Creating items programmatically.
11 answers
What I tried to do was this:
fTeamRepo = login();
IWorkItem work1 = (IWorkItem) IWorkItem.ITEM_TYPE.createItem(fTeamRepo);
IWorkItemClient workItemClient= (IWorkItemClient) fTeamRepo.getClientLibrary(IWorkItemClient.class);
IWorkItemWorkingCopyManager manager = workItemClient.getWorkItemWorkingCopyManager();
IWorkItemHandle handle = (IWorkItemHandle) work1.getItemHandle();
manager.connect(handle, IWorkItem.SMALL_PROFILE, null);
However, I got this error:
com.ibm.team.repository.common.ItemNotFoundException: CRJAZ0215I Item not found: com.ibm.team.workitem.common.internal.model.impl.WorkItemHandleImpl@18741874 (stateId: <unset>, itemId: , origin: com.ibm.team.repository.client.internal.TeamRepository@67866786, immutable: <unset>)
I ran this program on local mode, connecting to the default Derby repositoryDB.
fTeamRepo = login();
IWorkItem work1 = (IWorkItem) IWorkItem.ITEM_TYPE.createItem(fTeamRepo);
IWorkItemClient workItemClient= (IWorkItemClient) fTeamRepo.getClientLibrary(IWorkItemClient.class);
IWorkItemWorkingCopyManager manager = workItemClient.getWorkItemWorkingCopyManager();
IWorkItemHandle handle = (IWorkItemHandle) work1.getItemHandle();
manager.connect(handle, IWorkItem.SMALL_PROFILE, null);
However, I got this error:
com.ibm.team.repository.common.ItemNotFoundException: CRJAZ0215I Item not found: com.ibm.team.workitem.common.internal.model.impl.WorkItemHandleImpl@18741874 (stateId: <unset>, itemId: , origin: com.ibm.team.repository.client.internal.TeamRepository@67866786, immutable: <unset>)
I ran this program on local mode, connecting to the default Derby repositoryDB.
Hi Christof,
I looked at the wiki page that you pointed to, but I noticed that it didn't explain how I could create a new project area programmatically. So, I went off to try to create project area as follow:
IProjectArea projectArea = itemService.createProjectArea();
projectArea.setName("Test Project Area");
/*IProcessDefinition processDef = itemService.findProcessDefinition("Eclipse Way",
IProcessClientService.ALL_PROPERTIES, null);*/
List procDefs = itemService.findAllProcessDefinitions(IProcessClientService.ALL_PROPERTIES, null);
projectArea.setProcessDefinition((IProcessDefinition) procDefs.get(0));
IContributor thisUser = fTeamRepo.loggedInContributor();
projectArea.addMember(thisUser);
IProjectArea savedProject = (IProjectArea) itemService.save(projectArea, null);
However, I couldn't find any pre-defined IProcessDefinition and when I tried to save the projectArea with null process definition, it gave me an error that I don't have a valid process definition associated to the project area. Can you help me out, please?
Thanks,
Petcharat
I looked at the wiki page that you pointed to, but I noticed that it didn't explain how I could create a new project area programmatically. So, I went off to try to create project area as follow:
IProjectArea projectArea = itemService.createProjectArea();
projectArea.setName("Test Project Area");
/*IProcessDefinition processDef = itemService.findProcessDefinition("Eclipse Way",
IProcessClientService.ALL_PROPERTIES, null);*/
List procDefs = itemService.findAllProcessDefinitions(IProcessClientService.ALL_PROPERTIES, null);
projectArea.setProcessDefinition((IProcessDefinition) procDefs.get(0));
IContributor thisUser = fTeamRepo.loggedInContributor();
projectArea.addMember(thisUser);
IProjectArea savedProject = (IProjectArea) itemService.save(projectArea, null);
However, I couldn't find any pre-defined IProcessDefinition and when I tried to save the projectArea with null process definition, it gave me an error that I don't have a valid process definition associated to the project area. Can you help me out, please?
Thanks,
Petcharat
If you're just writing a JUnit test, then you'll want to create a
process definition as well. (If you're writing real code, then you'll
want to get a project area from some other source, not create one
yourself.) Process definition creation is pretty straight-forward. The
biggest piece of code you'll have to write will be something to create
the IContent items that persist the process specification and process
state. For our JUnit tests, we just read these from XML files that we
keep in our test projects.
Take a look at AbstractTeamProcessTest#setupProjectArea(...). If you
walk through this code, you'll find all the pieces you need.
Jared Burns
Jazz Process Team
petcharatv wrote:
process definition as well. (If you're writing real code, then you'll
want to get a project area from some other source, not create one
yourself.) Process definition creation is pretty straight-forward. The
biggest piece of code you'll have to write will be something to create
the IContent items that persist the process specification and process
state. For our JUnit tests, we just read these from XML files that we
keep in our test projects.
Take a look at AbstractTeamProcessTest#setupProjectArea(...). If you
walk through this code, you'll find all the pieces you need.
Jared Burns
Jazz Process Team
petcharatv wrote:
Hi Christof,
I looked at the wiki page that you pointed to, but I noticed that it
didn't explain how I could create a new project area
programmatically. So, I went off to try to create project area as
follow:
IProjectArea projectArea = itemService.createProjectArea();
projectArea.setName("Test Project Area");
/*IProcessDefinition processDef =
itemService.findProcessDefinition("Eclipse Way",
IProcessClientService.ALL_PROPERTIES, null);*/
List procDefs =
itemService.findAllProcessDefinitions(IProcessClientService.ALL_PROPERTIES,
null);
projectArea.setProcessDefinition((IProcessDefinition)
procDefs.get(0));
IContributor thisUser = fTeamRepo.loggedInContributor();
projectArea.addMember(thisUser);
IProjectArea savedProject = (IProjectArea)
itemService.save(projectArea, null);
However, I couldn't find any pre-defined IProcessDefinition and when I
tried to save the projectArea with null process definition, it gave me
an error that I don't have a valid process definition associated to
the project area. Can you help me out, please?
Thanks,
Petcharat
Hi,
Sorry, I still have one last small question. I was trying to create a new category and save it to the new project area that I created by doing this:
// Setup categories in the project area.
IAuditableClient auditableClient= (IAuditableClient) fTeamRepo.getClientLibrary(IAuditableClient.class);
CategoriesManager catManager = CategoriesManager.createInstance(auditableClient,
fProjectArea, null);
CategoryTreeNode rootNode = catManager.getRoot();
CategoryTreeNode childCat = rootNode.createChil(CATEGORY_ID);
catManager.save(null);
But I got an error: Permission denied, I couldn't save the category.
If I continued to create a work item, using:
IAuditableClient auditableClient= (IAuditableClient) fTeamRepo.getClientLibrary(IAuditableClient.class);
WorkItemInitialization operation= new WorkItemInitialization(summary, category);
IWorkItemHandle handle= operation.run(workItemType, null);
IWorkItem workItem= auditableClient.resolveAuditable(handle, IWorkItem.FULL_PROFILE, null);
I got an error ItemNotFound, saying it couldn't find the Category that I gave as argument.
Can you help me out, please?
Thanks
Sorry, I still have one last small question. I was trying to create a new category and save it to the new project area that I created by doing this:
// Setup categories in the project area.
IAuditableClient auditableClient= (IAuditableClient) fTeamRepo.getClientLibrary(IAuditableClient.class);
CategoriesManager catManager = CategoriesManager.createInstance(auditableClient,
fProjectArea, null);
CategoryTreeNode rootNode = catManager.getRoot();
CategoryTreeNode childCat = rootNode.createChil(CATEGORY_ID);
catManager.save(null);
But I got an error: Permission denied, I couldn't save the category.
If I continued to create a work item, using:
IAuditableClient auditableClient= (IAuditableClient) fTeamRepo.getClientLibrary(IAuditableClient.class);
WorkItemInitialization operation= new WorkItemInitialization(summary, category);
IWorkItemHandle handle= operation.run(workItemType, null);
IWorkItem workItem= auditableClient.resolveAuditable(handle, IWorkItem.FULL_PROFILE, null);
I got an error ItemNotFound, saying it couldn't find the Category that I gave as argument.
Can you help me out, please?
Thanks
Your process template for tests needs to include permissions for saving categories:
<project>
...other configuration...
<permissions>
<role>
...other operations...
<project>
<action>
</project>
</role>
</permissions>
</project>
HTH,
Christof
Jazz Work Item team
<project>
...other configuration...
<permissions>
<role>
...other operations...
<project>
<action>
</project>
</role>
</permissions>
</project>
HTH,
Christof
Jazz Work Item team
Hi
i am also trying to do the same things. I have to write junit test case for which i need to create project area and work items in that project area.
I tried searching in the Jazz code for AbstractTeamProcessTest , but i could not find it. Since this post is pretty old , maybe the test has been changed. Can u please help me in finding the code for doing the same.
Thanks
Yogesh
i am also trying to do the same things. I have to write junit test case for which i need to create project area and work items in that project area.
I tried searching in the Jazz code for AbstractTeamProcessTest , but i could not find it. Since this post is pretty old , maybe the test has been changed. Can u please help me in finding the code for doing the same.
Thanks
Yogesh
Hello,
The AbstractTeamProcessTest is in the com.ibm.team.process.client.tests package.
Martha
Jazz Developer
The AbstractTeamProcessTest is in the com.ibm.team.process.client.tests package.
Martha
Jazz Developer
Hi
i am also trying to do the same things. I have to write junit test case for which i need to create project area and work items in that project area.
I tried searching in the Jazz code for AbstractTeamProcessTest , but i could not find it. Since this post is pretty old , maybe the test has been changed. Can u please help me in finding the code for doing the same.
Thanks
Yogesh
page 1of 1 pagesof 2 pages