How to get LookupTable into Reformat node's transformClass?

Hi,

my graph looks like this:

<?xml version="1.0" encoding="UTF-8"?>

the init() in myTranform class looks like this:

public boolean init(Properties props, DataRecordMetadata sourceRecordsMetadata, DataRecordMetadata targetRecordsMetadata) throws ComponentNotReadyException {

LookupTable lookup = getLookupTable(“lookup_product_types”);
if (!lookup.isInitialized()) {
lookup.init();
}

System.out.println("lookup name : " + lookup.getName());
System.out.println("lookup metadata : " + lookup.getMetadata());


}

the output is:
lookup name : null
lookup meta data : null

how can I pass lookup_product_types to myTransform class so that I can perform DB lookup?

any help is greatly appreciated :slight_smile:

Thanks,
albert

Hi, your graph and transformation class are correct and should work properly. Only there is small bug in DBLookupTable that it doesn’t take into account the table name. If you write System.out.println("lookup id : " + lookup.getId()); in your transformation you get the correct ID.

Hi Agata,

How about lookup meta data? i am still getting “null”… i need the lookup meta data in my init() to setup the lookup key:

public boolean init(Properties props, DataRecordMetadata sourceRecordsMetadata, DataRecordMetadata targetRecordsMetadata) throws ComponentNotReadyException {

LookupTable lookup = getLookupTable(“lookup_product_types”);
if (!lookup.isInitialized()) {
lookup.init();
}

System.out.println("lookup name : " + lookup.getName());
System.out.println("lookup metadata : " + lookup.getMetadata());

String lookupKeyStr = {“lookup_product_type_code”};
RecordKey key = new RecordKey(lookupKeyStr, lookupMetadata);
key.init();
lookup.setLookupKey(key);

}

Thanks,
al

Hi,
it seems that there is one more bug in DBLookupTable and metadata in lookup table definition are discarded; they are created during first get method. But you need to set record key for the metadata, which you join with lookup table (as in graphDBLookup.grf:

		// create key 
	    String[] lookupKeyStr={"EmployeeID"};
		RecordKey key=new RecordKey(lookupKeyStr,sourceMetadata[0]);
		key.init();
		mylookup.setLookupKey(key);

)
By the way for joining data with database could be better DBJoin or LookupJoin component.