summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSidharth Singh2012-04-18 08:45:06 (EDT)
committer Manik Kishore2012-06-19 07:27:10 (EDT)
commit592adb762cd4aba1fa1552d590b7ec26e705e927 (patch)
tree06682f5393fd0c0951e5c8926ece20cdf2af0a67
parentb0ac9648b2afe639ec9a205a99ea26fea3d52ab6 (diff)
downloadorg.eclipse.stardust.ui.web-592adb762cd4aba1fa1552d590b7ec26e705e927.zip
org.eclipse.stardust.ui.web-592adb762cd4aba1fa1552d590b7ec26e705e927.tar.gz
org.eclipse.stardust.ui.web-592adb762cd4aba1fa1552d590b7ec26e705e927.tar.bz2
Jira-ID: CRNT-21100
1)Added parameterized method showNotifications() in NotificationMessageBean.java 2)Made changes to UserGroupManagementBean.java, UserManagementBean.java , AbortActivityBean.java, AbortProcessBean.java and ProcessInstanceUtils.java to remove all comman code to create NotificationMessageBean and called showNotifications() of NotificationMessageBean passing successNotificationList, failedNotificationList, successTitle , failedTitle and other optional arguments. git-svn-id: http://emeafrazerg/svn/ipp/product/trunk/stardust/ui.web@55576 8100b5e0-4d52-466c-ae9c-bdeccbdeaf6b
-rw-r--r--admin-portal/src/main/java/org/eclipse/stardust/ui/web/admin/views/UserGroupManagementBean.java35
-rw-r--r--admin-portal/src/main/java/org/eclipse/stardust/ui/web/admin/views/UserManagementBean.java32
-rw-r--r--views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/common/notification/NotificationMessageBean.java81
-rw-r--r--views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/dialogs/AbortActivityBean.java108
-rw-r--r--views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/utils/AbortProcessBean.java98
-rw-r--r--views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/utils/ProcessInstanceUtils.java80
6 files changed, 166 insertions, 268 deletions
diff --git a/admin-portal/src/main/java/org/eclipse/stardust/ui/web/admin/views/UserGroupManagementBean.java b/admin-portal/src/main/java/org/eclipse/stardust/ui/web/admin/views/UserGroupManagementBean.java
index ab5852a..a31cd4d 100644
--- a/admin-portal/src/main/java/org/eclipse/stardust/ui/web/admin/views/UserGroupManagementBean.java
+++ b/admin-portal/src/main/java/org/eclipse/stardust/ui/web/admin/views/UserGroupManagementBean.java
@@ -48,7 +48,6 @@ import org.eclipse.stardust.ui.web.common.util.FacesUtils;
import org.eclipse.stardust.ui.web.viewscommon.beans.SessionContext;
import org.eclipse.stardust.ui.web.viewscommon.common.PortalException;
import org.eclipse.stardust.ui.web.viewscommon.common.notification.NotificationItem;
-import org.eclipse.stardust.ui.web.viewscommon.common.notification.NotificationMessage;
import org.eclipse.stardust.ui.web.viewscommon.common.notification.NotificationMessageBean;
import org.eclipse.stardust.ui.web.viewscommon.common.table.IppFilterHandler;
import org.eclipse.stardust.ui.web.viewscommon.common.table.IppSearchHandler;
@@ -134,7 +133,9 @@ public class UserGroupManagementBean extends UIComponentBean
{
List<UserGroup> invalidatedUserGroups = new ArrayList<UserGroup>();
List<UserGroup> skippedUserGroups = new ArrayList<UserGroup>();
-
+ List<NotificationItem> successItemsList = new ArrayList<NotificationItem>();
+ List<NotificationItem> failureItemsList = new ArrayList<NotificationItem>();
+
List<UserGroupsTableEntry> groupsList = userGroupsTable.getCurrentList();
UserService service = workflowFacade.getServiceFactory().getUserService();
@@ -159,41 +160,29 @@ public class UserGroupManagementBean extends UIComponentBean
}
}
- NotificationMessageBean nb = NotificationMessageBean.getCurrent();
- NotificationMessage notificationMessage = new NotificationMessage();
- List<NotificationItem> itemsList = new ArrayList<NotificationItem>();
+
if (invalidatedUserGroups != null && !invalidatedUserGroups.isEmpty())
{
- notificationMessage.setMessage(this.getMessages().getString("notifySuccessMsg"));
- for (Iterator<UserGroup> iterator = invalidatedUserGroups.iterator(); iterator
- .hasNext();)
+ for (Iterator<UserGroup> iterator = invalidatedUserGroups.iterator(); iterator.hasNext();)
{
UserGroup userGroup = (UserGroup) iterator.next();
- itemsList.add(new NotificationItem(I18nUtils.getUserGroupLabel(userGroup), this.getMessages().getString(
- "notifyUserGroupInvalidate")));
+ successItemsList.add(new NotificationItem(I18nUtils.getUserGroupLabel(userGroup), this.getMessages()
+ .getString("notifyUserGroupInvalidate")));
}
- notificationMessage.setNotificationItem(itemsList);
- nb.add(notificationMessage);
}
- notificationMessage = new NotificationMessage();
- itemsList = new ArrayList<NotificationItem>();
if (skippedUserGroups != null && !skippedUserGroups.isEmpty())
{
- notificationMessage.setMessage(this.getMessages().getString(
- "notifyNonValidateMsg"));
- for (Iterator<UserGroup> iterator = skippedUserGroups.iterator(); iterator
- .hasNext();)
+ for (Iterator<UserGroup> iterator = skippedUserGroups.iterator(); iterator.hasNext();)
{
UserGroup userGroup = (UserGroup) iterator.next();
- itemsList.add(new NotificationItem(I18nUtils.getUserGroupLabel(userGroup), this.getMessages().getString(
- "notifyUserGroupNotValidateMsg")));
+ failureItemsList.add(new NotificationItem(I18nUtils.getUserGroupLabel(userGroup), this.getMessages()
+ .getString("notifyUserGroupNotValidateMsg")));
}
- notificationMessage.setNotificationItem(itemsList);
- nb.add(notificationMessage);
}
- nb.openPopup();
+ NotificationMessageBean.showNotifications(successItemsList, this.getMessages().getString("notifySuccessMsg"),
+ failureItemsList, this.getMessages().getString("notifyNonValidateMsg"));
initialize();
}
diff --git a/admin-portal/src/main/java/org/eclipse/stardust/ui/web/admin/views/UserManagementBean.java b/admin-portal/src/main/java/org/eclipse/stardust/ui/web/admin/views/UserManagementBean.java
index b0e0585..ebae915 100644
--- a/admin-portal/src/main/java/org/eclipse/stardust/ui/web/admin/views/UserManagementBean.java
+++ b/admin-portal/src/main/java/org/eclipse/stardust/ui/web/admin/views/UserManagementBean.java
@@ -73,7 +73,6 @@ import org.eclipse.stardust.ui.web.viewscommon.beans.SessionContext;
import org.eclipse.stardust.ui.web.viewscommon.common.FilterToolbarItem;
import org.eclipse.stardust.ui.web.viewscommon.common.PortalException;
import org.eclipse.stardust.ui.web.viewscommon.common.notification.NotificationItem;
-import org.eclipse.stardust.ui.web.viewscommon.common.notification.NotificationMessage;
import org.eclipse.stardust.ui.web.viewscommon.common.notification.NotificationMessageBean;
import org.eclipse.stardust.ui.web.viewscommon.common.table.IppFilterHandler;
import org.eclipse.stardust.ui.web.viewscommon.common.table.IppSearchHandler;
@@ -513,47 +512,36 @@ public class UserManagementBean extends PopupUIComponentBean
*/
private void showNotificationDialog()
{
- NotificationMessageBean nb = NotificationMessageBean.getCurrent();
- NotificationMessage notificationMessage = new NotificationMessage();
- List<NotificationItem> itemsList = new ArrayList<NotificationItem>();
+ List<NotificationItem> successItemsList = new ArrayList<NotificationItem>();
+ List<NotificationItem> failureItemsList = new ArrayList<NotificationItem>();
if (invalidatedUsers != null && !invalidatedUsers.isEmpty())
{
- notificationMessage.setMessage(this.getMessages().getString(
- "notifySuccessMsg"));
- for (Iterator<User> iterator = invalidatedUsers.iterator(); iterator
- .hasNext();)
+ for (Iterator<User> iterator = invalidatedUsers.iterator(); iterator.hasNext();)
{
User user = (User) iterator.next();
- itemsList.add(new NotificationItem(user.getAccount(), this.getMessages()
- .getString("notifyUserInvalidate")));
+ successItemsList.add(new NotificationItem(user.getAccount(), this.getMessages().getString(
+ "notifyUserInvalidate")));
}
- notificationMessage.setNotificationItem(itemsList);
- nb.add(notificationMessage);
}
- notificationMessage = new NotificationMessage();
- itemsList = new ArrayList<NotificationItem>();
if (skippedUsers != null && !skippedUsers.isEmpty())
{
- notificationMessage.setMessage(this.getMessages().getString(
- "notifyNonValidateMsg"));
for (Iterator<User> iterator = skippedUsers.iterator(); iterator.hasNext();)
{
User user = (User) iterator.next();
if (user.getAccount().equals("motu"))
- itemsList.add(new NotificationItem(user.getAccount(), this.getMessages().getString(
+ failureItemsList.add(new NotificationItem(user.getAccount(), this.getMessages().getString(
"notifyMotuNotValidateMsg")));
else
- itemsList.add(new NotificationItem(user.getAccount(), this.getMessages().getString(
+ failureItemsList.add(new NotificationItem(user.getAccount(), this.getMessages().getString(
"notifyUserCannotBeInvalidatedMsg")));
}
- notificationMessage.setNotificationItem(itemsList);
- nb.add(notificationMessage);
}
- nb.openPopup();
+ NotificationMessageBean.showNotifications(successItemsList, this.getMessages().getString("notifySuccessMsg"),
+ failureItemsList, this.getMessages().getString("notifyNonValidateMsg"));
initialize();
-
+
}
/**
diff --git a/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/common/notification/NotificationMessageBean.java b/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/common/notification/NotificationMessageBean.java
index dfb4118..a10a756 100644
--- a/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/common/notification/NotificationMessageBean.java
+++ b/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/common/notification/NotificationMessageBean.java
@@ -13,12 +13,12 @@ package org.eclipse.stardust.ui.web.viewscommon.common.notification;
import java.util.ArrayList;
import java.util.List;
+import org.eclipse.stardust.common.CollectionUtils;
import org.eclipse.stardust.ui.web.common.PopupUIComponentBean;
import org.eclipse.stardust.ui.web.common.util.FacesUtils;
import org.eclipse.stardust.ui.web.viewscommon.dialogs.ICallbackHandler;
import org.eclipse.stardust.ui.web.viewscommon.dialogs.ICallbackHandler.EventType;
-
/**
* @author Ankita.Patel
* @version $Revision: $
@@ -34,8 +34,6 @@ public class NotificationMessageBean extends PopupUIComponentBean
private ButtonType buttonType = ButtonType.CLOSE;
private ICallbackHandler callbackHandler ;
-
-
/**
*
*/
@@ -44,6 +42,80 @@ public class NotificationMessageBean extends PopupUIComponentBean
notifications = new ArrayList<NotificationMessage>();
}
+
+ /**
+ * @param successNotifications
+ * @param successTitle
+ * @param failureNotifications
+ * @param failureTitle
+ * @param itemTitle
+ * @param itemStatusTitle
+ * @return
+ */
+ public static boolean showNotifications(List<NotificationItem> successNotifications, String successTitle,
+ List<NotificationItem> failureNotifications, String failureTitle, String itemTitle, String itemStatusTitle, ICallbackHandler callbackHandler)
+ {
+ if ((CollectionUtils.isNotEmpty(successNotifications)) || (CollectionUtils.isNotEmpty(failureNotifications)))
+ {
+ NotificationMessageBean notificationMB = NotificationMessageBean.getCurrent();
+ notificationMB.setCallbackHandler(callbackHandler);
+ // Aborted processes
+ NotificationMessage notificationMessage = new NotificationMessage();
+ if (CollectionUtils.isNotEmpty(successNotifications))
+ {
+ notificationMessage.setMessage(successTitle);
+ notificationMessage.setKeyTitle(itemTitle);
+ notificationMessage.setValueTitle(itemStatusTitle);
+ notificationMessage.setNotificationItem(successNotifications);
+ notificationMB.add(notificationMessage);
+ }
+
+ // Skipped Processes
+ notificationMessage = new NotificationMessage();
+ if (CollectionUtils.isNotEmpty(failureNotifications))
+ {
+ notificationMessage.setMessage(failureTitle);
+ notificationMessage.setKeyTitle(itemTitle);
+ notificationMessage.setValueTitle(itemStatusTitle);
+ notificationMessage.setNotificationItem(failureNotifications);
+ notificationMB.add(notificationMessage);
+ }
+ if (!notificationMB.getNotifications().isEmpty())
+ {
+ notificationMB.openPopup();
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * @param successNotifications
+ * @param successTitle
+ * @param failureNotifications
+ * @param failureTitle
+ */
+ public static boolean showNotifications(List<NotificationItem> successNotifications, String successTitle,
+ List<NotificationItem> failureNotifications, String failureTitle)
+ {
+ return showNotifications(successNotifications, successTitle, failureNotifications, failureTitle, null, null, null);
+ }
+
+ /**
+ *
+ * @param successNotifications
+ * @param successTitle
+ * @param failureNotifications
+ * @param failureTitle
+ * @param callbackHandler
+ * @return
+ */
+ public static boolean showNotifications(List<NotificationItem> successNotifications, String successTitle,
+ List<NotificationItem> failureNotifications, String failureTitle, ICallbackHandler callbackHandler)
+ {
+ return showNotifications(successNotifications, successTitle, failureNotifications, failureTitle, null, null,callbackHandler);
+ }
+
/**
* Closes popup and clears list
*/
@@ -119,7 +191,4 @@ public class NotificationMessageBean extends PopupUIComponentBean
{
this.callbackHandler = callbackHandler;
}
-
-
-
}
diff --git a/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/dialogs/AbortActivityBean.java b/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/dialogs/AbortActivityBean.java
index 1cbf25a..7ec98f5 100644
--- a/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/dialogs/AbortActivityBean.java
+++ b/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/dialogs/AbortActivityBean.java
@@ -11,10 +11,7 @@
package org.eclipse.stardust.ui.web.viewscommon.dialogs;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
import javax.faces.model.SelectItem;
@@ -29,7 +26,6 @@ import org.eclipse.stardust.ui.web.common.log.LogManager;
import org.eclipse.stardust.ui.web.common.log.Logger;
import org.eclipse.stardust.ui.web.common.util.FacesUtils;
import org.eclipse.stardust.ui.web.viewscommon.common.notification.NotificationItem;
-import org.eclipse.stardust.ui.web.viewscommon.common.notification.NotificationMessage;
import org.eclipse.stardust.ui.web.viewscommon.common.notification.NotificationMessageBean;
import org.eclipse.stardust.ui.web.viewscommon.messages.MessagesViewsCommonBean;
import org.eclipse.stardust.ui.web.viewscommon.utils.ActivityInstanceUtils;
@@ -167,10 +163,12 @@ public class AbortActivityBean extends PopupUIComponentBean
*/
private boolean abortActivities(AbortScope abortScope)
{
+
if (CollectionUtils.isNotEmpty(activitiesToBeAborted))
{
- List<ActivityInstance> abortedActivities = new ArrayList<ActivityInstance>();
- Map<ActivityInstance, String> skippedActivities = new HashMap<ActivityInstance, String>();
+ List<NotificationItem> successNotifications = new ArrayList<NotificationItem>();
+ List<NotificationItem> failureNotifications = new ArrayList<NotificationItem>();
+
WorkflowService workflowService = ServiceFactoryUtils.getWorkflowService();
for (ActivityInstance activityInstance : activitiesToBeAborted)
{
@@ -183,102 +181,60 @@ public class AbortActivityBean extends PopupUIComponentBean
try
{
workflowService.abortActivityInstance(activityInstance.getOID(), abortScope);
- ClientContextBean.getCurrentInstance().getClientContext().sendActivityEvent(ActivityEvent.aborted(activityInstance));
- abortedActivities.add(activityInstance);
+ ClientContextBean.getCurrentInstance().getClientContext()
+ .sendActivityEvent(ActivityEvent.aborted(activityInstance));
+ successNotifications.add(new NotificationItem(ActivityInstanceUtils
+ .getActivityLabel(activityInstance), ActivityInstanceUtils
+ .getActivityStateLabel(activityInstance)));
}
catch (Exception e)
{
// It is very to rare that any exception would occur here
trace.error(e);
- skippedActivities.put(activityInstance, MessagesViewsCommonBean.getInstance().getParamString(
- "views.common.activity.abortActivity.failureMsg2", ExceptionHandler.getExceptionMessage(e)));
+
+ failureNotifications
+ .add(new NotificationItem(ActivityInstanceUtils.getActivityLabel(activityInstance),
+ MessagesViewsCommonBean.getInstance().getParamString(
+ "views.common.activity.abortActivity.failureMsg2",
+ ExceptionHandler.getExceptionMessage(e))));
}
}
else
{
- if(ActivityInstanceUtils.isDefaultCaseActivity(activityInstance))
+ if (ActivityInstanceUtils.isDefaultCaseActivity(activityInstance))
{
- skippedActivities.put(activityInstance, MessagesViewsCommonBean.getInstance().getParamString(
- "views.switchProcessDialog.caseAbort.message"));
+ failureNotifications.add(new NotificationItem(ActivityInstanceUtils
+ .getActivityLabel(activityInstance), MessagesViewsCommonBean.getInstance().getString(
+ "views.switchProcessDialog.caseAbort.message")));
}
else if (ActivityInstanceState.Aborted.equals(activityInstance.getState())
|| ActivityInstanceState.Completed.equals(activityInstance.getState()))
{
- skippedActivities.put(activityInstance, MessagesViewsCommonBean.getInstance().getParamString(
+ failureNotifications.add(new NotificationItem(ActivityInstanceUtils
+ .getActivityLabel(activityInstance), MessagesViewsCommonBean.getInstance().getParamString(
"views.common.activity.abortActivity.failureMsg3",
- ActivityInstanceUtils.getActivityStateLabel(activityInstance)));
+ ActivityInstanceUtils.getActivityStateLabel(activityInstance))));
}
else
{
- skippedActivities.put(activityInstance, MessagesViewsCommonBean.getInstance().getString(
- "views.common.activity.abortActivity.failureMsg1"));
+ failureNotifications.add(new NotificationItem(ActivityInstanceUtils
+ .getActivityLabel(activityInstance), MessagesViewsCommonBean.getInstance().getString(
+ "views.common.activity.abortActivity.failureMsg1")));
}
}
}
}
- return showActivityAbortNotification(abortedActivities, skippedActivities, callbackHandler);
- }
-
- return false;
- }
-
- /**
- * Shows abort notification dialog
- *
- * @param abortedActivities
- * @param skippedActivities
- */
- private boolean showActivityAbortNotification(List<ActivityInstance> abortedActivities,
- Map<ActivityInstance, String> skippedActivities, ICallbackHandler callbackHandler)
- {
- MessagesViewsCommonBean msgBean = MessagesViewsCommonBean.getInstance();
- if ((CollectionUtils.isNotEmpty(abortedActivities)) || (CollectionUtils.isNotEmpty(skippedActivities)))
- {
- NotificationMessageBean notificationMB = NotificationMessageBean.getCurrent();
- notificationMB.setCallbackHandler(callbackHandler);
- WorkflowService ws = ServiceFactoryUtils.getWorkflowService();
-
- // aborted activities
- NotificationMessage notificationMessage = new NotificationMessage();
- List<NotificationItem> itemsList = new ArrayList<NotificationItem>();
- if (CollectionUtils.isNotEmpty(abortedActivities))
- {
- notificationMessage.setMessage(msgBean.getString("views.common.activity.abortActivity.success"));
-
- for (ActivityInstance ai : abortedActivities)
- {
- ai = ws.getActivityInstance(ai.getOID());
- itemsList.add(new NotificationItem(ActivityInstanceUtils.getActivityLabel(ai), ActivityInstanceUtils
- .getActivityStateLabel(ai)));
- }
- notificationMessage.setNotificationItem(itemsList);
- notificationMB.add(notificationMessage);
- }
-
- // skipped activities
- notificationMessage = new NotificationMessage();
- itemsList = new ArrayList<NotificationItem>();
- if (CollectionUtils.isNotEmpty(skippedActivities))
- {
- notificationMessage.setMessage(msgBean.getString("views.common.activity.abortActivity.failure"));
- for (Entry<ActivityInstance, String> skippedActivity : skippedActivities.entrySet())
- {
- ActivityInstance ai = ws.getActivityInstance(skippedActivity.getKey().getOID());
- itemsList.add(new NotificationItem(ActivityInstanceUtils.getActivityLabel(ai), skippedActivity
- .getValue()));
- }
- notificationMessage.setNotificationItem(itemsList);
- notificationMB.add(notificationMessage);
- }
-
- // Before opening new Popup close current Popup so that ViewEvents will be fired in order
+ // Before opening new Popup close current Popup so that ViewEvents will be fired
+ // in order
closePopup();
- notificationMB.openPopup();
-
+ NotificationMessageBean.showNotifications(successNotifications, MessagesViewsCommonBean.getInstance()
+ .getString("views.common.activity.abortActivity.success"), failureNotifications, MessagesViewsCommonBean
+ .getInstance().getString("views.common.activity.abortActivity.failure"), callbackHandler);
+
return true;
}
-
+
return false;
}
diff --git a/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/utils/AbortProcessBean.java b/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/utils/AbortProcessBean.java
index 34b543b..f6188bc 100644
--- a/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/utils/AbortProcessBean.java
+++ b/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/utils/AbortProcessBean.java
@@ -11,10 +11,7 @@
package org.eclipse.stardust.ui.web.viewscommon.utils;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
import javax.faces.model.SelectItem;
@@ -28,14 +25,11 @@ import org.eclipse.stardust.ui.web.common.log.LogManager;
import org.eclipse.stardust.ui.web.common.log.Logger;
import org.eclipse.stardust.ui.web.common.util.FacesUtils;
import org.eclipse.stardust.ui.web.viewscommon.common.notification.NotificationItem;
-import org.eclipse.stardust.ui.web.viewscommon.common.notification.NotificationMessage;
import org.eclipse.stardust.ui.web.viewscommon.common.notification.NotificationMessageBean;
import org.eclipse.stardust.ui.web.viewscommon.dialogs.ICallbackHandler;
import org.eclipse.stardust.ui.web.viewscommon.dialogs.ICallbackHandler.EventType;
import org.eclipse.stardust.ui.web.viewscommon.messages.MessagesViewsCommonBean;
-
-
/**
* @author Yogesh.Manware
*
@@ -153,58 +147,6 @@ public class AbortProcessBean extends PopupUIComponentBean
openPopup();
}
-
- /**
- * Shows abort notification dialog
- *
- * @param abortedProcesses
- * @param skippedProcesses
- */
- private static void showProcessAbortNotification(List<ProcessInstance> abortedProcesses,
- Map<ProcessInstance, String> skippedProcesses)
- {
- MessagesViewsCommonBean msgBean = MessagesViewsCommonBean.getInstance();
- if ((CollectionUtils.isNotEmpty(abortedProcesses)) || (CollectionUtils.isNotEmpty(skippedProcesses)))
- {
- NotificationMessageBean notificationMB = NotificationMessageBean.getCurrent();
- WorkflowService ws = ServiceFactoryUtils.getWorkflowService();
-
- // Aborted processes
- NotificationMessage notificationMessage = new NotificationMessage();
- List<NotificationItem> itemsList = new ArrayList<NotificationItem>();
- if (CollectionUtils.isNotEmpty(abortedProcesses))
- {
- notificationMessage.setMessage(msgBean.getString("views.common.process.abortProcess.success"));
-
- for (ProcessInstance pi : abortedProcesses)
- {
- pi = ws.getProcessInstance(pi.getOID());
- itemsList.add(new NotificationItem(ProcessInstanceUtils.getProcessLabel(pi), ProcessInstanceUtils
- .getProcessStateLabel(pi)));
- }
- notificationMessage.setNotificationItem(itemsList);
- notificationMB.add(notificationMessage);
- }
-
- // Skipped Processes
- notificationMessage = new NotificationMessage();
- itemsList = new ArrayList<NotificationItem>();
-
- if (CollectionUtils.isNotEmpty(skippedProcesses))
- {
- notificationMessage.setMessage(msgBean.getString("views.common.process.abortProcess.failure"));
- for (Entry<ProcessInstance, String> skippedProcess : skippedProcesses.entrySet())
- {
- ProcessInstance pi = ws.getProcessInstance(skippedProcess.getKey().getOID());
- itemsList.add(new NotificationItem(ProcessInstanceUtils.getProcessLabel(pi), skippedProcess.getValue()));
- }
- notificationMessage.setNotificationItem(itemsList);
- notificationMB.add(notificationMessage);
- }
- notificationMB.openPopup();
- }
- }
-
/**
* Abort Process based on user preference
*
@@ -212,10 +154,13 @@ public class AbortProcessBean extends PopupUIComponentBean
*/
private void abortProcess(AbortScope abortScope)
{
+ MessagesViewsCommonBean msgBean = MessagesViewsCommonBean.getInstance();
if (CollectionUtils.isNotEmpty(processesToBeAborted))
{
- List<ProcessInstance> abortedProcesses = new ArrayList<ProcessInstance>();
- Map<ProcessInstance, String> skippedProcesses = new HashMap<ProcessInstance, String>();
+ List<NotificationItem> successNotifications = new ArrayList<NotificationItem>();
+ List<NotificationItem> failureNotifications = new ArrayList<NotificationItem>();
+ WorkflowService ws = ServiceFactoryUtils.getWorkflowService();
+
for (ProcessInstance processInstance : processesToBeAborted)
{
if (processInstance != null)
@@ -225,26 +170,29 @@ public class AbortProcessBean extends PopupUIComponentBean
{
try
{
-
if(processInstance.isCaseProcessInstance())
{
- skippedProcesses.put(processInstance, MessagesViewsCommonBean.getInstance().getParamString(
+ failureNotifications.add(new NotificationItem(ProcessInstanceUtils
+ .getProcessLabel(processInstance), msgBean.getParamString(
"views.switchProcessDialog.caseAbort.message",
- ProcessInstanceUtils.getProcessStateLabel(processInstance)));
+ ProcessInstanceUtils.getProcessStateLabel(processInstance))));
}
else
{
ProcessInstanceUtils.abortProcess(processInstance, abortScope);
- abortedProcesses.add(processInstance);
+
+ successNotifications.add(new NotificationItem(ProcessInstanceUtils
+ .getProcessLabel(processInstance), ProcessInstanceUtils.getProcessStateLabel(ws
+ .getProcessInstance(processInstance.getOID()))));
}
-
}
catch (Exception e)
{
// It is very to rare, any exception would occur here
trace.error(e);
- skippedProcesses.put(processInstance, MessagesViewsCommonBean.getInstance().getParamString(
- "views.common.process.abortProcess.failureMsg2", ExceptionHandler.getExceptionMessage(e)));
+ failureNotifications.add(new NotificationItem(ProcessInstanceUtils
+ .getProcessLabel(processInstance), msgBean.getParamString(
+ "views.common.process.abortProcess.failureMsg2", ExceptionHandler.getExceptionMessage(e))));
}
}
else
@@ -252,19 +200,25 @@ public class AbortProcessBean extends PopupUIComponentBean
if (ProcessInstanceState.Aborted.equals(processInstance.getState())
|| ProcessInstanceState.Completed.equals(processInstance.getState()))
{
- skippedProcesses.put(processInstance, MessagesViewsCommonBean.getInstance().getParamString(
+ failureNotifications.add(new NotificationItem(ProcessInstanceUtils
+ .getProcessLabel(processInstance), msgBean.getParamString(
"views.common.process.abortProcess.failureMsg3",
- ProcessInstanceUtils.getProcessStateLabel(processInstance)));
+ ProcessInstanceUtils.getProcessStateLabel(processInstance))));
}
else
{
- skippedProcesses.put(processInstance, MessagesViewsCommonBean.getInstance().getString(
- "views.common.process.abortProcess.failureMsg1"));
+ failureNotifications.add(new NotificationItem(ProcessInstanceUtils
+ .getProcessLabel(processInstance), msgBean
+ .getString("views.common.process.abortProcess.failureMsg1")));
}
}
}
}
- showProcessAbortNotification(abortedProcesses, skippedProcesses);
+
+ NotificationMessageBean.showNotifications(successNotifications,
+ msgBean.getString("views.common.process.abortProcess.success"), failureNotifications,
+ msgBean.getString("views.common.process.abortProcess.failure"));
+
if (null != callbackHandler)
{
callbackHandler.handleEvent(EventType.APPLY);
diff --git a/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/utils/ProcessInstanceUtils.java b/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/utils/ProcessInstanceUtils.java
index dc52bc5..782f013 100644
--- a/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/utils/ProcessInstanceUtils.java
+++ b/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/utils/ProcessInstanceUtils.java
@@ -58,7 +58,6 @@ import org.eclipse.stardust.ui.web.viewscommon.common.ModelHelper;
import org.eclipse.stardust.ui.web.viewscommon.common.configuration.UserPreferencesEntries;
import org.eclipse.stardust.ui.web.viewscommon.common.converter.PriorityConverter;
import org.eclipse.stardust.ui.web.viewscommon.common.notification.NotificationItem;
-import org.eclipse.stardust.ui.web.viewscommon.common.notification.NotificationMessage;
import org.eclipse.stardust.ui.web.viewscommon.common.notification.NotificationMessageBean;
import org.eclipse.stardust.ui.web.viewscommon.dialogs.ICallbackHandler;
import org.eclipse.stardust.ui.web.viewscommon.dialogs.JoinProcessDialogBean;
@@ -435,71 +434,14 @@ public class ProcessInstanceUtils
}
/**
- * Shows notification dialog for group changes on processes
- *
- * @param successTitle
- * @param failureTitle
- * @param successResults
- * @param failureResults
- */
- public static void showNotifications(String successTitle, String failureTitle, Map<String, String> successResults,
- Map<String, String> failureResults)
- {
- NotificationMessageBean notificationMB = NotificationMessageBean.getCurrent();
- boolean showPopup = false;
- // success messages
- if (CollectionUtils.isNotEmpty(successResults))
- {
- notificationMB.add(getNotificationMessage(successTitle, successResults));
- showPopup = true;
- }
- // failure messages
- if (CollectionUtils.isNotEmpty(failureResults))
- {
- notificationMB.add(getNotificationMessage(failureTitle, failureResults));
- showPopup = true;
- }
- if (showPopup)
- {
- notificationMB.openPopup();
- }
- }
-
- /**
- * @param title
- * @param successResults
- * @return
- */
- private static NotificationMessage getNotificationMessage(String title, Map<String, String> successResults)
- {
- NotificationMessage notificationMessage = new NotificationMessage();
- if (CollectionUtils.isNotEmpty(successResults))
- {
- List<NotificationItem> itemsList = new ArrayList<NotificationItem>();
- notificationMessage.setMessage(title);
-
- for (Entry<String, String> processInstanceEntry : successResults.entrySet())
- {
- itemsList.add(new NotificationItem(processInstanceEntry.getKey(), processInstanceEntry.getValue()));
- }
- notificationMessage.setNotificationItem(itemsList);
- notificationMessage.setKeyTitle(MessagesViewsCommonBean.getInstance().getString(
- "common.notification.selectedItems"));
- notificationMessage.setValueTitle(MessagesViewsCommonBean.getInstance().getString(
- "common.notification.actionStatus"));
- }
- return notificationMessage;
- }
-
- /**
* update process priorities
*
* @param changedProcess
*/
public static void updatePriorities(Map<Object, Integer> changedProcess)
{
- Map<String, String> failureMessages = new HashMap<String, String>();
- Map<String, String> successMessages = new HashMap<String, String>();
+ List<NotificationItem> successItemsList = new ArrayList<NotificationItem>();
+ List<NotificationItem> failureItemsList = new ArrayList<NotificationItem>();
for (Entry<Object, Integer> entry : changedProcess.entrySet())
{
@@ -529,20 +471,18 @@ public class ProcessInstanceUtils
try
{
ProcessInstanceUtils.setProcessPriority(processOID, priority);
- successMessages.put(
- itemLabel,
- MessagesViewsCommonBean.getInstance().getParamString(
- "views.processTable.savePriorities.priorityChanged",
- PriorityConverter.getPriorityLabel(priority)));
+ successItemsList.add(new NotificationItem(itemLabel, MessagesViewsCommonBean.getInstance().getParamString(
+ "views.processTable.savePriorities.priorityChanged",
+ PriorityConverter.getPriorityLabel(priority))));
}
catch (AccessForbiddenException e)
{
- failureMessages.put(itemLabel, MessagesViewsCommonBean.getInstance().getString("common.authorization.msg"));
+ failureItemsList.add(new NotificationItem(itemLabel, MessagesViewsCommonBean.getInstance().getString("common.authorization.msg")));
trace.error("Authorization exception occurred while changing process priority: ", e);
}
catch (Exception e)
{
- failureMessages.put(itemLabel, ExceptionHandler.getExceptionMessage(e));
+ failureItemsList.add(new NotificationItem(itemLabel, ExceptionHandler.getExceptionMessage(e)));
trace.error("Exception occurred while changing process priority: ", e);
}
}
@@ -552,8 +492,10 @@ public class ProcessInstanceUtils
+ MessagesViewsCommonBean.getInstance().getString("views.processTable.savePriorities.successMsg");
String failureTitle = title
+ MessagesViewsCommonBean.getInstance().getString("views.processTable.savePriorities.failureMsg");
-
- ProcessInstanceUtils.showNotifications(successTitle, failureTitle, successMessages, failureMessages);
+ String itemTitle = MessagesViewsCommonBean.getInstance().getString("common.notification.selectedItems");
+ String itemStatusTitle = MessagesViewsCommonBean.getInstance().getString("common.notification.actionStatus");
+ NotificationMessageBean.showNotifications(successItemsList, successTitle, failureItemsList, failureTitle,
+ itemTitle, itemStatusTitle, null);
}
/**