1 19 20 28 29 package org.netbeans.modules.xml.wsdl.ui.wizard; 30 31 import java.util.HashMap ; 32 import java.util.List ; 33 import java.util.Map ; 34 import org.netbeans.modules.xml.wsdl.model.Operation; 35 import org.netbeans.modules.xml.wsdl.model.PortType; 36 import org.netbeans.modules.xml.wsdl.model.WSDLModel; 37 import org.netbeans.modules.xml.wsdl.model.WSDLModelFactory; 38 import org.netbeans.modules.xml.wsdl.ui.view.OperationType; 39 import org.netbeans.modules.xml.wsdl.ui.view.PartAndElementOrTypeTableModel; 40 import org.netbeans.modules.xml.wsdl.ui.view.wizard.localized.LocalizedTemplate; 41 import org.netbeans.modules.xml.wsdl.ui.view.wizard.localized.LocalizedTemplateGroup; 42 import org.netbeans.modules.xml.xam.ModelSource; 43 import org.netbeans.modules.xml.xam.dom.AbstractDocumentComponent; 44 import org.openide.filesystems.FileObject; 45 import org.openide.loaders.TemplateWizard; 46 47 48 52 public class NewWSDLGenerator { 53 54 private FileObject mWsdlFile; 55 56 private TemplateWizard mTemplateWizard; 57 58 private WSDLModel mModel; 59 60 private WsdlGenerationUtil mUtil; 61 62 63 public NewWSDLGenerator(FileObject newWSDLFile, TemplateWizard templateWizard) { 64 this.mWsdlFile = newWSDLFile; 65 this.mTemplateWizard = templateWizard; 66 ModelSource modelSource = org.netbeans.modules.xml.retriever.catalog.Utilities.getModelSource(this.mWsdlFile, 67 true); 68 69 mModel = WSDLModelFactory.getDefault().getModel(modelSource); 70 this.mUtil = new WsdlGenerationUtil(this.mModel); 71 } 72 73 public void generate() { 74 75 if(mModel != null) { 76 mModel.startTransaction(); 77 78 Map configurationMap = new HashMap (); 79 80 String portTypeName = (String ) this.mTemplateWizard.getProperty(WizardPortTypeConfigurationStep.PORTTYPE_NAME); 82 String operationName = (String ) this.mTemplateWizard.getProperty(WizardPortTypeConfigurationStep.OPERATION_NAME); 83 OperationType ot = (OperationType) this.mTemplateWizard.getProperty(WizardPortTypeConfigurationStep.OPERATION_TYPE); 84 85 configurationMap.put(WizardPortTypeConfigurationStep.PORTTYPE_NAME, portTypeName); 86 configurationMap.put(WizardPortTypeConfigurationStep.OPERATION_NAME, operationName); 87 configurationMap.put(WizardPortTypeConfigurationStep.OPERATION_TYPE, ot); 88 89 List <PartAndElementOrTypeTableModel.PartAndElementOrType> inputMessageParts = 91 (List <PartAndElementOrTypeTableModel.PartAndElementOrType>) this.mTemplateWizard.getProperty(WizardPortTypeConfigurationStep.OPERATION_INPUT); 92 93 List <PartAndElementOrTypeTableModel.PartAndElementOrType> outputMessageParts = 94 (List <PartAndElementOrTypeTableModel.PartAndElementOrType>) this.mTemplateWizard.getProperty(WizardPortTypeConfigurationStep.OPERATION_OUTPUT); 95 96 List <PartAndElementOrTypeTableModel.PartAndElementOrType> faultMessageParts = 97 (List <PartAndElementOrTypeTableModel.PartAndElementOrType>) this.mTemplateWizard.getProperty(WizardPortTypeConfigurationStep.OPERATION_FAULT); 98 99 100 Map <String , String > namespaceToPrefixMap = (Map <String , String >) mTemplateWizard.getProperty(WizardPortTypeConfigurationStep.NAMESPACE_TO_PREFIX_MAP); 101 configurationMap.put(WizardPortTypeConfigurationStep.OPERATION_INPUT, inputMessageParts); 102 configurationMap.put(WizardPortTypeConfigurationStep.OPERATION_OUTPUT, outputMessageParts); 103 configurationMap.put(WizardPortTypeConfigurationStep.OPERATION_FAULT, faultMessageParts); 104 configurationMap.put(WizardPortTypeConfigurationStep.NAMESPACE_TO_PREFIX_MAP, namespaceToPrefixMap); 105 String bindingName = (String ) this.mTemplateWizard.getProperty(WizardBindingConfigurationStep.BINDING_NAME); 107 LocalizedTemplateGroup bindingType = (LocalizedTemplateGroup) this.mTemplateWizard.getProperty(WizardBindingConfigurationStep.BINDING_TYPE); 108 configurationMap.put(WizardBindingConfigurationStep.BINDING_NAME, bindingName); 109 configurationMap.put(WizardBindingConfigurationStep.BINDING_TYPE, bindingType); 110 111 LocalizedTemplate bindingSubType = (LocalizedTemplate) this.mTemplateWizard.getProperty(WizardBindingConfigurationStep.BINDING_SUBTYPE); 113 configurationMap.put(WizardBindingConfigurationStep.BINDING_SUBTYPE, bindingSubType); 114 115 String serviceName = (String ) this.mTemplateWizard.getProperty(WizardBindingConfigurationStep.SERVICE_NAME); 117 String servicePortName = (String ) this.mTemplateWizard.getProperty(WizardBindingConfigurationStep.SERVICEPORT_NAME); 118 configurationMap.put(WizardBindingConfigurationStep.SERVICE_NAME, serviceName); 119 configurationMap.put(WizardBindingConfigurationStep.SERVICEPORT_NAME, servicePortName); 120 121 if (namespaceToPrefixMap != null) { 122 for (String namespace : namespaceToPrefixMap.keySet()) { 123 ((AbstractDocumentComponent) mModel.getDefinitions()).addPrefix(namespaceToPrefixMap.get(namespace), namespace); 124 } 125 } 126 127 PortTypeGenerator ptGenerator = new PortTypeGenerator(this.mModel, configurationMap); 128 ptGenerator.execute(); 129 PortType pt = ptGenerator.getPortType(); 130 131 if(pt != null) { 132 BindingGenerator bg = new BindingGenerator(this.mModel, pt, configurationMap); 133 bg.execute(); 134 } 135 136 mModel.endTransaction(); 137 } 138 139 } 140 141 142 } 143 | Popular Tags |