summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSidharth Singh2013-05-28 07:49:30 (EDT)
committer Stephan Born2013-08-28 12:51:36 (EDT)
commit5b7b302b2c93d394b059308875d52c6ec4dc8dfa (patch)
tree194e0f19ad050a40d9f2fa2ec3ce619444acc458
parent22649a114da69efc10e83159fc1a0748db60e26c (diff)
downloadorg.eclipse.stardust.ui.web-5b7b302b2c93d394b059308875d52c6ec4dc8dfa.zip
org.eclipse.stardust.ui.web-5b7b302b2c93d394b059308875d52c6ec4dc8dfa.tar.gz
org.eclipse.stardust.ui.web-5b7b302b2c93d394b059308875d52c6ec4dc8dfa.tar.bz2
Jira-ID: CRNT-27976
Made following changes to DefaultAssemblyLineActivityProvider.createWorklistQuery() If participant is departmentScope, used ORG details to get Department and used dept.getScopedParticipant() as ParticipantContributer. Added departmentsCache to store the dept map. git-svn-id: https://svn.csa.sungard.com/repos/ipp2/product/trunk/stardust/ui.web@65141 8100b5e0-4d52-466c-ae9c-bdeccbdeaf6b Signed-off-by: Sidharth Singh <sidharth.singh@sungard.com>
-rw-r--r--views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/common/provider/DefaultAssemblyLineActivityProvider.java104
1 files changed, 100 insertions, 4 deletions
diff --git a/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/common/provider/DefaultAssemblyLineActivityProvider.java b/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/common/provider/DefaultAssemblyLineActivityProvider.java
index 0967d66..2a7b380 100644
--- a/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/common/provider/DefaultAssemblyLineActivityProvider.java
+++ b/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/common/provider/DefaultAssemblyLineActivityProvider.java
@@ -10,14 +10,22 @@
*******************************************************************************/
package org.eclipse.stardust.ui.web.viewscommon.common.provider;
+import java.util.HashMap;
import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
import java.util.Set;
+import org.eclipse.stardust.common.CollectionUtils;
import org.eclipse.stardust.common.CompareHelper;
import org.eclipse.stardust.common.error.ConcurrencyException;
import org.eclipse.stardust.engine.api.model.ConditionalPerformer;
import org.eclipse.stardust.engine.api.model.ModelParticipant;
+import org.eclipse.stardust.engine.api.model.Organization;
import org.eclipse.stardust.engine.api.model.Participant;
+import org.eclipse.stardust.engine.api.model.ParticipantInfo;
+import org.eclipse.stardust.engine.api.model.Role;
import org.eclipse.stardust.engine.api.query.FilterTerm;
import org.eclipse.stardust.engine.api.query.ParticipantWorklist;
import org.eclipse.stardust.engine.api.query.PerformingParticipantFilter;
@@ -26,12 +34,15 @@ import org.eclipse.stardust.engine.api.query.UserWorklist;
import org.eclipse.stardust.engine.api.query.Worklist;
import org.eclipse.stardust.engine.api.query.WorklistQuery;
import org.eclipse.stardust.engine.api.runtime.ActivityInstance;
+import org.eclipse.stardust.engine.api.runtime.Department;
+import org.eclipse.stardust.engine.api.runtime.QueryService;
import org.eclipse.stardust.engine.api.runtime.QualityAssuranceUtils.QualityAssuranceState;
import org.eclipse.stardust.engine.api.runtime.WorkflowService;
import org.eclipse.stardust.ui.web.viewscommon.common.AbstractProcessExecutionPortal;
import org.eclipse.stardust.ui.web.viewscommon.common.PortalException;
import org.eclipse.stardust.ui.web.viewscommon.common.provider.IAssemblyLineActivityProvider;
import org.eclipse.stardust.ui.web.viewscommon.utils.ModelCache;
+import org.eclipse.stardust.ui.web.viewscommon.utils.ServiceFactoryUtils;
@@ -48,23 +59,103 @@ import org.eclipse.stardust.ui.web.viewscommon.utils.ModelCache;
*/
public class DefaultAssemblyLineActivityProvider implements IAssemblyLineActivityProvider
{
-
+ private Map<String, List<Department>> departmentsCache = new HashMap<String, List<Department>>();
+
protected WorklistQuery createWorklistQuery(Set participantIds, boolean outline)
{
+ Map<String, Organization> organizationMap = CollectionUtils.newHashMap();
WorklistQuery query = new WorklistQuery();
query.setUserContribution(SubsetPolicy.UNRESTRICTED);
for (Iterator i = participantIds.iterator(); i.hasNext();)
{
String participantId = (String) i.next();
- query.setParticipantContribution(
- PerformingParticipantFilter.forModelParticipant(participantId, false),
- outline ? new SubsetPolicy(0, true) : null);
+ ModelParticipant participant = (ModelParticipant) ModelCache.findModelCache().getParticipant(participantId);
+ if(!participant.isDepartmentScoped())
+ {
+ // For non-department scoped Participant use the participantId for filter
+ query.setParticipantContribution(PerformingParticipantFilter.forModelParticipant(participantId, false),
+ outline ? new SubsetPolicy(0, true) : null);
+ }
+ else
+ {
+ List<Department> deptList;
+
+ if(!updateOrganizationMap(participant,organizationMap))
+ {
+ continue; // If query already contains filter for Org/Role, loop out
+ }
+ // Loop over each Org. to get Department for setting filter on Scoped
+ // Participant of Dept.
+ for (Entry<String, Organization> entry : organizationMap.entrySet())
+ {
+ Organization org = entry.getValue();
+ if (departmentsCache.containsKey(org.getQualifiedId()))
+ {
+ deptList = departmentsCache.get(org.getQualifiedId());
+ }
+ else
+ {
+ // Populate Department cache
+ QueryService qs = ServiceFactoryUtils.getQueryService();
+ deptList = qs.findAllDepartments(org.getDepartment(), org);
+ departmentsCache.put(org.getQualifiedId(), deptList);
+ }
+
+ for (Department department : deptList)
+ {
+ ParticipantInfo participantInfo = department.getScopedParticipant(participant);
+ if (null != participantInfo)
+ {
+ query.setParticipantContribution(PerformingParticipantFilter
+ .forParticipant(participantInfo, false), outline ? new SubsetPolicy(0, true) : null);
+ }
+ }
+ }
+ }
}
FilterTerm filter = query.getFilter().addAndTerm();
long caseActivityOID = ModelCache.findModelCache().getDefaultCaseActivity().getRuntimeElementOID();
filter.add(WorklistQuery.ACTIVITY_OID.notEqual(caseActivityOID));
return query;
}
+
+ /**
+ * Updates the original Org Map, return true if map is updated, return false, if Org.
+ * Map already contains key
+ *
+ * @param participant
+ * @param organizationMap
+ * @return
+ */
+ private boolean updateOrganizationMap(Participant participant, Map<String, Organization> organizationMap)
+ {
+ if (participant instanceof Organization)
+ {
+ if (!organizationMap.containsKey(participant.getQualifiedId()))
+ {
+ // Create a map for unique Org, used for fetching dept.
+ organizationMap.put(participant.getQualifiedId(), (Organization) participant);
+ return true;
+ }
+ }
+ else if (participant instanceof Role)
+ {
+ Role role = (Role) participant;
+ List<Organization> worksForOrganizations = role.getClientOrganizations();
+
+ if ((worksForOrganizations != null) && (worksForOrganizations.size() > 0))
+ {
+ String orgQualifierId = worksForOrganizations.get(0).getQualifiedId();
+ if (!organizationMap.containsKey(orgQualifierId))
+ {
+ organizationMap.put(orgQualifierId, worksForOrganizations.get(0));
+ return true;
+ }
+ }
+ }
+ // If Org. Map was not updated return false
+ return false;
+ }
private boolean isAssemblyLineActivity(Set assemblyLineParticipants, ActivityInstance ai)
{
@@ -173,4 +264,9 @@ public class DefaultAssemblyLineActivityProvider implements IAssemblyLineActivit
}
return activityCount;
}
+
+ public Map<String, List<Department>> getDepartmentsCache()
+ {
+ return departmentsCache;
+ }
}