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