Skip to content

Commit

Permalink
Merge branch 'master' of github.com:Evolveum/midpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
semancik committed Apr 13, 2016
2 parents bbb2c26 + c61983d commit 7d3c44e
Show file tree
Hide file tree
Showing 38 changed files with 401 additions and 338 deletions.
Expand Up @@ -35,6 +35,7 @@
/**
* @author mederly
*/
@Deprecated
public class WfDeltasPanel extends SimplePanel<TaskDto> {

private static final String ID_DELTA_IN_LIST = "deltaInList";
Expand Down
Expand Up @@ -21,21 +21,32 @@
<wicket:panel>
<div class="row">
<div class="col-md-5">
<h3><wicket:message key="workItemPanel.changesToBeApproved"/></h3>
<div wicket:id="deltasToBeApproved" />
</div>
<div class="col-md-7">
<h3><wicket:message key="workItemPanel.approvalHistory"/></h3>
<div wicket:id="history" />

<h3><wicket:message key="ItemApprovalPanel.currentWorkItems"/></h3>
<div wicket:id="currentWorkItems" />
<div class="box box-info">
<div class="box-header">
<h3 class="box-title"><wicket:message key="workItemPanel.approvalHistory"/></h3>
</div>
<div class="box-body">
<div wicket:id="history" />
</div>
</div>
<div class="box box-warning" wicket:id="currentWorkItemsContainer">
<div class="box-header">
<h3 class="box-title"><wicket:message key="ItemApprovalPanel.currentWorkItems"/></h3>
</div>
<div class="box-body">
<div wicket:id="currentWorkItems" />
</div>
</div>
</div>
</div>
<div wicket:id="relatedRequestsContainer">
<h3><wicket:message key="workItemPanel.relatedRequests"/></h3>
<div wicket:id="relatedRequests"/>
</div>
<br/>
<a href="#" wicket:id="showParent"><wicket:message key="taskWfChildPanel.showParent"/></a>
</wicket:panel>
</body>
Expand Down
Expand Up @@ -19,7 +19,6 @@
import com.evolveum.midpoint.gui.api.page.PageBase;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
import com.evolveum.midpoint.web.component.prism.show.ScenePanel;
import com.evolveum.midpoint.web.component.util.ListDataProvider;
import com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour;
import com.evolveum.midpoint.web.component.wf.WorkItemsTablePanel;
Expand Down Expand Up @@ -55,6 +54,7 @@ public class TaskWfChildPanel extends Panel {

private static final String ID_DELTAS_TO_BE_APPROVED = "deltasToBeApproved";
private static final String ID_HISTORY = "history";
private static final String ID_CURRENT_WORK_ITEMS_CONTAINER = "currentWorkItemsContainer";
private static final String ID_CURRENT_WORK_ITEMS = "currentWorkItems";
private static final String ID_RELATED_REQUESTS_CONTAINER = "relatedRequestsContainer";
private static final String ID_RELATED_REQUESTS = "relatedRequests";
Expand All @@ -70,7 +70,7 @@ public TaskWfChildPanel(String id, IModel<TaskDto> taskDtoModel, PageBase pageBa

private void initLayout(final IModel<TaskDto> taskDtoModel, PageBase pageBase) {

final ScenePanel deltasToBeApproved = new ScenePanel(ID_DELTAS_TO_BE_APPROVED, new PropertyModel(taskDtoModel, TaskDto.F_WORKFLOW_DELTA_IN));
TaskChangesPanel deltasToBeApproved = new TaskChangesPanel(ID_DELTAS_TO_BE_APPROVED, new PropertyModel(taskDtoModel, TaskDto.F_CHANGE_BEING_APPROVED));
deltasToBeApproved.setOutputMarkupId(true);
add(deltasToBeApproved);

Expand All @@ -81,13 +81,22 @@ private void initLayout(final IModel<TaskDto> taskDtoModel, PageBase pageBase) {
history.setOutputMarkupId(true);
add(history);

ISortableDataProvider<WorkItemDto, String> provider = new ListDataProvider(this, new PropertyModel<List<WorkItemDto>>(taskDtoModel, TaskDto.F_WORK_ITEMS));
WebMarkupContainer workItemsContainer = new WebMarkupContainer(ID_CURRENT_WORK_ITEMS_CONTAINER);
final ISortableDataProvider<WorkItemDto, String> provider = new ListDataProvider(this, new PropertyModel<List<WorkItemDto>>(taskDtoModel, TaskDto.F_WORK_ITEMS));
final WorkItemsTablePanel workItemsPanel = new WorkItemsTablePanel(ID_CURRENT_WORK_ITEMS, provider,
UserProfileStorage.TableId.PAGE_TASK_CURRENT_WORK_ITEMS_PANEL,
(int) pageBase.getItemsPerPage(UserProfileStorage.TableId.PAGE_TASK_CURRENT_WORK_ITEMS_PANEL),
WorkItemsTablePanel.View.ITEMS_FOR_PROCESS);
workItemsPanel.setOutputMarkupId(true);
add(workItemsPanel);
workItemsContainer.add(workItemsPanel);
workItemsContainer.setOutputMarkupId(true);
workItemsContainer.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return provider.size() > 0;
}
});
add(workItemsContainer);

final PropertyModel<List<ProcessInstanceDto>> relatedRequestsModel = new PropertyModel<>(taskDtoModel, TaskDto.F_WORKFLOW_REQUESTS);

Expand Down Expand Up @@ -120,7 +129,7 @@ public Collection<Component> getComponentsToUpdate() {
return Arrays.asList(
get(ID_DELTAS_TO_BE_APPROVED),
get(ID_HISTORY),
get(ID_CURRENT_WORK_ITEMS),
get(ID_CURRENT_WORK_ITEMS_CONTAINER),
get(ID_RELATED_REQUESTS_CONTAINER)
);
// exclude 'show parent' link
Expand Down
Expand Up @@ -19,9 +19,6 @@
xmlns:wicket="http://wicket.apache.org">
<body>
<wicket:panel>
<h3><wicket:message key="workItemPanel.requests"/></h3>
<div wicket:id="requests"/>

<div class="row" style="margin-bottom: 10px">
<div class="col-md-6" wicket:id="changes1">
<div wicket:id="changes1Content"/>
Expand All @@ -42,7 +39,14 @@ <h3><wicket:message key="workItemPanel.requests"/></h3>
<div class="col-md-6" wicket:id="changes5">
<div wicket:id="changes5Content"/>
</div>
<div class="col-md-6" wicket:id="changes6">
<div wicket:id="changes6Content"/>
</div>
</div>

<h3><wicket:message key="workItemPanel.requests"/></h3>
<div wicket:id="requests"/>

</wicket:panel>
</body>
</html>
Expand Down
Expand Up @@ -44,7 +44,7 @@ public class TaskWfParentPanel extends Panel {
private static final String ID_REQUESTS = "requests";
private static final String ID_CHANGES_PREFIX = "changes"; // e.g. changes3Content
public static final String ID_CHANGES_CONTENT_SUFFIX = "Content";
public static final int CHANGES_NUMBER = 5;
public static final int CHANGES_NUMBER = 6;

private static final Trace LOGGER = TraceManager.getTrace(TaskApprovalsTabPanel.class);

Expand Down
Expand Up @@ -26,7 +26,6 @@
import com.evolveum.midpoint.model.api.context.ModelContext;
import com.evolveum.midpoint.model.api.visualizer.Scene;
import com.evolveum.midpoint.prism.PrismContext;
import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.prism.PrismProperty;
import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.prism.polystring.PolyString;
Expand Down Expand Up @@ -62,11 +61,11 @@
import com.evolveum.midpoint.wf.api.WorkflowManager;
import com.evolveum.midpoint.wf.util.ChangesByState;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;
import com.evolveum.midpoint.xml.ns._public.model.scripting_3.ExecuteScriptType;
import com.evolveum.prism.xml.ns._public.query_3.QueryType;
import com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType;
import org.apache.commons.lang.Validate;
import org.apache.wicket.Application;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import javax.xml.datatype.XMLGregorianCalendar;
Expand Down Expand Up @@ -98,9 +97,9 @@ public class TaskDto extends Selectable implements InlineMenuable {
public static final String F_PARENT_TASK_OID = "parentTaskOid";
public static final String F_OWNER_NAME = "ownerName";
public static final String F_OWNER_OID = "ownerOid";
public static final String F_WORKFLOW_DELTAS_IN = "workflowDeltasIn";
public static final String F_WORKFLOW_DELTA_IN = "workflowDeltaIn";
public static final String F_WORKFLOW_DELTAS_OUT = "workflowDeltasOut";
@Deprecated public static final String F_WORKFLOW_DELTAS_IN = "workflowDeltasIn";
@Deprecated public static final String F_WORKFLOW_DELTAS_OUT = "workflowDeltasOut";
public static final String F_CHANGE_BEING_APPROVED = "changesBeingApproved";
public static final String F_IDENTIFIER = "identifier";
public static final String F_HANDLER_URI_LIST = "handlerUriList";
public static final String F_TASK_OPERATION_RESULT = "taskOperationResult";
Expand Down Expand Up @@ -149,10 +148,10 @@ public class TaskDto extends Selectable implements InlineMenuable {
private OperationResult taskOperationResult;
private ModelOperationStatusDto modelOperationStatusDto;

private List<TaskChangesDto> changes;
private List<TaskChangesDto> changesCategorizationList;
private List<ProcessInstanceDto> workflowRequests;
private List<SceneDto> workflowDeltasIn, workflowDeltasOut;
private SceneDto workflowDeltaIn;
private TaskChangesDto changesBeingApproved;

// related objects
private TaskType parentTaskType;
Expand Down Expand Up @@ -326,8 +325,7 @@ private void fillInWorkflowAttributes(TaskType taskType, ModelInteractionService
OperationResult thisOpResult) throws SchemaException, ObjectNotFoundException {

workflowDeltasIn = retrieveDeltasToProcess(taskType, modelInteractionService, opTask, thisOpResult);
workflowDeltaIn = retrieveDeltaToProcess(taskType, modelInteractionService, opTask, thisOpResult);
workflowDeltasOut = retrieveResultingDeltas(taskType, modelInteractionService, opTask, thisOpResult);
workflowDeltasOut = retrieveResultingDeltas(taskType, modelInteractionService, opTask, thisOpResult);

final TaskType rootTask;
if (parentTaskType == null) {
Expand All @@ -336,6 +334,17 @@ private void fillInWorkflowAttributes(TaskType taskType, ModelInteractionService
rootTask = parentTaskType;
}

WfContextType wfc = taskType.getWorkflowContext();
if (wfc != null && parentTaskType != null && (wfc.getProcessorSpecificState() instanceof WfPrimaryChangeProcessorStateType)) {
ChangesByState changesByState = workflowManager.getChangesByState(taskType, rootTask, modelInteractionService, prismContext, thisOpResult);
List<TaskChangesDto> changeCategories = computeChangesCategorizationList(changesByState, modelInteractionService, prismContext, opTask, thisOpResult);
if (changeCategories.size() > 1) {
throw new IllegalStateException("More than one task change category for task " + taskType + ": " + changeCategories);
} else if (changeCategories.size() == 1) {
changesBeingApproved = changeCategories.get(0);
}
}

workflowRequests = new ArrayList<>();
for (TaskType wfSubtask : rootTask.getSubtask()) {
final WfContextType subWfc = wfSubtask.getWorkflowContext();
Expand All @@ -346,8 +355,15 @@ private void fillInWorkflowAttributes(TaskType taskType, ModelInteractionService
}
}

changes = new ArrayList<>();
ChangesByState changesByState = workflowManager.getChangesByState(rootTask, modelInteractionService, prismContext, thisOpResult);
this.changesCategorizationList = computeChangesCategorizationList(changesByState, modelInteractionService, prismContext, opTask, thisOpResult);
}

@NotNull
private List<TaskChangesDto> computeChangesCategorizationList(ChangesByState changesByState, ModelInteractionService modelInteractionService,
PrismContext prismContext, Task opTask,
OperationResult thisOpResult) throws SchemaException {
List<TaskChangesDto> changes = new ArrayList<>();
if (!changesByState.getApplied().isEmpty()) {
changes.add(createTaskChangesDto("TaskDto.changesApplied", "box-solid box-success", changesByState.getApplied(), modelInteractionService, prismContext, opTask, thisOpResult));
}
Expand All @@ -358,11 +374,20 @@ private void fillInWorkflowAttributes(TaskType taskType, ModelInteractionService
changes.add(createTaskChangesDto("TaskDto.changesWaitingToBeApplied", "box-solid box-warning", changesByState.getWaitingToBeApplied(), modelInteractionService, prismContext, opTask, thisOpResult));
}
if (!changesByState.getWaitingToBeApproved().isEmpty()) {
changes.add(createTaskChangesDto("TaskDto.changesWaitingToBeApproved", "box-solid box-primary", changesByState.getWaitingToBeApproved(), modelInteractionService, prismContext, opTask, thisOpResult));
changes.add(createChangesToBeApproved(changesByState.getWaitingToBeApproved(), modelInteractionService, prismContext, opTask, thisOpResult));
}
if (!changesByState.getRejected().isEmpty()) {
changes.add(createTaskChangesDto("TaskDto.changesRejected", "box-solid box-danger", changesByState.getRejected(), modelInteractionService, prismContext, opTask, thisOpResult));
}
if (!changesByState.getCanceled().isEmpty()) {
changes.add(createTaskChangesDto("TaskDto.changesCanceled", "box-solid box-danger", changesByState.getCanceled(), modelInteractionService, prismContext, opTask, thisOpResult));
}
return changes;
}

private TaskChangesDto createChangesToBeApproved(ObjectTreeDeltas<?> deltas, ModelInteractionService modelInteractionService,
PrismContext prismContext, Task opTask, OperationResult thisOpResult) throws SchemaException {
return createTaskChangesDto("TaskDto.changesWaitingToBeApproved", "box-solid box-primary", deltas, modelInteractionService, prismContext, opTask, thisOpResult);
}

private TaskChangesDto createTaskChangesDto(String titleKey, String boxClassOverride, ObjectTreeDeltas deltas, ModelInteractionService modelInteractionService,
Expand Down Expand Up @@ -673,7 +698,7 @@ public ModelOperationStatusDto getModelOperationStatus() {

public TaskChangesDto getChangesForIndex(int index) {
int realIndex = index-1;
return realIndex < changes.size() ? changes.get(realIndex) : null;
return realIndex < changesCategorizationList.size() ? changesCategorizationList.get(realIndex) : null;
}

public void addChildTaskDto(TaskDto taskDto) {
Expand Down Expand Up @@ -701,14 +726,16 @@ public boolean isWorkflowProcessInstanceFinished() {
taskType.getWorkflowContext().getEndTimestamp() != null : false;
}

public List<SceneDto> getWorkflowDeltasIn() {
@Deprecated
public List<SceneDto> getWorkflowDeltasIn() {
return workflowDeltasIn;
}

public SceneDto getWorkflowDeltaIn() {
return workflowDeltaIn;
public TaskChangesDto getChangesBeingApproved() {
return changesBeingApproved;
}

@Deprecated
public List<SceneDto> getWorkflowDeltasOut() {
return workflowDeltasOut;
}
Expand Down Expand Up @@ -874,15 +901,16 @@ public boolean equals(Object o) {
!modelOperationStatusDto.equals(taskDto.modelOperationStatusDto) :
taskDto.modelOperationStatusDto != null)
return false;
if (changes != null ? !changes.equals(taskDto.changes) : taskDto.changes != null)
if (changesCategorizationList != null ? !changesCategorizationList
.equals(taskDto.changesCategorizationList) : taskDto.changesCategorizationList != null)
return false;
if (workflowRequests != null ? !workflowRequests.equals(taskDto.workflowRequests) : taskDto.workflowRequests != null)
return false;
if (workflowDeltasIn != null ? !workflowDeltasIn.equals(taskDto.workflowDeltasIn) : taskDto.workflowDeltasIn != null)
return false;
if (workflowDeltasOut != null ? !workflowDeltasOut.equals(taskDto.workflowDeltasOut) : taskDto.workflowDeltasOut != null)
return false;
if (workflowDeltaIn != null ? !workflowDeltaIn.equals(taskDto.workflowDeltaIn) : taskDto.workflowDeltaIn != null)
if (changesBeingApproved != null ? !changesBeingApproved.equals(taskDto.changesBeingApproved) : taskDto.changesBeingApproved != null)
return false;
if (parentTaskType != null ? !parentTaskType.equals(taskDto.parentTaskType) : taskDto.parentTaskType != null)
return false;
Expand Down Expand Up @@ -920,11 +948,11 @@ public int hashCode() {
result = 31 * result + (opResult != null ? opResult.hashCode() : 0);
result = 31 * result + (taskOperationResult != null ? taskOperationResult.hashCode() : 0);
result = 31 * result + (modelOperationStatusDto != null ? modelOperationStatusDto.hashCode() : 0);
result = 31 * result + (changes != null ? changes.hashCode() : 0);
result = 31 * result + (changesCategorizationList != null ? changesCategorizationList.hashCode() : 0);
result = 31 * result + (workflowRequests != null ? workflowRequests.hashCode() : 0);
result = 31 * result + (workflowDeltasIn != null ? workflowDeltasIn.hashCode() : 0);
result = 31 * result + (workflowDeltasOut != null ? workflowDeltasOut.hashCode() : 0);
result = 31 * result + (workflowDeltaIn != null ? workflowDeltaIn.hashCode() : 0);
result = 31 * result + (changesBeingApproved != null ? changesBeingApproved.hashCode() : 0);
result = 31 * result + (parentTaskType != null ? parentTaskType.hashCode() : 0);
result = 31 * result + (objectRefType != null ? objectRefType.hashCode() : 0);
result = 31 * result + (objectRefName != null ? objectRefName.hashCode() : 0);
Expand Down

This file was deleted.

0 comments on commit 7d3c44e

Please sign in to comment.