|
Lines 38-45
Link Here
|
| 38 |
import org.eclipse.tptp.wsdm.tooling.util.internal.WsdlUtils; |
38 |
import org.eclipse.tptp.wsdm.tooling.util.internal.WsdlUtils; |
| 39 |
import org.eclipse.tptp.wsdm.tooling.util.internal.WsdmConstants; |
39 |
import org.eclipse.tptp.wsdm.tooling.util.internal.WsdmConstants; |
| 40 |
import org.eclipse.tptp.wsdm.tooling.util.internal.XsdUtils; |
40 |
import org.eclipse.tptp.wsdm.tooling.util.internal.XsdUtils; |
|
|
41 |
import org.eclipse.xsd.XSDComplexTypeDefinition; |
| 41 |
import org.eclipse.xsd.XSDElementDeclaration; |
42 |
import org.eclipse.xsd.XSDElementDeclaration; |
| 42 |
import org.eclipse.xsd.XSDSchema; |
43 |
import org.eclipse.xsd.XSDSchema; |
|
|
44 |
import org.eclipse.xsd.XSDTypeDefinition; |
| 43 |
import org.w3c.dom.Document; |
45 |
import org.w3c.dom.Document; |
| 44 |
import org.w3c.dom.Element; |
46 |
import org.w3c.dom.Element; |
| 45 |
|
47 |
|
|
Lines 59-65
Link Here
|
| 59 |
private IProgressMonitor _monitor; |
61 |
private IProgressMonitor _monitor; |
| 60 |
private QName WSA_ACTION_QNAME = new QName(WsdmConstants.WSA_URI, |
62 |
private QName WSA_ACTION_QNAME = new QName(WsdmConstants.WSA_URI, |
| 61 |
WsdmConstants.WSA_ACTION_NAME); |
63 |
WsdmConstants.WSA_ACTION_NAME); |
| 62 |
|
64 |
|
| 63 |
/** |
65 |
/** |
| 64 |
* Creates a new object of this class. |
66 |
* Creates a new object of this class. |
| 65 |
*/ |
67 |
*/ |
|
Lines 139-145
Link Here
|
| 139 |
newInput.setName(importedOperation.getInput().getName()); |
141 |
newInput.setName(importedOperation.getInput().getName()); |
| 140 |
|
142 |
|
| 141 |
Message importedMessage = importedOperation.getInput().getMessage(); |
143 |
Message importedMessage = importedOperation.getInput().getMessage(); |
| 142 |
Message newMessage = createNewMessage(importedMessage); |
144 |
Message newMessage = createNewMessage(importedOperation, importedMessage, true); |
| 143 |
newInput.setMessage(newMessage); |
145 |
newInput.setMessage(newMessage); |
| 144 |
_capabilityDefinition.addMessage(newMessage); |
146 |
_capabilityDefinition.addMessage(newMessage); |
| 145 |
|
147 |
|
|
Lines 166-172
Link Here
|
| 166 |
newOutput.setName(importedOperation.getOutput().getName()); |
168 |
newOutput.setName(importedOperation.getOutput().getName()); |
| 167 |
|
169 |
|
| 168 |
Message importedMessage = importedOperation.getOutput().getMessage(); |
170 |
Message importedMessage = importedOperation.getOutput().getMessage(); |
| 169 |
Message newMessage = createNewMessage(importedMessage); |
171 |
Message newMessage = createNewMessage(importedOperation, importedMessage, false); |
| 170 |
newOutput.setMessage(newMessage); |
172 |
newOutput.setMessage(newMessage); |
| 171 |
_capabilityDefinition.addMessage(newMessage); |
173 |
_capabilityDefinition.addMessage(newMessage); |
| 172 |
|
174 |
|
|
Lines 192-205
Link Here
|
| 192 |
newFault.setName(importFault.getName()); |
194 |
newFault.setName(importFault.getName()); |
| 193 |
|
195 |
|
| 194 |
Message importedMessage = importFault.getMessage(); |
196 |
Message importedMessage = importFault.getMessage(); |
| 195 |
Message newMessage = createNewMessage(importedMessage); |
197 |
Message newMessage = createNewMessage(importedOperation, importedMessage, false); |
| 196 |
newFault.setMessage(newMessage); |
198 |
newFault.setMessage(newMessage); |
| 197 |
_capabilityDefinition.addMessage(newMessage); |
199 |
_capabilityDefinition.addMessage(newMessage); |
| 198 |
} |
200 |
} |
| 199 |
} |
201 |
} |
| 200 |
} |
202 |
} |
| 201 |
|
203 |
|
| 202 |
private Message createNewMessage(Message importedMessage) |
204 |
private Message createNewMessage(Operation importedOperation, Message importedMessage, boolean isInputMessge) |
| 203 |
{ |
205 |
{ |
| 204 |
Definition definition = _capabilityDefinition.getDefinition(); |
206 |
Definition definition = _capabilityDefinition.getDefinition(); |
| 205 |
Message existingMessage = WsdlUtils.getWSDLMessage(definition,importedMessage.getQName().getLocalPart()); |
207 |
Message existingMessage = WsdlUtils.getWSDLMessage(definition,importedMessage.getQName().getLocalPart()); |
|
Lines 219-227
Link Here
|
| 219 |
String xsdNS = importedPart.getElementName().getNamespaceURI(); |
221 |
String xsdNS = importedPart.getElementName().getNamespaceURI(); |
| 220 |
String elementName = importedPart.getElementName().getLocalPart(); |
222 |
String elementName = importedPart.getElementName().getLocalPart(); |
| 221 |
XSDSchema elementSchema = _capabilityDefinition.getSchema(xsdNS); |
223 |
XSDSchema elementSchema = _capabilityDefinition.getSchema(xsdNS); |
| 222 |
XSDElementDeclaration element = XsdUtils.getXSDElementDeclarationOfName(elementSchema, elementName); |
224 |
XSDElementDeclaration element = XsdUtils.getXSDElementDeclarationOfName(elementSchema, elementName); |
| 223 |
_capabilityDefinition.createOrFindPrefix(element.getTargetNamespace(), null); |
225 |
_capabilityDefinition.createOrFindPrefix(element.getTargetNamespace(), null); |
| 224 |
part.setElementName(new QName(xsdNS, elementName)); |
226 |
|
|
|
227 |
XSDTypeDefinition typeDef = element.getType(); |
| 228 |
XSDSchema typeDefSchema = _capabilityDefinition.getSchema(typeDef.getTargetNamespace()); |
| 229 |
typeDef = getXSDTypeDefinition(typeDefSchema, typeDef.getName()); |
| 230 |
if(typeDef instanceof XSDComplexTypeDefinition) |
| 231 |
{ |
| 232 |
XSDTypeDefinition anonymousTypeDef = (XSDTypeDefinition)typeDef.cloneConcreteComponent(true, false); |
| 233 |
anonymousTypeDef.setName(null); |
| 234 |
element.setAnonymousTypeDefinition(anonymousTypeDef); |
| 235 |
} |
| 236 |
|
| 237 |
if(isInputMessge) |
| 238 |
{ |
| 239 |
// Muse 2.2 requires the XSD element name should be same as the operation name |
| 240 |
// So we change the XSD element name to the operation name |
| 241 |
// Remove this if Muse fixes it in its next release |
| 242 |
element.setName(importedOperation.getName()); |
| 243 |
} |
| 244 |
QName elementQName = new QName(xsdNS, element.getName()); |
| 245 |
part.setElementName(elementQName); |
| 225 |
} |
246 |
} |
| 226 |
else if(importedPart.getTypeName()!=null) |
247 |
else if(importedPart.getTypeName()!=null) |
| 227 |
{ |
248 |
{ |
|
Lines 251-257
Link Here
|
| 251 |
Map namespacesMap = _importDefinition.getNamespaces(); |
272 |
Map namespacesMap = _importDefinition.getNamespaces(); |
| 252 |
for(int i=0;i<schemas.length;i++) |
273 |
for(int i=0;i<schemas.length;i++) |
| 253 |
{ |
274 |
{ |
| 254 |
_capabilityDefinition.addSchema(schemas[i], namespacesMap); |
275 |
String tns = schemas[i].getAttribute("targetNamespace"); |
|
|
276 |
if(_capabilityDefinition.getSchema(tns) == null) |
| 277 |
_capabilityDefinition.addSchema(schemas[i], namespacesMap); |
| 255 |
} |
278 |
} |
| 256 |
} |
279 |
} |
|
|
280 |
|
| 281 |
private XSDTypeDefinition getXSDTypeDefinition(XSDSchema schema, String typeName) |
| 282 |
{ |
| 283 |
List types = schema.getTypeDefinitions(); |
| 284 |
for(int i=0;i<types.size();i++) |
| 285 |
{ |
| 286 |
XSDTypeDefinition typeDef = (XSDTypeDefinition) types.get(i); |
| 287 |
if(typeDef.getName().equals(typeName)) |
| 288 |
return typeDef; |
| 289 |
} |
| 290 |
return null; |
| 291 |
} |
| 257 |
} |
292 |
} |