summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVikas Mishra2012-03-30 04:00:56 (EDT)
committerManik Kishore2012-06-19 07:24:42 (EDT)
commitacafbcd9ed810ef378ad79a9418430ec66a0b9c1 (patch)
tree56b4590c7c0bcba1d67e36a381a90aaf7a0d1f66
parent1b143451032e3d64f1c723978428e34d34441852 (diff)
downloadorg.eclipse.stardust.ui.web-acafbcd9ed810ef378ad79a9418430ec66a0b9c1.zip
org.eclipse.stardust.ui.web-acafbcd9ed810ef378ad79a9418430ec66a0b9c1.tar.gz
org.eclipse.stardust.ui.web-acafbcd9ed810ef378ad79a9418430ec66a0b9c1.tar.bz2
Jira-ID: CRNT-24122
1)added new method to getKeyDescriptor for intersection of Process descriptorChangeListener 2)added skip notification flag for Attach and Case 3)added callback handler to refresh view after Attach and Case. git-svn-id: http://emeafrazerg/svn/ipp/product/trunk/stardust/ui.web@55112 8100b5e0-4d52-466c-ae9c-bdeccbdeaf6b
-rw-r--r--views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/utils/CommonDescriptorUtils.java108
-rw-r--r--views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/utils/ProcessInstanceUtils.java13
-rw-r--r--views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/views/casemanagement/AttachToCaseDialogBean.java22
-rw-r--r--views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/views/casemanagement/CaseDetailsBean.java16
-rw-r--r--views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/views/search/RelatedProcessSearchBean.java25
-rw-r--r--views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/views/search/RelatedProcessSearchHelper.java6
6 files changed, 170 insertions, 20 deletions
diff --git a/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/utils/CommonDescriptorUtils.java b/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/utils/CommonDescriptorUtils.java
index d0945a6..bbef4c1 100644
--- a/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/utils/CommonDescriptorUtils.java
+++ b/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/utils/CommonDescriptorUtils.java
@@ -269,8 +269,8 @@ public class CommonDescriptorUtils
}
}
return datapathMap;
- }
-
+ }
+
/**
* Returns an array with all COMMON descriptors which exists in the given processes.
* Furthermore you have the option to get only descriptors that are filterable.
@@ -431,9 +431,9 @@ public class CommonDescriptorUtils
* @param sourceProcessInstances
* @return
*/
- public static Map<String, DataPath> getCommonDescriptorsMap(List<ProcessInstance> sourceProcessInstances, boolean onlyKeyDescriptor)
+ public static Map<String, DataPath> getKeyDescriptorsIntersectionMap(List<ProcessInstance> sourceProcessInstances)
{
- Map<String, DataPath> keyDescriptors = CollectionUtils.newHashMap();
+ Map<String, DataPath> keyDescriptorsMap = CollectionUtils.newHashMap();
List<ProcessDefinition> commonProcessDefinitions = CollectionUtils.newArrayList();
for (ProcessInstance processInstance : sourceProcessInstances)
@@ -441,19 +441,99 @@ public class CommonDescriptorUtils
ProcessDefinition pd = ProcessDefinitionUtils.getProcessDefinition(processInstance.getModelOID(),
processInstance.getProcessID());
commonProcessDefinitions.add(pd);
- }
- DataPath[] commonDatas = getCommonDescriptors(commonProcessDefinitions, true);
+ }
+ DataPath[] commonDatas = getKeyDescriptorsIntersection(commonProcessDefinitions);
for (DataPath dataPath : commonDatas)
{
- if (dataPath.isDescriptor() && ((onlyKeyDescriptor && dataPath.isKeyDescriptor()) || !onlyKeyDescriptor ) )
+ keyDescriptorsMap.put(dataPath.getId(), dataPath);
+ }
+ return keyDescriptorsMap;
+ }
+
+ /**
+ *
+ * @param processes
+ * @return
+ */
+
+ public static DataPath[] getKeyDescriptorsIntersection(List<ProcessDefinition> processes)
+ {
+ boolean firstProcess = true;
+
+ // We have to use this type of Map because of the predictable order of the keys
+ Map<String, DataPath> intersectionMap = new LinkedHashMap<String, DataPath>();
+
+ for (ProcessDefinition pd : processes)
+ {
+ // for first process put all key descriptor in Map
+ if (firstProcess)
+ {
+ firstProcess = false;
+
+ for (Object item : pd.getAllDataPaths())
+ {
+ DataPath path = (DataPath) item;
+ if (null != path && path.isKeyDescriptor() && Direction.IN.equals(path.getDirection()))
+ {
+ intersectionMap.put(path.getId(), path);
+ }
+ }
+
+ }
+ // from second process on words check intersectionMap descriptors present in
+ // process
+ // if not present then remove from map
+ else
{
- keyDescriptors.put(dataPath.getId(), dataPath);
+ for (Iterator<DataPath> itr = intersectionMap.values().iterator(); itr.hasNext();)
+ {
+ boolean contains = false;
+ DataPath first = itr.next();
+
+ for (Object item : pd.getAllDataPaths())
+ {
+ DataPath second = (DataPath) item;
+ if (null != second && second.isKeyDescriptor() && Direction.IN.equals(second.getDirection())
+ && equalsDescriptor(first, second))
+ {
+ contains = true;
+ break;
+ }
+ }
+ // if descriptor is not present then remove from map
+ if (!contains)
+ {
+ itr.remove();
+ }
+ }
}
}
- return keyDescriptors;
+
+ DataPath[] descriptors = (DataPath[]) intersectionMap.values().toArray(new DataPath[0]);
+ return descriptors;
}
+ /**
+ *
+ * @param first
+ * @param secound
+ * @return
+ */
+ private static boolean equalsDescriptor(DataPath first, DataPath secound)
+ {
+ if (null != first && null != secound && first.getId().equals(secound.getId()))
+ {
+ Data data1 = DescriptorFilterUtils.getData(secound);
+ Data data2 = DescriptorFilterUtils.getData(first);
+ if (data1.equals(data2))
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
/**
*
@@ -498,7 +578,9 @@ public class CommonDescriptorUtils
childPi.getProcessID());
commonProcessDefinitions.add(pd);
}
- DataPath[] commonDatas = getCommonDescriptors(commonProcessDefinitions, true);
+ // DataPath[] commonDatas = getCommonDescriptors(commonProcessDefinitions, true);
+ DataPath[] commonDatas = getKeyDescriptorsIntersection(commonProcessDefinitions);
+
for (DataPath dataPath : commonDatas)
{
if (dataPath.isKeyDescriptor())
@@ -523,10 +605,14 @@ public class CommonDescriptorUtils
descriptors.remove(dataPath.getId());
}
}
+ else
+ {
+ descriptors.remove(dataPath.getId());
+ }
}
}
- }
+ }
Set<Entry<String, Pair<Class, Object>>> entrySet = descriptors.entrySet();
for (Entry<String, Pair<Class, Object>> entry : entrySet)
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 c17ccbd..06e655b 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
@@ -59,6 +59,7 @@ import org.eclipse.stardust.ui.web.viewscommon.common.converter.PriorityConverte
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;
import org.eclipse.stardust.ui.web.viewscommon.dialogs.SpawnProcessDialogBean;
import org.eclipse.stardust.ui.web.viewscommon.dialogs.SwitchProcessDialogBean;
@@ -999,9 +1000,19 @@ public class ProcessInstanceUtils
/**
*
+ * @param processInstanceList
*/
public static void openAttachToCase(List<ProcessInstance> processInstanceList)
{
+ openAttachToCase(processInstanceList, false, null);
+ }
+
+ /**
+ *
+ */
+ public static void openAttachToCase(List<ProcessInstance> processInstanceList, boolean skipNotification,
+ ICallbackHandler callbackHandler)
+ {
MessagesViewsCommonBean commonMessage = MessagesViewsCommonBean.getInstance();
List<ProcessInstance> selectedProcesses = processInstanceList;
if (CollectionUtils.isEmpty(selectedProcesses))
@@ -1044,6 +1055,8 @@ public class ProcessInstanceUtils
{
AttachToCaseDialogBean attachToCaseDialog = AttachToCaseDialogBean.getInstance();
attachToCaseDialog.setSourceProcessInstances(selectedProcesses);
+ attachToCaseDialog.setSkipNotification(skipNotification);
+ attachToCaseDialog.setCallbackHandler(callbackHandler);
attachToCaseDialog.openPopup();
}
}
diff --git a/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/views/casemanagement/AttachToCaseDialogBean.java b/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/views/casemanagement/AttachToCaseDialogBean.java
index 9f02290..be3139b 100644
--- a/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/views/casemanagement/AttachToCaseDialogBean.java
+++ b/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/views/casemanagement/AttachToCaseDialogBean.java
@@ -24,6 +24,7 @@ import org.eclipse.stardust.ui.web.common.dialogs.ConfirmationDialogHandler;
import org.eclipse.stardust.ui.web.common.message.MessageDialog;
import org.eclipse.stardust.ui.web.common.util.FacesUtils;
import org.eclipse.stardust.ui.web.viewscommon.core.ResourcePaths;
+import org.eclipse.stardust.ui.web.viewscommon.dialogs.ICallbackHandler;
import org.eclipse.stardust.ui.web.viewscommon.messages.MessagesViewsCommonBean;
import org.eclipse.stardust.ui.web.viewscommon.utils.AuthorizationUtils;
import org.eclipse.stardust.ui.web.viewscommon.utils.CommonDescriptorUtils;
@@ -298,8 +299,19 @@ public class AttachToCaseDialogBean extends RelatedProcessSearchBean implements
{
ServiceFactoryUtils.getWorkflowService().joinCase(caseOID.longValue(), members);
CommonDescriptorUtils.reCalculateCaseDescriptors(caseInstance);
- setCurrentPage(Page.NOTIFICATION);
- openConfirmationDialog();
+ if (isSkipNotification())
+ {
+ closeCasePopup();
+ if (null != getCallbackHandler())
+ {
+ getCallbackHandler().handleEvent(ICallbackHandler.EventType.APPLY);
+ }
+ }
+ else
+ {
+ setCurrentPage(Page.NOTIFICATION);
+ openConfirmationDialog();
+ }
}
else
{
@@ -333,6 +345,12 @@ public class AttachToCaseDialogBean extends RelatedProcessSearchBean implements
public boolean accept()
{
attachCaseConfirmationDialog = null;
+
+ if (null != getCallbackHandler())
+ {
+ getCallbackHandler().handleEvent(ICallbackHandler.EventType.APPLY);
+ }
+
openCase();
return true;
}
diff --git a/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/views/casemanagement/CaseDetailsBean.java b/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/views/casemanagement/CaseDetailsBean.java
index f0ad727..d0c2e4b 100644
--- a/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/views/casemanagement/CaseDetailsBean.java
+++ b/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/views/casemanagement/CaseDetailsBean.java
@@ -328,7 +328,19 @@ public class CaseDetailsBean extends PopupUIComponentBean
{
List<ProcessInstance> selectedProcesses = CollectionUtils.newArrayList();
selectedProcesses.add(processInstance);
- ProcessInstanceUtils.openAttachToCase(selectedProcesses);
+
+ ICallbackHandler callbackHandler = new ICallbackHandler()
+ {
+ public void handleEvent(EventType eventType)
+ {
+ if (EventType.APPLY.equals(eventType))
+ {
+ initialize();
+ }
+ }
+ };
+ ProcessInstanceUtils.openAttachToCase(selectedProcesses, true, callbackHandler);
+
}
/**
@@ -531,7 +543,7 @@ public class CaseDetailsBean extends PopupUIComponentBean
AbortProcessBean abortProcessHelper = AbortProcessBean.getInstance();
abortProcessHelper.setCallbackHandler(new ICallbackHandler()
{
- public void handleEvent(EventType eventType)
+ public void handleEvent(EventType eventType)//Add condition check initialize() class
{
initialize();
}
diff --git a/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/views/search/RelatedProcessSearchBean.java b/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/views/search/RelatedProcessSearchBean.java
index f49dca1..e358183 100644
--- a/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/views/search/RelatedProcessSearchBean.java
+++ b/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/views/search/RelatedProcessSearchBean.java
@@ -16,6 +16,7 @@ import org.eclipse.stardust.common.CollectionUtils;
import org.eclipse.stardust.engine.api.runtime.ProcessInstance;
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.utils.ExceptionHandler;
import org.eclipse.stardust.ui.web.viewscommon.utils.ProcessInstanceUtils;
import org.eclipse.stardust.ui.web.viewscommon.views.casemanagement.CreateCaseDialogBean;
@@ -38,6 +39,8 @@ public class RelatedProcessSearchBean extends PopupUIComponentBean
private final RelatedProcessSearchHelper relatedProcessSearchHelper = new RelatedProcessSearchHelper();
private List<ProcessInstance> sourceProcessInstances;
private ProcessInstance targetProcessInstance;
+ private boolean skipNotification;
+ private ICallbackHandler callbackHandler;
@Override
public void initialize()
@@ -249,6 +252,26 @@ public class RelatedProcessSearchBean extends PopupUIComponentBean
boolean matchAny = relatedProcessSearchHelper.isMatchAny();
relatedProcessSearchHelper.setMatchAny(!matchAny);
relatedProcessSearchHelper.update();
- }
+ }
+
+ public boolean isSkipNotification()
+ {
+ return skipNotification;
+ }
+
+ public void setSkipNotification(boolean skipNotification)
+ {
+ this.skipNotification = skipNotification;
+ }
+
+ public ICallbackHandler getCallbackHandler()
+ {
+ return callbackHandler;
+ }
+
+ public void setCallbackHandler(ICallbackHandler callbackHandler)
+ {
+ this.callbackHandler = callbackHandler;
+ }
}
diff --git a/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/views/search/RelatedProcessSearchHelper.java b/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/views/search/RelatedProcessSearchHelper.java
index 5adbd08..9039d88 100644
--- a/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/views/search/RelatedProcessSearchHelper.java
+++ b/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/views/search/RelatedProcessSearchHelper.java
@@ -98,7 +98,7 @@ public class RelatedProcessSearchHelper
}
else
{
- keyDescriptors = CommonDescriptorUtils.getCommonDescriptorsMap(sourceProcessInstances, true);
+ keyDescriptors = CommonDescriptorUtils.getKeyDescriptorsIntersectionMap(sourceProcessInstances);
sourceDescriptors = getSourceDescriptors();
}
@@ -248,12 +248,10 @@ public class RelatedProcessSearchHelper
// if key descriptors is empty then no need to create n fire query
if (CollectionUtils.isNotEmpty(keyDescriptors))
{
-
- List<ProcessInstance> processInstances = null;
-
// to search Process(es)/Case(es),atleast one key descriptor must contain non empty value.
if (!isEmptyDescriptors(keyDescriptors.values(), sourceDescriptors))
{
+ List<ProcessInstance> processInstances = null;
// first check in cache
if (resultCache.containsKey(matchAny))
{