use of com.evolveum.midpoint.xml.ns._public.common.common_3.LensContextType in project midpoint by Evolveum.
the class TaskOperationPanel method initLayout.
protected void initLayout() {
final LensContextType lensContextType = getLensContextType();
LoadableModel<ModelOperationStatusDto> operationStatusModel = null;
if (lensContextType != null) {
operationStatusModel = new LoadableModel<ModelOperationStatusDto>() {
@Override
protected ModelOperationStatusDto load() {
Task task = getPageBase().createSimpleTask(OPERATION_LOAD_SCENE_DTO);
OperationResult result = task.getResult();
ModelContext ctx;
try {
ctx = ModelContextUtil.unwrapModelContext(lensContextType, getPageBase().getModelInteractionService(), task, result);
} catch (ObjectNotFoundException e) {
LoggingUtils.logUnexpectedException(LOGGER, "Unexpected error, cannot get real value for model context", e, e.getMessage());
return null;
}
return new ModelOperationStatusDto(ctx, getPageBase().getModelInteractionService(), task, result);
}
};
}
ModelOperationStatusPanel panel = new ModelOperationStatusPanel(ID_MODEL_OPERATION_STATUS_PANEL, operationStatusModel);
panel.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return lensContextType != null;
}
});
add(panel);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.LensContextType in project midpoint by Evolveum.
the class TestParseModelContext method testParseModelContextPrism.
@Test
public void testParseModelContextPrism() throws Exception {
System.out.println("===[ testParseModelContextPrism ]===");
// GIVEN
PrismContext prismContext = PrismTestUtil.getPrismContext();
// WHEN
LensContextType lensContextType = prismContext.parserFor(MODEL_CONTEXT_FILE).xml().parseRealValue(LensContextType.class);
// THEN
System.out.println("Parsed LensContextType: " + lensContextType);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.LensContextType in project midpoint by Evolveum.
the class ModelOperationTaskHandler method run.
@Override
public TaskRunResult run(Task task) {
OperationResult result = task.getResult().createSubresult(DOT_CLASS + "run");
TaskRunResult runResult = new TaskRunResult();
LensContextType contextType = task.getModelOperationContext();
if (contextType == null) {
LOGGER.trace("No model context found, skipping the model operation execution.");
if (result.isUnknown()) {
result.computeStatus();
}
runResult.setRunResultStatus(TaskRunResult.TaskRunResultStatus.FINISHED);
} else {
LensContext context;
try {
context = LensContext.fromLensContextType(contextType, prismContext, provisioningService, task, result);
} catch (SchemaException e) {
throw new SystemException("Cannot recover model context from task " + task + " due to schema exception", e);
} catch (ObjectNotFoundException | ConfigurationException | ExpressionEvaluationException e) {
throw new SystemException("Cannot recover model context from task " + task, e);
} catch (CommunicationException e) {
// todo wait and retry
throw new SystemException("Cannot recover model context from task " + task, e);
}
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Context to be executed = {}", context.debugDump());
}
try {
// here we brutally remove all the projection contexts -- because if we are continuing after rejection of a role/resource assignment
// that resulted in such projection contexts, we DO NOT want them to appear in the context any more
context.rot();
Iterator<LensProjectionContext> projectionIterator = context.getProjectionContextsIterator();
while (projectionIterator.hasNext()) {
LensProjectionContext projectionContext = projectionIterator.next();
if (projectionContext.getPrimaryDelta() != null && !projectionContext.getPrimaryDelta().isEmpty()) {
// don't remove client requested actions!
continue;
}
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Removing projection context {}", projectionContext.getHumanReadableName());
}
projectionIterator.remove();
}
if (task.getChannel() == null) {
task.setChannel(context.getChannel());
}
clockwork.run(context, task, result);
task.setModelOperationContext(context.toLensContextType());
task.savePendingModifications(result);
if (result.isUnknown()) {
result.computeStatus();
}
runResult.setRunResultStatus(TaskRunResult.TaskRunResultStatus.FINISHED);
} catch (RuntimeException | CommonException e) {
String message = "An exception occurred within model operation, in task " + task;
LoggingUtils.logUnexpectedException(LOGGER, message, e);
result.recordPartialError(message, e);
// TODO: here we do not know whether the error is temporary or permanent (in the future we could discriminate on the basis of particular exception caught)
runResult.setRunResultStatus(TaskRunResult.TaskRunResultStatus.TEMPORARY_ERROR);
}
}
task.getResult().recomputeStatus();
runResult.setOperationResult(task.getResult());
return runResult;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.LensContextType in project midpoint by Evolveum.
the class TaskOperationTabPanel method initLayout.
private void initLayout() {
final LensContextType lensContextType = getLensContextType();
LoadableModel<ModelOperationStatusDto> operationStatusModel = null;
if (lensContextType != null) {
operationStatusModel = new LoadableModel<ModelOperationStatusDto>() {
@Override
protected ModelOperationStatusDto load() {
Task task = getPageBase().createSimpleTask(OPERATION_LOAD_SCENE_DTO);
OperationResult result = task.getResult();
ModelContext ctx;
try {
ctx = ModelContextUtil.unwrapModelContext(lensContextType, getPageBase().getModelInteractionService(), task, result);
} catch (ObjectNotFoundException e) {
LoggingUtils.logUnexpectedException(LOGGER, "Unexpected error, cannot get real value for model context", e, e.getMessage());
return null;
}
return new ModelOperationStatusDto(ctx, getPageBase().getModelInteractionService(), task, result);
}
};
}
ModelOperationStatusPanel panel = new ModelOperationStatusPanel(ID_MODEL_OPERATION_STATUS_PANEL, operationStatusModel);
panel.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return lensContextType != null;
}
});
add(panel);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.LensContextType in project midpoint by Evolveum.
the class CaseClosing method finishCaseClosing.
public void finishCaseClosing(OperationResult result) throws SchemaException, ObjectNotFoundException, ObjectAlreadyExistsException, ExpressionEvaluationException, CommunicationException, ConfigurationException {
CaseType approvalCase = operation.getCurrentCase();
ObjectTreeDeltas<?> approvedDeltas = prepareDeltaOut(approvalCase);
beans.generalHelper.storeResultingDeltas(approvalCase, approvedDeltas, result);
// note: resulting deltas are now _not_ stored in currentCase object (these are in repo only)
// here we should execute the deltas, if appropriate!
CaseType rootCase = beans.generalHelper.getRootCase(approvalCase, result);
if (CaseTypeUtil.isClosed(rootCase)) {
LOGGER.debug("Root case ({}) is already closed; not starting any execution tasks for {}", rootCase, approvalCase);
beans.executionHelper.closeCaseInRepository(approvalCase, result);
} else {
LensContextType modelContextBean = rootCase.getModelContext();
if (modelContextBean == null) {
throw new IllegalStateException("No model context in root case " + rootCase);
}
if (isExecuteImmediately(modelContextBean)) {
processImmediateExecution(approvalCase, approvedDeltas, result);
} else {
processDelayedExecution(approvalCase, rootCase, result);
}
}
}
Aggregations