Examples of TypeHelper


Examples of commonj.sdo.helper.TypeHelper

     * @param isNullable
     * @return
     */
    public Type getEDataType(int type, boolean isNullable) {

        TypeHelper helper = TypeHelper.INSTANCE;
        SDOPackage.eINSTANCE.eClass();
        switch (type) {

            case Types.CHAR:
            case Types.VARCHAR:
            case Types.LONGVARCHAR:
                return helper.getType("commonj.sdo", "String");

            case Types.NUMERIC:
            case Types.DECIMAL:
                return helper.getType("commonj.sdo", "Decimal");

            case Types.BIT:
            case Types.BOOLEAN:
                if (isNullable) {
                    return helper.getType("commonj.sdo", "Boolean");
                }
                return helper.getType("commonj.sdo", "boolean");
               

            case Types.TINYINT:
            case Types.SMALLINT:
            case Types.INTEGER:
                if (isNullable) {
                    return helper.getType("commonj.sdo", "IntObject");
                }
               
                return helper.getType("commonj.sdo", "Int");
              

            case Types.BIGINT:
                if (isNullable) {
                    return helper.getType("commonj.sdo", "Long");
                }
                return helper.getType("commonj.sdo", "long");

            case Types.REAL:
                if (isNullable) {
                    return helper.getType("commonj.sdo", "Float");
                }
                return helper.getType("commonj.sdo", "float");
               

            case Types.FLOAT:
            case Types.DOUBLE:
                if (isNullable) {
                    return helper.getType("commonj.sdo", "Double");
                }
                return helper.getType("commonj.sdo", "double");
             

            case Types.BINARY:
            case Types.VARBINARY:
            case Types.LONGVARBINARY:
                return helper.getType("commonj.sdo", "ByteArray");

            case Types.DATE:
            case Types.TIME:
            case Types.TIMESTAMP:
                return helper.getType("commonj.sdo", "Date");

            case Types.CLOB:
                return helper.getType("commonj.sdo", "Clob");

            case Types.BLOB:
                return helper.getType("commonj.sdo", "Blob");

            case Types.ARRAY:
                return helper.getType("commonj.sdo", "Array");

            case Types.DISTINCT:
            case Types.STRUCT:
            case Types.REF:
            case Types.DATALINK:
            case Types.JAVA_OBJECT:
                return helper.getType("commonj.sdo", "Object");

            default:
                return helper.getType("commonj.sdo", "Object");
        }

    }
View Full Code Here

Examples of commonj.sdo.helper.TypeHelper

     * The presence or absence of the @ sign in a path has no meaning.
     * Properties are always matched by name independent of their XML representation.
     * @throws IOException
     */
    public void testAtSignProperty() throws IOException {
        TypeHelper typeHelper = SDOUtil.createTypeHelper();
        XSDHelper xsdHelper = SDOUtil.createXSDHelper(typeHelper);
        XMLHelper xmlHelper = SDOUtil.createXMLHelper(typeHelper);
       
        URL url = getClass().getResource(TEST_MODEL);
        InputStream inputStream = url.openStream();
View Full Code Here

Examples of commonj.sdo.helper.TypeHelper

        
        assertEquals(value, "2000-03-23");
    }
   
    public void testListIndexing() throws Exception {
        TypeHelper typeHelper = SDOUtil.createTypeHelper();
        XSDHelper xsdHelper = SDOUtil.createXSDHelper(typeHelper);
        XMLHelper xmlHelper = SDOUtil.createXMLHelper(typeHelper);

        URL url = getClass().getResource(TEST_MODEL);
        InputStream inputStream = url.openStream();
View Full Code Here

Examples of commonj.sdo.helper.TypeHelper

  private static final String OPEN_XML = "/open2.xml";
  private static final String MIXED_XML = "/mixed2.xml";
  private static final String MIXEDOPEN_XML = "/mixedopen.xml";
 
  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);
View Full Code Here

Examples of commonj.sdo.helper.TypeHelper

          getClass().getResource(CUSTOMER2_XML)));
  }
 
  public void testDefineType() 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);

    // 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");
View Full Code Here

Examples of commonj.sdo.helper.TypeHelper

          getClass().getResource(CUSTOMER2_XML)));
  }
 
  public void testDefineDataType() throws Exception
  {
    TypeHelper types = SDOUtil.createTypeHelper();
    DataFactory factory = SDOUtil.createDataFactory(types);
    XSDHelper xsdHelper = SDOUtil.createXSDHelper(types);
    XMLHelper xmlHelper = SDOUtil.createXMLHelper(types);

    Property javaClassProperty = xsdHelper.getGlobalProperty("commonj.sdo/java", "javaClass", false);
   
    // create a data types
    DataObject intType = factory.create("commonj.sdo", "Type");
    intType.set("uri", "http://example.com/customer");
    intType.set("name", "MyIntType");
    intType.setBoolean("dataType", true);
    intType.set(javaClassProperty, "int");
   
    DataObject stringType = factory.create("commonj.sdo", "Type");
    stringType.set("uri", "http://example.com/customer");
    stringType.set("name", "MyStringType");
    stringType.setBoolean("dataType", true);
    stringType.set(javaClassProperty, "java.lang.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);
View Full Code Here

Examples of commonj.sdo.helper.TypeHelper

          getClass().getResource(CUSTOMER2_XML)));
  }
 
  public void testFastDefineType() 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
    Type customerType = SDOUtil.createType(types, "http://example.com/customer", "Customer", false);

    // create a customer number property
View Full Code Here

Examples of commonj.sdo.helper.TypeHelper

  }
 
  public void testDefineSequencedType() throws Exception
  {
   
    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");
    mixedQuoteType.set("sequenced", Boolean.TRUE);
   
    DataObject symbolProperty = mixedQuoteType.createDataObject("property");
    symbolProperty.set("name", "symbol");
    symbolProperty.set("type", stringType);
   
    DataObject companyNameProperty = mixedQuoteType.createDataObject("property");
    companyNameProperty.set("name", "companyName");
    companyNameProperty.set("type", stringType);
   
    DataObject priceProperty = mixedQuoteType.createDataObject("property");
    priceProperty.set("name", "price");
    priceProperty.set("type", decimalType);
   
    DataObject quotesProperty = mixedQuoteType.createDataObject("property");
    quotesProperty.set("name", "quotes");
    quotesProperty.set("type", mixedQuoteType);
    quotesProperty.set("many", Boolean.TRUE);
    quotesProperty.set("containment", Boolean.TRUE);
   
    types.define(mixedQuoteType);
   
    DataObject quote = factory.create("http://www.example.com/mixed", "MixedQuote");

    assertTrue(quote.getType().isSequenced());
   
View Full Code Here

Examples of commonj.sdo.helper.TypeHelper

  }
 
  public void testDefineSequencedOpenType() throws Exception
  {
   
    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", "MixedOpenQuote");
    mixedQuoteType.set("sequenced", Boolean.TRUE);
    mixedQuoteType.set("open", Boolean.TRUE);
   
//    DataObject symbolProperty = mixedQuoteType.createDataObject("property");
//    symbolProperty.set("name", "symbol");
//    symbolProperty.set("type", stringType);
   
    DataObject companyNameProperty = mixedQuoteType.createDataObject("property");
    companyNameProperty.set("name", "companyName");
    companyNameProperty.set("type", stringType);
   
    DataObject priceProperty = mixedQuoteType.createDataObject("property");
    priceProperty.set("name", "price");
    priceProperty.set("type", decimalType);
   
    DataObject quotesProperty = mixedQuoteType.createDataObject("property");
    quotesProperty.set("name", "quotes");
    quotesProperty.set("type", mixedQuoteType);
    quotesProperty.set("many", Boolean.TRUE);
    quotesProperty.set("containment", Boolean.TRUE);
   
    types.define(mixedQuoteType);
   
    // Define a global type
    DataObject globalType = factory.create("commonj.sdo", "Type");
    globalType.set("uri", "http://www.example.com/open");
    // Don't set the type's name - null is used for types containing global properties.
   
    DataObject symbolProperty = globalType.createDataObject("property");
    symbolProperty.set("name", "symbol");
    symbolProperty.set("type", stringType);
    symbolProperty.set("containment", Boolean.TRUE);
   
    types.define(globalType);
   
    DataObject quote = factory.create("http://www.example.com/mixed", "MixedOpenQuote");

    assertTrue(quote.getType().isSequenced());
   
    Sequence sequence = quote.getSequence();

    sequence.add("\n  ");

    Type definedGlobalType = types.getType("http://www.example.com/open", null);
   
    Property definedSymbolProperty = definedGlobalType.getProperty("symbol");
    quote.setString(definedSymbolProperty, "fbnt");

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

Examples of commonj.sdo.helper.TypeHelper

    public void testXSDGeneration_DynamicWithNestedStaticSDOType() throws IOException
    {
        //testing static SDO with XSD Model being contained in a Dynamic SDO not having an XSD Model.
        //the schema must be generated with imports / includes for the XSD corresponding to the static
        //sdo types.
        TypeHelper typeHelper = SDOUtil.createTypeHelper();
        XSDHelper xsdHelper = SDOUtil.createXSDHelper(typeHelper);
       
        DataObject quoteSDO = (DataObject)SimpleFactoryImpl.INSTANCE.createQuote();
       
       
        DataObject quoteType = DataFactory.INSTANCE.create("commonj.sdo", "Type");
        quoteType.set("uri", "http://www.example.com/dynamic");
        quoteType.set("name", "DynamicQuote");
       
        DataObject aProperty = quoteType.createDataObject("property");
        aProperty.set("name", "symbol");
        aProperty.set("type", typeHelper.getType("commonj.sdo", "String"));
       
        aProperty = quoteType.createDataObject("property");
        aProperty.set("name", "price");
        aProperty.set("type", typeHelper.getType("commonj.sdo", "Decimal"));
       
        aProperty = quoteType.createDataObject("property");
        aProperty.set("name", "volume");
        aProperty.set("type", typeHelper.getType("commonj.sdo", "Double"));
       
        aProperty = quoteType.createDataObject("property");
        aProperty.set("name", "containedQuotes");
        aProperty.set("type", typeHelper.getType(quoteSDO.getType().getURI(), quoteSDO.getType().getName()));
        aProperty.set("containment", new Boolean(true));
       
        aProperty = quoteType.createDataObject("property");
        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;
       
        try
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.