use of com.evolveum.midpoint.task.api.Task in project midpoint by Evolveum.
the class PageSelfRegistration method initDynamicFormLayout.
private void initDynamicFormLayout(final Form<?> mainForm) {
WebMarkupContainer dynamicRegistrationForm = createMarkupContainer(ID_DYNAMIC_FORM, new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return getSelfRegistrationConfiguration().getFormRef() != null;
}
}, mainForm);
DynamicFormPanel<UserType> dynamicForm = runPrivileged(() -> {
final ObjectReferenceType ort = getSelfRegistrationConfiguration().getFormRef();
if (ort == null) {
return null;
}
Task task = createAnonymousTask(OPERATION_LOAD_DYNAMIC_FORM);
return new DynamicFormPanel<UserType>(ID_DYNAMIC_FORM_PANEL, userModel, ort.getOid(), mainForm, task, PageSelfRegistration.this);
});
if (dynamicForm != null) {
dynamicRegistrationForm.add(dynamicForm);
}
}
use of com.evolveum.midpoint.task.api.Task in project midpoint by Evolveum.
the class WorkItemDtoProvider method internalIterator.
@Override
public Iterator<? extends WorkItemDto> internalIterator(long first, long count) {
getAvailableData().clear();
Task task = getTaskManager().createTaskInstance();
OperationResult result = new OperationResult(OPERATION_LIST_ITEMS);
try {
ObjectQuery query = createQuery(first, count, result);
Collection<SelectorOptions<GetOperationOptions>> options = GetOperationOptions.resolveItemsNamed(new ItemPath(F_ASSIGNEE_REF), new ItemPath(T_PARENT, WfContextType.F_OBJECT_REF), new ItemPath(T_PARENT, WfContextType.F_TARGET_REF));
List<WorkItemType> items = getModel().searchContainers(WorkItemType.class, query, options, task, result);
for (WorkItemType item : items) {
try {
getAvailableData().add(new WorkItemDto(item));
} catch (Exception e) {
LoggingUtils.logUnexpectedException(LOGGER, "Unhandled exception when listing work item {}", e, item);
result.recordFatalError("Couldn't list work item.", e);
}
}
} catch (SchemaException | ObjectNotFoundException | SecurityViolationException | ConfigurationException | RuntimeException ex) {
LoggingUtils.logUnexpectedException(LOGGER, "Unhandled exception when listing work items", ex);
result.recordFatalError("Couldn't list work items.", ex);
}
if (result.isUnknown()) {
result.computeStatus();
}
return getAvailableData().iterator();
}
use of com.evolveum.midpoint.task.api.Task in project midpoint by Evolveum.
the class TreeTablePanel method moveConfirmPerformed.
private void moveConfirmPerformed(SelectableBean<OrgType> orgToMove, SelectableBean<OrgType> selected, AjaxRequestTarget target) {
getPageBase().hideMainPopup(target);
Task task = getPageBase().createSimpleTask(OPERATION_MOVE_OBJECT);
OperationResult result = new OperationResult(OPERATION_MOVE_OBJECT);
OrgType toMove = orgToMove.getValue();
if (toMove == null || selected.getValue() == null) {
return;
}
ObjectDelta<OrgType> moveOrgDelta = ObjectDelta.createEmptyModifyDelta(OrgType.class, toMove.getOid(), getPageBase().getPrismContext());
try {
for (OrgType parentOrg : toMove.getParentOrg()) {
AssignmentType oldRoot = new AssignmentType();
oldRoot.setTargetRef(ObjectTypeUtil.createObjectRef(parentOrg));
moveOrgDelta.addModification(ContainerDelta.createModificationDelete(OrgType.F_ASSIGNMENT, OrgType.class, getPageBase().getPrismContext(), oldRoot.asPrismContainerValue()));
// moveOrgDelta.addModification(ReferenceDelta.createModificationDelete(OrgType.F_PARENT_ORG_REF,
// toMove.asPrismObject().getDefinition(),
// ObjectTypeUtil.createObjectRef(parentOrg).asReferenceValue()));
}
AssignmentType newRoot = new AssignmentType();
newRoot.setTargetRef(ObjectTypeUtil.createObjectRef(selected.getValue()));
moveOrgDelta.addModification(ContainerDelta.createModificationAdd(OrgType.F_ASSIGNMENT, OrgType.class, getPageBase().getPrismContext(), newRoot.asPrismContainerValue()));
// moveOrgDelta.addModification(ReferenceDelta.createModificationAdd(OrgType.F_PARENT_ORG_REF,
// toMove.asPrismObject().getDefinition(),
// ObjectTypeUtil.createObjectRef(selected.getValue()).asReferenceValue()));
getPageBase().getPrismContext().adopt(moveOrgDelta);
getPageBase().getModelService().executeChanges(WebComponentUtil.createDeltaCollection(moveOrgDelta), null, task, result);
result.computeStatus();
} catch (ObjectAlreadyExistsException | ObjectNotFoundException | SchemaException | ExpressionEvaluationException | CommunicationException | ConfigurationException | PolicyViolationException | SecurityViolationException e) {
result.recordFatalError("Failed to move organization unit " + toMove, e);
LoggingUtils.logUnexpectedException(LOGGER, "Failed to move organization unit" + toMove, e);
}
parentPage.showResult(result);
target.add(parentPage.getFeedbackPanel());
setResponsePage(PageOrgTree.class);
}
use of com.evolveum.midpoint.task.api.Task in project midpoint by Evolveum.
the class AbstractSearchIterativeResultHandler method createWorkerThreads.
public void createWorkerThreads(Task coordinatorTask, OperationResult opResult) {
Integer threadsCount = getWorkerThreadsCount(coordinatorTask);
if (threadsCount == null || threadsCount == 0) {
// nothing to do
return;
}
// actually, size of threadsCount should be sufficient but it doesn't hurt if queue is larger
int queueSize = threadsCount * 2;
requestQueue = new ArrayBlockingQueue<>(queueSize);
workerSpecificResults = new ArrayList<>(threadsCount);
for (int i = 0; i < threadsCount; i++) {
// we intentionally do not put worker specific result under main operation result until the handler is done
// (because of concurrency issues - adding subresults vs e.g. putting main result into the task)
OperationResult workerSpecificResult = new OperationResult(taskOperationPrefix + ".handleAsynchronously");
workerSpecificResult.addContext("subtask", i);
workerSpecificResults.add(workerSpecificResult);
Task subtask = coordinatorTask.createSubtask(new WorkerHandler(workerSpecificResult));
if (isEnableIterationStatistics()) {
subtask.resetIterativeTaskInformation(null);
}
if (isEnableSynchronizationStatistics()) {
subtask.resetSynchronizationInformation(null);
}
if (isEnableActionsExecutedStatistics()) {
subtask.resetActionsExecutedInformation(null);
}
subtask.setCategory(coordinatorTask.getCategory());
subtask.setResult(new OperationResult(taskOperationPrefix + ".executeWorker", OperationResultStatus.IN_PROGRESS, null));
subtask.setName("Worker thread " + (i + 1) + " of " + threadsCount);
subtask.startLightweightHandler();
LOGGER.trace("Worker subtask {} created", subtask);
}
}
use of com.evolveum.midpoint.task.api.Task in project midpoint by Evolveum.
the class ControllerGetObjectTest method nullClass.
@Test(expectedExceptions = IllegalArgumentException.class)
public void nullClass() throws Exception {
Task task = taskManager.createTaskInstance("Get Object");
controller.getObject(null, "abababab-abab-abab-abab-000000000001", null, task, task.getResult());
}
Aggregations