java - Polarion WorkItem class getter methods returning null -
i attempting write java program gets work record information off of polarion , writes dat file later use.
i have connected our servers , have retrieved workitem
objects, none of getter methods (besides geturi()
) seem work, poses problem since need use workitem
class's getworkrecords()
method satisfy requirements of project.
i have tried of getter methods class on both our main polarion server , our 'staging' server, use kind of testing area things such program trying write , on have full permissions.
regardless of permissions, querying dummy workitems created , assigned myself, there shouldn't permissions issues since attempting view own workitems.
here code program:
package test; //stg= 10.4.1.50 //main= 10.4.1.10 import java.io.fileinputstream; import java.io.filenotfoundexception; import java.io.fileoutputstream; import java.io.ioexception; import java.io.objectinputstream; import java.io.objectoutputstream; import java.net.malformedurlexception; import java.rmi.remoteexception; import java.util.arraylist; import javax.xml.rpc.serviceexception; import com.polarion.alm.ws.client.webservicefactory; import com.polarion.alm.ws.client.session.sessionwebservice; import com.polarion.alm.ws.client.tracker.trackerwebservice; import com.polarion.alm.ws.client.types.tracker.workitem; import com.polarion.alm.ws.client.types.tracker.workrecord; public class workrecordimporter { private webservicefactory factory; private trackerwebservice trackerservice; private sessionwebservice sessionservice; private workitem[] workitems; private arraylist<workrecord> workrecords; private string password = //insertpasswordhere;//no peaking public workrecordimporter()throws serviceexception, ioexception, classnotfoundexception{ initializefields();//initializes of web services , arrays //step 1 getworkitems(); //readdatfile(); //step 2 getworkrecords(); //$$$ printworkrecords(); //$$$$$ writedatfile(); } //you know does. public void printworkrecords(){ for(int temp = 0; temp < workitems.length; temp++){ system.out.println(workitems[temp].geturi().tostring()); } } public void writedatfile() throws ioexception{ objectoutputstream out = new objectoutputstream(new fileoutputstream("c:\\users\\sweidenkopf\\workspace\\test\\filename.dat")); try { out.writeobject(workrecords); } { // make sure close file when done out.close(); } } /** * method sets webservicefactory @ specified url. initializes web services, logs in * session service, , initializes arrays. * @throws malformedurlexception * @throws serviceexception * @throws remoteexception */ public void initializefields() throws malformedurlexception, serviceexception, remoteexception{ factory = new webservicefactory("//insert url here"); trackerservice = factory.gettrackerservice(); sessionservice = factory.getsessionservice(); sessionservice.login("sweidenkopf", password); workrecords = new arraylist<>(); } public void getworkitems()throws malformedurlexception, serviceexception, remoteexception{ sessionservice.begintransaction(); workitems = trackerservice.queryworkitems("workrecords.user.id:sweidenkopf", null, null); sessionservice.endtransaction(false); } public void getworkrecords()throws malformedurlexception, serviceexception, remoteexception{ sessionservice.begintransaction(); for(int k = 0; k < workitems.length; k++) {system.out.println("this working"); try{//not every work item has work records system.out.println(workitems[k].getworkrecords()); workrecord[] temp; temp = workitems[k].getworkrecords(); for(int x = 0; x < temp.length; x++){ system.out.println("this working fine"); workrecords.add(temp[x]); } }catch(nullpointerexception e){ system.out.println("i must regretfully inform have grave news; endeavors have not been successfull."); continue; } } system.out.println(workrecords.tostring()); sessionservice.endtransaction(false); } public void readdatfile() throws filenotfoundexception, ioexception, classnotfoundexception{ objectinputstream in = new objectinputstream(new fileinputstream("c:\\users\\sweidenkopf\\workspace\\test\\filename.dat")); try{ object temp = in.readobject(); workrecords = (arraylist) temp; } finally{ in.close(); } } }
the important part of course getworkrecords()
method within my code. can see, contains statement system.out.println(workitems[k].getworkrecords());
using debugging purposes. statement returns null
, , workitem
method not return null when substituted in statement geturi()
. also, try-catch block in method catches nullpointerexception
because of for
loop contains temp.length
, temp being variable should contain return of getworkrecords()
method.
to summarize main issue here unable return getworkrecords()
or other getter methods workitem
class. puzzling because geturi()
method executing successfully, printworkrecords()
method code prints uris of of workitem
objects erturn query.
are there polarion experts have encountered issue before? know doing wrong? inclined think bug based on circumstances.
to whom may concern, have solved problem.
if @ calling of queryworkitems()
method, notice after query parameter specify 2 null parameters. first parameter specify how want returned work items sorted (which inconsequential @ moment), second string
array called fields
used specify of workitem
fields want returned along workitems
themselves. apparently, if set null
did, defaults returning uri. other things, author, workrecord, , type, have place them in string
array , and pass array when call method.
Comments
Post a Comment