Search in sources :

Example 46 with Duration

use of javax.xml.datatype.Duration in project cxf by apache.

the class SourceSequence method setExpires.

public void setExpires(Expires ex) {
    Duration d = null;
    expires = null;
    if (null != ex) {
        d = ex.getValue();
    }
    if (null != d && !d.equals(DatatypeFactory.PT0S)) {
        Date now = new Date();
        expires = new Date(now.getTime() + ex.getValue().getTimeInMillis(now));
    }
}
Also used : Duration(javax.xml.datatype.Duration) Date(java.util.Date)

Example 47 with Duration

use of javax.xml.datatype.Duration in project cxf by apache.

the class AbstractSubscription method parseTerminationTime.

protected XMLGregorianCalendar parseTerminationTime(String value) {
    try {
        Duration d = datatypeFactory.newDuration(value);
        XMLGregorianCalendar c = getCurrentTime();
        c.add(d);
        return c;
    } catch (Exception e) {
    // Ignore
    }
    try {
        Duration d = datatypeFactory.newDurationDayTime(value);
        XMLGregorianCalendar c = getCurrentTime();
        c.add(d);
        return c;
    } catch (Exception e) {
    // Ignore
    }
    try {
        Duration d = datatypeFactory.newDurationYearMonth(value);
        XMLGregorianCalendar c = getCurrentTime();
        c.add(d);
        return c;
    } catch (Exception e) {
    // Ignore
    }
    try {
        return datatypeFactory.newXMLGregorianCalendar(value);
    } catch (Exception e) {
    // Ignore
    }
    return null;
}
Also used : XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) Duration(javax.xml.datatype.Duration) DatatypeConfigurationException(javax.xml.datatype.DatatypeConfigurationException)

Example 48 with Duration

use of javax.xml.datatype.Duration in project cxf by apache.

the class DurationAndDateUtil method toExpirationTypeContainingDuration.

public static ExpirationType toExpirationTypeContainingDuration(XMLGregorianCalendar date) {
    ExpirationType et = new ExpirationType();
    XMLGregorianCalendar now = factory.newXMLGregorianCalendar(new GregorianCalendar());
    XMLGregorianCalendar then = factory.newXMLGregorianCalendar(date.toGregorianCalendar());
    long durationMillis = then.toGregorianCalendar().getTimeInMillis() - now.toGregorianCalendar().getTimeInMillis();
    Duration duration = factory.newDuration(durationMillis);
    et.setValue(duration.toString());
    return et;
}
Also used : XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) ExpirationType(org.apache.cxf.ws.eventing.ExpirationType) GregorianCalendar(java.util.GregorianCalendar) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) Duration(javax.xml.datatype.Duration)

Example 49 with Duration

use of javax.xml.datatype.Duration in project cxf by apache.

the class FiqlSearchConditionBuilderTest method testLessThanDuration.

@Test
public void testLessThanDuration() throws DatatypeConfigurationException {
    Duration d = DatatypeFactory.newInstance().newDuration(false, 0, 0, 1, 12, 0, 0);
    String ret = b.is("foo").before(d).query();
    assertEquals("foo=lt=-P0Y0M1DT12H0M0S", ret);
}
Also used : Duration(javax.xml.datatype.Duration) Test(org.junit.Test)

Example 50 with Duration

use of javax.xml.datatype.Duration in project cxf by apache.

the class FiqlSearchConditionBuilderTest method testEqualToDuration.

@Test
public void testEqualToDuration() throws ParseException, DatatypeConfigurationException {
    Duration d = DatatypeFactory.newInstance().newDuration(false, 0, 0, 1, 12, 0, 0);
    String ret = b.is("foo").equalTo(d).query();
    assertEquals("foo==-P0Y0M1DT12H0M0S", ret);
}
Also used : Duration(javax.xml.datatype.Duration) Test(org.junit.Test)

Aggregations

Duration (javax.xml.datatype.Duration)137 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)57 Test (org.junit.Test)16 ArrayList (java.util.ArrayList)14 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)12 Date (java.util.Date)12 BigDecimal (java.math.BigDecimal)9 Calendar (java.util.Calendar)9 GregorianCalendar (java.util.GregorianCalendar)9 ObjectDeltaType (com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType)8 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)7 CleanupPolicyType (com.evolveum.midpoint.xml.ns._public.common.common_3.CleanupPolicyType)6 ItemDelta (com.evolveum.midpoint.prism.delta.ItemDelta)5 IOException (java.io.IOException)5 XSDayTimeDuration (org.eclipse.wst.xml.xpath2.processor.internal.types.XSDayTimeDuration)5 FileNotFoundException (java.io.FileNotFoundException)4 Collection (java.util.Collection)4 DatatypeFactory (javax.xml.datatype.DatatypeFactory)4 NotNull (org.jetbrains.annotations.NotNull)4 PrismObject (com.evolveum.midpoint.prism.PrismObject)3