KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > uddi4j > datatype > tmodel > TModel


1 /*
2  * The source code contained herein is licensed under the IBM Public License
3  * Version 1.0, which has been approved by the Open Source Initiative.
4  * Copyright (C) 2001, International Business Machines Corporation
5  * Copyright (C) 2001, Hewlett-Packard Company
6  * All Rights Reserved.
7  *
8  */

9
10 package org.uddi4j.datatype.tmodel;
11
12 import java.util.Vector JavaDoc;
13
14 import org.uddi4j.UDDIElement;
15 import org.uddi4j.UDDIException;
16 import org.uddi4j.datatype.Description;
17 import org.uddi4j.datatype.Name;
18 import org.uddi4j.datatype.OverviewDoc;
19 import org.uddi4j.util.CategoryBag;
20 import org.uddi4j.util.IdentifierBag;
21 import org.w3c.dom.Element JavaDoc;
22 import org.w3c.dom.NodeList JavaDoc;
23
24 /**
25  * Represents the tModel element within the UDDI version 2.0 schema.
26  * This class contains the following types of methods:
27  *
28  * <ul>
29  * <li>Constructor passing required fields.
30  * <li>Constructor that will instantiate the object from an appropriate XML
31  * DOM element.
32  * <li>Get/set methods for each attribute that this element can contain.
33  * <li>A get/setVector method is provided for sets of attributes.
34  * <li>SaveToXML method. Serializes this class within a passed in element.
35  * </ul>
36  *
37  * Typically, this class is used to construct parameters for, or interpret
38  * responses from, methods in the UDDIProxy class.<BR>
39  * In addition, this class contains the tModel keys for the UDDI core tModels.
40  * See <a HREF="http://www.uddi.org/taxonomies/Core_Taxonomy_OverviewDoc.htm">
41  * http://www.uddi.org/taxonomies/Core_Taxonomy_OverviewDoc.htm</a> for a
42  * complete list of these core tModels.
43  *
44  * <p><b>Element description:</b>
45  * <p>This structure defines metadata about a technology, specification
46  * or namespace qualified list (e.g., taxonomy, organizaton, etc.).
47  *
48  * @author David Melgar (dmelgar@us.ibm.com)
49  * @author Ravi Trivedi (ravi_trivedi@hp.com)
50  * @author Vivek Chopra (vivek_chopra2@non.hp.com)
51  */

52 public class TModel extends UDDIElement {
53    public static final String JavaDoc UDDI_TAG = "tModel";
54
55
56    //UDDI Core tModels - built-in taxonomies, identifier systems, and relationships
57

58    /**
59     * UDDI Type Taxonomy [uddi-org:types]<BR>
60     * This taxonomy assists in general categorization of the tModels themselves.
61     */

62    public static final String JavaDoc TYPES_TMODEL_KEY = "UUID:C1ACF26D-9672-4404-9D70-39B756E62AB4";
63
64    /**
65     * Business Taxonomy: NAICS (1997 Release) [ntis-gov:naics:1997]<BR>
66     * This tModel defines the NAICS (North American Industry Classification
67     * System) 1997 Release industry taxonomy.
68     *
69     */

70    public static final String JavaDoc NAICS_TMODEL_KEY = "UUID:C0B9FE13-179F-413D-8A5B-5004DB8E5BB2";
71
72    /**
73     * Product Taxonomy: UNSPSC (Version 3.1) [unspsc-org:unspsc:3-1]<BR>
74     * This tModel defines the UNSPSC (United Nations Standard Products and
75     * Services Code System) version 3.1 product taxonomy.
76     * <P><B>This taxonomy has been superceeded by the Universal Standard Products
77     * and Services Classification (see {@link #UNSPSC_73_TMODEL_KEY}) taxonomy.</B>
78     */

79    public static final String JavaDoc UNSPSC_TMODEL_KEY = "UUID:DB77450D-9FA8-45D4-A7BC-04411D14E384";
80
81    /**
82     * Product and Services Taxonomy:UNSPSC (Version 7.3) [unspsc-org:unspsc]<BR>
83     * This tModel defines the UNSPSC (Universal Standard Products and Services
84     * Classification) version 7.3 product and services taxonomy.
85     */

86    public static final String JavaDoc UNSPSC_73_TMODEL_KEY = "UUID:CD153257-086A-4237-B336-6BDCBDCC6634";
87
88    /**
89     * ISO 3166 Geographic Taxonomy [uddi-org:iso-ch:3166-1999]<BR>
90     * This tModel defines the ISO 3166 geographic classification taxonomy.
91     */

92    public static final String JavaDoc ISO_CH_TMODEL_KEY = "UUID:4E49A8D6-D5A2-4FC2-93A0-0411D8D19E88";
93
94    /**
95     * UDDI Other Taxonomy [uddi-org:misc-taxomony]<BR>
96     * This tModel defines an unidentified taxonomy.
97     */

98    public static final String JavaDoc GENERAL_KEYWORDS_TMODEL_KEY = "UUID:A035A07C-F362-44dd-8F95-E2B134BF43B4";
99
100    /**
101     * UDDI Owning Business [uddi-org:owningBusiness]<BR>
102     * This tModel identifies the businessEntity that published or owns the
103     * tagged information. Used with tModels to establish an 'owned'
104     * relationship with a registered businessEntity.
105     */

106    public static final String JavaDoc OWNING_BUSINESS_TMODEL_KEY = "UUID:4064C064-6D14-4F35-8953-9652106476A9";
107
108    /**
109     * UDDI businessEntity relationship [uddi-org:relationships]<BR>
110     * This tModel is used to describe business relationships. Used in the
111     * publisher assertion messages.
112     */

113    public static final String JavaDoc RELATIONSHIPS_TMODEL_KEY = "UUID:807A2C6A-EE22-470D-ADC7-E0424A337C03";
114
115    /**
116     * UDDI Operators [uddi-org:operators]<BR>
117     * This checked value set is used to identify UDDI operators.
118     */

119    public static final String JavaDoc OPERATORS_TMODEL_KEY = "UUID:327A56F0-3299-4461-BC23-5CD513E95C55";
120
121    /**
122     * D-U-N-SŪ Number Identifier System [dnb-com:D-U-N-S]<BR>
123     * This tModel is used for the Dun & Bradstreet D-U-N-SŪ Number identifier.
124     */

125    public static final String JavaDoc D_U_N_S_TMODEL_KEY = "UUID:8609C81E-EE1F-4D5A-B202-3EB13AD01823";
126
127    /**
128     * Thomas Register Supplier Identifier Code System
129     * [thomasregister-com:supplierID]<BR>
130     * This tModel is used for the Thomas Register supplier identifier codes.
131     */

132    public static final String JavaDoc THOMAS_REGISTER_TMODEL_KEY = "UUID:B1B1BAF5-2329-43E6-AE13-BA8E97195039";
133
134    /**
135     * UDDI IsReplacedBy [uddi-org:isReplacedBy]<BR>
136     * An identifier system used to point (using UDDI keys) to the tModel
137     * (or businessEntity) that is the logical replacement for the one in
138     * which isReplacedBy is used.
139     */

140    public static final String JavaDoc IS_REPLACED_BY_TMODEL_KEY = "UUID:E59AE320-77A5-11D5-B898-0004AC49CC1E";
141
142    /**
143     * Email based web service [uddi-org:smtp]<BR>
144     * This tModel is used to describe a web service that is invoked through
145     * SMTP email transmissions. These transmissions may be between people or
146     * applications.
147     */

148    public static final String JavaDoc SMTP_TMODEL_KEY = "UUID:93335D49-3EFB-48A0-ACEA-EA102B60DDC6";
149
150    /**
151     * Fax based web service [uddi-org:fax]<BR>
152     * This tModel is used to describe a web service that is invoked through
153     * fax transmissions. These transmissions may be between people or
154     * applications.
155     */

156    public static final String JavaDoc FAX_TMODEL_KEY = "UUID:1A2B00BE-6E2C-42F5-875B-56F32686E0E7";
157
158    /**
159     * FTP based web service [uddi-org:ftp]<BR>
160     * This tModel is used to describe a web service that is invoked through
161     * file transfers via the ftp protocol.
162     */

163    public static final String JavaDoc FTP_TMODEL_KEY = "UUID:5FCF5CD0-629A-4C50-8B16-F94E9CF2A674";
164
165    /**
166     * Telephone based web service [uddi-org:telephone]<BR>
167     * This tModel is used to describe a web service that is invoked through a
168     * telephone call and interaction by voice and/or touch-tone.
169     */

170    public static final String JavaDoc TELEPHONE_TMODEL_KEY = "UUID:38E12427-5536-4260-A6F9-B5B530E63A07";
171
172    /**
173     * Web browser or HTTP based web service [uddi-org:http]<BR>
174     * This tModel is used to describe a web service that is invoked through a
175     * web browser and/or the HTTP protocol.
176     */

177    public static final String JavaDoc HTTP_TMODEL_KEY = "UUID:68DE9E80-AD09-469D-8A37-088422BFBC36";
178
179    /**
180     * HTTP Web Home Page URL [uddi-org:homepage]<BR>
181     * This tModel is used as the bindingTemplate fingerprint for a web home
182     * page reference.
183     */

184    public static final String JavaDoc HOMEPAGE_TMODEL_KEY = "UUID:4CEC1CEF-1F68-4B23-8CB7-8BAA763AEB89";
185
186    protected Element base = null;
187
188    String JavaDoc tModelKey = null;
189    String JavaDoc operator = null;
190    String JavaDoc authorizedName = null;
191    Name name = null;
192    OverviewDoc overviewDoc = null;
193    IdentifierBag identifierBag = null;
194    CategoryBag categoryBag = null;
195    // Vector of Description objects
196
Vector JavaDoc description = new Vector JavaDoc();
197
198    /**
199     * Default constructor.
200     * Avoid using the default constructor for validation. It does not validate
201     * required fields. Instead, use the required fields constructor to perform
202     * validation.
203     */

204    public TModel() {
205    }
206
207    /**
208     * Construct the object with required fields.
209     *
210     * @param tModelKey String
211     * @param name String
212     */

213    public TModel(String JavaDoc tModelKey,
214             String JavaDoc name) {
215       this.tModelKey = tModelKey;
216       this.name = new Name(name);
217    }
218
219    /**
220     * Construct the object from a DOM tree. Used by
221     * UDDIProxy to construct an object from a received UDDI
222     * message.
223     *
224     * @param base Element with the name appropriate for this class.
225     *
226     * @exception UDDIException Thrown if DOM tree contains a SOAP fault
227     * or a disposition report indicating a UDDI error.
228     */

229    public TModel(Element base) throws UDDIException {
230       // Check if it is a fault. Throws an exception if it is.
231
super(base);
232       tModelKey = base.getAttribute("tModelKey");
233       operator = getAttr(base,"operator");
234       authorizedName = getAttr(base,"authorizedName");
235       NodeList JavaDoc nl = null;
236       nl = getChildElementsByTagName(base, Name.UDDI_TAG);
237       if (nl.getLength() > 0) {
238          name = new Name((Element)nl.item(0));
239          // xml:lang for Name should not be present in TModel
240
if( null != name )
241                 name.setLang(null);
242       }
243       nl = getChildElementsByTagName(base, OverviewDoc.UDDI_TAG);
244       if (nl.getLength() > 0) {
245          overviewDoc = new OverviewDoc((Element)nl.item(0));
246       }
247       nl = getChildElementsByTagName(base, IdentifierBag.UDDI_TAG);
248       if (nl.getLength() > 0) {
249          identifierBag = new IdentifierBag((Element)nl.item(0));
250       }
251       nl = getChildElementsByTagName(base, CategoryBag.UDDI_TAG);
252       if (nl.getLength() > 0) {
253          categoryBag = new CategoryBag((Element)nl.item(0));
254       }
255       nl = getChildElementsByTagName(base, Description.UDDI_TAG);
256       for (int i=0; i < nl.getLength(); i++) {
257          description.addElement(new Description((Element)nl.item(i)));
258       }
259    }
260
261    private String JavaDoc getAttr(Element base, String JavaDoc attrname)
262    {
263      if(base.getAttributeNode(attrname)!=null && base.getAttributeNode(attrname).getSpecified() )
264      {
265        return base.getAttribute(attrname);
266      }
267      return null;
268    }
269
270    public void setTModelKey(String JavaDoc s) {
271       tModelKey = s;
272    }
273
274    public void setOperator(String JavaDoc s) {
275       operator = s;
276    }
277
278    public void setAuthorizedName(String JavaDoc s) {
279       authorizedName = s;
280    }
281
282    public void setName(Name s) {
283       name = s;
284    }
285    public void setName(String JavaDoc s) {
286       name = new Name();
287       name.setText(s);
288    }
289
290    public void setOverviewDoc(OverviewDoc s) {
291       overviewDoc = s;
292    }
293
294    public void setIdentifierBag(IdentifierBag s) {
295       identifierBag = s;
296    }
297
298    public void setCategoryBag(CategoryBag s) {
299       categoryBag = s;
300    }
301
302    /**
303     * Set description vector.
304     *
305     * @param s Vector of <I>Description</I> objects.
306     */

307    public void setDescriptionVector(Vector JavaDoc s) {
308       description = s;
309    }
310
311    /**
312     * Set default (english) description string.
313     *
314     * @param s String
315     */

316    public void setDefaultDescriptionString(String JavaDoc s) {
317       if (description.size() > 0) {
318          description.setElementAt(new Description(s), 0);
319       } else {
320          description.addElement(new Description(s));
321       }
322    }
323
324    public String JavaDoc getTModelKey() {
325       return tModelKey;
326    }
327
328    public String JavaDoc getOperator() {
329       return operator;
330    }
331
332    public String JavaDoc getAuthorizedName() {
333       return authorizedName;
334    }
335
336    public Name getName() {
337       return name;
338    }
339
340    public String JavaDoc getNameString() {
341       return name.getText();
342    }
343
344    public OverviewDoc getOverviewDoc() {
345       return overviewDoc;
346    }
347
348
349    public IdentifierBag getIdentifierBag() {
350       return identifierBag;
351    }
352
353
354    public CategoryBag getCategoryBag() {
355       return categoryBag;
356    }
357
358
359    /**
360     * Get description.
361     *
362     * @return s Vector of <I>Description</I> objects.
363     */

364    public Vector JavaDoc getDescriptionVector() {
365       return description;
366    }
367
368    /**
369     * Get default description string.
370     *
371     * @return s String
372     */

373    public String JavaDoc getDefaultDescriptionString() {
374       if ((description).size() > 0) {
375          Description t = (Description)description.elementAt(0);
376          return t.getText();
377       } else {
378          return null;
379       }
380    }
381
382    /**
383     * Save an object to the DOM tree. Used to serialize an object
384     * to a DOM tree, usually to send a UDDI message.
385     *
386     * <BR>Used by UDDIProxy.
387     *
388     * @param parent Object will serialize as a child element under the
389     * passed in parent element.
390     */

391    public void saveToXML(Element parent) {
392       base = parent.getOwnerDocument().createElement(UDDI_TAG);
393       // Save attributes.
394
if (tModelKey!=null) {
395          base.setAttribute("tModelKey", tModelKey);
396       }
397       if (operator!=null) {
398          base.setAttribute("operator", operator);
399       }
400       if (authorizedName!=null) {
401          base.setAttribute("authorizedName", authorizedName);
402       }
403       if (name!=null) {
404         // xml:lang for Name should not be present in TModel
405
name.setLang(null);
406          name.saveToXML(base);
407       }
408       if (description!=null) {
409         for (int i=0; i < description.size(); i++) {
410            ((Description)(description.elementAt(i))).saveToXML(base);
411         }
412       }
413       if (overviewDoc!=null) {
414          overviewDoc.saveToXML(base);
415       }
416       if (identifierBag!=null) {
417          identifierBag.saveToXML(base);
418       }
419       if (categoryBag!=null) {
420          categoryBag.saveToXML(base);
421       }
422       parent.appendChild(base);
423    }
424 }
425
Popular Tags