Search in sources :

Example 1 with TaskType

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;
}
Also used : EnvironmentalPerformanceInformationType(com.evolveum.midpoint.xml.ns._public.common.common_3.EnvironmentalPerformanceInformationType) OperationStatsType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationStatsType)

Example 2 with TaskType

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);
    }
}
Also used : MidPointApplication(com.evolveum.midpoint.web.security.MidPointApplication) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) SystemException(com.evolveum.midpoint.util.exception.SystemException) PrismContext(com.evolveum.midpoint.prism.PrismContext) TaskType(com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType) ReportParameterType(com.evolveum.midpoint.xml.ns._public.common.common_3.ReportParameterType) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 3 with TaskType

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());
    }
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) Task(com.evolveum.midpoint.task.api.Task) ExpressionEvaluationException(com.evolveum.midpoint.util.exception.ExpressionEvaluationException) CommunicationException(com.evolveum.midpoint.util.exception.CommunicationException) SecurityViolationException(com.evolveum.midpoint.util.exception.SecurityViolationException) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) TaskManager(com.evolveum.midpoint.task.api.TaskManager) SelectorOptions(com.evolveum.midpoint.schema.SelectorOptions) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) TaskType(com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException)

Example 4 with TaskType

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();
}
Also used : Task(com.evolveum.midpoint.task.api.Task) QName(javax.xml.namespace.QName) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ExpressionEvaluationException(com.evolveum.midpoint.util.exception.ExpressionEvaluationException) PrismObject(com.evolveum.midpoint.prism.PrismObject) ObjectPaging(com.evolveum.midpoint.prism.query.ObjectPaging) SelectorOptions(com.evolveum.midpoint.schema.SelectorOptions) TaskType(com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType)

Example 5 with TaskType

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));
            }
        }
    };
}
Also used : AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) TaskType(com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType) PatternDateConverter(org.apache.wicket.datetime.PatternDateConverter) Date(java.util.Date)

Aggregations

TaskType (com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType)88 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)63 Test (org.testng.annotations.Test)50 Task (com.evolveum.midpoint.task.api.Task)47 PrismObject (com.evolveum.midpoint.prism.PrismObject)30 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)25 OperationResultType (com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType)23 AbstractModelIntegrationTest (com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)19 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)18 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)17 PrismAsserts.assertEqualsPolyString (com.evolveum.midpoint.prism.util.PrismAsserts.assertEqualsPolyString)16 AbstractInitializedModelIntegrationTest (com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)15 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)15 ArrayList (java.util.ArrayList)14 QName (javax.xml.namespace.QName)13 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)11 ObjectDeltaType (com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType)10 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)8 Checker (com.evolveum.midpoint.test.Checker)8 ObjectChecker (com.evolveum.midpoint.test.ObjectChecker)8