use of com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType in project midpoint by Evolveum.
the class StatisticsDtoModel method getStatisticsFromTaskType.
protected StatisticsDto getStatisticsFromTaskType(TaskType task) {
OperationStatsType operationStats = task.getOperationStats();
if (operationStats == null) {
LOGGER.warn("No operational information in task");
return null;
}
EnvironmentalPerformanceInformationType envInfo = operationStats.getEnvironmentalPerformanceInformation();
if (envInfo == null) {
LOGGER.warn("No environmental performance information in task");
return null;
}
StatisticsDto dto = new StatisticsDto(envInfo);
return dto;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType in project midpoint by Evolveum.
the class ReportCreateHandlerDto method getReportParams.
public String getReportParams() {
PrismObject<TaskType> taskObject = taskDto.getTaskType().asPrismObject();
PrismContainer<ReportParameterType> container = taskObject.findContainer(new ItemPath(TaskType.F_EXTENSION, ReportConstants.REPORT_PARAMS_PROPERTY_NAME));
if (container == null || container.isEmpty()) {
return null;
}
PrismContainerValue<ReportParameterType> pcv = container.getValue();
PrismContext prismContext = ((MidPointApplication) Application.get()).getPrismContext();
try {
return WebXmlUtil.stripNamespaceDeclarations(prismContext.xmlSerializer().serialize(pcv, ReportConstants.REPORT_PARAMS_PROPERTY_NAME));
} catch (SchemaException e) {
throw new SystemException("Couldn't serialize report parameters: " + e.getMessage(), e);
}
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType in project midpoint by Evolveum.
the class TaskCurrentStateDtoModel method refresh.
public void refresh(PageBase page) {
object = null;
if (taskModel == null || taskModel.getObject() == null) {
LOGGER.warn("Null or empty taskModel");
return;
}
TaskManager taskManager = page.getTaskManager();
OperationResult result = new OperationResult("refresh");
Task operationTask = taskManager.createTaskInstance("refresh");
String oid = taskModel.getObject().getOid();
try {
LOGGER.debug("Refreshing task {}", taskModel.getObject());
Collection<SelectorOptions<GetOperationOptions>> options = GetOperationOptions.createRetrieveAttributesOptions(TaskType.F_SUBTASK, TaskType.F_NODE_AS_OBSERVED);
PrismObject<TaskType> task = page.getModelService().getObject(TaskType.class, oid, options, operationTask, result);
TaskDto taskDto = new TaskDto(task.asObjectable(), page.getModelService(), page.getTaskService(), page.getModelInteractionService(), taskManager, page.getWorkflowManager(), TaskDtoProviderOptions.fullOptions(), operationTask, result, page);
taskModel.setObject(taskDto);
} catch (CommunicationException | ObjectNotFoundException | SchemaException | SecurityViolationException | ConfigurationException | ExpressionEvaluationException | RuntimeException e) {
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't refresh task {}", e, taskModel.getObject());
}
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType in project midpoint by Evolveum.
the class TaskDtoProvider method internalIterator.
@Override
public Iterator<? extends TaskDto> internalIterator(long first, long count) {
Collection<String> selectedOids = getSelectedOids();
getAvailableData().clear();
OperationResult result = new OperationResult(OPERATION_LIST_TASKS);
Task operationTask = getTaskManager().createTaskInstance(OPERATION_LIST_TASKS);
try {
ObjectPaging paging = createPaging(first, count);
ObjectQuery query = getQuery();
if (query == null) {
query = new ObjectQuery();
}
query.setPaging(paging);
List<QName> propertiesToGet = new ArrayList<>();
if (options.isUseClusterInformation()) {
propertiesToGet.add(TaskType.F_NODE_AS_OBSERVED);
}
if (options.isGetNextRunStartTime()) {
propertiesToGet.add(TaskType.F_NEXT_RUN_START_TIMESTAMP);
propertiesToGet.add(TaskType.F_NEXT_RETRY_TIMESTAMP);
}
Collection<SelectorOptions<GetOperationOptions>> searchOptions = GetOperationOptions.createRetrieveAttributesOptions(propertiesToGet.toArray(new QName[0]));
List<PrismObject<TaskType>> tasks = getModel().searchObjects(TaskType.class, query, searchOptions, operationTask, result);
for (PrismObject<TaskType> task : tasks) {
try {
TaskDto taskDto = createTaskDto(task, operationTask, result);
getAvailableData().add(taskDto);
} catch (Exception ex) {
LoggingUtils.logUnexpectedException(LOGGER, "Unhandled exception when getting task {} details", ex, task.getOid());
result.recordPartialError("Couldn't get details of task " + task.getOid(), ex);
// todo display the result somehow
}
}
} catch (Exception ex) {
LoggingUtils.logUnexpectedException(LOGGER, "Unhandled exception when listing tasks", ex);
result.recordFatalError("Couldn't list tasks.", ex);
} finally {
if (result.hasUnknownStatus()) {
result.recomputeStatus();
}
}
setSelectedOids(selectedOids);
return getAvailableData().iterator();
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType in project midpoint by Evolveum.
the class TaskSummaryPanel method getTitle3Model.
@Override
protected IModel<String> getTitle3Model() {
return new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
if (parentPage.getTaskDto().isWorkflow()) {
String stageInfo = getStageInfo();
if (stageInfo != null) {
return getString("TaskSummaryPanel.stage", stageInfo);
} else {
return null;
}
}
TaskType taskType = getModel().getObject();
if (taskType == null) {
return null;
}
long started = XmlTypeConverter.toMillis(taskType.getLastRunStartTimestamp());
long finished = XmlTypeConverter.toMillis(taskType.getLastRunFinishTimestamp());
if (started == 0) {
return null;
}
if ((TaskExecutionStatus.RUNNABLE.equals(taskType.getExecutionStatus()) && taskType.getNodeAsObserved() != null) || finished == 0 || finished < started) {
PatternDateConverter pdc = new PatternDateConverter(WebComponentUtil.getLocalizedDatePattern(DateLabelComponent.SHORT_MEDIUM_STYLE), true);
String date = pdc.convertToString(new Date(started), WebComponentUtil.getCurrentLocale());
return getString("TaskStatePanel.message.executionTime.notFinished", date, DurationFormatUtils.formatDurationHMS(System.currentTimeMillis() - started));
} else {
PatternDateConverter pdc = new PatternDateConverter(WebComponentUtil.getLocalizedDatePattern(DateLabelComponent.SHORT_MEDIUM_STYLE), true);
String startedDate = pdc.convertToString(new Date(started), WebComponentUtil.getCurrentLocale());
String finishedDate = pdc.convertToString(new Date(finished), WebComponentUtil.getCurrentLocale());
return getString("TaskStatePanel.message.executionTime.finished", startedDate, finishedDate, DurationFormatUtils.formatDurationHMS(finished - started));
}
}
};
}
Aggregations