<rss version="2.0" xmlns:a10="http://www.w3.org/2005/Atom"><channel><title>Inflectra Customer Forums: Filtering dates with the SOAP API (Thread)</title><description>&#xD;
We are considering to use the SpiraTest SOAP API for a Java application.  I have set up a small Java project for testing the capabilities of the API. I am stuck by filtering Incidents by dates like CreationDate, LastUpdateDate, etc. According to this site it should work: https://www.inflectra.com/Support/KnowledgeBase/KB88.aspx  The central part of my code is:  ObjectFactory objectFactory = new ObjectFactory();                          RemoteFilter filter1 = objectFactory.createRemoteFilter();             filter1.setPropertyName(objectFactory.createRemoteIncidentDescription("CreationDate"));              // create calendas and set them as start and end date              javax.xml.datatype.XMLGregorianCalendar calStart = new com.sun.org.apache.xerces.internal.jaxp.datatype.XMLGregorianCalendarImpl();              Calendar c = Calendar.getInstance();             c.add(Calendar.DAY_OF_YEAR, -50);             calStart.setYear(c.get(Calendar.YEAR));             calStart.setMonth(c.get(Calendar.MONTH));             calStart.setDay(c.get(Calendar.DAY_OF_MONTH));                          calStart.setTime(c.get(Calendar.HOUR), c.get(Calendar.MINUTE), c.get(Calendar.SECOND));             System.out.println(calStart.toGregorianCalendar().getTime());              javax.xml.datatype.XMLGregorianCalendar calEnd = new com.sun.org.apache.xerces.internal.jaxp.datatype.XMLGregorianCalendarImpl();             Calendar c2 = Calendar.getInstance();             calEnd.setYear(c2.get(Calendar.YEAR));             calEnd.setMonth(c2.get(Calendar.MONTH));             calEnd.setDay(c2.get(Calendar.DAY_OF_MONTH));                          calEnd.setTime(c2.get(Calendar.HOUR), c2.get(Calendar.MINUTE), c2.get(Calendar.SECOND));             System.out.println(calEnd.toGregorianCalendar().getTime());                                                DateRange dr = objectFactory.createDateRange();             dr.setStartDate(objectFactory.createDateRangeStartDate(calStart));             dr.setEndDate(objectFactory.createDateRangeEndDate(calEnd));             dr.setConsiderTimes(true);              JAXBElement  drElement = objectFactory.createDateRange(dr);             filter1.setDateRangeValue(drElement);                           // add filter to a filter array             ArrayOfRemoteFilter filters = objectFactory.createArrayOfRemoteFilter();             filters.getRemoteFilter().add(filter1);              // Create RemoteSort             RemoteSort sort = objectFactory.createRemoteSort();             sort.setPropertyName(objectFactory.createRemoteFilterPropertyName("IncidentId"));             sort.setSortAscending(true);                  ArrayOfRemoteIncident incidents = soap.incidentRetrieve(filters, sort, 1, 1000);             List  inc = incidents.getRemoteIncident();             // ... loop over the incidents, print them to console  It throws no exceptions, but doesn't filter anything, eighter... :(  Can someone with experience help me?  Thanks, Zoltan  &#xD;
&#xD;
</description><language>en-US</language><copyright>(C) Copyright 2006-2026 Inflectra Corporation.</copyright><managingEditor>support@inflectra.com</managingEditor><category domain="http://www.dmoz.org">/Computers/Software/Project_Management/</category><category domain="http://www.dmoz.org">/Computers/Software/Quality_Assurance/</category><generator>KronoDesk</generator><a10:contributor><a10:email>support@inflectra.com</a10:email></a10:contributor><a10:id>http://www.inflectra.com/kronodesk/forums/threads</a10:id><ttl>120</ttl><link>/Support/Forum/spiratest/issues-questions/1319.aspx</link><item><guid isPermaLink="false">threadId=1319</guid><author>Marc Schneider (it-koordination.koeln@dertouristik.com)</author><category domain="http://www.inflectra.com/kronodesk/thread/tag">soap</category><category domain="http://www.inflectra.com/kronodesk/thread/tag"> api</category><title>Filtering dates with the SOAP API</title><description>&#xD;
We are considering to use the SpiraTest SOAP API for a Java application.  I have set up a small Java project for testing the capabilities of the API. I am stuck by filtering Incidents by dates like CreationDate, LastUpdateDate, etc. According to this site it should work: https://www.inflectra.com/Support/KnowledgeBase/KB88.aspx  The central part of my code is:  ObjectFactory objectFactory = new ObjectFactory();                          RemoteFilter filter1 = objectFactory.createRemoteFilter();             filter1.setPropertyName(objectFactory.createRemoteIncidentDescription("CreationDate"));              // create calendas and set them as start and end date              javax.xml.datatype.XMLGregorianCalendar calStart = new com.sun.org.apache.xerces.internal.jaxp.datatype.XMLGregorianCalendarImpl();              Calendar c = Calendar.getInstance();             c.add(Calendar.DAY_OF_YEAR, -50);             calStart.setYear(c.get(Calendar.YEAR));             calStart.setMonth(c.get(Calendar.MONTH));             calStart.setDay(c.get(Calendar.DAY_OF_MONTH));                          calStart.setTime(c.get(Calendar.HOUR), c.get(Calendar.MINUTE), c.get(Calendar.SECOND));             System.out.println(calStart.toGregorianCalendar().getTime());              javax.xml.datatype.XMLGregorianCalendar calEnd = new com.sun.org.apache.xerces.internal.jaxp.datatype.XMLGregorianCalendarImpl();             Calendar c2 = Calendar.getInstance();             calEnd.setYear(c2.get(Calendar.YEAR));             calEnd.setMonth(c2.get(Calendar.MONTH));             calEnd.setDay(c2.get(Calendar.DAY_OF_MONTH));                          calEnd.setTime(c2.get(Calendar.HOUR), c2.get(Calendar.MINUTE), c2.get(Calendar.SECOND));             System.out.println(calEnd.toGregorianCalendar().getTime());                                                DateRange dr = objectFactory.createDateRange();             dr.setStartDate(objectFactory.createDateRangeStartDate(calStart));             dr.setEndDate(objectFactory.createDateRangeEndDate(calEnd));             dr.setConsiderTimes(true);              JAXBElement  drElement = objectFactory.createDateRange(dr);             filter1.setDateRangeValue(drElement);                           // add filter to a filter array             ArrayOfRemoteFilter filters = objectFactory.createArrayOfRemoteFilter();             filters.getRemoteFilter().add(filter1);              // Create RemoteSort             RemoteSort sort = objectFactory.createRemoteSort();             sort.setPropertyName(objectFactory.createRemoteFilterPropertyName("IncidentId"));             sort.setSortAscending(true);                  ArrayOfRemoteIncident incidents = soap.incidentRetrieve(filters, sort, 1, 1000);             List  inc = incidents.getRemoteIncident();             // ... loop over the incidents, print them to console  It throws no exceptions, but doesn't filter anything, eighter... :(  Can someone with experience help me?  Thanks, Zoltan  &#xD;
&#xD;
</description><pubDate>Fri, 30 Oct 2015 16:21:27 -0400</pubDate><a10:updated>2015-11-05T08:50:48-05:00</a10:updated><link>/Support/Forum/spiratest/issues-questions/1319.aspx</link></item><item><guid isPermaLink="false">messageId=2402</guid><author>David J (adam.sandman+support@inflectra.com)</author><title>&#xD;
Hi Zoltan  The following doesn't look correct:               filter1.setPropertyName(objectFactory</title><description>&#xD;
Hi Zoltan  The following doesn't look correct:               filter1.setPropertyName(objectFactory.createRemoteIncidentDescription("CreationDate"));  the property name should be just "CreationDate"  If that doesn't work, I'd log a help desk ticket.  Regards  Adam  &#xD;
&#xD;
</description><pubDate>Wed, 04 Nov 2015 22:00:53 -0500</pubDate><a10:updated>2015-11-04T22:00:53-05:00</a10:updated><link>/Support/Forum/spiratest/issues-questions/1319.aspx#reply2402</link></item><item><guid isPermaLink="false">messageId=2403</guid><author>Marc Schneider (it-koordination.koeln@dertouristik.com)</author><title>Hi Adam,  I suspected that line myself, too...  Your suggestion did not work, because the method set</title><description>Hi Adam,  I suspected that line myself, too...  Your suggestion did not work, because the method setPropertyName() expects a JAXBElement  as parameter, it does not accept plain strings. I have already tried a couple of methods in the objectFactory that return a JAXBElement , without luck.  After your answer I looked again, and I found the method createRemoteFilterPropertyName(), and that works! Its name is also pretty straight forward, but the objectFactory has hundreds of methods, I just missed it...  So the complete line is:    filter1.setPropertyName(objectFactory.createRemoteFilterPropertyName("CreationDate"));  It seems the different filter parameter require different creator-methods. Too bad they are not documented, could have saved us some time...  But thank you, you led me to the solution at the end :)  Regards, Zoltan &#xD;
&#xD;
</description><pubDate>Thu, 05 Nov 2015 08:50:48 -0500</pubDate><a10:updated>2015-11-05T08:50:48-05:00</a10:updated><link>/Support/Forum/spiratest/issues-questions/1319.aspx#reply2403</link></item></channel></rss>