cancel
Showing results for 
Search instead for 
Did you mean: 

Filtering/Searching main table records by Tuple values using MDM java API

Former Member
0 Kudos

Hi there,

We would like to retrieve Vendor records based on a supplied contact personu2019s e-mail address.

The contact personu2019s e-mail address is stored in a tuple attached to main table u201CVendor.u201D The field the tuple is attached to in the u201CVendoru201D table is u201CVendorsContactsu201D and the field in the tuple that contains the e-mail address field is called u201CContactEmailu201D.

The code we wrote so far looks something like this but return no results. Any advice would be appreciated.


TableId tableId = repoSchema.getTableId(u201CVendoru201D);
TableProperties tableProperties =  repoSchema.getTable(tableId);
Search search = new Search(tableId);

//This is the tuple field in the Vendor table
FieldId ffFieldId = repoSchema.getFieldId(u201CVendoru201D,u201CVendorContactsu201D);
FieldId ffLookFieldId = repoSchema.getFieldId(u201CVendoru201D, u201CContactEmailu201D);

//Set up the lookup path
FieldId[] fieldList = {ffFieldId, ffLookFieldId};
sd = new FieldSearchDimension(fieldList);

SearchConstraint sc = new TextSearchConstraint(searchElement.getFieldValue(),
				TextSearchConstraint.CONTAINS);
search.addSearchItem(sd, sc);

//Set up the result definition
ResultDefinitionEx resDef = new ResultDefinitionEx(tableProperties.getCode(),
			  repositoryBean.getUserSessionContext());	
resDef.setLoadAttributes(false);	  
resDef.setFieldSelectionType(resDef.ALL_FIELDS);
	  
// Create and execute RetrieveLimitedRecordsExCommand
  RetrieveLimitedRecordsExCommand cmd;

try {
cmd = new RetrieveLimitedRecordsExCommand(repositoryBean.getUserSessionContext());
		
	cmd.setSearch(search);
	  	 
	cmd.setResultDefinition(resDef);
	cmd.execute();
			
	// Get results
	resultSet = cmd.getRecords(); 
		
} catch (CommandException e) {
		
	logger.errorT(e.getMessage());
}

Edited by: Christiaan du Plessis on Jun 14, 2010 8:48 AM

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Found the issue with the code above. We were using "Vendor" table for the tuple field. Adjusting the qouted code as follows made it work:

//FieldId ffLookFieldId = repoSchema.getFieldId(u201CVendoru201D, u201CContactEmailu201D);  

//insert tjhos

FieldId ffLookFieldId = null;
if (ffFieldId .isTuple()){
  TupleFieldProperties fpTuple = (TupleFieldProperties) fpLookup;					  
  TupleDefinitionSchema tupleDef = repoSchema.getTupleDefinitionSchema(fpTuple.getTupleDefinitionId());
   ffLookFieldId = tupleDef.getFieldId(searchElement.getField().getLookupFieldName());
}