Package commonj.sdo.helper

Examples of commonj.sdo.helper.TypeHelper


   
      commentary("A TypeHelper is used for both looking up types,  and later creating them\n\n"+
          "TypeHelper typeHelper = scope.getTypeHelper();");
     
      TypeHelper typeHelper = scope.getTypeHelper();
     
      commentary("We can look up existing types to use in the creation of Properties\n\n"+
          "Type intType = types.getType(\"commonj.sdo\", \"Int\");\n"+
          "Type stringType = types.getType(\"commonj.sdo\", \"String\");");
     
      Type intType = typeHelper.getType("commonj.sdo", "Int");
      Type stringType = typeHelper.getType("commonj.sdo", "String");
     
      commentary("To begin modelling the type system we create a DataObject with\n"+
          "Type \"commonj.sdo#Type\" and set the URI and name for that type\n\n"+
         
          "DataObject customerType = scope.getDataFactory().create(\"commonj.sdo\", \"Type\");\n"+
          "customerType.set(\"uri\", \"http://example.com/customer\");\n"+
          "customerType.set(\"name\", \"Customer\");");
     
      DataObject customerType = scope.getDataFactory().create("commonj.sdo", "Type");
      customerType.set("uri", "http://example.com/customer");
      customerType.set("name", "Customer");
     
      commentary("Now we can create a model for the Properties for the Type\n"+
          "and set the name and Types of those Properties\n\n"+
          "DataObject custNumProperty = customerType.createDataObject(\"property\");\n"+
          "custNumProperty.set(\"name\", \"custNum\");\n"+
          "custNumProperty.set(\"type\", intType);"
      );
     
      DataObject custNumProperty = customerType.createDataObject("property");
      custNumProperty.set("name", "custNum");
      custNumProperty.set("type", intType);
     
      commentary("We continue in this manner until all the Types and their Properties are modelled");
      DataObject lastNameProperty = customerType.createDataObject("property");
      lastNameProperty.set("name", "lastName");
      lastNameProperty.set("type", stringType);
     
      DataObject firstNameProperty = customerType.createDataObject("property");
      firstNameProperty.set("name", "firstName");
      firstNameProperty.set("type", stringType);
     
      commentary("Now that our type is fully modelled we submit the model to the TypeHelper\n"+
          "The new Type instance is retuend to us,  but is also available for lookup within\n"+
          "the scope associated with the TypeHelper\n\n"+
          "Type t = typeHelper.define(customerType);");
      Type t = typeHelper.define(customerType);
     
      commentary("Here we see the newly created Type being accessed via the TypeHelper\n"+
          "along with a printout of the Type's Properties\n\n"+
          "Type testType = scope.getTypeHelper().getType(\"http://example.com/customer\", \"Customer\");");
     
View Full Code Here


        URL url = getClass().getResource("/ipo.xsd");
        Assert.assertNotNull(url);
        InputStream is = url.openStream();
        XSDHelper xsdHelper = context.getXSDHelper();
        xsdHelper.define(is, url.toExternalForm());
        TypeHelper typeHelper = context.getTypeHelper();
        Type type = typeHelper.getType("http://www.example.com/IPO", "PurchaseOrderType");
        Assert.assertNotNull(type);
        /*
        SDOContextHelper.generateSchema(context, Arrays.asList(type));
        */
    }
View Full Code Here

        Type type = null;
        if (URI_2001_SCHEMA_XSD.equals(typeName.getNamespaceURI())) {
            type = SDOUtil.getXSDSDOType(typeName.getLocalPart());
        } else {
            HelperContext helperContext = SDOContextHelper.getHelperContext(context, false);
            TypeHelper typeHelper = helperContext.getTypeHelper();
            type = typeHelper.getType(typeName.getNamespaceURI(), typeName.getLocalPart());
        }
        return SDOUtil.createFromString(type, value);
    }
View Full Code Here

        Type type = null;
        if (URI_2001_SCHEMA_XSD.equals(typeName.getNamespaceURI())) {
            type = SDOUtil.getXSDSDOType(typeName.getLocalPart());
        } else {
            HelperContext helperContext = SDOContextHelper.getHelperContext(context, true);
            TypeHelper typeHelper = helperContext.getTypeHelper();
            type = typeHelper.getType(typeName.getNamespaceURI(), typeName.getLocalPart());
        }
        return SDOUtil.convertToString(type, obj);
    }
View Full Code Here

        Command select = Command.FACTORY.createCommand("SELECT firstName, lastName, loginID, password, id FROM customers where loginID = :loginID",
                mapping);
        Connection conn = createConnection();
        select.setConnection(conn);
        select.setParameterValue("loginID", logonID);
        TypeHelper helper = TypeHelper.INSTANCE;

        select.setDataObjectModel(helper.getType(DataGraphRoot.class));

        DataGraphRoot root = (DataGraphRoot) select.executeQuery();
        conn.close();

        Collection customers = root.getCustomerProfileData();
View Full Code Here

        Command select = Command.FACTORY.createCommand("SELECT accountNumber, balance FROM accounts where accountNumber = :accountNumber",
                createConfigStream());
        Connection conn = createConnection();
        select.setConnection(conn);
        select.setParameterValue("accountNumber", wd.getAccountNumber());
        TypeHelper helper = TypeHelper.INSTANCE;

        select.setDataObjectModel(helper.getType(DataGraphRoot.class));

        DataGraphRoot root = (DataGraphRoot) select.executeQuery();

        Collection accounts = root.getAccountSummaries();
        AccountSummary account = (AccountSummary) accounts.iterator().next();
View Full Code Here

    SDOUtil.registerStaticTypes(CustomerFactory.class);
    InputStream mapping = getClass().getClassLoader().getResourceAsStream("basicStaticCustomer.xml");
    Command select = Command.FACTORY.createCommand("Select ID, LASTNAME, ADDRESS from CUSTOMER where LASTNAME = :LASTNAME",mapping);
    select.setConnection(getConnection());
    select.setParameterValue("LASTNAME", "Williams");
    TypeHelper helper = TypeHelper.INSTANCE;
   
    select.setDataObjectModel(helper.getType(DataGraphRoot.class));
   
    DataGraphRoot root = (DataGraphRoot) select.executeQuery();
   
    Collection customers = root.getCustomers();
    assertEquals(4, customers.size());
View Full Code Here

            Command select = Command.FACTORY.createCommand(
                    "SELECT firstName, lastName, loginID, password, id FROM customers where loginID = :loginID", mapping);
            Connection conn = getConnection();
            select.setConnection(conn);
            select.setParameterValue("loginID", logonID);
            TypeHelper helper = TypeHelper.INSTANCE;

            select.setDataObjectModel(helper.getType(DataGraphRoot.class));

            DataGraphRoot root = (DataGraphRoot) select.executeQuery();
            conn.close();

            Collection customers = root.getCustomerProfileData();
View Full Code Here

        Command select = Command.FACTORY.createCommand("SELECT firstName, lastName, loginID, password, id FROM customers where loginID = :loginID",
                mapping);
        Connection conn = getConnection();
        select.setConnection(conn);
        select.setParameterValue("loginID", logonID);
        TypeHelper helper = TypeHelper.INSTANCE;

        select.setDataObjectModel(helper.getType(DataGraphRoot.class));

        DataGraphRoot root = (DataGraphRoot) select.executeQuery();
        conn.close();

        Collection customers = root.getCustomerProfileData();
View Full Code Here

            CommandGroup commandGroup = CommandGroup.FACTORY.createCommandGroup(createConfigStream());
            commandGroup.setConnection(getConnection());
            Command read = commandGroup.getCommand("all customers");

            // select.setDataObjectModel();
            TypeHelper helper = TypeHelper.INSTANCE;
            read.setDataObjectModel(helper.getType(DataGraphRoot.class));
            DataObject root = read.executeQuery();

            // Create a new stockPurchase
            DataObject customer = root.createDataObject("customerProfileData");
View Full Code Here

TOP

Related Classes of commonj.sdo.helper.TypeHelper

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.