Package org.apache.tuscany.das.rdb.config

Examples of org.apache.tuscany.das.rdb.config.Relationship


      if (p.getType().isDataType()) {
        if (obj.isSet(p))
          fields.add(p);
      } else {
        if ( obj.isSet(p) ) {
          Relationship relationship = config.getRelationshipByReference(p);
          if ( p.getOpposite().isMany() || (hasState(config, relationship, obj))) {             
            RelationshipWrapper r = new RelationshipWrapper(
              relationship);
            Iterator keys = r.getForeignKeys().iterator();
            while (keys.hasNext()) {
View Full Code Here


      return;
    }

    Iterator i = metadata.getRelationships().iterator();
    while (i.hasNext()) {
      Relationship r = (Relationship) i.next();

     
            DataObject parentTable = get(wrapper
          .getTablePropertyName(r.getPrimaryKeyTable()));
      DataObject childTable = get(wrapper
          .getTablePropertyName(r.getForeignKeyTable()));

      DebugUtil.debugln(getClass(), debug, "Parent table: " + parentTable);
      DebugUtil.debugln(getClass(), debug, "Child table: " + childTable);

      if ((parentTable == null) || (childTable == null))
        continue;

            Property p = parentTable.getType().getProperty(r.getName());
      setOrAdd(parentTable, childTable, p);
     
    }
  }
View Full Code Here

    while (i.hasNext()) {
      DataObject table = (DataObject) i.next();
   
      Iterator relationships = wrapper.getRelationshipsByChildTable(table.getType().getName()).iterator();
      while ( relationships.hasNext() ) {
        Relationship r = (Relationship) relationships.next();
   
        DataObject parentTable = findParentTable(table, r, wrapper);
       
        if (parentTable == null)
          continue;

                Property p = parentTable.getType().getProperty(r.getName());
        setOrAdd(parentTable, table, p);
      }
     
    }
  }
View Full Code Here

    private void initialize() {
        if (mappingWrapper.getConfig() != null) {
            List relationships = mappingWrapper.getConfig().getRelationship();
            Iterator i = relationships.iterator();
            while (i.hasNext()) {
                Relationship r = (Relationship) i.next();
                DebugUtil.debugln(getClass(), debug, "Initializing relationship: " + r.getName());
                if (r.getForeignKeyTable().equals(getTypeName())) {
                    List pairs = r.getKeyPair();
                    Iterator iter = pairs.iterator();
                    while (iter.hasNext()) {
                        KeyPair pair = (KeyPair) iter.next();
                        keyMappings.put(pair.getForeignKeyColumn(), r);
                    }
View Full Code Here

    public Object get(String parameter) {

        if (isPartOfPrimaryKey(parameter))
            return dataObject.get(parameter);

        Relationship r = (Relationship) keyMappings.get(parameter);
        if (r == null)
            return dataObject.get(parameter);

        Property parentRef = getParentReference(r.getPrimaryKeyTable());
        DataObject parent = dataObject.getDataObject(parentRef);
        if (parent == null)
            return null;
        String parentKey = getParentKey(r, parameter);
        return parent.get(parentKey);
View Full Code Here

      if ( mw.getConfig() == null )
        mw = registry.getFactory(changedObject.getType()).getConfig();
      if ( mw.getConfig() == null )
        return false;
     
      Relationship rel = mw.getRelationshipByReference(ref);     
     
      if ( !rel.isMany()) {
        // This is a one-one relationship
        Table t = mapping.getTableByPropertyName(changedObject.getType().getName());
        TableWrapper tw = new TableWrapper(t);
        RelationshipWrapper rw = new RelationshipWrapper(rel);
        if (( rel.getForeignKeyTable().equals(t.getName())) &&
            ( Collections.disjoint(tw.getPrimaryKeyProperties(),rw.getForeignKeys()) ))
          return true;
       
      }
   
View Full Code Here

            config = factory.createConfig();

        QualifiedColumn parent = new QualifiedColumn(parentName);
        QualifiedColumn child = new QualifiedColumn(childName);

        Relationship r = factory.createRelationship();
        r.setName(child.getTableName());
        r.setPrimaryKeyTable(parent.getTableName());
        r.setForeignKeyTable(child.getTableName());
        DebugUtil.debugln(getClass(), debug, "Created relationship from " + r.getPrimaryKeyTable() + " to "
                + r.getForeignKeyTable() + " named " + r.getName());

        KeyPair pair = factory.createKeyPair();
        pair.setPrimaryKeyColumn(parent.getColumnName());
        pair.setForeignKeyColumn(child.getColumnName());

        r.getKeyPair().add(pair);
        r.setMany(true);

        config.getRelationship().add(r);

    }
View Full Code Here

            config = factory.createConfig();

        QualifiedColumn parent = new QualifiedColumn((String) parentKey.getColumNames().get(0));
        QualifiedColumn child = new QualifiedColumn((String) childKey.getColumNames().get(0));

        Relationship r = factory.createRelationship();
        r.setName(child.getTableName());
        r.setPrimaryKeyTable(parent.getTableName());
        r.setForeignKeyTable(child.getTableName());
        DebugUtil.debugln(getClass(), debug, "Created relationship from " + r.getPrimaryKeyTable() + " to "
                + r.getForeignKeyTable() + " named " + r.getName());

        Iterator i = parentKey.getColumNames().iterator();
        Iterator j = childKey.getColumNames().iterator();
        while (i.hasNext() && j.hasNext()) {
            parent = new QualifiedColumn((String) i.next());
            child = new QualifiedColumn((String) j.next());
            KeyPair pair = factory.createKeyPair();
            pair.setPrimaryKeyColumn(parent.getColumnName());
            pair.setForeignKeyColumn(child.getColumnName());

            r.getKeyPair().add(pair);
        }
        r.setMany(true);
        config.getRelationship().add(r);

    }
View Full Code Here

    public boolean hasRecursiveRelationships() {
        if (config != null) {
            Iterator i = getConfig().getRelationship().iterator();
            while (i.hasNext()) {
                Relationship r = (Relationship) i.next();
                if (r.getPrimaryKeyTable().equals(r.getForeignKeyTable()))
                    return true;
            }
        }
        return false;
    }
View Full Code Here

    public Collection getRelationshipsByChildTable(String name) {
        ArrayList results = new ArrayList();
        if (config != null) {
            Iterator i = getConfig().getRelationship().iterator();
            while (i.hasNext()) {
                Relationship r = (Relationship) i.next();
                if (name.equals(r.getForeignKeyTable()))
                    results.add(r);
            }
        }
        return results;
    }
View Full Code Here

TOP

Related Classes of org.apache.tuscany.das.rdb.config.Relationship

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.