It's all about the answers!

Ask a question

How to set new value to "Filed Against" attribute.


radhika bandari (10675) | asked Nov 07 '11, 6:44 a.m.
I need to check the existing value of "Filed Against" value and then set it to new value.
Appriciate any suggessions or Piece of code.

Thanks in Advance

Radhika Bandari

3 answers



permanent link
Ralph Schoon (63.1k33646) | answered Nov 07 '11, 7:44 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Please consider to search the development WiKi, especially the SDK. Here is some example code https://jazz.net/wiki/bin/view/Main/ProgrammaticWorkItemCreation

I think there is no example for modifying a work item. You could look that up in the SDK itself. This code has worked for me:



ITeamRepository teamRepository = TeamPlatform
.getTeamRepositoryService().getTeamRepository(repositoryURI);
teamRepository.registerLoginHandler(new LoginHandler(userId, password));
teamRepository.login(null);

IWorkItemClient workItemClient = (IWorkItemClient) teamRepository
.getClientLibrary(IWorkItemClient.class);

URI uri = URI.create(projectAreaName.replaceAll(" ", "%20"));
IProjectArea projectArea = (IProjectArea) processClient
.findProcessArea(uri, null, null);
if (projectArea == null) {
System.out.println("Project area not found.");
return false;
}

int id = new Integer(idString).intValue();

IWorkItem workItem = workItemClient.findWorkItemById(id, IWorkItem.SMALL_PROFILE, null);
IWorkItemWorkingCopyManager wcm = workItemClient.getWorkItemWorkingCopyManager();
wcm.connect(workItem, IWorkItem.FULL_PROFILE, null);

try {
WorkItemWorkingCopy wc = wcm.getWorkingCopy(workItem);

wc.getWorkItem().setHTMLSummary(XMLString.createFromPlainText(summary));
IDetailedStatus s = wc.save(null);
if (!s.isOK()) {
throw new TeamRepositoryException("Error saving work item",
s.getException());
}
} finally {
wcm.disconnect(workItem);
}



The filed against is



ICategoryHandle category = workItemClient.findCategoryByNamePath(
projectArea, path, null);

wc.getWorkItem().setCategory(category )



permanent link
radhika bandari (10675) | answered Nov 08 '11, 1:00 a.m.
Hi,

Thanks for your reply. My code looks like this. I tried getting existin category value.

import com.ibm.team.repository.client.IItemManager;
import com.ibm.team.repository.client.ITeamRepository;

IItemManager itm = teamRepository.itemManager();
//get existing category value.
ICategory category = (ICategory) itm.fetchCompleteItem(parentWorkItem.getCategory(), IItemManager.DEFAULT, monitor);
System.out.println("This is category: " + category.getName());

when I use above import statements, the plugin itself is not deployed on the server. It is giving this message

State
CopyAttributeValuesToChildWI (Operation Advisor) completed successfully.

what could be the probelm.
And I neednot change complete category list to new list of values, but I need to change the selected value against Filed Against field before saving workitem.
Please suggest me on this issue.
Regards,
Radhika

permanent link
radhika bandari (10675) | answered Nov 16 '11, 1:11 a.m.
Hi Ralph,

To work with ITeamRepository, IWorkItemClient I have imported respective packages
import com.ibm.team.workitem.client.IWorkItemClient;
import com.ibm.team.repository.client.ITeamRepository;
and added corresponding pulg-ins in Dependencies tab plug-in.xml.


If I add these plug-ins in Dependencies tab, the advisor plug-in is not deployed into server. These two packages are related to client.
I have checked windows->preferences->plug-in development->Target platform's Target Definition It has all the plug-ins listed there.

What is the procedure I need to follow.

Thanks in Advance,
Radhika Bandari

Your answer


Register or 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.