use of com.evolveum.midpoint.task.api.Task in project midpoint by Evolveum.
the class PageTaskAdd method createResourceList.
private List<TaskAddResourcesDto> createResourceList() {
OperationResult result = new OperationResult(OPERATION_LOAD_RESOURCES);
Task task = createSimpleTask(OPERATION_LOAD_RESOURCES);
List<PrismObject<ResourceType>> resources = null;
List<TaskAddResourcesDto> resourceList = new ArrayList<TaskAddResourcesDto>();
try {
resources = getModelService().searchObjects(ResourceType.class, new ObjectQuery(), null, task, result);
result.recomputeStatus();
} catch (Exception ex) {
result.recordFatalError("Couldn't get resource list.", ex);
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't get resource list", ex);
}
// }
if (resources != null) {
ResourceType item = null;
for (PrismObject<ResourceType> resource : resources) {
item = resource.asObjectable();
resourceList.add(new TaskAddResourcesDto(item.getOid(), WebComponentUtil.getOrigStringFromPoly(item.getName())));
}
}
return resourceList;
}
use of com.evolveum.midpoint.task.api.Task in project midpoint by Evolveum.
the class PageTaskEdit method refreshTaskModels.
public void refreshTaskModels() {
TaskDto oldTaskDto = taskDtoModel.getObject();
if (oldTaskDto == null) {
LOGGER.warn("Null or empty taskModel");
return;
}
TaskManager taskManager = getTaskManager();
OperationResult result = new OperationResult("refresh");
Task operationTask = taskManager.createTaskInstance("refresh");
try {
LOGGER.debug("Refreshing task {}", oldTaskDto);
TaskType taskType = loadTaskType(oldTaskDto.getOid(), operationTask, result);
TaskDto newTaskDto = prepareTaskDto(taskType, operationTask, result);
final ObjectWrapper<TaskType> newWrapper = loadObjectWrapper(taskType.asPrismObject(), operationTask, result);
previousTaskDto = currentTaskDto;
currentTaskDto = newTaskDto;
taskDtoModel.setObject(newTaskDto);
objectWrapperModel.setObject(newWrapper);
} catch (ObjectNotFoundException | SchemaException | ExpressionEvaluationException | RuntimeException | Error e) {
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't refresh task {}", e, oldTaskDto);
}
}
use of com.evolveum.midpoint.task.api.Task in project midpoint by Evolveum.
the class PageTaskController method savePerformed.
void savePerformed(AjaxRequestTarget target) {
LOGGER.debug("Saving new task.");
OperationResult result = new OperationResult(PageTaskEdit.OPERATION_SAVE_TASK);
TaskDto dto = parentPage.getTaskDto();
Task operationTask = parentPage.createSimpleTask(PageTaskEdit.OPERATION_SAVE_TASK);
try {
List<ItemDelta<?, ?>> itemDeltas = getDeltasToExecute(dto);
ObjectDelta<TaskType> delta = ObjectDelta.createModifyDelta(dto.getOid(), itemDeltas, TaskType.class, parentPage.getPrismContext());
final Collection<ObjectDelta<? extends ObjectType>> deltas = Collections.<ObjectDelta<? extends ObjectType>>singletonList(delta);
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Saving task modifications:\n{}", DebugUtil.debugDump(deltas));
}
parentPage.getModelService().executeChanges(deltas, null, operationTask, result);
result.recomputeStatus();
} catch (Exception ex) {
result.recomputeStatus();
result.recordFatalError("Couldn't save task.", ex);
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't save task modifications", ex);
}
afterSave(target, result);
}
use of com.evolveum.midpoint.task.api.Task in project midpoint by Evolveum.
the class RoleMemberPanel method recomputeMembersPerformed.
@Override
protected void recomputeMembersPerformed(QueryScope scope, AjaxRequestTarget target) {
Task operationalTask = getPageBase().createSimpleTask(getTaskName("Recompute", scope));
executeMemberOperation(operationalTask, FocusType.COMPLEX_TYPE, getActionQuery(scope), null, TaskCategory.RECOMPUTATION, target);
}
use of com.evolveum.midpoint.task.api.Task in project midpoint by Evolveum.
the class NodeDtoProvider method internalIterator.
@Override
public Iterator<? extends NodeDto> internalIterator(long first, long count) {
Collection<String> selectedOids = getSelectedOids();
getAvailableData().clear();
OperationResult result = new OperationResult(OPERATION_LIST_NODES);
Task task = getTaskManager().createTaskInstance(OPERATION_LIST_NODES);
try {
ObjectPaging paging = createPaging(first, count);
ObjectQuery query = getQuery();
if (query == null) {
query = new ObjectQuery();
}
query.setPaging(paging);
List<PrismObject<NodeType>> nodes = getModel().searchObjects(NodeType.class, query, null, task, result);
for (PrismObject<NodeType> node : nodes) {
getAvailableData().add(createNodeDto(node));
}
result.recordSuccess();
} catch (Exception ex) {
LoggingUtils.logUnexpectedException(LOGGER, "Unhandled exception when listing nodes", ex);
result.recordFatalError("Couldn't list nodes.", ex);
}
setSelectedOids(selectedOids);
return getAvailableData().iterator();
}
Aggregations