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

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

Introduction

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

Prototype

Collection getAssociations() throws JAXRException;

Source Link

Document

Gets all Associations where this object is source.

Usage

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

public void removeExternalLink(ExternalLink extLink) throws JAXRException {
    getExternalLinks();/*from  w w  w.  j av a 2s.  co m*/

    if (externalLinks.contains(extLink)) {
        externalLinks.remove(extLink);

        //Now remove the ExternallyLinks association that has extLink as src and this object as target
        // We make a copy of this.externalLinks to avoid a
        // concurrent modification exception in the removeExternalLinks
        @SuppressWarnings("unchecked")
        Collection<Association> linkAssociations = new ArrayList<Association>(extLink.getAssociations());

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

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

                if (ass.getTargetObject().equals(this)) {
                    if (ass.getAssociationType().getValue()
                            .equalsIgnoreCase(BindingUtility.CANONICAL_ASSOCIATION_TYPE_ID_ExternallyLinks)) {
                        extLink.removeAssociation(ass);
                    }
                }
            }
        }

        //No need to call setModified(true) since RIM modified object is an Assoociation
        //setModified(true);
    }
}

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

public void addExternalLink(ExternalLink extLink) throws JAXRException {
    getExternalLinks();//  w  w w  .  j  av  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
    }
}