summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVikas Mishra2012-03-28 04:32:33 (EDT)
committer Manik Kishore2012-06-19 07:24:02 (EDT)
commitf6fd7ff85e87cd70ada341efbf3b6eb52b16c368 (patch)
tree4fe560014a888d7467b7b0e8feaa4dcdc5d5b171
parent50f243d8271b4d05b75cddefb346f3bf3fe00b05 (diff)
downloadorg.eclipse.stardust.ui.web-f6fd7ff85e87cd70ada341efbf3b6eb52b16c368.zip
org.eclipse.stardust.ui.web-f6fd7ff85e87cd70ada341efbf3b6eb52b16c368.tar.gz
org.eclipse.stardust.ui.web-f6fd7ff85e87cd70ada341efbf3b6eb52b16c368.tar.bz2
Jira-ID: CRNT-24322
1)Created CaseDelegateProvider class to handle Case delegation for User,Role Org.(dept is handled by existing code). 2)Added support for Scoped Role and Org for non default hierarchy. 3)changed label to standard label for scoped participant. git-svn-id: http://emeafrazerg/svn/ipp/product/trunk/stardust/ui.web@54991 8100b5e0-4d52-466c-ae9c-bdeccbdeaf6b
-rw-r--r--views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/common/ModelHelper.java3
-rw-r--r--views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/dialogs/CaseDelegateProvider.java227
-rw-r--r--views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/dialogs/DefaultDelegatesProvider.java47
-rw-r--r--views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/dialogs/DelegationBean.java59
-rw-r--r--views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/dialogs/DelegationHandlerBean.java9
-rw-r--r--views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/dialogs/IDelegatesProvider.java4
-rw-r--r--views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/dialogs/IDelegationHandler.java4
-rw-r--r--views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/user/DelegatesDataProvider.java39
-rw-r--r--views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/user/ParticipantAutocompleteSelector.java1
-rw-r--r--views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/utils/ParticipantUtils.java49
10 files changed, 354 insertions, 88 deletions
diff --git a/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/common/ModelHelper.java b/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/common/ModelHelper.java
index 570226b..e3b56b0 100644
--- a/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/common/ModelHelper.java
+++ b/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/common/ModelHelper.java
@@ -67,10 +67,11 @@ public class ModelHelper
Role role = (Role) ModelUtils.getModelCache().getParticipant(roleInfo.getId(), Role.class);
// Format: RoleName (OrgName - DeptName)
- AdministrationService as = SessionContext.findSessionContext().getServiceFactory().getAdministrationService();
+
participantName = I18nUtils.getParticipantName(role);
if (departmentInfo != null && !Department.DEFAULT.equals(departmentInfo))
{
+ AdministrationService as = SessionContext.findSessionContext().getServiceFactory().getAdministrationService();
Department department = as.getDepartment(departmentInfo.getOID());
String organizationName = I18nUtils.getParticipantName(department.getOrganization());
participantName += " (" + organizationName + " - " + department.getName() + ")";
diff --git a/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/dialogs/CaseDelegateProvider.java b/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/dialogs/CaseDelegateProvider.java
new file mode 100644
index 0000000..cd2852e
--- /dev/null
+++ b/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/dialogs/CaseDelegateProvider.java
@@ -0,0 +1,227 @@
+/*
+ * $Id$
+ * (C) 2000 - 2012 CARNOT AG
+ */
+package org.eclipse.stardust.ui.web.viewscommon.dialogs;
+
+import java.io.Serializable;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.stardust.common.CollectionUtils;
+import org.eclipse.stardust.common.StringUtils;
+import org.eclipse.stardust.engine.api.model.ModelParticipantInfo;
+import org.eclipse.stardust.engine.api.model.Organization;
+import org.eclipse.stardust.engine.api.model.OrganizationInfo;
+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.model.RoleInfo;
+import org.eclipse.stardust.engine.api.query.FilterOrTerm;
+import org.eclipse.stardust.engine.api.query.UserQuery;
+import org.eclipse.stardust.engine.api.runtime.ActivityInstance;
+import org.eclipse.stardust.engine.api.runtime.Department;
+import org.eclipse.stardust.engine.api.runtime.DeployedModel;
+import org.eclipse.stardust.engine.api.runtime.PerformerType;
+import org.eclipse.stardust.ui.web.viewscommon.utils.ModelCache;
+import org.eclipse.stardust.ui.web.viewscommon.utils.ParticipantUtils;
+import org.eclipse.stardust.ui.web.viewscommon.utils.RegExUtils;
+import org.eclipse.stardust.ui.web.viewscommon.utils.ServiceFactoryUtils;
+
+
+/**
+ * Class is DelegateProvider implementation for Case Process
+ *
+ * @author Vikas.Mishra
+ * @version $Revision: $
+ */
+public class CaseDelegateProvider implements IDelegatesProvider, Serializable
+{
+ private static final long serialVersionUID = -3937163761535955743L;
+ public static final CaseDelegateProvider INSTANCE = new CaseDelegateProvider();
+
+ /**
+ * private constructor
+ */
+ private CaseDelegateProvider()
+ {
+
+ }
+
+ /**
+ *
+ */
+ public Map<PerformerType, List< ? extends ParticipantInfo>> findDelegates(List<ActivityInstance> activityInstances,
+ Options options)
+ {
+
+ Map<PerformerType, List< ? extends ParticipantInfo>> result = CollectionUtils.newHashMap();
+ // add users
+ if (options.getPerformerTypes().contains(USER_TYPE))
+ {
+ result.putAll(findUserDelegates(options));
+ }
+ // add org,role and department
+ Collection<ParticipantInfo> participantInfos = getParticipantsFromActiveModels(options);
+ result.putAll(findParticipantDelegates(participantInfos, options));
+
+ return result;
+
+ }
+
+ /**
+ *
+ * @param options
+ * @return
+ */
+ private Map<PerformerType, List< ? extends ParticipantInfo>> findUserDelegates(Options options)
+ {
+ Map<PerformerType, List< ? extends ParticipantInfo>> result = CollectionUtils.newHashMap();
+
+ // user filter
+ if (options.getPerformerTypes().contains(USER_TYPE))
+ {
+ UserQuery userQuery = UserQuery.findActive();
+
+ // filter for user names if selected
+ if (!StringUtils.isEmpty(options.getNameFilter()))
+ {
+ String name = options.getNameFilter().replaceAll("\\*", "%") + "%";
+ String nameFirstLetterCaseChanged = alternateFirstLetter(name);
+ FilterOrTerm or = userQuery.getFilter().addOrTerm();
+ or.add(UserQuery.LAST_NAME.like(name));
+ or.add(UserQuery.LAST_NAME.like(nameFirstLetterCaseChanged));
+ or.add(UserQuery.FIRST_NAME.like(name));
+ or.add(UserQuery.FIRST_NAME.like(nameFirstLetterCaseChanged));
+ or.add(UserQuery.ACCOUNT.like(name));
+ or.add(UserQuery.ACCOUNT.like(nameFirstLetterCaseChanged));
+ }
+ userQuery.orderBy(UserQuery.LAST_NAME).and(UserQuery.FIRST_NAME).and(UserQuery.ACCOUNT);
+
+ List< ? extends Participant> matchingUsers = ServiceFactoryUtils.getQueryService().getAllUsers(userQuery);
+ // add result for type
+ result.put(PerformerType.User, matchingUsers);
+
+ }
+ return result;
+ }
+
+ /**
+ *
+ * @param participantInfos
+ * @param options
+ */
+ private Map<PerformerType, List< ? extends ParticipantInfo>> findParticipantDelegates(
+ final Collection<ParticipantInfo> participantInfos, final Options options)
+ {
+ Map<PerformerType, List< ? extends ParticipantInfo>> result = CollectionUtils.newHashMap();
+
+ String filterValue = options.getNameFilter();
+ String regex = null;
+
+ if (!StringUtils.isEmpty(filterValue))
+ {
+ regex = RegExUtils.escape(filterValue.toLowerCase()).replaceAll("\\*", ".*") + ".*";
+ }
+
+ List<ParticipantInfo> matchingModelParticipants = CollectionUtils.newList();
+ // filter participants if we search for a string
+
+ for (ParticipantInfo participantInfo : participantInfos)
+ {
+ String name = participantInfo.getName();
+ if (StringUtils.isEmpty(regex) || name.toLowerCase().matches(regex))
+ {
+ matchingModelParticipants.add(participantInfo);
+ }
+ }
+ result.put(PerformerType.ModelParticipant, matchingModelParticipants);
+ return result;
+ }
+
+ /**
+ *
+ * @return
+ */
+ private Collection<ParticipantInfo> getParticipantsFromActiveModels(Options options)
+ {
+ ModelCache modelCache = ModelCache.findModelCache();
+ List<DeployedModel> activeModels = modelCache.getActiveModels();
+ Map<String, ParticipantInfo> participants = CollectionUtils.newMap();
+
+ for (DeployedModel model : activeModels)
+ {
+ List<Participant> allParticipants = model.getAllParticipants();
+ for (Participant participant : allParticipants)
+ {
+ if (participant instanceof Role || participant instanceof Organization || participant instanceof Department)
+ {
+ // add
+ if (!filterParticipant(participant, options))
+ {
+ participants.put(ParticipantUtils.getParticipantUniqueKey(participant), participant);
+ }
+
+ ModelParticipantInfo mp = (ModelParticipantInfo) participant;
+ if (mp.isDepartmentScoped())
+ {
+ List<ModelParticipantInfo> runtimeScopes = ParticipantUtils.getRuntimeScopes(mp);
+
+ for (ModelParticipantInfo participantInfo : runtimeScopes)
+ {
+ // add
+ if (!filterParticipant(participantInfo, options))
+ {
+ participants.put(ParticipantUtils.getParticipantUniqueKey(participantInfo), participantInfo);
+ }
+ }
+
+ }
+ }
+ }
+ }
+
+ Collection<ParticipantInfo> uniqueParticipants = participants.values();
+ return uniqueParticipants;
+ }
+
+ /**
+ *
+ * @param participant
+ * @param options
+ * @return
+ */
+ private boolean filterParticipant(ParticipantInfo participant, Options options)
+ {
+ if (participant instanceof OrganizationInfo && options.getPerformerTypes().contains(ORGANIZATION_TYPE))
+ {
+ return false;
+ }
+ // else if (participant instanceof DepartmentInfo &&
+ // options.getPerformerTypes().contains(DEPARTMENT_TYPE))
+ // {
+ // return false;
+ // }
+ else if (participant instanceof RoleInfo && options.getPerformerTypes().contains(ROLE_TYPE))
+ {
+ return false;
+ }
+ return true;
+ }
+
+ private static String alternateFirstLetter(String field)
+ {
+ String firstLetter = field.substring(0, 1);
+ if (firstLetter.compareTo(field.substring(0, 1).toLowerCase()) == 0)
+ {
+ firstLetter = firstLetter.toUpperCase();
+ }
+ else
+ {
+ firstLetter = firstLetter.toLowerCase();
+ }
+ return firstLetter + field.substring(1);
+ }
+
+}
diff --git a/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/dialogs/DefaultDelegatesProvider.java b/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/dialogs/DefaultDelegatesProvider.java
index 0f09eeb..313b8f1 100644
--- a/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/dialogs/DefaultDelegatesProvider.java
+++ b/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/dialogs/DefaultDelegatesProvider.java
@@ -47,7 +47,6 @@ import org.eclipse.stardust.engine.api.runtime.PerformerType;
import org.eclipse.stardust.engine.api.runtime.QueryService;
import org.eclipse.stardust.engine.api.runtime.QualityAssuranceUtils.QualityAssuranceState;
import org.eclipse.stardust.ui.web.viewscommon.beans.SessionContext;
-import org.eclipse.stardust.ui.web.viewscommon.utils.ActivityInstanceUtils;
import org.eclipse.stardust.ui.web.viewscommon.utils.ModelCache;
import org.eclipse.stardust.ui.web.viewscommon.utils.ModelUtils;
import org.eclipse.stardust.ui.web.viewscommon.utils.ParticipantUtils;
@@ -66,18 +65,17 @@ public class DefaultDelegatesProvider implements IDelegatesProvider, Serializabl
public static final DefaultDelegatesProvider INSTANCE = new DefaultDelegatesProvider();
- public Map<PerformerType, List<? extends Participant>> findDelegates(
+ public Map<PerformerType, List<? extends ParticipantInfo>> findDelegates(
List<ActivityInstance> activityInstances, Options options)
{
- Map<PerformerType, List<? extends Participant>> result = CollectionUtils.newMap();
+ Map<PerformerType, List<? extends ParticipantInfo>> result = CollectionUtils.newMap();
QueryService service = getQueryService();
if ((null != service) && (null != activityInstances))
{
// collect models
- Set<Integer> models = CollectionUtils.newSet();
- boolean isCaseActivities = ActivityInstanceUtils.isDefaultCaseActivities(activityInstances);
+ Set<Integer> models = CollectionUtils.newSet();
for (int i = 0; i < activityInstances.size(); ++i)
{
@@ -94,9 +92,8 @@ public class DefaultDelegatesProvider implements IDelegatesProvider, Serializabl
if (options.getPerformerTypes().contains(USER_TYPE))
{
// limited or not
- UserQuery userQuery = (options.isStrictSearch() && !isCaseActivities)
- ? buildStrictUserQuery(activityInstances)
- : UserQuery.findActive();
+ UserQuery userQuery = (options.isStrictSearch()) ? buildStrictUserQuery(activityInstances) : UserQuery
+ .findActive();
// filter for user names if selected
if (!StringUtils.isEmpty(options.getNameFilter()))
@@ -132,7 +129,7 @@ public class DefaultDelegatesProvider implements IDelegatesProvider, Serializabl
ActivityInstance ai = activityInstances.get(i);
// limited search
- if (options.isStrictSearch() && !isCaseActivities)
+ if (options.isStrictSearch())
{
ModelParticipant modelParticipant = getActivityPerformer(ai);
@@ -193,15 +190,13 @@ public class DefaultDelegatesProvider implements IDelegatesProvider, Serializabl
}
// get all from model and select only the ones we have filtered
- Collection<Participant> candidateParticipants = isCaseActivities
- ? getUniqueParticipantsFromActiveModels()
- : getCommonParticipantsFromModels(models);
+ Collection<Participant> candidateParticipants = getCommonParticipantsFromModels(models);
List<String> roleIds = CollectionUtils.newList();
List<String> orgIds = CollectionUtils.newList();
for (Iterator<Participant> i = candidateParticipants.iterator(); i.hasNext();)
{
Participant p = i.next();
- if (!options.isStrictSearch() || isCaseActivities || defaultPerformerSet.contains(p.getId()))
+ if (!options.isStrictSearch() || defaultPerformerSet.contains(p.getId()))
{
if (p instanceof Organization)
{
@@ -390,31 +385,7 @@ public class DefaultDelegatesProvider implements IDelegatesProvider, Serializabl
return userQuery;
}
- /**
- *
- * @return
- */
- private static Collection<Participant> getUniqueParticipantsFromActiveModels()
- {
- ModelCache modelCache = ModelCache.findModelCache();
- List<DeployedModel> activeModels = modelCache.getActiveModels();
- Map<String, Participant> participants = CollectionUtils.newMap();
-
- for (DeployedModel model : activeModels)
- {
- List<Participant> allParticipants = model.getAllParticipants();
- for (Participant participant : allParticipants)
- {
- if (participant instanceof Role || participant instanceof Organization)
- {
- participants.put(participant.getId(), participant);
- }
- }
- }
-
- Collection<Participant> uniqueParticipants = participants.values();
- return uniqueParticipants;
- }
+
// collect all participants
private static Collection<Participant> getCommonParticipantsFromModels(
diff --git a/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/dialogs/DelegationBean.java b/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/dialogs/DelegationBean.java
index 40d8c13..deb6516 100644
--- a/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/dialogs/DelegationBean.java
+++ b/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/dialogs/DelegationBean.java
@@ -33,10 +33,10 @@ import org.eclipse.stardust.common.log.LogManager;
import org.eclipse.stardust.common.log.Logger;
import org.eclipse.stardust.engine.api.dto.DepartmentDetails;
import org.eclipse.stardust.engine.api.model.ModelParticipant;
-import org.eclipse.stardust.engine.api.model.Organization;
+import org.eclipse.stardust.engine.api.model.OrganizationInfo;
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.model.RoleInfo;
import org.eclipse.stardust.engine.api.query.UserGroups;
import org.eclipse.stardust.engine.api.query.Users;
import org.eclipse.stardust.engine.api.runtime.ActivityInstance;
@@ -50,6 +50,7 @@ import org.eclipse.stardust.ui.web.viewscommon.utils.ManagedBeanUtils;
import org.eclipse.stardust.ui.web.viewscommon.beans.SessionContext;
import org.eclipse.stardust.ui.web.viewscommon.common.Localizer;
import org.eclipse.stardust.ui.web.viewscommon.common.LocalizerKey;
+import org.eclipse.stardust.ui.web.viewscommon.common.ModelHelper;
import org.eclipse.stardust.ui.web.viewscommon.dialogs.ICallbackHandler.EventType;
import org.eclipse.stardust.ui.web.viewscommon.dialogs.IDelegatesProvider.Options;
import org.eclipse.stardust.ui.web.viewscommon.messages.MessagesViewsCommonBean;
@@ -231,16 +232,13 @@ public class DelegationBean extends PopupUIComponentBean
propsBean.getString("views.common.activity.abortActivity.failureMsg1"));
return;
}
- }
+ }
- if (participant != null)
- {
- delegatedActivities = delHandler.delegateActivities(ais, participant, params);
- }
- else if (department != null)
+ if (department != null)
{
delegatedActivities = delHandler.delegateActivities(ais, department, params);
}
+ //this will delegate to Case and non Case activity
else if (null != obj && obj instanceof ParticipantInfo)
{
delegatedActivities = delHandler.delegateActivities(ais, (ParticipantInfo) obj, params);
@@ -300,7 +298,7 @@ public class DelegationBean extends PopupUIComponentBean
if (autoCompleteSelector == null)
{
- autoCompleteSelector = new ParticipantAutocompleteSelector(new DelegatesDataProvider(
+ DelegatesDataProvider delegatesDataProvider=new DelegatesDataProvider(
new ParticipantFilterCriteria()
{
@@ -328,7 +326,10 @@ public class DelegationBean extends PopupUIComponentBean
{
return typeFilter;
}
- }), null);
+ });
+ delegatesProvider = delegateCase ? CaseDelegateProvider.INSTANCE : delegatesProvider;
+ delegatesDataProvider.setDelegatesProvider(delegatesProvider);
+ autoCompleteSelector = new ParticipantAutocompleteSelector(delegatesDataProvider, null);
}
}
@@ -484,20 +485,20 @@ public class DelegationBean extends PopupUIComponentBean
*/
private void retrieveDefaultParticipants()
{
- IDelegatesProvider delegatesProvider = getDelegatesProvider();
+ delegatesProvider = delegateCase ? CaseDelegateProvider.INSTANCE : delegatesProvider;
if (null == delegatesProvider)
{
delegatesProvider = DefaultDelegatesProvider.INSTANCE;
trace.info("Using DEFAULT delegates provider to retrieve participants");
}
- Map<PerformerType, List<? extends Participant>> delegates = delegatesProvider.findDelegates(ais,
+ Map<PerformerType, List<? extends ParticipantInfo>> delegates = delegatesProvider.findDelegates(ais,
getDelegateProviderOptions());
if (!CollectionUtils.isEmpty(delegates))
{
// handle users
- List<? extends Participant> users = delegates.get(PerformerType.User);
+ List<? extends ParticipantInfo> users = delegates.get(PerformerType.User);
if ((users instanceof Users) && ((Users) users).hasMore())
{
@@ -510,7 +511,7 @@ public class DelegationBean extends PopupUIComponentBean
}
// handle model participants
- List<? extends Participant> modelParticipants = delegates.get(PerformerType.ModelParticipant);
+ List<? extends ParticipantInfo> modelParticipants = delegates.get(PerformerType.ModelParticipant);
if (!CollectionUtils.isEmpty(modelParticipants))
{
@@ -518,7 +519,7 @@ public class DelegationBean extends PopupUIComponentBean
}
// handle user groups
- List<? extends Participant> userGroups = delegates.get(PerformerType.UserGroup);
+ List<? extends ParticipantInfo> userGroups = delegates.get(PerformerType.UserGroup);
if ((userGroups instanceof UserGroups) && ((UserGroups) userGroups).hasMore())
{
@@ -538,12 +539,13 @@ public class DelegationBean extends PopupUIComponentBean
*
* @param delegates
*/
- private void appendParticipantsToSearchResult(List<? extends Participant> delegates)
+ private void appendParticipantsToSearchResult(List< ? extends ParticipantInfo> delegates)
{
- for (int i = 0; i < delegates.size(); ++i)
+ for (ParticipantInfo delegate : delegates)
{
- Participant delegate = delegates.get(i);
- searchResult.add(new ParticipantEntry(delegate, false));
+ {
+ searchResult.add(new ParticipantEntry(delegate, false));
+ }
}
}
@@ -975,7 +977,7 @@ public class DelegationBean extends PopupUIComponentBean
{
private final static long serialVersionUID = 1l;
- private Participant participant;
+ private ParticipantInfo participant;
private DepartmentInfo department;
@@ -989,15 +991,15 @@ public class DelegationBean extends PopupUIComponentBean
private String label;
- public ParticipantEntry(Participant participant)
+ public ParticipantEntry(ParticipantInfo participant)
{
this.participant = participant;
- if (participant instanceof Role)
+ if (participant instanceof RoleInfo)
{
isRole = true;
type = "delegation.role";
}
- else if (participant instanceof Organization)
+ else if (participant instanceof OrganizationInfo)
{
isOrganization = true;
type = "delegation.organization";
@@ -1009,7 +1011,7 @@ public class DelegationBean extends PopupUIComponentBean
this.label = getLabel();
}
- public ParticipantEntry(Participant participant, boolean select)
+ public ParticipantEntry(ParticipantInfo participant, boolean select)
{
this(participant);
this.selected = select;
@@ -1052,7 +1054,7 @@ public class DelegationBean extends PopupUIComponentBean
return isOrganization;
}
- public Participant getParticipant()
+ public ParticipantInfo getParticipant()
{
return participant;
}
@@ -1063,7 +1065,7 @@ public class DelegationBean extends PopupUIComponentBean
{
if (isRole() || isOrganization())
{
- return I18nUtils.getParticipantName(participant);
+ return ModelHelper.getParticipantName(participant);//I18nUtils.getParticipantName(participant);
}
else if (participant instanceof User)
{
@@ -1072,7 +1074,7 @@ public class DelegationBean extends PopupUIComponentBean
}
else if (isReferencingDepartment())
{
- if (department instanceof DepartmentDetails)
+ if (department instanceof Department)
{
DepartmentDetails deptDetail = (DepartmentDetails) department;
if (null != deptDetail.getOrganization() && deptDetail.getOrganization().isDepartmentScoped())
@@ -1080,9 +1082,10 @@ public class DelegationBean extends PopupUIComponentBean
StringBuilder departmentName = new StringBuilder();
departmentName.append(I18nUtils.getParticipantName(deptDetail.getOrganization()));
return departmentName.append(" - ").append(department.getName()).toString();
+
}
- }
+ }
return department.getName();
}
return "";
diff --git a/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/dialogs/DelegationHandlerBean.java b/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/dialogs/DelegationHandlerBean.java
index c1bc24f..0771da9 100644
--- a/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/dialogs/DelegationHandlerBean.java
+++ b/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/dialogs/DelegationHandlerBean.java
@@ -60,13 +60,8 @@ public class DelegationHandlerBean implements IDelegationHandler
protected final static Logger trace = LogManager
.getLogger(DelegationHandlerBean.class);
- private MessagesViewsCommonBean propsBean = MessagesViewsCommonBean.getInstance();
-
- public List<ActivityInstance> delegateActivities(List<ActivityInstance> activities, Participant toParticipant,
- Map<String, Object> params) throws FacesException
- {
- return delegateActivities(activities, (ParticipantInfo) toParticipant, params);
- }
+ private MessagesViewsCommonBean propsBean = MessagesViewsCommonBean.getInstance();
+
public List<ActivityInstance> delegateActivities(List<ActivityInstance> activities,
ParticipantInfo toParticipantInfo, Map<String, Object> params) throws FacesException
diff --git a/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/dialogs/IDelegatesProvider.java b/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/dialogs/IDelegatesProvider.java
index 19eac91..b417d72 100644
--- a/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/dialogs/IDelegatesProvider.java
+++ b/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/dialogs/IDelegatesProvider.java
@@ -14,7 +14,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
-import org.eclipse.stardust.engine.api.model.Participant;
+import org.eclipse.stardust.engine.api.model.ParticipantInfo;
import org.eclipse.stardust.engine.api.runtime.ActivityInstance;
import org.eclipse.stardust.engine.api.runtime.PerformerType;
@@ -98,7 +98,7 @@ public interface IDelegatesProvider
* @param options Additional options further describing the domain of valid delegates.
* @return A list of valid delegates per requested participant category.
*/
- Map<PerformerType, List<? extends Participant>> findDelegates(
+ Map<PerformerType, List<? extends ParticipantInfo>> findDelegates(
List<ActivityInstance> activityInstances, Options options);
interface Factory
diff --git a/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/dialogs/IDelegationHandler.java b/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/dialogs/IDelegationHandler.java
index 54139ef..5323594 100644
--- a/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/dialogs/IDelegationHandler.java
+++ b/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/dialogs/IDelegationHandler.java
@@ -15,8 +15,6 @@ import java.util.List;
import java.util.Map;
import javax.faces.FacesException;
-
-import org.eclipse.stardust.engine.api.model.Participant;
import org.eclipse.stardust.engine.api.model.ParticipantInfo;
import org.eclipse.stardust.engine.api.runtime.ActivityInstance;
import org.eclipse.stardust.engine.api.runtime.Department;
@@ -24,8 +22,6 @@ import org.eclipse.stardust.engine.api.runtime.Department;
public interface IDelegationHandler extends Serializable
{
- public List<ActivityInstance> delegateActivities(List<ActivityInstance> activities, Participant toParticipant,
- Map<String, Object> params) throws FacesException;
public List<ActivityInstance> delegateActivities(List<ActivityInstance> activities, Department toDepartment,
Map<String, Object> params) throws FacesException;
diff --git a/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/user/DelegatesDataProvider.java b/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/user/DelegatesDataProvider.java
index 0b7aef4..001a2b5 100644
--- a/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/user/DelegatesDataProvider.java
+++ b/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/user/DelegatesDataProvider.java
@@ -18,11 +18,13 @@ import java.util.Set;
import javax.faces.model.SelectItem;
import org.eclipse.stardust.engine.api.model.Participant;
+import org.eclipse.stardust.engine.api.model.ParticipantInfo;
import org.eclipse.stardust.engine.api.runtime.DepartmentInfo;
import org.eclipse.stardust.engine.api.runtime.PerformerType;
import org.eclipse.stardust.ui.web.common.autocomplete.IAutocompleteDataProvider;
import org.eclipse.stardust.ui.web.viewscommon.dialogs.DefaultDelegatesProvider;
import org.eclipse.stardust.ui.web.viewscommon.dialogs.DepartmentDelegatesProvider;
+import org.eclipse.stardust.ui.web.viewscommon.dialogs.IDelegatesProvider;
import org.eclipse.stardust.ui.web.viewscommon.dialogs.ParticipantFilterCriteria;
@@ -41,6 +43,8 @@ public class DelegatesDataProvider implements IAutocompleteDataProvider
private static final int DEPARTMENT_TYPE = 4;
private ParticipantFilterCriteria addnFilterCriteria;
+
+ private IDelegatesProvider delegatesProvider;
/**
* @param addnFilterCriteria
@@ -60,9 +64,12 @@ public class DelegatesDataProvider implements IAutocompleteDataProvider
* (java.lang.String, int)
*/
public List<SelectItem> getMatchingData(String searchValue, int maxMatches)
- {
- Map<PerformerType, List<? extends Participant>> delegates = DefaultDelegatesProvider.INSTANCE.findDelegates(
- addnFilterCriteria.getActivityInstances(), addnFilterCriteria.getDefaultParticipantOptions());
+ {
+ if (null == delegatesProvider)
+ {
+ delegatesProvider = DefaultDelegatesProvider.INSTANCE;
+ }
+
List<SelectItem> userItems = new ArrayList<SelectItem>();
// Add default participants
@@ -70,6 +77,10 @@ public class DelegatesDataProvider implements IAutocompleteDataProvider
if (typeFilter == ALL_TYPES || typeFilter == USER_TYPE || typeFilter == ROLE_TYPE
|| typeFilter == ORGANIZATION_TYPE)
{
+
+ Map<PerformerType, List< ? extends ParticipantInfo>> delegates = delegatesProvider.findDelegates(
+ addnFilterCriteria.getActivityInstances(), addnFilterCriteria.getDefaultParticipantOptions());
+
List<ParticipantWrapper> selectedParticipants = new ArrayList<ParticipantWrapper>();
selectedParticipants.addAll(copyToParticipantWrapperList(delegates.get(PerformerType.User)));
selectedParticipants.addAll(copyToParticipantWrapperList(delegates.get(PerformerType.ModelParticipant)));
@@ -80,6 +91,7 @@ public class DelegatesDataProvider implements IAutocompleteDataProvider
userItems.add(new SelectItem(participantWrapper, participantWrapper.getText()));
}
}
+
// Add departments
if (typeFilter == ALL_TYPES || typeFilter == DEPARTMENT_TYPE)
{
@@ -100,17 +112,30 @@ public class DelegatesDataProvider implements IAutocompleteDataProvider
* @param allParticipants
* @return
*/
- private List<ParticipantWrapper> copyToParticipantWrapperList(List<? extends Participant> allParticipants)
+ private List<ParticipantWrapper> copyToParticipantWrapperList(List< ? extends ParticipantInfo> allParticipants)
{
List<ParticipantWrapper> selectParticipants = new ArrayList<ParticipantWrapper>();
if (allParticipants != null)
{
- for (Participant participant : allParticipants)
+ for (ParticipantInfo participantInfo : allParticipants)
{
-
- selectParticipants.add(new ParticipantWrapper(participant));
+ if (participantInfo instanceof Participant)
+ {
+ selectParticipants.add(new ParticipantWrapper((Participant) participantInfo));
+ }
}
}
return selectParticipants;
}
+
+ public IDelegatesProvider getDelegatesProvider()
+ {
+ return delegatesProvider;
+ }
+
+ public void setDelegatesProvider(IDelegatesProvider delegatesProvider)
+ {
+ this.delegatesProvider = delegatesProvider;
+ }
+
}
diff --git a/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/user/ParticipantAutocompleteSelector.java b/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/user/ParticipantAutocompleteSelector.java
index be605dc..ac56e01 100644
--- a/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/user/ParticipantAutocompleteSelector.java
+++ b/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/user/ParticipantAutocompleteSelector.java
@@ -23,7 +23,6 @@ import org.eclipse.stardust.ui.web.common.column.ColumnPreference;
import org.eclipse.stardust.ui.web.common.column.DefaultColumnModel;
import org.eclipse.stardust.ui.web.common.column.IColumnModel;
import org.eclipse.stardust.ui.web.common.column.ColumnPreference.ColumnAlignment;
-import org.eclipse.stardust.ui.web.common.message.MessageDialog;
import org.eclipse.stardust.ui.web.common.table.SortableTable;
import org.eclipse.stardust.ui.web.common.table.SortableTableComparator;
import org.eclipse.stardust.ui.web.common.util.CollectionUtils;
diff --git a/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/utils/ParticipantUtils.java b/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/utils/ParticipantUtils.java
index 822c113..fbe5f27 100644
--- a/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/utils/ParticipantUtils.java
+++ b/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/utils/ParticipantUtils.java
@@ -639,4 +639,53 @@ public class ParticipantUtils
return grant.getQualifiedId();
}
+
+
+ /**
+ * @param modelParticipantInfo
+ * @return
+ */
+ public static List<ModelParticipantInfo> getRuntimeScopes(ModelParticipantInfo modelParticipantInfo)
+ {
+ List<ModelParticipantInfo> modelParticipants = new ArrayList<ModelParticipantInfo>();
+
+ if (modelParticipantInfo instanceof Organization)
+ {
+ Organization organization = (Organization) modelParticipantInfo;
+ List<Department> departments = ServiceFactoryUtils.getQueryService().findAllDepartments(null, organization);
+
+ for (Department department : departments)
+ {
+ modelParticipants.add(department.getScopedParticipant(organization));
+ }
+ }
+ else if (modelParticipantInfo instanceof Role)
+ {
+ Role role = (Role) modelParticipantInfo;
+ Organization parentOrganization = null;
+ List<Organization> leadsOrganizations = role.getTeams();
+ if (CollectionUtils.isEmpty(leadsOrganizations))
+ {
+ List<Organization> worksForOrganizations = role.getClientOrganizations();
+ if ((worksForOrganizations != null) && (worksForOrganizations.size() > 0))
+ {
+ parentOrganization = worksForOrganizations.get(0);
+ }
+ }
+ else
+ {
+ parentOrganization = leadsOrganizations.get(0);
+ }
+ List<Department> departments = ServiceFactoryUtils.getQueryService().findAllDepartments(null,
+ parentOrganization);
+
+ for (Department department : departments)
+ {
+ modelParticipants.add(department.getScopedParticipant(role));
+ }
+ }
+
+ return modelParticipants;
+ }
+
}