Search in sources :

Example 1 with PrismObjectValue

use of com.evolveum.midpoint.prism.PrismObjectValue in project midpoint by Evolveum.

the class BaseActionExecutor method iterateOverItems.

void iterateOverItems(PipelineData input, ExecutionContext context, OperationResult globalResult, ItemProcessor itemProcessor, ConsoleFailureMessageWriter writer) throws ScriptExecutionException {
    for (PipelineItem item : input.getData()) {
        PrismValue value = item.getValue();
        OperationResult result = operationsHelper.createActionResult(item, this, globalResult);
        context.checkTaskStop();
        Operation op;
        if (value instanceof PrismObjectValue) {
            op = operationsHelper.recordStart(context, asObjectType(value));
        } else {
            op = null;
        }
        try {
            itemProcessor.process(value, item, result);
            operationsHelper.recordEnd(context, op, null, result);
        } catch (Throwable ex) {
            result.recordFatalError(ex);
            operationsHelper.recordEnd(context, op, ex, result);
            Throwable exception = processActionException(ex, getActionName(), value, context);
            writer.write(value, exception);
        }
        operationsHelper.trimAndCloneResult(result, item.getResult());
    }
}
Also used : PrismObjectValue(com.evolveum.midpoint.prism.PrismObjectValue) PipelineItem(com.evolveum.midpoint.model.api.PipelineItem) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Operation(com.evolveum.midpoint.schema.statistics.Operation) PrismValue(com.evolveum.midpoint.prism.PrismValue)

Example 2 with PrismObjectValue

use of com.evolveum.midpoint.prism.PrismObjectValue in project midpoint by Evolveum.

the class AbstractObjectBasedActionExecutor method castToObject.

@SuppressWarnings("ThrowableNotThrown")
private PrismObject<T> castToObject(PrismValue value, Class<T> expectedType, ExecutionContext context) throws ScriptExecutionException {
    if (value instanceof PrismObjectValue) {
        PrismObjectValue objectValue = (PrismObjectValue) value;
        Class<? extends Objectable> realType = objectValue.asObjectable().getClass();
        if (expectedType.isAssignableFrom(realType)) {
            // noinspection unchecked
            return objectValue.asPrismObject();
        } else {
            processActionException(new ScriptExecutionException("Item is not a PrismObject of " + expectedType.getName() + "; it is " + realType.getName() + " instead"), getActionName(), value, context);
            return null;
        }
    } else {
        processActionException(new ScriptExecutionException("Item is not a PrismObject"), getActionName(), value, context);
        return null;
    }
}
Also used : PrismObjectValue(com.evolveum.midpoint.prism.PrismObjectValue) ScriptExecutionException(com.evolveum.midpoint.util.exception.ScriptExecutionException)

Example 3 with PrismObjectValue

use of com.evolveum.midpoint.prism.PrismObjectValue in project midpoint by Evolveum.

the class CaseTypeUtil method getCase.

public static CaseType getCase(CaseWorkItemType workItem) {
    if (workItem == null) {
        return null;
    }
    @SuppressWarnings({ "unchecked", "raw" }) PrismContainerable<CaseWorkItemType> parent = workItem.asPrismContainerValue().getParent();
    if (!(parent instanceof PrismContainer)) {
        return null;
    }
    PrismValue parentParent = ((PrismContainer<CaseWorkItemType>) parent).getParent();
    if (!(parentParent instanceof PrismObjectValue)) {
        return null;
    }
    @SuppressWarnings({ "unchecked", "raw" }) PrismObjectValue<CaseType> parentParentPov = (PrismObjectValue<CaseType>) parentParent;
    return parentParentPov.asObjectable();
}
Also used : PrismObjectValue(com.evolveum.midpoint.prism.PrismObjectValue) PrismContainer(com.evolveum.midpoint.prism.PrismContainer) PrismValue(com.evolveum.midpoint.prism.PrismValue)

Aggregations

PrismObjectValue (com.evolveum.midpoint.prism.PrismObjectValue)3 PrismValue (com.evolveum.midpoint.prism.PrismValue)2 PipelineItem (com.evolveum.midpoint.model.api.PipelineItem)1 PrismContainer (com.evolveum.midpoint.prism.PrismContainer)1 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)1 Operation (com.evolveum.midpoint.schema.statistics.Operation)1 ScriptExecutionException (com.evolveum.midpoint.util.exception.ScriptExecutionException)1