Examples of MyHumanChangingValuesSimulatorWorkItemHandler


Examples of com.wordpress.salaboy.example.handlers.MyHumanChangingValuesSimulatorWorkItemHandler

       
        //Creates a new TrackingSystem
        this.trackingSystem = new MyAsyncTrackingSystemMock();
       
        //Work Item Handlers
        humanActivitiesSimHandler = new MyHumanChangingValuesSimulatorWorkItemHandler();
        this.trackingSystem = new MyAsyncTrackingSystemMock();
        AsyncVehicleTrackingMockSystem trackingSystemHandler = new AsyncVehicleTrackingMockSystem(trackingSystem);
       
        Map<String,WorkItemHandler> workItemHandlers = new HashMap<String, WorkItemHandler>();
        workItemHandlers.put("Human Task", humanActivitiesSimHandler);
View Full Code Here

Examples of com.wordpress.salaboy.example.handlers.MyHumanChangingValuesSimulatorWorkItemHandler

        if (ksession == null) {
            //Creates a ksession
            ksession = createSession();
           
            //Registers the handler for "Human Task"
            humanActivitiesSimHandler = new MyHumanChangingValuesSimulatorWorkItemHandler();
            ksession.getWorkItemManager().registerWorkItemHandler("Human Task", humanActivitiesSimHandler);

            //Register the handler for "StartTrackingSystem" Work Item
            AsyncVehicleTrackingMockSystem trackingSystemHandler = new AsyncVehicleTrackingMockSystem(trackingSystem);
            ksession.getWorkItemManager().registerWorkItemHandler("VehicleTrackingSystem", trackingSystemHandler);
View Full Code Here

Examples of com.wordpress.salaboy.example.handlers.MyHumanChangingValuesSimulatorWorkItemHandler

        KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
        kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());


        ksession = kbase.newStatefulKnowledgeSession();
        MyHumanChangingValuesSimulatorWorkItemHandler humanActivitiesSimHandler = new MyHumanChangingValuesSimulatorWorkItemHandler();
        ksession.getWorkItemManager().registerWorkItemHandler("Human Task", humanActivitiesSimHandler);
        MyTrackingSystemMock trackingSystem = new MyTrackingSystemMock();
        StartVehicleTrackingMockSystem trackingSystemHandler = new StartVehicleTrackingMockSystem(trackingSystem);
        ksession.getWorkItemManager().registerWorkItemHandler("VehicleTrackingSystem", trackingSystemHandler);

        KnowledgeRuntimeLoggerFactory.newConsoleLogger(ksession);

      
        Emergency emergency = new Emergency("555-1234");
        emergency.setType("Heart Attack");
        Map<String, Object> parameters = new HashMap<String, Object>();
        parameters.put("emergency", emergency);


        WorkflowProcessInstance process = (WorkflowProcessInstance) ksession
                                            .startProcess("com.wordpress.salaboy.bpmn2.SimpleEmergencyService", parameters);
        // My Emergency and My Process are both inserted as Facts / Truths in my Knowledge Session
        // Now Emergency and the Process Instance can be used by the inference engine
        ksession.insert(emergency);
        ksession.insert(process);
       
        // Is the Process still Active?
        Assert.assertEquals(ProcessInstance.STATE_ACTIVE, process.getState());
        // Is there a running node instance?
        Assert.assertEquals(1, process.getNodeInstances().size());
        // Is the process stopped in the "Ask for Emergency Information" activity?
        Assert.assertEquals("Ask for Emergency Information", process.getNodeInstances().iterator().next().getNodeName());
        // Lets check the value of the emergency.getRevision(), it should be 1
        Assert.assertEquals(1, ((Emergency) process.getVariable("emergency")).getRevision());
       
        System.out.println("Completing the first Activity");
        //Complete the first human activity
        humanActivitiesSimHandler.completeWorkItem();
        // Is the Process still Active?
        Assert.assertEquals(ProcessInstance.STATE_ACTIVE, process.getState());
       
        //I need to call the FireAllRules method because I have a RuleTask inside the business process
        int fired = ksession.fireAllRules();
        // Now that I have rules being evaluated, at least one should fire
        Assert.assertEquals(1, fired);
       
       
        // Lets check the value of the vehicle variable it should be an Ambulance => Heart Attack
        Vehicle selectedVehicle = ((Vehicle) process.getVariable("vehicle"));
        Assert.assertTrue(selectedVehicle instanceof Ambulance);
       
       
        // Is the Process still Active?
        Assert.assertEquals(ProcessInstance.STATE_ACTIVE, process.getState());
        // Is there a running node instance?
        Assert.assertEquals(1, process.getNodeInstances().size());
        // Is the process stopped in the "Dispatch Vehicle" activity?
        Assert.assertEquals("Dispatch Vehicle", process.getNodeInstances().iterator().next().getNodeName());
        // Lets check the value of the emergency.getRevision(), it should be 1
        Assert.assertEquals(2, ((Emergency) process.getVariable("emergency")).getRevision());
       
       
       
        System.out.println("Completing the second Activity");
        //Complete the second human activity
        humanActivitiesSimHandler.completeWorkItem();
       
        //Start Tracking and Reporting are automatic -> Check the report in the console
        //We can also check against the tracking system itself
        Assert.assertEquals("Vehicle "+selectedVehicle.getId()+" Located at 5th and A Avenue"
                                    , trackingSystem.queryVehicleStatus(selectedVehicle.getId()));
View Full Code Here

Examples of com.wordpress.salaboy.example.handlers.MyHumanChangingValuesSimulatorWorkItemHandler

        KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
        kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());


        ksession = kbase.newStatefulKnowledgeSession();
        MyHumanChangingValuesSimulatorWorkItemHandler humanActivitiesSimHandler = new MyHumanChangingValuesSimulatorWorkItemHandler();
        ksession.getWorkItemManager().registerWorkItemHandler("Human Task", humanActivitiesSimHandler);

        KnowledgeRuntimeLoggerFactory.newConsoleLogger(ksession);


        Map<String, Object> parameters = new HashMap<String, Object>();
        parameters.put("emergency", new Emergency("555-1234"));


        WorkflowProcessInstance process = (WorkflowProcessInstance) ksession.startProcess("com.wordpress.salaboy.bpmn2.SimpleEmergencyService", parameters);

        // Is the Process still Active?
        Assert.assertEquals(ProcessInstance.STATE_ACTIVE, process.getState());
        // Is there a running node instance?
        Assert.assertEquals(1, process.getNodeInstances().size());
        // Is the process stopped in the "Ask for Emergency Information" activity?
        Assert.assertEquals("Ask for Emergency Information", process.getNodeInstances().iterator().next().getNodeName());
        // Lets check the value of the emergency.getRevision(), it should be 1
        Assert.assertEquals(1, ((Emergency) process.getVariable("emergency")).getRevision());
       
       
        //Complete the first human activity
        System.out.println("Completing the first Activity");
        humanActivitiesSimHandler.completeWorkItem();
       
        // Is the Process still Active?
        Assert.assertEquals(ProcessInstance.STATE_ACTIVE, process.getState());
       
        //I need to call the FireAllRules method because I have a RuleTask inside the business process
        ksession.fireAllRules();
       
       
        // Is the Process still Active?
        Assert.assertEquals(ProcessInstance.STATE_ACTIVE, process.getState());
        // Is there a running node instance?
        Assert.assertEquals(1, process.getNodeInstances().size());
        // Is the process stopped in the "Dispatch Vehicle" activity?
        Assert.assertEquals("Dispatch Vehicle", process.getNodeInstances().iterator().next().getNodeName());
        // Lets check the value of the emergency.getRevision(), it should be 2, because the work item handler changes it
        Assert.assertEquals(2, ((Emergency) process.getVariable("emergency")).getRevision());
       
        System.out.println("Completing the second Activity");
        //Complete the second human activity
        humanActivitiesSimHandler.completeWorkItem();

        // Is the process completed?
        Assert.assertEquals(ProcessInstance.STATE_COMPLETED, process.getState());
       
    }
View Full Code Here

Examples of com.wordpress.salaboy.example.handlers.MyHumanChangingValuesSimulatorWorkItemHandler

        KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
        kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());


        ksession = kbase.newStatefulKnowledgeSession();
        MyHumanChangingValuesSimulatorWorkItemHandler humanActivitiesSimHandler = new MyHumanChangingValuesSimulatorWorkItemHandler();
        ksession.getWorkItemManager().registerWorkItemHandler("Human Task", humanActivitiesSimHandler);

        KnowledgeRuntimeLoggerFactory.newConsoleLogger(ksession);

      
        Emergency emergency = new Emergency("555-1234");
        emergency.setType("Heart Attack");
        Map<String, Object> parameters = new HashMap<String, Object>();
        parameters.put("emergency", emergency);


        WorkflowProcessInstance process = (WorkflowProcessInstance) ksession
                                            .startProcess("com.wordpress.salaboy.bpmn2.SimpleEmergencyService", parameters);
        // My Emergency and My Process are both inserted as Facts / Truths in my Knowledge Session
        // Now Emergency and the Process Instance can be used by the inference engine
        ksession.insert(emergency);
        ksession.insert(process);
       
        // Is the Process still Active?
        Assert.assertEquals(ProcessInstance.STATE_ACTIVE, process.getState());
        // Is there a running node instance?
        Assert.assertEquals(1, process.getNodeInstances().size());
        // Is the process stopped in the "Ask for Emergency Information" activity?
        Assert.assertEquals("Ask for Emergency Information", process.getNodeInstances().iterator().next().getNodeName());
        // Lets check the value of the emergency.getRevision(), it should be 1
        Assert.assertEquals(1, ((Emergency) process.getVariable("emergency")).getRevision());
       
        System.out.println("Completing the first Activity");
        //Complete the first human activity
        humanActivitiesSimHandler.completeWorkItem();
        // Is the Process still Active?
        Assert.assertEquals(ProcessInstance.STATE_ACTIVE, process.getState());
       
        //I need to call the FireAllRules method because I have a RuleTask inside the business process
        int fired = ksession.fireAllRules();
        // Now that I have rules being evaluated, at least one should fire
        Assert.assertEquals(1, fired);
       
       
        // Lets check the value of the vehicle variable it should be an Ambulance => Heart Attack
        Assert.assertTrue(((Vehicle) process.getVariable("vehicle")) instanceof Ambulance);
       
       
        // Is the Process still Active?
        Assert.assertEquals(ProcessInstance.STATE_ACTIVE, process.getState());
        // Is there a running node instance?
        Assert.assertEquals(1, process.getNodeInstances().size());
        // Is the process stopped in the "Dispatch Vehicle" activity?
        Assert.assertEquals("Dispatch Vehicle", process.getNodeInstances().iterator().next().getNodeName());
        // Lets check the value of the emergency.getRevision(), it should be 1
        Assert.assertEquals(2, ((Emergency) process.getVariable("emergency")).getRevision());
       
       
       
        System.out.println("Completing the second Activity");
        //Complete the second human activity
        humanActivitiesSimHandler.completeWorkItem();
       
        // Is the process completed?
        Assert.assertEquals(ProcessInstance.STATE_COMPLETED, process.getState());

    }
View Full Code Here

Examples of com.wordpress.salaboy.example.handlers.MyHumanChangingValuesSimulatorWorkItemHandler

                ksession.fireUntilHalt();
            }
        }).start();
       
       
        MyHumanChangingValuesSimulatorWorkItemHandler humanActivitiesSimHandler = new MyHumanChangingValuesSimulatorWorkItemHandler();
        ksession.getWorkItemManager().registerWorkItemHandler("Human Task", humanActivitiesSimHandler);

        KnowledgeRuntimeLoggerFactory.newConsoleLogger(ksession);


        Emergency emergency = new Emergency("555-1234");
        //Run with Heart Attack and check the output. An Ambulance must appear in the report
        //emergency.setType("Heart Attack");
        //Run with Fire and check the output. A FireTruck must appear in the report
        emergency.setType("Fire");
        Map<String, Object> parameters = new HashMap<String, Object>();
        parameters.put("emergency", emergency);


        WorkflowProcessInstance process = (WorkflowProcessInstance) ksession
                                            .startProcess("com.wordpress.salaboy.bpmn2.SimpleEmergencyService", parameters);
        // My Emergency and My Process are both inserted as Facts / Truths in my Knowledge Session
        // Now Emergency and the Process Instance can be used by the inference engine
        ksession.insert(emergency);
        ksession.insert(process);
       
        // Is the Process still Active?
        Assert.assertEquals(ProcessInstance.STATE_ACTIVE, process.getState());
        // Is there a running node instance?
        Assert.assertEquals(1, process.getNodeInstances().size());
        // Is the process stopped in the "Ask for Emergency Information" activity?
        Assert.assertEquals("Ask for Emergency Information", process.getNodeInstances().iterator().next().getNodeName());
        // Lets check the value of the emergency.getRevision(), it should be 1
        Assert.assertEquals(1, ((Emergency) process.getVariable("emergency")).getRevision());
       
        System.out.println("Completing the first Activity");
        //Complete the first human activity
        humanActivitiesSimHandler.completeWorkItem();
       
       
        // I need to sleep for a little while, because the other thread can be executing some activated rules
        Thread.sleep(1000);
       
        // Lets check the value of the vehicle variable it should be a Fire Truck => Fire
        Assert.assertTrue(((Vehicle) process.getVariable("vehicle")) instanceof FireTruck);
       
       
        // Is the Process still Active?
        Assert.assertEquals(ProcessInstance.STATE_ACTIVE, process.getState());
        // Is there a running node instance?
        Assert.assertEquals(1, process.getNodeInstances().size());
        // Is the process stopped in the "Dispatch Vehicle" activity?
        Assert.assertEquals("Dispatch Vehicle", process.getNodeInstances().iterator().next().getNodeName());
        // Lets check the value of the emergency.getRevision(), it should be 2
        Assert.assertEquals(2, ((Emergency) process.getVariable("emergency")).getRevision());
       
        System.out.println("Completing the second Activity");
        //Complete the second human activity
        humanActivitiesSimHandler.completeWorkItem();
       
        // Is the process completed?
        Assert.assertEquals(ProcessInstance.STATE_COMPLETED, process.getState());
    }
View Full Code Here

Examples of com.wordpress.salaboy.example.handlers.MyHumanChangingValuesSimulatorWorkItemHandler

        KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
        kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());


        ksession = kbase.newStatefulKnowledgeSession();
        MyHumanChangingValuesSimulatorWorkItemHandler humanActivitiesSimHandler = new MyHumanChangingValuesSimulatorWorkItemHandler();
        ksession.getWorkItemManager().registerWorkItemHandler("Human Task", humanActivitiesSimHandler);
        MyTrackingSystemMock trackingSystem = new MyTrackingSystemMock();
        StartVehicleTrackingMockSystem trackingSystemHandler = new StartVehicleTrackingMockSystem(trackingSystem);
        ksession.getWorkItemManager().registerWorkItemHandler("StartTrackingSystem", trackingSystemHandler);

        KnowledgeRuntimeLoggerFactory.newConsoleLogger(ksession);

      
        Emergency emergency = new Emergency("555-1234");
        emergency.setType("Heart Attack");
        Map<String, Object> parameters = new HashMap<String, Object>();
        parameters.put("emergency", emergency);


        WorkflowProcessInstance process = (WorkflowProcessInstance) ksession
                                            .startProcess("com.wordpress.salaboy.bpmn2.SimpleEmergencyService", parameters);
        // My Emergency and My Process are both inserted as Facts / Truths in my Knowledge Session
        // Now Emergency and the Process Instance can be used by the inference engine
        ksession.insert(emergency);
        ksession.insert(process);
       
        // Is the Process still Active?
        Assert.assertEquals(ProcessInstance.STATE_ACTIVE, process.getState());
        // Is there a running node instance?
        Assert.assertEquals(1, process.getNodeInstances().size());
        // Is the process stopped in the "Ask for Emergency Information" activity?
        Assert.assertEquals("Ask for Emergency Information", process.getNodeInstances().iterator().next().getNodeName());
        // Lets check the value of the emergency.getRevision(), it should be 1
        Assert.assertEquals(1, ((Emergency) process.getVariable("emergency")).getRevision());
       
        System.out.println("Completing the first Activity");
        //Complete the first human activity
        humanActivitiesSimHandler.completeWorkItem();
        // Is the Process still Active?
        Assert.assertEquals(ProcessInstance.STATE_ACTIVE, process.getState());
       
        //I need to call the FireAllRules method because I have a RuleTask inside the business process
        int fired = ksession.fireAllRules();
        // Now that I have rules being evaluated, at least one should fire
        Assert.assertEquals(1, fired);
       
       
        // Lets check the value of the vehicle variable it should be an Ambulance => Heart Attack
        Vehicle selectedVehicle = ((Vehicle) process.getVariable("vehicle"));
        Assert.assertTrue(selectedVehicle instanceof Ambulance);
       
       
        // Is the Process still Active?
        Assert.assertEquals(ProcessInstance.STATE_ACTIVE, process.getState());
        // Is there a running node instance?
        Assert.assertEquals(1, process.getNodeInstances().size());
        // Is the process stopped in the "Dispatch Vehicle" activity?
        Assert.assertEquals("Dispatch Vehicle", process.getNodeInstances().iterator().next().getNodeName());
        // Lets check the value of the emergency.getRevision(), it should be 1
        Assert.assertEquals(2, ((Emergency) process.getVariable("emergency")).getRevision());
       
       
       
        System.out.println("Completing the second Activity");
        //Complete the second human activity
        humanActivitiesSimHandler.completeWorkItem();
       
        //Start Tracking and Reporting are automatic -> Check the report in the console
        //We can also check against the tracking system itself
        Assert.assertEquals("Vehicle "+selectedVehicle.getId()+" Located at 5th and A Avenue"
                                    , trackingSystem.queryTackingStatus(selectedVehicle.getId()));
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.