Package commonj.sdo

Examples of commonj.sdo.DataObject


       
        Command select = Command.FACTORY.createCommand(statement, helper.getConfig());
        select.setConnection(getConnection());
        select.setParameterValue("ID", new Integer(1));

        DataObject root = select.executeQuery();
       
        DataObject newBook = root.createDataObject("Book");
        newBook.setString("NAME", "Ant Colonies of the Old World");
        newBook.setInt("BOOK_ID", 1001);
        root.getList("Book").add(newBook);
              
        ApplyChangesCommand apply = Command.FACTORY.createApplyChangesCommand(helper.getConfig());
        apply.setConnection(getConnection());
        apply.execute(root);
View Full Code Here


            Command read = commandGroup.getCommand("all customers");

            // select.setDataObjectModel();
            TypeHelper helper = TypeHelper.INSTANCE;
            read.setDataObjectModel(helper.getType(DataGraphRoot.class));
            DataObject root = read.executeQuery();

            // Create a new stockPurchase
            DataObject customer = root.createDataObject("customerProfileData");

            // THIS SEEMS TO BE THE ONLY WAY TO DO THIS .. NO WAY TO JUST ADD AN EXISTING CUSTOMER.
            customer.set("firstName", customerProfile.getFirstName());
            customer.set("lastName", customerProfile.getLastName());
            customer.set("address", customerProfile.getAddress());
            customer.set("email", customerProfile.getEmail());
            customer.set("loginID", customerProfile.getLoginID());
            customer.set("password", customerProfile.getPassword());

            ApplyChangesCommand apply = commandGroup.getApplyChangesCommand();
            apply.execute(root);
            return getCustomerProfile(customerProfile.getLoginID());
View Full Code Here

    if (tableClass == null)
      throw new RuntimeException("An SDO Type with name "
          + tableData.getTableName() + " was not found");

    DataObject obj = DataFactory.INSTANCE.create(tableClass);

    // Now, check to see if the root data object has a containment reference
    // to this EClass. If so, add it to the graph. If not, it will be taken
    // care
    // of when we process relationships

    Iterator i = this.rootObject.getType().getProperties().iterator();
    while (i.hasNext()) {
      Property p = (Property) i.next();

      if (p.isContainment() && p.getType().equals(tableClass)) {
        if (p.isMany())
          rootObject.getList(p).add(obj);
        // TODO This was a performance optimization for EMF in SDO 1.1,
        // check to see if there is
        // something equivalent in SDO 2.0
        // ((InternalEList) this.dataGraph.eGet(ref)).addUnique(obj);
        else
          this.rootObject.set(p, obj);
      }

    }

    Iterator columnNames = resultMetadata.getColumnNames(
        tableData.getTableName()).iterator();
    while (columnNames.hasNext()) {
      String columnName = (String) columnNames.next();
      DataObject dataObject = (DataObject) obj;
      Property p = findProperty(dataObject.getType(), columnName);
      Object value = tableData.getColumnData(columnName);

      dataObject.set(p, value);
    }

    return obj;
  }
View Full Code Here

    //Create a pager with the command
    Pager pager = new PagerImpl(custCommand, 2);

    //Get and work with first page
    DataObject root = pager.next();
    DataObject customer1 = root.getDataObject("CUSTOMER[1]");
    DataObject customer2 = root.getDataObject("CUSTOMER[2]");
    assertEquals(1, customer1.getInt("ID"));
    assertEquals(2, customer2.getInt("ID"));

    //Get and work with the second page
    root = pager.next();
    customer1 = root.getDataObject("CUSTOMER[1]");
    customer2 = root.getDataObject("CUSTOMER[2]");
    assertEquals(3, customer1.getInt("ID"));
    assertEquals(4, customer2.getInt("ID"));
   
    // First page again
    root = pager.previous();
    customer1 = root.getDataObject("CUSTOMER[1]");
    customer2 = root.getDataObject("CUSTOMER[2]");
    assertEquals(1, customer1.getInt("ID"));
    assertEquals(2, customer2.getInt("ID"));

  }
View Full Code Here

    //Create a pager
    Pager pager = new PagerImpl(select, 2);

    //Get the first page
    DataObject root = pager.getPage(1);
    DataObject customer1 = root.getDataObject("CUSTOMER[1]");
    DataObject customer2 = root.getDataObject("CUSTOMER[2]");
    assertEquals(1, customer1.getInt("ID"));
    assertEquals(2, customer2.getInt("ID"));

    //Get the second page
    root = pager.getPage(2);
    customer1 = root.getDataObject("CUSTOMER[1]");
    customer2 = root.getDataObject("CUSTOMER[2]");
    assertEquals(3, customer1.getInt("ID"));
    assertEquals(4, customer2.getInt("ID"));

   
    // Get the first page again
    root = pager.getPage(1);
    customer1 = root.getDataObject("CUSTOMER[1]");
    customer2 = root.getDataObject("CUSTOMER[2]");
    assertEquals(1, customer1.getInt("ID"));
    assertEquals(2, customer2.getInt("ID"));
  }
View Full Code Here

    Iterator i = metadata.getRelationships().iterator();
    while (i.hasNext()) {
      Relationship r = (Relationship) i.next();

     
            DataObject parentTable = get(wrapper
          .getTablePropertyName(r.getPrimaryKeyTable()));
      DataObject childTable = get(wrapper
          .getTablePropertyName(r.getForeignKeyTable()));

      DebugUtil.debugln(getClass(), debug, "Parent table: " + parentTable);
      DebugUtil.debugln(getClass(), debug, "Child table: " + childTable);
View Full Code Here

 
  private void processRecursiveRelationships(MappingWrapper wrapper) {
    Iterator i = tableObjects.iterator();
    while (i.hasNext()) {
      DataObject table = (DataObject) i.next();
   
      Iterator relationships = wrapper.getRelationshipsByChildTable(table.getType().getName()).iterator();
      while ( relationships.hasNext() ) {
        Relationship r = (Relationship) relationships.next();
   
        DataObject parentTable = findParentTable(table, r, wrapper);
       
        if (parentTable == null)
          continue;

                Property p = parentTable.getType().getProperty(r.getName());
        setOrAdd(parentTable, table, p);
      }
     
    }
  }
View Full Code Here

      fkValue.add(childTable.get(p));
    }

    DebugUtil.debugln(getClass(), debug, "Trying to find parent of " + r.getForeignKeyTable() + " with FK "
        + fkValue);
    DataObject parentTable = registry.get(r.getPrimaryKeyTable(), fkValue);
    DebugUtil.debugln(getClass(), debug, "Parent table from registry: " + parentTable);
    return parentTable;
  }
View Full Code Here

        Command select = Command.FACTORY.createCommand(
                "SELECT * FROM CUSTOMER LEFT JOIN ANORDER ON CUSTOMER.ID = ANORDER.CUSTOMER_ID",
                getConfig("CustomersOrdersConfig.xml"));
        select.setConnection(getConnection());

        DataObject root = select.executeQuery();

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

        // Save ID and Order Count
        int custID = cust.getInt("ID");
        int custOrderCount = cust.getList("orders").size();

        // Create a new Order and add to customer1
        DataObject order = root.createDataObject("ANORDER");

        order.set("ID", new Integer(99));
        order.set("PRODUCT", "The 99th product");
        order.set("QUANTITY", new Integer(99));
        cust.getList("orders").add(order);

        assertEquals(custOrderCount + 1, cust.getList("orders").size());
        // Build apply changes command
        ApplyChangesCommand apply = Command.FACTORY.createApplyChangesCommand(getConfig("CustomersOrdersConfig.xml"));
View Full Code Here

        insert.execute();

        // Verify
        Command select = Command.FACTORY.createCommand("Select * from conmgt.serverstatus");
        select.setConnection(getConnection());
        DataObject root = select.executeQuery();
        assertEquals(1, root.getList("SERVERSTATUS").size());

    }
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.