Package org.apache.cayenne.map

Examples of org.apache.cayenne.map.Entity


            return new ObjAttribute(name, null, (ObjEntity) namingContext);
        }

        @Override
        protected boolean isNameInUse(String name, Object namingContext) {
            Entity ent = (Entity) namingContext;
            return ent.getAttribute(name) != null;
        }
View Full Code Here


            return new ObjRelationship(name);
        }

        @Override
        protected boolean isNameInUse(String name, Object namingContext) {
            Entity ent = (Entity) namingContext;
            return ent.getRelationship(name) != null;
        }
View Full Code Here

            // TODO: andrus, 5/2/2006 - infer this from Jpa relationship
            src.setMandatory(false);
            src.setMaxLength(jpaTargetId.getColumn().getLength());
            src.setType(jpaTargetId.getDefaultJdbcType());

            Entity srcEntity = dbRelationship.getSourceEntity();
            srcEntity.addAttribute(src);

            // add join
            DbJoin join = new DbJoin(dbRelationship, src.getName(), jpaTargetId
                    .getColumn()
                    .getName());
View Full Code Here

            }
        }

        // if this is really to-one we need to rename the relationship
        if (!toMany) {
            Entity source = relationship.getSourceEntity();
            source.removeRelationship(relationship.getName());
            relationship.setName(DbLoader.uniqueRelName(source, relationship
                    .getTargetEntityName(), false));
            source.addRelationship(relationship);
        }

        relationship.setToDependentPK(toDependentPK);
        relationship.setToMany(toMany);
    }
View Full Code Here

     */
    public static void setAttributeName(Attribute attribute, String newName) {
        String oldName = attribute.getName();

        attribute.setName(newName);
        Entity entity = attribute.getEntity();

        if (entity != null) {
            entity.removeAttribute(oldName);
            entity.addAttribute(attribute);
        }
    }
View Full Code Here

            for (ObjRelationship rel : entity.getRelationships()) {

                List<DbRelationship> dbRelList = new ArrayList<DbRelationship>(rel
                        .getDbRelationships());
                for (DbRelationship dbRel : dbRelList) {
                    Entity srcEnt = dbRel.getSourceEntity();
                    if (srcEnt == null
                            || map.getDbEntity(srcEnt.getName()) != srcEnt
                            || srcEnt.getRelationship(dbRel.getName()) != dbRel) {
                        rel.removeDbRelationship(dbRel);
                    }
                }
            }
        }
View Full Code Here

    /**
     * Returns a collection of DbRelationships that use this attribute as a source.
     */
    public static Collection<DbRelationship> getRelationshipsUsingAttributeAsSource(
            DbAttribute attribute) {
        Entity parent = attribute.getEntity();

        if (parent == null) {
            return Collections.EMPTY_LIST;
        }

        Collection<DbRelationship> parentRelationships = (Collection<DbRelationship>) parent
                .getRelationships();
        Collection<DbRelationship> relationships = new ArrayList<DbRelationship>(
                parentRelationships.size());
        // Iterator it = parentRelationships.iterator();
        // while (it.hasNext()) {
View Full Code Here

    /**
     * Returns a collection of DbRelationships that use this attribute as a source.
     */
    public static Collection<DbRelationship> getRelationshipsUsingAttributeAsTarget(
            DbAttribute attribute) {
        Entity parent = attribute.getEntity();

        if (parent == null) {
            return Collections.EMPTY_LIST;
        }

        DataMap map = parent.getDataMap();
        if (map == null) {
            return Collections.EMPTY_LIST;
        }

        Collection<DbRelationship> relationships = new ArrayList<DbRelationship>();
View Full Code Here

        }
        else if (object instanceof DataMap) {
            return mapIcon;
        }
        else if (object instanceof Entity) {
            Entity entity = (Entity) object;
            if (entity instanceof DbEntity) {
                return dbEntityIcon;
            }
            else if (entity instanceof ObjEntity) {
                return objEntityIcon;
View Full Code Here

        if (obj instanceof CayenneMapEntry) {
            CayenneMapEntry mapObject = (CayenneMapEntry) obj;
            String label = mapObject.getName();

            if (mapObject instanceof Entity) {
                Entity entity = (Entity) mapObject;

                // for different namespace display its name
                DataMap dataMap = entity.getDataMap();
                if (dataMap != null && dataMap != namespace) {
                    label += " (" + dataMap.getName() + ")";
                }
            }
           
View Full Code Here

TOP

Related Classes of org.apache.cayenne.map.Entity

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.