Setting priority within a participant
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
Accepted answer
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]))
{
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!