Example usage for javax.xml.registry.infomodel ExternalLink addAssociation

List of usage examples for javax.xml.registry.infomodel ExternalLink addAssociation

Introduction

In this page you can find the example usage for javax.xml.registry.infomodel ExternalLink addAssociation.

Prototype

void addAssociation(Association association) throws JAXRException;

Source Link

Document

Adds specified Association to use this object as source.

Usage

From source file:it.cnr.icar.eric.client.xml.registry.infomodel.RegistryObjectImpl.java

public void addExternalLink(ExternalLink extLink) throws JAXRException {
    getExternalLinks();/*from w w w.j  a  v  a2  s.  co m*/

    // If the external link is not in this object's in-memory-cache of
    // external links, add it.
    if (!(externalLinks.contains(extLink))) {
        // Check that an ExternallyLinks association exists between this
        // object and its external link.
        boolean associationExists = false;
        BusinessQueryManagerImpl bqm = (BusinessQueryManagerImpl) (lcm.getRegistryService()
                .getBusinessQueryManager());
        Concept assocType = bqm
                .findConceptByPath("/" + BindingUtility.CANONICAL_CLASSIFICATION_SCHEME_LID_AssociationType
                        + "/" + BindingUtility.CANONICAL_ASSOCIATION_TYPE_CODE_ExternallyLinks);
        @SuppressWarnings("unchecked")
        Collection<Association> linkAssociations = extLink.getAssociations();

        if (linkAssociations != null) {
            Iterator<Association> assIter = linkAssociations.iterator();

            while (assIter.hasNext()) {
                Association ass = assIter.next();

                if (ass.getSourceObject().equals(extLink) && ass.getTargetObject().equals(this)
                        && ass.getAssociationType().equals(assocType)) {
                    associationExists = true;

                    break;
                }
            }
        }

        // Create the association between the external link and this object,
        // if necessary.
        if (!associationExists) {
            Association ass = lcm.createAssociation(this, assocType);
            extLink.addAssociation(ass);
        }

        externalLinks.add(extLink);

        // Note: There is no need to call setModified(true) since
        // the RIM modified object is an Association
    }
}