Package org.apache.cayenne.map

Examples of org.apache.cayenne.map.Entity


                (EntityRelationshipsModel) dbRelationshipPath.get(size - 1);
            last = wrapper.getSelectedRelationship();

        }

        Entity target = getEndEntity();

        if (last == null || last.getTargetEntity() != target) {
            // try to connect automatically, if we can't use dummy connector

            Entity source = (last == null) ? getStartEntity() : last.getTargetEntity();
            Relationship anyConnector = source.getAnyRelationship(target);
            EntityRelationshipsModel connector = null;

            connector =
                (anyConnector == null)
                    ? new EntityRelationshipsModel(source, getEndEntity())
View Full Code Here


    public void removeTreeModelListener(TreeModelListener listener) {
        // do nothing...
    }

    private Object[] sortedChildren(Object node) {
        Entity entity = entityForNonLeafNode(node);
       
        // may happen in incomplete relationships
        if(entity == null) {
            return new Object[0];
        }

        synchronized (sortedChildren) {
            String key = entity.getName();
            Object[] sortedForNode = (Object[]) sortedChildren.get(key);

            if (sortedForNode == null) {
                Collection attributes = entity.getAttributes();
                Collection relationships = entity.getRelationships();

                // combine two collections in an array
                int alen = (hideAttributes) ? 0 : attributes.size();
                int rlen = relationships.size();
                sortedForNode = new Object[alen + rlen];
View Full Code Here

        if (validationCode >= ValidationDisplayHandler.WARNING) {

            Iterator it = validator.validationResults().iterator();
            while (it.hasNext()) {
                ValidationInfo nextProblem = (ValidationInfo) it.next();
                Entity failedEntity = null;

                if (nextProblem.getValidatedObject() instanceof DbAttribute) {
                    DbAttribute failedAttribute = (DbAttribute) nextProblem
                            .getValidatedObject();
                    failedEntity = failedAttribute.getEntity();
                }
                else if (nextProblem.getValidatedObject() instanceof DbRelationship) {
                    DbRelationship failedRelationship = (DbRelationship) nextProblem
                            .getValidatedObject();
                    failedEntity = failedRelationship.getSourceEntity();
                }
                else if (nextProblem.getValidatedObject() instanceof DbEntity) {
                    failedEntity = (Entity) nextProblem.getValidatedObject();
                }

                if (failedEntity == null) {
                    continue;
                }

                excludedTables.put(failedEntity.getName(), failedEntity);
                validationMessages.put(failedEntity.getName(), nextProblem.getMessage());
            }
        }

        // now do a pass through the tables and exclude derived
        Iterator tablesIt = tables.iterator();
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

                ObjRelationship rel = (ObjRelationship) rels.next();

                Iterator dbRels = new ArrayList(rel.getDbRelationships()).iterator();
                while (dbRels.hasNext()) {
                    DbRelationship dbRel = (DbRelationship) dbRels.next();
                    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 getRelationshipsUsingAttributeAsSource(DbAttribute attribute) {
        Entity parent = attribute.getEntity();

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

        Collection parentRelationships = parent.getRelationships();
        Collection relationships = new ArrayList(parentRelationships.size());
        Iterator it = parentRelationships.iterator();
        while (it.hasNext()) {
            DbRelationship relationship = (DbRelationship) it.next();
            if (ProjectUtil.containsSourceAttribute(relationship, attribute)) {
View Full Code Here

    /**
     * Returns a collection of DbRelationships that use this attribute as a source.
     */
    public static Collection 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 relationships = new ArrayList();

        Iterator it = map.getDbEntities().iterator();
        while (it.hasNext()) {
            Entity entity = (Entity) it.next();
            if (entity == parent) {
                continue;
            }

            Collection entityRelationships = entity.getRelationships();
            Iterator relationshipsIt = entityRelationships.iterator();
            while (relationshipsIt.hasNext()) {
                DbRelationship relationship = (DbRelationship) relationshipsIt.next();
                if (ProjectUtil.containsTargetAttribute(relationship, attribute)) {
                    relationships.add(relationship);
View Full Code Here

            QueryEvent queryEvent = new QueryEvent(Application.getFrame(), null);

            Collection addedOE = CollectionUtils.subtract(newOE, originalOE);
            Iterator it = addedOE.iterator();
            while (it.hasNext()) {
                Entity e = (Entity) it.next();
                entityEvent.setEntity(e);
                entityEvent.setId(MapEvent.ADD);
                mediator.fireObjEntityEvent(entityEvent);
            }

            Collection removedOE = CollectionUtils.subtract(originalOE, newOE);
            it = removedOE.iterator();
            while (it.hasNext()) {
                Entity e = (Entity) it.next();
                entityEvent.setEntity(e);
                entityEvent.setId(MapEvent.REMOVE);
                mediator.fireObjEntityEvent(entityEvent);
            }

            Collection addedDE = CollectionUtils.subtract(newDE, originalDE);
            it = addedDE.iterator();
            while (it.hasNext()) {
                Entity e = (Entity) it.next();
                entityEvent.setEntity(e);
                entityEvent.setId(MapEvent.ADD);
                mediator.fireDbEntityEvent(entityEvent);
            }

            Collection removedDE = CollectionUtils.subtract(originalDE, newDE);
            it = removedDE.iterator();
            while (it.hasNext()) {
                Entity e = (Entity) it.next();
                entityEvent.setEntity(e);
                entityEvent.setId(MapEvent.REMOVE);
                mediator.fireDbEntityEvent(entityEvent);
            }
           
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 != mediator.getCurrentDataMap()) {
                        label += " (" + dataMap.getName() + ")";
                    }
                }
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 != mediator.getCurrentDataMap()) {
                        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.