use of com.evolveum.midpoint.web.page.admin.server.dto.TaskDto 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.web.page.admin.server.dto.TaskDto in project midpoint by Evolveum.
the class IterativeInformationPanel method showAgo.
protected boolean showAgo(TaskCurrentStateDto dto) {
boolean showAgo = false;
TaskDto taskDto = dto.getTaskDto();
if (taskDto != null) {
Long started = taskDto.getLastRunStartTimestampLong();
Long finished = taskDto.getLastRunFinishTimestampLong();
if (started != null && (finished == null || finished < started)) {
// for all running tasks
showAgo = true;
}
}
return showAgo;
}
use of com.evolveum.midpoint.web.page.admin.server.dto.TaskDto in project midpoint by Evolveum.
the class TaskBasicTabPanel method initLayoutBasic.
private void initLayoutBasic() {
// Name
WebMarkupContainer nameContainer = new WebMarkupContainer(ID_NAME_CONTAINER);
RequiredTextField<String> name = new RequiredTextField<>(ID_NAME, new PropertyModel<String>(taskDtoModel, TaskDto.F_NAME));
name.add(parentPage.createEnabledIfEdit(new ItemPath(TaskType.F_NAME)));
name.add(new AttributeModifier("style", "width: 100%"));
name.add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
nameContainer.add(name);
nameContainer.add(parentPage.createVisibleIfAccessible(new ItemPath(TaskType.F_NAME)));
add(nameContainer);
// Description
WebMarkupContainer descriptionContainer = new WebMarkupContainer(ID_DESCRIPTION_CONTAINER);
TextArea<String> description = new TextArea<>(ID_DESCRIPTION, new PropertyModel<String>(taskDtoModel, TaskDto.F_DESCRIPTION));
description.add(parentPage.createEnabledIfEdit(new ItemPath(TaskType.F_DESCRIPTION)));
// description.add(new AttributeModifier("style", "width: 100%"));
// description.add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
descriptionContainer.add(description);
descriptionContainer.add(parentPage.createVisibleIfAccessible(new ItemPath(TaskType.F_DESCRIPTION)));
add(descriptionContainer);
// OID
Label oid = new Label(ID_OID, new PropertyModel(getObjectWrapperModel(), ID_OID));
add(oid);
// Identifier
WebMarkupContainer identifierContainer = new WebMarkupContainer(ID_IDENTIFIER_CONTAINER);
identifierContainer.add(new Label(ID_IDENTIFIER, new PropertyModel(taskDtoModel, TaskDto.F_IDENTIFIER)));
identifierContainer.add(parentPage.createVisibleIfAccessible(new ItemPath(TaskType.F_TASK_IDENTIFIER)));
add(identifierContainer);
// Category
WebMarkupContainer categoryContainer = new WebMarkupContainer(ID_CATEGORY_CONTAINER);
categoryContainer.add(new Label(ID_CATEGORY, WebComponentUtil.createCategoryNameModel(this, new PropertyModel(taskDtoModel, TaskDto.F_CATEGORY))));
categoryContainer.add(parentPage.createVisibleIfAccessible(new ItemPath(TaskType.F_CATEGORY)));
add(categoryContainer);
// Parent
WebMarkupContainer parentContainer = new WebMarkupContainer(ID_PARENT_CONTAINER);
final LinkPanel parent = new LinkPanel(ID_PARENT, new PropertyModel<String>(taskDtoModel, TaskDto.F_PARENT_TASK_NAME)) {
@Override
public void onClick(AjaxRequestTarget target) {
String oid = taskDtoModel.getObject().getParentTaskOid();
if (oid != null) {
PageParameters parameters = new PageParameters();
parameters.add(OnePageParameterEncoder.PARAMETER, oid);
getPageBase().navigateToNext(PageTaskEdit.class, parameters);
}
}
};
parentContainer.add(parent);
parentContainer.add(parentPage.createVisibleIfAccessible(new ItemPath(TaskType.F_PARENT)));
add(parentContainer);
// Owner
WebMarkupContainer ownerContainer = new WebMarkupContainer(ID_OWNER_CONTAINER);
final LinkPanel owner = new LinkPanel(ID_OWNER, new PropertyModel<String>(taskDtoModel, TaskDto.F_OWNER_NAME)) {
@Override
public void onClick(AjaxRequestTarget target) {
String oid = taskDtoModel.getObject().getOwnerOid();
if (oid != null) {
PageParameters parameters = new PageParameters();
parameters.add(OnePageParameterEncoder.PARAMETER, oid);
getPageBase().navigateToNext(PageUser.class, parameters);
}
}
};
ownerContainer.add(owner);
ownerContainer.add(parentPage.createVisibleIfAccessible(new ItemPath(TaskType.F_OWNER_REF)));
add(ownerContainer);
// Handler URI
ListView<String> handlerUriContainer = new ListView<String>(ID_HANDLER_URI_CONTAINER, new PropertyModel(taskDtoModel, TaskDto.F_HANDLER_URI_LIST)) {
@Override
protected void populateItem(ListItem<String> item) {
item.add(new Label(ID_HANDLER_URI, item.getModelObject()));
}
};
handlerUriContainer.add(parentPage.createVisibleIfAccessible(new ItemPath(TaskType.F_HANDLER_URI), new ItemPath(TaskType.F_OTHER_HANDLERS_URI_STACK)));
add(handlerUriContainer);
// Execution
WebMarkupContainer executionContainer = new WebMarkupContainer(ID_EXECUTION_CONTAINER);
Label execution = new Label(ID_EXECUTION, new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
TaskDtoExecutionStatus executionStatus = taskDtoModel.getObject().getExecution();
if (executionStatus != TaskDtoExecutionStatus.CLOSED) {
return getString(TaskDtoExecutionStatus.class.getSimpleName() + "." + executionStatus.name());
} else {
return getString(TaskDtoExecutionStatus.class.getSimpleName() + "." + executionStatus.name() + ".withTimestamp", new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
if (taskDtoModel.getObject().getCompletionTimestamp() != null) {
// todo correct formatting
return new Date(taskDtoModel.getObject().getCompletionTimestamp()).toLocaleString();
} else {
return "?";
}
}
});
}
}
});
executionContainer.add(execution);
Label node = new Label(ID_NODE, new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
TaskDto dto = taskDtoModel.getObject();
if (!TaskDtoExecutionStatus.RUNNING.equals(dto.getExecution())) {
return null;
}
return parentPage.getString("pageTaskEdit.message.node", dto.getExecutingAt());
}
});
executionContainer.add(node);
executionContainer.add(parentPage.createVisibleIfAccessible(new ItemPath(TaskType.F_EXECUTION_STATUS), new ItemPath(TaskType.F_NODE_AS_OBSERVED)));
add(executionContainer);
}
use of com.evolveum.midpoint.web.page.admin.server.dto.TaskDto in project midpoint by Evolveum.
the class TaskButtonsVisibility method computeSuspendVisible.
public boolean computeSuspendVisible(PageTaskEdit parentPage) {
final TaskDto taskDto = parentPage.getTaskDto();
suspendVisible = !parentPage.isEdit() && taskDto.isRunnableOrRunning() && (!taskDto.isWorkflow() || parentPage.isShowAdvanced()) && parentPage.canSuspend();
return suspendVisible;
}
use of com.evolveum.midpoint.web.page.admin.server.dto.TaskDto in project midpoint by Evolveum.
the class PageTaskController method deleteSyncTokenPerformed.
public void deleteSyncTokenPerformed(AjaxRequestTarget target) {
LOGGER.debug("Deleting sync token.");
OperationResult result = new OperationResult(PageTaskEdit.OPERATION_DELETE_SYNC_TOKEN);
Task operationTask = parentPage.createSimpleTask(PageTaskEdit.OPERATION_DELETE_SYNC_TOKEN);
try {
final TaskDto taskDto = parentPage.getTaskDto();
final PrismProperty property = taskDto.getExtensionProperty(SchemaConstants.SYNC_TOKEN);
if (property == null) {
// should be treated by isVisible
result.recordWarning("Token is not present in this task.");
} else {
final ObjectDelta<? extends ObjectType> delta = (ObjectDelta<? extends ObjectType>) DeltaBuilder.deltaFor(TaskType.class, parentPage.getPrismContext()).item(new ItemPath(TaskType.F_EXTENSION, SchemaConstants.SYNC_TOKEN), property.getDefinition()).replace().asObjectDelta(parentPage.getTaskDto().getOid());
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Deleting sync token:\n{}", delta.debugDump());
}
parentPage.getModelService().executeChanges(Collections.<ObjectDelta<? extends ObjectType>>singleton(delta), null, operationTask, result);
result.recomputeStatus();
}
} catch (Exception ex) {
result.recomputeStatus();
result.recordFatalError("Couldn't delete sync token from the task.", ex);
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't delete sync token from the task.", ex);
}
afterStateChangingOperation(target, result);
}
Aggregations