Package org.apache.agila.impl

Examples of org.apache.agila.impl.BusinessProcessImpl


    }

    public void testAddGraph() {
        // create a business process with a root node and get a business process
        // id
        BusinessProcessImpl bProcess = new BusinessProcessImpl();
        String graphName = "Graph1";
        bProcess.setName( graphName );
        Node rootNode = new BaseNodeImpl() {

            public Connection[] doEnd( NodeContext ctx ) {
                return null;
            }
        };

        rootNode.setNodeId(new NodeID(1));
        rootNode.setDisplayName("root");

        bProcess.setRoot( rootNode );

        // add the business process graph
        BusinessProcessID bpId = bpService.addGraph( bProcess );

        // confirm that the graph has been saved by retrieving all current
View Full Code Here


     * Test the creation of a new process instance.
     *
     */
    public void testNewInstance() {
        // get a business process id
        BusinessProcessImpl bProcess = new BusinessProcessImpl();
        String graphName = "Graph" + count++;
        bProcess.setName(graphName);
        BusinessProcessID bpId = bpService.addGraph(bProcess);

        // then create a map of parameters
        Map params = new HashMap();
        params.put("foo", "foo value");
View Full Code Here

     * Test starting a created instance.
     *
     */
    public void testStart() {
        // get a business process id
        BusinessProcessImpl bProcess = new BusinessProcessImpl();
        String graphName = "Graph" + count++;
        bProcess.setName(graphName);
        Node rootNode = new BaseNodeImpl() {

            public Connection[] doEnd(NodeContext ctx) {
                return null;
            }
        };

        rootNode.setNodeId(new NodeID(1));
        rootNode.setDisplayName("root");

        bProcess.setRoot(rootNode);
        BusinessProcessID bpId = bpService.addGraph(bProcess);

        // then create a map of parameters
        Map params = new HashMap();
        params.put("foo", "foo value");
        params.put("bar", "bar value");
        params.put("baz", "baz value");

        // create a new instance using the service
        InstanceID instanceId = instanceService.newInstance(bpId, params);

        // start the newly created instance
        instanceService.start(instanceId);

        // wait until the message has been consumed in the queue
        while(engineMessage == null) {
            try {
                Thread.sleep(1000);
            }
            catch (InterruptedException e) {
                e.printStackTrace();
                fail();
            }
        }

        if(engineMessage == null) {
            fail("something went wrong");
        }

        assertEquals("Type must be 'move token'", EngineMessage.TYPE_MOVE_TOKEN, engineMessage.getMessageType());

        TokenID tokenId = engineMessage.getCurrentTokenID();
        Token token = tokenService.getTokenByID(tokenId);
        assertEquals(1, token.getCurrentNodeID().getID());
        assertTrue(token.isActive());
        assertEquals(Token.PRE, token.getCurrentState());
        assertNotNull(bpService.getGraphByID(instanceService.getInstanceByID(token.getInstanceID()).getBusinessProcessID()));
        assertSame(bProcess.getRoot(),
                bpService.getGraphByID(instanceService.getInstanceByID(token.getInstanceID()).getBusinessProcessID()).getRoot());
    }
View Full Code Here

                bpService.getGraphByID(instanceService.getInstanceByID(token.getInstanceID()).getBusinessProcessID()).getRoot());
    }

    public void testSave() {
        // get a business process id
        BusinessProcessImpl bProcess = new BusinessProcessImpl();
        String graphName = "Graph" + count++;
        bProcess.setName(graphName);
        BusinessProcessID bpId = bpService.addGraph(bProcess);

        // then create a map of parameters
        Map params = new HashMap();
        params.put("foo", "foo value");
View Full Code Here

        return retVal;
    }

    public BusinessProcess getGraphByID( BusinessProcessID businessProcessID ) {
        BusinessProcessImpl retVal = null;

        Connection connection = null;

        try {
            String sql = "select businessprocessid, xml" +
                " from bpm_businessprocess" +
                " where businessprocessid = " + businessProcessID.getID();

            connection = getConnection();

            Statement statement = connection.createStatement();
            ResultSet result = statement.executeQuery( sql );
            result.next();

            String xml = result.getString( "xml" );
            retVal = (BusinessProcessImpl)XMLUtil.deserializeXML(
                new StringReader( xml ) );
            retVal.setBusinessProcessID( businessProcessID );

            result.close();
            statement.close();
        }
        catch( SQLException e ) {
View Full Code Here

     * @param doc
     * @return
     */
    public static BusinessProcess deserializeXML(Reader doc) {

        BusinessProcessImpl graph = new BusinessProcessImpl();

        SAXReader reader = new SAXReader();

        try {
            Document d = reader.read(doc);

            graph.setGraphAsXML(d.asXML());

            graph.setName(d.getRootElement().attribute("name").getValue());

            Element e = (Element) d.getRootElement().selectSingleNode("graph");

            /*
             * grab and process the variables
             */

            List vars = d.getRootElement().selectNodes("variables/*");

            Iterator it = vars.iterator();

            while(it.hasNext()) {
                digestVariable(graph, (Element) it.next());
            }

            /*
             * process the nodes
             */
            List nodes = e.selectNodes("nodes/*");

            it = nodes.iterator();

            while(it.hasNext()) {

                digestNode(graph,(Element) it.next());
            }

            List conns = e.selectNodes("connections/*");

            it = conns.iterator();

            while(it.hasNext()) {

                Element node = (Element) it.next();
                String start = node.attribute("startid").getValue();
                String end = node.attribute("endid").getValue();
                String name = node.attribute("display_name").getValue();

                graph.addConnection(Integer.parseInt(start), Integer.parseInt(end), name);
            }

        } catch (DocumentException e) {
            e.printStackTrace();
        } catch (ClassNotFoundException e) {
View Full Code Here

TOP

Related Classes of org.apache.agila.impl.BusinessProcessImpl

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.