public interface Association extends RegistryObject {
// Property Accessor Methods (by property name)
public abstract Concept getAssociationType( )
throws javax.xml.registry.JAXRException; //L0
public abstract void setAssociationType(Concept associationType)
throws javax.xml.registry.JAXRException; //L0
public abstract boolean isConfirmed( )
throws javax.xml.registry.JAXRException; //L0
public abstract boolean isConfirmedBySourceOwner( )
throws javax.xml.registry.JAXRException; //L0
public abstract boolean isConfirmedByTargetOwner( )
throws javax.xml.registry.JAXRException; //L0
public abstract boolean isExtramural( )
throws javax.xml.registry.JAXRException; //L0
public abstract RegistryObject getSourceObject( )
throws javax.xml.registry.JAXRException; //L0
public abstract void setSourceObject(RegistryObject srcObject)
throws javax.xml.registry.JAXRException; //L0
public abstract RegistryObject getTargetObject( )
throws javax.xml.registry.JAXRException; //L0
public abstract void setTargetObject(RegistryObject targetObject)
throws javax.xml.registry.JAXRException; //L0
}
An Association represents an assertion of a
relationship of some kind between two objects in the registry, one of
which is referred to as the source object, and the other as the
target object. To create an Association, use the
LifeCycleManager createAssociation(
) method, which requires a reference to the target object
and an association type. The source object is set by adding the
Association to it using the
RegistryObject addAssociation(
) method. As with other registry objects, an
Association is not visible in the registry until
it has been saved using the
BusinessLifeCycleManager
saveAssociations( ) method; in some cases, this is
not sufficient to make the association visible, as described shortly.
The Association type is specified using a
Concept. The JAXR specification defines an
enumerated type containing a set of standard
Association types. There is a full list of these
types listed under "Associations"
in Chapter 7. You can obtain the appropriate
Concept for the type of association you would like
to create using the findConceptByPath( ) method of
BusinessQueryManager, which is described in the
reference section for the Concept interface, later
in this chapter. To form the path needed to locate the
Concept, you must have the identifier of a
ClassificationScheme called
AssociationType, which represents the enumeration
that defines all of the types. The following code extract
demonstrates how to get this ClassificationScheme
and then use it to find the Concept that
represents the association type Uses. It is
assumed that the variable bqm refers to an
instance of BusinessQueryManager.
ClassificationScheme types = bqm.findClassificationSchemeByName(null, "AssociationType");
String path = "/" + types.getKey( ).getId( ) + "/Uses";
Concept uses = bqm.findConceptByPath(path);
Some JAXR providers allow you to use the name of the enumeration in
the path supplied to the findConceptByPath( )
method, thus removing the need to search for the ID of the
ClassificationScheme. In this case, you can use
the following, much simpler code:
Concept uses = bqm.findConceptByPath("/AssociationType/Uses");
The next step is to create an Association by
specifying the type and the target object. The following code uses
the BusinessLifeCycleManager referred to by the
variable blcm to create an association of type
uses with an object referred to by the variable
targetObject as its target:
Association association = blcm.createAssociation(targetObject, uses);
Finally, to complete the association, add the
Association object to the source object:
sourceObject.addAssociation(association);
There is a distinction made in the API between the source and target
objects because associations are directional. The
Uses association type is an example of this
� the Assocation just created conveys the
fact that the source object "uses"
the target object, rather than the other way around. If, at some
point in the future, the association needs to be broken, this can be
done by removing it from the source object using the
removeAssociation( ) method. The source and target
objects and the association type can be obtained by calling the
getSourceObject( ), getTargetObject(
), and getAssociationType( ) methods,
respectively, and can be changed using the corresponding setter
methods. Changing the source object using setSourceObject(
) implicitly removes the Association
from the original source. Note that a registry object may be the
source and/or target of any number of Associations
at the same time. You can search for existing
Associations using the findAssociations(
) and findCallerAssociations( ) methods
of BusinessQueryManager.
Associations can be categorized as either
intramural or extramural. An intramural
Association is formed when the source and target
objects are owned by the same registry User and
the Association is created by that same
User. Such an Association can
be considered a correct factual assertion, and is therefore said to
be confirmed as soon as it is created. An extramural
Association is one in which at least one of the
source and target objects in not owned by the User
that creates it. Such an Association is
unconfirmed, since it has not been agreed to by the owner of both
objects and is not visible to other registry users until it is
confirmed by them. The isExtramural( ) method can
be used to determine the intramural or extramural status of an
Association. An Association can
be confirmed using the confirmAssociation( )
method of BusinessLifeCycleManager, and
confirmation can be withdrawn using the
unconfirmAssociation( ) method. To find out
whether an extramural Association is confirmed,
use the isConfirmed( ),
isConfirmedBySourceOwner( ), and
isConfirmedByTargetOwner( ) methods, which all
return true when applied to an intramural
Association.