svn commit: r932317 [3/3] - in /ofbiz/trunk/specialpurpose/workflow/src/org/ofbiz/workflow: ./ client/ definition/ impl/

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r932317 [3/3] - in /ofbiz/trunk/specialpurpose/workflow/src/org/ofbiz/workflow: ./ client/ definition/ impl/

jleroux@apache.org
Modified: ofbiz/trunk/specialpurpose/workflow/src/org/ofbiz/workflow/impl/WfProcessMgrImpl.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/workflow/src/org/ofbiz/workflow/impl/WfProcessMgrImpl.java?rev=932317&r1=932316&r2=932317&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/workflow/src/org/ofbiz/workflow/impl/WfProcessMgrImpl.java (original)
+++ ofbiz/trunk/specialpurpose/workflow/src/org/ofbiz/workflow/impl/WfProcessMgrImpl.java Fri Apr  9 09:40:02 2010
@@ -20,7 +20,6 @@ package org.ofbiz.workflow.impl;
 
 import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.Collection;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
@@ -56,11 +55,11 @@ public class WfProcessMgrImpl implements
     protected GenericValue processDef;
 
     protected String state; // will probably move to a runtime entity for the manager
-    protected List processList; // will probably be a related entity to the runtime entity
+    protected List<WfProcess> processList; // will probably be a related entity to the runtime entity
 
-    protected Map contextSignature = null;
-    protected Map resultSignature = null;
-    protected Map initialContext = null;
+    protected Map<String, Object> contextSignature = null;
+    protected Map<String, Object> resultSignature = null;
+    protected Map<String, Object> initialContext = null;
 
     /**
      * Method WfProcessMgrImpl.
@@ -73,13 +72,13 @@ public class WfProcessMgrImpl implements
      */
     public WfProcessMgrImpl(Delegator delegator, String packageId, String packageVersion,
             String processId, String processVersion) throws WfException {
-        Map finder = UtilMisc.toMap("packageId", packageId, "processId", processId);
-        List order = UtilMisc.toList("-packageVersion", "-processVersion");
+        Map<String, Object> finder = UtilMisc.toMap("packageId", (Object) packageId, "processId", processId);
+        List<String> order = UtilMisc.toList("-packageVersion", "-processVersion");
 
         if (packageVersion != null) finder.put("packageVersion", packageVersion);
         if (processVersion != null) finder.put("processVersion", processVersion);
         try {
-            List processes = delegator.findByAnd("WorkflowProcess", finder, order);
+            List<GenericValue> processes = delegator.findByAnd("WorkflowProcess", finder, order);
             if (processes.size() == 0)
                 throw new WfException("No process definition found for the specified processId");
             else
@@ -90,7 +89,7 @@ public class WfProcessMgrImpl implements
 
         buildSignatures();
         buildInitialContext();
-        processList = new ArrayList();
+        processList = new ArrayList<WfProcess>();
         state = "enabled";
         if (Debug.infoOn()) Debug.logInfo("[WfProcessMgr.init] : Create process manager (" +
                 packageId + "[" + packageVersion + "]" + " / " + processId + "[" + processVersion + "]" + ")", module);
@@ -108,9 +107,9 @@ public class WfProcessMgrImpl implements
     /**
      * @see org.ofbiz.workflow.WfProcessMgr#getSequenceProcess(int)
      */
-    public List getSequenceProcess(int maxNumber) throws WfException {
+    public List<WfProcess> getSequenceProcess(int maxNumber) throws WfException {
         if (maxNumber > 0)
-            return new ArrayList(processList.subList(0, maxNumber - 1));
+            return new ArrayList<WfProcess>(processList.subList(0, maxNumber - 1));
         return processList;
     }
 
@@ -141,7 +140,7 @@ public class WfProcessMgrImpl implements
     /**
      * @see org.ofbiz.workflow.WfProcessMgr#contextSignature()
      */
-    public Map contextSignature() throws WfException {
+    public Map<String, Object> contextSignature() throws WfException {
         return this.contextSignature;
     }
 
@@ -155,7 +154,7 @@ public class WfProcessMgrImpl implements
     /**
      * @see org.ofbiz.workflow.WfProcessMgr#processMgrStateType()
      */
-    public List processMgrStateType() throws WfException {
+    public List<String> processMgrStateType() throws WfException {
         String[] list = {"enabled", "disabled"};
         return Arrays.asList(list);
     }
@@ -191,7 +190,7 @@ public class WfProcessMgrImpl implements
     /**
      * @see org.ofbiz.workflow.WfProcessMgr#resultSignature()
      */
-    public Map resultSignature() throws WfException {
+    public Map<String, Object> resultSignature() throws WfException {
         return this.resultSignature;
     }
 
@@ -199,7 +198,7 @@ public class WfProcessMgrImpl implements
      * Method getInitialContext.
      * @return Map
      */
-    public Map getInitialContext() {
+    public Map<String, Object> getInitialContext() {
         return initialContext;
     }
 
@@ -213,18 +212,18 @@ public class WfProcessMgrImpl implements
     /**
      * @see org.ofbiz.workflow.WfProcessMgr#getIteratorProcess()
      */
-    public Iterator getIteratorProcess() throws WfException {
+    public Iterator<WfProcess> getIteratorProcess() throws WfException {
         return processList.iterator();
     }
 
     // Constructs the context/result signatures from the formalParameters
     private void buildSignatures() throws WfException {
-        contextSignature = new HashMap();
-        resultSignature = new HashMap();
-        Collection params = null;
-
+        contextSignature = new HashMap<String, Object>();
+        resultSignature = new HashMap<String, Object>();
+        
+        List<GenericValue> params = null;
         try {
-            Map fields = new HashMap();
+            Map<String, Object> fields = new HashMap<String, Object>();
 
             fields.put("packageId", processDef.getString("packageId"));
             fields.put("packageVersion", processDef.getString("packageVersion"));
@@ -236,54 +235,52 @@ public class WfProcessMgrImpl implements
         } catch (GenericEntityException e) {
             throw new WfException(e.getMessage(), e);
         }
-        if (params == null)
+        if (params == null) {
             return;
+        }
 
-        Iterator i = params.iterator();
-        while (i.hasNext()) {
-            GenericValue param = (GenericValue) i.next();
+        for (GenericValue param : params) {
             String name = param.getString("formalParamId");
             String mode = param.getString("modeEnumId");
             String type = param.getString("dataTypeEnumId");
 
-            if (mode.equals("WPM_IN") || mode.equals("WPM_INOUT"))
+            if (mode.equals("WPM_IN") || mode.equals("WPM_INOUT")) {
                 contextSignature.put(name, WfUtil.getJavaType(type));
-            else if (mode.equals("WPM_OUT") || mode.equals("WPM_INOUT"))
+            } else if (mode.equals("WPM_OUT") || mode.equals("WPM_INOUT")) {
                 resultSignature.put(name, WfUtil.getJavaType(type));
+            }
         }
     }
 
     private void buildInitialContext() throws WfException {
         Delegator delegator = processDef.getDelegator();
-        this.initialContext = new HashMap();
-        List dataFields = new ArrayList();
+        this.initialContext = new HashMap<String, Object>();
+        List<GenericValue> dataFields = new ArrayList<GenericValue>();
         try {
             // make fields
-            Map fields = new HashMap();
+            Map<String, Object> fields = new HashMap<String, Object>();
             fields.put("packageId", processDef.get("packageId"));
             fields.put("packageVersion", processDef.get("packageVersion"));
 
             // first get all package fields
             fields.put("processId", "_NA_");
             fields.put("processVersion", "_NA_");
-            List data1 = delegator.findByAnd("WorkflowDataField", fields);
+            List<GenericValue> data1 = delegator.findByAnd("WorkflowDataField", fields);
             dataFields.addAll(data1);
 
             // now get all process fields
             fields.put("processId", processDef.get("processId"));
             fields.put("processVersion", processDef.get("processVersion"));
-            List data2 = delegator.findByAnd("WorkflowDataField", fields);
+            List<GenericValue> data2 = delegator.findByAnd("WorkflowDataField", fields);
             dataFields.addAll(data2);
         } catch (GenericEntityException e) {
             throw new WfException(e.getMessage(), e);
         }
-        if (dataFields == null)
+        if (dataFields == null) {
             return;
+        }
 
-        Iterator i = dataFields.iterator();
-
-        while (i.hasNext()) {
-            GenericValue dataField = (GenericValue) i.next();
+        for (GenericValue dataField : dataFields) {
             String name = dataField.getString("dataFieldName");
             String type = dataField.getString("dataTypeEnumId");
             String value = dataField.getString("initialValue");

Modified: ofbiz/trunk/specialpurpose/workflow/src/org/ofbiz/workflow/impl/WfRequesterImpl.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/workflow/src/org/ofbiz/workflow/impl/WfRequesterImpl.java?rev=932317&r1=932316&r2=932317&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/workflow/src/org/ofbiz/workflow/impl/WfRequesterImpl.java (original)
+++ ofbiz/trunk/specialpurpose/workflow/src/org/ofbiz/workflow/impl/WfRequesterImpl.java Fri Apr  9 09:40:02 2010
@@ -26,6 +26,7 @@ import java.util.Map;
 import java.util.Locale;
 
 import org.ofbiz.base.util.Debug;
+import org.ofbiz.base.util.UtilGenerics;
 import org.ofbiz.entity.GenericEntityException;
 import org.ofbiz.entity.GenericValue;
 import org.ofbiz.service.GenericRequester;
@@ -46,19 +47,19 @@ public class WfRequesterImpl implements
 
     public static final String module = WfRequesterImpl.class.getName();
 
-    protected Map performers = null;
+    protected Map<WfProcess, GenericRequester> performers = null;
 
     /**
      * Method WfRequesterImpl.
      */
     public WfRequesterImpl() {
-        this.performers = new HashMap();
+        this.performers = new HashMap<WfProcess, GenericRequester>();
     }
 
     /**
      * @see org.ofbiz.workflow.WfRequester#registerProcess(org.ofbiz.workflow.WfProcess, java.util.Map, org.ofbiz.service.GenericRequester)
      */
-    public void registerProcess(WfProcess process, Map context, GenericRequester requester) throws WfException {
+    public void registerProcess(WfProcess process, Map<String, Object> context, GenericRequester requester) throws WfException {
         if (process == null)
             throw new WfException("Process cannot be null");
         if (context == null)
@@ -70,13 +71,14 @@ public class WfRequesterImpl implements
         // Validate the process context w/ what was passed.
         try {
             if (Debug.verboseOn()) Debug.logVerbose("Validating w/ signature: " + mgr.contextSignature(), module);
-            ModelService.validate(mgr.contextSignature(), context, true, null, ModelService.IN_PARAM, Locale.getDefault());
+            Map<String, String> contextSignature = UtilGenerics.cast(mgr.contextSignature());
+            ModelService.validate(contextSignature, context, true, null, ModelService.IN_PARAM, Locale.getDefault());
         } catch (GenericServiceException e) {
             throw new WfException("Context passed does not validate against defined signature: ", e);
         }
 
         // Set the context w/ the process
-        Map localContext = new HashMap(context);
+        Map<String, Object> localContext = new HashMap<String, Object>(context);
         localContext.putAll(mgr.getInitialContext());
         process.setProcessContext(localContext);
 
@@ -107,17 +109,17 @@ public class WfRequesterImpl implements
     /**
      * @see org.ofbiz.workflow.WfRequester#getIteratorPerformer()
      */
-    public Iterator getIteratorPerformer() throws WfException {
+    public Iterator<WfProcess> getIteratorPerformer() throws WfException {
         return performers.keySet().iterator();
     }
 
     /**
      * @see org.ofbiz.workflow.WfRequester#getSequencePerformer(int)
      */
-    public List getSequencePerformer(int maxNumber) throws WfException {
+    public List<WfProcess> getSequencePerformer(int maxNumber) throws WfException {
         if (maxNumber > 0)
-            return new ArrayList(performers.keySet()).subList(0, (maxNumber - 1));
-        return new ArrayList(performers.keySet());
+            return new ArrayList<WfProcess>(performers.keySet()).subList(0, (maxNumber - 1));
+        return new ArrayList<WfProcess>(performers.keySet());
     }
 
     /**

Modified: ofbiz/trunk/specialpurpose/workflow/src/org/ofbiz/workflow/impl/WfResourceImpl.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/workflow/src/org/ofbiz/workflow/impl/WfResourceImpl.java?rev=932317&r1=932316&r2=932317&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/workflow/src/org/ofbiz/workflow/impl/WfResourceImpl.java (original)
+++ ofbiz/trunk/specialpurpose/workflow/src/org/ofbiz/workflow/impl/WfResourceImpl.java Fri Apr  9 09:40:02 2010
@@ -19,7 +19,6 @@
 package org.ofbiz.workflow.impl;
 
 import java.util.ArrayList;
-import java.util.Collection;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
@@ -94,14 +93,14 @@ public class WfResourceImpl implements W
     /**
      * @see org.ofbiz.workflow.WfResource#getIteratorWorkItem()
      */
-    public Iterator getIteratorWorkItem() throws WfException {
+    public Iterator<WfActivity> getIteratorWorkItem() throws WfException {
         return workItems().iterator();
     }
 
     /**
      * @see org.ofbiz.workflow.WfResource#getSequenceWorkItem(int)
      */
-    public List getSequenceWorkItem(int maxNumber) throws WfException {
+    public List<WfActivity> getSequenceWorkItem(int maxNumber) throws WfException {
         if (maxNumber > 0)
             return workItems().subList(0, (maxNumber - 1));
         return workItems();
@@ -153,21 +152,19 @@ public class WfResourceImpl implements W
         // log the transaction
     }
 
-    private List workItems() throws WfException {
-        List workList = new ArrayList();
-        Collection c = null;
+    private List<WfActivity> workItems() throws WfException {
+        List<WfActivity> workList = new ArrayList<WfActivity>();
+        List<GenericValue> c = null;
 
         try {
-            Map fields = UtilMisc.toMap("partyId", partyId, "roleTypeId", roleTypeId);
+            Map<String, Object> fields = UtilMisc.toMap("partyId", (Object) partyId, "roleTypeId", roleTypeId);
             c = delegator.findByAnd("WorkEffortPartyAssignment", fields);
         } catch (GenericEntityException e) {
             throw new WfException(e.getMessage(), e);
         }
 
         if (c != null) {
-            Iterator i = c.iterator();
-            while (i.hasNext()) {
-                GenericValue v = (GenericValue) i.next();
+            for (GenericValue v : c) {
                 WfActivity a = null;
 
                 try {