/** * Returns a Collection of all relationships that belong to this ObjEntity, excluding * inherited attributes. * * @since 1.1 */ public Collection getDeclaredRelationships() { return super.getRelationships(); }
/** * Returns a Collection of all relationships that belong to this ObjEntity, * excluding inherited attributes. * * @since 1.1 */ @SuppressWarnings("unchecked") public Collection<ObjRelationship> getDeclaredRelationships() { return (Collection<ObjRelationship>) super.getRelationships(); }
/** * Returns a Collection of relationships from this entity or inherited. */ @SuppressWarnings("unchecked") @Override public Collection<DbRelationship> getRelationships() { return (Collection<DbRelationship>) super.getRelationships(); }
/** * Removes children cache for specified entity. */ public void invalidateChildren(Entity entity) { sortedChildren.remove(entity); for (Relationship rel : entity.getRelationships()) { sortedChildren.remove(rel); } }
/** * Returns a relationship that has a specified entity as a target. If there is more * than one relationship for the same target, it is unpredictable which one will be * returned. * * @since 1.1 */ public Relationship getAnyRelationship(Entity targetEntity) { if (getRelationships().isEmpty()) { return null; } for (Relationship r : getRelationships()) { if (r.getTargetEntity() == targetEntity) { return r; } } return null; }
private final void encodeDBRelationshipsAsXML(Map entityMap, XMLEncoder encoder) { Iterator it = entityMap.entrySet().iterator(); while (it.hasNext()) { Map.Entry entry = (Map.Entry) it.next(); Entity entity = (Entity) entry.getValue(); encoder.print(entity.getRelationships()); } }
public Collection getRelationships() { if (superEntityName == null) { return super.getRelationships(); } return getRelationshipMap().values(); }
/** * Returns a relationship that has a specified entity as a target. If there is more * than one relationship for the same target, it is unpredictable which one will be * returned. * * @since 1.1 */ public Relationship getAnyRelationship(Entity targetEntity) { if (getRelationships().isEmpty()) { return null; } Iterator it = getRelationships().iterator(); while (it.hasNext()) { Relationship r = (Relationship) it.next(); if (r.getTargetEntity() == targetEntity) { return r; } } return null; }
private final void encodeDBRelationshipsAsXML(Map<String, DbEntity> entityMap, XMLEncoder encoder) { for (Entity entity : entityMap.values()) { for (Relationship relationship : entity.getRelationships()) { // filter out synthetic if (!relationship.isRuntime()) { relationship.encodeAsXML(encoder); } } } }
/** * 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()) { // DbRelationship relationship = (DbRelationship) it.next(); for (DbRelationship relationship : parentRelationships) { if (ProjectUtil.containsSourceAttribute(relationship, attribute)) { relationships.add(relationship); } } return relationships; }
boolean isPropagated(DbAttribute attribute) { Iterator it = attribute.getEntity().getRelationships().iterator(); while (it.hasNext()) { DbRelationship dbRel = (DbRelationship) it.next(); if (!dbRel.isToMasterPK()) { continue; } Iterator joins = dbRel.getJoins().iterator(); while (joins.hasNext()) { DbJoin join = (DbJoin) joins.next(); if (attribute.getName().equals(join.getSourceName())) { return true; } } } return false; } }
/** * Post (i.e. after creation on entity cell) process of the entity */ protected void postProcessEntity(Entity entity, DefaultGraphCell cell) { for (Relationship rel : entity.getRelationships()) { if (rel.getSourceEntity() != null && rel.getTargetEntity() != null) { DefaultEdge edge = createRelationshipCell(rel); if (edge != null) { createdObjects.add(edge); } } } }
/** * Returns whether an entity is not connected to any other TODO: not fine * algorithm, it iterates through all entities and all rels */ protected boolean isIsolated(DataChannelDescriptor domain, Entity entity) { if (entity.getRelationships().size() == 0) { // searching for rels that have a target="entity" for (DataMap map : domain.getDataMaps()) { for (Entity source : getEntities(map)) { if (source.getAnyRelationship(entity) != null) { return false; } } } return true; } return false; }
private Object[] sortedChildren(Object node) { Entity entity = entityForNonLeafNode(node); // may happen in incomplete relationships if (entity == null) { return new Object[0]; } Object key = node; Object[] sortedForNode = sortedChildren.get(key); if (sortedForNode == null) { Collection<? extends Attribute> attributes = entity.getAttributes(); Collection<? extends Relationship> relationships = entity.getRelationships(); List<Object> nodes = new Vector<Object>(); // combine two collections in an array for (Attribute attr : attributes) { if (filter == null || filter.attributeMatch(node, attr)) { nodes.add(attr); } } for (Relationship rel : relationships) { if (filter == null || filter.relationshipMatch(node, rel)) { nodes.add(rel); } } sortedForNode = nodes.toArray(); Arrays.sort(sortedForNode, Comparators.getEntityChildrenComparator()); sortedChildren.put(key, sortedForNode); } return sortedForNode; }
/** * Returns <code>true</code> if the DB column represented by this attribute is a * foreign key, referencing another table. * * @since 1.1 */ public boolean isForeignKey() { String name = getName(); if (name == null) { // won't be able to match joins... return false; } Iterator relationships = getEntity().getRelationships().iterator(); while (relationships.hasNext()) { DbRelationship relationship = (DbRelationship) relationships.next(); Iterator joins = relationship.getJoins().iterator(); while (joins.hasNext()) { DbJoin join = (DbJoin) joins.next(); if (name.equals(join.getSourceName())) { DbAttribute target = join.getTarget(); if (target != null && target.isPrimaryKey()) { return true; } } } } return false; }
Iterator it = target.getRelationships().iterator(); while (it.hasNext()) { ObjRelationship rel = (ObjRelationship) it.next();
public void traverseEntities(Iterator entities, ProjectPath path) { if (sort) { entities = Util .sortedIterator(entities, ProjectTraversal.mapObjectComparator); } while (entities.hasNext()) { Entity ent = (Entity) entities.next(); ProjectPath entPath = path.appendToPath(ent); handler.projectNode(entPath); if (handler.shouldReadChildren(ent, path)) { this.traverseAttributes(ent.getAttributes().iterator(), entPath); this.traverseRelationships(ent.getRelationships().iterator(), entPath); } } }
/** * 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>(); for (Entity entity : map.getDbEntities()) { if (entity == parent) { continue; } Collection<DbRelationship> entityRelationships = (Collection<DbRelationship>) entity .getRelationships(); for (DbRelationship relationship : entityRelationships) { if (ProjectUtil.containsTargetAttribute(relationship, attribute)) { relationships.add(relationship); } } } return relationships; }
Iterator it = target.getRelationships().iterator(); while (it.hasNext()) { DbRelationship rel = (DbRelationship) it.next();