View Javadoc
1 /*** 2 * $Header: /cvsroot/ebxmlrr/jaxr/src/com/sun/xml/registry/client/browser/graph/RelationshipPanel.java,v 1.7 2003/08/24 22:14:56 farrukh_najmi Exp $ 3 * 4 * 5 */ 6 package com.sun.xml.registry.client.browser.graph; 7 8 import java.awt.*; 9 import java.awt.event.*; 10 import java.net.*; 11 import java.io.*; 12 import java.util.*; 13 import java.beans.*; 14 import javax.swing.*; 15 import javax.xml.registry.*; 16 import javax.xml.registry.infomodel.*; 17 18 import com.sun.xml.registry.client.browser.conf.bindings.*; 19 import com.sun.xml.registry.client.browser.conf.bindings.types.*; 20 //import org.oasis.ebxml.registry.bindings.rim.*; 21 22 import com.sun.xml.registry.client.browser.*; 23 24 /*** 25 * A panel that allows setting different types of relationships between two RegistryObjects. 26 * 27 * @author <a href="mailto:Farrukh.Najmi@Sun.COM">Farrukh S. Najmi</a> 28 */ 29 public class RelationshipPanel extends CardManagerPanel { 30 31 private GridBagConstraints c = new GridBagConstraints(); 32 private RegistryObject src = null; 33 private RegistryObject target = null; 34 35 public static final String RELATIONSHIP_TYPE_ASSOCIATION="Association"; 36 public static final String RELATIONSHIP_TYPE_REFERENCE="Reference"; 37 38 private String relationshipType = RELATIONSHIP_TYPE_ASSOCIATION; 39 40 private AssociationPanel assPanel; 41 private ReferencePanel refPanel; 42 43 private ArrayList map = new ArrayList(); 44 45 private static final String REL_CLASSIFICATION_RO = "classifiedObject"; 46 private static final String REL_CLASSIFICATION_SCHEME = "classificationScheme"; 47 private static final String REL_CLASSIFICATION_CONCEPT = "concept"; 48 49 private static final String REL_CONCEPT_PARENT = "parent"; 50 51 private static final String REL_EXTERNALID_IDSCHEME = "identificationScheme"; 52 53 private static final String REL_ORGANIZATION_CHILDORGS = "childOrganizations"; 54 private static final String REL_ORGANIZATION_CONTACT = "primaryContact"; 55 56 private static final String REL_BINDING_SPECLINKS = "specificationLinks"; 57 58 private static final String REL_SERVICE_BINDINGS = "serviceBindings"; 59 60 private static final String REL_SPECLINK_SPEC = "specificationObject"; 61 62 private String[][][] refMatrix = { 63 {{}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}}, //0 - Association 64 { {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}}, //1 - AuditableEvent 65 {{REL_CLASSIFICATION_RO}, {REL_CLASSIFICATION_RO}, {REL_CLASSIFICATION_RO}, {REL_CLASSIFICATION_SCHEME, REL_CLASSIFICATION_RO}, {REL_CLASSIFICATION_CONCEPT, REL_CLASSIFICATION_RO}, {REL_CLASSIFICATION_RO}, {REL_CLASSIFICATION_RO}, {REL_CLASSIFICATION_RO}, {REL_CLASSIFICATION_RO}, {REL_CLASSIFICATION_RO}, {REL_CLASSIFICATION_RO}, {REL_CLASSIFICATION_RO}, {REL_CLASSIFICATION_RO}, {REL_CLASSIFICATION_RO}}, 66 {{}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}}, //3 - ClassificationScheme 67 {{}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}}, //4 - Concept 68 {{}, {}, {}, {REL_EXTERNALID_IDSCHEME}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}}, //5 - ExternalIdentifier 69 {{}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}}, //6 - ExternalLink 70 {{}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}}, //7 - ExtrinsicObject 71 {{}, {}, {}, {}, {}, {}, {}, {}, {REL_ORGANIZATION_CHILDORGS}, {}, {}, {}, {}, {REL_ORGANIZATION_CONTACT}}, //8 - Organization 72 {{}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}}, //9 - RegistryPackage 73 {{}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {REL_BINDING_SPECLINKS}, {}}, //10 - ServiceBinding 74 {{}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {REL_SERVICE_BINDINGS}, {}, {}, {}}, //11 - Service 75 {{}, {}, {}, {}, {REL_SPECLINK_SPEC}, {}, {}, {REL_SPECLINK_SPEC}, {}, {}, {}, {}, {}, {}}, //12- SpecificationLink 76 {{}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}}, //13 - User 77 }; 78 79 /*** 80 * Class Constructor. 81 */ 82 public RelationshipPanel(RegistryObject src, RegistryObject target) { 83 84 super( 85 new String[] {RELATIONSHIP_TYPE_ASSOCIATION, RELATIONSHIP_TYPE_REFERENCE}, 86 new JPanel[] {new AssociationPanel(), new ReferencePanel(src, target)} 87 ); 88 89 assPanel = (AssociationPanel)cardPanels[0]; 90 refPanel = (ReferencePanel)cardPanels[1]; 91 92 this.src = src; 93 this.target = target; 94 95 map.add("Association"); //0 96 map.add("AuditableEvent"); //1 97 map.add("Classification"); //2 98 map.add("ClassificationScheme"); //3 99 map.add("Concept"); //4 100 map.add("ExternalIdentifier"); //5 101 map.add("ExternalLink"); //6 102 map.add("ExtrinsicObject"); //7 103 map.add("Organization"); //8 104 map.add("RegistryPackage"); //9 105 map.add("ServiceBinding"); //10 106 map.add("Service"); //11 107 map.add("SpecificationLink"); //12 108 map.add("User"); //13 109 110 111 int row = map.indexOf(getJAXRName(src)); 112 int col = map.indexOf(getJAXRName(target)); 113 114 String[] refs = refMatrix[row][col]; 115 116 try { 117 JAXRClient client = RegistryBrowser.getInstance().getClient(); 118 BusinessLifeCycleManager lcm = client.getBusinessLifeCycleManager(); 119 com.sun.xml.registry.ebxml.BusinessQueryManagerImpl bqm = (com.sun.xml.registry.ebxml.BusinessQueryManagerImpl)(client.getBusinessQueryManager()); 120 121 if (refs.length == 0) { 122 remove(selectorPanel); 123 initAssociationPanel(); 124 } 125 else { 126 relationshipType = RELATIONSHIP_TYPE_REFERENCE; 127 refPanel.setReferenceAttributes(refs); 128 } 129 showCard(relationshipType); 130 } 131 catch (JAXRException e) { 132 RegistryBrowser.displayError(e); 133 } 134 135 } 136 137 private void initAssociationPanel() throws JAXRException { 138 JAXRClient client = RegistryBrowser.getInstance().getClient(); 139 BusinessLifeCycleManager lcm = client.getBusinessLifeCycleManager(); 140 com.sun.xml.registry.ebxml.BusinessQueryManagerImpl bqm = (com.sun.xml.registry.ebxml.BusinessQueryManagerImpl)(client.getBusinessQueryManager()); 141 142 relationshipType = RELATIONSHIP_TYPE_ASSOCIATION; 143 144 Concept assType = null; 145 146 //Set associationType for any pre-defined associations 147 if (src instanceof RegistryPackage) { 148 assType = bqm.findConceptByPath("/urn:uuid:6902675f-2f18-44b8-888b-c91db8b96b4d/" + com.sun.xml.registry.ebxml.infomodel.AssociationImpl.ASSOCIATION_TYPE_HAS_MEMBER); 149 } 150 else if (src instanceof ExternalLink) { 151 assType = bqm.findConceptByPath("/urn:uuid:6902675f-2f18-44b8-888b-c91db8b96b4d/" + com.sun.xml.registry.ebxml.infomodel.AssociationImpl.ASSOCIATION_TYPE_EXTERNALLY_LINKS); 152 } 153 else if ((src instanceof Organization) && (target instanceof Service)) { 154 assType = bqm.findConceptByPath("/urn:uuid:6902675f-2f18-44b8-888b-c91db8b96b4d/" + com.sun.xml.registry.ebxml.infomodel.AssociationImpl.ASSOCIATION_TYPE_OFFERS_SERVICE); 155 } 156 //this.remove(selectorPanel); 157 158 Association ass = lcm.createAssociation(target, assType); 159 src.addAssociation(ass); 160 assPanel.setModel(ass); 161 } 162 163 protected void showCardAction(String card) { 164 if (card.equals(RELATIONSHIP_TYPE_ASSOCIATION)) { 165 try { 166 if (assPanel.getModel() == null) { 167 initAssociationPanel(); 168 } 169 } 170 catch (JAXRException e) { 171 RegistryBrowser.displayError(e); 172 } 173 } 174 super.showCardAction(card); 175 } 176 177 178 public void setReferenceAttributeOnSourceObject() throws JAXRException { 179 if (relationshipType == RELATIONSHIP_TYPE_REFERENCE) { 180 refPanel.setReferenceAttributeOnSourceObject(); 181 } 182 183 } 184 185 186 public String getRelationshipType() { 187 return relationshipType; 188 } 189 190 public String getRelationshipName() { 191 String relName = ""; 192 193 try { 194 if (relationshipType == RELATIONSHIP_TYPE_ASSOCIATION) { 195 Concept assType = ((Association)(assPanel.getModel())).getAssociationType(); 196 if (assType != null) { 197 relName = assType.getValue(); 198 } 199 } 200 else if (relationshipType == RELATIONSHIP_TYPE_REFERENCE) { 201 relName = refPanel.getReferenceAttribute(); 202 } 203 } 204 catch (JAXRException e) { 205 RegistryBrowser.displayError(e); 206 } 207 208 return relName; 209 } 210 211 public Association getAssociation() throws JAXRException { 212 return (Association)(assPanel.getModel()); 213 } 214 215 String getJAXRName(RegistryObject ro) { 216 String newClassName = ro.getClass().getName(); 217 newClassName = newClassName.substring(newClassName.lastIndexOf(".")+1); 218 if (newClassName.endsWith("Impl")) { 219 //Remove Impl suffix for JAXR provider Impl classes 220 newClassName = newClassName.substring(0, newClassName.length() -4); 221 } 222 223 return newClassName; 224 } 225 226 227 228 } 229 230 231 232

This page was automatically generated by Maven