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);
}
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;
}
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;
}
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());
}
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;
}
Aggregations