wt.epm.structure
Class Relationship.Role

java.lang.Object
  extended bywt.epm.structure.Relationship.Role
Direct Known Subclasses:
Relationship.ObjectRole, Relationship.VersionRole
Enclosing class:
Relationship

protected abstract static class Relationship.Role
extends Object

Represents the Role for a Binary Link. Since a role may reference either an object or a version, there are two subclasses of Role, ObjectRole and VersionRole.


Field Summary
private  boolean isRoleA
           
private  String name
           
private  Class referencedClass
           
 
Constructor Summary
protected Relationship.Role(String name, Class referencedClass)
           
 
Method Summary
abstract  void appendJoinCriteria(QuerySpec select, Class linkClass)
          Appends a JOIN condition to input QuerySpec that joins this role of the given link class with the object class that this role references.
abstract  void appendRoleCriteria(QuerySpec select, Class linkClass, WTCollection objects)
          Appends a seach condition to the input QuerySpec that finds all links of the given class where this role of the link references one of the objects in the given collection.
 boolean areSuitable(WTCollection objects)
          Determines whether all of the objects in the given collection are suitable for this role.
abstract  QueryKey createQueryKey(String className, long identifier)
          Creates the appropriate type of QueryKey for this role, either an ObjectIdentifier or a VersionForeignKey.
 WTCollection filterObjects(WTCollection objects)
          Filters out all of the objects in the given collection are not suitable for this role.
protected  String getClassName()
          Returns the logical name of the database column that holds the name of the class of the object that this role references.
protected abstract  String getIdentifierName()
          Returns the logical name of the database column that holds the identifier of the object that this role references.
abstract  int getKeyMask()
          Returns the appropriate key mask for this role.
 String getName()
          Returns the name of this role.
 WTReference getReference(BinaryLink link)
          For the given link, returns the object or version reference that this role holds.
 Class getReferencedClass()
          Returns the class of object that this role references.
 boolean isRoleA()
          Returns true if this role is Role A.
 void selectQueryKey(QuerySpec select, Class linkClass)
          Appends to the SELECT clause such that the identifier and class name of the object that this role references is returned by the query.
 void setObject(BinaryLink link, Persistable object)
          Set this role on the given link such that it references the given object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

name

private String name

referencedClass

private Class referencedClass

isRoleA

private boolean isRoleA
Constructor Detail

Relationship.Role

protected Relationship.Role(String name,
                            Class referencedClass)
Method Detail

getName

public String getName()
Returns the name of this role.


isRoleA

public boolean isRoleA()
Returns true if this role is Role A.


getReferencedClass

public Class getReferencedClass()
Returns the class of object that this role references.


getReference

public WTReference getReference(BinaryLink link)
For the given link, returns the object or version reference that this role holds.


setObject

public void setObject(BinaryLink link,
                      Persistable object)
Set this role on the given link such that it references the given object.


appendJoinCriteria

public abstract void appendJoinCriteria(QuerySpec select,
                                        Class linkClass)
                                 throws WTException
Appends a JOIN condition to input QuerySpec that joins this role of the given link class with the object class that this role references.

Throws:
WTException

appendRoleCriteria

public abstract void appendRoleCriteria(QuerySpec select,
                                        Class linkClass,
                                        WTCollection objects)
                                 throws WTException
Appends a seach condition to the input QuerySpec that finds all links of the given class where this role of the link references one of the objects in the given collection.

Throws:
WTException

selectQueryKey

public void selectQueryKey(QuerySpec select,
                           Class linkClass)
                    throws WTException
Appends to the SELECT clause such that the identifier and class name of the object that this role references is returned by the query.

Throws:
WTException

areSuitable

public boolean areSuitable(WTCollection objects)
                    throws WTException
Determines whether all of the objects in the given collection are suitable for this role.

Throws:
WTException

filterObjects

public WTCollection filterObjects(WTCollection objects)
                           throws WTException
Filters out all of the objects in the given collection are not suitable for this role.

Throws:
WTException

createQueryKey

public abstract QueryKey createQueryKey(String className,
                                        long identifier)
                                 throws WTException
Creates the appropriate type of QueryKey for this role, either an ObjectIdentifier or a VersionForeignKey.

Throws:
WTException

getIdentifierName

protected abstract String getIdentifierName()
Returns the logical name of the database column that holds the identifier of the object that this role references.


getClassName

protected String getClassName()
Returns the logical name of the database column that holds the name of the class of the object that this role references.


getKeyMask

public abstract int getKeyMask()
Returns the appropriate key mask for this role. A key mask determines what types of QueryKeys can be stored in a WTCollection or WTKeyedMap.