How can I get a stgdefect universal ID(com.ibm.stg.attribute.universalId) from its id?
Now I can get a stgdefect id from its universal id. Conversely, does anyone know how to get its universal id from id?
Here is my code to get id from universal id:
public static int getIdFromUniID(ITeamRepository teamRepository, String uProject, String type, String uniID) throws TeamRepositoryException {
IProcessClientService pcs = (IProcessClientService) teamRepository.getClientLibrary(IProcessClientService.class);
IAuditableClient adc = (IAuditableClient) teamRepository.getClientLibrary(IAuditableClient.class);
IProjectArea upa = (IProjectArea) pcs.findProcessArea(URI.create(uProject.replaceAll(" ", "%20")), null, null);
IQueryableAttributeFactory uFactory = QueryableAttributes.getFactory(IWorkItem.ITEM_TYPE);
IQueryableAttribute uniAttr = uFactory.findAttribute(upa, "com.ibm.stg.attribute.universalId", adc, null);
IQueryableAttribute typeAttr = uFactory.findAttribute(upa, IWorkItem.TYPE_PROPERTY, adc, null);
AttributeExpression uExpression = new AttributeExpression(typeAttr, AttributeOperation.EQUALS, type);
AttributeExpression uTypeExpression = new AttributeExpression(uniAttr, AttributeOperation.EQUALS, uniID);
Term uTerm = new Term(Operator.AND);
uTerm.add(uExpression);
uTerm.add(uTypeExpression);
IQueryClient uQueryClient = (IQueryClient) teamRepository.getClientLibrary(IQueryClient.class);
IQueryResult<IResolvedResult<IWorkItem>> uResult = uQueryClient.getResolvedExpressionResults(upa, (Expression) uTerm, IWorkItem.FULL_PROFILE);
int ret = -1;
while (uResult.hasNext(null)) {
IResolvedResult<IWorkItem> resolve = uResult.next(null);
IWorkItem uWI = resolve.getItem();
System.out.println(uWI.getId());
ret = uWI.getId();
}
return ret;
}
Here is my code to get id from universal id:
public static int getIdFromUniID(ITeamRepository teamRepository, String uProject, String type, String uniID) throws TeamRepositoryException {
IProcessClientService pcs = (IProcessClientService) teamRepository.getClientLibrary(IProcessClientService.class);
IAuditableClient adc = (IAuditableClient) teamRepository.getClientLibrary(IAuditableClient.class);
IProjectArea upa = (IProjectArea) pcs.findProcessArea(URI.create(uProject.replaceAll(" ", "%20")), null, null);
IQueryableAttributeFactory uFactory = QueryableAttributes.getFactory(IWorkItem.ITEM_TYPE);
IQueryableAttribute uniAttr = uFactory.findAttribute(upa, "com.ibm.stg.attribute.universalId", adc, null);
IQueryableAttribute typeAttr = uFactory.findAttribute(upa, IWorkItem.TYPE_PROPERTY, adc, null);
AttributeExpression uExpression = new AttributeExpression(typeAttr, AttributeOperation.EQUALS, type);
AttributeExpression uTypeExpression = new AttributeExpression(uniAttr, AttributeOperation.EQUALS, uniID);
Term uTerm = new Term(Operator.AND);
uTerm.add(uExpression);
uTerm.add(uTypeExpression);
IQueryClient uQueryClient = (IQueryClient) teamRepository.getClientLibrary(IQueryClient.class);
IQueryResult<IResolvedResult<IWorkItem>> uResult = uQueryClient.getResolvedExpressionResults(upa, (Expression) uTerm, IWorkItem.FULL_PROFILE);
int ret = -1;
while (uResult.hasNext(null)) {
IResolvedResult<IWorkItem> resolve = uResult.next(null);
IWorkItem uWI = resolve.getItem();
System.out.println(uWI.getId());
ret = uWI.getId();
}
return ret;
}
One answer
This question is about a custom attribute in a custom process template with custom extensions. Please refer to your process people to understand the details about your custom attributes and their values.
Alternatively, provide more information what you try to achieve and the details of your process customization. At least enough example data and context that users can understand what your question is all about.
Alternatively, provide more information what you try to achieve and the details of your process customization. At least enough example data and context that users can understand what your question is all about.
Comments
Ralph Schoon
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER Aug 13 '14, 3:02 a.m.I fail to understand your question. Maybe you want to explain what you are trying to achieve? The other thing here, I have to assume the work item attribute com.ibm.stg.attribute.universalId is custom. You will have to check what type it is.