Package org.apache.lenya.workflow

Examples of org.apache.lenya.workflow.Workflow


        assert publication != null;
        assert(workflowFileName != null) && !"".equals(workflowFileName);

        File workflowDirectory = new File(publication.getDirectory(), WORKFLOW_DIRECTORY);
        File workflowFile = new File(workflowDirectory, workflowFileName);
        Workflow workflow = WorkflowBuilder.buildWorkflow(workflowFile);

        return workflow;
    }
View Full Code Here


            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();
            }
            entry.setValue(KEY_WORKFLOW_STATE, state);
        } else {
            entry.setValue(KEY_WORKFLOW_STATE, "");
        }
View Full Code Here

                Workflowable workflowable = WorkflowUtil.getWorkflowable(this.manager,
                        getSession(), getLogger(), doc);
                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(WORKFLOW_VARIABLE_ISLIVE)) {
                            isLive = Boolean.valueOf(latestVersion
                                    .getValue(WORKFLOW_VARIABLE_ISLIVE));
                        }
                    } else {
                        setParameter(STATE, workflow.getInitialState());
                        if (Arrays.asList(variableNames).contains(WORKFLOW_VARIABLE_ISLIVE)) {
                            isLive = Boolean.valueOf(workflow
                                    .getInitialValue(WORKFLOW_VARIABLE_ISLIVE));
                        }
                    }
                    setParameter(ISLIVE, isLive);
                } else {
View Full Code Here

     */
    public void invoke(Workflowable workflowable, String event, boolean force)
            throws WorkflowException {
        if (hasWorkflow(workflowable)) {
            WorkflowEngine engine = new WorkflowEngineImpl();
            Workflow workflow = getWorkflowSchema(workflowable);

            if (force && !engine.canInvoke(workflowable, workflow, event)) {
                throw new WorkflowException("The event [" + event
                        + "] cannot be invoked on the document [" + workflowable + "]");
            }
View Full Code Here

     */
    public boolean canInvoke(Workflowable workflowable, String event) {
        boolean canInvoke = true;
        try {
            if (hasWorkflow(workflowable)) {
                Workflow workflow = getWorkflowSchema(workflowable);
                WorkflowEngine engine = new WorkflowEngineImpl();
                canInvoke = engine.canInvoke(workflowable, workflow, event);
            }
        } catch (Exception e) {
            throw new RuntimeException(e);
View Full Code Here

    public String getState() throws WorkflowException {
        String state;
        if (getWorkflowable().getVersions().length > 0) {
            state = getWorkflowable().getLatestVersion().getState();
        } else {
            Workflow workflow = getWorkflowSchema();
            state = workflow.getInitialState();
        }
        return state;
    }
View Full Code Here

    public String[] getStates() throws WorkflowException {
        return getWorkflowSchema().getStates();
    }

    protected Workflow getWorkflowSchema() throws WorkflowException {
        Workflow workflow = WorkflowUtil.getWorkflowSchema(this.manager, this.session, getLogger(),
                this.document);
        return workflow;
    }
View Full Code Here

                    Version latestVersion = workflowable.getLatestVersion();
                    String state;
                    if (latestVersion != null) {
                        state = latestVersion.getState();
                    } else {
                        Workflow workflow = WorkflowUtil.getWorkflowSchema(this.manager,
                                getSession(), getLogger(), documents[i]);
                        state = workflow.getInitialState();
                    }
                    entry.setValue(KEY_WORKFLOW_STATE, state);
                } else {
                    entry.setValue(KEY_WORKFLOW_STATE, "");
                }
View Full Code Here

                    Version latestVersion = workflowable.getLatestVersion();

                    if (name.equals(STATE)) {
                        if (latestVersion == null) {
                            Workflow workflow = wfManager.getWorkflowSchema(workflowable);
                            value = workflow.getInitialState();
                        } else {
                            value = latestVersion.getState();
                        }
                    } else if (name.startsWith(VARIABLE_PREFIX)) {
                        String variableName = name.substring(VARIABLE_PREFIX.length());
                        Workflow workflow = wfManager.getWorkflowSchema(workflowable);
                        String[] variableNames = workflow.getVariableNames();
                        if (Arrays.asList(variableNames).contains(variableName)) {
                            if (latestVersion == null) {
                                value = Boolean.valueOf(workflow.getInitialValue(variableName));
                            } else {
                                value = Boolean.valueOf(latestVersion.getValue(variableName));
                            }
                        }
                    } else if (name.startsWith(LAST_USER_PREFIX)) {
View Full Code Here

     */
    public void invoke(Workflowable workflowable, String event, boolean force)
            throws WorkflowException {
        if (hasWorkflow(workflowable)) {
            WorkflowEngine engine = new WorkflowEngineImpl();
            Workflow workflow = getWorkflowSchema(workflowable);

            if (force && !engine.canInvoke(workflowable, workflow, event)) {
                throw new WorkflowException("The event [" + event
                        + "] cannot be invoked on the document [" + workflowable + "]");
            }
View Full Code Here

TOP

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

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.