syncope-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ilgro...@apache.org
Subject [1/2] syncope git commit: [SYNCOPE-1053] Providing UserTO and UserPatch pending approval as part of the workflow form
Date Thu, 25 May 2017 15:16:38 GMT
Repository: syncope
Updated Branches:
  refs/heads/2_0_X 845ce01db -> ba947fbc9
  refs/heads/master 419ad61f2 -> 0b96dfc47


[SYNCOPE-1053] Providing UserTO and UserPatch pending approval as part of the workflow form


Project: http://git-wip-us.apache.org/repos/asf/syncope/repo
Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/ba947fbc
Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/ba947fbc
Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/ba947fbc

Branch: refs/heads/2_0_X
Commit: ba947fbc9eaadbb2ad088ac23d0ce556b68cd5b4
Parents: 845ce01
Author: Francesco Chicchiriccò <ilgrosso@apache.org>
Authored: Thu May 25 17:15:44 2017 +0200
Committer: Francesco Chicchiriccò <ilgrosso@apache.org>
Committed: Thu May 25 17:15:44 2017 +0200

----------------------------------------------------------------------
 .../syncope/common/lib/to/WorkflowFormTO.java   | 21 +++++++++++
 .../activiti/ActivitiUserWorkflowAdapter.java   | 14 +++++---
 .../flowable/FlowableUserWorkflowAdapter.java   | 14 +++++---
 .../syncope/fit/core/UserWorkflowITCase.java    | 37 ++++++++++++++++++++
 4 files changed, 78 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/syncope/blob/ba947fbc/common/lib/src/main/java/org/apache/syncope/common/lib/to/WorkflowFormTO.java
----------------------------------------------------------------------
diff --git a/common/lib/src/main/java/org/apache/syncope/common/lib/to/WorkflowFormTO.java
b/common/lib/src/main/java/org/apache/syncope/common/lib/to/WorkflowFormTO.java
index 1748435..a73a8cc 100644
--- a/common/lib/src/main/java/org/apache/syncope/common/lib/to/WorkflowFormTO.java
+++ b/common/lib/src/main/java/org/apache/syncope/common/lib/to/WorkflowFormTO.java
@@ -31,6 +31,7 @@ import javax.xml.bind.annotation.XmlElementWrapper;
 import javax.xml.bind.annotation.XmlRootElement;
 import javax.xml.bind.annotation.XmlType;
 import org.apache.syncope.common.lib.AbstractBaseBean;
+import org.apache.syncope.common.lib.patch.UserPatch;
 
 @XmlRootElement(name = "workflowForm")
 @XmlType
@@ -50,6 +51,10 @@ public class WorkflowFormTO extends AbstractBaseBean {
 
     private String owner;
 
+    private UserTO userTO;
+
+    private UserPatch userPatch;
+
     private final List<WorkflowFormPropertyTO> properties = new ArrayList<>();
 
     public String getUsername() {
@@ -114,6 +119,22 @@ public class WorkflowFormTO extends AbstractBaseBean {
         this.owner = owner;
     }
 
+    public UserTO getUserTO() {
+        return userTO;
+    }
+
+    public void setUserTO(final UserTO userTO) {
+        this.userTO = userTO;
+    }
+
+    public UserPatch getUserPatch() {
+        return userPatch;
+    }
+
+    public void setUserPatch(final UserPatch userPatch) {
+        this.userPatch = userPatch;
+    }
+
     @XmlElementWrapper(name = "workflowFormProperties")
     @XmlElement(name = "workflowFormProperty")
     @JsonProperty("workflowFormProperties")

http://git-wip-us.apache.org/repos/asf/syncope/blob/ba947fbc/core/workflow-activiti/src/main/java/org/apache/syncope/core/workflow/activiti/ActivitiUserWorkflowAdapter.java
----------------------------------------------------------------------
diff --git a/core/workflow-activiti/src/main/java/org/apache/syncope/core/workflow/activiti/ActivitiUserWorkflowAdapter.java
b/core/workflow-activiti/src/main/java/org/apache/syncope/core/workflow/activiti/ActivitiUserWorkflowAdapter.java
index 82e7e01..ff86c02 100644
--- a/core/workflow-activiti/src/main/java/org/apache/syncope/core/workflow/activiti/ActivitiUserWorkflowAdapter.java
+++ b/core/workflow-activiti/src/main/java/org/apache/syncope/core/workflow/activiti/ActivitiUserWorkflowAdapter.java
@@ -483,10 +483,10 @@ public class ActivitiUserWorkflowAdapter extends AbstractUserWorkflowAdapter
{
     }
 
     protected WorkflowFormTO getFormTO(final Task task, final TaskFormData fd) {
-        final WorkflowFormTO formTO =
+        WorkflowFormTO formTO =
                 getFormTO(task.getProcessInstanceId(), task.getId(), fd.getFormKey(), fd.getFormProperties());
-
         BeanUtils.copyProperties(task, formTO);
+
         return formTO;
     }
 
@@ -501,11 +501,11 @@ public class ActivitiUserWorkflowAdapter extends AbstractUserWorkflowAdapter
{
             }
         }
 
-        final WorkflowFormTO formTO = getHistoricFormTO(
+        WorkflowFormTO formTO = getHistoricFormTO(
                 task.getProcessInstanceId(), task.getId(), task.getFormKey(), props);
         BeanUtils.copyProperties(task, formTO);
 
-        final HistoricActivityInstance historicActivityInstance = engine.getHistoryService().
+        HistoricActivityInstance historicActivityInstance = engine.getHistoryService().
                 createHistoricActivityInstanceQuery().
                 executionId(task.getExecutionId()).activityType("userTask").activityName(task.getName()).singleResult();
 
@@ -534,6 +534,9 @@ public class ActivitiUserWorkflowAdapter extends AbstractUserWorkflowAdapter
{
         formTO.setTaskId(taskId);
         formTO.setKey(formKey);
 
+        formTO.setUserTO(engine.getRuntimeService().getVariable(processInstanceId, USER_TO,
UserTO.class));
+        formTO.setUserPatch(engine.getRuntimeService().getVariable(processInstanceId, USER_PATCH,
UserPatch.class));
+
         for (HistoricFormPropertyEntity prop : props) {
             WorkflowFormPropertyTO propertyTO = new WorkflowFormPropertyTO();
             propertyTO.setId(prop.getPropertyId());
@@ -563,6 +566,9 @@ public class ActivitiUserWorkflowAdapter extends AbstractUserWorkflowAdapter
{
         formTO.setTaskId(taskId);
         formTO.setKey(formKey);
 
+        formTO.setUserTO(engine.getRuntimeService().getVariable(processInstanceId, USER_TO,
UserTO.class));
+        formTO.setUserPatch(engine.getRuntimeService().getVariable(processInstanceId, USER_PATCH,
UserPatch.class));
+
         for (FormProperty fProp : properties) {
             WorkflowFormPropertyTO propertyTO = new WorkflowFormPropertyTO();
             BeanUtils.copyProperties(fProp, propertyTO, PROPERTY_IGNORE_PROPS);

http://git-wip-us.apache.org/repos/asf/syncope/blob/ba947fbc/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/FlowableUserWorkflowAdapter.java
----------------------------------------------------------------------
diff --git a/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/FlowableUserWorkflowAdapter.java
b/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/FlowableUserWorkflowAdapter.java
index 5ecf2ce..47634d6 100644
--- a/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/FlowableUserWorkflowAdapter.java
+++ b/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/FlowableUserWorkflowAdapter.java
@@ -483,10 +483,10 @@ public class FlowableUserWorkflowAdapter extends AbstractUserWorkflowAdapter
{
     }
 
     protected WorkflowFormTO getFormTO(final Task task, final TaskFormData fd) {
-        final WorkflowFormTO formTO =
+        WorkflowFormTO formTO =
                 getFormTO(task.getProcessInstanceId(), task.getId(), fd.getFormKey(), fd.getFormProperties());
-
         BeanUtils.copyProperties(task, formTO);
+
         return formTO;
     }
 
@@ -501,11 +501,11 @@ public class FlowableUserWorkflowAdapter extends AbstractUserWorkflowAdapter
{
             }
         }
 
-        final WorkflowFormTO formTO = getHistoricFormTO(
+        WorkflowFormTO formTO = getHistoricFormTO(
                 task.getProcessInstanceId(), task.getId(), task.getFormKey(), props);
         BeanUtils.copyProperties(task, formTO);
 
-        final HistoricActivityInstance historicActivityInstance = engine.getHistoryService().
+        HistoricActivityInstance historicActivityInstance = engine.getHistoryService().
                 createHistoricActivityInstanceQuery().
                 executionId(task.getExecutionId()).activityType("userTask").activityName(task.getName()).singleResult();
 
@@ -534,6 +534,9 @@ public class FlowableUserWorkflowAdapter extends AbstractUserWorkflowAdapter
{
         formTO.setTaskId(taskId);
         formTO.setKey(formKey);
 
+        formTO.setUserTO(engine.getRuntimeService().getVariable(processInstanceId, USER_TO,
UserTO.class));
+        formTO.setUserPatch(engine.getRuntimeService().getVariable(processInstanceId, USER_PATCH,
UserPatch.class));
+
         for (HistoricFormPropertyEntity prop : props) {
             WorkflowFormPropertyTO propertyTO = new WorkflowFormPropertyTO();
             propertyTO.setId(prop.getPropertyId());
@@ -563,6 +566,9 @@ public class FlowableUserWorkflowAdapter extends AbstractUserWorkflowAdapter
{
         formTO.setTaskId(taskId);
         formTO.setKey(formKey);
 
+        formTO.setUserTO(engine.getRuntimeService().getVariable(processInstanceId, USER_TO,
UserTO.class));
+        formTO.setUserPatch(engine.getRuntimeService().getVariable(processInstanceId, USER_PATCH,
UserPatch.class));
+
         for (FormProperty fProp : properties) {
             WorkflowFormPropertyTO propertyTO = new WorkflowFormPropertyTO();
             BeanUtils.copyProperties(fProp, propertyTO, PROPERTY_IGNORE_PROPS);

http://git-wip-us.apache.org/repos/asf/syncope/blob/ba947fbc/fit/core-reference/src/test/java/org/apache/syncope/fit/core/UserWorkflowITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/UserWorkflowITCase.java
b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/UserWorkflowITCase.java
index 31a3e3d..896b922 100644
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/UserWorkflowITCase.java
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/UserWorkflowITCase.java
@@ -31,7 +31,10 @@ import java.util.Collections;
 import java.util.List;
 import java.util.Map;
 import javax.sql.DataSource;
+import javax.ws.rs.core.Response;
+import org.apache.syncope.client.lib.SyncopeClient;
 import org.apache.syncope.common.lib.SyncopeClientException;
+import org.apache.syncope.common.lib.patch.MembershipPatch;
 import org.apache.syncope.common.lib.patch.PasswordPatch;
 import org.apache.syncope.common.lib.patch.StringPatchItem;
 import org.apache.syncope.common.lib.patch.UserPatch;
@@ -42,6 +45,7 @@ import org.apache.syncope.common.lib.to.WorkflowFormPropertyTO;
 import org.apache.syncope.common.lib.to.WorkflowFormTO;
 import org.apache.syncope.common.lib.types.ClientExceptionType;
 import org.apache.syncope.common.lib.types.PatchOperation;
+import org.apache.syncope.common.rest.api.service.UserSelfService;
 import org.apache.syncope.common.rest.api.service.UserWorkflowService;
 import org.apache.syncope.fit.AbstractITCase;
 import org.junit.Assume;
@@ -215,6 +219,39 @@ public class UserWorkflowITCase extends AbstractITCase {
     }
 
     @Test
+    public void updateApproval() {
+        Assume.assumeTrue(ActivitiDetector.isActivitiEnabledForUsers(syncopeService));
+
+        // read forms *before* any operation
+        List<WorkflowFormTO> forms = userWorkflowService.getForms();
+        assertNotNull(forms);
+        int preForms = forms.size();
+
+        UserTO created = createUser(UserITCase.getUniqueSampleTO("updateApproval@syncope.apache.org")).getEntity();
+        assertNotNull(created);
+
+        UserPatch patch = new UserPatch();
+        patch.setKey(created.getKey());
+        patch.getMemberships().add(new MembershipPatch.Builder().group("b1f7c12d-ec83-441f-a50e-1691daaedf3b").build());
+
+        SyncopeClient client = clientFactory.create(created.getUsername(), "password123");
+        Response response = client.getService(UserSelfService.class).update(patch);
+        assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
+
+        forms = userWorkflowService.getForms();
+        assertNotNull(forms);
+        assertEquals(preForms + 1, forms.size());
+
+        WorkflowFormTO form = userWorkflowService.getFormForUser(created.getKey());
+        assertNotNull(form);
+        assertNotNull(form.getTaskId());
+        assertNull(form.getOwner());
+        assertNotNull(form.getUserTO());
+        assertNotNull(form.getUserPatch());
+        assertEquals(patch, form.getUserPatch());
+    }
+
+    @Test
     public void issueSYNCOPE15() {
         Assume.assumeTrue(ActivitiDetector.isActivitiEnabledForUsers(syncopeService));
 


Mime
View raw message