public void createObjRelationship(ObjEntity objEntity, ObjRelationship rel) { ProjectController mediator = getProjectController(); rel.setSourceEntity(objEntity); DeleteRuleUpdater.updateObjRelationship(rel); objEntity.addRelationship(rel); fireObjRelationshipEvent(this, mediator, objEntity, rel); }
objRelationship .setDbRelationshipPath((atts.getValue("", "db-relationship-path"))); source.addRelationship(objRelationship);
private void processStartObjRelationship(Attributes atts) throws SAXException { String name = atts.getValue("", "name"); if (null == name) { throw new SAXException("MapLoader::processStartObjRelationship()," + " Unable to parse target. Attributes:\n" + printAttributes(atts)); } String collectionType = atts.getValue("", "collection-type"); String mapKey = atts.getValue("", "map-key"); String sourceName = atts.getValue("", "source"); if (sourceName == null) { throw new SAXException("MapLoader::processStartObjRelationship()," + " Unable to parse source. Attributes:\n" + printAttributes(atts)); } ObjEntity source = dataMap.getObjEntity(sourceName); if (source == null) { throw new SAXException("MapLoader::processStartObjRelationship()," + " Unable to find source " + sourceName); } String deleteRuleName = atts.getValue("", "deleteRule"); int deleteRule = (deleteRuleName != null) ? DeleteRule.deleteRuleForName(deleteRuleName) : DeleteRule.NO_ACTION; objRelationship = new ObjRelationship(name); objRelationship.setSourceEntity(source); objRelationship.setTargetEntityName(atts.getValue("", "target")); objRelationship.setDeleteRule(deleteRule); objRelationship.setUsedForLocking(TRUE.equalsIgnoreCase(atts.getValue("", "lock"))); objRelationship.setDeferredDbRelationshipPath((atts.getValue("", "db-relationship-path"))); objRelationship.setCollectionType(collectionType); objRelationship.setMapKey(mapKey); source.addRelationship(objRelationship); }
/** * Returns an ObjEntity stripped of any server-side information, such as DbEntity * mapping. "clientClassName" property of this entity is used to intialize "className" * property of returned entity. * * @since 1.2 */ public ObjEntity getClientEntity() { ObjEntity entity = new ObjEntity(getName()); entity.setClassName(getClientClassName()); entity.setSuperClassName(getClientSuperClassName()); entity.setSuperEntityName(getSuperEntityName()); // TODO: should we also copy lock type? // copy attributes Iterator attributes = getDeclaredAttributes().iterator(); while (attributes.hasNext()) { ObjAttribute attribute = (ObjAttribute) attributes.next(); entity.addAttribute(attribute.getClientAttribute()); } // copy relationships Iterator relationships = getDeclaredRelationships().iterator(); while (relationships.hasNext()) { ObjRelationship relationship = (ObjRelationship) relationships.next(); entity.addRelationship(relationship.getClientRelationship()); } return entity; }
rel.setSourceEntity(objEntity); rel.setTargetEntity(target); objEntity.addRelationship(rel);
rel.setSourceEntity(objEntity); rel.setTargetEntityName(target); objEntity.addRelationship(rel);
private void addFlattenedRelationship(ObjectNameGenerator nameGenerator, ObjEntity srcEntity, ObjEntity dstEntity, DbRelationship rel1, DbRelationship rel2) { if (rel1.getSourceAttributes().isEmpty() && rel2.getTargetAttributes().isEmpty()) { LOG.warn("Wrong call ManyToManyCandidateEntity.addFlattenedRelationship(... , " + srcEntity.getName() + ", " + dstEntity.getName() + ", ...)"); return; } ObjRelationship newRelationship = new ObjRelationship(); newRelationship.setName(NameBuilder .builder(newRelationship, srcEntity) .baseName(nameGenerator.relationshipName(rel1, rel2)) .name()); newRelationship.setSourceEntity(srcEntity); newRelationship.setTargetEntityName(dstEntity); newRelationship.addDbRelationship(rel1); newRelationship.addDbRelationship(rel2); srcEntity.addRelationship(newRelationship); }
or.setSourceEntity(entity); or.setTargetEntity(mappedTarget); entity.addRelationship(or); changed = true;
entity.addRelationship(or); fireRelationshipAdded(or);
@Override public void init(DataChannel channel) { // load dynamic attributes and relationships... Will be testing whether Agrest can handle generic Cayenne properties // with no getters/setters. ObjEntity e25 = channel.getEntityResolver().getObjEntity(E25.class); ObjAttribute dynamicAttribute = new ObjAttribute("name", "java.lang.String", e25); dynamicAttribute.setDbAttributePath("name"); e25.addAttribute(dynamicAttribute); ObjEntity e22 = channel.getEntityResolver().getObjEntity(E22.class); ObjRelationship e25_e22 = new ObjRelationship("e22"); e25_e22.setTargetEntityName(e22.getName()); e25_e22.setSourceEntity(e25); e25_e22.setDbRelationshipPath("e22"); e25.addRelationship(e25_e22); }
.name()); objEntity.addRelationship(rel); CreateRelationshipAction.fireObjRelationshipEvent( this,