org.jlf.dataMap
Class Relationship

java.lang.Object
  |
  +--org.jlf.dataMap.Relationship
All Implemented Interfaces:
java.io.Serializable

public class Relationship
extends java.lang.Object
implements java.io.Serializable

This class

See Also:
DataMappedObject, RelationshipDescriptor, Serialized Form

Field Summary
protected  boolean hasRelationshipBeenRead
          Holds a flag for relationships that are not read inline, to see if the relationship that is read in a separate query has already been populated.
protected  java.util.Vector relatedObjects
          Holds the DataMappedObject objects on the far (role B) side of the relationship.
 
Constructor Summary
Relationship(RelationshipDescriptor rd, DataMappedObject primaryObject)
          Initial constructor for the relationship.
 
Method Summary
 void addRelatedObject(DataMappedObject bo)
          Adds a DataMappedObject to the relationships vector so it can later be retrieved.
protected  void checkAndPerformLazyRead()
          Checks to see if a lazy read of the relationship is required.
 void cleanupAfterWrite(DataMapper dataMapper)
          Performs cleanup work after a write is committed to the database (for example, resets attribute values).
 java.util.Vector getDeletedRelatedObjects()
          This is the accessor to the relatedObjects Vector when the relationship cardinality on the relatedObjects side is 0..*.
protected  DataMappedObject getNewRoleBInstance()
          Helper method to returns a new (and blank) data mapped object of the Role B side of the relationship appropriate for reading/adding to the relationship.
 DataMappedObject getPrimaryObject()
          Returns the primary object (Role A object) of the relationship.
 DataMappedObject getRelatedObject()
          This is the accessor to the relatedObjects Vector when the relationship cardinality on the relatedObjects side is 0..1 or 1.
 java.util.Vector getRelatedObjects()
          This is the accessor to the relatedObjects Vector when the relationship cardinality on the relatedObjects side is 0..*.
 java.lang.Class getRelationshipClass()
          Return the relationship class on the role B side of the relationship.
 java.lang.String getRelationshipName()
          Return the relationship name.
 java.util.Vector getUndeletedRelatedObjects()
          This is the accessor to the relatedObjects Vector when the relationship cardinality on the relatedObjects side is 0..*.
 boolean hasRelationshipBeenRead()
          Returns the flag telling whether the relationship has been read.
 void populateFromDataArray(DataArray dataArray)
          Reads as many attributes as it can from the DataArray for an object of the type on the role B side of the relationship.
 void readRelationshipNow()
          Reads the relationship from the default data location for the primary object.
 void readRelationshipNow(DataMapper dataMapper)
          Reads the relationship from the data mapper specified.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

hasRelationshipBeenRead

protected boolean hasRelationshipBeenRead
Holds a flag for relationships that are not read inline, to see if the relationship that is read in a separate query has already been populated. If it hasn't, need to issue a lazy query before any relationship information is returned.


relatedObjects

protected java.util.Vector relatedObjects
Holds the DataMappedObject objects on the far (role B) side of the relationship.

Constructor Detail

Relationship

public Relationship(RelationshipDescriptor rd,
                    DataMappedObject primaryObject)
Initial constructor for the relationship. This sets the relationship up to be populated.

Method Detail

getRelationshipName

public java.lang.String getRelationshipName()
Return the relationship name. Implemented as a passthrough to the relationship descriptor.


getRelationshipClass

public java.lang.Class getRelationshipClass()
Return the relationship class on the role B side of the relationship. Implemented as a passthrough to the relationship descriptor.


getPrimaryObject

public DataMappedObject getPrimaryObject()
Returns the primary object (Role A object) of the relationship.


getNewRoleBInstance

protected DataMappedObject getNewRoleBInstance()
Helper method to returns a new (and blank) data mapped object of the Role B side of the relationship appropriate for reading/adding to the relationship.


hasRelationshipBeenRead

public boolean hasRelationshipBeenRead()
Returns the flag telling whether the relationship has been read. If it hasn't, need to issue a lazy read before returning any relationship information.


readRelationshipNow

public void readRelationshipNow(DataMapper dataMapper)
Reads the relationship from the data mapper specified.


readRelationshipNow

public void readRelationshipNow()
Reads the relationship from the default data location for the primary object.


checkAndPerformLazyRead

protected void checkAndPerformLazyRead()
Checks to see if a lazy read of the relationship is required. If so, performs it and resets the flag.


getRelatedObjects

public java.util.Vector getRelatedObjects()
This is the accessor to the relatedObjects Vector when the relationship cardinality on the relatedObjects side is 0..*.


getUndeletedRelatedObjects

public java.util.Vector getUndeletedRelatedObjects()
This is the accessor to the relatedObjects Vector when the relationship cardinality on the relatedObjects side is 0..*. Only retrieves objects that haven't been marked for deletion the next time a write occurs.


getDeletedRelatedObjects

public java.util.Vector getDeletedRelatedObjects()
This is the accessor to the relatedObjects Vector when the relationship cardinality on the relatedObjects side is 0..*. Only retrieves objects that have been marked for deletion the next time a write occurs. After a write occurs, the vector gets cleaned out.


getRelatedObject

public DataMappedObject getRelatedObject()
This is the accessor to the relatedObjects Vector when the relationship cardinality on the relatedObjects side is 0..1 or 1.

Returns:
null if no related object, the first DataMappedObject in the relatedObjects vector if any are present.

addRelatedObject

public void addRelatedObject(DataMappedObject bo)
Adds a DataMappedObject to the relationships vector so it can later be retrieved.


populateFromDataArray

public void populateFromDataArray(DataArray dataArray)
Reads as many attributes as it can from the DataArray for an object of the type on the role B side of the relationship. If the object has sufficient information (primary key and required fields), adds the object and processes any nested relationships. This method is used for inline-type relationships ONLY!


cleanupAfterWrite

public void cleanupAfterWrite(DataMapper dataMapper)
Performs cleanup work after a write is committed to the database (for example, resets attribute values).