Example usage for javax.xml.registry.infomodel RegistryObject getExternalLinks

List of usage examples for javax.xml.registry.infomodel RegistryObject getExternalLinks

Introduction

In this page you can find the example usage for javax.xml.registry.infomodel RegistryObject getExternalLinks.

Prototype

Collection getExternalLinks() throws JAXRException;

Source Link

Document

Returns the ExternalLinks associated with this object.

Usage

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

/**
 * DOCUMENT ME!/*from   w w w.jav a  2 s . c om*/
 *
 * @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;
}