20-Turquoise
October 4, 2010
Question
How to define QuerySpec for latest rev, iteration and UDA = some value
- October 4, 2010
- 3 replies
- 2544 views
I am attempting to create a QuerySpec that will search for the latest
revision, latest iteration, of all EPMDocuments that have a user defined
attribute RELEASE_NUMBER = to some value. I have found code snippets here
in this forum that is getting me close. What I have so far is this:
String MyReleaseNumber = "2010-426";
QuerySpec qs = new QuerySpec(EPMDocument.class);
int defindex = qs.addClassList(StringDefinition.class,false);
int valueindex = qs.addClassList(StringValue.class,true);
qs.appendWhere(new SearchCondition(StringDefinition.class, StringDefinition.NAME, SearchCondition.EQUAL, "RELEASE_NUMBER"),defindex );
qs.appendAnd();
qs.appendWhere(new SearchCondition(StringValue.class, StringValue.VALUE, SearchCondition.EQUAL, MyReleaseNumber),valueindex );
qs.appendAnd();
qs.appendWhere(new SearchCondition(StringDefinition.class, "thePersistInfo.theObjectIdentifier.id", StringValue.class, "definitionReference.key.id"), new int[] { defindex, valueindex });
qs.appendAnd();
qs.appendWhere(new SearchCondition(EPMDocument.class, "iterationInfo.latest", "TRUE"));
System.out.println("Query String:\n" + qs.toString());
What this gives is the following query string:
SELECT A0.*,A2.*
FROM wt.epm.EPMDocument A0,wt.iba.definition.StringDefinition A1,wt.iba.value.StringValue A2
WHERE (A1.name = 'RELEASE_NUMBER') AND (A2.value = '2010-426') AND (A1.idA2A2 = A2.idA3A6) AND (A0.latestiterationInfo = 1)
What I am lacking is 2 parts.
1. The part that joins StringDefinition and EPMDocument. This should look like
"and (A2.IDA3A4 = A0.IDA2A2)" How do I get the magic combination of appendWhere
and SearchCondition to give this simple condition???
2. The part that returns only the latest revision. I am not even sure what this
part of the query should look like.
Does anybody have any pointers or helpful hints on this?
Attached is a screenshot of a very similar query I have defined in the advanced
search page.
Thanks
--
revision, latest iteration, of all EPMDocuments that have a user defined
attribute RELEASE_NUMBER = to some value. I have found code snippets here
in this forum that is getting me close. What I have so far is this:
String MyReleaseNumber = "2010-426";
QuerySpec qs = new QuerySpec(EPMDocument.class);
int defindex = qs.addClassList(StringDefinition.class,false);
int valueindex = qs.addClassList(StringValue.class,true);
qs.appendWhere(new SearchCondition(StringDefinition.class, StringDefinition.NAME, SearchCondition.EQUAL, "RELEASE_NUMBER"),defindex );
qs.appendAnd();
qs.appendWhere(new SearchCondition(StringValue.class, StringValue.VALUE, SearchCondition.EQUAL, MyReleaseNumber),valueindex );
qs.appendAnd();
qs.appendWhere(new SearchCondition(StringDefinition.class, "thePersistInfo.theObjectIdentifier.id", StringValue.class, "definitionReference.key.id"), new int[] { defindex, valueindex });
qs.appendAnd();
qs.appendWhere(new SearchCondition(EPMDocument.class, "iterationInfo.latest", "TRUE"));
System.out.println("Query String:\n" + qs.toString());
What this gives is the following query string:
SELECT A0.*,A2.*
FROM wt.epm.EPMDocument A0,wt.iba.definition.StringDefinition A1,wt.iba.value.StringValue A2
WHERE (A1.name = 'RELEASE_NUMBER') AND (A2.value = '2010-426') AND (A1.idA2A2 = A2.idA3A6) AND (A0.latestiterationInfo = 1)
What I am lacking is 2 parts.
1. The part that joins StringDefinition and EPMDocument. This should look like
"and (A2.IDA3A4 = A0.IDA2A2)" How do I get the magic combination of appendWhere
and SearchCondition to give this simple condition???
2. The part that returns only the latest revision. I am not even sure what this
part of the query should look like.
Does anybody have any pointers or helpful hints on this?
Attached is a screenshot of a very similar query I have defined in the advanced
search page.
Thanks
--
