Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/Evolveum/midpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
katkav committed Mar 2, 2017
2 parents d4649ff + 0e2d36a commit 46f874e
Show file tree
Hide file tree
Showing 30 changed files with 426 additions and 520 deletions.
Expand Up @@ -64,6 +64,10 @@ <h3 class="box-title"><wicket:message key="workItemPanel.mainInfo"/></h3>
<td><wicket:message key="workItemPanel.escalationLevel" /></td>
<td><b><span wicket:id="escalationLevelInfo" /></b></td>
</tr>
<tr wicket:id="requesterCommentContainer">
<td><wicket:message key="workItemPanel.requesterComment" /></td>
<td><b><span wicket:id="requesterCommentMessage" /></b></td>
</tr>
</table>
</div>
</div>
Expand Down
Expand Up @@ -92,6 +92,9 @@ public class WorkItemPanel extends BasePanel<WorkItemDto> {
private static final String ID_APPROVER_COMMENT = "approverComment";
private static final String ID_SHOW_REQUEST = "showRequest";
private static final String ID_SHOW_REQUEST_HELP = "showRequestHelp";
private static final String ID_REQUESTER_COMMENT_CONTAINER = "requesterCommentContainer";
private static final String ID_REQUESTER_COMMENT_MESSAGE = "requesterCommentMessage";


public WorkItemPanel(String id, IModel<WorkItemDto> model, Form mainForm, PageBase pageBase) {
super(id, model);
Expand Down Expand Up @@ -176,6 +179,11 @@ public boolean isVisible() {
escalationLevelInfoContainer.add(new Label(ID_ESCALATION_LEVEL_INFO, new PropertyModel<String>(getModel(), WorkItemDto.F_ESCALATION_LEVEL_INFO)));
escalationLevelInfoContainer.add(new VisibleBehaviour(() -> getModelObject().getEscalationLevelInfo() != null));

WebMarkupContainer requesterCommentContainer = new WebMarkupContainer(ID_REQUESTER_COMMENT_CONTAINER);
requesterCommentContainer.setOutputMarkupId(true);
primaryInfoColumn.add(requesterCommentContainer);
requesterCommentContainer.add(new Label(ID_REQUESTER_COMMENT_MESSAGE, new PropertyModel<String>(getModel(), WorkItemDto.F_REQUESTER_COMMENT)));

//primaryInfoColumn.add(new ScenePanel(ID_DELTAS_TO_BE_APPROVED, new PropertyModel<SceneDto>(getModel(), WorkItemDto.F_DELTAS)));
primaryInfoColumn.add(new TaskChangesPanel(ID_DELTAS_TO_BE_APPROVED, new PropertyModel<>(getModel(), WorkItemDto.F_CHANGES)));
primaryInfoColumn.add(new AttributeModifier("class", new AbstractReadOnlyModel<String>() {
Expand Down
Expand Up @@ -94,6 +94,8 @@ public class WorkItemDto extends Selectable {
public static final String F_PROCESS_INSTANCE_ID = "processInstanceId";
public static final String F_CHANGES = "changes";

public static final String F_REQUESTER_COMMENT = "requesterComment";

// workItem may or may not contain resolved taskRef;
// and this task may or may not contain filled-in workflowContext -> and then requesterRef object
//
Expand Down Expand Up @@ -232,11 +234,7 @@ public String getTargetName() {

public WfContextType getWorkflowContext() {
TaskType task = getTaskType();
if (task == null || task.getWorkflowContext() == null) {
return null;
} else {
return task.getWorkflowContext();
}
return task != null ? task.getWorkflowContext() : null;
}

public String getRequesterName() {
Expand Down Expand Up @@ -401,4 +399,9 @@ public ObjectType getFocus(PageBase pageBase) {
}
return focus;
}

public String getRequesterComment() {
OperationBusinessContextType businessContext = WfContextUtil.getBusinessContext(getWorkflowContext());
return businessContext != null ? businessContext.getComment() : null;
}
}
Expand Up @@ -184,10 +184,13 @@ private void onRequestPerformed(AjaxRequestTarget target) {
PrismContainerDefinition def = user.getDefinition().findContainerDefinition(UserType.F_ASSIGNMENT);
handleAssignmentDeltas(delta, addAssignmentsToUser(), def);

OperationBusinessContextType businessContextType = new OperationBusinessContextType();
businessContextType.setComment(descriptionModel.getObject() != null ?
descriptionModel.getObject() : "");

OperationBusinessContextType businessContextType;
if (descriptionModel.getObject() != null) {
businessContextType = new OperationBusinessContextType();
businessContextType.setComment(descriptionModel.getObject());
} else {
businessContextType = null;
}
getModelService().executeChanges(deltas, ModelExecuteOptions.createRequestBusinessContext(businessContextType),
createSimpleTask(OPERATION_REQUEST_ASSIGNMENTS), result);

Expand Down
Expand Up @@ -2186,6 +2186,7 @@ workItemPanel.currentlyAllocatedTo=Currently allocated to\:
workItemPanel.candidateActors=Candidate actors\:
workItemPanel.stage=Approval stage\:
workItemPanel.escalationLevel=Escalation level\:
workItemPanel.requesterComment=Requester comment\:
workItemPanel.delta=Delta to be approved
workItemPanel.mainInfo=Basic information
workItemPanel.options=Options
Expand Down
Expand Up @@ -20,10 +20,7 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.*;
import java.util.stream.Collectors;

/**
Expand Down Expand Up @@ -267,4 +264,14 @@ public static void checkLevelsOrderingStrict(ApprovalSchemaType schema) {
}
}
}

public static OperationBusinessContextType getBusinessContext(WfContextType wfc) {
if (wfc == null) {
return null;
}
return wfc.getEvent().stream()
.filter(e -> e instanceof WfProcessCreationEventType)
.map(e -> ((WfProcessCreationEventType) e).getBusinessContext())
.findFirst().orElse(null);
}
}
Expand Up @@ -1399,14 +1399,6 @@
</xsd:documentation>
</xsd:annotation>
</xsd:element>

<!--<xsd:element name="operational" type="xsd:boolean" minOccurs="0">-->
<!--<xsd:annotation>-->
<!--<xsd:documentation>-->
<!--A hint that this event needs not be displayed in GUI. -->
<!--</xsd:documentation>-->
<!--</xsd:annotation>-->
<!--</xsd:element>-->
</xsd:sequence>
</xsd:complexType>

Expand Down Expand Up @@ -1624,6 +1616,31 @@
</xsd:complexContent>
</xsd:complexType>

<xsd:complexType name="WfProcessCreationEventType">
<xsd:annotation>
<xsd:documentation>
Event describing the creation of a workflow process instance.
</xsd:documentation>
<xsd:appinfo>
<a:since>3.6</a:since>
</xsd:appinfo>
</xsd:annotation>
<xsd:complexContent>
<xsd:extension base="tns:WfProcessEventType">
<xsd:sequence>
<xsd:element name="businessContext" type="tns:OperationBusinessContextType" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
Business context of the operation, if provided.
TODO move to WfProcessEventType?
</xsd:documentation>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>

<xsd:complexType name="DecisionType">
<xsd:annotation>
<xsd:documentation>
Expand Down
Expand Up @@ -21,7 +21,9 @@
import com.evolveum.midpoint.model.impl.lens.LensContext;
import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.prism.delta.ObjectDelta;
import com.evolveum.midpoint.prism.xml.XmlTypeConverter;
import com.evolveum.midpoint.schema.ObjectTreeDeltas;
import com.evolveum.midpoint.schema.util.ObjectTypeUtil;
import com.evolveum.midpoint.util.DebugUtil;
import com.evolveum.midpoint.util.exception.SchemaException;
import com.evolveum.midpoint.util.exception.SystemException;
Expand All @@ -33,12 +35,11 @@
import com.evolveum.midpoint.wf.impl.processors.primary.aspect.PrimaryChangeAspect;
import com.evolveum.midpoint.wf.impl.tasks.ProcessSpecificContent;
import com.evolveum.midpoint.wf.impl.tasks.WfTaskCreationInstruction;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ApprovalSchemaType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.SchemaAttachedPolicyRulesType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;
import org.jetbrains.annotations.NotNull;

import java.util.Date;

/**
* @author mederly
*/
Expand Down Expand Up @@ -77,6 +78,14 @@ public void prepareCommonAttributes(PrimaryChangeAspect aspect, ModelContext<?>
setTaskModelContext(((PrimaryChangeProcessor) getChangeProcessor()).contextCopyWithNoDelta((LensContext) modelContext));
setExecuteModelOperationHandler(true);
}

WfProcessCreationEventType event = new WfProcessCreationEventType();
event.setTimestamp(XmlTypeConverter.createXMLGregorianCalendar(new Date()));
if (requester != null) {
event.setInitiatorRef(ObjectTypeUtil.createObjectRef(requester));
}
event.setBusinessContext(((LensContext) modelContext).getRequestBusinessContext());
wfContext.getEvent().add(event);
}

public <F extends FocusType> void setDeltasToProcess(ObjectDelta<F> delta) {
Expand Down
Expand Up @@ -269,6 +269,10 @@ private void sortFragments(List<Fragment> fragments) {
if (o1 == null || o2 == null) {
return MiscUtil.compareNullLast(o1, o2);
}
int c = Integer.compare(o1, o2);
if (c != 0) {
return c;
}
// non-mergeable first
boolean m1 = BooleanUtils.isTrue(s1.isMergeable());
boolean m2 = BooleanUtils.isTrue(s2.isMergeable());
Expand Down
Expand Up @@ -59,7 +59,7 @@ public class WfTaskCreationInstruction<PRC extends ProcessorSpecificContent, PCS

private final ChangeProcessor changeProcessor;

private final WfContextType wfContext = new WfContextType(); // workflow context to be put into the task
protected final WfContextType wfContext = new WfContextType(); // workflow context to be put into the task
private ModelContext taskModelContext; // model context to be put into the task

private final Date processCreationTimestamp = new Date();
Expand Down
Expand Up @@ -16,8 +16,12 @@

package com.evolveum.midpoint.wf.impl.policy.other;

import com.evolveum.midpoint.model.api.ModelExecuteOptions;
import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.prism.delta.ObjectDelta;
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.schema.util.MiscSchemaUtil;
import com.evolveum.midpoint.schema.util.WfContextUtil;
import com.evolveum.midpoint.task.api.Task;
import com.evolveum.midpoint.test.util.TestUtil;
import com.evolveum.midpoint.wf.impl.activiti.ActivitiEngine;
Expand All @@ -28,6 +32,7 @@
import org.springframework.test.context.ContextConfiguration;
import org.testng.annotations.Test;

import java.util.Collection;
import java.util.List;

import static com.evolveum.midpoint.test.IntegrationTestTools.display;
Expand Down Expand Up @@ -59,7 +64,14 @@ public void test100SimpleApprove() throws Exception {
OperationResult result = task.getResult();

// GIVEN
assignRole(userJackOid, roleRole1aOid, task, result); // should start approval process

OperationBusinessContextType businessContext = new OperationBusinessContextType();
businessContext.setComment("req.comment");

ObjectDelta<UserType> userDelta = createAssignmentUserDelta(userJackOid, roleRole1aOid, RoleType.COMPLEX_TYPE, null, null, null, true);
Collection<ObjectDelta<? extends ObjectType>> deltas = MiscSchemaUtil.createCollection(userDelta);
modelService.executeChanges(deltas, ModelExecuteOptions.createRequestBusinessContext(businessContext), task, result);

assertNotAssignedRole(userJackOid, roleRole1aOid, task, result);

WorkItemType workItem = getWorkItem(task, result);
Expand All @@ -72,12 +84,17 @@ public void test100SimpleApprove() throws Exception {
TaskType wfTask = getTask(workItem.getTaskRef().getOid()).asObjectable();
display("workflow context", wfTask.getWorkflowContext());
List<WfProcessEventType> events = wfTask.getWorkflowContext().getEvent();
assertEquals("Wrong # of events", 1, events.size());
WorkItemEventType event = (WorkItemEventType) events.get(0);
display("Event", event);
assertEquals("Wrong # of events", 2, events.size());

WfProcessCreationEventType event1 = (WfProcessCreationEventType) events.get(0);
display("Event 1", event1);
assertEquals("Wrong requester comment", "req.comment", WfContextUtil.getBusinessContext(wfTask.getWorkflowContext()).getComment());

WorkItemEventType event2 = (WorkItemEventType) events.get(1);
display("Event 2", event2);

assertNotNull("Original assignee is null", event.getOriginalAssigneeRef());
assertEquals("Wrong original assignee OID", userLead1Oid, event.getOriginalAssigneeRef().getOid());
assertNotNull("Original assignee is null", event2.getOriginalAssigneeRef());
assertEquals("Wrong original assignee OID", userLead1Oid, event2.getOriginalAssigneeRef().getOid());
}

}
Expand Up @@ -932,7 +932,7 @@ public <O extends ObjectType> boolean selectorMatches(ObjectSelectorType objectS

// Type
if (specTypeQName != null && !QNameUtil.match(specTypeQName, objectDefinition.getTypeName())) {
logger.trace("{} type mismatch, expected {}, was {}", specTypeQName, objectDefinition.getTypeName());
logger.trace("{} type mismatch, expected {}, was {}", logMessagePrefix, specTypeQName, objectDefinition.getTypeName());
return false;
}

Expand Down

0 comments on commit 46f874e

Please sign in to comment.