Package org.ofbiz.workflow

Examples of org.ofbiz.workflow.WfException


                if (pAct != null) {
                    try {
                        runTime.set("priority", new Long(pAct.priority()));
                        runTime.store();
                    } catch (GenericEntityException e) {
                        throw new WfException(e.getMessage(), e);
                    }
                }
            }
        }

        GenericValue performer = null;
        if (valueObject.get("performerParticipantId") != null) {
            try {
                performer = valueObject.getRelatedOne("PerformerWorkflowParticipant");
                if (performer == null) {
                    Map<String, Object> performerFields = UtilMisc.toMap("packageId", (Object) valueObject.getString("packageId"),
                            "packageVersion", valueObject.getString("packageVersion"), "processId", "_NA_",
                            "processVersion", "_NA_", "participantId", valueObject.getString("performerParticipantId"));
                    performer = delegator.findByPrimaryKey("WorkflowParticipant", performerFields);
                }
            } catch (GenericEntityException e) {
                throw new WfException(e.getMessage(), e);
            }
        }
        if (performer != null)
            createAssignments(performer);
View Full Code Here


                partyType = v1.getRelatedOne("PartyType");
                Map<String, Object> fields2 = UtilMisc.toMap("partyTypeId", (Object) "PARTY_GROUP");
                groupType = getDelegator().findByPrimaryKeyCache("PartyType", fields2);
            } catch (GenericEntityException e) {
                throw new WfException(e.getMessage(), e);
            }
            if (EntityTypeUtil.isType(partyType, groupType)) {
                // party is a group
                List<GenericValue> partyRelations = null;
                try {
                    Map<String, Object> fields = UtilMisc.toMap("partyIdFrom", (Object) performer.getString("partyId"),
                            "partyRelationshipTypeId", "GROUP_ROLLUP");
                    partyRelations = getDelegator().findByAnd("PartyRelationship", fields);
                } catch (GenericEntityException e) {
                    throw new WfException(e.getMessage(), e);
                }

                // make assignments for these parties
                Debug.logVerbose("[WfActivity.createAssignments] : Group assignment", module);
                for (GenericValue value : partyRelations) {
                    assign(
                        WfFactory.getWfResource(getDelegator(), null, null, value.getString("partyIdTo"), null),
                        true);
                }
            } else {
                // not a group
                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_")) {
            List<GenericValue> partyRoles = null;

            try {
                Map<String, Object> fields = UtilMisc.toMap("roleTypeId", (Object) performer.getString("roleTypeId"));
                partyRoles = getDelegator().findByAnd("PartyRole", fields);
            } catch (GenericEntityException e) {
                throw new WfException(e.getMessage(), e);
            }

            // loop through the roles and create assignments
            Debug.logVerbose("[WfActivity.createAssignments] : Role assignment", module);
            for (GenericValue value : partyRoles) {
View Full Code Here

    private List<GenericValue> getAllAssignments() throws WfException {
        List<GenericValue> assignList = null;
        try {
            assignList = getDelegator().findByAnd("WorkEffortPartyAssignment", UtilMisc.toMap("workEffortId", runtimeKey()));
        } catch (GenericEntityException e) {
            throw new WfException(e.getMessage(), e);
        }

        if (assignList != null) {
            assignList = EntityUtil.filterByDate(assignList);
        } else {
View Full Code Here

            if (Debug.verboseOn()) Debug.logVerbose("Dynamic performer: Found a party expression", module);
            Object value = null;
            try {
                value = BshUtil.eval(partyId.trim().substring(5).trim(), context);
            } catch (bsh.EvalError e) {
                throw new WfException("Bsh evaluation error occurred.", e);
            }
            if (value != null) {
                if (value instanceof String) {
                    newPerformer.set("partyId", value);
                } 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);
            } catch (bsh.EvalError e) {
                throw new WfException("Bsh evaluation error occurred.", e);
            }
            if (value != null) {
                if (value instanceof String) {
                    newPerformer.set("roleTypeId", value);
                } else {
                    throw new WfException("Expression did not return a String");
                }
            }
        }

        // check for un-defined party
View Full Code Here

        // check the start mode
        String mode = getDefinitionObject().getString("startModeEnumId");

        if (mode == null) {
            throw new WfException("Start mode cannot be null");
        }

        if (mode.equals("WAM_AUTOMATIC")) {
            Debug.logVerbose("Activity start mode is AUTO", module);
            for (WfAssignment assignment : getAssignments()) {
View Full Code Here

        if (howManyAssignment() > 0 && !checkAssignStatus(CHECK_COMPLETE))
            throw new CannotComplete("All assignments have not been completed");
        try {
            container().receiveResults(this, result());
        } catch (InvalidData e) {
            throw new WfException("Invalid result data was passed", e);
        }
        try {
            changeState("closed.completed");
            GenericValue activityWe = getRuntimeObject();
            activityWe.set("actualCompletionDate", UtilDateTime.nowTimestamp());
            activityWe.store();
        } catch (InvalidState is) {
            throw new WfException("Invalid WF State", is);
        } catch (TransitionNotAllowed tna) {
            throw new WfException(tna.getMessage(), tna);
        } catch (GenericEntityException gee) {
            throw new WfException(gee.getMessage(), gee);
        }

        container().activityComplete(this);
    }
View Full Code Here

        if (type == CHECK_ASSIGN)
            validStatus = UtilMisc.toList("CAL_ACCEPTED", "CAL_COMPLETED", "CAL_DELEGATED");
        else if (type == CHECK_COMPLETE)
            validStatus = UtilMisc.toList("CAL_COMPLETED", "CAL_DELEGATED");
        else
            throw new WfException("Invalid status type");

        boolean foundOne = false;

        for (GenericValue value : this.getAllAssignments()) {
            String party = value.getString("partyId");
View Full Code Here

        // get the type of this activity
        String type = getDefinitionObject().getString("activityTypeEnumId");

        if (type == null)
            throw new WfException("Illegal activity type");

        WfActivityAbstractImplementation executor = WfActivityImplementationFact.getConcretImplementation(type, this);
        executor.run();
        this.setResult(executor.getResult());
        if (executor.isComplete())
View Full Code Here

            case 's' :
                cal.add(Calendar.SECOND, timeLimit.intValue());
                break;

            default :
                throw new WfException("Invalid duration unit");
        }

        long startTime = cal.getTime().getTime();

        Map<String, Object> context = new HashMap<String, Object>();
        context.put("serviceName", limitService);
        context.put("serviceContext", serviceContext);
        context.put("workEffortId", runtimeKey());

        try {
            dispatcher.schedule("wfLimitInvoker", context, startTime); // yes we are hard coded!
        } catch (GenericServiceException e) {
            throw new WfException(e.getMessage(), e);
        }
        if (Debug.verboseOn()) {
            Debug.logVerbose("[WfActivity.setLimitService]: Set limit service (" + limitService + ") to run at " + startTime, module);
        }
    }
View Full Code Here

                if (key != null && key.trim().toLowerCase().startsWith("expr:")) {
                    // check for bsh expressions; this does not place values into the context
                    try {
                        BshUtil.eval(key.trim().substring(5).trim(), context);
                    } catch (bsh.EvalError e) {
                        throw new WfException("Bsh evaluation error.", e);
                    }
                } else if (key != null && key.trim().toLowerCase().startsWith("name:")) {
                    // name mapping of context values
                    List<String> couple = StringUtil.split(key.trim().substring(5).trim(), "=");
                    String mName = couple.get(0); // mapped name
                    String cName = 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)) {
                        actualContext.put(mName, context.get(cName));
                    }
                } else if (context.containsKey(key)) {
                    // direct assignment from context
                    actualContext.put(key, context.get(key));
                } else if (!actualContext.containsKey(key) && !ignoreUnknown) {
                    throw new WfException("Context does not contain the key: '" + key + "'");
                }
            }
        }

        // the serviceSignature should not limit which parameters are in the actualContext
View Full Code Here

TOP

Related Classes of org.ofbiz.workflow.WfException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.