Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

Setting priority within a participant

I'm sure this is really easy, but for the life of me, I can't get it to work.

I am in a Server-side participant for a WorkItemSave and I just need to set the value of the Priority built-in attribute.

I have the workingCOpy, and I can do workingCopy.setPriority(iPriorityIdentifier); and then _service.saveWorkItem3();

but the setPriority takes an Identifier<IPriority> which I am struggling to get.  
Anybody have a snippet they can help me with?

Susan

0 votes


Accepted answer

Permanent link
well, the priority is an enum, enums have ILiterals and these have identifiers.
from my dump workitem utility

// this will throw exception if not enumeration
                            IEnumeration<ILiteral> enumeration = (IEnumeration<ILiteral>) workItemCommon
                                    .resolveEnumeration(ia, monitor);
                            if (enumeration != null)
                            {
                                String[] iaval = ia
                                        .getValue(auditableClient, workItem,
                                                monitor).toString().split(":");
                                if (iaval.length > 1 && iaval[1] != null)
                                {
                                    List<ILiteral> enumerationLiterals = enumeration
                                            .getEnumerationLiterals();
                                    for (ILiteral literal : enumerationLiterals)
                                    {
                                       Identifier i=literal.getIdentifier2();  <------
                                        if (literal.getIdentifier2()
                                                .getStringIdentifier()
                                                .equalsIgnoreCase(iaval[1]))
                                        {
Susan Hanson selected this answer as the correct answer

0 votes

Comments

Right, I have almost all of that already, but am missing the IAttributeHandle for Priority to pass in.
private Identifier getLiteralEqualsString(String name, IAttributeHandle ia) throws TeamRepositoryException {
  IWorkItemServer wiService = (IWorkItemServer) getService(IWorkItemServer.class);
  Identifier literalID = null;
  IEnumeration en = wiService.resolveEnumeration(ia, null);
  List literals = en.getEnumerationLiterals();
        for (Iterator iter = literals.iterator(); iter.hasNext();) {
            ILiteral iLiteral = (ILiteral) itor.next();
            if (iLiteral.getName().equals(name)) {
                literalID = iLiteral.getIdentifier2();
                break;
            }
        }
        return literalID;
    }

nevermind .. duh
IAttribute prioAttr = _service.findAttribute(workItem.getProjectArea(), IWorkItem.PRIORITY_PROPERTY, null);

All is working now!

Your answer

Register or log in to post your answer.

Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,927

Question asked: Aug 27 '14, 5:52 p.m.

Question was seen: 3,267 times

Last updated: Aug 27 '14, 9:52 p.m.

Confirmation Cancel Confirm