use of com.evolveum.midpoint.model.api.ModelService in project midpoint by Evolveum.
the class PageProcessInstances method deleteProcessInstancesPerformed.
private void deleteProcessInstancesPerformed(AjaxRequestTarget target) {
List<ProcessInstanceDto> processInstanceDtoList = WebComponentUtil.getSelectedData(getTable());
if (!isSomeItemSelected(processInstanceDtoList, false, target)) {
return;
}
Task opTask = createSimpleTask(OPERATION_DELETE_PROCESS_INSTANCES);
OperationResult result = opTask.getResult();
ModelService modelService = getModelService();
for (ProcessInstanceDto processInstanceDto : processInstanceDtoList) {
String taskOid = processInstanceDto.getTaskOid();
try {
ObjectDelta<? extends ObjectType> deleteDelta = ObjectDelta.createDeleteDelta(TaskType.class, taskOid, getPrismContext());
modelService.executeChanges(Collections.<ObjectDelta<? extends ObjectType>>singletonList(deleteDelta), null, opTask, result);
} catch (CommonException | RuntimeException e) {
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't delete task (process instance) {}", e, taskOid);
}
}
if (result.isUnknown()) {
result.recomputeStatus();
}
if (result.isSuccess()) {
result.recordStatus(OperationResultStatus.SUCCESS, "Selected process instance(s) have been successfully deleted.");
}
showResult(result);
ProcessInstanceDtoProvider provider = (ProcessInstanceDtoProvider) getTable().getDataTable().getDataProvider();
provider.clearCache();
//refresh feedback and table
target.add(getFeedbackPanel());
target.add(getTable());
}
use of com.evolveum.midpoint.model.api.ModelService in project midpoint by Evolveum.
the class ProgressReporter method executeChanges.
/**
* Executes changes on behalf of the parent page. By default, changes are executed asynchronously (in
* a separate thread). However, when set in the midpoint configuration, changes are executed synchronously.
*
* @param deltas Deltas to be executed.
* @param options Model execution options.
* @param task Task in context of which the changes have to be executed.
* @param result Operation result.
* @param target AjaxRequestTarget into which any synchronous changes are signalized.
*/
public void executeChanges(final Collection<ObjectDelta<? extends ObjectType>> deltas, final boolean previewOnly, final ModelExecuteOptions options, final Task task, final OperationResult result, AjaxRequestTarget target) {
parentPage.startProcessing(target, result);
ModelService modelService = parentPage.getModelService();
ModelInteractionService modelInteractionService = parentPage.getModelInteractionService();
if (asynchronousExecution) {
executeChangesAsync(deltas, previewOnly, options, task, result, target, modelService, modelInteractionService);
} else {
executeChangesSync(deltas, previewOnly, options, task, result, target, modelService, modelInteractionService);
}
}
use of com.evolveum.midpoint.model.api.ModelService in project midpoint by Evolveum.
the class ObjectChangesExecutorImpl method executeChangesSync.
private Collection<ObjectDeltaOperation<? extends ObjectType>> executeChangesSync(Collection<ObjectDelta<? extends ObjectType>> deltas, ModelExecuteOptions options, Task task, OperationResult result) {
try {
MidPointApplication application = MidPointApplication.get();
ModelService service = application.getModel();
Collection<ObjectDeltaOperation<? extends ObjectType>> executedDeltas = service.executeChanges(deltas, options, task, result);
result.computeStatusIfUnknown();
return executedDeltas;
} catch (CommonException | RuntimeException e) {
LoggingUtils.logUnexpectedException(LOGGER, "Error executing changes", e);
if (!result.isFatalError()) {
// just to be sure the exception is recorded into the result
result.recordFatalError(e.getMessage(), e);
}
}
return null;
}
use of com.evolveum.midpoint.model.api.ModelService in project midpoint by Evolveum.
the class NameStep method discoverConnectors.
private void discoverConnectors(ConnectorHostType host) {
PageBase page = (PageBase) getPage();
Task task = page.createSimpleTask(OPERATION_DISCOVER_CONNECTORS);
OperationResult result = task.getResult();
try {
ModelService model = page.getModelService();
model.discoverConnectors(host, task, result);
} catch (CommonException | RuntimeException ex) {
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't discover connectors", ex);
} finally {
result.recomputeStatus();
}
if (WebComponentUtil.showResultInPage(result)) {
page.showResult(result);
}
}
use of com.evolveum.midpoint.model.api.ModelService in project midpoint by Evolveum.
the class ProgressAwareChangesExecutorImpl method executeChangesSync.
private void executeChangesSync(ProgressReporter reporter, Collection<ObjectDelta<? extends ObjectType>> deltas, boolean previewOnly, ModelExecuteOptions options, Task task, OperationResult result) {
try {
MidPointApplication application = MidPointApplication.get();
if (previewOnly) {
ModelInteractionService service = application.getModelInteractionService();
ModelContext previewResult = service.previewChanges(deltas, options, task, result);
reporter.setPreviewResult(previewResult);
} else {
ModelService service = application.getModel();
Collection<ObjectDeltaOperation<? extends ObjectType>> executedDeltas = service.executeChanges(deltas, options, task, result);
reporter.setObjectDeltaOperation(executedDeltas);
}
result.computeStatusIfUnknown();
} catch (CommonException | RuntimeException e) {
LoggingUtils.logUnexpectedException(LOGGER, "Error executing changes", e);
if (!result.isFatalError()) {
// just to be sure the exception is recorded into the result
result.recordFatalError(e.getMessage(), e);
}
}
}
Aggregations