Example usage for javax.xml.registry.infomodel Association getAssociationType

List of usage examples for javax.xml.registry.infomodel Association getAssociationType

Introduction

In this page you can find the example usage for javax.xml.registry.infomodel Association getAssociationType.

Prototype

Concept getAssociationType() throws JAXRException;

Source Link

Document

Gets the association type for this Association.

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  . ja v  a2 s . c o  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();/*from   ww  w.jav a 2 s.c  o  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
    }
}

From source file:it.cnr.icar.eric.client.ui.swing.graph.JBGraph.java

/**
 * DOCUMENT ME!//from w w w .  ja v a2s. c o m
 *
 * @param cell DOCUMENT ME!
 * @param ro DOCUMENT ME!
 *
 * @return ArrayList of GraphCell for the related objects.
 */
private ArrayList<Object> showRelatedObjects(JBGraphCell cell, RegistryObject ro) {
    ArrayList<Object> relatedCells = new ArrayList<Object>();

    if (ro == null) {
        return relatedCells;
    }

    try {
        CellView cellView = getView().getMapping(cell, false);
        Rectangle bounds = cellView.getBounds();

        //Classifications
        Collection<?> classifications = ro.getClassifications();
        DefaultGraphCell groupCell = createGroupFromObjectCollection(classifications);

        if (groupCell != null) {
            connectCells(cell, groupCell, "classifications", false);
            relatedCells.add(groupCell);
        }

        //ExternalIdentifiers
        Collection<?> extIds = ro.getExternalIdentifiers();
        groupCell = createGroupFromObjectCollection(extIds);

        if (groupCell != null) {
            connectCells(cell, groupCell, "externalIdentifiers", false);
            relatedCells.add(groupCell);
        }

        //ExternalLinks
        Collection<?> extLinks = ro.getExternalLinks();
        groupCell = createGroupFromObjectCollection(extLinks);

        if (groupCell != null) {
            connectCells(cell, groupCell, "externalLinks", false);
            relatedCells.add(groupCell);
        }

        /*
           //RegistryPackages
           try {
           Collection pkgs = ro.getRegistryPackages();
           Iterator iter = pkgs.iterator();
           while (iter.hasNext()) {
               RegistryPackage pkg = (RegistryPackage)iter.next();
               if (pkg != null) {
                   JBGraphCell newCell = addRelatedObject(cell, pkg, new Rectangle(0, 0, 50, 50), "HasMember", true);
                   relatedCells.add(newCell);
               }
           }
           } catch (UnsupportedCapabilityException e) {
           }
         **/

        try {
            //Associations
            Collection<?> assocs = ((RegistryObjectImpl) ro).getAllAssociations();
            Iterator<?> iter = assocs.iterator();

            while (iter.hasNext()) {
                Association assoc = (Association) iter.next();
                RegistryObject srcObj = assoc.getSourceObject();
                RegistryObject targetObj = assoc.getTargetObject();
                Concept concept = assoc.getAssociationType();

                String label = "associatedWith";

                if (concept != null) {
                    label = concept.getValue();
                }

                if ((srcObj != null) && (targetObj != null)) {
                    JBGraphCell newCell = null;

                    if (srcObj.getKey().getId().equalsIgnoreCase(ro.getKey().getId())) {
                        //ro is the source, newCell is the target
                        newCell = addRelatedObject(cell, targetObj,
                                new Rectangle(bounds.x + 100, bounds.y, 50, 50), label, false);
                    } else {
                        //ro is the target, newCell is the source
                        newCell = addRelatedObject(cell, srcObj,
                                new Rectangle(bounds.x + 100, bounds.y, 50, 50), label, true);
                    }

                    relatedCells.add(newCell);
                } else {
                    System.err.println(
                            "Invalid association. Source or target is null: " + assoc.getKey().getId());
                }
            }

        } catch (UnsupportedCapabilityException e) {
        }
    } catch (JAXRException e) {
        RegistryBrowser.displayError(e);
    }

    return relatedCells;
}

From source file:it.cnr.icar.eric.client.ui.thin.RegistryObjectCollectionBean.java

private List<RegistryObjectBean> getAssociationsSearchResultsBeans(RegistryObjectBean roBean)
        throws ClassNotFoundException, NoSuchMethodException, ExceptionInInitializerError, Exception {
    // The objectTypeRefs map is normally populated by a call to ro.getComposedObjects().
    // However, the getComposedObjects() method retrieves all composed objects for the 
    // inspected RO. In terms of Associations, only those where the RO is the source object 
    // are returned. In order to get all Associations, including those where the RO is the
    // target of an Association, you must call RegistryObjectImpl.getAllAssociations().
    Collection<RegistryObject> associations = ((RegistryObjectImpl) roBean.getRegistryObject())
            .getAllAssociations();//from   w  w  w. j a  v  a2s .c om
    // check if association is valid to list in association tab of
    // details panel.
    if (associations != null) {
        associations = this.filterValidAssociation(associations);
    }
    if (associations == null) {
        return null;
    }
    int numAssociations = associations.size();
    @SuppressWarnings("unused")
    ArrayList<Object> list = new ArrayList<Object>(numAssociations);

    Iterator<RegistryObject> roItr = associations.iterator();
    if (log.isDebugEnabled()) {
        log.debug("Query results: ");
    }

    String objectType = "Association";
    int numCols = 2;
    // Replace ObjectType with Id. TODO - formalize this convention
    List<RegistryObjectBean> roBeans = new ArrayList<RegistryObjectBean>(numAssociations);
    for (@SuppressWarnings("unused")
    int i = 0; roItr.hasNext(); i++) {
        Association association = (Association) roItr.next();
        String header = null;
        Object columnValue = null;
        @SuppressWarnings("unused")
        ArrayList<Object> srvbHeader = new ArrayList<Object>(numCols);
        ArrayList<SearchResultValueBean> searchResultValueBeans = new ArrayList<SearchResultValueBean>(numCols);

        header = WebUIResourceBundle.getInstance().getString("Details");
        columnValue = association.getKey().getId();
        searchResultValueBeans.add(new SearchResultValueBean(header, columnValue));

        header = WebUIResourceBundle.getInstance().getString("Source Object");
        columnValue = association.getSourceObject().getKey().getId();
        searchResultValueBeans.add(new SearchResultValueBean(header, columnValue));

        header = WebUIResourceBundle.getInstance().getString("Target Object");
        columnValue = association.getTargetObject().getKey().getId();
        searchResultValueBeans.add(new SearchResultValueBean(header, columnValue));

        header = WebUIResourceBundle.getInstance().getString("Type");
        columnValue = association.getAssociationType();
        searchResultValueBeans.add(new SearchResultValueBean(header, columnValue));

        RegistryObjectBean srb = new RegistryObjectBean(searchResultValueBeans, roBean.getRegistryObject(),
                objectType, association, false);
        roBeans.add(srb);
    }
    return roBeans;
}

From source file:org.apache.ws.scout.util.ScoutJaxrUddiHelper.java

public static PublisherAssertion getPubAssertionFromJAXRAssociation(Association association)
        throws JAXRException {
    PublisherAssertion pa = objectFactory.createPublisherAssertion();
    try {/* w  w w  .  j a  va 2 s. c  om*/
        if (association.getSourceObject().getKey() != null
                && association.getSourceObject().getKey().getId() != null) {
            pa.setFromKey(association.getSourceObject().getKey().getId());
        }

        if (association.getTargetObject().getKey() != null
                && association.getTargetObject().getKey().getId() != null) {
            pa.setToKey(association.getTargetObject().getKey().getId());
        }
        Concept c = association.getAssociationType();
        String v = c.getValue();
        KeyedReference kr = objectFactory.createKeyedReference();
        Key key = c.getKey();
        if (key == null) {
            // TODO:Need to check this. If the concept is a predefined
            // enumeration, the key can be the parent classification scheme
            key = c.getClassificationScheme().getKey();
        }
        if (key != null && key.getId() != null) {
            kr.setTModelKey(key.getId());
        }
        kr.setKeyName("Concept");

        if (v != null) {
            kr.setKeyValue(v);
        }

        pa.setKeyedReference(kr);
    } catch (Exception ud) {
        throw new JAXRException("Apache JAXR Impl:", ud);
    }
    return pa;
}