Skip to content

Commit

Permalink
Interim commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
mederly committed Sep 14, 2015
1 parent 04e6abe commit bc23a83
Show file tree
Hide file tree
Showing 12 changed files with 426 additions and 43 deletions.
Expand Up @@ -24,6 +24,7 @@
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.ListView;
import org.apache.wicket.model.AbstractReadOnlyModel;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.PropertyModel;

import java.util.ArrayList;
Expand Down Expand Up @@ -81,6 +82,7 @@ public class StatisticsPanel extends SimplePanel<ProgressDto> {

private WebMarkupContainer contentsPanel;
private transient Task task;
private IModel<Task> taskModel;

public StatisticsPanel(String id) {
super(id);
Expand All @@ -91,6 +93,11 @@ public StatisticsPanel(String id, Task task) {
this.task = task;
}

public StatisticsPanel(String id, IModel<Task> taskModel) {
super(id);
this.taskModel = taskModel;
}

protected void initLayout() {
contentsPanel = new WebMarkupContainer(ID_CONTENTS_PANEL);
contentsPanel.setOutputMarkupId(true);
Expand All @@ -99,10 +106,11 @@ protected void initLayout() {
ListView provisioningLines = new ListView<ProvisioningStatisticsLineDto>(ID_PROVISIONING_STATISTICS_LINES, new AbstractReadOnlyModel<List<ProvisioningStatisticsLineDto>>() {
@Override
public List<ProvisioningStatisticsLineDto> getObject() {
if (task == null && task.getOperationalInformation() == null) {
Task t = getTask();
if (t == null || t.getOperationalInformation() == null) {
return new ArrayList<>();
}
return ProvisioningStatisticsLineDto.extractFromOperationalInformation(task.getOperationalInformation());
return ProvisioningStatisticsLineDto.extractFromOperationalInformation(t.getOperationalInformation());
}
}) {
protected void populateItem(final ListItem<ProvisioningStatisticsLineDto> item) {
Expand Down Expand Up @@ -135,10 +143,11 @@ protected void populateItem(final ListItem<ProvisioningStatisticsLineDto> item)
ListView mappingsLines = new ListView<MappingsLineDto>(ID_MAPPINGS_STATISTICS_LINES, new AbstractReadOnlyModel<List<MappingsLineDto>>() {
@Override
public List<MappingsLineDto> getObject() {
if (task == null && task.getOperationalInformation() == null) {
Task t = getTask();
if (t == null || t.getOperationalInformation() == null) {
return new ArrayList<>();
}
return MappingsLineDto.extractFromOperationalInformation(task.getOperationalInformation());
return MappingsLineDto.extractFromOperationalInformation(t.getOperationalInformation());
}
}) {
protected void populateItem(final ListItem<MappingsLineDto> item) {
Expand All @@ -155,10 +164,11 @@ protected void populateItem(final ListItem<MappingsLineDto> item) {
ListView notificationsLines = new ListView<NotificationsLineDto>(ID_NOTIFICATIONS_STATISTICS_LINES, new AbstractReadOnlyModel<List<NotificationsLineDto>>() {
@Override
public List<NotificationsLineDto> getObject() {
if (task == null && task.getOperationalInformation() == null) {
Task t = getTask();
if (t == null || t.getOperationalInformation() == null) {
return new ArrayList<>();
}
return NotificationsLineDto.extractFromOperationalInformation(task.getOperationalInformation());
return NotificationsLineDto.extractFromOperationalInformation(t.getOperationalInformation());
}
}) {
protected void populateItem(final ListItem<NotificationsLineDto> item) {
Expand All @@ -176,10 +186,11 @@ protected void populateItem(final ListItem<NotificationsLineDto> item) {
Label lastMessage = new Label(ID_LAST_MESSAGE, new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
if (task == null || task.getOperationalInformation() == null) {
Task t = getTask();
if (t == null || t.getOperationalInformation() == null) {
return "(unavailable)";
}
List<StatusMessage> messages = task.getOperationalInformation().getMessages();
List<StatusMessage> messages = t.getOperationalInformation().getMessages();
if (messages == null || messages.isEmpty()) {
return "(none)";
}
Expand All @@ -206,6 +217,12 @@ public void setTask(Task task) {
}

public Task getTask() {
return task;
if (task != null) {
return task;
} else if (taskModel != null) {
return taskModel.getObject();
} else {
return null;
}
}
}
Expand Up @@ -113,7 +113,7 @@ public PrismContext getPrismContext() {
return getMidpointApplication().getPrismContext();
}

protected TaskManager getTaskManager() {
public TaskManager getTaskManager() {
return taskManager;
}

Expand Down
Expand Up @@ -142,7 +142,7 @@ <h2><wicket:message key="pageTaskEdit.scheduleTitle"/><br />
</tr>
</tbody>
<tbody>
<tr> f
<tr>
<td><wicket:message key="pageTaskEdit.notStartBefore"/></td>
<td><span wicket:id="notStartBeforeField" /></td>
</tr>
Expand Down
Expand Up @@ -289,7 +289,7 @@ public boolean isVisible() {
panel.add(modelOpBehaviour);
mainForm.add(panel);

TaskStatePanel taskStatePanel = new TaskStatePanel(ID_TASK_STATE_PANEL, model);
TaskStatePanel taskStatePanel = new TaskStatePanel(ID_TASK_STATE_PANEL, model, this);
taskStatePanel.add(hiddenWhenEditing);
mainForm.add(taskStatePanel);

Expand Down Expand Up @@ -958,16 +958,6 @@ public boolean isVisible() {
mainForm.add(runNow);
}

private List<IColumn<OperationResult, String>> initResultColumns() {
List<IColumn<OperationResult, String>> columns = new ArrayList<IColumn<OperationResult, String>>();

columns.add(new PropertyColumn(createStringResource("pageTaskEdit.opResult.token"), "token"));
columns.add(new PropertyColumn(createStringResource("pageTaskEdit.opResult.operation"), "operation"));
columns.add(new PropertyColumn(createStringResource("pageTaskEdit.opResult.status"), "status"));
columns.add(new PropertyColumn(createStringResource("pageTaskEdit.opResult.message"), "message"));
return columns;
}

private List<TaskAddResourcesDto> createResourceList() {
OperationResult result = new OperationResult(OPERATION_LOAD_RESOURCES);
Task task = createSimpleTask(OPERATION_LOAD_RESOURCES);
Expand Down
Expand Up @@ -18,6 +18,39 @@
<html xmlns:wicket="http://wicket.apache.org">
<wicket:panel>

<table class="table table-condensed table-striped">
<tr>
<td><wicket:message key="TaskStatePanel.executionStatus"/></td>
<td><span wicket:id="executionStatus"/> <span wicket:id="executionNode"/></td>
</tr>
<tr>
<td><wicket:message key="TaskStatePanel.executionTime"/></td>
<td><span wicket:id="executionTime"/></td>
</tr>
<tr>
<td><wicket:message key="TaskStatePanel.progress"/></td>
<td><span wicket:id="progress"/></td>
</tr>
<tr>
<td><wicket:message key="TaskStatePanel.lastObjectProcessedOk"/></td>
<td><span wicket:id="lastObjectProcessedOk"/></td>
</tr>
<tr>
<td><wicket:message key="TaskStatePanel.lastObjectProcessedNotOk"/></td>
<td><span wicket:id="lastObjectProcessedNotOk"/></td>
</tr>
<tr>
<td><wicket:message key="TaskStatePanel.lastError"/></td>
<td><span wicket:id="lastError"/></td>
</tr>
<tr>
<td><wicket:message key="TaskStatePanel.currentObjectProcessed"/></td>
<td><span wicket:id="currentObjectProcessed"/></td>
</tr>
</table>

<h3><wicket:message key="TaskStatePanel.statistics"/></h3>
<div wicket:id="statisticsPanel"/>

<h3><wicket:message key="TaskStatePanel.opResult"/></h3>
<div wicket:id="operationResult"/>
Expand Down
Expand Up @@ -17,64 +17,184 @@
package com.evolveum.midpoint.web.page.admin.server.currentState;

import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.task.api.Task;
import com.evolveum.midpoint.task.api.TaskManager;
import com.evolveum.midpoint.task.api.TaskManagerException;
import com.evolveum.midpoint.util.logging.LoggingUtils;
import com.evolveum.midpoint.web.component.data.TablePanel;
import com.evolveum.midpoint.web.component.data.column.LinkPanel;
import com.evolveum.midpoint.web.component.progress.StatisticsPanel;
import com.evolveum.midpoint.web.component.util.ListDataProvider;
import com.evolveum.midpoint.web.component.util.SimplePanel;
import com.evolveum.midpoint.web.component.wf.WfDeltasPanel;
import com.evolveum.midpoint.web.component.wf.WfHistoryEventDto;
import com.evolveum.midpoint.web.component.wf.WfHistoryPanel;
import com.evolveum.midpoint.web.page.PageBase;
import com.evolveum.midpoint.web.page.admin.server.dto.TaskDto;
import com.evolveum.midpoint.web.page.admin.server.dto.TaskDtoExecutionStatus;
import com.evolveum.midpoint.web.page.admin.workflow.PageProcessInstance;
import com.evolveum.midpoint.web.util.OnePageParameterEncoder;
import com.evolveum.midpoint.web.util.WebMiscUtil;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn;
import org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn;
import org.apache.wicket.extensions.markup.html.repeater.util.SortableDataProvider;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.model.AbstractReadOnlyModel;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.PropertyModel;
import org.apache.wicket.model.StringResourceModel;
import org.apache.wicket.request.mapper.parameter.PageParameters;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
* @author mederly
*/
public class TaskStatePanel extends SimplePanel<TaskDto> {

private static final String ID_DELTAS_PANEL = "deltasPanel";
private static final String ID_HISTORY_PANEL = "historyPanel";
private static final String ID_PAGE_PROCESS_INSTANCE_LINK = "pageProcessInstanceLink";
private static final String ID_EXECUTION_STATUS = "executionStatus";
private static final String ID_EXECUTION_NODE = "executionNode";
private static final String ID_EXECUTION_TIME = "executionTime";

public TaskStatePanel(String id, IModel<TaskDto> model) {
private static final String ID_PROGRESS = "progress";

private static final String ID_LAST_OBJECT_PROCESSED_OK = "lastObjectProcessedOk";
private static final String ID_LAST_OBJECT_PROCESSED_NOT_OK = "lastObjectProcessedNotOk";
private static final String ID_LAST_ERROR = "lastError";
private static final String ID_CURRENT_OBJECT_PROCESSED = "currentObjectProcessed";

private static final String ID_STATISTICS_PANEL = "statisticsPanel";

private static final String ID_OPERATION_RESULT = "operationResult";

IModel<Task> taskModel;

public TaskStatePanel(String id, IModel<TaskDto> model, final PageBase pageBase) {
super(id, model);
taskModel = new AbstractReadOnlyModel<Task>() {
@Override
public Task getObject() {
TaskDto taskDto = getModel().getObject();
if (taskDto == null || taskDto.getIdentifier() == null) {
return null;
}
String id = taskDto.getIdentifier();
TaskManager taskManager = pageBase.getTaskManager();
Task task = taskManager.getLocallyRunningTaskByIdentifier(id);
return task;
}
};
realInitLayout();
}

@Override
protected void initLayout() {
// taskModel is not ready here...
}

private void realInitLayout() {
Label executionStatus = new Label(ID_EXECUTION_STATUS, new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
TaskDtoExecutionStatus executionStatus = getModel().getObject().getExecution();
return getString(TaskDtoExecutionStatus.class.getSimpleName() + "." + executionStatus.name());
}
});
add(executionStatus);

Label executionNode = new Label(ID_EXECUTION_NODE, new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
TaskDto dto = getModel().getObject();
if (!TaskDtoExecutionStatus.RUNNING.equals(dto.getExecution())) {
return null;
}
return getString("TaskStatePanel.message.node", dto.getExecutingAt());
}
});
add(executionNode);

Label executionTime = new Label(ID_EXECUTION_TIME, new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
TaskDto dto = getModel().getObject();
Date started = new Date(dto.getLastRunFinishTimestampLong());
if (TaskDtoExecutionStatus.RUNNING.equals(dto.getExecution())) {
return getString("TaskStatePanel.message.executionTime.notFinished", WebMiscUtil.formatDate(started));
} else {
Date finished = new Date(dto.getLastRunFinishTimestampLong());
return getString("TaskStatePanel.message.executionTime.finished",
WebMiscUtil.formatDate(started), WebMiscUtil.formatDate(finished));
}
}
});
add(executionTime);

Label progress = new Label(ID_PROGRESS, new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
TaskDto dto = getModel().getObject();
return dto.getProgressDescription(); // TODO implement using live task + implement stalled since
}
});
add(progress);

Label lastProcessedOk = new Label(ID_LAST_OBJECT_PROCESSED_OK, new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
return "N/A";
}
});
add(lastProcessedOk);

Label lastProcessedNotOk = new Label(ID_LAST_OBJECT_PROCESSED_NOT_OK, new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
return "N/A";
}
});
add(lastProcessedNotOk);

Label lastError = new Label(ID_LAST_ERROR, new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
return "N/A";
}
});
add(lastError);

Label currentObjectProcessed = new Label(ID_CURRENT_OBJECT_PROCESSED, new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
return "N/A";
}
});
add(currentObjectProcessed);

StatisticsPanel statisticsPanel = new StatisticsPanel(ID_STATISTICS_PANEL, taskModel.getObject());
add(statisticsPanel);

SortableDataProvider<OperationResult, String> provider = new ListDataProvider<>(this,
new PropertyModel<List<OperationResult>>(model, "opResult"));
TablePanel result = new TablePanel<>("operationResult", provider, initResultColumns());
new PropertyModel<List<OperationResult>>(getModel(), "opResult"));
TablePanel result = new TablePanel<>(ID_OPERATION_RESULT, provider, initResultColumns());
result.setStyle("padding-top: 0px;");
result.setShowPaging(false);
result.setOutputMarkupId(true);
result.add(hiddenWhenEditing);
mainForm.add(result);
add(result);
}

add(new LinkPanel(ID_PAGE_PROCESS_INSTANCE_LINK, new StringResourceModel("WorkflowInformationPanel.link.processInstance", getModel())) {
@Override
public void onClick(AjaxRequestTarget target) {
String pid = TaskStatePanel.this.getModel().getObject().getWorkflowProcessInstanceId();
boolean finished = TaskStatePanel.this.getModel().getObject().isWorkflowProcessInstanceFinished();
PageParameters parameters = new PageParameters();
parameters.add(OnePageParameterEncoder.PARAMETER, pid);
parameters.add(PageProcessInstance.PARAM_PROCESS_INSTANCE_FINISHED, finished);
TaskStatePanel.this.setResponsePage(new PageProcessInstance(parameters, (PageBase) TaskStatePanel.this.getPage()));
}
});
private List<IColumn<OperationResult, String>> initResultColumns() {
List<IColumn<OperationResult, String>> columns = new ArrayList<IColumn<OperationResult, String>>();

add(new WfDeltasPanel(ID_DELTAS_PANEL, getModel()));
add(new WfHistoryPanel(ID_HISTORY_PANEL, new PropertyModel<List<WfHistoryEventDto>>(getModel(), TaskDto.F_WORKFLOW_HISTORY)));
columns.add(new PropertyColumn(createStringResource("pageTaskEdit.opResult.token"), "token"));
columns.add(new PropertyColumn(createStringResource("pageTaskEdit.opResult.operation"), "operation"));
columns.add(new PropertyColumn(createStringResource("pageTaskEdit.opResult.status"), "status"));
columns.add(new PropertyColumn(createStringResource("pageTaskEdit.opResult.message"), "message"));
return columns;
}


}

0 comments on commit bc23a83

Please sign in to comment.