Modified: ofbiz/trunk/specialpurpose/workflow/src/org/ofbiz/workflow/definition/XpdlReader.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/workflow/src/org/ofbiz/workflow/definition/XpdlReader.java?rev=757110&r1=757109&r2=757110&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/workflow/src/org/ofbiz/workflow/definition/XpdlReader.java (original) +++ ofbiz/trunk/specialpurpose/workflow/src/org/ofbiz/workflow/definition/XpdlReader.java Sun Mar 22 00:38:34 2009 @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -62,7 +62,7 @@ * datasource through the given delegator */ public static void importXpdl(URL location, GenericDelegator delegator) throws DefinitionParserException { List values = readXpdl(location, delegator); - + // attempt to start a transaction boolean beganTransaction = false; try { @@ -70,7 +70,7 @@ } catch (GenericTransactionException gte) { Debug.logError(gte, "Unable to begin transaction", module); } - + try { delegator.storeAll(values); TransactionUtil.commit(beganTransaction); @@ -78,9 +78,9 @@ try { // only rollback the transaction if we started one... TransactionUtil.rollback(beganTransaction, "Error importing XPDL", e); - } catch (GenericEntityException e2) { + } catch (GenericEntityException e2) { Debug.logError(e2, "Problems rolling back transaction", module); - } + } throw new DefinitionParserException("Could not store values", e); } } @@ -165,7 +165,7 @@ // RedefinableHeader? Element redefinableHeaderElement = UtilXml.firstChildElement(packageElement, "RedefinableHeader"); boolean packageOk = readRedefinableHeader(redefinableHeaderElement, packageValue, "package"); - String packageVersion = packageValue.getString("packageVersion"); + String packageVersion = packageValue.getString("packageVersion"); // Only do these if the package hasn't been imported. if (packageOk) { @@ -311,7 +311,7 @@ participantListValue.set("processId", "_NA_"); participantListValue.set("processVersion", "_NA_"); } - values.add(participantListValue); + values.add(participantListValue); responsibleIndex++; } } @@ -476,7 +476,7 @@ // RedefinableHeader? Element redefinableHeaderElement = UtilXml.firstChildElement(workflowProcessElement, "RedefinableHeader"); boolean processOk = readRedefinableHeader(redefinableHeaderElement, workflowProcessValue, "process"); - String processVersion = workflowProcessValue.getString("processVersion"); + String processVersion = workflowProcessValue.getString("processVersion"); if (!processOk) { values.remove(workflowProcessValue); @@ -520,10 +520,10 @@ List transitions = UtilXml.childElementList(transitionsElement, "Transition"); readTransitions(transitions, packageId, packageVersion, processId, processVersion); - + // ExtendedAttributes? - workflowProcessValue.set("defaultStartActivityId", getExtendedAttributeValue(workflowProcessElement, "defaultStartActivityId", workflowProcessValue.getString("defaultStartActivityId"))); - workflowProcessValue.set("sourceReferenceField", getExtendedAttributeValue(workflowProcessElement, "sourceReferenceField", "sourceReferenceId")); + workflowProcessValue.set("defaultStartActivityId", getExtendedAttributeValue(workflowProcessElement, "defaultStartActivityId", workflowProcessValue.getString("defaultStartActivityId"))); + workflowProcessValue.set("sourceReferenceField", getExtendedAttributeValue(workflowProcessElement, "sourceReferenceField", "sourceReferenceId")); } // ---------------------------------------------------------------- @@ -912,11 +912,11 @@ // Description? transitionValue.set("description", UtilXml.childElementValue(transitionElement, "Description")); - - // ExtendedAttributes? - Element extendedAttributesElement = UtilXml.firstChildElement(transitionElement, "ExtendedAttributes"); - List extendedAttributes = UtilXml.childElementList(extendedAttributesElement, "ExtendedAttribute"); - transitionValue.set("extendedAttributes", readExtendedAttributes(extendedAttributes), false); + + // ExtendedAttributes? + Element extendedAttributesElement = UtilXml.firstChildElement(transitionElement, "ExtendedAttributes"); + List extendedAttributes = UtilXml.childElementList(extendedAttributesElement, "ExtendedAttribute"); + transitionValue.set("extendedAttributes", readExtendedAttributes(extendedAttributes), false); } protected void readTransitionRestrictions(List transitionRestrictions, GenericValue activityValue) throws DefinitionParserException { @@ -984,7 +984,7 @@ } } - protected void readTransitionRefs(List transitionRefs, String packageId, String packageVersion, String processId, String processVersion, String activityId) throws DefinitionParserException { + protected void readTransitionRefs(List transitionRefs, String packageId, String packageVersion, String processId, String processVersion, String activityId) throws DefinitionParserException { if (transitionRefs == null || transitionRefs.size() == 0) return; Iterator transitionRefsIter = transitionRefs.iterator(); @@ -1012,21 +1012,21 @@ if (participants == null || participants.size() == 0) return; Iterator participantsIter = participants.iterator(); - + while (participantsIter.hasNext()) { Element participantElement = (Element) participantsIter.next(); String participantId = participantElement.getAttribute("Id"); GenericValue participantValue = delegator.makeValue("WorkflowParticipant"); - + values.add(participantValue); - + participantValue.set("packageId", packageId); participantValue.set("packageVersion", packageVersion); participantValue.set("processId", processId); participantValue.set("processVersion", processVersion); participantValue.set("participantId", participantId); participantValue.set("participantName", participantElement.getAttribute("Name")); - + // ParticipantType Element participantTypeElement = UtilXml.firstChildElement(participantElement, "ParticipantType"); @@ -1039,10 +1039,10 @@ // ExtendedAttributes participantValue.set("partyId", getExtendedAttributeValue(participantElement, "partyId", null), false); - participantValue.set("roleTypeId", getExtendedAttributeValue(participantElement, "roleTypeId", null), false); + participantValue.set("roleTypeId", getExtendedAttributeValue(participantElement, "roleTypeId", null), false); } } - + /* protected void readParticipants(List participants, String packageId, String packageVersion, String processId, String processVersion, GenericValue valueObject) throws DefinitionParserException { if (participants == null || participants.size() == 0) @@ -1302,7 +1302,7 @@ } return defaultValue; } - + // --------------------------------------------------------- // RUNTIME, TEST, AND SAMPLE METHODS // --------------------------------------------------------- Modified: ofbiz/trunk/specialpurpose/workflow/src/org/ofbiz/workflow/impl/ServiceCondition.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/workflow/src/org/ofbiz/workflow/impl/ServiceCondition.java?rev=757110&r1=757109&r2=757110&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/workflow/src/org/ofbiz/workflow/impl/ServiceCondition.java (original) +++ ofbiz/trunk/specialpurpose/workflow/src/org/ofbiz/workflow/impl/ServiceCondition.java Sun Mar 22 00:38:34 2009 @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -31,7 +31,7 @@ /** * ServiceCondition - Invokes a special service for condition evaluation - * + * * To call a service set a Transition ExtendedAttribute named 'serviceName', services are required * to return a Boolean OUT parameter named 'evaluationResult' */ @@ -45,16 +45,16 @@ String serviceName = (String) attrs.get("serviceName"); if (serviceName == null || serviceName.length() == 0) throw new EvaluationException("Invalid serviceName; be sure to set the serviceName ExtendedAttribute"); - - // get the dispatcher + + // get the dispatcher LocalDispatcher dispatcher = dctx.getDispatcher(); if (dispatcher == null) throw new EvaluationException("Bad LocalDispatcher found in the DispatchContext"); - + // create a map of all context and extended attributes, attributes will overwrite context values Map newContext = new HashMap(context); newContext.putAll(attrs); - + // build the context for the service Map serviceContext = null; ModelService model = null; @@ -62,9 +62,9 @@ model = dctx.getModelService(serviceName); serviceContext = model.makeValid(newContext, ModelService.IN_PARAM); } catch (GenericServiceException e) { - throw new EvaluationException("Cannot get ModelService object for service named: " + serviceName, e); + throw new EvaluationException("Cannot get ModelService object for service named: " + serviceName, e); } - + // invoke the service Map serviceResult = null; try { @@ -72,7 +72,7 @@ } catch (GenericServiceException e) { throw new EvaluationException("Cannot invoke the service named: " + serviceName, e); } - + // get the evaluationResult object from the result Boolean evaluationResult = null; try { @@ -80,7 +80,7 @@ } catch (ClassCastException e) { throw new EvaluationException("Service did not return a valid evaluationResult object"); } - + return evaluationResult; } Modified: ofbiz/trunk/specialpurpose/workflow/src/org/ofbiz/workflow/impl/WfActivityAbstractImplementation.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/workflow/src/org/ofbiz/workflow/impl/WfActivityAbstractImplementation.java?rev=757110&r1=757109&r2=757110&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/workflow/src/org/ofbiz/workflow/impl/WfActivityAbstractImplementation.java (original) +++ ofbiz/trunk/specialpurpose/workflow/src/org/ofbiz/workflow/impl/WfActivityAbstractImplementation.java Sun Mar 22 00:38:34 2009 @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -67,14 +67,14 @@ return runService(service, params, extend); } - protected GenericResultWaiter runService(ModelService service, String params, String extend) throws WfException { + protected GenericResultWaiter runService(ModelService service, String params, String extend) throws WfException { LocalDispatcher dispatcher = getActivity().getDispatcher(); List paramNames = service.getParameterNames(ModelService.IN_PARAM, true); if (paramNames != null && paramNames.size() == 0) paramNames = null; - + Map ctx = getActivity().actualContext(params, extend, paramNames, false); - + GenericResultWaiter waiter = new GenericResultWaiter(); Debug.logVerbose("[WfActivityAbstractImplementation.runService] : Invoking the service.", module); try { @@ -104,7 +104,7 @@ return resultContext; } - /** + /** * Getter for property complete. * @return Value of property complete. */ @@ -112,7 +112,7 @@ return this.complete; } - /** + /** * Setter for property complete. * @param complete New value of property complete. */ Modified: ofbiz/trunk/specialpurpose/workflow/src/org/ofbiz/workflow/impl/WfActivityImpl.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/workflow/src/org/ofbiz/workflow/impl/WfActivityImpl.java?rev=757110&r1=757109&r2=757110&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/workflow/src/org/ofbiz/workflow/impl/WfActivityImpl.java (original) +++ ofbiz/trunk/specialpurpose/workflow/src/org/ofbiz/workflow/impl/WfActivityImpl.java Sun Mar 22 00:38:34 2009 @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -67,7 +67,7 @@ public class WfActivityImpl extends WfExecutionObjectImpl implements WfActivity { public static final String module = WfActivityImpl.class.getName(); - + private static final int CHECK_ASSIGN = 1; private static final int CHECK_COMPLETE = 2; @@ -88,10 +88,10 @@ private void init() throws WfException { GenericValue valueObject = getDefinitionObject(); - + // set the activity context this.setProcessContext(container().contextKey()); - + // parse the descriptions this.parseDescriptions(this.processContext()); @@ -116,15 +116,15 @@ } } } - + GenericValue performer = null; if (valueObject.get("performerParticipantId") != null) { try { performer = valueObject.getRelatedOne("PerformerWorkflowParticipant"); if (performer == null) { - Map performerFields = UtilMisc.toMap("packageId", valueObject.getString("packageId"), - "packageVersion", valueObject.getString("packageVersion"), "processId", "_NA_", - "processVersion", "_NA_", "participantId", valueObject.getString("performerParticipantId")); + Map performerFields = UtilMisc.toMap("packageId", valueObject.getString("packageId"), + "packageVersion", valueObject.getString("packageVersion"), "processId", "_NA_", + "processVersion", "_NA_", "participantId", valueObject.getString("performerParticipantId")); performer = delegator.findByPrimaryKey("WorkflowParticipant", performerFields); } } catch (GenericEntityException e) { @@ -133,7 +133,7 @@ } if (performer != null) createAssignments(performer); - + boolean limitAfterStart = valueObject.getBoolean("limitAfterStart").booleanValue(); if (Debug.verboseOn()) { @@ -142,7 +142,7 @@ if (!limitAfterStart && valueObject.get("limitService") != null && !valueObject.getString("limitService").equals("")) { Debug.logVerbose("[WfActivity.init]: limit service is not after start, setting up now.", module); setLimitService(); - } + } } private void createAssignments(GenericValue currentPerformer) throws WfException { @@ -150,16 +150,16 @@ GenericValue performer = checkPerformer(currentPerformer); boolean assignAll = false; - if (valueObject.get("acceptAllAssignments") != null) { + if (valueObject.get("acceptAllAssignments") != null) { assignAll = valueObject.getBoolean("acceptAllAssignments").booleanValue(); } - - // first check for single assignment + + // first check for single assignment if (!assignAll) { if (performer != null) { Debug.logVerbose("[WfActivity.createAssignments] : (S) Single assignment", module); assign(WfFactory.getWfResource(performer), false); - } + } } // check for a party group @@ -181,8 +181,8 @@ // party is a group Collection partyRelations = null; try { - Map fields = UtilMisc.toMap("partyIdFrom", performer.getString("partyId"), - "partyRelationshipTypeId", "GROUP_ROLLUP"); + Map fields = UtilMisc.toMap("partyIdFrom", performer.getString("partyId"), + "partyRelationshipTypeId", "GROUP_ROLLUP"); partyRelations = getDelegator().findByAnd("PartyRelationship", fields); } catch (GenericEntityException e) { throw new WfException(e.getMessage(), e); @@ -203,8 +203,8 @@ Debug.logVerbose("[WfActivity.createAssignments] : (G) Single assignment", module); assign(WfFactory.getWfResource(performer), false); } - } - + } + // check for role types else if (performer.get("roleTypeId") != null && !performer.getString("roleTypeId").equals("_NA_")) { Collection partyRoles = null; @@ -230,10 +230,10 @@ private List getAssignments() throws WfException { List assignments = new ArrayList(); List assignList = this.getAllAssignments(); - + if (assignList == null) return assignments; - + Iterator i = assignList.iterator(); while (i.hasNext()) { GenericValue value = (GenericValue) i.next(); @@ -248,7 +248,7 @@ if (Debug.verboseOn()) Debug.logVerbose("Found [" + assignments.size() + "] assignment(s)", module); return assignments; } - + private List getAllAssignments() throws WfException { List assignList = null; try { @@ -256,13 +256,13 @@ } catch (GenericEntityException e) { throw new WfException(e.getMessage(), e); } - + if (assignList != null) { assignList = EntityUtil.filterByDate(assignList); - } else { + } else { return new ArrayList(); } - return assignList; + return assignList; } // create a new assignment @@ -283,11 +283,11 @@ private GenericValue checkPerformer(GenericValue performer) throws WfException { GenericValue newPerformer = GenericValue.create(performer); Map context = processContext(); - - String performerType = performer.getString("participantTypeId"); + + String performerType = performer.getString("participantTypeId"); String partyId = performer.getString("partyId"); String roleTypeId = performer.getString("roleTypeId"); - + // check for dynamic party if (partyId != null && partyId.trim().toLowerCase().startsWith("expr:")) { if (Debug.verboseOn()) Debug.logVerbose("Dynamic performer: Found a party expression", module); @@ -303,15 +303,15 @@ } else { throw new WfException("Expression did not return a String"); } - } + } } - + // check for dynamic role if (roleTypeId != null && roleTypeId.trim().toLowerCase().startsWith("expr:")) { if (Debug.verboseOn()) Debug.logVerbose("Dynamic performer: Found a role expression", module); Object value = null; try { - value = BshUtil.eval(roleTypeId.trim().substring(5).trim(), context); + value = BshUtil.eval(roleTypeId.trim().substring(5).trim(), context); } catch (bsh.EvalError e) { throw new WfException("Bsh evaluation error occurred.", e); } @@ -323,21 +323,21 @@ } } } - + // check for un-defined party if (performerType.equals("HUMAN") || performerType.equals("ORGANIZATIONAL_UNIT")) { if (partyId == null) { newPerformer.set("partyId", performer.getString("participantId")); } } - + // check for un-defined role if (performerType.equals("ROLE")) { if (roleTypeId == null) { newPerformer.set("roleTypeId", performer.getString("participantId")); } } - + return newPerformer; } @@ -352,7 +352,7 @@ // check the start mode String mode = getDefinitionObject().getString("startModeEnumId"); - if (mode == null) { + if (mode == null) { throw new WfException("Start mode cannot be null"); } @@ -383,9 +383,9 @@ } try { changeState("closed.completed"); - GenericValue activityWe = getRuntimeObject(); + GenericValue activityWe = getRuntimeObject(); activityWe.set("actualCompletionDate", UtilDateTime.nowTimestamp()); - activityWe.store(); + activityWe.store(); } catch (InvalidState is) { throw new WfException("Invalid WF State", is); } catch (TransitionNotAllowed tna) { @@ -396,33 +396,33 @@ container().activityComplete(this); } - + /** * @see org.ofbiz.workflow.WfExecutionObject#resume() */ public void resume() throws WfException, CannotResume, NotRunning, NotSuspended { super.resume(); - try { - Debug.logVerbose("Checking to see if we can complete the activity", module); + try { + Debug.logVerbose("Checking to see if we can complete the activity", module); this.checkComplete(); } catch (CannotComplete e) { throw new CannotResume("Attempt to complete activity failed", e); - } + } } - + /** * @see org.ofbiz.workflow.WfExecutionObject#abort() */ public void abort() throws WfException, CannotStop, NotRunning { super.abort(); - + // cancel the active assignments Iterator assignments = this.getAssignments().iterator(); while (assignments.hasNext()) { - WfAssignment assignment = (WfAssignment) assignments.next(); + WfAssignment assignment = (WfAssignment) assignments.next(); assignment.changeStatus("CAL_CANCELLED"); - } - } + } + } /** * @see org.ofbiz.workflow.WfActivity#isMemberOfAssignment(org.ofbiz.workflow.WfAssignment) @@ -433,11 +433,11 @@ /** * @see org.ofbiz.workflow.WfActivity#container() - */ + */ public WfProcess container() throws WfException { return WfFactory.getWfProcess(delegator, processId); } - + /** * @see org.ofbiz.workflow.WfActivity#setResult(java.util.Map) */ @@ -538,26 +538,26 @@ if (valueObject.get("completeAllAssignments") != null) completeAll = valueObject.getBoolean("completeAllAssignments").booleanValue(); - List validStatus = null; + List validStatus = null; if (type == CHECK_ASSIGN) - validStatus = UtilMisc.toList("CAL_ACCEPTED", "CAL_COMPLETED", "CAL_DELEGATED"); + validStatus = UtilMisc.toList("CAL_ACCEPTED", "CAL_COMPLETED", "CAL_DELEGATED"); else if (type == CHECK_COMPLETE) - validStatus = UtilMisc.toList("CAL_COMPLETED", "CAL_DELEGATED"); + validStatus = UtilMisc.toList("CAL_COMPLETED", "CAL_DELEGATED"); else throw new WfException("Invalid status type"); boolean foundOne = false; List assignList = this.getAllAssignments(); - Iterator i = assignList.iterator(); + Iterator i = assignList.iterator(); - while (i.hasNext()) { + while (i.hasNext()) { GenericValue value = (GenericValue) i.next(); String party = value.getString("partyId"); String role = value.getString("roleTypeId"); - java.sql.Timestamp from = value.getTimestamp("fromDate"); - WfAssignment a = WfFactory.getWfAssignment(getDelegator(), runtimeKey(), party, role, from); + java.sql.Timestamp from = value.getTimestamp("fromDate"); + WfAssignment a = WfFactory.getWfAssignment(getDelegator(), runtimeKey(), party, role, from); if (validStatus.contains(a.status())) { // if we find one set this to true @@ -568,7 +568,7 @@ return false; } } - + // we are here only if all are done, or complete/assign is false; so if not false we are done if ((type == CHECK_COMPLETE && completeAll) || (type == CHECK_ASSIGN && acceptAll)) { return true; @@ -632,9 +632,9 @@ // schedule the limit service to run private void setLimitService() throws WfException { - LocalDispatcher dispatcher = getDispatcher(); + LocalDispatcher dispatcher = getDispatcher(); - + DispatchContext dctx = dispatcher.getDispatchContext(); String limitService = getDefinitionObject().getString("limitService"); ModelService service = null; @@ -652,9 +652,9 @@ // make the limit service context List inList = new ArrayList(service.getInParamNames()); - String inParams = StringUtil.join(inList, ","); - - Map serviceContext = actualContext(inParams, null, null, true); + String inParams = StringUtil.join(inList, ","); + + Map serviceContext = actualContext(inParams, null, null, true); Debug.logVerbose("Setting limit service with context: " + serviceContext, module); Double timeLimit = null; @@ -728,7 +728,7 @@ // extended attributes take priority over context attributes Map extendedAttributes = StringUtil.strToMap(extendedAttr); - if (UtilValidate.isNotEmpty(extendedAttributes)) { + if (UtilValidate.isNotEmpty(extendedAttributes)) { context.putAll(extendedAttributes); } @@ -752,9 +752,9 @@ WfResource res = assign.assignee(); context.put("assignedPartyId", res.resourcePartyId()); context.put("assignedRoleTypeId", res.resourceRoleId()); - } - - // first we will pull out the values from the context for the actual parameters + } + + // first we will pull out the values from the context for the actual parameters if (actualParameters != null) { List params = StringUtil.split(actualParameters, ","); Iterator i = params.iterator(); @@ -762,7 +762,7 @@ while (i.hasNext()) { Object key = i.next(); String keyStr = (String) key; - + if (keyStr != null && keyStr.trim().toLowerCase().startsWith("expr:")) { // check for bsh expressions; this does not place values into the context try { @@ -775,23 +775,23 @@ List couple = StringUtil.split(keyStr.trim().substring(5).trim(), "="); String mName = (String) couple.get(0); // mapped name String cName = (String) couple.get(1); // context name - + // trim out blank space if (mName != null) mName = mName.trim(); - if (cName != null) cName = cName.trim(); - - if (mName != null && cName != null && context.containsKey(cName)) { + if (cName != null) cName = cName.trim(); + + if (mName != null && cName != null && context.containsKey(cName)) { actualContext.put(mName, context.get(cName)); - } + } } else if (context.containsKey(key)) { - // direct assignment from context + // direct assignment from context actualContext.put(key, context.get(key)); - } else if (!actualContext.containsKey(key) && !ignoreUnknown) { + } else if (!actualContext.containsKey(key) && !ignoreUnknown) { throw new WfException("Context does not contain the key: '" + (String) key + "'"); } } } - + // the serviceSignature should not limit which parameters are in the actualContext // so instead we will use this signature to pull out values so they do not all have to be defined if (serviceSignature != null) { @@ -799,11 +799,11 @@ while (si.hasNext()) { Object key = si.next(); String keyStr = (String) key; - if (!actualContext.containsKey(key) && context.containsKey(key)) { + if (!actualContext.containsKey(key) && context.containsKey(key)) { actualContext.put(keyStr, context.get(keyStr)); } } - } + } return actualContext; } Modified: ofbiz/trunk/specialpurpose/workflow/src/org/ofbiz/workflow/impl/WfActivityImplementationFact.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/workflow/src/org/ofbiz/workflow/impl/WfActivityImplementationFact.java?rev=757110&r1=757109&r2=757110&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/workflow/src/org/ofbiz/workflow/impl/WfActivityImplementationFact.java (original) +++ ofbiz/trunk/specialpurpose/workflow/src/org/ofbiz/workflow/impl/WfActivityImplementationFact.java Sun Mar 22 00:38:34 2009 @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY Modified: ofbiz/trunk/specialpurpose/workflow/src/org/ofbiz/workflow/impl/WfActivityLoopImplementation.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/workflow/src/org/ofbiz/workflow/impl/WfActivityLoopImplementation.java?rev=757110&r1=757109&r2=757110&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/workflow/src/org/ofbiz/workflow/impl/WfActivityLoopImplementation.java (original) +++ ofbiz/trunk/specialpurpose/workflow/src/org/ofbiz/workflow/impl/WfActivityLoopImplementation.java Sun Mar 22 00:38:34 2009 @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -25,7 +25,7 @@ public static final String module = WfActivityLoopImplementation.class.getName(); - /** + /** * @see org.ofbiz.workflow.impl.WfActivityAbstractImplementation#WfActivityAbstractImplementation(WfActivityImpl) */ public WfActivityLoopImplementation(WfActivityImpl wfActivity) { Modified: ofbiz/trunk/specialpurpose/workflow/src/org/ofbiz/workflow/impl/WfActivityNoImplementation.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/workflow/src/org/ofbiz/workflow/impl/WfActivityNoImplementation.java?rev=757110&r1=757109&r2=757110&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/workflow/src/org/ofbiz/workflow/impl/WfActivityNoImplementation.java (original) +++ ofbiz/trunk/specialpurpose/workflow/src/org/ofbiz/workflow/impl/WfActivityNoImplementation.java Sun Mar 22 00:38:34 2009 @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY Modified: ofbiz/trunk/specialpurpose/workflow/src/org/ofbiz/workflow/impl/WfActivityRouteImplementation.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/workflow/src/org/ofbiz/workflow/impl/WfActivityRouteImplementation.java?rev=757110&r1=757109&r2=757110&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/workflow/src/org/ofbiz/workflow/impl/WfActivityRouteImplementation.java (original) +++ ofbiz/trunk/specialpurpose/workflow/src/org/ofbiz/workflow/impl/WfActivityRouteImplementation.java Sun Mar 22 00:38:34 2009 @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY Modified: ofbiz/trunk/specialpurpose/workflow/src/org/ofbiz/workflow/impl/WfActivitySubFlowImplementation.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/workflow/src/org/ofbiz/workflow/impl/WfActivitySubFlowImplementation.java?rev=757110&r1=757109&r2=757110&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/workflow/src/org/ofbiz/workflow/impl/WfActivitySubFlowImplementation.java (original) +++ ofbiz/trunk/specialpurpose/workflow/src/org/ofbiz/workflow/impl/WfActivitySubFlowImplementation.java Sun Mar 22 00:38:34 2009 @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -60,9 +60,9 @@ service.engineName = "workflow"; service.location = subFlow.getString("packageId"); service.invoke = subFlow.getString("subFlowProcessId"); - service.validate = false; + service.validate = false; - // we don't use the service definition parameters (since there is no definition) so, we will just grab + // we don't use the service definition parameters (since there is no definition) so, we will just grab // the actual parameters and let the workflow engine test the contextSignature String actualParameters = subFlow.getString("actualParameters"); GenericResultWaiter waiter = runService(service, actualParameters, null); Modified: ofbiz/trunk/specialpurpose/workflow/src/org/ofbiz/workflow/impl/WfActivityToolImplementation.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/workflow/src/org/ofbiz/workflow/impl/WfActivityToolImplementation.java?rev=757110&r1=757109&r2=757110&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/workflow/src/org/ofbiz/workflow/impl/WfActivityToolImplementation.java (original) +++ ofbiz/trunk/specialpurpose/workflow/src/org/ofbiz/workflow/impl/WfActivityToolImplementation.java Sun Mar 22 00:38:34 2009 @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -71,17 +71,17 @@ String toolId = thisTool.getString("toolId"); String params = thisTool.getString("actualParameters"); String toolTypeEnumId = thisTool.getString("toolTypeEnumId"); - + //Linea agregada por Oswin Ondarza allParams = allParams + "," + params; String extend = thisTool.getString("extendedAttributes"); - - Map extendedAttr = StringUtil.strToMap(extend); + + Map extendedAttr = StringUtil.strToMap(extend); if (extendedAttr != null && extendedAttr.containsKey("serviceName")) serviceName = (String) extendedAttr.get("serviceName"); - - serviceName = serviceName != null ? serviceName : (toolTypeEnumId.equals("WTT_APPLICATION") ? - "wfActivateApplication" : toolId); + + serviceName = serviceName != null ? serviceName : (toolTypeEnumId.equals("WTT_APPLICATION") ? + "wfActivateApplication" : toolId); waiters.add(runService(serviceName, params, extend)); } @@ -90,7 +90,7 @@ Collection remove = new ArrayList(); while (wi.hasNext()) { GenericResultWaiter thw = (GenericResultWaiter) wi.next(); - + if (thw.isCompleted()) { Map thwResult = null; if (thw.status() == GenericResultWaiter.SERVICE_FINISHED) { @@ -105,8 +105,8 @@ Debug.logError("Service Error: " + errorMsg, module); } thwResult.remove(ModelService.RESPONSE_MESSAGE); - } - + } + try { if (thwResult != null) this.setResult(thwResult, allParams); @@ -118,7 +118,7 @@ } waiters.removeAll(remove); } - + setComplete(true); } Modified: ofbiz/trunk/specialpurpose/workflow/src/org/ofbiz/workflow/impl/WfAssignmentImpl.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/workflow/src/org/ofbiz/workflow/impl/WfAssignmentImpl.java?rev=757110&r1=757109&r2=757110&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/workflow/src/org/ofbiz/workflow/impl/WfAssignmentImpl.java (original) +++ ofbiz/trunk/specialpurpose/workflow/src/org/ofbiz/workflow/impl/WfAssignmentImpl.java Sun Mar 22 00:38:34 2009 @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -109,7 +109,7 @@ if (value == null) throw new WfException("No existing assignment found or create failed"); } - + /** * @see org.ofbiz.workflow.WfAssignment#accept() */ @@ -141,7 +141,7 @@ while (ai.hasNext()) { WfAssignment a = (WfAssignment) ai.next(); - if (!this.isEqual(a)) a.delegate(); + if (!this.isEqual(a)) a.delegate(); } } } @@ -164,7 +164,7 @@ try { activity.complete(); } catch (CannotComplete e) { - Debug.logWarning("Activity not complete : " + e.getMessage(), module); + Debug.logWarning("Activity not complete : " + e.getMessage(), module); } } @@ -175,7 +175,7 @@ // check and make sure we are not already delegated if (status().equals("CAL_DELEGATED")) throw new WfException("Assignment has already been delegated"); - + // set the thru-date GenericValue valueObject = valueObject(); try { @@ -183,18 +183,18 @@ valueObject.store(); if (Debug.verboseOn()) Debug.logVerbose("[WfAssignment.delegated()] : set the thru-date.", module); } catch (GenericEntityException e) { - e.printStackTrace(); + e.printStackTrace(); throw new WfException(e.getMessage(), e); - } - - // change the status - changeStatus("CAL_DELEGATED"); + } + + // change the status + changeStatus("CAL_DELEGATED"); } /** * @see org.ofbiz.workflow.WfAssignment#changeStatus(java.lang.String) */ - public void changeStatus(String status) throws WfException { + public void changeStatus(String status) throws WfException { // change the status GenericValue valueObject = valueObject(); try { @@ -273,23 +273,23 @@ throw new WfException("Invalid assignment; no runtime entity"); return value; } - + private boolean isEqual(WfAssignment asgn) throws WfException { // compare this to null = different assignment if (asgn == null) { return false; } - + // if status is different; we must be different if (!this.status().equals(asgn.status())) { return false; } - + // different activity = different assignment WfActivity thisActivity = this.activity(); - WfActivity compActivity = asgn.activity(); + WfActivity compActivity = asgn.activity(); if ((thisActivity == null && compActivity != null) || (thisActivity != null && compActivity == null)) { - return false; + return false; } else { String thisKey = thisActivity.runtimeKey(); String compKey = compActivity.runtimeKey(); @@ -297,14 +297,14 @@ return false; } else if (thisKey != null && compKey != null && !thisKey.equals(compKey)) { return false; - } + } } - + // different participantId = different assignment - the rest doesn't matter WfResource thisResource = this.assignee(); - WfResource compResource = asgn.assignee(); + WfResource compResource = asgn.assignee(); if ((thisResource == null && compResource != null) || (thisResource != null && compResource == null)) { - return false; + return false; } else { String thisKey = thisResource.resourceKey(); String compKey = compResource.resourceKey(); @@ -312,9 +312,9 @@ return false; } else if (thisKey != null && compKey != null && !thisKey.equals(compKey)) { return false; - } - } - + } + } + // same status, same activity, same participantId = same assignement return true; } Modified: ofbiz/trunk/specialpurpose/workflow/src/org/ofbiz/workflow/impl/WfEventAuditImpl.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/workflow/src/org/ofbiz/workflow/impl/WfEventAuditImpl.java?rev=757110&r1=757109&r2=757110&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/workflow/src/org/ofbiz/workflow/impl/WfEventAuditImpl.java (original) +++ ofbiz/trunk/specialpurpose/workflow/src/org/ofbiz/workflow/impl/WfEventAuditImpl.java Sun Mar 22 00:38:34 2009 @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -43,7 +43,7 @@ this.eventType = eventType; this.timeStamp = new Timestamp(new Date().getTime()); } - + /** * @see org.ofbiz.workflow.WfEventAudit#source() */ Modified: ofbiz/trunk/specialpurpose/workflow/src/org/ofbiz/workflow/impl/WfExecutionObjectImpl.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/workflow/src/org/ofbiz/workflow/impl/WfExecutionObjectImpl.java?rev=757110&r1=757109&r2=757110&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/workflow/src/org/ofbiz/workflow/impl/WfExecutionObjectImpl.java (original) +++ ofbiz/trunk/specialpurpose/workflow/src/org/ofbiz/workflow/impl/WfExecutionObjectImpl.java Sun Mar 22 00:38:34 2009 @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -65,7 +65,7 @@ public abstract class WfExecutionObjectImpl implements WfExecutionObject { public static final String module = WfExecutionObjectImpl.class.getName(); - public static final String dispatcherName = "WFDispatcher"; + public static final String dispatcherName = "WFDispatcher"; protected String packageId = null; protected String packageVersion = null; @@ -103,7 +103,7 @@ if (Debug.verboseOn()) Debug.logVerbose(" Process ID: " + processId + " V: " + processVersion, module); if (Debug.verboseOn()) Debug.logVerbose("Activity ID: " + activityId, module); } - + // creates the stored runtime workeffort data. private void createRuntime(String parentId) throws WfException { GenericValue valueObject = getDefinitionObject(); @@ -135,24 +135,24 @@ dataMap.put("sourceReferenceId", parentWorkEffort.getString("sourceReferenceId")); } - try { - dataObject = getDelegator().makeValue("WorkEffort", dataMap); + try { + dataObject = getDelegator().makeValue("WorkEffort", dataMap); getDelegator().create(dataObject); - + String objectId = activityId != null ? activityId : processId; if (Debug.verboseOn()) Debug.logVerbose("Created new runtime object [" + objectId + "] (Workeffort: " + runtimeKey() + ")", module); } catch (GenericEntityException e) { throw new WfException(e.getMessage(), e); } } - + protected void parseDescriptions(Map parseContext) throws WfException { GenericValue runtime = getRuntimeObject(); String name = runtime.getString("workEffortName"); String desc = runtime.getString("description"); String nameExp = FlexibleStringExpander.expandString(name, parseContext); String descExp = FlexibleStringExpander.expandString(desc, parseContext); - + boolean changed = false; if (nameExp != null && !nameExp.equals(name)) { changed = true; @@ -162,7 +162,7 @@ changed = true; runtime.set("description", descExp); } - + if (changed) { try { runtime.store(); @@ -174,11 +174,11 @@ /** * @see org.ofbiz.workflow.WfExecutionObject#name() - */ + */ public String name() throws WfException { return getRuntimeObject().getString("workEffortName"); } - + /** * @see org.ofbiz.workflow.WfExecutionObject#setName(java.lang.String) */ @@ -192,7 +192,7 @@ throw new WfException(e.getMessage(), e); } } - + /** * @see org.ofbiz.workflow.WfExecutionObject#setPriority(long) */ @@ -233,8 +233,8 @@ if (stateStr == null) throw new WfException("Stored state is not a valid type."); - - if (Debug.verboseOn()) Debug.logVerbose("Current state: " + stateStr, module); + + if (Debug.verboseOn()) Debug.logVerbose("Current state: " + stateStr, module); return stateStr; } @@ -260,14 +260,14 @@ possibleStates.remove("open.not_running.not_started"); possibleStates.remove("open.not_running.suspended"); possibleStates.remove("closed.completed"); - possibleStates.remove("closed.terminated"); + possibleStates.remove("closed.terminated"); return possibleStates; } if (currentState.equals("open.not_running.suspended")) { possibleStates.remove("open.not_running.suspended"); possibleStates.remove("open.not_running.not_started"); possibleStates.remove("closed.complete"); - possibleStates.remove("closed.terminated"); + possibleStates.remove("closed.terminated"); return possibleStates; } return new ArrayList(); @@ -288,15 +288,15 @@ public void abort() throws WfException, CannotStop, NotRunning { Debug.logInfo("Aborting current state : " + state(), module); String stateStr = "closed.aborted"; - + if (!state().startsWith("open")) { throw new NotRunning(); } - + if (!validStates().contains(stateStr)) { throw new CannotStop(); } - + changeState(stateStr); } @@ -345,14 +345,14 @@ /** * @see org.ofbiz.workflow.WfExecutionObject#setProcessContext(java.util.Map) */ - public void setProcessContext(Map newValue) throws WfException, InvalidData, UpdateNotAllowed { + public void setProcessContext(Map newValue) throws WfException, InvalidData, UpdateNotAllowed { setSerializedData(newValue); } /** * @see org.ofbiz.workflow.WfExecutionObject#setProcessContext(java.lang.String) */ - public void setProcessContext(String contextKey) throws WfException, InvalidData, UpdateNotAllowed { + public void setProcessContext(String contextKey) throws WfException, InvalidData, UpdateNotAllowed { GenericValue dataObject = getRuntimeObject(); try { @@ -463,7 +463,7 @@ } } else { changeState("open.running"); - } + } } /** @@ -478,7 +478,7 @@ /** * @see org.ofbiz.workflow.WfExecutionObject#changeState(java.lang.String) */ - public void changeState(String newState) throws WfException, InvalidState, TransitionNotAllowed { + public void changeState(String newState) throws WfException, InvalidState, TransitionNotAllowed { // Test is transaction is allowed??? GenericValue dataObject = getRuntimeObject(); @@ -500,7 +500,7 @@ /** * @see org.ofbiz.workflow.WfExecutionObject#suspend() */ - public void suspend() throws WfException, CannotSuspend, NotRunning, AlreadySuspended { + public void suspend() throws WfException, CannotSuspend, NotRunning, AlreadySuspended { changeState("open.not_running.suspended"); } @@ -623,7 +623,7 @@ } return context; } - + private GenericValue getWorkEffort(String workEffortId) throws WfException { GenericValue we = null; try { @@ -633,14 +633,14 @@ } return we; } - + /** * Evaluate a condition expression using an implementation of TransitionCondition * @param className The class name of the TransitionCondition implementation * @param expression The expression to evaluate * @return The result of the evaluation (True/False) * @throws WfException - */ + */ protected boolean evalConditionClass(String className, String expression, Map context, Map attrs) throws WfException { // attempt to load and instance of the class Object conditionObject = null; @@ -648,41 +648,41 @@ conditionObject = ObjectType.getInstance(className); } catch (ClassNotFoundException e) { Debug.logError(e, "Cannot load class " + className, module); - return false; + return false; } catch (InstantiationException e) { Debug.logError(e, "Cannot get instance of class " + className, module); - return false; + return false; } catch (IllegalAccessException e) { Debug.logError(e, "Cannot access class " + className, module); - return false; + return false; } - + // make sure we implement the TransitionCondition interface if (!ObjectType.instanceOf(conditionObject, "org.ofbiz.workflow.TransitionCondition")) { Debug.logError("Class " + className + " is not an instance of TransitionCondition", module); return false; } - + // cast to the interface TransitionCondition cond = (TransitionCondition) conditionObject; - + // trim up the expression if it isn't empty if (expression != null) expression = expression.trim(); - + // get a DispatchContext object to pass over to the eval DispatchContext dctx = this.getDispatcher().getDispatchContext(); - + // evaluate the condition - Boolean evaluation = null; - try { + Boolean evaluation = null; + try { evaluation = cond.evaluateCondition(context, attrs, expression, dctx); } catch (EvaluationException e) { throw new WfException("Problems evaluating condition", e); } - - return evaluation.booleanValue(); - } + + return evaluation.booleanValue(); + } /** * Evaluate a condition expression using BeanShell @@ -696,7 +696,7 @@ Debug.logVerbose("Null or empty expression, returning true.", module); return true; } - + Object o = null; try { o = BshUtil.eval(expression.trim(), context); Modified: ofbiz/trunk/specialpurpose/workflow/src/org/ofbiz/workflow/impl/WfProcessImpl.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/workflow/src/org/ofbiz/workflow/impl/WfProcessImpl.java?rev=757110&r1=757109&r2=757110&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/workflow/src/org/ofbiz/workflow/impl/WfProcessImpl.java (original) +++ ofbiz/trunk/specialpurpose/workflow/src/org/ofbiz/workflow/impl/WfProcessImpl.java Sun Mar 22 00:38:34 2009 @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -65,15 +65,15 @@ public static final String module = WfProcessImpl.class.getName(); protected WfRequester requester = null; - protected WfProcessMgr manager = null; - + protected WfProcessMgr manager = null; + public WfProcessImpl(GenericValue valueObject, WfProcessMgr manager) throws WfException { super(valueObject, null); - this.manager = manager; + this.manager = manager; this.requester = null; init(); } - + /** * @see org.ofbiz.workflow.impl.WfExecutionObjectImpl#WfExecutionObjectImpl(org.ofbiz.entity.GenericDelegator, java.lang.String) */ @@ -82,14 +82,14 @@ if (activityId != null && activityId.length() > 0) throw new WfException("Execution object is not of type WfProcess."); this.manager = WfFactory.getWfProcessMgr(delegator, packageId, packageVersion, processId, processVersion); - this.requester = null; + this.requester = null; } - + private void init() throws WfException { // since we are a process we don't have a context yet // get the context to use with parsing descriptions from the manager Map context = manager.getInitialContext(); - this.parseDescriptions(context); + this.parseDescriptions(context); } /** @@ -109,28 +109,28 @@ return new ArrayList(activeSteps().subList(0, maxNumber - 1)); return activeSteps(); } - + /** * @see org.ofbiz.workflow.WfExecutionObject#abort() */ public void abort() throws WfException, CannotStop, NotRunning { super.abort(); - + // cancel the active activities Iterator activities = this.activeSteps().iterator(); while (activities.hasNext()) { WfActivity activity = (WfActivity) activities.next(); activity.abort(); - } + } } - + /** * @see org.ofbiz.workflow.WfProcess#start() */ public void start() throws WfException, CannotStart, AlreadyRunning { start(null); } - + /** * @see org.ofbiz.workflow.WfProcess#start() */ @@ -149,11 +149,11 @@ try { if (activityId != null) { GenericValue processDef = getDefinitionObject(); - Map fields = UtilMisc.toMap("packageId", processDef.getString("packageId"), "packageVersion", - processDef.getString("packageVersion"), "processId", processDef.getString("processId"), - "processVersion", processDef.getString("processVersion"), "activityId", activityId); + Map fields = UtilMisc.toMap("packageId", processDef.getString("packageId"), "packageVersion", + processDef.getString("packageVersion"), "processId", processDef.getString("processId"), + "processVersion", processDef.getString("processVersion"), "activityId", activityId); start = getDelegator().findByPrimaryKey("WorkflowActivity", fields); - + // here we must check and make sure this activity is defined to as a starting activity if (!start.getBoolean("canStart").booleanValue()) throw new CannotStart("The specified activity cannot initiate the workflow process"); @@ -168,9 +168,9 @@ if (start == null) throw new CannotStart("No initial activity available"); - if (Debug.verboseOn()) + if (Debug.verboseOn()) Debug.logVerbose("[WfProcess.start] : Started the workflow process.", module); - + // set the actualStartDate try { GenericValue v = getRuntimeObject(); @@ -179,38 +179,38 @@ } catch (GenericEntityException e) { Debug.logWarning("Could not set 'actualStartDate'.", module); e.printStackTrace(); - } + } startActivity(start); } - + /** * @see org.ofbiz.workflow.WfProcess#manager() */ public WfProcessMgr manager() throws WfException { return manager; } - + /** * @see org.ofbiz.workflow.WfProcess#requester() */ public WfRequester requester() throws WfException { return requester; } - + /** * @see org.ofbiz.workflow.WfProcess#getIteratorStep() */ public Iterator getIteratorStep() throws WfException { return activeSteps().iterator(); } - + /** * @see org.ofbiz.workflow.WfProcess#isMemberOfStep(org.ofbiz.workflow.WfActivity) */ public boolean isMemberOfStep(WfActivity member) throws WfException { return activeSteps().contains(member); } - + /** * @see org.ofbiz.workflow.WfProcess#getActivitiesInState(java.lang.String) */ @@ -226,7 +226,7 @@ } return res.iterator(); } - + /** * @see org.ofbiz.workflow.WfProcess#result() */ @@ -248,14 +248,14 @@ } return results; } - + /** * @see org.ofbiz.workflow.WfProcess#howManyStep() */ public int howManyStep() throws WfException { return activeSteps().size(); } - + /** * @see org.ofbiz.workflow.WfProcess#receiveResults(org.ofbiz.workflow.WfActivity, java.util.Map) */ @@ -264,7 +264,7 @@ context.putAll(results); setSerializedData(context); } - + /** * @see org.ofbiz.workflow.WfProcess#activityComplete(org.ofbiz.workflow.WfActivity) */ @@ -316,7 +316,7 @@ joinTransition(toActivity, trans); } } else { - if (Debug.verboseOn()) + if (Debug.verboseOn()) Debug.logVerbose("[WfProcess.queueNext] : No transitions left to follow.", module); this.finishProcess(); } @@ -384,34 +384,34 @@ GenericResultWaiter req = new GenericResultWaiter(); if (Debug.verboseOn()) Debug.logVerbose("[WfProcess.startActivity] : Attempting to start activity (" + activity.name() + ")", module); - + // locate the dispatcher to use LocalDispatcher dispatcher = this.getDispatcher(); - + // get the job manager JobManager jm = dispatcher.getJobManager(); if (jm == null) { throw new WfException("No job manager found on the service dispatcher; cannot start activity"); } - - // using the StartActivityJob class to run the activity within its own thread - try { - Job activityJob = new StartActivityJob(activity, req); - jm.runJob(activityJob); + + // using the StartActivityJob class to run the activity within its own thread + try { + Job activityJob = new StartActivityJob(activity, req); + jm.runJob(activityJob); } catch (JobManagerException e) { throw new WfException("JobManager error", e); } - - // the GenericRequester object will hold any exceptions; and report the job as failed + + // the GenericRequester object will hold any exceptions; and report the job as failed if (req.status() == GenericResultWaiter.SERVICE_FAILED) { Throwable reqt = req.getThrowable(); if (reqt instanceof CannotStart) Debug.logVerbose("[WfProcess.startActivity] : Cannot start activity. Waiting for manual start.", module); else if (reqt instanceof AlreadyRunning) throw new WfException("Activity already running", reqt); - else + else throw new WfException("Activity error", reqt); - } + } } // Determine the next activity or activities @@ -434,8 +434,8 @@ // the default value is TRUE, so if no expression is supplied we evaluate as true boolean transitionOk = true; - - // the otherwise condition (only used by XOR splits) + + // the otherwise condition (only used by XOR splits) GenericValue otherwise = null; // iterate through the possible transitions @@ -449,24 +449,24 @@ otherwise = transition; continue; } - + // get the condition body from the condition tag String conditionBody = transition.getString("conditionExpr"); - + // get the extended attributes for the transition - Map extendedAttr = StringUtil.strToMap(transition.getString("extendedAttributes")); - + Map extendedAttr = StringUtil.strToMap(transition.getString("extendedAttributes")); + // check for a conditionClassName attribute if exists use it if (extendedAttr != null && extendedAttr.get("conditionClassName") != null) { - String conditionClassName = (String) extendedAttr.get("conditionClassName"); - transitionOk = this.evalConditionClass(conditionClassName, conditionBody, this.processContext(), extendedAttr); + String conditionClassName = (String) extendedAttr.get("conditionClassName"); + transitionOk = this.evalConditionClass(conditionClassName, conditionBody, this.processContext(), extendedAttr); } else { // since no condition class is supplied, evaluate the expression using bsh if (conditionBody != null) { transitionOk = this.evalBshCondition(conditionBody, this.processContext()); } } - + if (transitionOk) { transList.add(transition); if (split.equals("WST_XOR")) 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=757110&r1=757109&r2=757110&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 Sun Mar 22 00:38:34 2009 @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -54,14 +54,14 @@ public static final String module = WfProcessMgrImpl.class.getName(); 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 Map contextSignature = null; protected Map resultSignature = null; protected Map initialContext = null; - + /** * Method WfProcessMgrImpl. * @param delegator @@ -70,7 +70,7 @@ * @param processId * @param processVersion * @throws WfException - */ + */ public WfProcessMgrImpl(GenericDelegator delegator, String packageId, String packageVersion, String processId, String processVersion) throws WfException { Map finder = UtilMisc.toMap("packageId", packageId, "processId", processId); @@ -99,7 +99,7 @@ /** * @see org.ofbiz.workflow.WfProcessMgr#setProcessMgrState(java.lang.String) */ - public void setProcessMgrState(String newState) throws WfException, TransitionNotAllowed { + public void setProcessMgrState(String newState) throws WfException, TransitionNotAllowed { if (!newState.equals("enabled") || !newState.equals("disabled")) throw new TransitionNotAllowed(); this.state = newState; @@ -117,8 +117,8 @@ /** * @see org.ofbiz.workflow.WfProcessMgr#createProcess(org.ofbiz.workflow.WfRequester) */ - public WfProcess createProcess(WfRequester requester) throws WfException, NotEnabled, - InvalidRequester, RequesterRequired { + public WfProcess createProcess(WfRequester requester) throws WfException, NotEnabled, + InvalidRequester, RequesterRequired { if (state.equals("disabled")) throw new NotEnabled(); @@ -140,11 +140,11 @@ /** * @see org.ofbiz.workflow.WfProcessMgr#contextSignature() - */ + */ public Map contextSignature() throws WfException { return this.contextSignature; } - + /** * @see org.ofbiz.workflow.WfProcessMgr#howManyProcess() */ @@ -194,7 +194,7 @@ public Map resultSignature() throws WfException { return this.resultSignature; } - + /** * Method getInitialContext. * @return Map @@ -252,7 +252,7 @@ resultSignature.put(name, WfUtil.getJavaType(type)); } } - + private void buildInitialContext() throws WfException { GenericDelegator delegator = processDef.getDelegator(); this.initialContext = new HashMap(); @@ -262,18 +262,18 @@ Map fields = new HashMap(); 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_"); + fields.put("processVersion", "_NA_"); List 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); - dataFields.addAll(data2); + dataFields.addAll(data2); } catch (GenericEntityException e) { throw new WfException(e.getMessage(), e); } @@ -281,19 +281,19 @@ return; Iterator i = dataFields.iterator(); - + while (i.hasNext()) { GenericValue dataField = (GenericValue) i.next(); - String name = dataField.getString("dataFieldName"); + String name = dataField.getString("dataFieldName"); String type = dataField.getString("dataTypeEnumId"); String value = dataField.getString("initialValue"); - - try { - initialContext.put(name, ObjectType.simpleTypeConvert(value, WfUtil.getJavaType(type), null, null)); + + try { + initialContext.put(name, ObjectType.simpleTypeConvert(value, WfUtil.getJavaType(type), null, null)); } catch (GeneralException e) { throw new WfException(e.getMessage(), e); - } + } } - } + } } 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=757110&r1=757109&r2=757110&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 Sun Mar 22 00:38:34 2009 @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -43,11 +43,11 @@ * WfRequesterImpl - Workflow Requester implementation */ public class WfRequesterImpl implements WfRequester { - + public static final String module = WfRequesterImpl.class.getName(); protected Map performers = null; - + /** * Method WfRequesterImpl. */ @@ -57,7 +57,7 @@ /** * @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 { if (process == null) throw new WfException("Process cannot be null"); @@ -75,15 +75,15 @@ throw new WfException("Context passed does not validate against defined signature: ", e); } - // Set the context w/ the process + // Set the context w/ the process Map localContext = new HashMap(context); localContext.putAll(mgr.getInitialContext()); - process.setProcessContext(localContext); - + process.setProcessContext(localContext); + // Set the source reference id if one was passed GenericValue processDefinition = process.getDefinitionObject(); String sourceReferenceField = processDefinition.getString("sourceReferenceField"); - if (context.containsKey(sourceReferenceField)) { + if (context.containsKey(sourceReferenceField)) { GenericValue processObj = process.getRuntimeObject(); if (processObj != null) { try { @@ -94,23 +94,23 @@ } } } - + } /** * @see org.ofbiz.workflow.WfRequester#howManyPerformer() - */ + */ public int howManyPerformer() throws WfException { return performers.size(); } - + /** * @see org.ofbiz.workflow.WfRequester#getIteratorPerformer() */ public Iterator getIteratorPerformer() throws WfException { return performers.keySet().iterator(); } - + /** * @see org.ofbiz.workflow.WfRequester#getSequencePerformer(int) */ @@ -119,14 +119,14 @@ return new ArrayList(performers.keySet()).subList(0, (maxNumber - 1)); return new ArrayList(performers.keySet()); } - + /** * @see org.ofbiz.workflow.WfRequester#isMemberOfPerformer(org.ofbiz.workflow.WfProcess) */ public boolean isMemberOfPerformer(WfProcess member) throws WfException { return performers.containsKey(member); } - + /** * @see org.ofbiz.workflow.WfRequester#receiveEvent(org.ofbiz.workflow.WfEventAudit) */ 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=757110&r1=757109&r2=757110&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 Sun Mar 22 00:38:34 2009 @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -83,7 +83,7 @@ if (roleTypeId == null) roleTypeId = "_NA_"; } - + /** * @see org.ofbiz.workflow.WfResource#howManyWorkItem() */ @@ -97,7 +97,7 @@ public Iterator getIteratorWorkItem() throws WfException { return workItems().iterator(); } - + /** * @see org.ofbiz.workflow.WfResource#getSequenceWorkItem(int) */ |
Free forum by Nabble | Edit this page |