Inflectra Customer Forums: Filtering dates with the SOAP API (Thread) 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 en-US(C) Copyright 2006-2024 Inflectra Corporation.support@inflectra.com/Computers/Software/Project_Management//Computers/Software/Quality_Assurance/KronoDesksupport@inflectra.comhttp://www.inflectra.com/kronodesk/forums/threads120/Support/Forum/spiratest/issues-questions/1319.aspxthreadId=1319Marc Schneider (it-koordination.koeln@dertouristik.com)SOAP API filterFiltering dates with the SOAP API 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 Fri, 30 Oct 2015 16:21:27 -04002015-11-05T08:50:48-05:00/Support/Forum/spiratest/issues-questions/1319.aspxmessageId=2402David J (support1@inflectra.com) Hi Zoltan The following doesn't look correct: filter1.setPropertyName(objectFactory 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 Wed, 04 Nov 2015 22:00:53 -05002015-11-04T22:00:53-05:00/Support/Forum/spiratest/issues-questions/1319.aspx#reply2402messageId=2403Marc Schneider (it-koordination.koeln@dertouristik.com)Hi Adam, I suspected that line myself, too... Your suggestion did not work, because the method setHi 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 Thu, 05 Nov 2015 08:50:48 -05002015-11-05T08:50:48-05:00/Support/Forum/spiratest/issues-questions/1319.aspx#reply2403