summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSidharth Singh2013-07-08 09:55:57 (EDT)
committerStephan Born2013-08-29 05:04:35 (EDT)
commit63e7f0c7ed1f0de16904823af0ed77e45ab18298 (patch)
treef0c491b94b464a0beccf8637490d3d49a689a042
parent79af214cbc650980436c5465cabcd20ec294310c (diff)
downloadorg.eclipse.stardust.ui.web-63e7f0c7ed1f0de16904823af0ed77e45ab18298.zip
org.eclipse.stardust.ui.web-63e7f0c7ed1f0de16904823af0ed77e45ab18298.tar.gz
org.eclipse.stardust.ui.web-63e7f0c7ed1f0de16904823af0ed77e45ab18298.tar.bz2
Jira-ID: CRNT-26814
Refactored some code for worklist tree functionality. git-svn-id: https://svn.csa.sungard.com/repos/ipp2/product/trunk/stardust/ui.web@65892 8100b5e0-4d52-466c-ae9c-bdeccbdeaf6b Signed-off-by: Sidharth Singh <sidharth.singh@sungard.com>
-rw-r--r--process-portal/src/main/java/org/eclipse/stardust/ui/web/processportal/launchpad/WorklistsTreeUserObject.java22
-rw-r--r--process-portal/src/main/java/org/eclipse/stardust/ui/web/processportal/view/WorklistTableBean.java62
-rw-r--r--views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/utils/ParticipantWorklistCacheEntry.java29
-rw-r--r--views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/utils/ParticipantWorklistCacheManager.java21
-rw-r--r--views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/utils/WorklistUtils.java19
5 files changed, 84 insertions, 69 deletions
diff --git a/process-portal/src/main/java/org/eclipse/stardust/ui/web/processportal/launchpad/WorklistsTreeUserObject.java b/process-portal/src/main/java/org/eclipse/stardust/ui/web/processportal/launchpad/WorklistsTreeUserObject.java
index d7a7ebc..cb540e0 100644
--- a/process-portal/src/main/java/org/eclipse/stardust/ui/web/processportal/launchpad/WorklistsTreeUserObject.java
+++ b/process-portal/src/main/java/org/eclipse/stardust/ui/web/processportal/launchpad/WorklistsTreeUserObject.java
@@ -20,9 +20,12 @@ import javax.swing.tree.DefaultMutableTreeNode;
import org.eclipse.stardust.common.CollectionUtils;
import org.eclipse.stardust.engine.api.model.Participant;
import org.eclipse.stardust.engine.api.model.ParticipantInfo;
+import org.eclipse.stardust.engine.api.query.FilterOrTerm;
import org.eclipse.stardust.engine.api.query.PerformingParticipantFilter;
+import org.eclipse.stardust.engine.api.query.PerformingUserFilter;
import org.eclipse.stardust.engine.api.query.Query;
-import org.eclipse.stardust.engine.api.query.WorklistQuery;
+import org.eclipse.stardust.engine.api.runtime.User;
+import org.eclipse.stardust.engine.api.runtime.UserInfo;
import org.eclipse.stardust.ui.web.common.util.FacesUtils;
import org.eclipse.stardust.ui.web.processportal.common.PPUtils;
import org.eclipse.stardust.ui.web.viewscommon.common.ModelHelper;
@@ -67,23 +70,30 @@ public class WorklistsTreeUserObject extends IceUserObject
String viewKey = ParticipantUtils.getWorklistViewKey(participantInfo);
Participant participant= ParticipantUtils.getParticipant(participantInfo);
Map<String, Object> params = CollectionUtils.newTreeMap();
+ Query query = null;
boolean leafNode= Boolean.valueOf((FacesUtils.getRequestParameter("leafNode")));
- WorklistQuery query = ParticipantWorklistCacheManager.getInstance().getWorklistQuery(participantInfo);
if (!leafNode)
{
+ // Use Activity Instance Query for Unified worklist
+ query = ParticipantWorklistCacheManager.getInstance().getActivityInstanceQuery(participantInfo);
+ FilterOrTerm or = query.getFilter().addOrTerm();
+ User user = (User) ParticipantUtils.getParticipant(participantInfo);
+ or.add(new PerformingUserFilter(user.getOID()));
Set<ParticipantInfo> partInfo = ParticipantWorklistCacheManager.getInstance().getWorklistParticipants()
.get(participantInfo.getId());
for (ParticipantInfo participantInfo1 : partInfo)
{
- if (!participantInfo1.getId().equals(participantInfo.getId()))
- {
- query.setParticipantContribution(PerformingParticipantFilter.forParticipant(participantInfo1, false));
- }
+ if (!(participantInfo1 instanceof UserInfo))
+ or.add(PerformingParticipantFilter.forParticipant(participantInfo1));
}
// As Personal WL also has same viewKey,append Qualifier Id to make Unique
// viewKey at parent Node
viewKey = viewKey + participantInfo.getQualifiedId();
}
+ else
+ {
+ query = ParticipantWorklistCacheManager.getInstance().getWorklistQuery(participantInfo);
+ }
params.put(Query.class.getName(), query);
params.put("participantInfo", participantInfo);
params.put("id", participant.getQualifiedId());
diff --git a/process-portal/src/main/java/org/eclipse/stardust/ui/web/processportal/view/WorklistTableBean.java b/process-portal/src/main/java/org/eclipse/stardust/ui/web/processportal/view/WorklistTableBean.java
index 63f7843..a2a5d90 100644
--- a/process-portal/src/main/java/org/eclipse/stardust/ui/web/processportal/view/WorklistTableBean.java
+++ b/process-portal/src/main/java/org/eclipse/stardust/ui/web/processportal/view/WorklistTableBean.java
@@ -18,7 +18,6 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
-import java.util.ListIterator;
import java.util.Map;
import java.util.Set;
import java.util.Map.Entry;
@@ -49,7 +48,6 @@ import org.eclipse.stardust.engine.api.query.ProcessDefinitionFilter;
import org.eclipse.stardust.engine.api.query.Query;
import org.eclipse.stardust.engine.api.query.QueryResult;
import org.eclipse.stardust.engine.api.query.RawQueryResult;
-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;
@@ -253,7 +251,7 @@ public class WorklistTableBean extends UIComponentBean
showAllWorklist = (Boolean) getParamFromView("showAllWorklist");
if (StringUtils.isNotEmpty(wrappedLabel))
{
- this.view.setLabel(getMessages().getString("wrappedLabel", wrappedLabel));
+ this.view.setLabel(getMessages().getString("wrappedLabel", wrappedLabel));
}
break;
@@ -433,14 +431,6 @@ public class WorklistTableBean extends UIComponentBean
if (query instanceof WorklistQuery)
{
Worklist worklist = ServiceFactoryUtils.getWorkflowService().getWorklist((WorklistQuery) query);
- if (showAllWorklist)
- {
- List<Object> worklistList = fetchWorklistResult(worklist,participantInfo);
- queryResult = new RawQueryResult<Object>(worklistList, worklist.getSubsetPolicy(), false,
- Long.valueOf(worklistList.size()), worklist.getTotalCountThreshold());
- }
- else
- {
queryResult = PPUtils.extractParticipantWorklist(worklist, participantInfo);
//TODO- Temperory code added to handle scenario when null Sub-Worklist is returned.
//Engine should return empty list
@@ -456,7 +446,6 @@ public class WorklistTableBean extends UIComponentBean
ParticipantWorklistCacheManager.getInstance().setWorklistThresholdCount(participantInfo,
queryResult.getTotalCountThreshold());
}
- }
}
else if (query instanceof ActivityInstanceQuery)
{
@@ -485,55 +474,6 @@ public class WorklistTableBean extends UIComponentBean
}
/**
- *
- * @param worklist
- * @return
- */
- private List<Object> fetchWorklistResult(Worklist worklist, ParticipantInfo participant)
- {
- List<Object> list = CollectionUtils.newArrayList();
- if (participant.getId().equals(worklist.getOwner().getId()))
- {
- list.addAll(iterateWorklistObjects(worklist.listIterator()));
- }
- list.addAll(fetchSubWorklist(worklist, participant));
- return list;
- }
-
- private List<Object> fetchSubWorklist(Worklist worklist, ParticipantInfo participant)
- {
- List<Object> list = CollectionUtils.newArrayList();
- Iterator<Worklist> subWorklistIter = worklist.getSubWorklists();
- while (subWorklistIter.hasNext())
- {
- Worklist subWorklist = subWorklistIter.next();
- if ((subWorklist instanceof UserWorklist) && (!subWorklist.getOwner().getId().equals(participant.getId())))
- {
- continue;
- }
- list.addAll(iterateWorklistObjects(subWorklist.listIterator()));
- list.addAll(fetchSubWorklist(subWorklist, participant));
- }
- return list;
- }
-
- /**
- *
- * @param listIterator
- * @param list
- * @return
- */
- private List<Object> iterateWorklistObjects(ListIterator<ActivityInstance> listIterator)
- {
- List<Object> list=CollectionUtils.newArrayList();
- while (listIterator.hasNext())
- {
- list.add(listIterator.next());
- }
- return list;
- }
-
- /**
* @return
*
*/
diff --git a/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/utils/ParticipantWorklistCacheEntry.java b/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/utils/ParticipantWorklistCacheEntry.java
index 8a820e2..095a35e 100644
--- a/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/utils/ParticipantWorklistCacheEntry.java
+++ b/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/utils/ParticipantWorklistCacheEntry.java
@@ -12,6 +12,7 @@ package org.eclipse.stardust.ui.web.viewscommon.utils;
import java.io.Serializable;
+import org.eclipse.stardust.engine.api.query.ActivityInstanceQuery;
import org.eclipse.stardust.engine.api.query.WorklistQuery;
/**
@@ -24,6 +25,7 @@ public class ParticipantWorklistCacheEntry implements Serializable
private long count;
private long totalCountThreshold;
private WorklistQuery worklistQuery;
+ private ActivityInstanceQuery activityInstanceQuery;
private String worklistOwner;
/**
@@ -46,6 +48,23 @@ public class ParticipantWorklistCacheEntry implements Serializable
this.totalCountThreshold = totalCountThreshold;
this.worklistOwner = worklistOwner;
}
+
+ /**
+ *
+ * @param count
+ * @param worklistQuery
+ * @param activityQuery
+ * @param totalCountThreshold
+ * @param worklistOwner
+ */
+ public ParticipantWorklistCacheEntry(long count, WorklistQuery worklistQuery, ActivityInstanceQuery activityQuery,
+ long totalCountThreshold, String worklistOwner)
+ {
+ this(count, worklistQuery);
+ this.totalCountThreshold = totalCountThreshold;
+ this.worklistOwner = worklistOwner;
+ this.activityInstanceQuery = activityQuery;
+ }
public long getCount()
{
@@ -77,6 +96,16 @@ public class ParticipantWorklistCacheEntry implements Serializable
this.worklistQuery = worklistQuery;
}
+ public ActivityInstanceQuery getActivityInstanceQuery()
+ {
+ return activityInstanceQuery;
+ }
+
+ public void setActivityInstanceQuery(ActivityInstanceQuery activityInstanceQuery)
+ {
+ this.activityInstanceQuery = activityInstanceQuery;
+ }
+
public String getWorklistOwner()
{
return worklistOwner;
diff --git a/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/utils/ParticipantWorklistCacheManager.java b/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/utils/ParticipantWorklistCacheManager.java
index add2fde..3c23126 100644
--- a/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/utils/ParticipantWorklistCacheManager.java
+++ b/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/utils/ParticipantWorklistCacheManager.java
@@ -15,10 +15,11 @@ import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
-import java.util.Set;
import java.util.Map.Entry;
+import java.util.Set;
import org.eclipse.stardust.engine.api.model.ParticipantInfo;
+import org.eclipse.stardust.engine.api.query.ActivityInstanceQuery;
import org.eclipse.stardust.engine.api.query.Worklist;
import org.eclipse.stardust.engine.api.query.WorklistQuery;
import org.eclipse.stardust.engine.api.runtime.ActivityInstance;
@@ -74,7 +75,12 @@ public class ParticipantWorklistCacheManager implements InitializingBean, Serial
for (Worklist worklist : entry.getValue())
{
worklistOwner = worklist.getOwner();
-
+ if(entry.getKey().equals(worklistOwner.getId()))
+ {
+ participantWorklists.put(new ParticipantInfoWrapper(worklistOwner), new ParticipantWorklistCacheEntry(
+ worklist.getTotalCount(), WorklistUtils.createWorklistQuery(worklistOwner),WorklistUtils.getAllUserAssignedActivities(),worklist.getTotalCountThreshold(),entry.getKey()));
+ }
+ else
participantWorklists.put(new ParticipantInfoWrapper(worklistOwner), new ParticipantWorklistCacheEntry(
worklist.getTotalCount(), WorklistUtils.createWorklistQuery(worklistOwner),worklist.getTotalCountThreshold(),entry.getKey()));
}
@@ -153,6 +159,17 @@ public class ParticipantWorklistCacheManager implements InitializingBean, Serial
/**
* @param participantInfo
+ * @return
+ */
+ public ActivityInstanceQuery getActivityInstanceQuery(ParticipantInfo participantInfo)
+ {
+ ParticipantWorklistCacheEntry pwc=participantWorklists.get(new ParticipantInfoWrapper(participantInfo));
+ ActivityInstanceQuery activityInstanceQuery = participantWorklists.get(new ParticipantInfoWrapper(participantInfo)).getActivityInstanceQuery();
+ return (ActivityInstanceQuery) QueryUtils.getClonedQuery(activityInstanceQuery);
+ }
+
+ /**
+ * @param participantInfo
* @param count
*/
public void setWorklistCount(ParticipantInfo participantInfo, long count)
diff --git a/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/utils/WorklistUtils.java b/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/utils/WorklistUtils.java
index 606f473..e320355 100644
--- a/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/utils/WorklistUtils.java
+++ b/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/utils/WorklistUtils.java
@@ -518,6 +518,25 @@ public class WorklistUtils
}
/**
+ * returns unified list of activities assigned to user(Personal,Role)
+ *
+ * @return
+ */
+ public static ActivityInstanceQuery getAllUserAssignedActivities()
+ {
+ ActivityInstanceQuery allAssignedActivitiesQuery = ActivityInstanceQuery.findInState(new ActivityInstanceState[] {
+ ActivityInstanceState.Application, ActivityInstanceState.Suspended});
+ allAssignedActivitiesQuery.setPolicy(EvaluateByWorkitemsPolicy.WORKITEMS);
+
+ allAssignedActivitiesQuery.setPolicy(new SubsetPolicy(0, true));
+ allAssignedActivitiesQuery.setPolicy(ExcludeUserPolicy.EXCLUDE_USER);
+
+ applyFilterProviders(allAssignedActivitiesQuery);
+
+ return allAssignedActivitiesQuery;
+ }
+
+ /**
* @param query
* @param process
*/