wt.fc.association
Class AssociationRuntimeUtilities

java.lang.Object
  extended bywt.fc.association.AssociationRuntimeUtilities

public class AssociationRuntimeUtilities
extends Object

Utility methods for processing associations at runtime. These methods take into account static introspection information as well as runtime information.


Nested Class Summary
private static class AssociationRuntimeUtilities.RoleDescriptorKey
           
 
Field Summary
static int CASCADE_ROLE_QUERY_OID_COUNT
           
static int CASCADE_ROLE_QUERY_ROLE_OID_INDEX
           
private static String CLASSNAME
           
static boolean DEBUG
           
private static DebugWriter LOG
           
static int OWNED_LINK_QUERY_LINK_OID_INDEX
           
static int OWNED_LINK_QUERY_OID_COUNT
           
static int OWNED_LINK_QUERY_ROLE_OID_INDEX
           
 
Constructor Summary
AssociationRuntimeUtilities()
           
 
Method Summary
static Map buildCascadeMap(ClassInfo a_targetClassInfo)
          This method returns a Map of RoleDescriptors for the specified target class.
static QuerySpec buildComponentRoleSpec(long[] a_objectIds, RoleDescriptor a_role, Class a_referenceType, Class a_validClass, String[] a_validClassNames, boolean a_selectLinkObjects, boolean a_linkObjectIds, ClassInfo a_targetClassInfo)
          This method builds a query to return role ObjectIdentifier columns and optionally link ObjectIdentifier columns (if a_selectLinkObjects=true) for the specified role.
private static List buildDescendentRuntimeReferentialIntegrityClassInfos(ClassInfo a_targetClassInfo, List a_list)
           
static List buildNonOwnerList(ClassInfo a_targetClassInfo)
          This method returns a List of RoleDescriptors for associations that the specified target class can take part in.
static List buildOwnerList(ClassInfo a_targetClassInfo)
          This method returns a List of RoleDescriptors for associations that the specified target class can take part in.
private static List buildOwnerList(ClassInfo a_targetClassInfo, boolean a_checkOwner)
          This method returns a List of RoleDescriptors for associations that the specified target class can take part in.
static StatementSpec buildRoleSpec(long[] a_objectIds, Collection a_roles, Map a_roleValidClassMap, boolean a_selectLinkObjects, boolean a_linkObjectIds, ClassInfo a_targetClassInfo)
          This method builds a query to return role ObjectIdentifier columns and optionally link ObjectIdentifier columns (if a_selectLinkObjects=true) for the specified roles.
static boolean isRoleParticipant(ClassInfo a_targetClassInfo)
          This method indicates if the specified target class participates as a role object in another association.
static boolean isRuntimeReferentialIntegrityProcessingRequired(ClassInfo a_targetClassInfo)
          This method indicates if the specified target class requires "remove event" participation.
private static HashSet processOwnerList(LinkInfo a_linkInfo, boolean a_isRoleA, ClassInfo a_targetClassInfo, boolean a_checkOwner, HashSet a_set)
          This method processes the specified LinkInfo to determine if it is a valid Role for the target class for the specified owner check.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLASSNAME

private static final String CLASSNAME

DEBUG

public static final boolean DEBUG

LOG

private static final DebugWriter LOG

OWNED_LINK_QUERY_OID_COUNT

public static final int OWNED_LINK_QUERY_OID_COUNT
See Also:
Constant Field Values

OWNED_LINK_QUERY_LINK_OID_INDEX

public static final int OWNED_LINK_QUERY_LINK_OID_INDEX
See Also:
Constant Field Values

OWNED_LINK_QUERY_ROLE_OID_INDEX

public static final int OWNED_LINK_QUERY_ROLE_OID_INDEX
See Also:
Constant Field Values

CASCADE_ROLE_QUERY_OID_COUNT

public static final int CASCADE_ROLE_QUERY_OID_COUNT
See Also:
Constant Field Values

CASCADE_ROLE_QUERY_ROLE_OID_INDEX

public static final int CASCADE_ROLE_QUERY_ROLE_OID_INDEX
See Also:
Constant Field Values
Constructor Detail

AssociationRuntimeUtilities

public AssociationRuntimeUtilities()
Method Detail

buildNonOwnerList

public static List buildNonOwnerList(ClassInfo a_targetClassInfo)
                              throws WTException
This method returns a List of RoleDescriptors for associations that the specified target class can take part in. The results are filtered to only roles where the Owner attributes is false and the Link requires "remove event" participation.

Supported API: false

Parameters:
a_targetClassInfo -
Throws:
WTException

buildOwnerList

public static List buildOwnerList(ClassInfo a_targetClassInfo)
                           throws WTException
This method returns a List of RoleDescriptors for associations that the specified target class can take part in. The results are filtered to only roles where the Owner attribute is true and the Link requires "remove event" participation.

Supported API: false

Parameters:
a_targetClassInfo -
Throws:
WTException

buildCascadeMap

public static Map buildCascadeMap(ClassInfo a_targetClassInfo)
                           throws WTException
This method returns a Map of RoleDescriptors for the specified target class. The target class will only have RoleDescriptors if it is a Link. The key in the Map is a RoleDescriptor which is associated with a List of valid role classes that require remove event participation. Any role classes that do not require remove event participation are filtered out.

Supported API: false

Parameters:
a_targetClassInfo -
Throws:
WTException

buildRoleSpec

public static StatementSpec buildRoleSpec(long[] a_objectIds,
                                          Collection a_roles,
                                          Map a_roleValidClassMap,
                                          boolean a_selectLinkObjects,
                                          boolean a_linkObjectIds,
                                          ClassInfo a_targetClassInfo)
                                   throws WTException
This method builds a query to return role ObjectIdentifier columns and optionally link ObjectIdentifier columns (if a_selectLinkObjects=true) for the specified roles. The specified object IDs are used as primary key criteria on either the link (a_linkObjectIds=true) or role (a_linkObjectIds=false) class. The specified roleValidClassMap (optional) is used to indicate a list of valid role classes for a given role. If the map is null or has no associated list, then the role's valid class is used. The query that is built will return ObjectIdentifier classname and ID as raw columns. The QueryResult elements will be an Object[] of either 2 or 4 columns with clasname preceding ID.

Parameters:
a_objectIds - ObjectIdentifier IDs to use in criteria
a_roles - Collection of roles to build the query for
a_roleValidClassMap - indicates associated valid classes (optional)
a_selectLinkObjects - indicates if link OIDs should be selected in addition to role OIDs
a_linkObjectIds - indicates if the ObjectIdentifier ID criteria should use the link class (true) or the role class (false)
a_targetClassInfo - specifies the exact role target class (if known)
Throws:
WTException

buildComponentRoleSpec

public static QuerySpec buildComponentRoleSpec(long[] a_objectIds,
                                               RoleDescriptor a_role,
                                               Class a_referenceType,
                                               Class a_validClass,
                                               String[] a_validClassNames,
                                               boolean a_selectLinkObjects,
                                               boolean a_linkObjectIds,
                                               ClassInfo a_targetClassInfo)
                                        throws WTException
This method builds a query to return role ObjectIdentifier columns and optionally link ObjectIdentifier columns (if a_selectLinkObjects=true) for the specified role. The specified object IDs are used as primary key criteria on either the link (a_linkObjectIds=true) or role (a_linkObjectIds=false) class. The query that is built will return ObjectIdentifier classname and ID as raw columns. The QueryResult elements will be an Object[] of either 2 or 4 columns with clasname preceding ID.

Parameters:
a_objectIds - ObjectIdentifier IDs to use in criteria
a_role - Role to build the query for
a_referenceType - WTReference class that implements this Role
a_validClass - valid role class
a_selectLinkObjects - indicates if link OIDs should be selected in addition to role OIDs
a_linkObjectIds - indicates if the ObjectIdentifier ID criteria should use the link class (true) or the role class (false)
Throws:
WTException

isRuntimeReferentialIntegrityProcessingRequired

public static boolean isRuntimeReferentialIntegrityProcessingRequired(ClassInfo a_targetClassInfo)
                                                               throws WTException
This method indicates if the specified target class requires "remove event" participation.

Supported API: false

Parameters:
a_targetClassInfo -
Throws:
WTException

isRoleParticipant

public static boolean isRoleParticipant(ClassInfo a_targetClassInfo)
                                 throws WTException
This method indicates if the specified target class participates as a role object in another association.

Supported API: false

Parameters:
a_targetClassInfo -
Throws:
WTException

buildDescendentRuntimeReferentialIntegrityClassInfos

private static List buildDescendentRuntimeReferentialIntegrityClassInfos(ClassInfo a_targetClassInfo,
                                                                         List a_list)
                                                                  throws WTException
Throws:
WTException

buildOwnerList

private static List buildOwnerList(ClassInfo a_targetClassInfo,
                                   boolean a_checkOwner)
                            throws WTException
This method returns a List of RoleDescriptors for associations that the specified target class can take part in. The results are filtered as specified by a_checkOwner boolean. The associated Link must also require "remove event" participation.

Supported API: false

Parameters:
a_targetClassInfo - target class to check
a_checkOwner - check for "owner=true" or "owner= false"
Throws:
WTException

processOwnerList

private static HashSet processOwnerList(LinkInfo a_linkInfo,
                                        boolean a_isRoleA,
                                        ClassInfo a_targetClassInfo,
                                        boolean a_checkOwner,
                                        HashSet a_set)
                                 throws WTException
This method processes the specified LinkInfo to determine if it is a valid Role for the target class for the specified owner check.

Supported API: false

Parameters:
a_linkInfo - Link class to check
a_isRoleA - indicates which role
a_targetClassInfo - target class for the association
a_checkOwner - check for "owner=true" or "owner= false"
Throws:
WTException