Issue while accessing workitems from repository using server side api
Hello Everyone,
I am using CLM 6.0.6.
I want to develop an Advisor plugin which should allow only a single occurrence of value in attribute tcr_id which is of type Large String.
I have created below code using server side java api to fetch all workitems from repository which contains some specific value in custom attribute tcr_id.
tcr_id contains value like: "124-"
Code is below:
///////////////////////////////////////////////////////
IQueryableAttribute projectareaAttribute= QueryableAttributes
.getFactory(IWorkItem.ITEM_TYPE).findAttribute(projectArea,
IWorkItem.PROJECT_AREA_PROPERTY, fAuditableCommon,
monitor);
//get workitem type attribute
IQueryableAttribute typeAttribute = QueryableAttributes.getFactory(
IWorkItem.ITEM_TYPE).findAttribute(projectArea,
IWorkItem.TYPE_PROPERTY, fAuditableCommon, monitor);
IQueryableAttribute proxyIDAttribute = QueryableAttributes.getFactory(
IWorkItem.ITEM_TYPE).findAttribute(projectArea,"tcr.id", fAuditableCommon,
monitor);
Expression inProjectAreaExpression = new AttributeExpression(
projectareaAttribute, AttributeOperation.EQUALS, projectArea);
Expression isTypeExpression = new AttributeExpression(typeAttribute,
AttributeOperation.EQUALS,
"task");
Expression proxyIDExpression = new AttributeExpression(
proxyIDAttribute, AttributeOperation.CONTAINS, CAIDobject); //Get the value of large string attribute into CAIDobject which of type Object
Term term = new Term(Operator.AND);
term.add(inProjectAreaExpression);
term.add(isTypeExpression);
term.add(proxyIDExpression);
IQueryResult results = fQueryCommon.getExpressionResults(
projectArea, term);
List <WorkItem>Sameworkitems = new ArrayList<WorkItem>();
int resultSize = results.getResultSize(monitor).getTotal(); //queryResult.getResultSize(utility.monitor).getTotal();
System.out.println(resultSize);
while(results.hasNext(monitor))
{
IResult result = (IResult) results.next(monitor);
IWorkItemHandle resultHandle = (IWorkItemHandle) result.getItem();
IWorkItem BPM = (IWorkItem) wis
.getAuditableCommon()
.resolveAuditable(resultHandle, IWorkItem.FULL_PROFILE,
monitor).getWorkingCopy();
}
/////////////////////////
Its working till line of code: System.out.println(resultSize);
But I got exception in line of above code "while(results.hasNext(monitor)".
Kindly checked the above code, Is it correct to fetch workitems based on custom attribute value???
Kindly provide me assistance.
Regards
Pallavi
Comments
Pallavi Deore
Jun 18 '19, 8:01 a.m.Luca Martinucci
Jun 18 '19, 8:43 a.m.Pallavi Deore
Jun 18 '19, 8:57 a.m.