Package commonj.sdo

Examples of commonj.sdo.DataObject


    Object pk = getPrimaryKey(object);

    if (!registry.contains(object.getType().getName(), Collections
        .singletonList(pk))) {
  //    logger.info("creating " + object.getType().getName() + " with pk " + pk);
      DataObject newObject = root.createDataObject(p.getName());

     

      Iterator attrs = object.getType().getProperties().iterator();
      while (attrs.hasNext()) {
        Property attr = (Property) attrs.next();
        if ( attr.getType().isDataType()) {
          newObject.set(attr.getName(), object.get(attr));
        }
      }
      registry.put(object.getType().getName(), Collections
          .singletonList(pk), newObject);

      Iterator refs = object.getType().getProperties().iterator();
      while (refs.hasNext()) {
        Property ref = (Property) refs.next();
        if ( !ref.getType().isDataType()) {
          List refObjects;
          if (!ref.isMany()) {
            refObjects = Collections.singletonList(object.get(ref));
          } else {
            refObjects = (List) object.get(ref);
          }

          Iterator iter = refObjects.iterator();
          while (iter.hasNext()) {
            DataObject refObject = (DataObject) iter.next();
            createObjectWithSubtree(root, refObject
              .getContainmentProperty(), refObject);
         
            refObject = (DataObject) registry.get(refObject.getType().getName(), Collections.singletonList(getPrimaryKey(refObject)));
            if (ref.isMany()) {
              newObject.getList(
                newObject.getType().getProperty(ref.getName()))
                .add(refObject);
            } else
View Full Code Here


    Iterator i = graph1.getType().getProperties().iterator();
    while (i.hasNext()) {
      Property p = (Property) i.next();
      Iterator objects = graph1.getList(p).iterator();
      while (objects.hasNext()) {
        DataObject object = (DataObject) objects.next();
        Object pk = object.get(getPrimaryKeyName(object));
        logger.finest("Adding object with pk " + pk + " to registry");
        registry.put(object.getType().getName(), Collections
            .singletonList(pk), object);
      }
    }
  }
View Full Code Here

    {

        //Read customer 1
        Command select = Command.FACTORY.createCommand( "Select * from CUSTOMER where ID = 1" );
        select.setConnection( getConnection() );
        DataObject root = select.executeQuery();

        DataObject customer = (DataObject) root.get( "CUSTOMER[1]" );

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

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

        //Manually create and add update command
        Command update = Command.FACTORY.createCommand( "update CUSTOMER set LASTNAME = :LASTNAME where ID = :ID" );
        update.addParameter( "LASTNAME", SDODataTypes.STRING );
        update.addParameter( "ID", SDODataTypes.INTEGER );
        apply.addUpdateCommand( customer.getType(), update );

        //Flush changes
        apply.execute( root );

        //Verify changes
View Full Code Here

    {

        //Read customer 1
        Command select = Command.FACTORY.createCommand( "Select * from CUSTOMER where ID = 1" );
        select.setConnection( getConnection() );
        DataObject root = select.executeQuery();

        DataObject customer = (DataObject) root.get( "CUSTOMER[1]" );

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

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

View Full Code Here

    {

        //Read customer with particular ID
        Command select = Command.FACTORY.createCommand( "Select * from CUSTOMER where ID = 1" );
        select.setConnection( getConnection() );
        DataObject root = select.executeQuery();

        DataObject customer = root.getDataObject( "CUSTOMER[1]" );

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

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

View Full Code Here

    {

        //Read customer with particular ID
        Command select = Command.FACTORY.createCommand( "Select * from CUSTOMER where ID = 1" );
        select.setConnection( getConnection() );
        DataObject root = select.executeQuery();

        DataObject customer = (DataObject) root.get( "CUSTOMER[1]" );

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

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

View Full Code Here

    {

        //Read some customers
        Command select = Command.FACTORY.createCommand( "Select * from CUSTOMER where LASTNAME = 'Williams'" );
        select.setConnection( getConnection() );
        DataObject root = select.executeQuery();

        DataObject cust1 = (DataObject) root.getList( "CUSTOMER" ).get( 0 );
        DataObject cust2 = (DataObject) root.getList( "CUSTOMER" ).get( 1 );
        DataObject cust3 = (DataObject) root.getList( "CUSTOMER" ).get( 2 );

        //Modify a customer
        cust1.set( "LASTNAME", "Pavick" );
        int cust1ID = cust1.getInt( "ID" );

        //Save IDs before delete
        int cust2ID = cust2.getInt( "ID" );
        int cust3ID = cust3.getInt( "ID" );
        //Delete a couple
        cust2.delete();
        cust3.delete();

        //Create a new customer
        DataObject cust4 = root.createDataObject( "CUSTOMER" );
        cust4.set( "ID", new Integer( 100 ) );
        cust4.set( "ADDRESS", "5528 Wells Fargo Drive" );
        cust4.set( "LASTNAME", "Gerkin" );

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

View Full Code Here

    //Read customer with particular ID
    Command select = Command.FACTORY
        .createCommand("Select * from CUSTOMER");
    select.setConnection(getConnection());
    DataObject root = select.executeQuery();

    DataObject customer = root.getDataObject("CUSTOMER[1]");

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

    DataObject customerForDelete = root.getDataObject("CUSTOMER[2]");
    String deletedLastName = customerForDelete.getString("LASTNAME");
    customerForDelete.delete();
   
    DataObject newCustomer = root.createDataObject("CUSTOMER");
    newCustomer.set("LASTNAME", "NewCustomer");
    newCustomer.setInt("ID", 9000);
   
    //Build apply changes command
    ApplyChangesCommand apply = Command.FACTORY.createApplyChangesCommand();
    apply.setConnection(getConnection());   

View Full Code Here

    public void testReadModifyApplyWithAssumedIDFailure() throws Exception {
 
    Command select = Command.FACTORY
        .createCommand("Select * from ORDERDETAILS");
    select.setConnection(getConnection());
    DataObject root = select.executeQuery();

    DataObject od = root.getDataObject("ORDERDETAILS[1]");

    //Modify customer
    od.setInt("PRODUCTID", 72)
   
    //Build apply changes command
    ApplyChangesCommand apply = Command.FACTORY.createApplyChangesCommand();
    apply.setConnection(getConnection());   

View Full Code Here

    public void testReadModifyApplyWithAssumedIDFailure2() throws Exception {
     
    Command select = Command.FACTORY
        .createCommand("Select * from ORDERDETAILS");
    select.setConnection(getConnection());
    DataObject root = select.executeQuery();

    DataObject od = root.getDataObject("ORDERDETAILS[1]");
    od.delete()
   
    //Build apply changes command
    ApplyChangesCommand apply = Command.FACTORY.createApplyChangesCommand();
    apply.setConnection(getConnection());   

View Full Code Here

TOP

Related Classes of commonj.sdo.DataObject

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.