Package org.apache.tuscany.das.rdb

Examples of org.apache.tuscany.das.rdb.ApplyChangesCommand


        root = custOrders.executeQuery();

        // Modify the first order and flush this change back to the database
        root.setString("CUSTOMER[1]/orders[1]/PRODUCT", "Defibrillator");
        Integer orderId = (Integer) root.get("CUSTOMER[1]/orders[1]/ID");
        ApplyChangesCommand flush = commandGroup.getApplyChangesCommand();
        flush.execute(root);

        // Verify
        Command orderByID = commandGroup.getCommand("order by id");
        orderByID.setParameterValue("ID", orderId);
        assertEquals("Defibrillator", root.getString("ANORDER[1]/PRODUCT"));
View Full Code Here


        stockPurchase.set("SYMBOL", sp.getStock().getSymbol());
        stockPurchase.set("QUANTITY", new Integer(sp.getStock().getQuantity()));
        stockPurchase.set("PURCHASEPRICE", new Float(11.00));
        stockPurchase.set("PURCHASEDATE", new Date());

        ApplyChangesCommand apply = commandGroup.getApplyChangesCommand();

        apply.execute(root);



    }
View Full Code Here

        // Modify
        orderDetails.setFloat("PRICE", 0f);

        // Build apply changes command
        ApplyChangesCommand apply = Command.FACTORY.createApplyChangesCommand(getConfig("OrdersOrderDetailsConfig.xml"));
        apply.setConnection(getConnection());

        // Write
        apply.execute(root);

        // Verify
        root = getOrderDetails.executeQuery();
        orderDetails = root.getDataObject("ORDERDETAILS[1]");
        assertEquals(0f, orderDetails.getFloat("PRICE"), 0.01);
View Full Code Here

    update.setConnection(getConnection());
    update.setParameterValue("OCC", new Integer(100));
    update.execute();

    //Try to flush the change
    ApplyChangesCommand apply = Command.FACTORY.createApplyChangesCommand(getConfig("BooksConfig.xml"));
    apply.setConnection(getConnection());

    try {
      apply.execute(root);
      fail("An OCCException should be thrown");
    } catch (RuntimeException ex) {
      if ( !ex.getMessage().equals("OCC Exception") )
        throw ex;
    }
View Full Code Here

    assertEquals(kbday, root.getDate("CUSTOMER[1]/LASTNAME"));
   
    //Modify
    root.setDate("CUSTOMER[1]/LASTNAME", tbday)
   
    ApplyChangesCommand write = Command.FACTORY.createApplyChangesCommand(getConfig("CustomerConfigWithConverter.xml"));
    write.setConnection(getConnection());
    write.execute(root);
   
    //Read
    root = read.executeQuery();

    //Verify
View Full Code Here

    // Modify customer
    customer.set("LASTNAME", "Pavick");

    // Build apply changes command
    ApplyChangesCommand apply = Command.FACTORY
        .createApplyChangesCommand(getConfig("basicCustomerMappingWithInvalidCUD.xml"));
    apply.setConnection(getConnection());

    // Flush changes
    try {
      apply.execute(root);
      fail("Should fail with invalid SQL.  Provided CUD not used!!");
    } catch (RuntimeException e) {
      // Everything OK
    }
View Full Code Here

    DataObject customer = root.createDataObject("CUSTOMER");
    customer.setInt("ID", 720);
    customer.set("LASTNAME", "foobar");
    customer.set("ADDRESS", "asdfasdf");

    ApplyChangesCommand apply = Command.FACTORY.createApplyChangesCommand();
    apply.setConnection(getConnection());
    apply.execute(root);

    select = Command.FACTORY
        .createCommand("select * from CUSTOMER where ID = 720");
    select.setConnection(getConnection());
    root = select.executeQuery();
View Full Code Here

    // Modify an order
    DataObject order = (DataObject) customer.get("orders[1]");
    order.setString("PRODUCT", "Kitchen Sink 001");

    ApplyChangesCommand apply = Command.FACTORY.createApplyChangesCommand(getConfig("1xM_mapping_no_cud.xml"));
    apply.setConnection(getConnection());   

    // Flush changes
    apply.execute(root);

  }
View Full Code Here

            // Modify customer
            customer.set("LASTNAME", "Pavick");

            // Build apply changes command
            ApplyChangesCommand apply = Command.FACTORY.createApplyChangesCommand();
            apply.setConnection(c, false);

            // Flush changes
            apply.execute(root);

            // Verify changes
            root = select.executeQuery();
            assertEquals("Pavick", root.getString("CUSTOMER[1]/LASTNAME"));
View Full Code Here

        int deptCount = firstCustomer.getList("departments").size();
       
        DataObject newDepartment = root.createDataObject("DEPARTMENT");
        firstCustomer.getList("departments").add(newDepartment);
       
        ApplyChangesCommand apply = commandGroup.getApplyChangesCommand();
        apply.execute(root);
       
        //verify
        root = read.executeQuery();
        firstCustomer = root.getDataObject("COMPANY[1]");
        assertEquals (deptCount + 1, firstCustomer.getList("departments").size());
View Full Code Here

TOP

Related Classes of org.apache.tuscany.das.rdb.ApplyChangesCommand

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.