Remove bindingType attribute on casaPort. The bindingType is derivable from the binding component service unit.
1.1 --- a/compapp.casaeditor/src/org/netbeans/modules/compapp/casaeditor/design/CasaModelGraphUtilities.java Wed Mar 28 23:04:27 2007 +0000
1.2 +++ b/compapp.casaeditor/src/org/netbeans/modules/compapp/casaeditor/design/CasaModelGraphUtilities.java Wed Mar 28 23:41:04 2007 +0000
1.3 @@ -260,10 +260,11 @@
1.4 return false;
1.5 }
1.6 // String bindingType = model.getDefaultBindingComponents().get(bcCompName);
1.7 - String bindingType = casaPort.getBindingType();
1.8 - if (bindingType == null) {
1.9 - bindingType = model.getDefaultBindingComponents().get(bcCompName);
1.10 - }
1.11 +// String bindingType = casaPort.getBindingType();
1.12 +// if (bindingType == null) {
1.13 +// bindingType = model.getDefaultBindingComponents().get(bcCompName);
1.14 +// }
1.15 + String bindingType = model.getBindingType(casaPort);
1.16 if (bindingType == null) {
1.17 ErrorManager.getDefault().notify(new UnsupportedOperationException(
1.18 NbBundle.getMessage(CasaModelGraphUtilities.class, "Error_Invalid_Binding_Component") + bcCompName));
2.1 --- a/compapp.casaeditor/src/org/netbeans/modules/compapp/casaeditor/graph/actions/CasaPaletteAcceptProvider.java Wed Mar 28 23:04:27 2007 +0000
2.2 +++ b/compapp.casaeditor/src/org/netbeans/modules/compapp/casaeditor/graph/actions/CasaPaletteAcceptProvider.java Wed Mar 28 23:41:04 2007 +0000
2.3 @@ -236,7 +236,7 @@
2.4 case WSDL_BINDINGS :
2.5 point = getScene().getBindingRegion().convertSceneToLocal(point);
2.6 mModel.addCasaPort(
2.7 - selNode.getTitle(),
2.8 + //selNode.getTitle(),
2.9 selNode.getComponentName(),
2.10 point.x,
2.11 point.y);
3.1 --- a/compapp.casaeditor/src/org/netbeans/modules/compapp/casaeditor/model/casa/CasaPort.java Wed Mar 28 23:04:27 2007 +0000
3.2 +++ b/compapp.casaeditor/src/org/netbeans/modules/compapp/casaeditor/model/casa/CasaPort.java Wed Mar 28 23:41:04 2007 +0000
3.3 @@ -34,14 +34,14 @@
3.4 public static final String CONSUMES_PROPERTY = "consumes"; // NOI18N
3.5 public static final String PROVIDES_PROPERTY = "provides"; // NOI18N
3.6
3.7 - public static final String BINDINGTYPE_PROPERTY = "bindingType"; // NOI18N
3.8 +// public static final String BINDINGTYPE_PROPERTY = "bindingType"; // NOI18N
3.9 // public static final String PORTTYPE_PROPERTY = "portType"; // NOI18N
3.10 //
3.11 // String getPortType();
3.12 // void setPortType(String portType);
3.13 -
3.14 - String getBindingType();
3.15 - void setBindingType(String bindingType);
3.16 +//
3.17 +// String getBindingType();
3.18 +// void setBindingType(String bindingType);
3.19
3.20 int getX();
3.21 void setX(int x);
4.1 --- a/compapp.casaeditor/src/org/netbeans/modules/compapp/casaeditor/model/casa/CasaWrapperModel.java Wed Mar 28 23:04:27 2007 +0000
4.2 +++ b/compapp.casaeditor/src/org/netbeans/modules/compapp/casaeditor/model/casa/CasaWrapperModel.java Wed Mar 28 23:41:04 2007 +0000
4.3 @@ -89,16 +89,16 @@
4.4 public static final String PROPERTY_ENDPOINT_REMOVED = PROPERTY_PREFIX + "endpoint_removed"; // NOI18N
4.5 public static final String PROPERTY_ENDPOINT_ADDED = PROPERTY_PREFIX + "endpoint_added"; // NOI18N
4.6 public static final String PROPERTY_ENDPOINT_NAME_CHANGED = PROPERTY_PREFIX + "endpoint_renamed"; // NOI18N
4.7 - public static final String PROPERTY_ENDPOINT_INTERFACE_QNAME_CHANGED = PROPERTY_PREFIX + "endpoint_interface_qname_changed"; // NOI18N
4.8 - public static final String PROPERTY_ENDPOINT_SERVICE_QNAME_CHANGED = PROPERTY_PREFIX + "endpoint_service_qname_changed"; // NOI18N
4.9 + public static final String PROPERTY_ENDPOINT_INTERFACE_QNAME_CHANGED = PROPERTY_PREFIX + "endpoint_interface_qname_changed"; // NOI18N
4.10 + public static final String PROPERTY_ENDPOINT_SERVICE_QNAME_CHANGED = PROPERTY_PREFIX + "endpoint_service_qname_changed"; // NOI18N
4.11 public static final String PROPERTY_SERVICE_UNIT_RENAMED = PROPERTY_PREFIX + "service_unit_renamed"; // NOI18N
4.12 public static final String PROPERTY_SERVICE_ENGINE_SERVICE_UNIT_ADDED = PROPERTY_PREFIX + "service_unit_added"; // NOI18N
4.13 public static final String PROPERTY_SERVICE_ENGINE_SERVICE_UNIT_REMOVED = PROPERTY_PREFIX + "service_unit_removed"; // NOI18N
4.14
4.15 - private static final String CASA_WSDL_RELATIVE_LOCATION = "../jbiasa/"; // NOI18N
4.16 - private static final String CASA_WSDL_FILENAME = "casa.wsdl"; // NOI18N
4.17 - private static final String JBI_SERVICE_UNITS_DIR = "jbiServiceUnits"; // NOI18N
4.18 - private static final String DUMMY_PORTTYPE_NAME = "dummyCasaPortType"; // NOI18N
4.19 + private static final String CASA_WSDL_RELATIVE_LOCATION = "../jbiasa/"; // NOI18N
4.20 + private static final String CASA_WSDL_FILENAME = "casa.wsdl"; // NOI18N
4.21 + private static final String JBI_SERVICE_UNITS_DIR = "jbiServiceUnits"; // NOI18N
4.22 + private static final String DUMMY_PORTTYPE_NAME = "dummyCasaPortType"; // NOI18N
4.23
4.24 private static final String NEWLINE = System.getProperty("line.separator");
4.25 private static final String CASA_WSDL_TNS = "http://whatever";
4.26 @@ -117,7 +117,15 @@
4.27 // mapping WSDL port link hrefs to WSDL components
4.28 private Map<String, Object> cachedWSDLComponents = new HashMap<String, Object>();
4.29
4.30 -
4.31 + // mapping binding component name to binding type,
4.32 + // e.x, "sun-smtp-binding" -> "smtp".
4.33 + private Map<String, String> bcName2BindingType;
4.34 +
4.35 + // mapping binding type to binding component name,
4.36 + // e.x, "smtp" -> "sun-smtp-binding".
4.37 + private Map<String, String> bindingType2BcName;
4.38 +
4.39 +
4.40 /** Creates a new instance of CasaWrapperModel */
4.41 public CasaWrapperModel(ModelSource source) {
4.42 super(source);
4.43 @@ -129,13 +137,9 @@
4.44 ex.printStackTrace();
4.45 }
4.46
4.47 - buildCatalogModel();
4.48 + buildBindingComponentMaps();
4.49 }
4.50 -
4.51 - private void buildCatalogModel() {
4.52
4.53 - }
4.54 -
4.55 public void removePropertyChangeListener(final PropertyChangeListener pcl) {
4.56 super.removePropertyChangeListener(pcl);
4.57 mSupport.removePropertyChangeListener(pcl);
4.58 @@ -198,6 +202,11 @@
4.59 (CasaBindingComponentServiceUnit) casaPort.getParent().getParent();
4.60 return bcSU.getComponentName();
4.61 }
4.62 +
4.63 + public String getBindingType(final CasaPort casaPort) {
4.64 + String bcName = getBindingComponentName(casaPort);
4.65 + return bcName2BindingType.get(bcName);
4.66 + }
4.67
4.68 /**
4.69 * Sets the endpoint name of a casa port.
4.70 @@ -846,25 +855,22 @@
4.71
4.72 return null;
4.73 }
4.74 -
4.75 - // mapping bc namspace to bc name?
4.76 - private Map<String, String> bcNameMap;
4.77 -
4.78 +
4.79 // FIXME: should we get bcs from design time or run time?
4.80 - public Map<String, String> getDefaultBindingComponents() {
4.81 - if (bcNameMap == null) {
4.82 - bcNameMap = new HashMap<String, String>();
4.83 -
4.84 - JbiDefaultComponentInfo bcinfo =
4.85 - JbiDefaultComponentInfo.getJbiDefaultComponentInfo();
4.86 - assert bcinfo != null;
4.87 -
4.88 - List<JbiBindingInfo> bcList = bcinfo.getBindingInfoList();
4.89 - for (JbiBindingInfo bi : bcList) {
4.90 - bcNameMap.put(bi.getBcName(), bi.getBindingName());
4.91 - }
4.92 + private void buildBindingComponentMaps() {
4.93 + bcName2BindingType = new HashMap<String, String>();
4.94 + bindingType2BcName = new HashMap<String, String>();
4.95 +
4.96 + JbiDefaultComponentInfo bcinfo =
4.97 + JbiDefaultComponentInfo.getJbiDefaultComponentInfo();
4.98 + assert bcinfo != null;
4.99 +
4.100 + for (JbiBindingInfo bi : bcinfo.getBindingInfoList()) {
4.101 + String bcName = bi.getBcName();
4.102 + String bindingName = bi.getBindingName();
4.103 + bcName2BindingType.put(bcName, bindingName);
4.104 + bindingType2BcName.put(bindingName, bcName);
4.105 }
4.106 - return bcNameMap;
4.107 }
4.108
4.109 /**
4.110 @@ -1051,8 +1057,7 @@
4.111 /**
4.112 * Adds a new WSDL endpoint.
4.113 */
4.114 - public CasaPort addCasaPort(String componentType, String componentName,
4.115 - int x, int y) {
4.116 + public CasaPort addCasaPort(String componentName, int x, int y) {
4.117
4.118 // 1. Update casa.wsdl
4.119 WSDLModel casaWSDLModel = getCasaWSDLModel(true);
4.120 @@ -1095,7 +1100,7 @@
4.121 "#xpointer(/definitions/service[@name='" + // NOI18N
4.122 newServiceName + "']/port[@name='" + newPortName + "'])"; // NOI18N
4.123
4.124 - return addCasaPortToModel(componentType, componentName,
4.125 + return addCasaPortToModel(componentName,
4.126 newServiceName, newPortName, portHref, null, x, y);
4.127 }
4.128
4.129 @@ -1141,7 +1146,7 @@
4.130 if (bi == null) {
4.131 return null;
4.132 }
4.133 - String componentType = bi.getBindingName();
4.134 +
4.135 String componentName = bi.getBcName();
4.136 String newServiceName = ((Service) (port.getParent())).getName();
4.137 String newPortName = port.getName();
4.138 @@ -1152,7 +1157,7 @@
4.139 String portHref = "../" + href + "#xpointer(/definitions/service[@name='" // NOI18N
4.140 + newServiceName + "']/port[@name='" + newPortName + "'])"; // NOI18N
4.141
4.142 - return addCasaPortToModel(componentType, componentName,
4.143 + return addCasaPortToModel(componentName,
4.144 newServiceName, newPortName, portHref, port, x, y);
4.145 } catch (Exception ex) {
4.146 // add failed...
4.147 @@ -1161,8 +1166,7 @@
4.148 return null;
4.149 }
4.150
4.151 - private CasaPort addCasaPortToModel(String componentType,
4.152 - String componentName,
4.153 + private CasaPort addCasaPortToModel(String componentName,
4.154 String newServiceName, String newPortName,
4.155 String portHref, Port port, int x, int y) {
4.156 CasaComponentFactory casaFactory = getFactory();
4.157 @@ -1195,7 +1199,7 @@
4.158 casaPort.setY(y);
4.159 // casaPort.setBindingState("unbound");
4.160 // casaPort.setPortType("");
4.161 - casaPort.setBindingType(componentType);
4.162 +// casaPort.setBindingType(componentType);
4.163
4.164 // 3. Add casa port link
4.165 CasaLink link = casaFactory.createCasaLink();
4.166 @@ -2403,10 +2407,13 @@
4.167 // endTransaction();
4.168 // }
4.169 // }
4.170 + CasaBindingComponentServiceUnit bcSU =
4.171 + (CasaBindingComponentServiceUnit) casaPort.getParent().getParent();
4.172 + String bcName = bcSU.getComponentName();
4.173 + String bindingType = bcName2BindingType.get(bcName);
4.174
4.175 Port port = getLinkedWSDLPort(casaPort);
4.176 - populateBindingAndPort(casaPort, port, interfaceQName,
4.177 - casaPort.getBindingType());
4.178 + populateBindingAndPort(casaPort, port, interfaceQName, bindingType);
4.179
4.180 // Cascade the change to connected endpoints.
4.181 // Since the casaport is user-created, there is no
5.1 --- a/compapp.casaeditor/src/org/netbeans/modules/compapp/casaeditor/model/casa/impl/CasaPortImpl.java Wed Mar 28 23:04:27 2007 +0000
5.2 +++ b/compapp.casaeditor/src/org/netbeans/modules/compapp/casaeditor/model/casa/impl/CasaPortImpl.java Wed Mar 28 23:41:04 2007 +0000
5.3 @@ -107,14 +107,14 @@
5.4 // public void setPortType(String portType) {
5.5 // setAttribute(PORTTYPE_PROPERTY, CasaAttribute.PORTTYPE, portType);
5.6 // }
5.7 -
5.8 - public String getBindingType() {
5.9 - return getAttribute(CasaAttribute.BINDINGTYPE);
5.10 - }
5.11 -
5.12 - public void setBindingType(String bindingType) {
5.13 - setAttribute(BINDINGTYPE_PROPERTY, CasaAttribute.BINDINGTYPE, bindingType);
5.14 - }
5.15 +//
5.16 +// public String getBindingType() {
5.17 +// return getAttribute(CasaAttribute.BINDINGTYPE);
5.18 +// }
5.19 +//
5.20 +// public void setBindingType(String bindingType) {
5.21 +// setAttribute(BINDINGTYPE_PROPERTY, CasaAttribute.BINDINGTYPE, bindingType);
5.22 +// }
5.23
5.24 // Convenience method
5.25 //
6.1 --- a/compapp.casaeditor/test/unit/src/org/netbeans/modules/compapp/casaeditor/model/casa/CasaWrapperModelTest.java Wed Mar 28 23:04:27 2007 +0000
6.2 +++ b/compapp.casaeditor/test/unit/src/org/netbeans/modules/compapp/casaeditor/model/casa/CasaWrapperModelTest.java Wed Mar 28 23:41:04 2007 +0000
6.3 @@ -102,6 +102,12 @@
6.4 ModelSource modelSource = TestCatalogModel.getDefault().createModelSource(casaFileObject, true);
6.5 casaWrapperModel = new CasaWrapperModel(modelSource);
6.6
6.7 + URI casaWSDLUri = CasaWrapperModelTest.class.getResource(
6.8 + "resources/SynchronousSampleApplication/jbiasa/casa.wsdl").toURI();
6.9 + File casaWSDLFile = new File(casaWSDLUri);
6.10 + FileObject casaWSDLFileObject = FileUtil.toFileObject(casaWSDLFile);
6.11 + ModelSource casaWSDLModelSource = TestCatalogModel.getDefault().createModelSource(casaWSDLFileObject, true);
6.12 +
6.13 componentListener = new TestComponentListener();
6.14 propertyListener = new PropertyListener();
6.15 casaWrapperModel.addComponentListener(componentListener);
6.16 @@ -256,6 +262,9 @@
6.17 System.out.println("getBindingComponentName");
6.18
6.19 CasaPort casaPort = casaWrapperModel.getCasaPorts().get(0);
6.20 + assertEquals("sun-file-binding", casaWrapperModel.getBindingComponentName(casaPort));
6.21 +
6.22 + casaPort = casaWrapperModel.getCasaPorts().get(1);
6.23 assertEquals("sun-http-binding", casaWrapperModel.getBindingComponentName(casaPort));
6.24 }
6.25
6.26 @@ -265,9 +274,15 @@
6.27 public void testSetEndpointName() {
6.28 System.out.println("setEndpointName");
6.29
6.30 + // file binding
6.31 CasaPort casaPort = casaWrapperModel.getCasaPorts().get(0);
6.32 casaWrapperModel.setEndpointName(casaPort, "FOO");
6.33 assertEquals("FOO", casaPort.getEndpointName());
6.34 +
6.35 + // http binding
6.36 + casaPort = casaWrapperModel.getCasaPorts().get(1);
6.37 + casaWrapperModel.setEndpointName(casaPort, "FOO");
6.38 + assertEquals("FOO", casaPort.getEndpointName());
6.39 }
6.40
6.41 /**
6.42 @@ -409,22 +424,6 @@
6.43 }
6.44
6.45 /**
6.46 - * Test of getDefaultBindingComponents method, of class org.netbeans.modules.compapp.casaeditor.model.casa.CasaWrapperModel.
6.47 - */
6.48 - public void testGetDefaultBindingComponents() {
6.49 - System.out.println("getDefaultBindingComponents");
6.50 -
6.51 - CasaWrapperModel instance = null;
6.52 -
6.53 - Map<String, String> expResult = null;
6.54 - Map<String, String> result = instance.getDefaultBindingComponents();
6.55 - assertEquals(expResult, result);
6.56 -
6.57 - // TODO review the generated test code and remove the default call to fail.
6.58 - fail("The test case is a prototype.");
6.59 - }
6.60 -
6.61 - /**
6.62 * Test of getCasaConnectionList method, of class org.netbeans.modules.compapp.casaeditor.model.casa.CasaWrapperModel.
6.63 */
6.64 public void testGetCasaConnectionList() {
6.65 @@ -483,14 +482,13 @@
6.66 public void testAddCasaPort() {
6.67 System.out.println("addCasaPort");
6.68
6.69 - String componentType = "";
6.70 String componentName = "";
6.71 int x = 0;
6.72 int y = 0;
6.73 CasaWrapperModel instance = null;
6.74
6.75 CasaPort expResult = null;
6.76 - CasaPort result = instance.addCasaPort(componentType, componentName, x, y);
6.77 + CasaPort result = instance.addCasaPort(componentName, x, y);
6.78 assertEquals(expResult, result);
6.79
6.80 // TODO review the generated test code and remove the default call to fail.