on 05-21-2009 5:00 AM
Hi Experts,
Using MDM JAVA APIS
I need some small info.I want to fetch records from MDM repository using some search criteria. Am able to fetch the records using one search criteria but how do we have to do for multiple search criteria.
snippet/example would help.
i want to search with three search creteria.
thanks
Narendra
Hi,
For clubbing search criteria you have to use SearchGroup class. A SearchGroup instance can combine multiple search item using Logical Operators like AND / OR.
A sample code can be like this,
SearchDimension searchDimension1 = new FieldSearchDimension(FieldId1);
SearchConstraint searchConstraint1 = new DateTimeSearchConstraint(MdmValue, DateTimeSearchConstraint.LESS_THAN);
SearchGroup searchGroup = new SearchGroup();
searchGroup.addSearchItem(searchDimension1 ,searchConstraint1 );
searchGroup.addSearchItem(searchDimension2 ,searchConstraint2);
searchGroup.addSearchItem(searchDimension3 ,searchConstraint3);
serachGroup.setComparisonOperator(SearchGroup.AND_OPERATOR / SearchGroup.OR_OPERATOR);
Search search = new Search();
search.addSearchItem(searchGroup);
Pass search object to RetrieveLimitedRecordsCommand.
Regards,
Suresh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
A SearchGroup works fine if the same field is being searched, for example field A = value c OR field A = value b. If your search constraints are for different fields just keep adding them to the Search object with the addSearchItem method, for example A = b && D = e.
From the API javadocs.
1. At most one level of nesting is allowed.
For examples:
A=a && B=b && C=c // no nesting, OK
(A=a || A=b) &&(C=c) // one level nesting, OK
((A=a || A=b) && (C=c)) && (D=d) // two or more level nesting, not OK
2. All field dimensions within a search group needs to be the same field dimension.
For examples:
(A=a || A=b) // OK
(A=a || B=b) // not OK
thanks a lot
Regards
Narendra
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
91 | |
10 | |
10 | |
9 | |
9 | |
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.