Hi Agata,
you are right, getKeyMetadata() did throw an exception: “Reason: Can’t get metadata from database”… sorry for the confusion…
if I cannot get the dbMetadata, since it is not instantiated immediately after init(), how can I create the RecordKey for creating the lookup and seeking?
I would not be able to create keyRecord in the transform() in my BaseRules class (from my code snipplet below) if keyMetadata is NULL… so what should I do?
public class BaseRules extends DataRecordTransform {
… …
public boolean init() throws ComponentNotReadyException {
… …
LookupTable lookupTable = getLookupTable(“LOOKUPTABLE_0”);
// initialize lookup table
if (!lookupTable.isInitialized()) {
lookupTable.init();
}
logger.info(new StringBuffer("Lookup table “).append(lookupTblID).append(” metadata : ").append(lookupTable.getMetadata()).toString());
… …
} // end init()
public int transform(DataRecord _source, DataRecord _target) throws TransformException {
DataRecordMetadata keyMetadata = lookupTable.getMetadata();
DataRecord keyRecord = new DataRecord(keyMetadata);
keyRecord.init();
RecordKey key = new RecordKey(keyMetadata.getFieldNamesArray(), keyMetadata);
key.init();
// create lookup query based on requested key
Lookup lookup = null;
try {
lookup = lookupTable.createLookup(key, keyRecord);
} catch (ComponentNotReadyException e) {
logger.error(new StringBuffer(“Error creating lookup query for lookup table!!”).toString());
return null;
}
// setup the key record value
keyRecord.getField(i).fromString(“COM”);
// try to lookup based on specified parameter
lookup.seek(keyRecord);
// get results, if there are any
if (lookup.hasNext()) {
Object value = lookup.next();
… …
}
… …
} // end transform()
… …
} // end BaseRules
Thanks,
al