Package commonj.sdo

Examples of commonj.sdo.Type


    }
    return null;
  }

  public Collection getUpdateParameters(DataObject changedObject, Table table) {
    Type type = changedObject.getType();
    TableWrapper wrapper = new TableWrapper(table);
    Collection pkNames = wrapper.getPrimaryKeyProperties();
    ArrayList parameters = new ArrayList();
    ArrayList pkParams = new ArrayList();
   
    Iterator i = getAttributeProperties(changedObject).iterator();
    while (i.hasNext()) {
      Property attr = (Property) i.next();
      String field = attr.getName();

      Parameter p = getParameter(wrapper, type.getProperty(field));
      if (pkNames.contains(field)) {
        pkParams.add(p);
      } else {
        parameters.add(p);
      }
View Full Code Here


      assertTrue(baseTypes.size() == 0);
    }
   
    public void testSimpleSDOTypeExtendedInstanceClass() throws IOException
    {
      Type type = TypeHelper.INSTANCE.getType(TEST_NAMESPACE, "SimpleSDOTypeExtendedInstanceClass");
      List baseTypes = type.getBaseTypes();
      assertTrue(baseTypes.size() == 1);
    }
View Full Code Here

    return null;
  }
 
  public Type getType(Class interfaceClass)
  {
    Type type = SDOUtil.getJavaSDOType(interfaceClass);
    if (type != null)
    {
      return type;
    }
   
View Full Code Here

    if (!(type instanceof org.apache.tuscany.sdo.model.Type))
      throw new IllegalArgumentException();
    org.apache.tuscany.sdo.model.Type modeledType = (org.apache.tuscany.sdo.model.Type)type;
   
    boolean isDataType = modeledType.isDataType();
    Type definedType = SDOUtil.createType(this, modeledType.getUri(), modeledType.getName(), isDataType)
   
    SDOUtil.setJavaClassName(definedType, modeledType.getInstanceClassName());
   
    if (!isDataType)
    {
      SDOUtil.setSequenced(definedType, modeledType.isSequenced());
      SDOUtil.setOpen(definedType, modeledType.isOpen());
      SDOUtil.setAbstract(definedType, modeledType.isAbstract());
     
      for (Iterator iter = modeledType.getBaseType().iterator(); iter.hasNext(); )
      {
        Type baseType = getDefinedType((org.apache.tuscany.sdo.model.Type)iter.next());
        SDOUtil.addBaseType(definedType, baseType);
      }
     
      for (Iterator iter = modeledType.getAliasName().iterator(); iter.hasNext(); )
      {
        String aliasName = (String)iter.next();
        SDOUtil.addAliasName(definedType, aliasName);
      }
     
      for (Iterator iter = modeledType.getProperty().iterator(); iter.hasNext(); )
      {
        org.apache.tuscany.sdo.model.Property modeledProperty = (org.apache.tuscany.sdo.model.Property)iter.next();
       
        Type propertyType = getDefinedType(modeledProperty.getType_());
        Property definedProperty = SDOUtil.createProperty(definedType, modeledProperty.getName(), propertyType);
       
        SDOUtil.setMany(definedProperty, modeledProperty.isMany());
        SDOUtil.setDefault(definedProperty, modeledProperty.getDefault_());
        SDOUtil.setReadOnly(definedProperty, modeledProperty.isReadOnly());
       
        for (Iterator iter2 = modeledProperty.getAliasName().iterator(); iter2.hasNext(); )
        {
          String aliasName = (String)iter2.next();
          SDOUtil.addAliasName(definedProperty, aliasName);
        }
       
        if (!propertyType.isDataType())
        {
          SDOUtil.setContainment(definedProperty, modeledProperty.isContainment());
          if (modeledProperty.getOpposite_() != null)
          {
            SDOUtil.setOpposite(definedProperty, getDefinedProperty(modeledProperty.getOpposite_()));
View Full Code Here

    }
    else
    {
      DataObject modeledContainingType = ((DataObject)modeledProperty).getContainer();
     
      Type definedContainingType = getDefinedType((org.apache.tuscany.sdo.model.Type)modeledContainingType);
      String propertyName = modeledProperty.getName();
   
      return definedContainingType.getProperty(propertyName);
    }
  }
View Full Code Here

    /**
     * Open content SDO 2 test.
     */
    public void testOpenType() throws IOException {
        Type quoteType = TypeHelper.INSTANCE.getType(TEST_NAMESPACE, "OpenQuote");
        DataObject quote = DataFactory.INSTANCE.create(quoteType);

        quote.setString("symbol", "s1");

        for (Iterator iter = quote.getInstanceProperties().iterator(); iter.hasNext();) {
View Full Code Here

    /**
     * Simple Dynamic SDO 2 test.
     */
    public void testDynamic() throws IOException {
        Type quoteType = TypeHelper.INSTANCE.getType(TEST_NAMESPACE, "Quote");
        DataObject quote = DataFactory.INSTANCE.create(quoteType);

        quote.setString("symbol", "fbnt");
        quote.setString("companyName", "FlyByNightTechnology");
        quote.setBigDecimal("price", new BigDecimal("1000.0"));
View Full Code Here

    /**
     * Sequenced type SDO 2 test.
     */
    public void testSequencedType() throws IOException {
        Type quoteType = TypeHelper.INSTANCE.getType(TEST_NAMESPACE, "MixedQuote");
        DataObject quote = DataFactory.INSTANCE.create(quoteType);

        Sequence sequence = quote.getSequence();

        sequence.add("\n  ");
View Full Code Here

  public void testDefineTypeRoundTrip() throws Exception {
    TypeHelper types = SDOUtil.createTypeHelper();
    DataFactory factory = SDOUtil.createDataFactory(types);
    XMLHelper xmlHelper = SDOUtil.createXMLHelper(types);

    Type intType = types.getType("commonj.sdo", "Int");
    Type stringType = types.getType("commonj.sdo", "String");
   
    // create a new Type for Customers
    DataObject customerType = factory.create("commonj.sdo",
    "Type");
    customerType.set("uri", "http://example.com/customer");
    customerType.set("name", "Customer");
   
    // create a customer number property
    DataObject custNumProperty = customerType.createDataObject("property");
    custNumProperty.set("name", "custNum");
    custNumProperty.set("type", intType);
    
    // create a first name property
    DataObject firstNameProperty =
    customerType.createDataObject("property");
    firstNameProperty.set("name", "firstName");
    firstNameProperty.set("type", stringType);

    // create a last name property
    DataObject lastNameProperty = customerType.createDataObject("property");
    lastNameProperty.set("name", "lastName");
    lastNameProperty.set("type", stringType);

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    xmlHelper.save(customerType, "commonj.sdo", "type", baos);
   
    ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
    XMLDocument xdoc = xmlHelper.load(bais);

    customerType = xdoc.getRootObject();
   
    // now define the Customer type so that customers can be made
    types.define(customerType);
   
    DataObject customer1 = factory.create("http://example.com/customer",
    "Customer");
   
    customer1.setInt("custNum", 1);
    customer1.set("firstName", "John");
    customer1.set("lastName", "Adams");
    DataObject customer2 = factory.create("http://example.com/customer",
    "Customer");   
    customer2.setInt("custNum", 2);
    customer2.set("firstName", "Jeremy");
    customer2.set("lastName", "Pavick");
   
    assertNotNull(customer1);
    Type type = customer1.getType();
    assertNotNull(type.getProperty("custNum"));
    assertNotNull(type.getProperty("firstName"));
    assertNotNull(type.getProperty("lastName"));
    assertEquals(type.getProperty("custNum").getType(), intType);
    assertEquals(type.getProperty("firstName").getType(), stringType);
    assertEquals(type.getProperty("lastName").getType(), stringType);
   
    assertNotNull(customer2);
    type = customer2.getType();
    assertNotNull(type.getProperty("custNum"));
    assertNotNull(type.getProperty("firstName"));
    assertNotNull(type.getProperty("lastName"));
    assertEquals(type.getProperty("custNum").getType(), intType);
    assertEquals(type.getProperty("firstName").getType(), stringType);
    assertEquals(type.getProperty("lastName").getType(), stringType);
   
    baos = new ByteArrayOutputStream();
    xmlHelper.save(
      customer1,
      "http://example.com/customer",
View Full Code Here

  {
    TypeHelper types = SDOUtil.createTypeHelper();
    DataFactory factory = SDOUtil.createDataFactory(types);
    XMLHelper xmlHelper = SDOUtil.createXMLHelper(types);

    Type intType = types.getType("commonj.sdo", "Int");
    Type stringType = types.getType("commonj.sdo", "String");
   
    // create a new Type for Customers
    DataObject customerType = factory.create("commonj.sdo",
    "Type");
    customerType.set("uri", "http://example.com/customer");
    customerType.set("name", "Customer");

    // create a customer number property
    DataObject custNumProperty = customerType.createDataObject("property");
    custNumProperty.set("name", "custNum");
    custNumProperty.set("type", intType);

    // create a first name property
    DataObject firstNameProperty =
    customerType.createDataObject("property");
    firstNameProperty.set("name", "firstName");
    firstNameProperty.set("type", stringType);

    // create a last name property
    DataObject lastNameProperty = customerType.createDataObject("property");
    lastNameProperty.set("name", "lastName");
    lastNameProperty.set("type", stringType);

    // now define the Customer type so that customers can be made
    types.define(customerType);
   
    DataObject customer1 = factory.create("http://example.com/customer",
    "Customer");
    customer1.setInt("custNum", 1);
    customer1.set("firstName", "John");
    customer1.set("lastName", "Adams");
    DataObject customer2 = factory.create("http://example.com/customer",
    "Customer");   
    customer2.setInt("custNum", 2);
    customer2.set("firstName", "Jeremy");
    customer2.set("lastName", "Pavick");

    assertNotNull(customer1);
    Type type = customer1.getType();
    assertNotNull(type.getProperty("custNum"));
    assertNotNull(type.getProperty("firstName"));
    assertNotNull(type.getProperty("lastName"));
    assertEquals(type.getProperty("custNum").getType(), intType);
    assertEquals(type.getProperty("firstName").getType(), stringType);
    assertEquals(type.getProperty("lastName").getType(), stringType);
   
    assertNotNull(customer2);
    type = customer2.getType();
    assertNotNull(type.getProperty("custNum"));
    assertNotNull(type.getProperty("firstName"));
    assertNotNull(type.getProperty("lastName"));
    assertEquals(type.getProperty("custNum").getType(), intType);
    assertEquals(type.getProperty("firstName").getType(), stringType);
    assertEquals(type.getProperty("lastName").getType(), stringType);
   
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    xmlHelper.save(
      customer1,
      "http://example.com/customer",
View Full Code Here

TOP

Related Classes of commonj.sdo.Type

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.