KickJava   Java API By Example, From Geeks To Geeks.

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


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  * PortTypeGenerator.java
22  *
23  * Created on September 6, 2006, 4:36 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.ArrayList JavaDoc;
32 import java.util.Collection JavaDoc;
33 import java.util.List JavaDoc;
34 import java.util.Map JavaDoc;
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 JavaDoc;
45 import org.w3c.dom.Element JavaDoc;
46
47
48 /**
49  *
50  * @author radval
51  */

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 JavaDoc mConfigurationMap;
61     
62     private List JavaDoc<Message> mNewMessageList = new ArrayList JavaDoc<Message>();
63     
64     private Collection JavaDoc<Import> mImports = new ArrayList JavaDoc<Import>();
65     
66     private ExtensibilityElement mPartnerLinkTypeElement = null;
67     
68     private Comment JavaDoc mComment;
69     
70     /** Creates a new instance of PortTypeGenerator */
71     public PortTypeGenerator(WSDLModel model, Map JavaDoc 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 JavaDoc<Message> getNewMessages() {
85         return this.mNewMessageList;
86     }
87     
88     
89     public Collection JavaDoc<Import> getImports() {
90         return this.mImports;
91     }
92     public ExtensibilityElement getPartnerLinkType() {
93         return mPartnerLinkTypeElement;
94     }
95     
96     public Comment JavaDoc getComment() {
97         return this.mComment;
98     }
99     
100     public void execute() {
101         if(mModel != null) {
102             //portType
103
String JavaDoc portTypeName = (String JavaDoc) 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             //automatically generate a partnerLinkType
117
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 JavaDoc<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