on 12-12-2008 5:29 AM
Hi,
I have a requirement on matching strategy. I have two repositories A and B. I need to take the record from repository A and i have to execute the matching strategy in repository B using the strategies in B. How we can do this through JAVA API. Two repositories are having same schema.
Thanks.
Hi,
It is possible to use ExecuteMatchingStrategyForNewRecordValuesCommand API command for that.
This command enables matching a virtual record which does not exist at the repository, against the current repository with and it's strategies.
The concept to implement your requirements is:
1) Retrieve the record from repository A.
2) Use the API RecordFactory.createEmptyRecord to create a record in repository B. Fill that record with field values from the record retrieved at step 1.
3) Use ExecuteMatchingStrategyForNewRecordValuesCommand API to match the new record with Repository B.
Regards
Orit
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Orit, I tried with ExecuteMatchingStrategyForNewRecordValuesCommand command, i got the matchingtask id after executing the matching. But i could not able to retrieve the matching result. I am using RetrieveMatchingResultCommand command, it is giving NullPointer Exception. Can you please help me.
Thanks,
Sreenivasulu Thimmanapalli.
Hi,
Here is the method for matching external record:
// Define source record
Record newRecord = RecordFactory.createEmptyRecord(repositorySchema.getTableId(mainTable.getTableName()));
// Populate the new record with values
// Build strategy source records array with the new record you have created
Record[] sourceRecords = ;
// Build target records search object
Search targetSearch = getSearchObject(...);
// Execute matching strategy
ExecuteMatchingStrategyForNewRecordValuesCommand
executeMatchingStrategyForNewRecordValuesCommand = new
ExecuteMatchingStrategyForNewRecordValuesCommand(connection);
executeMatchingStrategyForNewRecordValuesCommand.setSession(session);
executeMatchingStrategyForNewRecordValuesCommand.setStrategyId(matchingStrat
egy.getId());
executeMatchingStrategyForNewRecordValuesCommand.setSource(sourceRecords);
executeMatchingStrategyForNewRecordValuesCommand.setTarget(targetSearch);
executeMatchingStrategyForNewRecordValuesCommand.execute();
// Build result definition for matches records retreival
ResultDefinition matchResult = new ResultDefinition(_mainTableID);
// Retrieve matching records
RetrieveMatchedRecordsCommand retrieveMatchedRecordsCommand = new
RetrieveMatchedRecordsCommand(connection);
retrieveMatchedRecordsCommand.setResultDefinition(matchResult);
retrieveMatchedRecordsCommand.setSession(session);
retrieveMatchedRecordsCommand.setMatchingTaskId(executeMatchingStrategyForNe
wRecordValuesCommand.getMatchingTaskId());
// For external record matching, the source record Id should be -1 !!
retrieveMatchedRecordsCommand.setRecordId(new RecordId(-1));
retrieveMatchedRecordsCommand.execute();
MatchedRecordResult matchedRecordResults[] =
retrieveMatchedRecordsCommand.getMatchingResult().getMatchedRecordResults();
//Iterate through the results
matchedRecords = new MatchResult[matchedRecordResults.length];
Record record;
for (i = 0; i < matchedRecordResults.length; i++)
{
record = matchedRecordResults<i>.getMatchedRecord();
//logic for processins matched record
}
Regards
Orit
User | Count |
---|---|
85 | |
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.