Package org.ofbiz.workflow

Examples of org.ofbiz.workflow.WfException


     * @see org.ofbiz.workflow.impl.WfExecutionObjectImpl#WfExecutionObjectImpl(org.ofbiz.entity.Delegator, java.lang.String)
     */
    public WfProcessImpl(Delegator delegator, String workEffortId) throws WfException {
        super(delegator, workEffortId);
        if (UtilValidate.isNotEmpty(activityId))
            throw new WfException("Execution object is not of type WfProcess.");
        this.manager = WfFactory.getWfProcessMgr(delegator, packageId, packageVersion, processId, processVersion);
        this.requester = null;
    }
View Full Code Here


                // this is either the first activity defined or specified as an ExtendedAttribute
                // since this is defined in XPDL, we don't care if canStart is set.
                start = getDefinitionObject().getRelatedOne("DefaultStartWorkflowActivity");
            }
        } catch (GenericEntityException e) {
            throw new WfException(e.getMessage(), e.getNested());
        }
        if (start == null)
            throw new CannotStart("No initial activity available");

        if (Debug.verboseOn())
View Full Code Here

    /**
     * @see org.ofbiz.workflow.WfProcess#activityComplete(org.ofbiz.workflow.WfActivity)
     */
    public synchronized void activityComplete(WfActivity activity) throws WfException {
        if (!activity.state().equals("closed.completed"))
            throw new WfException("Activity state is not completed");
        if (Debug.verboseOn()) Debug.logVerbose("[WfProcess.activityComplete] : Activity (" + activity.name() + ") is complete", module);
        queueNext(activity);
    }
View Full Code Here

                GenericValue toActivity = null;

                try {
                    toActivity = trans.getRelatedOne("ToWorkflowActivity");
                } catch (GenericEntityException e) {
                    throw new WfException(e.getMessage(), e);
                }

                // check for a join
                String join = "WJT_AND"; // default join is AND
View Full Code Here

       
        List<GenericValue> toTrans = null;
        try {
            toTrans = toActivity.getRelated("ToWorkflowTransition");
        } catch (GenericEntityException e) {
            throw new WfException(e.getMessage(), e);
        }

        // get a list of followed transition to this activity
        List<GenericValue> followed = null;
        try {
            Map<String, Object> fields = new HashMap<String, Object>();
            fields.put("processWorkEffortId", dataObject.getString("workEffortId"));
            fields.put("toActivityId", toActivity.getString("activityId"));
            followed = getDelegator().findByAnd("WorkEffortTransBox", fields);
        } catch (GenericEntityException e) {
            throw new WfException(e.getMessage(), e);
        }

        if (Debug.verboseOn()) Debug.logVerbose("[WfProcess.joinTransition] : toTrans (" + toTrans.size() + ") followed (" +
                (followed.size() + 1) + ")", module);

        // check to see if all transition requirements are met
        if (toTrans.size() == (followed.size() + 1)) {
            Debug.logVerbose("[WfProcess.joinTransition] : All transitions have followed.", module);
            startActivity(toActivity);
            try {
                Map<String, Object> fields = new HashMap<String, Object>();
                fields.put("processWorkEffortId", dataObject.getString("workEffortId"));
                fields.put("toActivityId", toActivity.getString("activityId"));
                getDelegator().removeByAnd("WorkEffortTransBox", fields);
            } catch (GenericEntityException e) {
                throw new WfException(e.getMessage(), e);
            }
        } else {
            Debug.logVerbose("[WfProcess.joinTransition] : Waiting for transitions to finish.", module);
            try {
                Map<String, Object> fields = new HashMap<String, Object>();
                fields.put("processWorkEffortId", dataObject.getString("workEffortId"));
                fields.put("toActivityId", toActivity.getString("activityId"));
                fields.put("transitionId", transition.getString("transitionId"));
                GenericValue obj = getDelegator().makeValue("WorkEffortTransBox", fields);

                getDelegator().create(obj);
            } catch (GenericEntityException e) {
                throw new WfException(e.getMessage(), e);
            }
        }
    }
View Full Code Here

        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);
        } catch (JobManagerException e) {
            throw new WfException("JobManager error", e);
        }

        // 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
                throw new WfException("Activity error", reqt);
        }
    }
View Full Code Here

        // get the from transitions
        List<GenericValue> fromTransitions = null;
        try {
            fromTransitions = fromActivity.getDefinitionObject().getRelated("FromWorkflowTransition");
        } catch (GenericEntityException e) {
            throw new WfException(e.getMessage(), e);
        }

        // check for a split
        String split = "WST_AND"; // default split is AND
View Full Code Here

            WfEventAudit audit = WfFactory.getWfEventAudit(this, null); // this will need to be updated

            try {
                requester.receiveEvent(audit);
            } catch (InvalidPerformer e) {
                throw new WfException(e.getMessage(), e);
            }
        }
    }
View Full Code Here

        List<GenericValue> workEffortList = null;
        try {
            workEffortList = getDelegator().findByAnd("WorkEffort", UtilMisc.toMap("workEffortParentId", runtimeKey()));
        } catch (GenericEntityException e) {
            throw new WfException(e.getMessage(), e);
        }
        if (workEffortList == null) {
            return steps;
        }
       
View Full Code Here

        List<GenericValue> tools = null;
        String allParams = "";
        try {
            tools = getActivity().getDefinitionObject().getRelated("WorkflowActivityTool");
        } catch (GenericEntityException e) {
            throw new WfException(e.getMessage(), e);
        }
        if (tools == null) {
            setComplete(true);
            return; // Null tools mean nothing to do (same as route?)
        }

        if (Debug.verboseOn())
            Debug.logVerbose("[WfActivity.runTool] : Running tools (" + tools.size() + ").", module);
        List<GenericResultWaiter> waiters = new ArrayList<GenericResultWaiter>();
        for (GenericValue thisTool : tools) {
            String serviceName = null;
            String toolId = thisTool.getString("toolId");
            String params = thisTool.getString("actualParameters");
            String toolTypeEnumId = thisTool.getString("toolTypeEnumId");

            allParams = allParams + "," + params;
            String extend = thisTool.getString("extendedAttributes");

            Map<String, String> extendedAttr = StringUtil.strToMap(extend);
            if (extendedAttr != null && extendedAttr.containsKey("serviceName")) {
                serviceName = extendedAttr.get("serviceName");
            }

            serviceName = serviceName != null ? serviceName : (toolTypeEnumId.equals("WTT_APPLICATION") ? "wfActivateApplication" : toolId);
            waiters.add(runService(serviceName, params, extend));
        }

        while (waiters.size() > 0) {
            List<GenericResultWaiter> remove = new ArrayList<GenericResultWaiter>();
            for (GenericResultWaiter thw : waiters) {
                if (thw.isCompleted()) {
                    Map<String, Object> thwResult = null;
                    if (thw.status() == GenericResultWaiter.SERVICE_FINISHED) {
                        thwResult = thw.getResult();
                        Debug.logVerbose("Service finished.", module);
                    } else if (thw.status() == GenericResultWaiter.SERVICE_FAILED) {
                        Debug.logError(thw.getThrowable(), "Service failed", module);
                    }
                    if (thwResult != null && thwResult.containsKey(ModelService.RESPONSE_MESSAGE)) {
                        if (thwResult.get(ModelService.RESPONSE_MESSAGE).equals(ModelService.RESPOND_ERROR)) {
                            String errorMsg = (String) thwResult.remove(ModelService.ERROR_MESSAGE);
                            Debug.logError("Service Error: " + errorMsg, module);
                        }
                        thwResult.remove(ModelService.RESPONSE_MESSAGE);
                    }

                    try {
                        if (thwResult != null)
                            this.setResult(thwResult, allParams);
                    } catch (IllegalStateException e) {
                        throw new WfException("Unknown error", e);
                    }
                    remove.add(thw);
                }
            }
            waiters.removeAll(remove);
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.