Search in sources :

Example 21 with XMLGregorianCalendar

use of javax.xml.datatype.XMLGregorianCalendar in project midpoint by Evolveum.

the class AuditPopupPanel method initLayout.

@SuppressWarnings("serial")
private void initLayout(final Component component) {
    TextFormGroup name = new TextFormGroup(ID_NAME, new PropertyModel<String>(getModel(), AuditReportDto.F_NAME), createStringResource("ObjectType.name"), ID_LABEL_SIZE, ID_INPUT_SIZE, true);
    add(name);
    TextFormGroup description = new TextFormGroup(ID_DESCRIPTION, new PropertyModel<String>(getModel(), AuditReportDto.F_DESCRIPTION), createStringResource("ObjectType.description"), ID_LABEL_SIZE, ID_INPUT_SIZE, true);
    add(description);
    IModel choices = WebComponentUtil.createReadonlyModelFromEnum(ExportType.class);
    IChoiceRenderer renderer = new EnumChoiceRenderer();
    DropDownFormGroup exportType = new DropDownFormGroup(ID_EXPORT_TYPE, new PropertyModel<ExportType>(getModel(), AuditReportDto.F_EXPORT_TYPE), choices, renderer, createStringResource("AuditPopulPanel.exportType.label"), ID_LABEL_SIZE, ID_INPUT_SIZE, false);
    add(exportType);
    choices = WebComponentUtil.createReadonlyModelFromEnum(AuditEventType.class);
    DropDownFormGroup auditEventType = new DropDownFormGroup(ID_AUDITEVENTTYPE, new PropertyModel<AuditEventType>(getModel(), AuditReportDto.F_AUDITEVENTTYPE), choices, renderer, createStringResource("AuditPopupPanel.auditEventType"), ID_LABEL_SIZE, ID_INPUT_SIZE, false);
    add(auditEventType);
    DateFormGroup dateFrom = new DateFormGroup(ID_DATE_FROM, new PropertyModel<XMLGregorianCalendar>(getModel(), AuditReportDto.F_FROM_GREG), createStringResource("AuditPopupPanel.dateFrom"), ID_LABEL_SIZE, ID_INPUT_SIZE, false);
    add(dateFrom);
    DateFormGroup dateTo = new DateFormGroup(ID_DATE_TO, new PropertyModel<XMLGregorianCalendar>(getModel(), AuditReportDto.F_TO_GREG), createStringResource("AuditPopupPanel.dateTo"), ID_LABEL_SIZE, ID_INPUT_SIZE, false);
    add(dateTo);
}
Also used : TextFormGroup(com.evolveum.midpoint.web.component.form.TextFormGroup) IModel(org.apache.wicket.model.IModel) DropDownFormGroup(com.evolveum.midpoint.web.component.form.DropDownFormGroup) AuditEventType(com.evolveum.midpoint.audit.api.AuditEventType) ExportType(com.evolveum.midpoint.xml.ns._public.common.common_3.ExportType) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) DateFormGroup(com.evolveum.midpoint.web.component.form.DateFormGroup)

Example 22 with XMLGregorianCalendar

use of javax.xml.datatype.XMLGregorianCalendar in project midpoint by Evolveum.

the class SynchronizationUtils method createSynchronizationSituationAndDescriptionDelta.

public static List<PropertyDelta<?>> createSynchronizationSituationAndDescriptionDelta(PrismObject object, SynchronizationSituationType situation, String sourceChannel, boolean full) {
    XMLGregorianCalendar timestamp = XmlTypeConverter.createXMLGregorianCalendar(System.currentTimeMillis());
    List<PropertyDelta<?>> delta = createSynchronizationSituationDescriptionDelta(object, situation, timestamp, sourceChannel, full);
    PropertyDelta<XMLGregorianCalendar> timestampDelta = createSynchronizationTimestampDelta(object, ShadowType.F_SYNCHRONIZATION_TIMESTAMP, timestamp);
    delta.add(timestampDelta);
    if (full) {
        timestampDelta = createSynchronizationTimestampDelta(object, ShadowType.F_FULL_SYNCHRONIZATION_TIMESTAMP, timestamp);
        delta.add(timestampDelta);
    }
    PropertyDelta<SynchronizationSituationType> syncSituationDelta = createSynchronizationSituationDelta(object, situation);
    if (syncSituationDelta != null) {
        delta.add(syncSituationDelta);
    }
    return delta;
}
Also used : SynchronizationSituationType(com.evolveum.midpoint.xml.ns._public.common.common_3.SynchronizationSituationType) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) PropertyDelta(com.evolveum.midpoint.prism.delta.PropertyDelta)

Example 23 with XMLGregorianCalendar

use of javax.xml.datatype.XMLGregorianCalendar in project midpoint by Evolveum.

the class ActivationComputer method getValidityStatus.

public TimeIntervalStatusType getValidityStatus(ActivationType activationType, XMLGregorianCalendar referenceTime) {
    if (activationType == null || referenceTime == null) {
        return null;
    }
    XMLGregorianCalendar validFrom = activationType.getValidFrom();
    XMLGregorianCalendar validTo = activationType.getValidTo();
    if (validFrom == null && validTo == null) {
        return null;
    }
    TimeIntervalStatusType status = TimeIntervalStatusType.IN;
    if (validFrom != null && (referenceTime == null || referenceTime.compare(validFrom) == DatatypeConstants.LESSER)) {
        status = TimeIntervalStatusType.BEFORE;
    }
    if (validTo != null && referenceTime.compare(validTo) == DatatypeConstants.GREATER) {
        status = TimeIntervalStatusType.AFTER;
    }
    return status;
}
Also used : XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) TimeIntervalStatusType(com.evolveum.midpoint.xml.ns._public.common.common_3.TimeIntervalStatusType)

Example 24 with XMLGregorianCalendar

use of javax.xml.datatype.XMLGregorianCalendar in project midpoint by Evolveum.

the class TestImmutable method test020DateProperty.

@Test
public void test020DateProperty() throws Exception {
    System.out.println("===[ test020DateProperty ]===");
    // GIVEN
    PrismContext prismContext = PrismTestUtil.getPrismContext();
    // WHEN
    PrismPropertyDefinition<XMLGregorianCalendar> datePPD = new PrismPropertyDefinitionImpl<>(new QName(SchemaConstants.NS_C, "dateTime"), DOMUtil.XSD_DATETIME, prismContext);
    PrismProperty<XMLGregorianCalendar> datePP = datePPD.instantiate();
    Date now = new Date();
    Date yesterday = new Date(now.getTime() - 86400000L);
    datePP.setRealValue(XmlTypeConverter.createXMLGregorianCalendar(now));
    datePP.setImmutable(true);
    // THEN
    try {
        datePP.setRealValue(yesterday);
        AssertJUnit.fail("Value was changed when immutable!");
    } catch (RuntimeException e) {
        System.out.println("Got (expected) exception of " + e);
    }
    try {
        datePP.getValue().setValue(XmlTypeConverter.createXMLGregorianCalendar(yesterday));
        AssertJUnit.fail("Value was changed when immutable!");
    } catch (RuntimeException e) {
        System.out.println("Got (expected) exception of " + e);
    }
// Testing that returned objects are in fact clones (disabled as not implemented yet)
//		XMLGregorianCalendar realValue = datePP.getAnyRealValue();
//		int hourPlus1 = (realValue.getHour() + 1) % 24;
//		realValue.setHour(hourPlus1);
//		assertEquals("Date was changed even if it should not", XmlTypeConverter.createXMLGregorianCalendar(now), datePP.getAnyRealValue());
}
Also used : XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) QName(javax.xml.namespace.QName) Date(java.util.Date) Test(org.testng.annotations.Test)

Example 25 with XMLGregorianCalendar

use of javax.xml.datatype.XMLGregorianCalendar in project midpoint by Evolveum.

the class WfContextUtil method computeTriggerTime.

@NotNull
private static XMLGregorianCalendar computeTriggerTime(Duration duration, WfTimeBaseType base, Date start, Date deadline) {
    Date baseTime;
    if (base == null) {
        base = duration.getSign() <= 0 ? WfTimeBaseType.DEADLINE : WfTimeBaseType.WORK_ITEM_CREATION;
    }
    switch(base) {
        case DEADLINE:
            if (deadline == null) {
                throw new IllegalStateException("Couldn't set timed action relative to work item's deadline because" + " the deadline is not set. Requested interval: " + duration);
            }
            baseTime = deadline;
            break;
        case WORK_ITEM_CREATION:
            if (start == null) {
                throw new IllegalStateException("Task's start time is null");
            }
            baseTime = start;
            break;
        default:
            throw new IllegalArgumentException("base: " + base);
    }
    XMLGregorianCalendar rv = XmlTypeConverter.createXMLGregorianCalendar(baseTime);
    rv.add(duration);
    return rv;
}
Also used : XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)336 Test (org.testng.annotations.Test)159 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)130 Task (com.evolveum.midpoint.task.api.Task)104 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)72 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)52 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)44 Date (java.util.Date)36 TestValidityRecomputeTask (com.evolveum.midpoint.model.intest.sync.TestValidityRecomputeTask)32 ArrayList (java.util.ArrayList)32 AbstractInitializedModelIntegrationTest (com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)31 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)31 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)30 AbstractSynchronizationStoryTest (com.evolveum.midpoint.model.intest.sync.AbstractSynchronizationStoryTest)23 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)21 GregorianCalendar (java.util.GregorianCalendar)18 QName (javax.xml.namespace.QName)18 DummyAccount (com.evolveum.icf.dummy.resource.DummyAccount)15 Duration (javax.xml.datatype.Duration)15 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)14