Package commonj.sdo

Examples of commonj.sdo.Type


  }
 
  public static DataObject createDataObject(DataObject dataObject, String propertyName, String namespaceURI, String typeName)
  {
    Property property = getProperty(dataObject, propertyName);
    Type type = DataObjectUtil.getType(dataObject, namespaceURI, typeName);
    return createDataObject(dataObject, property, type);
  }
View Full Code Here


    return createDataObject(dataObject, property, type);
  }
 
  public static DataObject createDataObject(DataObject dataObject, Property property)
  {
    Type type = property.getType();
    return createDataObject(dataObject, property, type);
  }
View Full Code Here

  }
 
  public static DataObject createDataObject(DataObject dataObject, int propertyIndex)
  {
    Property property = getProperty(dataObject, propertyIndex);
    Type type = property.getType();
    return createDataObject(dataObject,property, type);
  }
View Full Code Here

  }

  public static DataObject createDataObject(DataObject dataObject, String propertyName)
  {
    Property property = (Property)getProperty(dataObject, propertyName);
    Type type = property.getType();
    return createDataObject(dataObject,property, type);
  }
View Full Code Here

        writer.print("public interface ");
        writer.print(name);
        List baseTypes = type.getBaseTypes();
        for (int i = 0; i < baseTypes.size(); i++) {
            Type baseType = (Type) baseTypes.get(i);
            if (i == 0) {
                writer.print(" extends ");
            } else {
                writer.print(", ");
            }
            writer.print(baseType.getInstanceClass().getName());
        }

        writer.println(" {");
    }
View Full Code Here

        }

        List baseTypes = type.getBaseTypes();
        String[] interfaces = new String[baseTypes.size()];
        for (int i = 0; i < baseTypes.size(); i++) {
            Type baseType = (Type) baseTypes.get(i);
            interfaces[i] = baseType.getInstanceClass().getName().replace('.', '/');
        }

        cw.visit(Opcodes.V1_4,
                 Opcodes.ACC_PUBLIC + Opcodes.ACC_ABSTRACT + Opcodes.ACC_INTERFACE,
                 name, null, "java/lang/Object", interfaces);
View Full Code Here

    private final String TEST_MODEL = "/datatype.xsd";
    private final String TEST_NAMESPACE = "http://www.example.com/datatype";

    public void testSimpleSDOType() throws IOException
    {
      Type type = TypeHelper.INSTANCE.getType(TEST_NAMESPACE, "SimpleSDOType");
      List baseTypes = type.getBaseTypes();
      assertTrue(baseTypes.size() == 1);
    }
View Full Code Here

      assertTrue(baseTypes.size() == 1);
    }
   
    public void testSimpleSDOTypeInstanceClass() throws IOException
    {
      Type type = TypeHelper.INSTANCE.getType(TEST_NAMESPACE, "SimpleSDOTypeInstanceClass");
      List baseTypes = type.getBaseTypes();
      assertTrue(baseTypes.size() == 0);
    }
View Full Code Here

   
    DataObjectUtil.initRuntime();
    SDOUtil.createDataGraph();

 
    Type rootType = SDOUtil.createType(types, getURI(), "DataGraphRoot", false)

    Iterator iter = metadata.getResultMetadata().iterator();
    while (iter.hasNext()) {

      ResultMetadata resultMetadata = (ResultMetadata) iter.next();

      Iterator names = resultMetadata.getAllTablePropertyNames()
          .iterator();
      while (names.hasNext()) {
        String tableName = (String) names.next();
 
        Type tableType = SDOUtil.createType(types, getURI(), tableName, false);                   
        Property property = SDOUtil.createProperty(rootType, tableName, tableType);
        SDOUtil.setMany(property,true);   
        SDOUtil.setContainment(property, true);
      }
   
      // TODO tablePropertyMap is temporary until Tuscany-203 is fixed
      HashMap tablePropertyMap = new HashMap();
     
      for (int i = 1; i <= resultMetadata.getColumnNames().size(); i++) {

        Property ref = rootType.getProperty(resultMetadata.getTablePropertyName(i));
       
        // TODO Temporary code to check to see if a property has already been added.
        // Replace when Tuscany-203 is fixed
        ArrayList addedProperties = (ArrayList) tablePropertyMap.get(ref.getName());
        if ( addedProperties == null ) {
          addedProperties = new ArrayList();
          tablePropertyMap.put(ref.getName(), addedProperties);
        }
       
        if (ref == null)
          throw new RuntimeException("Could not find table "
              + resultMetadata.getTablePropertyName(i)
              + " in the SDO model");
     
        String columnName = resultMetadata.getColumnPropertyName(i);

        // TODO temporary check until Tuscany-203 is fixed
        if ( !addedProperties.contains(columnName)) {
          addedProperties.add(columnName);
          Type atype = (Type) resultMetadata.getDataType(i);         
 
          SDOUtil.createProperty(ref.getType(), columnName, atype);       

          DebugUtil.debugln(getClass(), debug, "Adding column "
              + columnName + " to "
              + resultMetadata.getTablePropertyName(i))
        }

      }
    }

    if (metadata.hasMappingModel()) {
      MappingWrapper wrapper = new MappingWrapper(metadata.getMapping());
      Iterator i = metadata.getRelationships().iterator();
      while (i.hasNext()) {
        Relationship r = (Relationship) i.next();

        Type parent = rootType.getProperty(
            wrapper.getTablePropertyName(r.getPrimaryKeyTable())).getType();
        Type child = rootType.getProperty(
            wrapper.getTablePropertyName(r.getForeignKeyTable())).getType();
        if (parent == null) {
          throw new RuntimeException("The parent table ("
              + r.getPrimaryKeyTable() + ") in relationship "
              + r.getName()
View Full Code Here

    super();
  }

  public UpdateCommandImpl getUpdateCommand(MappingWrapper mapping, DataObject changedObject, Table table) {
    ArrayList parameters = new ArrayList();
    Type type = changedObject.getType();
    TableWrapper t = new TableWrapper(table);
    StringBuffer statement = new StringBuffer("update ");
    statement.append(table.getName());
    statement.append(" set ");

   
    ChangeSummary summary = changedObject.getDataGraph().getChangeSummary();
    Iterator i = getChangedFields(mapping, summary, changedObject).iterator();

    while (i.hasNext()) {
      Property attr = (Property) i.next();
      Column c = t.getColumnByPropertyName(attr.getName());
      if ((c != null) && (c.isCollision() || c.isPrimaryKey())) {
        // get rid of comma if OCC or PK is last field
        if (!i.hasNext()) {
          statement
              .delete(statement.length() - 2, statement.length());
        }
      } else {
        parameters.add(attr);
        statement.append(c == null ? attr.getName() : c.getName());
        statement.append(" = ?");
        if (i.hasNext())
          statement.append(", ");
      }
    }

    statement.append(" where ");

    Iterator names = t.getPrimaryKeyNames().iterator();
    Iterator properties = t.getPrimaryKeyProperties().iterator();
    while (names.hasNext() && properties.hasNext()) {
      String name = (String) names.next();
      String property = (String) properties.next();
      statement.append(name);
      statement.append(" = ?");
      if (names.hasNext() && properties.hasNext())
        statement.append(" and ");
      parameters.add(type.getProperty(property));
    }

    if (t.getCollisionColumn() != null) {
      statement.append(" and ");
      statement.append(t.getCollisionColumn().getName());
      statement.append(" = ?");
      parameters.add(type.getProperty(t.getCollisionColumnPropertyName()));
    }

   
    UpdateCommandImpl updateCommand;
    if ( t.getCollisionColumn() != null )
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.