Examples of ExportedKey


Examples of org.apache.cayenne.access.reveng.ExportedKey

            // is found in the result set (which should be ordered by table name among
            // other things)
            DbRelationship forwardRelationship = null;
            DbRelationshipDetected reverseRelationship = null;
            DbEntity fkEntity = null;
            ExportedKey key = null;

            do {
                //extract data from resultset
                key = ExportedKey.extractData(rs);
               
                short keySeq = rs.getShort("KEY_SEQ");
                if (keySeq == 1) {

                    if (forwardRelationship != null) {
                        postprocessMasterDbRelationship(forwardRelationship, key);
                        forwardRelationship = null;
                    }

                    // start new entity
                    String fkEntityName = key.getFKTableName();
                    String fkName = key.getFKName();
                   
                    if (!includeTableName(fkEntityName)) {
                        continue;
                    }
                   
                    fkEntity = map.getDbEntity(fkEntityName);

                    if (fkEntity == null) {
                        logObj.info("FK warning: no entity found for name '"
                                + fkEntityName
                                + "'");
                    } else if (skippedEntities.contains(pkEntity) && skippedEntities.contains(fkEntity)) {
                        // cay-479 - don't load relationships between two
                        // skipped entities.
                        continue;
                    }
                    else {
                        // init relationship
                        String forwardPreferredName = namingStrategy.createDbRelationshipName(key, true);
                        forwardRelationship = new DbRelationship(
                                uniqueRelName(pkEntity, forwardPreferredName));

                        forwardRelationship.setSourceEntity(pkEntity);
                        forwardRelationship.setTargetEntity(fkEntity);
                        pkEntity.addRelationship(forwardRelationship);

                        String reversePreferredName = namingStrategy.createDbRelationshipName(key, false);
                        reverseRelationship = new DbRelationshipDetected(uniqueRelName(
                                fkEntity,
                                reversePreferredName));
                        reverseRelationship.setFkName(fkName);
                        reverseRelationship.setToMany(false);
                        reverseRelationship.setSourceEntity(fkEntity);
                        reverseRelationship.setTargetEntity(pkEntity);
                        fkEntity.addRelationship(reverseRelationship);
                    }
                }

                if (fkEntity != null) {
                    // Create and append joins
                    String pkName = key.getPKColumnName();
                    String fkName = key.getFKColumnName();

                    // skip invalid joins...
                    DbAttribute pkAtt = (DbAttribute) pkEntity.getAttribute(pkName);
                    if (pkAtt == null) {
                        logObj.info("no attribute for declared primary key: "
View Full Code Here

Examples of org.apache.cayenne.map.naming.ExportedKey

            // is found in the result set (which should be ordered by table name among
            // other things)
            DbRelationship forwardRelationship = null;
            DbRelationshipDetected reverseRelationship = null;
            DbEntity fkEntity = null;
            ExportedKey key = null;

            do {
                // extract data from resultset
                key = ExportedKey.extractData(rs);

                short keySeq = rs.getShort("KEY_SEQ");
                if (keySeq == 1) {

                    if (forwardRelationship != null) {
                        postprocessMasterDbRelationship(forwardRelationship, key);
                        forwardRelationship = null;
                    }

                    // start new entity
                    String fkEntityName = key.getFKTableName();
                    String fkName = key.getFKName();

                    if (!includeTableName(fkEntityName)) {
                        continue;
                    }

                    fkEntity = map.getDbEntity(fkEntityName);

                    if (fkEntity == null) {
                        logObj.info("FK warning: no entity found for name '"
                                + fkEntityName
                                + "'");
                    }
                    else if (skippedEntities.contains(pkEntity)
                            && skippedEntities.contains(fkEntity)) {
                        // cay-479 - don't load relationships between two
                        // skipped entities.
                        continue;
                    }
                    else {
                        // init relationship
                        String forwardPreferredName = namingStrategy
                                .createDbRelationshipName(key, true);
                        forwardRelationship = new DbRelationship(uniqueRelName(
                                pkEntity,
                                forwardPreferredName));

                        forwardRelationship.setSourceEntity(pkEntity);
                        forwardRelationship.setTargetEntity(fkEntity);
                        pkEntity.addRelationship(forwardRelationship);

                        String reversePreferredName = namingStrategy
                                .createDbRelationshipName(key, false);
                        reverseRelationship = new DbRelationshipDetected(uniqueRelName(
                                fkEntity,
                                reversePreferredName));
                        reverseRelationship.setFkName(fkName);
                        reverseRelationship.setToMany(false);
                        reverseRelationship.setSourceEntity(fkEntity);
                        reverseRelationship.setTargetEntity(pkEntity);
                        fkEntity.addRelationship(reverseRelationship);
                    }
                }

                if (fkEntity != null) {
                    // Create and append joins
                    String pkName = key.getPKColumnName();
                    String fkName = key.getFKColumnName();

                    // skip invalid joins...
                    DbAttribute pkAtt = (DbAttribute) pkEntity.getAttribute(pkName);
                    if (pkAtt == null) {
                        logObj.info("no attribute for declared primary key: " + pkName);
View Full Code Here

Examples of org.apache.cayenne.map.naming.ExportedKey

            // is found in the result set (which should be ordered by table name among
            // other things)
            DbRelationship forwardRelationship = null;
            DbRelationshipDetected reverseRelationship = null;
            DbEntity fkEntity = null;
            ExportedKey key = null;

            do {
                // extract data from resultset
                key = ExportedKey.extractData(rs);

                short keySeq = rs.getShort("KEY_SEQ");
                if (keySeq == 1) {

                    if (forwardRelationship != null) {
                        postprocessMasterDbRelationship(forwardRelationship, key);
                        forwardRelationship = null;
                    }

                    // start new entity
                    String fkEntityName = key.getFKTableName();
                    String fkName = key.getFKName();

                    if (!includeTableName(fkEntityName)) {
                        continue;
                    }

                    fkEntity = map.getDbEntity(fkEntityName);

                    if (fkEntity == null) {
                        logObj.info("FK warning: no entity found for name '"
                                + fkEntityName
                                + "'");
                    }
                    else if (skippedEntities.contains(pkEntity)
                            && skippedEntities.contains(fkEntity)) {
                        // cay-479 - don't load relationships between two
                        // skipped entities.
                        continue;
                    }
                    else {
                        // init relationship
                        String forwardPreferredName = namingStrategy
                                .createDbRelationshipName(key, true);
                        forwardRelationship = new DbRelationship(uniqueRelName(
                                pkEntity,
                                forwardPreferredName));

                        forwardRelationship.setSourceEntity(pkEntity);
                        forwardRelationship.setTargetEntity(fkEntity);
                        pkEntity.addRelationship(forwardRelationship);

                        String reversePreferredName = namingStrategy
                                .createDbRelationshipName(key, false);
                        reverseRelationship = new DbRelationshipDetected(uniqueRelName(
                                fkEntity,
                                reversePreferredName));
                        reverseRelationship.setFkName(fkName);
                        reverseRelationship.setToMany(false);
                        reverseRelationship.setSourceEntity(fkEntity);
                        reverseRelationship.setTargetEntity(pkEntity);
                        fkEntity.addRelationship(reverseRelationship);
                    }
                }

                if (fkEntity != null) {
                    // Create and append joins
                    String pkName = key.getPKColumnName();
                    String fkName = key.getFKColumnName();

                    // skip invalid joins...
                    DbAttribute pkAtt = (DbAttribute) pkEntity.getAttribute(pkName);
                    if (pkAtt == null) {
                        logObj.info("no attribute for declared primary key: " + pkName);
View Full Code Here

Examples of org.apache.cayenne.map.naming.ExportedKey

            // among
            // other things)
            DbRelationship forwardRelationship = null;
            DbRelationshipDetected reverseRelationship = null;
            DbEntity fkEntity = null;
            ExportedKey key = null;

            do {
                // extract data from resultset
                key = ExportedKey.extractData(rs);

                short keySeq = rs.getShort("KEY_SEQ");
                if (keySeq == 1) {

                    if (forwardRelationship != null) {
                        postprocessMasterDbRelationship(forwardRelationship,
                                key);
                        forwardRelationship = null;
                    }

                    // start new entity
                    String fkEntityName = key.getFKTableName();
                    String fkName = key.getFKName();

                    if (!includeTableName(fkEntityName)) {
                        continue;
                    }

                    fkEntity = map.getDbEntity(fkEntityName);

                    if (fkEntity == null) {
                        logger.info("FK warning: no entity found for name '"
                                + fkEntityName + "'");
                    } else if (skippedEntities.contains(pkEntity)
                            && skippedEntities.contains(fkEntity)) {
                        // cay-479 - don't load relationships between two
                        // skipped entities.
                        continue;
                    } else {
                        // init relationship
                        String forwardPreferredName = namingStrategy
                                .createDbRelationshipName(key, true);
                        forwardRelationship = new DbRelationship(uniqueRelName(
                                pkEntity, forwardPreferredName));

                        forwardRelationship.setSourceEntity(pkEntity);
                        forwardRelationship.setTargetEntity(fkEntity);
                        pkEntity.addRelationship(forwardRelationship);

                        String reversePreferredName = namingStrategy
                                .createDbRelationshipName(key, false);
                        reverseRelationship = new DbRelationshipDetected(
                                uniqueRelName(fkEntity, reversePreferredName));
                        reverseRelationship.setFkName(fkName);
                        reverseRelationship.setToMany(false);
                        reverseRelationship.setSourceEntity(fkEntity);
                        reverseRelationship.setTargetEntity(pkEntity);
                        fkEntity.addRelationship(reverseRelationship);
                    }
                }

                if (fkEntity != null) {
                    // Create and append joins
                    String pkName = key.getPKColumnName();
                    String fkName = key.getFKColumnName();

                    // skip invalid joins...
                    DbAttribute pkAtt = (DbAttribute) pkEntity
                            .getAttribute(pkName);
                    if (pkAtt == null) {
View Full Code Here

Examples of org.apache.cayenne.map.naming.ExportedKey

        }
    }

    public void createName() {

        ExportedKey key = null;
        for (InferRelationships myir : ir) {
            if (myir.getJoinSource().isPrimaryKey()) {
                key = getExportedKey(myir.getSource().getName(), myir
                        .getJoinSource()
                        .getName(), myir.getTarget().getName(), myir
View Full Code Here

Examples of org.apache.cayenne.map.naming.ExportedKey

    public ExportedKey getExportedKey(
            String pkTable,
            String pkColumn,
            String fkTable,
            String fkColumn) {
        return new ExportedKey(pkTable, pkColumn, null, fkTable, fkColumn, null);
    }
View Full Code Here

Examples of org.apache.cayenne.map.naming.ExportedKey

        }
    }

    protected void createNames() {

        ExportedKey key = null;
        for (InferredRelationship myir : inferredRelationships) {
            if (myir.getJoinSource().isPrimaryKey()) {
                key = getExportedKey(myir.getSource().getName(), myir
                        .getJoinSource()
                        .getName(), myir.getTarget().getName(), myir
View Full Code Here

Examples of org.apache.cayenne.map.naming.ExportedKey

    public ExportedKey getExportedKey(
            String pkTable,
            String pkColumn,
            String fkTable,
            String fkColumn) {
        return new ExportedKey(pkTable, pkColumn, null, fkTable, fkColumn, null);
    }
View Full Code Here

Examples of org.apache.cayenne.map.naming.ExportedKey

            // is found in the result set (which should be ordered by table name among
            // other things)
            DbRelationship forwardRelationship = null;
            DbRelationshipDetected reverseRelationship = null;
            DbEntity fkEntity = null;
            ExportedKey key = null;

            do {
                // extract data from resultset
                key = ExportedKey.extractData(rs);

                short keySeq = rs.getShort("KEY_SEQ");
                if (keySeq == 1) {

                    if (forwardRelationship != null) {
                        postprocessMasterDbRelationship(forwardRelationship, key);
                        forwardRelationship = null;
                    }

                    // start new entity
                    String fkEntityName = key.getFKTableName();
                    String fkName = key.getFKName();

                    if (!includeTableName(fkEntityName)) {
                        continue;
                    }

                    fkEntity = map.getDbEntity(fkEntityName);

                    if (fkEntity == null) {
                        logObj.info("FK warning: no entity found for name '"
                                + fkEntityName
                                + "'");
                    }
                    else if (skippedEntities.contains(pkEntity)
                            && skippedEntities.contains(fkEntity)) {
                        // cay-479 - don't load relationships between two
                        // skipped entities.
                        continue;
                    }
                    else {
                        // init relationship
                        String forwardPreferredName = namingStrategy
                                .createDbRelationshipName(key, true);
                        forwardRelationship = new DbRelationship(uniqueRelName(
                                pkEntity,
                                forwardPreferredName));

                        forwardRelationship.setSourceEntity(pkEntity);
                        forwardRelationship.setTargetEntity(fkEntity);
                        pkEntity.addRelationship(forwardRelationship);

                        String reversePreferredName = namingStrategy
                                .createDbRelationshipName(key, false);
                        reverseRelationship = new DbRelationshipDetected(uniqueRelName(
                                fkEntity,
                                reversePreferredName));
                        reverseRelationship.setFkName(fkName);
                        reverseRelationship.setToMany(false);
                        reverseRelationship.setSourceEntity(fkEntity);
                        reverseRelationship.setTargetEntity(pkEntity);
                        fkEntity.addRelationship(reverseRelationship);
                    }
                }

                if (fkEntity != null) {
                    // Create and append joins
                    String pkName = key.getPKColumnName();
                    String fkName = key.getFKColumnName();

                    // skip invalid joins...
                    DbAttribute pkAtt = (DbAttribute) pkEntity.getAttribute(pkName);
                    if (pkAtt == null) {
                        logObj.info("no attribute for declared primary key: " + pkName);
View Full Code Here

Examples of org.apache.cayenne.map.naming.ExportedKey

public class SmartNamingStrategyTest extends TestCase {
    public void testStrategy() throws Exception {
        SmartNamingStrategy strategy = new SmartNamingStrategy();
       
        ExportedKey key = new ExportedKey("ARTIST", "ARTIST_ID", null,
                "PAINTING", "ARTIST_ID", null);
        assertEquals(strategy.createDbRelationshipName(key, false), "artist");
        assertEquals(strategy.createDbRelationshipName(key, true), "paintings");
       
        key = new ExportedKey("PERSON", "PERSON_ID", null,
                "PERSON", "MOTHER_ID", null);
        assertEquals(strategy.createDbRelationshipName(key, false), "mother");
        assertEquals(strategy.createDbRelationshipName(key, true), "people");
       
        key = new ExportedKey("PERSON", "PERSON_ID", null,
                "ADDRESS", "SHIPPING_ADDRESS_ID", null);
        assertEquals(strategy.createDbRelationshipName(key, false), "shippingAddress");
        assertEquals(strategy.createDbRelationshipName(key, true), "addresses");
       
        assertEquals(strategy.createObjEntityName(new DbEntity("ARTIST")), "Artist");
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.