Cannot "Set linked Work Item" during "Create Work Item" usin

Description
pranav
Posts: 6
Joined: Sun Apr 13, 2014 5:49 am

Cannot "Set linked Work Item" during "Create Work Item" usin

Postby pranav » Sun Apr 13, 2014 5:55 am

Our company is shifting to Polarion. My role is to do some automation. Polarion Jave APIs are working well.
I can create workitems, set their title/descriptions and other attributes and commit to repo successfully.

I created 1 work item, let’s say “old work item”. And then I create another 1 work item, say “new work item”. Both are being created.
I am trying to link this “new work item” with the “old work item”
But seems like “.setLinkedWorkItems(..)” is not working, or maybe I am missing something. The programs compiles and runs without any warning.

Here is a piece of code from the context. Have a look.

Code: Select all

            sessionService.beginTransaction(); // to do just one TX
         
//newWorkItem(..) is my custom function which uses workitem constructor/setters to create & return a simple workitem
            WorkItem wi1 = newWorkItem("old related work item", "to be revise", "critical");
                        
            String wiURI1 = trackerService.createWorkItem(wi1);//create it
            System.out.println("\n"++" created!");

            //also tried commit and start new transaction, didn't worked
            //sessionService.endTransaction(false);
            //sessionService.beginTransaction();
            

            //preparing the LinkedWorkItem[] for the "setLinkedWorkItems" method            
            LinkedWorkItem lwi= new LinkedWorkItem();
            lwi.setWorkItemURI(wiURI1);
            LinkedWorkItem[] lwitm = new LinkedWorkItem[1];//just one element for time being.
            lwitm[0]=lwi;
            
            WorkItem wi2 = newWorkItem("new updated work item", "will have links to old workitems", "urgent");
            wi2.setLinkedWorkItems(lwitm);
            
            String wiURI2 = trackerService.createWorkItem(wi2);//create it
            System.out.println(wiURI2+ " created too!");
            
            sessionService.endTransaction(false);//false for No rollback but commit to repo
            
         



Your suggestions might be helpful. Thanks!

hseifert
Posts: 21
Joined: Wed Apr 17, 2013 12:10 pm
Location: Böblingen, Baden-Württemberg, Germany
Contact:

Re: Cannot "Set linked Work Item" during "Create Work Item"

Postby hseifert » Tue Apr 15, 2014 7:15 am

Hello.

I think you have to save the workitem after setting the link. Try to use the .save() method. I wrote a smaller code example. You have to set the revision and the ILinkRoleOpt for the role.

Code: Select all

sessionService.beginTransaction();
WorkItem motherWorkItem = newWorkItem("mother work item", "to be revise", "critical");
WorkItem childWorkItem = newWorkItem("child work item", "to be revise", "critical");

motherWorkItem.addLinkedItem(childWorkitem, <ILinkRoleOpt role>, <java.lang.String revision>, true);
motherWorkItem.save();

sessionService.endTransaction(false);
Kind regards.

Hagen

pranav
Posts: 6
Joined: Sun Apr 13, 2014 5:49 am

Re: Cannot "Set linked Work Item" during "Create Work Item"

Postby pranav » Wed Apr 16, 2014 6:50 am

Thank You for your suggestions :)

I was trying examples from "com.polarion.example.importer". It uses "com.polarion.alm.ws.client.*". There is no such method called save() in class "com.polarion.alm.ws.client.types.tracker.WorkItem".
I researched a bit and found out that it is found in interface "IWorkItem" of a package " com.polarion.alm.tracker.*" instead of " com.polarion.alm.ws.client.tracker.*"

I could not find example of using "ITrackerService" anywhere in SDK docs. How much it differs from the " TrackerWebService" of "com.polarion.alm.ws.client".
Can you suggest me some resources where I can find examples depicting a clearance of my scenario.

hseifert
Posts: 21
Joined: Wed Apr 17, 2013 12:10 pm
Location: Böblingen, Baden-Württemberg, Germany
Contact:

Re: Cannot "Set linked Work Item" during "Create Work Item"

Postby hseifert » Thu Apr 17, 2014 7:37 am

Hello.

Are you doing this from inside Polarion (eg. wiki page, workflow function, etc.) or outside? If outside: are you writing a Web Service Call or an Plugin for Polarion?
Kind regards.

Hagen

pranav
Posts: 6
Joined: Sun Apr 13, 2014 5:49 am

Re: Cannot "Set linked Work Item" during "Create Work Item"

Postby pranav » Tue Apr 22, 2014 8:53 am

I am doing this outside polarion using javaapplication in eclipse.
All i did was to download the polarion sdk.
I ran com.polarion.example.importer which was provided with the SDK.
It ran succesffuly created work items in my polarion server.
Now, I am modifyiung com.polarion.example.importer project to create 2 work items and link one of them with the other.
I have tried all combinations like begin and save transactions at steps, linking only after creation committed to actual server.
Please view my source code in the ExportToPolarion.txt attached file.

My question has now moreover become, How to use iTrackerService, and iWorkitems etc. interfaces to use save() function. Because it is nowhere in examples provided with sdk. view previous post in the thread where .save() was suggested.
Attachments
ExportToPolarion.txt
my source code
(9.45 KiB) Downloaded 233 times
Capture2.PNG
list of libraries
Capture2.PNG (14.53 KiB) Viewed 6952 times
Capture.PNG
list of libraries
Capture.PNG (48.47 KiB) Viewed 6952 times

martins
Posts: 181
Joined: Thu Nov 05, 2009 3:24 pm

Re: Cannot "Set linked Work Item" during "Create Work Item"

Postby martins » Wed Apr 23, 2014 9:29 am

Hello Pranav,

the example you are talking about uses the Webservice interface, as you can see in line 45 of the example source code:

Code: Select all

import com.polarion.alm.ws.client.tracker.TrackerWebService;

The according documentation for this service can be found in the SDK:
http://almdemo.polarion.com/polarion/sd ... rvice.html

To link two workitems you have to use function

Code: Select all

addLinkedItem(java.lang.String workitemURI, java.lang.String linkedWorkitemURI, EnumOptionId role)


As parameter you have to pass the URI property of the workitems and not the workitem object itself!

You don't need to "save()" because there's no such function in the tracker webservice. You just have to finish the transaction without "roleback".

Kind regards

Martin

pranav
Posts: 6
Joined: Sun Apr 13, 2014 5:49 am

Re: Cannot "Set linked Work Item" during "Create Work Item"

Postby pranav » Wed Apr 23, 2014 4:14 pm

Thanks for the reply. :)
Actually, I peeked into a source code of a plugin into github that appeared in google.
And found it already to use addLinkedItem(...) function from TrackerWebService class.

I am also using
com.polarion.alm.ws.client.types.tracker.WorkItem
class in my program. It contains a similar method
.setLinkedWorkItems(..)
as mentioned in the API Docs you gave.

Work is done. But I might come across methods with similar name with both of their classes being used. Can you differentiate the roles of those 2 method atleast. Because I think the generated API Doc in HTML is insufficient.

Also, Are com.polarion.alm.tracker.ITrackerService, ..iWorkItem and other similar interfaces only with used with the classLoader and Servlet?

Regards :)


Return to “Polarion Application Lifecycle Management (ALM)”

Who is online

Users browsing this forum: SteffPoint and 10 guests