use of com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType in project midpoint by Evolveum.
the class PageTaskAdd method savePerformed.
private void savePerformed(AjaxRequestTarget target) {
LOGGER.debug("Saving new task.");
OperationResult result = new OperationResult(OPERATION_SAVE_TASK);
TaskAddDto dto = model.getObject();
Task operationTask = createSimpleTask(OPERATION_SAVE_TASK);
try {
TaskType task = createTask(dto);
getPrismContext().adopt(task);
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Adding new task.");
}
getModelService().executeChanges(prepareChangesToExecute(task), null, operationTask, result);
result.recomputeStatus();
setResponsePage(PageTasks.class);
} catch (Exception ex) {
result.recomputeStatus();
result.recordFatalError("Unable to save task.", ex);
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't add new task", ex);
}
showResult(result);
target.add(getFeedbackPanel());
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType in project midpoint by Evolveum.
the class PageTaskEdit method loadTaskTypeChecked.
private TaskType loadTaskTypeChecked(String taskOid, Task operationTask, OperationResult result) {
TaskType taskType = loadTaskType(taskOid, operationTask, result);
if (!result.isSuccess()) {
showResult(result);
}
if (taskType == null) {
getSession().error(getString("pageTaskEdit.message.cantTaskDetails"));
showResult(result, false);
throw getRestartResponseException(PageTasks.class);
}
return taskType;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType 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.xml.ns._public.common.common_3.TaskType in project midpoint by Evolveum.
the class PageTaskAdd method createTask.
private TaskType createTask(TaskAddDto dto) throws SchemaException {
TaskType task = new TaskType();
MidPointPrincipal owner = SecurityUtils.getPrincipalUser();
ObjectReferenceType ownerRef = new ObjectReferenceType();
ownerRef.setOid(owner.getOid());
ownerRef.setType(owner.getUser().COMPLEX_TYPE);
task.setOwnerRef(ownerRef);
task.setCategory(dto.getCategory());
String handlerUri = getTaskManager().getHandlerUriForCategory(dto.getCategory());
if (handlerUri == null) {
throw new SystemException("Cannot determine task handler URI for category " + dto.getCategory());
}
task.setHandlerUri(handlerUri);
ObjectReferenceType objectRef;
if (dto.getResource() != null) {
objectRef = new ObjectReferenceType();
objectRef.setOid(dto.getResource().getOid());
objectRef.setType(ResourceType.COMPLEX_TYPE);
task.setObjectRef(objectRef);
}
task.setName(WebComponentUtil.createPolyFromOrigString(dto.getName()));
task.setRecurrence(dto.getReccuring() ? TaskRecurrenceType.RECURRING : TaskRecurrenceType.SINGLE);
task.setBinding(dto.getBound() ? TaskBindingType.TIGHT : TaskBindingType.LOOSE);
ScheduleType schedule = new ScheduleType();
schedule.setInterval(dto.getInterval());
schedule.setCronLikePattern(dto.getCron());
schedule.setEarliestStartTime(MiscUtil.asXMLGregorianCalendar(dto.getNotStartBefore()));
schedule.setLatestStartTime(MiscUtil.asXMLGregorianCalendar(dto.getNotStartAfter()));
schedule.setMisfireAction(dto.getMisfireAction());
task.setSchedule(schedule);
if (dto.getSuspendedState()) {
task.setExecutionStatus(TaskExecutionStatusType.SUSPENDED);
} else {
task.setExecutionStatus(TaskExecutionStatusType.RUNNABLE);
}
if (dto.getThreadStop() != null) {
task.setThreadStopAction(dto.getThreadStop());
} else {
// fill-in default
if (dto.getRunUntilNodeDown() == true) {
task.setThreadStopAction(ThreadStopActionType.CLOSE);
} else {
task.setThreadStopAction(ThreadStopActionType.RESTART);
}
}
if (dto.isDryRun()) {
PrismObject<TaskType> prismTask = task.asPrismObject();
ItemPath path = new ItemPath(TaskType.F_EXTENSION, SchemaConstants.MODEL_EXTENSION_DRY_RUN);
PrismProperty dryRun = prismTask.findOrCreateProperty(path);
SchemaRegistry registry = getPrismContext().getSchemaRegistry();
PrismPropertyDefinition def = registry.findPropertyDefinitionByElementName(SchemaConstants.MODEL_EXTENSION_DRY_RUN);
dryRun.setDefinition(def);
dryRun.setRealValue(true);
}
if (dto.getFocusType() != null) {
PrismObject<TaskType> prismTask = task.asPrismObject();
ItemPath path = new ItemPath(TaskType.F_EXTENSION, SchemaConstants.MODEL_EXTENSION_OBJECT_TYPE);
PrismProperty focusType = prismTask.findOrCreateProperty(path);
focusType.setRealValue(dto.getFocusType());
}
if (dto.getKind() != null) {
PrismObject<TaskType> prismTask = task.asPrismObject();
ItemPath path = new ItemPath(TaskType.F_EXTENSION, SchemaConstants.MODEL_EXTENSION_KIND);
PrismProperty kind = prismTask.findOrCreateProperty(path);
SchemaRegistry registry = getPrismContext().getSchemaRegistry();
PrismPropertyDefinition def = registry.findPropertyDefinitionByElementName(SchemaConstants.MODEL_EXTENSION_KIND);
kind.setDefinition(def);
kind.setRealValue(dto.getKind());
}
if (dto.getIntent() != null && StringUtils.isNotEmpty(dto.getIntent())) {
PrismObject<TaskType> prismTask = task.asPrismObject();
ItemPath path = new ItemPath(TaskType.F_EXTENSION, SchemaConstants.MODEL_EXTENSION_INTENT);
PrismProperty intent = prismTask.findOrCreateProperty(path);
SchemaRegistry registry = getPrismContext().getSchemaRegistry();
PrismPropertyDefinition def = registry.findPropertyDefinitionByElementName(SchemaConstants.MODEL_EXTENSION_INTENT);
intent.setDefinition(def);
intent.setRealValue(dto.getIntent());
}
if (dto.getObjectClass() != null && StringUtils.isNotEmpty(dto.getObjectClass())) {
PrismObject<TaskType> prismTask = task.asPrismObject();
ItemPath path = new ItemPath(TaskType.F_EXTENSION, SchemaConstants.OBJECTCLASS_PROPERTY_NAME);
PrismProperty objectClassProperty = prismTask.findOrCreateProperty(path);
QName objectClass = null;
for (QName q : model.getObject().getObjectClassList()) {
if (q.getLocalPart().equals(dto.getObjectClass())) {
objectClass = q;
}
}
SchemaRegistry registry = getPrismContext().getSchemaRegistry();
PrismPropertyDefinition def = registry.findPropertyDefinitionByElementName(SchemaConstants.OBJECTCLASS_PROPERTY_NAME);
objectClassProperty.setDefinition(def);
objectClassProperty.setRealValue(objectClass);
}
return task;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType in project midpoint by Evolveum.
the class PageTaskEdit method initLayout.
protected void initLayout() {
refreshModel = new Model(new AutoRefreshDto());
refreshModel.getObject().setInterval(getRefreshInterval());
IModel<PrismObject<TaskType>> prismObjectModel = new AbstractReadOnlyModel<PrismObject<TaskType>>() {
@Override
public PrismObject<TaskType> getObject() {
return objectWrapperModel.getObject().getObject();
}
};
final TaskSummaryPanel summaryPanel = new TaskSummaryPanel(ID_SUMMARY_PANEL, prismObjectModel, refreshModel, this);
summaryPanel.setOutputMarkupId(true);
add(summaryPanel);
mainPanel = new TaskMainPanel(ID_MAIN_PANEL, objectWrapperModel, taskDtoModel, showAdvancedFeaturesModel, this);
mainPanel.setOutputMarkupId(true);
add(mainPanel);
summaryPanel.getRefreshPanel().startRefreshing(this, null);
}
Aggregations