KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > wsdl > ui > wizard > NewWSDLGenerator


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 /*
21  * NewWSDLGenerator.java
22  *
23  * Created on September 1, 2006, 3:45 PM
24  *
25  * To change this template, choose Tools | Template Manager
26  * and open the template in the editor.
27  */

28
29 package org.netbeans.modules.xml.wsdl.ui.wizard;
30
31 import java.util.HashMap JavaDoc;
32 import java.util.List JavaDoc;
33 import java.util.Map JavaDoc;
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 /**
49  *
50  * @author radval
51  */

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     /** Creates a new instance of NewWSDLGenerator */
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 JavaDoc configurationMap = new HashMap JavaDoc();
79             
80             //portType
81
String JavaDoc portTypeName = (String JavaDoc) this.mTemplateWizard.getProperty(WizardPortTypeConfigurationStep.PORTTYPE_NAME);
82             String JavaDoc operationName = (String JavaDoc) 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             //opertion type
90
List JavaDoc<PartAndElementOrTypeTableModel.PartAndElementOrType> inputMessageParts =
91                     (List JavaDoc<PartAndElementOrTypeTableModel.PartAndElementOrType>) this.mTemplateWizard.getProperty(WizardPortTypeConfigurationStep.OPERATION_INPUT);
92             
93             List JavaDoc<PartAndElementOrTypeTableModel.PartAndElementOrType> outputMessageParts =
94                     (List JavaDoc<PartAndElementOrTypeTableModel.PartAndElementOrType>) this.mTemplateWizard.getProperty(WizardPortTypeConfigurationStep.OPERATION_OUTPUT);
95             
96             List JavaDoc<PartAndElementOrTypeTableModel.PartAndElementOrType> faultMessageParts =
97                     (List JavaDoc<PartAndElementOrTypeTableModel.PartAndElementOrType>) this.mTemplateWizard.getProperty(WizardPortTypeConfigurationStep.OPERATION_FAULT);
98
99             
100             Map JavaDoc<String JavaDoc, String JavaDoc> namespaceToPrefixMap = (Map JavaDoc<String JavaDoc, String JavaDoc>) 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             //binding
106
String JavaDoc bindingName = (String JavaDoc) 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             //this could be null for a binding which does not have a sub type
112
LocalizedTemplate bindingSubType = (LocalizedTemplate) this.mTemplateWizard.getProperty(WizardBindingConfigurationStep.BINDING_SUBTYPE);
113             configurationMap.put(WizardBindingConfigurationStep.BINDING_SUBTYPE, bindingSubType);
114             
115             //service and port
116
String JavaDoc serviceName = (String JavaDoc) this.mTemplateWizard.getProperty(WizardBindingConfigurationStep.SERVICE_NAME);
117             String JavaDoc servicePortName = (String JavaDoc) 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 JavaDoc 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