Examples of TypeHelper


Examples of commonj.sdo.helper.TypeHelper

            Command select = Command.FACTORY.createCommand("SELECT accountNumber, accountType, balance FROM accounts where id = :id", mapping);
            Connection conn = getConnection();
            select.setConnection(conn);
            select.setParameterValue("id", customerID);
            TypeHelper helper = TypeHelper.INSTANCE;
            select.setDataObjectModel(helper.getType(DataGraphRoot.class));
            DataGraphRoot root = (DataGraphRoot) select.executeQuery();
            accountReport.getAccountSummaries().addAll(root.getAccountSummaries());

            // Get Stocks

            select = Command.FACTORY.createCommand(
                    "SELECT Symbol, quantity, purchasePrice, purchaseDate, purchaseLotNumber  FROM stocks where id = :id", createConfigStream());
            select.setConnection(conn);
            select.setParameterValue("id", customerID);
            select.setDataObjectModel(helper.getType(DataGraphRoot.class));

            // select.addConverter("STOCKS.PURCHASEDATE", DateConverter.class.getName());

            root = (DataGraphRoot) select.executeQuery();
            accountReport.getStockSummaries().addAll(root.getStockSummaries());
View Full Code Here

Examples of commonj.sdo.helper.TypeHelper

            Command select = Command.FACTORY.createCommand("SELECT accountNumber, balance FROM accounts where accountNumber = :accountNumber",
                    createConfigStream());
            Connection conn = getConnection();
            select.setConnection(conn);
            select.setParameterValue("accountNumber", account);
            TypeHelper helper = TypeHelper.INSTANCE;
            select.setDataObjectModel(helper.getType(DataGraphRoot.class));
            DataGraphRoot root = (DataGraphRoot) select.executeQuery();
            Collection accounts = root.getAccountSummaries();
            AccountSummary accountData = (AccountSummary) accounts.iterator().next();
            float newbalance = accountData.getBalance() + ammount;
            accountData.setBalance(newbalance);
View Full Code Here

Examples of commonj.sdo.helper.TypeHelper

        try {
            CommandGroup commandGroup = CommandGroup.FACTORY.createCommandGroup(createConfigStream());
            commandGroup.setConnection(getConnection());

            Command read = commandGroup.getCommand("stockbylotSelect");
            TypeHelper helper = TypeHelper.INSTANCE;
            read.setDataObjectModel(helper.getType(DataGraphRoot.class));
            read.setParameterValue("PURCHASELOTNUMBER", purchaseLotNumber);// autoboxing :-)
            DataGraphRoot root = (DataGraphRoot) read.executeQuery();
            List stocks = root.getStockSummaries();
            if (null != stocks && !stocks.isEmpty()) {
                StockSummary stock = (StockSummary) stocks.get(0);
View Full Code Here

Examples of commonj.sdo.helper.TypeHelper

   * @link RelationshipMaker to transform
   * @link Metadata elements into EMF Schema elements.
   */

  public Type createTypes() {
    TypeHelper types = SDOUtil.createTypeHelper()
   
    DataObjectUtil.initRuntime();
    SDOUtil.createDataGraph();

 
View Full Code Here

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");
      else
        return helper.getType("commonj.sdo", "boolean");

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

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

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

    case Types.FLOAT:
    case Types.DOUBLE:
      if (isNullable)
        return helper.getType("commonj.sdo", "Double");
      else
        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

    }
  }
 
  public void testTypeRoundTrips() throws Exception {
    String URI = "commonj.sdo";
    TypeHelper types = TypeHelper.INSTANCE;
    List list = new ArrayList();
    list.add("foo");
    list.add("bar");
    list.add("test");
    Test[] tests = {
      new Test(types.getType(URI, "Boolean"),      "true", new Boolean(true)),
      new Test(types.getType(URI, "Byte"),         "49", new Byte((byte)49)),
      new Test(types.getType(URI, "Bytes"),        "Zm9v", "foo", new BytesComparator()),
      new Test(types.getType(URI, "Character"),    "a", new Character('a')),
      new Test(types.getType(URI, "Date"),         "2005-12-12Z", "2005-12-12Z", new DateComparator()),
      new Test(types.getType(URI, "DateTime"),     "2005-12-12T12:12:12Z", "2005-12-12T12:12:12Z"),
      new Test(types.getType(URI, "Day"),          "---12", "---12"),
      new Test(types.getType(URI, "Decimal"),      "12.12", new BigDecimal("12.12")),
      new Test(types.getType(URI, "Double"),       "12.12", new Double(12.12)),
      new Test(types.getType(URI, "Duration"),     "P5Y2M10D", "P5Y2M10D"),
      new Test(types.getType(URI, "Float"),        "12.12", new Float(12.12f)),
      new Test(types.getType(URI, "Int"),          "12", new Integer(12)),
      new Test(types.getType(URI, "Integer"),      "12", new BigInteger("12")),
      new Test(types.getType(URI, "Long"),         "12", new Long(12l)),
      new Test(types.getType(URI, "Month"),        "--12", "--12"),
      new Test(types.getType(URI, "MonthDay"),     "--12-12", "--12-12"),
      new Test(types.getType(URI, "Object"),       "test", "test"),
      new Test(types.getType(URI, "Short"),        "12", new Short((short)12)),
      new Test(types.getType(URI, "String"),       "test", "test"),
      new Test(types.getType(URI, "Strings"),      "foo bar test", list, new ListComparator()),
      new Test(types.getType(URI, "Time"),         "12:12:12.12", "12:12:12.12"),
      new Test(types.getType(URI, "URI"),          "http://example.org", "http://example.org"),
      new Test(types.getType(URI, "Year"),         "2005", "2005"),
      new Test(types.getType(URI, "YearMonth"),    "2005-12", "2005-12"),
      new Test(types.getType(URI, "YearMonthDay"), "2005-12-12", "2005-12-12")
    };
   
    for (int n = 0; n < tests.length; n++) {
      assertEquals(
        SDOUtil.convertToString(tests[n].type, SDOUtil.createFromString(tests[n].type, tests[n].value)),
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
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.