Example usage for javax.xml.datatype XMLGregorianCalendar clone

List of usage examples for javax.xml.datatype XMLGregorianCalendar clone

Introduction

In this page you can find the example usage for javax.xml.datatype XMLGregorianCalendar clone.

Prototype

@Override
public abstract Object clone();

Source Link

Document

Creates and returns a copy of this object.

Usage

From source file:com.evolveum.midpoint.schema.util.WfContextUtil.java

@NotNull
public static List<TriggerType> createTriggers(int escalationLevel, Date workItemCreateTime,
        Date workItemDeadline, List<WorkItemTimedActionsType> timedActionsList, PrismContext prismContext,
        Trace logger, @Nullable String workItemId, @NotNull String handlerUri) throws SchemaException {
    List<TriggerType> triggers = new ArrayList<>();
    for (WorkItemTimedActionsType timedActionsEntry : timedActionsList) {
        Integer levelFrom;//from   w  w w  .  j  ava 2 s . c om
        Integer levelTo;
        if (timedActionsEntry.getEscalationLevelFrom() == null
                && timedActionsEntry.getEscalationLevelTo() == null) {
            levelFrom = levelTo = 0;
        } else {
            levelFrom = timedActionsEntry.getEscalationLevelFrom();
            levelTo = timedActionsEntry.getEscalationLevelTo();
        }
        if (levelFrom != null && escalationLevel < levelFrom) {
            logger.trace("Current escalation level is before 'escalationFrom', skipping timed actions {}",
                    timedActionsEntry);
            continue;
        }
        if (levelTo != null && escalationLevel > levelTo) {
            logger.trace("Current escalation level is after 'escalationTo', skipping timed actions {}",
                    timedActionsEntry);
            continue;
        }
        // TODO evaluate the condition
        List<TimedActionTimeSpecificationType> timeSpecifications = CloneUtil
                .cloneCollectionMembers(timedActionsEntry.getTime());
        if (timeSpecifications.isEmpty()) {
            timeSpecifications.add(new TimedActionTimeSpecificationType());
        }
        for (TimedActionTimeSpecificationType timeSpec : timeSpecifications) {
            if (timeSpec.getValue().isEmpty()) {
                timeSpec.getValue().add(XmlTypeConverter.createDuration(0));
            }
            for (Duration duration : timeSpec.getValue()) {
                XMLGregorianCalendar mainTriggerTime = computeTriggerTime(duration, timeSpec.getBase(),
                        workItemCreateTime, workItemDeadline);
                TriggerType mainTrigger = createTrigger(mainTriggerTime, timedActionsEntry.getActions(), null,
                        prismContext, workItemId, handlerUri);
                triggers.add(mainTrigger);
                List<Pair<Duration, AbstractWorkItemActionType>> notifyInfoList = getNotifyBefore(
                        timedActionsEntry);
                for (Pair<Duration, AbstractWorkItemActionType> notifyInfo : notifyInfoList) {
                    XMLGregorianCalendar notifyTime = (XMLGregorianCalendar) mainTriggerTime.clone();
                    notifyTime.add(notifyInfo.getKey().negate());
                    TriggerType notifyTrigger = createTrigger(notifyTime, null, notifyInfo, prismContext,
                            workItemId, handlerUri);
                    triggers.add(notifyTrigger);
                }
            }
        }
    }
    return triggers;
}

From source file:com.evolveum.midpoint.model.common.mapping.Mapping.java

private XMLGregorianCalendar parseTime(MappingTimeDeclarationType timeType, Task task, OperationResult result)
        throws SchemaException, ObjectNotFoundException {
    if (timeType == null) {
        return null;
    }/*ww w .  ja v a 2  s.c  o  m*/
    XMLGregorianCalendar time = null;
    MappingSourceDeclarationType referenceTimeType = timeType.getReferenceTime();
    if (referenceTimeType == null) {
        if (time == null) {
            throw new SchemaException(
                    "No reference time specified (and there is also no default) in time specification in "
                            + getMappingContextDescription());
        } else {
            time = (XMLGregorianCalendar) defaultReferenceTime.clone();
        }
    } else {
        time = parseTimeSource(referenceTimeType, task, result);
        if (time == null) {
            // Reference time is specified but the value is not present.
            return null;
        }
        time = (XMLGregorianCalendar) time.clone();
    }
    Duration offset = timeType.getOffset();
    if (offset != null) {
        time.add(offset);
    }
    return time;
}