Package org.apache.lenya.workflow

Examples of org.apache.lenya.workflow.Version


        Workflowable workflowable = WorkflowUtil.getWorkflowable(getManager(),
                session,
                getLogger(),
                document);
        if (workflowable.getVersions().length > 0) {
            Version version = workflowable.getLatestVersion();
            if (version.getValue(variableName) == true) {
                invoke(document, deactivateSituation);
            } else if (version.getState().equals("review")) {
                invoke(document, rejectSituation);
            }
        }

        for (int situationIndex = 0; situationIndex < situations.length; situationIndex++) {
View Full Code Here


        entry.setValue(KEY_LAST_MODIFIED, lastModified);

        if (WorkflowUtil.hasWorkflow(this.manager, getSession(), getLogger(), doc)) {
            Workflowable workflowable = WorkflowUtil.getWorkflowable(this.manager,
                    getSession(), getLogger(), doc);
            Version latestVersion = workflowable.getLatestVersion();
            String state;
            if (latestVersion != null) {
                state = latestVersion.getState();
            } else {
                Workflow workflow = WorkflowUtil.getWorkflowSchema(this.manager,
                        getSession(), getLogger(), doc);
                state = workflow.getInitialState();
            }
View Full Code Here

     * @see org.apache.lenya.workflow.Condition#isComplied(org.apache.lenya.workflow.Workflow,
     *      org.apache.lenya.workflow.Situation,
     *      org.apache.lenya.workflow.Workflowable)
     */
public boolean isComplied(Workflow workflow, Situation situation, Workflowable workflowable) throws WorkflowException {
        Version latestVersion = workflowable.getLatestVersion();
        boolean value = false;
        if (latestVersion == null) {
            value = workflow.getInitialValue(getVariableName());
        }
        else {
            value = latestVersion.getValue(getVariableName());
        }
       
        if (getLogger().isDebugEnabled()) {
            getLogger().debug("Checking boolean variable condition");
            getLogger().debug("    Condition value: [" + getValue() + "]");
View Full Code Here

                    getLogger());
            resolver = (WorkflowManager) this.manager.lookup(WorkflowManager.ROLE);
            if (resolver.hasWorkflow(workflowable)) {
                Workflow workflow = resolver.getWorkflowSchema(workflowable);
                String[] variableNames = workflow.getVariableNames();
                Version latestVersion = workflowable.getLatestVersion();
                Boolean isLive = null;
                if (latestVersion != null) {
                    setParameter(STATE, latestVersion.getState());
                    if (Arrays.asList(variableNames).contains(ISLIVE)) {
                        isLive = Boolean.valueOf(latestVersion.getValue(ISLIVE));
                    }
                } else {
                    setParameter(STATE, workflow.getInitialState());
                    if (Arrays.asList(variableNames).contains(ISLIVE)) {
                        isLive = Boolean.valueOf(workflow.getInitialValue(ISLIVE));
View Full Code Here

                    String string = versionStrings[i];
                    int spaceIndex = string.indexOf(" ");
                    String numberString = string.substring(0, spaceIndex);
                    int number = Integer.parseInt(numberString);
                    String versionString = string.substring(spaceIndex + 1);
                    Version version = decodeVersion(versionString);
                    this.versions[number] = version;
                }

            } catch (DocumentException e) {
                throw new RuntimeException();
View Full Code Here

            firingTransition = (Transition) firingTransitions.get(0);
        }

        String destination = firingTransition.getDestination();

        Version newVersion = createNewVersion(workflowable, workflow, event, destination);

        Action[] actions = firingTransition.getActions();
        for (int i = 0; i < actions.length; i++) {
            actions[i].execute(newVersion);
        }
View Full Code Here

    /**
     * @see org.apache.lenya.workflow.Workflowable#getLatestVersion()
     */
    public Version getLatestVersion() {
        Version version = null;
        Version[] versions = getVersions();
        if (versions.length > 0) {
            version = versions[versions.length - 1];
        }
        return version;
View Full Code Here

     * @return A version.
     * @throws WorkflowException if an error occurs.
     */
    protected Version createNewVersion(Workflowable workflowable, Workflow workflow, String event,
            String destination) throws WorkflowException {
        Version latestVersion = workflowable.getLatestVersion();
        Version newVersion = new VersionImpl(event, destination);
        String[] variableNames = workflow.getVariableNames();
        for (int i = 0; i < variableNames.length; i++) {
            String name = variableNames[i];
            boolean value;
            if (latestVersion == null) {
                value = workflow.getInitialValue(name);
            } else {
                value = latestVersion.getValue(name);
            }
            newVersion.setValue(name, value);
        }
        return newVersion;
    }
View Full Code Here

            if (steps[0].equals("var")) {
                String[] nameValue = steps[1].split("=");
                variables.put(nameValue[0], nameValue[1]);
            }
        }
        Version version = new LenyaVersion(event, state);
        for (Iterator i = variables.keySet().iterator(); i.hasNext();) {
            String name = (String) i.next();
            String value = (String) variables.get(name);
            version.setValue(name, Boolean.valueOf(value).booleanValue());
        }
        return version;
    }
View Full Code Here

     * @return A list of transitions.
     * @throws WorkflowException if an error occurs.
     */
    protected List getFiringTransitions(Workflowable workflowable, Workflow workflow,
            Situation situation, String event) throws WorkflowException {
        Version lastVersion = workflowable.getLatestVersion();
       
        String currentState;
        if (lastVersion == null) {
            currentState = workflow.getInitialState();
        }
        else {
            currentState = lastVersion.getState();
        }
       
        Transition[] transitions = workflow.getLeavingTransitions(currentState);
        List firingTransitions = new ArrayList();

View Full Code Here

TOP

Related Classes of org.apache.lenya.workflow.Version

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.