Search in sources :

Example 16 with TaskDto

use of com.evolveum.midpoint.web.page.admin.server.dto.TaskDto in project midpoint by Evolveum.

the class TaskSchedulingTabPanel method initLayoutForInfoPanel.

private void initLayoutForInfoPanel() {
    // last start
    WebMarkupContainer lastStartedContainer = new WebMarkupContainer(ID_LAST_STARTED_CONTAINER);
    Label lastStart = new Label(ID_LAST_STARTED, new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            TaskDto dto = taskDtoModel.getObject();
            if (dto.getLastRunStartTimestampLong() == null) {
                return "-";
            } else {
                return WebComponentUtil.formatDate(new Date(dto.getLastRunStartTimestampLong()));
            }
        }
    });
    lastStartedContainer.add(lastStart);
    Label lastStartAgo = new Label(ID_LAST_STARTED_AGO, new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            TaskDto dto = taskDtoModel.getObject();
            if (dto.getLastRunStartTimestampLong() == null) {
                return "";
            } else {
                final long ago = System.currentTimeMillis() - dto.getLastRunStartTimestampLong();
                return createStringResource("TaskStatePanel.message.ago", DurationFormatUtils.formatDurationWords(ago, true, true)).getString();
            }
        }
    });
    lastStartedContainer.add(lastStartAgo);
    lastStartedContainer.add(parentPage.createVisibleIfAccessible(TaskType.F_LAST_RUN_START_TIMESTAMP));
    add(lastStartedContainer);
    // last finish
    WebMarkupContainer lastFinishedContainer = new WebMarkupContainer(ID_LAST_FINISHED_CONTAINER);
    Label lastFinished = new Label(ID_LAST_FINISHED, new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            TaskDto dto = taskDtoModel.getObject();
            if (dto.getLastRunFinishTimestampLong() == null) {
                return "-";
            } else {
                return WebComponentUtil.formatDate(new Date(dto.getLastRunFinishTimestampLong()));
            }
        }
    });
    lastFinishedContainer.add(lastFinished);
    Label lastFinishedAgo = new Label(ID_LAST_FINISHED_AGO, new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            TaskDto dto = taskDtoModel.getObject();
            if (dto.getLastRunFinishTimestampLong() == null) {
                return "";
            } else {
                Long duration;
                if (dto.getLastRunStartTimestampLong() == null || dto.getLastRunFinishTimestampLong() < dto.getLastRunStartTimestampLong()) {
                    duration = null;
                } else {
                    duration = dto.getLastRunFinishTimestampLong() - dto.getLastRunStartTimestampLong();
                }
                long ago = System.currentTimeMillis() - dto.getLastRunFinishTimestampLong();
                if (duration != null) {
                    return getString("TaskStatePanel.message.durationAndAgo", DurationFormatUtils.formatDurationWords(ago, true, true), duration);
                } else {
                    return getString("TaskStatePanel.message.ago", DurationFormatUtils.formatDurationWords(ago, true, true));
                }
            }
        }
    });
    lastFinishedContainer.add(lastFinishedAgo);
    lastFinishedContainer.add(parentPage.createVisibleIfAccessible(TaskType.F_LAST_RUN_FINISH_TIMESTAMP));
    add(lastFinishedContainer);
    WebMarkupContainer nextRunContainer = new WebMarkupContainer(ID_NEXT_RUN_CONTAINER);
    Label nextRun = new Label(ID_NEXT_RUN, new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            TaskDto dto = taskDtoModel.getObject();
            if (dto.isRecurring() && dto.isBound() && dto.isRunning()) {
                return getString("pageTasks.runsContinually");
            } else if (dto.getNextRunStartTimeLong() == null) {
                return "-";
            } else {
                return WebComponentUtil.formatDate(new Date(dto.getNextRunStartTimeLong()));
            }
        }
    });
    nextRunContainer.add(nextRun);
    Label nextRunIn = new Label(ID_NEXT_RUN_IN, new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            TaskDto dto = taskDtoModel.getObject();
            if (dto.getNextRunStartTimeLong() == null || (dto.isRecurring() && dto.isBound() && dto.isRunning())) {
                return "";
            } else {
                long currentTime = System.currentTimeMillis();
                final long in = dto.getNextRunStartTimeLong() - currentTime;
                if (in >= 0) {
                    return getString("TaskStatePanel.message.in", DurationFormatUtils.formatDurationWords(in, true, true));
                } else {
                    return "";
                }
            }
        }
    });
    nextRunContainer.add(nextRunIn);
    nextRunContainer.add(parentPage.createVisibleIfAccessible(TaskType.F_NEXT_RUN_START_TIMESTAMP));
    add(nextRunContainer);
    WebMarkupContainer nextRetryContainer = new WebMarkupContainer(ID_NEXT_RETRY_CONTAINER);
    Label nextRetry = new Label(ID_NEXT_RETRY, new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            TaskDto dto = taskDtoModel.getObject();
            if (dto.getNextRetryTimeLong() == null) {
                return "-";
            } else {
                return WebComponentUtil.formatDate(new Date(dto.getNextRetryTimeLong()));
            }
        }
    });
    nextRetryContainer.add(nextRetry);
    Label nextRetryIn = new Label(ID_NEXT_RETRY_IN, new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            TaskDto dto = taskDtoModel.getObject();
            if (dto.getNextRetryTimeLong() == null) /* || (dto.isRecurring() && dto.isBound() && dto.isRunning()) */
            {
                return "";
            } else {
                long currentTime = System.currentTimeMillis();
                final long in = dto.getNextRetryTimeLong() - currentTime;
                if (in >= 0) {
                    return getString("TaskStatePanel.message.in", DurationFormatUtils.formatDurationWords(in, true, true));
                } else {
                    return "";
                }
            }
        }
    });
    nextRetryContainer.add(nextRetryIn);
    nextRetryContainer.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return taskDtoModel.getObject().getNextRetryTimeLong() != null;
        }
    });
    add(nextRetryContainer);
}
Also used : Label(org.apache.wicket.markup.html.basic.Label) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) TaskDto(com.evolveum.midpoint.web.page.admin.server.dto.TaskDto) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) Date(java.util.Date)

Example 17 with TaskDto

use of com.evolveum.midpoint.web.page.admin.server.dto.TaskDto in project midpoint by Evolveum.

the class TaskSummaryPanel method getTitleModel.

@Override
protected IModel<String> getTitleModel() {
    return new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            TaskDto taskDto = parentPage.getTaskDto();
            if (taskDto.isWorkflow()) {
                return getString("TaskSummaryPanel.requestedBy", parentPage.getTaskDto().getRequestedBy());
            //						return getString("TaskSummaryPanel.requestedByAndOn",
            //								parentPage.getTaskDto().getRequestedBy(), getRequestedOn());
            } else {
                TaskType taskType = getModelObject();
                String rv;
                if (taskType.getExpectedTotal() != null) {
                    rv = createStringResource("TaskSummaryPanel.progressWithTotalKnown", taskType.getProgress(), taskType.getExpectedTotal()).getString();
                } else {
                    rv = createStringResource("TaskSummaryPanel.progressWithTotalUnknown", taskType.getProgress()).getString();
                }
                if (taskDto.isSuspended()) {
                    rv += " " + getString("TaskSummaryPanel.progressIfSuspended");
                } else if (taskDto.isClosed()) {
                    rv += " " + getString("TaskSummaryPanel.progressIfClosed");
                } else if (taskDto.isWaiting()) {
                    rv += " " + getString("TaskSummaryPanel.progressIfWaiting");
                } else if (taskDto.getStalledSince() != null) {
                    rv += " " + getString("TaskSummaryPanel.progressIfStalled", WebComponentUtil.formatDate(new Date(parentPage.getTaskDto().getStalledSince())));
                }
                return rv;
            }
        }
    };
}
Also used : AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) TaskType(com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType) TaskDto(com.evolveum.midpoint.web.page.admin.server.dto.TaskDto) Date(java.util.Date)

Aggregations

TaskDto (com.evolveum.midpoint.web.page.admin.server.dto.TaskDto)17 ArrayList (java.util.ArrayList)4 Date (java.util.Date)4 Label (org.apache.wicket.markup.html.basic.Label)4 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)3 Task (com.evolveum.midpoint.task.api.Task)3 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)3 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)3 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)3 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)2 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)2 SecurityViolationException (com.evolveum.midpoint.util.exception.SecurityViolationException)2 ListDataProvider (com.evolveum.midpoint.web.component.util.ListDataProvider)2 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)2 TaskType (com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType)2 Component (org.apache.wicket.Component)2 IColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn)2 AbstractReadOnlyModel (org.apache.wicket.model.AbstractReadOnlyModel)2 PrismProperty (com.evolveum.midpoint.prism.PrismProperty)1 ItemDelta (com.evolveum.midpoint.prism.delta.ItemDelta)1