Package commonj.sdo

Examples of commonj.sdo.Type


     
      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\");");
     
      Type testType = scope.getTypeHelper().getType("http://example.com/customer", "Customer");
      List props = testType.getProperties();
      for (int i = 0; i < props.size(); i++) {
          System.out.println(props.get(i));
      }

      commentary("Now we can create an instance of the type using the DataFactory associated with the type scope\n\n"+
View Full Code Here


        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

    public SDOSimpleTypeMapper() {
        super();
    }

    public Object toJavaObject(QName typeName, String value, TransformationContext context) {
        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();
View Full Code Here

        }
        return SDOUtil.createFromString(type, value);
    }

    public String toXMLLiteral(QName typeName, Object obj, TransformationContext context) {
        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();
View Full Code Here

            public HelperContext run() {
                return SDOContextHelper.getHelperContext(operation);
            }
        });

        final Type type = context.getTypeHelper().getType(javaType);
        if (type == null) {
            // FIXME: Need a better to test dynamic SDO
            if (DataObject.class.isAssignableFrom(javaType)) {
                // Dynamic SDO
                dataType.setDataBinding(getName());
                if (dataType.getLogical() == null) {
                    dataType.setLogical(XMLType.UNKNOWN);
                }
                return true;
            }
            return false;
        }
        if (type.isDataType()) {
            // FIXME: Ignore simple types?
            return false;
        }

        // Found a SDO type, replace the default context with a private one
        AccessController.doPrivileged(new PrivilegedAction<Object>() {
            public Object run() {
                if (context == SDOContextHelper.getDefaultHelperContext()) {
                    HelperContext newContext = SDOUtil.createHelperContext();
                    SDOContextHelper.register(newContext, type);
                    if (operation != null) {
                        operation.getInputType().setMetaData(HelperContext.class, newContext);
                    }
                } else {
                    SDOContextHelper.register(context, type);
                }
                return null;
            }
        });

        String namespace = type.getURI();
        String name = context.getXSDHelper().getLocalName(type);
        QName xmlType = new QName(namespace, name);
        dataType.setDataBinding(getName());
        QName elementName = null;
        Object logical = dataType.getLogical();
View Full Code Here

    public static boolean register(HelperContext helperContext, Class javaType) {
        if (javaType == null || DataObject.class == javaType) {
            return false;
        }
        try {
            Type type = helperContext.getTypeHelper().getType(javaType);
            return register(helperContext, type);
        } catch (Exception e) {
            throw new TransformationException(e);
        }
    }
View Full Code Here

    public static String generateSchema(HelperContext context, Class<?>[] classes) {
        TypeHelper typeHelper = context.getTypeHelper();
        List<Type> types = new ArrayList<Type>();
        for (Class<?> cls : classes) {
            Type type = typeHelper.getType(cls);
            if (type != null) {
                types.add(type);
            }
        }
        return generateSchema(context, types);
View Full Code Here

    // Get a Type from the package and create a standalone DataObject

    DebugUtil.debugln(getClass(), this.debug, "Looking for Type for "
        + tableData.getTableName());

    Type tableClass = findTableTypeByPropertyName(tableData.getTableName());

    if (tableClass == null)
      throw new RuntimeException("An SDO Type with name "
          + tableData.getTableName() + " was not found");
View Full Code Here

   * @param xsdType a type name in the XML Schema namespace.
   * @return the SDO built-in Type corresponding to the specified XSD type.
   */
  public static Type getXSDSDOType(String xsdType)
  {   
    Type type = null;
    if ("anyType".equals(xsdType)) {
      type = (Type)SDOPackage.eINSTANCE.getDataObject();
    } else {
      String name = (String)xsdToSdoMappings.get(xsdType);
      if (name != null) {
View Full Code Here

  }
 
  public static DataObject createDataObject(DataObject dataObject, int propertyIndex, String namespaceURI, String typeName)
  {
    Property property = DataObjectUtil.getProperty(dataObject, propertyIndex);
    Type type = DataObjectUtil.getType(dataObject, namespaceURI, typeName);
    return createDataObject(dataObject, property, type);
  }
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.