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

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


        else{
          parent = new QualifiedColumn(parentName);
          child = new QualifiedColumn(childName);         
        }
       
        Relationship r = FACTORY.createRelationship();
        //JIRA-952
        if(this.config.isDatabaseSchemaNameSupported()){         
            r.setName(child.getSchemaName()+"."+child.getTableName());
            r.setPrimaryKeyTable(parent.getSchemaName()+"."+parent.getTableName());
            r.setForeignKeyTable(child.getSchemaName()+"."+child.getTableName());         
        }
        else{
        r.setName(child.getTableName());
        r.setPrimaryKeyTable(parent.getTableName());
        r.setForeignKeyTable(child.getTableName());
        }

        if (this.logger.isDebugEnabled()) {
            this.logger.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);

        return r;
View Full Code Here


      checkSchemaNames(parentColumns);
       
        checkTableNames(childColumns);
      checkSchemaNames(childColumns);
       
        Relationship r = FACTORY.createRelationship();
        //JIRA-952
        if(this.config.isDatabaseSchemaNameSupported()){         
            r.setName(((QualifiedColumn)childColumns.get(0)).getSchemaName()+"."
                +((QualifiedColumn)childColumns.get(0)).getTableName());
            r.setPrimaryKeyTable(((QualifiedColumn)parentColumns.get(0)).getSchemaName()+"."
                +((QualifiedColumn)parentColumns.get(0)).getTableName());
            r.setForeignKeyTable(((QualifiedColumn)childColumns.get(0)).getSchemaName()+"."
                +((QualifiedColumn)childColumns.get(0)).getTableName());         
        }
        else{
        r.setName(((QualifiedColumn)childColumns.get(0)).getTableName());
        r.setPrimaryKeyTable(((QualifiedColumn)parentColumns.get(0)).getTableName());
        r.setForeignKeyTable(((QualifiedColumn)childColumns.get(0)).getTableName());
        }

        if (this.logger.isDebugEnabled()) {
            this.logger.debug("Created relationship from " + r.getPrimaryKeyTable()
                    + " to " + r.getForeignKeyTable() + " named " + r.getName());
        }
       
        KeyPair pair = null;
       
        for(int i=0; i<parentColumns.size(); i++){
            pair = FACTORY.createKeyPair();
            pair.setPrimaryKeyColumn(((QualifiedColumn)parentColumns.get(i)).getColumnName());
            pair.setForeignKeyColumn(((QualifiedColumn)childColumns.get(i)).getColumnName());
            r.getKeyPair().add(pair);
        }
       
        r.setMany(true);
        config.getRelationship().add(r);

        return 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) {
        List 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

        List parents = new ArrayList();
        List children = new ArrayList();
        if (config != null) {
            Iterator i = getConfig().getRelationship().iterator();
            while (i.hasNext()) {
                Relationship r = (Relationship) i.next();
                parents.add(r.getPrimaryKeyTable());
                children.add(r.getForeignKeyTable());
                parentToChild.put(r.getPrimaryKeyTable(), r.getForeignKeyTable());
            }
            while (parents.size() > 0) {
                String parent = (String) parents.get(0);
                if (!children.contains(parent)) {
                    if (!inserts.contains(parent)) {
View Full Code Here

    }

    public Relationship getRelationshipByReference(Property ref) {
        Iterator i = config.getRelationship().iterator();
        while (i.hasNext()) {
            Relationship r = (Relationship) i.next();
            if (ref.getName().equals(r.getName()) || ref.getOpposite().getName().equals(r.getName())) {
                return r;
            }
        }
        throw new RuntimeException("Could not find relationship " + ref.getName() + " in the configuration");
    }
View Full Code Here

    }

    public Relationship getRelationshipByName(String name) {
        Iterator i = config.getRelationship().iterator();
        while (i.hasNext()) {
            Relationship r = (Relationship) i.next();
            if (name.equals(r.getName())) {
                return r;
            }
        }
        throw new RuntimeException("Could not find relationship " + name + " in the configuration");
    }
View Full Code Here

        parentColumnNames.add(1, "ORDERDETAILS.PRODUCTID");

        childColumnNames.add(0, "ORDERDETAILSDESC.ORDERID");
        childColumnNames.add(1, "ORDERDETAILSDESC.PRODUCTID");       
       
        Relationship r = helper.addRelationship(parentColumnNames, childColumnNames);

        DAS das = DAS.FACTORY.createDAS(helper.getConfig(), getConnection());
        Command select = das.createCommand("SELECT * FROM ORDERDETAILS LEFT JOIN ORDERDETAILSDESC ON ORDERDETAILS.ORDERID = ORDERDETAILSDESC.ORDERID " +
                    " AND ORDERDETAILS.PRODUCTID = ORDERDETAILSDESC.PRODUCTID");

View Full Code Here

        parentColumnNames.add(1, "ORDERDETAILS.PRODUCTID");

        childColumnNames.add(0, "ORDERDETAILSDESC.ORDERID_INVALID");
        childColumnNames.add(1, "ORDERDETAILSDESC.PRODUCTID");       
       
        Relationship r = helper.addRelationship(parentColumnNames, childColumnNames);

        DAS das = DAS.FACTORY.createDAS(helper.getConfig(), getConnection());
        Command select = das.createCommand("SELECT * FROM ORDERDETAILS LEFT JOIN ORDERDETAILSDESC ON ORDERDETAILS.ORDERID = ORDERDETAILSDESC.ORDERID " +
                    " AND ORDERDETAILS.PRODUCTID = ORDERDETAILSDESC.PRODUCTID");

View Full Code Here

        }
        if (mw.getConfig() == null) {
            return false;
        }

        Relationship rel = mw.getRelationshipByReference(ref);

        if (!rel.isMany()) {
            if (rel.isKeyRestricted()) {
                throw new RuntimeException("Can not modify a one to one relationship that is key restricted");
            }
            // This is a one-one relationship
            Table t = mapping.getTableByTypeName(changedObject.getType().getName());
            TableWrapper tw = new TableWrapper(t);
            RelationshipWrapper rw = new RelationshipWrapper(rel);
            if ((rel.getForeignKeyTable().equals(t.getTableName()))
                    && (Collections.disjoint(tw.getPrimaryKeyProperties(), rw.getForeignKeys()))) {
                return true;
            }

        }
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.