summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSidharth Singh2013-02-05 09:27:58 (EST)
committer Sven Rottstock2013-03-11 06:31:15 (EDT)
commitb067d3887e0761e905cbb5495db9c0e26614920d (patch)
treeba43f994c3c7fc3080c270fa121bca1b2ebb97ad
parenta31c4ae6a2867e36e325d4c430dee94d79fcb7c9 (diff)
downloadorg.eclipse.stardust.ui.web-b067d3887e0761e905cbb5495db9c0e26614920d.zip
org.eclipse.stardust.ui.web-b067d3887e0761e905cbb5495db9c0e26614920d.tar.gz
org.eclipse.stardust.ui.web-b067d3887e0761e905cbb5495db9c0e26614920d.tar.bz2
Jira-ID: CRNT-27174
1)Added new methods getUser(account),getUser(oid) in UserUtils.java in views-common. 2)Changed references from UserService.getUser(account) and UserService.getUser(oid) to UserUtils.java methods git-svn-id: http://emeafrazerg/svn/ipp/product/trunk/stardust/ui.web@62777 8100b5e0-4d52-466c-ae9c-bdeccbdeaf6b
-rw-r--r--admin-portal/src/main/java/org/eclipse/stardust/ui/web/admin/views/ParticipantManagementBean.java5
-rw-r--r--views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/docmgmt/DocumentMgmtUtility.java5
-rw-r--r--views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/helper/activityTable/ActivityInstanceWithPrio.java4
-rw-r--r--views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/participantManagement/ParticipantTree.java6
-rw-r--r--views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/process/history/ActivityInstanceHistoryItem.java5
-rw-r--r--views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/processContextExplorer/ProcessInstanceDetailsBean.java5
-rw-r--r--views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/security/Participant.java3
-rw-r--r--views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/user/UserDetailsBean.java7
-rw-r--r--views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/user/UserProfileBean.java8
-rw-r--r--views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/utils/ActivityInstanceUtils.java2
-rw-r--r--views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/utils/ParticipantUtils.java4
-rw-r--r--views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/utils/UserUtils.java73
12 files changed, 104 insertions, 23 deletions
diff --git a/admin-portal/src/main/java/org/eclipse/stardust/ui/web/admin/views/ParticipantManagementBean.java b/admin-portal/src/main/java/org/eclipse/stardust/ui/web/admin/views/ParticipantManagementBean.java
index 29ad6ec..1f8c2a8 100644
--- a/admin-portal/src/main/java/org/eclipse/stardust/ui/web/admin/views/ParticipantManagementBean.java
+++ b/admin-portal/src/main/java/org/eclipse/stardust/ui/web/admin/views/ParticipantManagementBean.java
@@ -18,6 +18,7 @@ import java.util.Set;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
+import org.eclipse.stardust.engine.api.dto.UserDetailsLevel;
import org.eclipse.stardust.engine.api.runtime.User;
import org.eclipse.stardust.ui.web.admin.AdminportalConstants;
import org.eclipse.stardust.ui.web.admin.ResourcePaths;
@@ -36,7 +37,7 @@ import org.eclipse.stardust.ui.web.viewscommon.dialogs.ICallbackHandler;
import org.eclipse.stardust.ui.web.viewscommon.docmgmt.ParametricCallbackHandler;
import org.eclipse.stardust.ui.web.viewscommon.participantManagement.ParticipantTree;
import org.eclipse.stardust.ui.web.viewscommon.participantManagement.ParticipantUserObject;
-import org.eclipse.stardust.ui.web.viewscommon.utils.ServiceFactoryUtils;
+import org.eclipse.stardust.ui.web.viewscommon.utils.UserUtils;
@@ -226,7 +227,7 @@ public class ParticipantManagementBean extends PopupUIComponentBean implements V
UserDetailsTableEntry userTabEntry = (UserDetailsTableEntry) getParameter("selectedUser");
if (userTabEntry.isSelectedRow())
{
- recentlySelectedUser = ServiceFactoryUtils.getUserService().getUser(userTabEntry.getUser().getOID());
+ recentlySelectedUser = UserUtils.getUser(userTabEntry.getUser().getOID(),UserDetailsLevel.Full);
selecteUsers.add(recentlySelectedUser);
}
}
diff --git a/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/docmgmt/DocumentMgmtUtility.java b/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/docmgmt/DocumentMgmtUtility.java
index 1fc41fc..415328f 100644
--- a/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/docmgmt/DocumentMgmtUtility.java
+++ b/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/docmgmt/DocumentMgmtUtility.java
@@ -51,7 +51,6 @@ import org.eclipse.stardust.engine.api.runtime.Folder;
import org.eclipse.stardust.engine.api.runtime.ProcessInstance;
import org.eclipse.stardust.engine.api.runtime.ProcessInstanceState;
import org.eclipse.stardust.engine.api.runtime.User;
-import org.eclipse.stardust.engine.api.runtime.UserService;
import org.eclipse.stardust.engine.api.runtime.WorkflowService;
import org.eclipse.stardust.engine.core.repository.DocumentRepositoryFolderNames;
import org.eclipse.stardust.engine.extensions.dms.data.DmsConstants;
@@ -72,6 +71,7 @@ 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.ProcessInstanceUtils;
import org.eclipse.stardust.ui.web.viewscommon.utils.ServiceFactoryUtils;
+import org.eclipse.stardust.ui.web.viewscommon.utils.UserUtils;
import org.eclipse.stardust.ui.web.viewscommon.views.document.JCRDocument;
import org.eclipse.stardust.ui.web.viewscommon.views.document.JCRVersionTracker;
import org.eclipse.stardust.ui.web.viewscommon.views.documentsearch.DocumentSearchProvider;
@@ -1127,8 +1127,7 @@ public class DocumentMgmtUtility
{
try
{
- UserService service = ServiceFactoryUtils.getUserService();
- return service.getUser(document.getOwner());
+ return UserUtils.getUser(document.getOwner());
}
catch (Exception e)
{
diff --git a/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/helper/activityTable/ActivityInstanceWithPrio.java b/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/helper/activityTable/ActivityInstanceWithPrio.java
index 8f89cae..366d8e1 100644
--- a/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/helper/activityTable/ActivityInstanceWithPrio.java
+++ b/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/helper/activityTable/ActivityInstanceWithPrio.java
@@ -32,10 +32,10 @@ import org.eclipse.stardust.ui.web.common.util.DateUtils;
import org.eclipse.stardust.ui.web.viewscommon.utils.ActivityInstanceUtils;
import org.eclipse.stardust.ui.web.viewscommon.utils.AuthorizationUtils;
import org.eclipse.stardust.ui.web.viewscommon.utils.I18nUtils;
-import org.eclipse.stardust.ui.web.viewscommon.utils.ParticipantUtils;
import org.eclipse.stardust.ui.web.viewscommon.utils.ProcessInstanceUtils;
import org.eclipse.stardust.ui.web.viewscommon.utils.ResubmissionUtils;
import org.eclipse.stardust.ui.web.viewscommon.utils.ServiceFactoryUtils;
+import org.eclipse.stardust.ui.web.viewscommon.utils.UserUtils;
@@ -204,7 +204,7 @@ public class ActivityInstanceWithPrio implements Serializable
UserInfo userInfo = activityInstance.getPerformedBy();
if (null != userInfo)
{
- User user = ServiceFactoryUtils.getUserService().getUser(userInfo.getId());
+ User user = UserUtils.getUser(userInfo.getId());
return I18nUtils.getUserLabel(user);
}
else
diff --git a/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/participantManagement/ParticipantTree.java b/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/participantManagement/ParticipantTree.java
index 3a4dbb1..e55d7a8 100644
--- a/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/participantManagement/ParticipantTree.java
+++ b/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/participantManagement/ParticipantTree.java
@@ -35,6 +35,7 @@ import org.eclipse.stardust.common.CollectionUtils;
import org.eclipse.stardust.common.error.InvalidArgumentException;
import org.eclipse.stardust.common.log.LogManager;
import org.eclipse.stardust.common.log.Logger;
+import org.eclipse.stardust.engine.api.dto.UserDetailsLevel;
import org.eclipse.stardust.engine.api.model.DynamicParticipantInfo;
import org.eclipse.stardust.engine.api.model.Model;
import org.eclipse.stardust.engine.api.model.Organization;
@@ -44,6 +45,7 @@ import org.eclipse.stardust.engine.api.model.QualifiedModelParticipantInfo;
import org.eclipse.stardust.engine.api.model.QualifiedOrganizationInfo;
import org.eclipse.stardust.engine.api.model.Role;
import org.eclipse.stardust.engine.api.query.ParticipantAssociationFilter;
+import org.eclipse.stardust.engine.api.query.UserDetailsPolicy;
import org.eclipse.stardust.engine.api.query.UserGroupQuery;
import org.eclipse.stardust.engine.api.query.UserQuery;
import org.eclipse.stardust.engine.api.query.Users;
@@ -59,6 +61,7 @@ import org.eclipse.stardust.engine.api.runtime.UserService;
import org.eclipse.stardust.ui.web.viewscommon.beans.SessionContext;
import org.eclipse.stardust.ui.web.viewscommon.common.GenericDataFilterOnOff;
import org.eclipse.stardust.ui.web.viewscommon.common.PortalException;
+import org.eclipse.stardust.ui.web.viewscommon.common.configuration.UserPreferencesEntries;
import org.eclipse.stardust.ui.web.viewscommon.dialogs.CallbackHandler;
import org.eclipse.stardust.ui.web.viewscommon.dialogs.PanelConfirmation;
import org.eclipse.stardust.ui.web.viewscommon.messages.MessagesViewsCommonBean;
@@ -522,6 +525,9 @@ public class ParticipantTree
{
UserQuery userQuery = UserQuery.findAll();
userQuery.getFilter().add(ParticipantAssociationFilter.forParticipant(participantInfo, false));
+ UserDetailsPolicy userPolicy = new UserDetailsPolicy(UserDetailsLevel.Full);
+ userPolicy.setPreferenceModules(UserPreferencesEntries.M_ADMIN_PORTAL);
+ userQuery.setPolicy(userPolicy);
Users allUsers = getQryService().getAllUsers(userQuery);
int index = 0;
for (User user : allUsers)
diff --git a/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/process/history/ActivityInstanceHistoryItem.java b/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/process/history/ActivityInstanceHistoryItem.java
index 7794b3d..5c36b19 100644
--- a/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/process/history/ActivityInstanceHistoryItem.java
+++ b/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/process/history/ActivityInstanceHistoryItem.java
@@ -32,6 +32,7 @@ import org.eclipse.stardust.ui.web.viewscommon.utils.ActivityInstanceUtils;
import org.eclipse.stardust.ui.web.viewscommon.utils.I18nUtils;
import org.eclipse.stardust.ui.web.viewscommon.utils.ParticipantUtils;
import org.eclipse.stardust.ui.web.viewscommon.utils.ServiceFactoryUtils;
+import org.eclipse.stardust.ui.web.viewscommon.utils.UserUtils;
@@ -179,7 +180,7 @@ public class ActivityInstanceHistoryItem extends AbstractProcessHistoryTableEntr
if (activityInstance.isAssignedToUser())
{
UserInfo userInfo = (UserInfo) activityInstance.getCurrentPerformer();
- User user = ServiceFactoryUtils.getUserService().getUser(userInfo.getId());
+ User user = UserUtils.getUser(userInfo.getId());
performer = I18nUtils.getUserLabel(user);
}
else if (activityInstance.isAssignedToModelParticipant() && activityInstance.getCurrentPerformer()!=null)
@@ -200,7 +201,7 @@ public class ActivityInstanceHistoryItem extends AbstractProcessHistoryTableEntr
UserInfo userInfo = activityInstance.getPerformedBy();
if (null != userInfo)
{
- User user = ServiceFactoryUtils.getUserService().getUser(userInfo.getId());
+ User user = UserUtils.getUser(userInfo.getId());
performer= I18nUtils.getUserLabel(user);
}
else
diff --git a/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/processContextExplorer/ProcessInstanceDetailsBean.java b/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/processContextExplorer/ProcessInstanceDetailsBean.java
index cad0958..1d9d5a4 100644
--- a/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/processContextExplorer/ProcessInstanceDetailsBean.java
+++ b/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/processContextExplorer/ProcessInstanceDetailsBean.java
@@ -41,6 +41,7 @@ import org.eclipse.stardust.engine.api.runtime.ActivityInstance;
import org.eclipse.stardust.engine.api.runtime.PredefinedProcessInstanceLinkTypes;
import org.eclipse.stardust.engine.api.runtime.ProcessInstance;
import org.eclipse.stardust.engine.api.runtime.QueryService;
+import org.eclipse.stardust.engine.api.runtime.User;
import org.eclipse.stardust.engine.api.runtime.WorkflowService;
import org.eclipse.stardust.ui.web.common.PopupUIComponentBean;
import org.eclipse.stardust.ui.web.common.app.PortalApplication;
@@ -880,7 +881,9 @@ public class ProcessInstanceDetailsBean extends PopupUIComponentBean
public String getStartingUser()
{
- return UserUtils.getUserDisplayLabel(getProcessInstance().getStartingUser());
+ User startingUser = getProcessInstance().getStartingUser();
+ UserUtils.loadDisplayPreferenceForUser(startingUser);
+ return UserUtils.getUserDisplayLabel(startingUser);
}
/**
diff --git a/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/security/Participant.java b/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/security/Participant.java
index 8b5547d..151af1e 100644
--- a/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/security/Participant.java
+++ b/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/security/Participant.java
@@ -25,6 +25,7 @@ import org.eclipse.stardust.ui.web.viewscommon.utils.I18nUtils;
import org.eclipse.stardust.ui.web.viewscommon.utils.ModelUtils;
import org.eclipse.stardust.ui.web.viewscommon.utils.ParticipantUtils;
import org.eclipse.stardust.ui.web.viewscommon.utils.ServiceFactoryUtils;
+import org.eclipse.stardust.ui.web.viewscommon.utils.UserUtils;
public class Participant implements Comparable<Participant>
{
@@ -80,7 +81,7 @@ public class Participant implements Comparable<Participant>
{
principal = new DmsPrincipal(userInfo, realmId);
id = principal.getName();
- User user = ServiceFactoryUtils.getUserService().getUser(userInfo.getId());
+ User user = UserUtils.getUser(userInfo.getId());
name = I18nUtils.getUserLabel(user);
}
diff --git a/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/user/UserDetailsBean.java b/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/user/UserDetailsBean.java
index 123f2a9..33c3f1e 100644
--- a/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/user/UserDetailsBean.java
+++ b/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/user/UserDetailsBean.java
@@ -16,12 +16,10 @@ import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
import org.eclipse.stardust.engine.api.runtime.User;
-import org.eclipse.stardust.engine.api.runtime.UserService;
import org.eclipse.stardust.ui.web.common.PopupUIComponentBean;
import org.eclipse.stardust.ui.web.viewscommon.common.PortalException;
import org.eclipse.stardust.ui.web.viewscommon.utils.ExceptionHandler;
import org.eclipse.stardust.ui.web.viewscommon.utils.MyPicturePreferenceUtils;
-import org.eclipse.stardust.ui.web.viewscommon.utils.ServiceFactoryUtils;
import org.eclipse.stardust.ui.web.viewscommon.utils.UserUtils;
@@ -103,10 +101,9 @@ public class UserDetailsBean extends PopupUIComponentBean
return;
}
- UserService userService = ServiceFactoryUtils.getUserService();
- if ((userOid != null) && (userService != null))
+ if (userOid != null)
{
- user = userService.getUser(userOid.longValue());
+ user = UserUtils.getUser(userOid.longValue());
}
}
catch (Exception e)
diff --git a/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/user/UserProfileBean.java b/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/user/UserProfileBean.java
index 84a65f6..415d261 100644
--- a/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/user/UserProfileBean.java
+++ b/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/user/UserProfileBean.java
@@ -28,6 +28,7 @@ import org.eclipse.stardust.common.config.Parameters;
import org.eclipse.stardust.common.error.PublicException;
import org.eclipse.stardust.common.security.InvalidPasswordException;
import org.eclipse.stardust.engine.api.dto.QualityAssuranceAdminServiceFacade;
+import org.eclipse.stardust.engine.api.dto.UserDetailsLevel;
import org.eclipse.stardust.engine.api.model.PredefinedConstants;
import org.eclipse.stardust.engine.api.query.PreferenceQuery;
import org.eclipse.stardust.engine.api.runtime.AdministrationService;
@@ -40,7 +41,6 @@ import org.eclipse.stardust.engine.core.preferences.PreferenceScope;
import org.eclipse.stardust.engine.core.preferences.Preferences;
import org.eclipse.stardust.engine.core.runtime.beans.removethis.SecurityProperties;
import org.eclipse.stardust.ui.web.common.PopupUIComponentBean;
-import org.eclipse.stardust.ui.web.common.configuration.UserPreferencesHelper;
import org.eclipse.stardust.ui.web.common.dialogs.ConfirmationDialog;
import org.eclipse.stardust.ui.web.common.dialogs.ConfirmationDialog.DialogActionType;
import org.eclipse.stardust.ui.web.common.dialogs.ConfirmationDialog.DialogContentType;
@@ -328,11 +328,10 @@ public class UserProfileBean extends PopupUIComponentBean implements Confirmatio
}
else if ((isModifyMode() || isModifyProfileConfiguration()) && null != user)
{
- UserService userService = ServiceFactoryUtils.getUserService();
Long userOid = user.getOID();
- if ((userOid != null) && (userService != null))
+ if (userOid != null)
{
- user = userService.getUser(userOid.longValue());
+ user = UserUtils.getUser(userOid.longValue(), UserDetailsLevel.Full);
}
headerTitle = propsBean.getString("views.modifyUser.title");
changePassword = false;
@@ -345,7 +344,6 @@ public class UserProfileBean extends PopupUIComponentBean implements Confirmatio
validTo = user.getValidTo();
description = user.getDescription();
qaOverride = user.getQualityAssuranceProbability();
- UserUtils.loadDisplayPreferenceForUser(user);
if (isModifyProfileConfiguration())
{
diff --git a/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/utils/ActivityInstanceUtils.java b/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/utils/ActivityInstanceUtils.java
index 3522fd0..0a3d43b 100644
--- a/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/utils/ActivityInstanceUtils.java
+++ b/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/utils/ActivityInstanceUtils.java
@@ -302,7 +302,7 @@ public class ActivityInstanceUtils
if (ai.isAssignedToUser())
{
UserInfo userInfo = (UserInfo) ai.getCurrentPerformer();
- User user = ServiceFactoryUtils.getUserService().getUser(userInfo.getId());
+ User user = UserUtils.getUser(userInfo.getId());
performerName = I18nUtils.getUserLabel(user);
}
else
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 2f2e12c..1333c5b 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
@@ -23,6 +23,7 @@ import javax.xml.namespace.QName;
import org.eclipse.stardust.common.CollectionUtils;
import org.eclipse.stardust.common.config.Parameters;
+import org.eclipse.stardust.engine.api.dto.UserDetailsLevel;
import org.eclipse.stardust.engine.api.model.DynamicParticipantInfo;
import org.eclipse.stardust.engine.api.model.Model;
import org.eclipse.stardust.engine.api.model.ModelParticipant;
@@ -193,11 +194,12 @@ public class ParticipantUtils
break;
case USER:
- participant = ServiceFactoryUtils.getUserService().getUser(participantInfo.getId());
+ participant = UserUtils.getUser(participantInfo.getId(), UserDetailsLevel.Full);
break;
case USERGROUP:
participant = ServiceFactoryUtils.getUserService().getUserGroup(participantInfo.getId());
+ UserUtils.loadDisplayPreferenceForUser((User)participant);
break;
}
}
diff --git a/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/utils/UserUtils.java b/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/utils/UserUtils.java
index 6830c7b..f8ae617 100644
--- a/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/utils/UserUtils.java
+++ b/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/utils/UserUtils.java
@@ -29,6 +29,7 @@ import org.eclipse.stardust.engine.api.model.OrganizationInfo;
import org.eclipse.stardust.engine.api.model.Participant;
import org.eclipse.stardust.engine.api.model.QualifiedModelParticipantInfo;
import org.eclipse.stardust.engine.api.model.Role;
+import org.eclipse.stardust.engine.api.query.FilterAndTerm;
import org.eclipse.stardust.engine.api.query.FilterOrTerm;
import org.eclipse.stardust.engine.api.query.PreferenceQuery;
import org.eclipse.stardust.engine.api.query.SubsetPolicy;
@@ -126,6 +127,78 @@ public class UserUtils
}
/**
+ *
+ * @param account
+ * @return
+ */
+ public static User getUser(String account)
+ {
+ // When call is made to display only user label, we use 'Core' details Level
+ return getUser(account, null, UserDetailsLevel.Core);
+ }
+
+ /**
+ *
+ * @param account
+ * @param userDetailsLevel
+ * @return
+ */
+ public static User getUser(String account, UserDetailsLevel userDetailsLevel)
+ {
+ return getUser(account, null, userDetailsLevel);
+ }
+
+ /**
+ *
+ * @param account
+ * @return
+ */
+ public static User getUser(Long oid)
+ {
+ // When call is made to display only user label, we use 'Core' details Level
+ return getUser(null, oid, UserDetailsLevel.Core);
+ }
+
+ /**
+ *
+ * @param oid
+ * @param userDetailsLevel
+ * @return
+ */
+ public static User getUser(Long oid, UserDetailsLevel userDetailsLevel)
+ {
+ return getUser(null, oid, userDetailsLevel);
+ }
+
+ /**
+ *
+ * @param account
+ * @param oid
+ * @param userDetailsLevel
+ * @return
+ */
+ public static User getUser(String account, Long oid, UserDetailsLevel userDetailsLevel)
+ {
+ UserQuery userQuery = UserQuery.findAll();
+
+ String[] prefModules = {UserPreferencesEntries.M_ADMIN_PORTAL, UserPreferencesEntries.M_VIEWS_COMMON};
+ UserDetailsPolicy userPolicy = new UserDetailsPolicy(userDetailsLevel);
+ userPolicy.setPreferenceModules(prefModules);
+ userQuery.setPolicy(userPolicy);
+
+ FilterAndTerm filter = userQuery.getFilter().addAndTerm();
+ if (null != account)
+ filter.and(UserQuery.ACCOUNT.like(account));
+ if (null != oid)
+ filter.and(UserQuery.OID.isEqual(oid));
+ userQuery.where(filter);
+
+ Users users = SessionContext.findSessionContext().getServiceFactory().getQueryService().getAllUsers(userQuery);
+
+ return users.isEmpty() ? null : users.get(0);
+ }
+
+ /**
* @param users
* @return
*/