/** * Updates delete rules for all relationships in a objentity */ public static void updateObjEntity(ObjEntity e) { Collection<ObjRelationship> rels = e.getRelationships(); for (ObjRelationship rel : rels) { updateObjRelationship(rel); } }
public ObjRelationshipTableModel(ObjEntity entity, ProjectController mediator, Object eventSource) { super(mediator, eventSource, new ArrayList<>(entity.getRelationships())); this.entity = entity; // order using local comparator Collections.sort(objectList, new RelationshipComparator()); }
/** * Returns true if an ObjEntity contains at least one toOne relationship. */ public boolean hasToOneRelationships(ObjEntity anObjEntity) { if (anObjEntity == null) { return false; } for (Relationship r : anObjEntity.getRelationships()) { if (false == r.isToMany()) { return true; } } return false; }
public Collection<ObjRelationship> allRelationships() { if (subentities == null) { return entity.getRelationships(); } Collection<ObjRelationship> c = new ArrayList<>(); appendDeclaredRelationships(c); // add base relationships if any ObjEntity superEntity = entity.getSuperEntity(); if (superEntity != null) { c.addAll(superEntity.getRelationships()); } return c; }
/** * Returns true if an ObjEntity contains at least one toOne relationship. */ public boolean hasToOneRelationships(ObjEntity anObjEntity) { if (anObjEntity == null) { return false; } for (Relationship r : anObjEntity.getRelationships()) { if (!r.isToMany()) { return true; } } return false; }
public Collection allRelationships() { if (subentities == null) { return entity.getRelationships(); } Collection c = new ArrayList(); appendDeclaredRelationships(c); // add base relationships if any ObjEntity superEntity = entity.getSuperEntity(); if (superEntity != null) { c.addAll(superEntity.getRelationships()); } return c; }
/** * Returns true if an ObjEntity contains at least one toMany relationship. */ public boolean hasToManyRelationships(ObjEntity anObjEntity) { if (anObjEntity == null) { return false; } Iterator it = anObjEntity.getRelationships().iterator(); while (it.hasNext()) { Relationship r = (Relationship) it.next(); if (r.isToMany()) { return true; } } return false; }
/** * Returns true if an ObjEntity contains at least one toMany relationship. */ public boolean hasToManyRelationships(ObjEntity anObjEntity) { if (anObjEntity == null) { return false; } for (Relationship r : anObjEntity.getRelationships()) { if (r.isToMany()) { return true; } } return false; }
/** * Returns true if an ObjEntity contains at least one toMany relationship. */ public boolean hasToManyRelationships(ObjEntity anObjEntity) { if (anObjEntity == null) { return false; } for (Relationship r : anObjEntity.getRelationships()) { if (r.isToMany()) { return true; } } return false; }
/** * Returns true if an ObjEntity contains at least one toOne relationship. */ public boolean hasToOneRelationships(ObjEntity anObjEntity) { if (anObjEntity == null) { return false; } Iterator it = anObjEntity.getRelationships().iterator(); while (it.hasNext()) { Relationship r = (Relationship) it.next(); if (false == r.isToMany()) { return true; } } return false; }
/** * Returns true if current entity contains at least one List property. * * @since 1.1 */ public boolean isContainingListProperties() { if (entity == null) { return false; } Iterator it = entity.getRelationships().iterator(); while(it.hasNext()) { Relationship r = (Relationship) it.next(); if(r.isToMany()) { return true; } } return false; }
AuditableEntityDescriptor(ObjEntity auditableEntity, String[] ignoredProperties) { this.ignoredProperties = new HashSet<>(); // ignore runtime relationships for (ObjRelationship relationship : auditableEntity.getRelationships()) { if (relationship.isRuntime()) { this.ignoredProperties.add(relationship.getName()); } } // ignore explicitly specified properties if (ignoredProperties != null) { for (String property : ignoredProperties) { this.ignoredProperties.add(property); } } }
MutableCommitLogLogEntity setIgnoreToManyRelationships(boolean ignore) { if (ignore) { for (ObjRelationship r : entity.getRelationships()) { if (r.isToMany()) { this.ignoredProperties.add(r.getName()); } } } return this; } }
MutableCommitLogLogEntity setIgnoreToOneRelationships(boolean ignore) { if (ignore) { for (ObjRelationship r : entity.getRelationships()) { if (!r.isToMany()) { this.ignoredProperties.add(r.getName()); } } } return this; }
private boolean shouldAddToObjEntity(ObjEntity entity, DbRelationship dbRelationship) { if(dbRelationship.getName() == null) { return false; } for(Relationship relationship : entity.getRelationships()) { ObjRelationship objRelationship = (ObjRelationship)relationship; if(objRelationshipHasDbRelationship(objRelationship, dbRelationship)) { return false; } } return true; }
/** * Method check - if current entity represent many to many temporary table * * @return true if current entity is represent many to many table; otherwise returns false */ public static ManyToManyCandidateEntity build(ObjEntity joinEntity) { ArrayList<ObjRelationship> relationships = new ArrayList<>(joinEntity.getRelationships()); if (relationships.size() != 2 || (relationships.get(0).getDbRelationships().isEmpty() || relationships.get(1).getDbRelationships().isEmpty())) { return null; } ManyToManyCandidateEntity candidateEntity = new ManyToManyCandidateEntity(joinEntity, relationships); if (candidateEntity.isManyToMany()) { return candidateEntity; } return null; }
/** * Clears all the mapping between this obj entity and its current db entity. Clears * mapping between entities, attributes and relationships. */ public void clearDbMapping() { if (dbEntityName == null) return; Iterator it = getAttributeMap().values().iterator(); while (it.hasNext()) { ObjAttribute objAttr = (ObjAttribute) it.next(); DbAttribute dbAttr = objAttr.getDbAttribute(); if (null != dbAttr) { objAttr.setDbAttribute(null); } } Iterator rels = this.getRelationships().iterator(); while (rels.hasNext()) { ((ObjRelationship) rels.next()).clearDbRelationships(); } dbEntityName = null; }
private void relationshipsSanity(DataMap executed) { for (ObjEntity objEntity : executed.getObjEntities()) { List<ObjRelationship> rels = new LinkedList<>(objEntity.getRelationships()); for (ObjRelationship rel : rels) { if (rel.getSourceEntity() == null || rel.getTargetEntity() == null) { logger.error("Incorrect obj relationship source or target entity is null: " + rel); objEntity.removeRelationship(rel.getName()); } } } }
public static Collection<ObjRelationship> findObjRelationshipsForDbRelationship(ProjectController mediator, DbRelationship relationship) { DataChannelDescriptor domain = (DataChannelDescriptor) mediator.getProject().getRootNode(); List<ObjRelationship> objRelationships = new ArrayList<>(); if (domain != null) { for (DataMap map : domain.getDataMaps()) { for (ObjEntity entity : map.getObjEntities()) { for (ObjRelationship objRelationship : entity.getRelationships()) { if (objRelationship.getDbRelationships().contains(relationship)) { objRelationships.add(objRelationship); } } } } } return objRelationships; }
public ValidationResult visitObjEntity(ObjEntity entity) { objEntityValidator.validate(entity, validationResult); for (ObjAttribute attr : entity.getAttributes()) { visitObjAttribute(attr); } for (ObjRelationship rel : entity.getRelationships()) { visitObjRelationship(rel); } return validationResult; }