syncope-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ilgro...@apache.org
Subject [4/5] syncope git commit: [SYNCOPE-611] Forms are now retrieved depending on candidate or assignment
Date Fri, 28 Nov 2014 17:18:25 GMT
[SYNCOPE-611] Forms are now retrieved depending on candidate or assignment


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

Branch: refs/heads/1_2_X
Commit: e414b79bead9bfc4044a8a8dde6a95b1855cf354
Parents: d5061bc
Author: Francesco Chicchiriccò <ilgrosso@apache.org>
Authored: Fri Nov 28 18:18:04 2014 +0100
Committer: Francesco Chicchiriccò <ilgrosso@apache.org>
Committed: Fri Nov 28 18:18:04 2014 +0100

----------------------------------------------------------------------
 .../activiti/ActivitiUserWorkflowAdapter.java   | 36 ++++++++++++++++++--
 1 file changed, 33 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/syncope/blob/e414b79b/core/src/main/java/org/apache/syncope/core/workflow/user/activiti/ActivitiUserWorkflowAdapter.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/syncope/core/workflow/user/activiti/ActivitiUserWorkflowAdapter.java
b/core/src/main/java/org/apache/syncope/core/workflow/user/activiti/ActivitiUserWorkflowAdapter.java
index 2587706..78968ab 100644
--- a/core/src/main/java/org/apache/syncope/core/workflow/user/activiti/ActivitiUserWorkflowAdapter.java
+++ b/core/src/main/java/org/apache/syncope/core/workflow/user/activiti/ActivitiUserWorkflowAdapter.java
@@ -682,14 +682,42 @@ public class ActivitiUserWorkflowAdapter extends AbstractUserWorkflowAdapter
{
         return formTO;
     }
 
+    @Transactional(readOnly = true)
     @Override
     public List<WorkflowFormTO> getForms() {
-        return getForms(taskService.createTaskQuery().taskVariableValueEquals(TASK_IS_FORM,
Boolean.TRUE));
+        List<WorkflowFormTO> forms = new ArrayList<WorkflowFormTO>();
+
+        String authUser = EntitlementUtil.getAuthenticatedUsername();
+        if (adminUser.equals(authUser)) {
+            forms.addAll(getForms(taskService.createTaskQuery().
+                    taskVariableValueEquals(TASK_IS_FORM, Boolean.TRUE)));
+        } else {
+            SyncopeUser user = userDAO.find(authUser);
+            if (user == null) {
+                throw new NotFoundException("Syncope User " + authUser);
+            }
+
+            forms.addAll(getForms(taskService.createTaskQuery().
+                    taskVariableValueEquals(TASK_IS_FORM, Boolean.TRUE).
+                    taskCandidateOrAssigned(user.getId().toString())));
+
+            List<String> candidateGroups = new ArrayList<String>();
+            for (Long roleId : user.getRoleIds()) {
+                candidateGroups.add(roleId.toString());
+            }
+            if (!candidateGroups.isEmpty()) {
+                forms.addAll(getForms(taskService.createTaskQuery().
+                        taskVariableValueEquals(TASK_IS_FORM, Boolean.TRUE).
+                        taskCandidateGroupIn(candidateGroups)));
+            }
+        }
+
+        return forms;
     }
 
     @Override
     public List<WorkflowFormTO> getForms(final String workflowId, final String name)
{
-        final List<WorkflowFormTO> forms = getForms(
+        List<WorkflowFormTO> forms = getForms(
                 taskService.createTaskQuery().processInstanceId(workflowId).taskName(name).
                 taskVariableValueEquals(TASK_IS_FORM, Boolean.TRUE));
 
@@ -700,7 +728,7 @@ public class ActivitiUserWorkflowAdapter extends AbstractUserWorkflowAdapter
{
     }
 
     private <T extends Query<?, ?>, U extends Object> List<WorkflowFormTO>
getForms(final Query<T, U> query) {
-        final List<WorkflowFormTO> forms = new ArrayList<WorkflowFormTO>();
+        List<WorkflowFormTO> forms = new ArrayList<WorkflowFormTO>();
 
         for (U obj : query.list()) {
             try {
@@ -772,6 +800,7 @@ public class ActivitiUserWorkflowAdapter extends AbstractUserWorkflowAdapter
{
         return new SimpleEntry<Task, TaskFormData>(task, formData);
     }
 
+    @Transactional
     @Override
     public WorkflowFormTO claimForm(final String taskId, final String username)
             throws WorkflowException {
@@ -797,6 +826,7 @@ public class ActivitiUserWorkflowAdapter extends AbstractUserWorkflowAdapter
{
         return getFormTO(task, checked.getValue());
     }
 
+    @Transactional
     @Override
     public WorkflowResult<UserMod> submitForm(final WorkflowFormTO form, final String
username)
             throws WorkflowException {


Mime
View raw message