Package org.apache.tuscany.sdo.helper

Examples of org.apache.tuscany.sdo.helper.TypeHelperImpl


   */
  public static TypeHelper createTypeHelper()
  {
    EPackage.Registry registry = new EPackageRegistryImpl(EPackage.Registry.INSTANCE);
    ExtendedMetaData extendedMetaData = new SDOExtendedMetaDataImpl(registry); //TODO create subclass that makes demand() methods synchronous
    return new TypeHelperImpl(extendedMetaData);
  }
View Full Code Here


  }

 
  public void testDefineOpenType() throws Exception
  {
    TypeHelperImpl types = (TypeHelperImpl)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 open type - OpenQuote
    DataObject openQuoteType = factory.create("commonj.sdo", "Type");
    openQuoteType.set("uri", "http://www.example.com/open");
    openQuoteType.set("name", "OpenQuote");
    openQuoteType.set("open", Boolean.TRUE);
    openQuoteType.setBoolean("open", true);

    types.define(openQuoteType);
   
    // Define new type - CompanyType
    DataObject companyType = factory.create("commonj.sdo", "Type");
    companyType.set("uri", "http://www.example.com/open");
    companyType.set("name", "CompanyType");
   
    // Create CompanyType property - "name"
    DataObject nameProperty = companyType.createDataObject("property");
    nameProperty.set("name", "name");
    nameProperty.set("type", stringType);
    nameProperty.set("containment", Boolean.TRUE);
   
    types.define(companyType);
   
    // Define open content property - company
    DataObject symbolProperty = factory.create("commonj.sdo", "Property");
    symbolProperty.set("name", "symbol");
    symbolProperty.set("type", stringType);
    types.defineOpenContentProperty("http://www.example.com/open", symbolProperty);

    // Define open content property - company
    DataObject companyProperty = factory.create("commonj.sdo", "Property");
    companyProperty.set("name", "company");
    companyProperty.set("type", companyType);
    companyProperty.set("containment", Boolean.TRUE);
    types.defineOpenContentProperty("http://www.example.com/open", companyProperty);
   
    // Define open content property - price
    DataObject priceProperty = factory.create("commonj.sdo", "Property");
    priceProperty.set("name", "price");
    priceProperty.set("type", decimalType);
    types.defineOpenContentProperty("http://www.example.com/open", priceProperty);
   
    // Create DataObject instances
    DataObject openQuote = factory.create("http://www.example.com/open", "OpenQuote");
    assertTrue(openQuote.getType().isOpen());
   
    Property definedSymbolProperty = types.getOpenContentProperty("http://www.example.com/open", "symbol");
    openQuote.set(definedSymbolProperty, "s1");
   
    Property definedCompanyProperty = types.getOpenContentProperty("http://www.example.com/open", "company");
    DataObject company = openQuote.createDataObject(definedCompanyProperty);
    company.setString("name", "FlyByNightTechnology");
     
    Property definedPriceProperty = types.getOpenContentProperty("http://www.example.com/open", "price");
    openQuote.setBigDecimal(definedPriceProperty, new BigDecimal("1000.0"));
   
    assertEquals(definedPriceProperty.getType(), decimalType);
   
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
View Full Code Here

   */
  public static TypeHelper createTypeHelper()
  {
    EPackage.Registry registry = new EPackageRegistryImpl(EPackage.Registry.INSTANCE);
    ExtendedMetaData extendedMetaData = new SDOExtendedMetaDataImpl(registry); //TODO create subclass that makes demand() methods synchronous
    return new TypeHelperImpl(extendedMetaData);
  }
View Full Code Here

   
    //Register dependent packages with provided scope
    ModelFactory.INSTANCE.register(scope);
   
    // Initialize this package  
    TypeHelperImpl th = (TypeHelperImpl)scope.getTypeHelper();
    th.getExtendedMetaData().putPackage(NAMESPACE_URI, this);
  }
View Full Code Here

      Resource resource = resourceSet.createResource(URI.createURI("all.datagraph"));

      HashMap map = null;
      if(objectInput instanceof SDOObjectInputStream)
      {
         TypeHelperImpl th = (TypeHelperImpl)((SDOObjectInputStream)objectInput).getHelperContext().getTypeHelper();
         map = new HashMap();
         map.put("EXTENDED_META_DATA", th.getExtendedMetaData());
      }
      resource.load(new ByteArrayInputStream(bytes), map);
      eDataGraph = (DataGraphImpl)resource.getContents().get(0);
    }
View Full Code Here

    }
   
    //Register dependent packages with provided scope
   
    // Initialize this package  
    TypeHelperImpl th = (TypeHelperImpl)scope.getTypeHelper();
    th.getExtendedMetaData().putPackage(NAMESPACE_URI, this);
  }
View Full Code Here

   
    //Register dependent packages with provided scope
    ModelFactory.INSTANCE.register(scope);
   
    // Initialize this package  
    TypeHelperImpl th = (TypeHelperImpl)scope.getTypeHelper();
    th.getExtendedMetaData().putPackage(NAMESPACE_URI, this);
  }
View Full Code Here

   
    //Register dependent packages with provided scope
    ModelFactory.INSTANCE.register(scope);
   
    // Initialize this package  
    TypeHelperImpl th = (TypeHelperImpl)scope.getTypeHelper();
    th.getExtendedMetaData().putPackage(NAMESPACE_URI, this);
  }
View Full Code Here

   */ 
  public void register(HelperContext scope) {
    if(scope == null) {
       throw new IllegalArgumentException("Scope can not be null");
    }
    TypeHelperImpl th = (TypeHelperImpl)scope.getTypeHelper();
    th.getExtendedMetaData().putPackage(NAMESPACE_URI, this);
  }
View Full Code Here

   */ 
  public void register(HelperContext scope) {
    if(scope == null) {
       throw new IllegalArgumentException("Scope can not be null");
    }
    TypeHelperImpl th = (TypeHelperImpl)scope.getTypeHelper();
    th.getExtendedMetaData().putPackage(NAMESPACE_URI, this);
  }
View Full Code Here

TOP

Related Classes of org.apache.tuscany.sdo.helper.TypeHelperImpl

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.