public void arcCreated(Object nodeId, Object targetNodeId, Object arcId) { ObjRelationship relationship = (ObjRelationship) objEntity.getRelationship(arcId .toString()); if (!relationship.isSourceIndependentFromTargetChange()) { if (currentArcDiff == null) { currentArcDiff = new HashMap(); } currentArcDiff.put(arcId, targetNodeId); } }
@Override public ObjRelationship getReverseRelationship() { if (reverseRelationshipName == null) { return null; } ObjEntity target = getTargetEntity(); if (target == null) { return null; } return target.getRelationship(reverseRelationshipName); } }
public void arcDeleted(Object nodeId, Object targetNodeId, Object arcId) { ObjRelationship relationship = (ObjRelationship) objEntity.getRelationship(arcId .toString()); if (!relationship.isSourceIndependentFromTargetChange()) { if (currentArcDiff == null) { currentArcDiff = new HashMap(); currentArcDiff.put(arcId, null); } // check for situation when a substitute arc was created prior to deleting the // old arc... else if (targetNodeId.equals(currentArcDiff.get(arcId))) { currentArcDiff.put(arcId, null); } } }
public BaseArcProperty(ClassDescriptor owner, ClassDescriptor targetDescriptor, Accessor accessor, String reverseName) { super(owner, accessor); this.targetDescriptor = targetDescriptor; this.complimentaryReverseArcName = reverseName; this.relationship = owner.getEntity().getRelationship(getName()); }
public boolean visitCollectionArc(CollectionProperty property) { ObjRelationship relationship = (ObjRelationship) entity .getRelationship(property.getName()); processRules(object, property, relationship.getDeleteRule(), oldState); return true; }
public boolean visitSingleObjectArc(SingleObjectArcProperty property) { ObjRelationship relationship = (ObjRelationship) entity .getRelationship(property.getName()); processRules(object, property, relationship.getDeleteRule(), oldState); return true; }
@Override public boolean isNameInUse(String name) { ObjEntity entity = (ObjEntity) parent; // check if either attribute or relationship name matches... if (entity.getAttribute(name) != null || entity.getRelationship(name) != null) { return true; } // check if there's a callback method that shadows attribute getter (unlikely, but still) String conflictingCallback = "get" + NameUtil.capitalize(name); return entity.getCallbackMethods().contains(conflictingCallback); } });
/** * Returns a named Relationship that either belongs to this ObjEntity or is inherited. * Returns null if no matching attribute is found. */ public Relationship getRelationship(String name) { Relationship relationship = super.getRelationship(name); if (relationship != null) { return relationship; } if (superEntityName == null) { return null; } ObjEntity superEntity = getSuperEntity(); return (superEntity != null) ? superEntity.getRelationship(name) : null; }
/** * Returns a named Relationship that either belongs to this ObjEntity or is * inherited. Returns null if no matching attribute is found. */ @Override public ObjRelationship getRelationship(String name) { ObjRelationship relationship = (ObjRelationship) super.getRelationship(name); if (relationship != null) { return relationship; } if (superEntityName == null) { return null; } ObjEntity superEntity = getSuperEntity(); return (superEntity != null) ? superEntity.getRelationship(name) : null; }
protected void processLastPathComponent() { ObjAttribute attribute = currentEntity.getAttribute(lastPathComponent); if (attribute != null) { processTerminatingAttribute(attribute); return; } ObjRelationship relationship = currentEntity.getRelationship(lastPathComponent); if (relationship != null) { processTerminatingRelationship(relationship); return; } throw new IllegalStateException("Invalid path component: " + lastPathComponent); }
public void arcCreated(Object nodeId, Object targetNodeId, Object arcId) { String arcIdString = arcId.toString(); ObjRelationship relationship = objEntity.getRelationship(arcIdString); if (relationship == null) { // phantom FK if (arcIdString.startsWith(ASTDbPath.DB_PREFIX)) { DbRelationship dbRelationship = dbEntity.getRelationship(arcIdString.substring(ASTDbPath.DB_PREFIX .length())); if (!dbRelationship.isSourceIndependentFromTargetChange()) { doArcCreated(targetNodeId, arcId); } } else { throw new IllegalArgumentException("Bad arcId: " + arcId); } } else if (!relationship.isSourceIndependentFromTargetChange()) { doArcCreated(targetNodeId, arcId); } }
protected void processIntermediatePathComponent() { ObjRelationship relationship = currentEntity.getRelationship(lastPathComponent); if (relationship == null) { throw new EJBQLException("Unknown relationship '" + lastPathComponent + "' for entity '" + currentEntity.getName() + "'"); } this.currentEntity = (ObjEntity) relationship.getTargetEntity(); }
@Override public boolean visitToOne(ToOneProperty property) { boolean isUsedForLocking = entity.getRelationship(property.getName()).isUsedForLocking(); // eagerly resolve optimistically locked relationships Object target = isUsedForLocking ? property.readProperty(object) : property.readPropertyDirectly(object); if (target instanceof Persistent) { target = ((Persistent) target).getObjectId(); } // else - null || Fault arcSnapshot.put(property.getName(), target); return true; } });
@Override public void arcDeleted(Object nodeId, Object targetNodeId, Object arcId) { ObjectId id = (ObjectId) nodeId; String relationshipName = arcId.toString(); ObjEntity entity = entityResolver.getObjEntity(id.getEntityName()); ObjRelationship relationship = entity.getRelationship(relationshipName); MutableObjectChange c = changeSet.getOrCreate(id, ObjectChangeType.UPDATE); ObjectId tid = (ObjectId) targetNodeId; if (relationship.isToMany()) { c.toManyRelationshipDisconnected(relationshipName, tid); } else { c.toOneRelationshipDisconnected(relationshipName, tid); } }
@Override public void arcCreated(Object nodeId, Object targetNodeId, Object arcId) { ObjectId id = (ObjectId) nodeId; String relationshipName = arcId.toString(); ObjEntity entity = entityResolver.getObjEntity(id.getEntityName()); ObjRelationship relationship = entity.getRelationship(relationshipName); MutableObjectChange c = changeSet.getOrCreate(id, ObjectChangeType.UPDATE); ObjectId tid = (ObjectId) targetNodeId; if (relationship.isToMany()) { c.toManyRelationshipConnected(relationshipName, tid); } else { c.toOneRelationshipConnected(relationshipName, tid); } } }
private boolean isClientArc(Object id, Object targetId, Object arcId) { ObjectId oid = (ObjectId) id; ObjEntity entity = resolver.getObjEntity(oid.getEntityName()); if(!entity.isClientAllowed()) { return false; } if(entity.getRelationship(arcId.toString()).isRuntime()) { return false; } ObjectId targetOid = (ObjectId) targetId; ObjEntity targetEntity = resolver.getObjEntity(targetOid.getEntityName()); if(!targetEntity.isClientAllowed()) { return false; } return true; } }
public void arcDeleted(Object nodeId, Object targetNodeId, Object arcId) { DataObject source = findObject(nodeId); // find whether this is to-one or to-many ObjEntity sourceEntity = context.getEntityResolver().lookupObjEntity(source); Relationship relationship = sourceEntity.getRelationship(arcId.toString()); DataObject target = findObject(targetNodeId); if (relationship.isToMany()) { source.removeToManyTarget(relationship.getName(), target, false); } else { source.setToOneTarget(relationship.getName(), null, false); } }
public void arcCreated(Object nodeId, Object targetNodeId, Object arcId) { DataObject source = findObject(nodeId); if(source == null) { return; } // find whether this is to-one or to-many ObjEntity sourceEntity = context.getEntityResolver().lookupObjEntity(source); Relationship relationship = sourceEntity.getRelationship(arcId.toString()); DataObject target = findObject(targetNodeId); if (relationship.isToMany()) { source.addToManyTarget(relationship.getName(), target, false); } else { source.setToOneTarget(relationship.getName(), target, false); } }
/** * Initializes reverse relationship from object <code>val</code> to this object. * * @param relName name of relationship from this object to <code>val</code>. */ protected void setReverseRelationship(String relName, DataObject val) { ObjRelationship rel = (ObjRelationship) objectContext .getEntityResolver() .lookupObjEntity(objectId.getEntityName()) .getRelationship(relName); ObjRelationship revRel = rel.getReverseRelationship(); if (revRel != null) { if (revRel.isToMany()) val.addToManyTarget(revRel.getName(), this, false); else val.setToOneTarget(revRel.getName(), this, false); } }
protected void updateReverse(List resolved) { EntityResolver resolver = relationshipOwner.getObjectContext().getEntityResolver(); ObjEntity sourceEntity = resolver.getObjEntity(relationshipOwner.getObjectId().getEntityName()); ObjRelationship relationship = sourceEntity.getRelationship(relationshipName); ObjRelationship reverse = relationship.getReverseRelationship(); if (reverse != null && !reverse.isToMany()) { PropertyDescriptor property = resolver.getClassDescriptor(reverse.getSourceEntity().getName()).getProperty( reverse.getName()); for (Object o : resolved) { property.writePropertyDirectly(o, null, relationshipOwner); } } } }