Package org.apache.cayenne.map

Examples of org.apache.cayenne.map.Entity


        actionManager.getAction(RemoveRelationshipAction.class).setEnabled(false);
        actionManager.getAction(RemoveCallbackMethodAction.class).setEnabled(false);
    }

    public void currentObjEntityChanged(EntityDisplayEvent e) {
        Entity entity = e.getEntity();

        if (e.isMainTabFocus() && entity instanceof ObjEntity) {
            if (getSelectedComponent() != entityPanel) {
                setSelectedComponent(entityPanel);
                entityPanel.setVisible(true);
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

            }
        }

        // 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,
                    namingStrategy.createDbRelationshipName(key, false)));
            source.addRelationship(relationship);
        }

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

        QuotingStrategy quoter = context.getQuotingStrategy();
        DbRelationship incomingDB = joinRelationships.get(0);

        // TODO: andrus, 1/6/2008 - move reusable join check here...

        Entity sourceEntity = incomingDB.getSourceEntity();
        String tableName;

        if (sourceEntity instanceof DbEntity) {
            tableName = quoter.quotedFullyQualifiedName((DbEntity) sourceEntity);
        }
        else {
            tableName = sourceEntity.getName();
        }

        String sourceAlias = context.getTableAlias(lhsId.getEntityId(), tableName);

        if (marker != null) {
View Full Code Here

     * Event handler for ObjEntity and DbEntity additions. Adds a tree node for the entity
     * and make it selected.
     */
    protected void entityAdded(EntityEvent e) {

        Entity entity = e.getEntity();

        DefaultMutableTreeNode mapNode = getProjectModel().getNodeForObjectPath(
                new Object[] {
                        mediator.getCurrentDataDomain(), mediator.getCurrentDataMap()
                });
View Full Code Here

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

            if (value instanceof CayenneMapEntry) {
                CayenneMapEntry mapObject = (CayenneMapEntry) value;
                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 != this.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.