Package commonj.sdo

Examples of commonj.sdo.Type


      
   }
  
   private void populateScopeWithDynamicTypes(TypeHelper scope)
   {
       Type stringType = scope.getType("commonj.sdo", "String");
       DataObject customerType = DataFactory.INSTANCE.create("commonj.sdo", "Type");
       customerType.set("uri", TEST_NAMESPACE);
       customerType.set("name", DYNAMIC_TYPE );
       DataObject custNumProperty = customerType.createDataObject("property");
       custNumProperty.set("name", "custNum");
View Full Code Here


  {
    URL url = getClass().getResource("/SubstitutionValues.xsd");
    XSDHelper.INSTANCE.define(url.openStream(), url.toString());

    final DataObject  object = DataFactory.INSTANCE.create("http://www.apache.org/tuscany/SubstitutionValues", "TestObject");
    final Type  type = object.getType();
   
    assertNotNull( SDOUtil.getSubstitutionValues(object, type.getProperty("groupHead")));
    assertNull( SDOUtil.getSubstitutionValues(object, type.getProperty("nonGroupHead")));
  }
View Full Code Here

        aProperty.set("name", "volume");
        aProperty.set("type", TypeHelper.INSTANCE.getType("commonj.sdo", "Double"));
       
        TypeHelper.INSTANCE.define(quoteType);
       
        Type dynamicQuoteType =
            TypeHelper.INSTANCE.getType("http://www.example.com/dynamic", "DynamicQuote");
       
        Vector types = new Vector();
        types.add(dynamicQuoteType);
        String xsd = null;
View Full Code Here

        aProperty.set("name", "referredQuotes");
        aProperty.set("type", typeHelper.getType(quoteSDO.getType().getURI(), quoteSDO.getType().getName()));
       
        typeHelper.define(quoteType);
       
        Type dynamicQuoteType =
            typeHelper.getType("http://www.example.com/dynamic", "DynamicQuote");
        Vector types = new Vector();
        types.add(dynamicQuoteType);
        String xsd = null;
       
View Full Code Here

    public void testSerializeTypesRoundTrip() throws Exception {
        TypeHelper types = SDOUtil.createTypeHelper();
        DataFactory factory = SDOUtil.createDataFactory(types);

        Type intType = types.getType("commonj.sdo", "Int");
        Type stringType = types.getType("commonj.sdo", "String");

        // create a new Type for Addresses
        DataObject addressType = factory.create("commonj.sdo", "Type");
        addressType.set("uri", "http://example.com/address");
        addressType.set("name", "Address");

        // create a address street property
        DataObject addrStProperty = addressType.createDataObject("property");
        addrStProperty.set("name", "addrSt");
        addrStProperty.set("type", stringType);

        // 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);

        // create an address property
        DataObject addressProperty = customerType.createDataObject("property");
        addressProperty.set("name", "address");
        addressProperty.set("type", addressType);
        addressProperty.setBoolean("containment", true);

        // now define the Address and Customer type so that addresses and customers can be made
        List types2define = new ArrayList();
        types2define.add(addressType);
        types2define.add(customerType);
        List typesDefined = types.define(types2define);

        // Create an empty data graph and add a root object, an instance of customerType
        //

        DataGraph dataGraph = SDOUtil.createDataGraph();
        Type customerTypeDefined = (Type) typesDefined.get(1);
        DataObject customer1 = dataGraph.createRootObject(customerTypeDefined);

        customer1.setInt("custNum", 1);
        customer1.set("firstName", "John");
        customer1.set("lastName", "Adams");
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

    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"));
    assertNotNull(type.getProperty("custNum"));
    assertNotNull(type.getProperty("firstName"));
    assertNotNull(type.getProperty("lastName"));
   
    type = type.getProperty("custNum").getType();
    assertEquals(type.getURI(), "http://example.com/customer");
    assertEquals(type.getName(), "MyIntType");
    assertTrue(type.isDataType());
   
    assertNotNull(customer2);
    type = customer2.getType();
    assertNotNull(type.getProperty("custNum"));
    assertNotNull(type.getProperty("firstName"));
    assertNotNull(type.getProperty("lastName"));
    assertNotNull(type.getProperty("custNum"));
    assertNotNull(type.getProperty("firstName"));
    assertNotNull(type.getProperty("lastName"));
   
    ByteArrayOutputStream 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
    Type customerType = SDOUtil.createType(types, "http://example.com/customer", "Customer", false);

    // create a customer number property
    SDOUtil.createProperty(customerType, "custNum", intType);

    // create a first name property
    SDOUtil.createProperty(customerType, "firstName", stringType);

    // create a last name property
    SDOUtil.createProperty(customerType, "lastName", stringType);

    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

   
    TypeHelper types = SDOUtil.createTypeHelper();
    DataFactory factory = SDOUtil.createDataFactory(types);
    XMLHelper xmlHelper = SDOUtil.createXMLHelper(types);
   
    Type stringType = types.getType("commonj.sdo", "String");
    Type decimalType = types.getType("commonj.sdo", "Decimal");
   
    // Define a new mixed type - MixedQuote
    DataObject mixedQuoteType = factory.create("commonj.sdo", "Type");
    mixedQuoteType.set("uri", "http://www.example.com/mixed");
    mixedQuoteType.set("name", "MixedQuote");
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.