on 02-18-2009 6:42 AM
Hi,
How to retrieve lookup table values using MDM java API.
Thanks.
Hi Jyothi,
Check the below code
TableId lookupTableId = repositorySchema.getTableId("Test_Lookup");
FieldId[] lookupFields = new FieldId[2];
lookupFields[0] = repositorySchema.getFieldId("Test_Lookup", "Name");
lookupFields[1] = repositorySchema.getFieldId("Test_Lookup", "Code");
ResultDefinition rd = new ResultDefinition(lookupTableId);
rd.setSelectFields(lookupFields);
RetrieveLimitedRecordsCommand retrieveLimitedRecordsCommand = new RetrieveLimitedRecordsCommand(simpleConnection);
retrieveLimitedRecordsCommand.setSession(authenticateUserSessionCmd.getSession());
retrieveLimitedRecordsCommand.setResultDefinition(rd);
try
{
retrieveLimitedRecordsCommand.execute();
totalRecord = retrieveLimitedRecordsCommand.getRecords().getCount();
}
Regards,
Jitesh Talreja
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jyothi,
Please find smaple code below
UserSessionContext context = new UserSessionContext(serverName,repositoryName,defaultLang,username);*
SessionManager session = SessionManager.getInstance();
String userSession = session.createSession(context, SessionTypes.USER_SESSION_TYPE, password);
MetadataManager metadataManager = MetadataManager.getInstance(); metadataManager.registerDataNotifications(context, password);
RepositorySchemaEx repositorySchema = metadataManager.getRepositorySchema(context);
//Retrieve Lookup table Data
TableSchema tableSchema = repositorySchema.getTableSchema(tableName);
ResultDefinition resultDef = new ResultDefinition(tableSchema.getTable().getId());
resultDef.setSelectFields(tableSchema.getFieldIds());
try {
RetrieveLimitedRecordsCommand limitingCommand = new RetrieveLimitedRecordsCommand(context);
limitingCommand.setResultDefinition(resultDef);
limitingCommand.execute();
} catch (SessionException e) {
} catch (ConnectionException e) {
} catch (CommandException e) {
} *
// Result Set
RecordResultSet resultSet = limitingCommand.getRecords();
Record [] records = resultSet.getRecords();
for (int i = 0; i < records.length; i++) {
Record record = records<i>;
System.out.println("Record ID: "+ record.getId());
System.out.println("Code Field Value: "+
record.getFieldValue(tableSchema.getFieldId(u201CCodeu201D)).toString());
System.out.println("Description Field Value: "+
record.getFieldValue(tableSchema.getFieldId (u201CDescriptionu201D)).toString());
}
Thanks,
Veeru.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
i think the blog is based on MDM4j. Can somebody give me the code sample for the same.
Thanks.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi jyothi,
You can search the lookup tables the same way you search the main table with the RetrieveLimitedRecordsCommand, passing the lookup TableId to the Search object and ResultDefinition object that the command uses. If you want all of the values just pass the command a Search object with no constraints.
-Greg
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jyothi,
Refer /people/anand.chandrashekar/blog/2006/05/27/populating-lookup-fields-using-java-api
Hope it helps.
Thanks,
Minaz
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.