Package org.ofbiz.workflow

Examples of org.ofbiz.workflow.WfActivity


        }
    }

    // Activates an activity object
    private void startActivity(GenericValue value) throws WfException {
        WfActivity activity = WfFactory.getWfActivity(value, workEffortId);
        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
View Full Code Here


     * @param append Append this assignment to the list, if others exist.
     * @return The new assignment object.
     * @throws WfException
     */
    public WfAssignment assign(String workEffortId, String partyId, String roleTypeId, Timestamp fromDate, boolean append) throws WfException {
        WfActivity activity = WfFactory.getWfActivity(delegator, workEffortId);
        WfResource resource = WfFactory.getWfResource(delegator, null, null, partyId, roleTypeId);

        if (!append) {
            Iterator<WfAssignment> i = activity.getIteratorAssignment();
            while (i.hasNext()) {
                WfAssignment a = i.next();
                a.remove();
            }
        }
View Full Code Here

     * @param toFromDate The new delegated assignment fromDate.
     * @return The new assignment object.
     * @throws WfException
     */
    public WfAssignment delegate(String workEffortId, String fromPartyId, String fromRoleTypeId, Timestamp fromFromDate, String toPartyId, String toRoleTypeId, Timestamp toFromDate) throws WfException {
        WfActivity activity = WfFactory.getWfActivity(delegator, workEffortId);
        WfAssignment fromAssign = null;

        // check status and delegateAfterStart attribute
        if (activity.state().equals("open.running") && !activity.getDefinitionObject().getBoolean("delegateAfterStart").booleanValue())
            throw new WfException("This activity cannot be delegated once it has been started");

        if (fromPartyId == null && fromRoleTypeId == null && fromFromDate == null) {
            Iterator<WfAssignment> i = activity.getIteratorAssignment();
            fromAssign = i.next();
            if (i.hasNext()) {
                throw new WfException("Cannot locate the assignment to delegate from, there is more then one " +
                        "assignment for this activity.");
            }
        }

        if (fromAssign == null) {
            fromAssign = WfFactory.getWfAssignment(delegator, workEffortId, fromPartyId, fromRoleTypeId, fromFromDate);
        }
        fromAssign.delegate();

        // check for a restartOnDelegate
        WfActivity newActivity = null;
        if (activity.getDefinitionObject().getBoolean("restartOnDelegate").booleanValue()) {
            // this only applies to running single assignment activities
            if (activity.state().equals("open.running") && activity.howManyAssignment() == 0) {
                try {
                    activity.abort();
                } catch (CannotStop cs) {
                    throw new WfException("Cannot stop the current activity");
                } catch (NotRunning nr) {
                    throw new WfException("Current activity is not running; cannot abort");
                }
                String parentProcessId = activity.container().runtimeKey();
                newActivity = WfFactory.getWfActivity(activity.getDefinitionObject(), parentProcessId);
            }
        }

        WfAssignment assign = null;
        if (newActivity != null) {
            assign = assign(newActivity.runtimeKey(), toPartyId, toRoleTypeId, toFromDate, true);
        } else {
            assign = assign(workEffortId, toPartyId, toRoleTypeId, toFromDate, true);
        }

        return assign;
View Full Code Here

    public void start(String workEffortId) throws WfException {
        if (dispatcher == null) {
            throw new WfException("LocalDispatcher is null; cannot create job for activity startup");
        }

        WfActivity activity = WfFactory.getWfActivity(delegator, workEffortId);

        if (Debug.verboseOn()) Debug.logVerbose("Starting activity: " + activity.name(), module);
        if (activityRunning(activity))
            throw new WfException("Activity is already running");

        Job job = new StartActivityJob(activity);
View Full Code Here

     * Suspend an activity
     * @param workEffortId The WorkEffort entity key for the activity object
     * @throws WfException
     */
    public void suspend(String workEffortId) throws WfException {
        WfActivity activity = WfFactory.getWfActivity(delegator, workEffortId);

        if (Debug.verboseOn()) Debug.logVerbose("Suspending activity: " + activity.name(), module);
        if (!activityRunning(activity))
            throw new WfException("Activity is not running");

        activity.suspend();
    }
View Full Code Here

     * Resume an activity
     * @param workEffortId The WorkEffort entity key for the activity object
     * @throws WfException
     */
    public void resume(String workEffortId) throws WfException {
        WfActivity activity = WfFactory.getWfActivity(delegator, workEffortId);

        if (Debug.verboseOn()) Debug.logVerbose("Resuming activity: " + activity.name(), module);
        if (activityRunning(activity))
            throw new WfException("Activity is already running");

        activity.resume();
    }
View Full Code Here

            GenericValue runTime = getRuntimeObject();
            Map<String, Object> context = processContext();

            if (context.containsKey("previousActivity")) {
                String previousActivity = (String) context.get("previousActivity");
                WfActivity pAct = WfFactory.getWfActivity(getDelegator(), previousActivity);

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

        if (!this.status().equals(asgn.status())) {
            return false;
        }

        // different activity = different assignment
        WfActivity thisActivity = this.activity();
        WfActivity compActivity = asgn.activity();
        if ((thisActivity == null && compActivity != null) || (thisActivity != null && compActivity == null)) {
            return false;
        } else {
            String thisKey = thisActivity.runtimeKey();
            String compKey = compActivity.runtimeKey();
            if ((thisKey != null && compKey == null) || (thisKey == null && compKey != null)) {
                return false;
            } else if (thisKey != null && compKey != null && !thisKey.equals(compKey)) {
                return false;
            }
View Full Code Here

        if (!this.status().equals(asgn.status())) {
            return false;
        }

        // different activity = different assignment
        WfActivity thisActivity = this.activity();
        WfActivity compActivity = asgn.activity();
        if ((thisActivity == null && compActivity != null) || (thisActivity != null && compActivity == null)) {
            return false;
        } else {
            String thisKey = thisActivity.runtimeKey();
            String compKey = compActivity.runtimeKey();
            if ((thisKey != null && compKey == null) || (thisKey == null && compKey != null)) {
                return false;
            } else if (thisKey != null && compKey != null && !thisKey.equals(compKey)) {
                return false;
            }
View Full Code Here

            GenericValue runTime = getRuntimeObject();
            Map context = processContext();

            if (context.containsKey("previousActivity")) {
                String previousActivity = (String) context.get("previousActivity");
                WfActivity pAct = WfFactory.getWfActivity(getDelegator(), previousActivity);

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

TOP

Related Classes of org.ofbiz.workflow.WfActivity

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.