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);
}
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;
}
}
};
}
Aggregations