Package org.apache.lenya.workflow

Examples of org.apache.lenya.workflow.WorkflowInstance


            PageEnvelope envelope = PageEnvelopeFactory.getInstance().getPageEnvelope(objectModel);
            Document document = envelope.getDocument();

            WorkflowFactory factory = WorkflowFactory.newInstance();
            if (factory.hasWorkflow(document)) {
                WorkflowInstance instance = factory.buildInstance(document);
                if (name.equals(STATE)) {
                    value = instance.getCurrentState().toString();
                }
                else if (name.startsWith(VARIABLE_PREFIX)) {
                    String variableName = name.substring(VARIABLE_PREFIX.length());
                    String[] variableNames = instance.getWorkflow().getVariableNames();
                    if (Arrays.asList(variableNames).contains(variableName)) {
                        value = Boolean.valueOf(instance.getValue(variableName));
                    }
                }
                else if (name.equals(HISTORY_PATH)) {
                    value = ((CMSHistory) WorkflowFactory.getHistory(document)).getHistoryPath();
                }
View Full Code Here


        Situation situation = factory.buildSituation(emptyRoles, "test", "127.0.0.1");

        WorkflowFactory.initHistory(document, workflowId, situation);

        for (int situationIndex = 0; situationIndex < situations.length; situationIndex++) {
            WorkflowInstance instance = null;
            instance = factory.buildInstance(document);
            assertNotNull(instance);

            System.out.println("Current state: " + instance.getCurrentState());

            Identity identity = new Identity();
            User user =
                getAccreditableManager().getUserManager().getUser(
                    situations[situationIndex].getUser());
            identity.addIdentifiable(user);

            Role[] roles = policy.getRoles(identity);
            System.out.print("Roles:");

            for (int roleIndex = 0; roleIndex < roles.length; roleIndex++) {
                System.out.print(" " + roles[roleIndex]);
            }

            System.out.println();

            situation = null;

            try {
                situation = factory.buildSituation(roles, identity);
            } catch (WorkflowException e1) {
                e1.printStackTrace(System.err);
            }

            Event[] events = instance.getExecutableEvents(situation);

            Event event = null;
            System.out.print("Events:");

            for (int eventIndex = 0; eventIndex < events.length; eventIndex++) {
                System.out.print(" " + events[eventIndex]);

                if (events[eventIndex].getName().equals(situations[situationIndex].getEvent())) {
                    event = events[eventIndex];
                }
            }

            assertNotNull(event);
            System.out.println();

            System.out.println("Executing event: " + event);
            instance.invoke(situation, event);

            assertTrue(instance.getValue(variableName) == situations[situationIndex].getValue());

            System.out.println(
                "Variable: " + variableName + " = " + instance.getValue(variableName));
            System.out.println("------------------------------------------------------");
        }

        System.out.println("Test completed.");
    }
View Full Code Here


            String[] emptyRoles = {};
            Situation situation = new CMSSituation(emptyRoles, "test", "127.0.0.1");

            WorkflowInstance instance = resolver.getWorkflowInstance(document);
            instance.getHistory().initialize(situation);

            for (int situationIndex = 0; situationIndex < situations.length; situationIndex++) {
                assertNotNull(instance);

                System.out.println("Current state: " + instance.getCurrentState());

                Identity identity = new Identity();
                User user = getAccreditableManager().getUserManager().getUser(
                        situations[situationIndex].getUser());
                identity.addIdentifiable(user);

                Role[] roles = policy.getRoles(identity);
                System.out.print("Roles:");

                for (int roleIndex = 0; roleIndex < roles.length; roleIndex++) {
                    System.out.print(" " + roles[roleIndex]);
                }

                System.out.println();
               
                String[] roleIds = new String[roles.length];
                for (int i = 0; i < roles.length; i++) {
                    roleIds[i] = roles[i].getId();
                }

                situation = new CMSSituation(roleIds, identity.getUser().getId(), "");

                String[] events = instance.getExecutableEvents(situation);

                String event = null;
                System.out.print("Events:");

                for (int eventIndex = 0; eventIndex < events.length; eventIndex++) {
                    System.out.print(" " + events[eventIndex]);

                    if (events[eventIndex].equals(situations[situationIndex].getEvent())) {
                        event = events[eventIndex];
                    }
                }

                assertNotNull(event);
                System.out.println();

                System.out.println("Executing event: " + event);
                instance.invoke(situation, event);

                assertTrue(instance.getValue(variableName) == situations[situationIndex].getValue());

                System.out.println("Variable: " + variableName + " = "
                        + instance.getValue(variableName));
                System.out.println("------------------------------------------------------");
            }
        }
        finally {
//            this.manager.release(resolver);
View Full Code Here

        Situation situation = factory.buildSituation(emptyRoles, "test", "127.0.0.1");

        WorkflowFactory.initHistory(document, workflowId, situation);

        for (int situationIndex = 0; situationIndex < situations.length; situationIndex++) {
            WorkflowInstance instance = null;
            instance = factory.buildInstance(document);
            assertNotNull(instance);

            System.out.println("Current state: " + instance.getCurrentState());

            Identity identity = new Identity();
            User user =
                getAccreditableManager().getUserManager().getUser(
                    situations[situationIndex].getUser());
            identity.addIdentifiable(user);

            Role[] roles = policy.getRoles(identity);
            System.out.print("Roles:");

            for (int roleIndex = 0; roleIndex < roles.length; roleIndex++) {
                System.out.print(" " + roles[roleIndex]);
            }

            System.out.println();

            situation = null;

            try {
                situation = factory.buildSituation(roles, identity);
            } catch (WorkflowException e1) {
                e1.printStackTrace(System.err);
            }

            Event[] events = instance.getExecutableEvents(situation);

            Event event = null;
            System.out.print("Events:");

            for (int eventIndex = 0; eventIndex < events.length; eventIndex++) {
                System.out.print(" " + events[eventIndex]);

                if (events[eventIndex].getName().equals(situations[situationIndex].getEvent())) {
                    event = events[eventIndex];
                }
            }

            assertNotNull(event);
            System.out.println();

            System.out.println("Executing event: " + event);
            instance.invoke(situation, event);

            assertTrue(instance.getValue(variableName) == situations[situationIndex].getValue());

            System.out.println(
                "Variable: " + variableName + " = " + instance.getValue(variableName));
            System.out.println("------------------------------------------------------");
        }

        System.out.println("Test completed.");
    }
View Full Code Here

        Situation situation = factory.buildSituation(emptyRoles, "test", "127.0.0.1");

        WorkflowFactory.initHistory(document, workflowId, situation);

        for (int situationIndex = 0; situationIndex < situations.length; situationIndex++) {
            WorkflowInstance instance = null;
            instance = factory.buildInstance(document);
            assertNotNull(instance);

            System.out.println("Current state: " + instance.getCurrentState());

            Identity identity = new Identity();
            User user =
                getAccreditableManager().getUserManager().getUser(
                    situations[situationIndex].getUser());
            identity.addIdentifiable(user);

            Role[] roles = policy.getRoles(identity);
            System.out.print("Roles:");

            for (int roleIndex = 0; roleIndex < roles.length; roleIndex++) {
                System.out.print(" " + roles[roleIndex]);
            }

            System.out.println();

            situation = null;

            try {
                situation = factory.buildSituation(roles, identity);
            } catch (WorkflowException e1) {
                e1.printStackTrace(System.err);
            }

            Event[] events = instance.getExecutableEvents(situation);

            Event event = null;
            System.out.print("Events:");

            for (int eventIndex = 0; eventIndex < events.length; eventIndex++) {
                System.out.print(" " + events[eventIndex]);

                if (events[eventIndex].getName().equals(situations[situationIndex].getEvent())) {
                    event = events[eventIndex];
                }
            }

            assertNotNull(event);
            System.out.println();

            System.out.println("Executing event: " + event);
            instance.invoke(situation, event);

            assertTrue(instance.getValue(variableName) == situations[situationIndex].getValue());

            System.out.println(
                "Variable: " + variableName + " = " + instance.getValue(variableName));
            System.out.println("------------------------------------------------------");
        }

        System.out.println("Test completed.");
    }
View Full Code Here

            PageEnvelope envelope = PageEnvelopeFactory.getInstance().getPageEnvelope(objectModel);
            Document document = envelope.getDocument();

            WorkflowFactory factory = WorkflowFactory.newInstance();
            if (factory.hasWorkflow(document)) {
                WorkflowInstance instance = factory.buildInstance(document);
                if (name.equals(STATE)) {
                    value = instance.getCurrentState().toString();
                }
                else if (name.startsWith(VARIABLE_PREFIX)) {
                    String variableName = name.substring(VARIABLE_PREFIX.length());
                    String[] variableNames = instance.getWorkflow().getVariableNames();
                    if (Arrays.asList(variableNames).contains(variableName)) {
                        value = new Boolean(instance.getValue(variableName));
                    }
                }
                else if (name.equals(HISTORY_PATH)) {
                    value = ((CMSHistory) WorkflowFactory.getHistory(document)).getHistoryPath();
                }
View Full Code Here

            PageEnvelope envelope = PageEnvelopeFactory.getInstance().getPageEnvelope(objectModel);
            Document document = envelope.getDocument();

            WorkflowFactory factory = WorkflowFactory.newInstance();
            if (factory.hasWorkflow(document)) {
                WorkflowInstance instance = factory.buildInstance(document);
                if (name.equals(STATE)) {
                    value = instance.getCurrentState().toString();
                }
                else if (name.startsWith(VARIABLE_PREFIX)) {
                    String variableName = name.substring(VARIABLE_PREFIX.length());
                    String[] variableNames = instance.getWorkflow().getVariableNames();
                    if (Arrays.asList(variableNames).contains(variableName)) {
                        value = Boolean.valueOf(instance.getValue(variableName));
                    }
                }
                else if (name.equals(HISTORY_PATH)) {
                    value = ((CMSHistory) WorkflowFactory.getHistory(document)).getHistoryPath();
                }
View Full Code Here

        Situation situation = factory.buildSituation(emptyRoles, "test", "127.0.0.1");

        WorkflowFactory.initHistory(document, workflowId, situation);

        for (int situationIndex = 0; situationIndex < situations.length; situationIndex++) {
            WorkflowInstance instance = null;
            instance = factory.buildInstance(document);
            assertNotNull(instance);

            System.out.println("Current state: " + instance.getCurrentState());

            Identity identity = new Identity();
            User user =
                getAccreditableManager().getUserManager().getUser(
                    situations[situationIndex].getUser());
            identity.addIdentifiable(user);

            Role[] roles = policy.getRoles(identity);
            System.out.print("Roles:");

            for (int roleIndex = 0; roleIndex < roles.length; roleIndex++) {
                System.out.print(" " + roles[roleIndex]);
            }

            System.out.println();

            situation = null;

            try {
                situation = factory.buildSituation(roles, identity);
            } catch (WorkflowException e1) {
                e1.printStackTrace(System.err);
            }

            Event[] events = instance.getExecutableEvents(situation);

            Event event = null;
            System.out.print("Events:");

            for (int eventIndex = 0; eventIndex < events.length; eventIndex++) {
                System.out.print(" " + events[eventIndex]);

                if (events[eventIndex].getName().equals(situations[situationIndex].getEvent())) {
                    event = events[eventIndex];
                }
            }

            assertNotNull(event);
            System.out.println();

            System.out.println("Executing event: " + event);
            instance.invoke(situation, event);

            assertTrue(instance.getValue(variableName) == situations[situationIndex].getValue());

            System.out.println(
                "Variable: " + variableName + " = " + instance.getValue(variableName));
            System.out.println("------------------------------------------------------");
        }

        System.out.println("Test completed.");
    }
View Full Code Here

            PageEnvelope envelope = PageEnvelopeFactory.getInstance().getPageEnvelope(objectModel);
            Document document = envelope.getDocument();

            WorkflowFactory factory = WorkflowFactory.newInstance();
            if (factory.hasWorkflow(document)) {
                WorkflowInstance instance = factory.buildInstance(document);
                if (name.equals(STATE)) {
                    value = instance.getCurrentState().toString();
                }
                else if (name.startsWith(VARIABLE_PREFIX)) {
                    String variableName = name.substring(VARIABLE_PREFIX.length());
                    String[] variableNames = instance.getWorkflow().getVariableNames();
                    if (Arrays.asList(variableNames).contains(variableName)) {
                        value = new Boolean(instance.getValue(variableName));
                    }
                }
                else if (name.equals(HISTORY_PATH)) {
                    value = ((CMSHistory) WorkflowFactory.getHistory(document)).getHistoryPath();
                }
View Full Code Here

TOP

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

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.