1 19 20 28 29 package org.netbeans.modules.xml.wsdl.ui.wizard; 30 31 import java.util.ArrayList ; 32 import java.util.Collection ; 33 import java.util.List ; 34 import java.util.Map ; 35 import org.netbeans.modules.xml.schema.model.Import; 36 import org.netbeans.modules.xml.wsdl.model.ExtensibilityElement; 37 import org.netbeans.modules.xml.wsdl.model.Message; 38 import org.netbeans.modules.xml.wsdl.model.Operation; 39 import org.netbeans.modules.xml.wsdl.model.PortType; 40 import org.netbeans.modules.xml.wsdl.model.WSDLComponent; 41 import org.netbeans.modules.xml.wsdl.model.WSDLModel; 42 import org.netbeans.modules.xml.xam.dom.AbstractDocumentComponent; 43 import org.openide.util.NbBundle; 44 import org.w3c.dom.Comment ; 45 import org.w3c.dom.Element ; 46 47 48 52 public class PortTypeGenerator implements Command { 53 54 private WSDLModel mModel; 55 56 private PortType mPortType; 57 58 private Operation mOperation; 59 60 private Map mConfigurationMap; 61 62 private List <Message> mNewMessageList = new ArrayList <Message>(); 63 64 private Collection <Import> mImports = new ArrayList <Import>(); 65 66 private ExtensibilityElement mPartnerLinkTypeElement = null; 67 68 private Comment mComment; 69 70 71 public PortTypeGenerator(WSDLModel model, Map configurationMap) { 72 this.mModel = model; 73 this.mConfigurationMap = configurationMap; 74 } 75 76 public PortType getPortType() { 77 return this.mPortType; 78 } 79 80 public Operation getOperation() { 81 return this.mOperation; 82 } 83 84 public List <Message> getNewMessages() { 85 return this.mNewMessageList; 86 } 87 88 89 public Collection <Import> getImports() { 90 return this.mImports; 91 } 92 public ExtensibilityElement getPartnerLinkType() { 93 return mPartnerLinkTypeElement; 94 } 95 96 public Comment getComment() { 97 return this.mComment; 98 } 99 100 public void execute() { 101 if(mModel != null) { 102 String portTypeName = (String ) this.mConfigurationMap.get(WizardPortTypeConfigurationStep.PORTTYPE_NAME); 104 if (portTypeName == null) return; 105 106 this.mPortType = mModel.getFactory().createPortType(); 107 this.mPortType.setName(portTypeName); 108 mModel.getDefinitions().addPortType(this.mPortType); 109 110 OperationGenerator og = new OperationGenerator(this.mModel, this.mPortType, this.mConfigurationMap); 111 og.execute(); 112 this.mOperation = og.getOperation(); 113 this.mNewMessageList = og.getNewMessages(); 114 mImports.addAll(og.getImports()); 115 116 PartnerLinkTypeGenerator pltGen = new PartnerLinkTypeGenerator(this.mPortType, this.mModel); 118 pltGen.execute(); 119 mPartnerLinkTypeElement = pltGen.getPartnerLinkType(); 120 if(mPartnerLinkTypeElement != null) { 121 this.mModel.getDefinitions().addExtensibilityElement(mPartnerLinkTypeElement); 122 List <WSDLComponent> children = mPartnerLinkTypeElement.getChildren(); 123 if(children != null && children.size() > 0) { 124 WSDLComponent role = children.get(0); 125 Element pltElement = mPartnerLinkTypeElement.getPeer(); 126 Element roleElement = role.getPeer(); 127 this.mComment = this.mModel.getAccess().getDocumentRoot().createComment(NbBundle.getMessage(PortTypeGenerator.class, "LBL_partnerLinkType_comment")); 128 this.mModel.getAccess().insertBefore(pltElement, this.mComment, roleElement, (AbstractDocumentComponent) this.mPartnerLinkTypeElement); 129 } 130 } 131 } 132 } 133 } 134 | Popular Tags |