Example usage for javax.xml.datatype DatatypeConstants GREATER

List of usage examples for javax.xml.datatype DatatypeConstants GREATER

Introduction

In this page you can find the example usage for javax.xml.datatype DatatypeConstants GREATER.

Prototype

int GREATER

To view the source code for javax.xml.datatype DatatypeConstants GREATER.

Click Source Link

Document

Comparison result.

Usage

From source file:com.evolveum.midpoint.model.impl.lens.projector.ObjectTemplateProcessor.java

private <V extends PrismValue, D extends ItemDefinition, F extends FocusType> XMLGregorianCalendar collectTripleFromMappings(
        Collection<ObjectTemplateMappingType> mappings, ObjectTemplateMappingEvaluationPhaseType phase,
        LensContext<F> context, ObjectTemplateType objectTemplateType, ObjectDeltaObject<F> focusOdo,
        Map<ItemPath, DeltaSetTriple<? extends ItemValueWithOrigin<?, ?>>> outputTripleMap, int iteration,
        String iterationToken, XMLGregorianCalendar now, String contextDesc, Task task, OperationResult result)
        throws SchemaException, ExpressionEvaluationException, ObjectNotFoundException,
        PolicyViolationException {//from   w  w w .ja va 2 s .co m

    XMLGregorianCalendar nextRecomputeTime = null;

    for (ObjectTemplateMappingType mappingType : mappings) {
        ObjectTemplateMappingEvaluationPhaseType mappingPhase = mappingType.getEvaluationPhase();
        if (mappingPhase == null) {
            mappingPhase = ObjectTemplateMappingEvaluationPhaseType.BEFORE_ASSIGNMENTS;
        }
        if (mappingPhase != phase) {
            continue;
        }
        LOGGER.trace("Starting evaluation of mapping '{}' in {}", mappingType.getName(), contextDesc);
        ObjectDeltaObject<F> updatedFocusOdo = getUpdatedFocusOdo(context, focusOdo, outputTripleMap,
                mappingType, contextDesc); // for mapping chaining

        Mapping<V, D> mapping = mappingEvaluator.createFocusMapping(mappingFactory, context, mappingType,
                objectTemplateType, updatedFocusOdo, null, iteration, iterationToken,
                context.getSystemConfiguration(), now, contextDesc, task, result);
        if (mapping == null) {
            continue;
        }

        Boolean timeConstraintValid = mapping.evaluateTimeConstraintValid(task, result);

        if (timeConstraintValid != null && !timeConstraintValid) {
            // Delayed mapping. Just schedule recompute time
            XMLGregorianCalendar mappingNextRecomputeTime = mapping.getNextRecomputeTime();
            LOGGER.trace("Evaluation of mapping {} delayed to {}", mapping, mappingNextRecomputeTime);
            if (mappingNextRecomputeTime != null) {
                if (nextRecomputeTime == null
                        || nextRecomputeTime.compare(mappingNextRecomputeTime) == DatatypeConstants.GREATER) {
                    nextRecomputeTime = mappingNextRecomputeTime;
                }
            }
            continue;
        }

        mappingEvaluator.evaluateMapping(mapping, context, task, result);

        ItemPath itemPath = mapping.getOutputPath();
        if (itemPath == null) {
            continue;
        }
        DeltaSetTriple<ItemValueWithOrigin<V, D>> outputTriple = ItemValueWithOrigin
                .createOutputTriple(mapping);
        if (LOGGER.isTraceEnabled()) {
            LOGGER.trace("Output triple for {}:\n{}", mapping, DebugUtil.debugDump(outputTriple));
        }
        if (outputTriple == null) {
            continue;
        }
        DeltaSetTriple<ItemValueWithOrigin<V, D>> mapTriple = (DeltaSetTriple<ItemValueWithOrigin<V, D>>) outputTripleMap
                .get(itemPath);
        if (mapTriple == null) {
            outputTripleMap.put(itemPath, outputTriple);
        } else {
            mapTriple.merge(outputTriple);
        }
    }

    return nextRecomputeTime;
}

From source file:com.evolveum.midpoint.model.impl.lens.projector.focus.ObjectTemplateProcessor.java

private <V extends PrismValue, D extends ItemDefinition, F extends FocusType, T extends FocusType> XMLGregorianCalendar collectTripleFromMappings(
        LensContext<F> context, List<FocalMappingSpec> mappings, ObjectTemplateMappingEvaluationPhaseType phase,
        ObjectDeltaObject<F> focusOdo, PrismObject<T> target,
        Map<ItemPath, DeltaSetTriple<? extends ItemValueWithOrigin<?, ?>>> outputTripleMap, int iteration,
        String iterationToken, XMLGregorianCalendar now, Task task, OperationResult result)
        throws SchemaException, ExpressionEvaluationException, ObjectNotFoundException,
        PolicyViolationException, SecurityViolationException, ConfigurationException, CommunicationException {

    List<FocalMappingSpec> sortedMappings = sortMappingsByDependencies(mappings);

    XMLGregorianCalendar nextRecomputeTime = null;

    for (FocalMappingSpec mappingSpec : sortedMappings) {
        ObjectTemplateMappingEvaluationPhaseType mappingPhase = mappingSpec.getEvaluationPhase();
        if (phase != null && mappingPhase != phase) {
            continue;
        }//from   w w w  .j  a va 2  s  .c  om
        String mappingDesc = mappingSpec.shortDump();
        LOGGER.trace("Starting evaluation of {}", mappingDesc);
        ObjectDeltaObject<F> updatedFocusOdo = getUpdatedFocusOdo(context, focusOdo, outputTripleMap,
                mappingSpec, mappingDesc); // for mapping chaining

        MappingImpl<V, D> mapping = mappingEvaluator.createFocusMapping(mappingFactory, context,
                mappingSpec.getMappingType(), mappingSpec.getOriginObject(), updatedFocusOdo,
                mappingSpec.getDefaultSource(focusOdo), target, null, iteration, iterationToken,
                context.getSystemConfiguration(), now, mappingDesc, task, result);
        if (mapping == null) {
            continue;
        }

        Boolean timeConstraintValid = mapping.evaluateTimeConstraintValid(task, result);

        if (timeConstraintValid != null && !timeConstraintValid) {
            // Delayed mapping. Just schedule recompute time
            XMLGregorianCalendar mappingNextRecomputeTime = mapping.getNextRecomputeTime();
            LOGGER.trace("Evaluation of mapping {} delayed to {}", mapping, mappingNextRecomputeTime);
            if (mappingNextRecomputeTime != null) {
                if (nextRecomputeTime == null
                        || nextRecomputeTime.compare(mappingNextRecomputeTime) == DatatypeConstants.GREATER) {
                    nextRecomputeTime = mappingNextRecomputeTime;
                }
            }
            continue;
        }

        mappingEvaluator.evaluateMapping(mapping, context, task, result);

        ItemPath itemPath = mapping.getOutputPath();
        if (itemPath == null) {
            continue;
        }
        DeltaSetTriple<ItemValueWithOrigin<V, D>> outputTriple = ItemValueWithOrigin
                .createOutputTriple(mapping);
        if (LOGGER.isTraceEnabled()) {
            LOGGER.trace("Output triple for {}:\n{}", mapping, DebugUtil.debugDump(outputTriple));
        }
        if (outputTriple == null) {
            continue;
        }
        DeltaSetTriple<ItemValueWithOrigin<V, D>> mapTriple = (DeltaSetTriple<ItemValueWithOrigin<V, D>>) outputTripleMap
                .get(itemPath);
        if (mapTriple == null) {
            outputTripleMap.put(itemPath, outputTriple);
        } else {
            mapTriple.merge(outputTriple);
        }
    }

    return nextRecomputeTime;
}

From source file:de.escidoc.core.test.EscidocTestBase.java

/**
 * Returns a positive integer if ts1 depicts a time after ts2 (ts1 > ts2), 0 if ts1 and ts2 depict the same time
 * (ts1 == ts2), and a negative integer if if ts1 depicts a time before ts2 (ts1 < ts2).
 * /*from  www .  j a v a  2  s.c  o m*/
 * @param ts1
 *            The first timestamp.
 * @param ts2
 *            The second timestamp.
 * @return The comparison result.
 * @throws Exception
 *             If anything fails (e.g. one timstamp has incorrect format).
 */
public static int compareTimestamps(final String ts1, final String ts2) throws Exception {

    int result = 0;

    XMLGregorianCalendar date1 = DatatypeFactory.newInstance().newXMLGregorianCalendar(ts1);
    XMLGregorianCalendar date2 = DatatypeFactory.newInstance().newXMLGregorianCalendar(ts2);

    int diff = date1.compare(date2);
    if (diff == DatatypeConstants.LESSER) {
        result = -1;
    } else if (diff == DatatypeConstants.GREATER) {
        result = 1;
    } else if (diff == DatatypeConstants.EQUAL) {
        result = 0;
    } else if (diff == DatatypeConstants.INDETERMINATE) {
        throw new Exception("Date comparing: INDETERMINATE");
    }

    return result;
}