KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > finalist > jag > uml > JagUMLProfile


1 /* Copyright (C) 2003 Finalist IT Group
2  *
3  * This file is part of JAG - the Java J2EE Application Generator
4  *
5  * JAG is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  * JAG is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  * You should have received a copy of the GNU General Public License
14  * along with JAG; if not, write to the Free Software
15  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16  */

17
18 package com.finalist.jag.uml;
19
20 import java.util.HashMap JavaDoc;
21 import java.lang.reflect.Field JavaDoc;
22 import java.lang.reflect.Modifier JavaDoc;
23
24 /**
25  *
26  * Define all UML profile elements for generating a UML model from JAG.
27  * A UML Profile uses UML Extensions like stereotypes and tagged values
28  * to add extra semantics to an UML model.
29  *
30  * @author Rudie Ekkelenkamp.
31  * @version $Revision: 1.11 $, $Date: 2005/12/24 13:35:48 $
32  * @created Octobre 23, 2003
33  *
34  */

35 public class JagUMLProfile {
36    /* Private class that will keep a hashmap with all constants defined using reflection. */
37    private static HashMap JavaDoc map = null;
38
39
40    /* Class StereoTypes */
41
42    /** Class stereotype: Service for for example a Session EJB */
43    public final static String JavaDoc STEREOTYPE_CLASS_SERVICE = "Service";
44    /** Class stereotypes: Entity */
45    public final static String JavaDoc STEREOTYPE_CLASS_ENTITY = "Entity";
46    /** Class stereotypes: ValueObject*/
47    public final static String JavaDoc STEREOTYPE_CLASS_VALUE_OBJECT = "ValueObject";
48    /** Class stereotypes: DataSource used to configure a datasource to be used with the application */
49    public final static String JavaDoc STEREOTYPE_CLASS_DATA_SOURCE = "DataSource";
50     /** Class stereotypes: JagConfig used to configure JAG */
51     public final static String JavaDoc STEREOTYPE_CLASS_JAG_CONFIG = "JagConfig";
52
53    /* Attribute StereoTypes */
54
55    /** Attribute stereotypes: PrimaryKey */
56    public final static String JavaDoc STEREOTYPE_ATTRIBUTE_PRIMARY_KEY = "PrimaryKey";
57    /** Attribute stereotypes: ForeignKey */
58    public final static String JavaDoc STEREOTYPE_ATTRIBUTE_FOREIGN_KEY = "ForeignKey";
59    /** Attribute stereotypes: Required field */
60    public final static String JavaDoc STEREOTYPE_ATTRIBUTE_REQUIRED = "Required";
61    /** Operation stereotypes: FinderMethod */
62    public final static String JavaDoc STEREOTYPE_OPERATION_FINDER_METHOD = "FinderMethod";
63
64    /* Dependency StereoTypes */
65
66    /** Dependency stereotypes: EntityRef */
67    public final static String JavaDoc STEREOTYPE_DEPENDENCTY_ENTITY_REF = "EntityRef";
68    /** Dependency stereotypes: ServiceRef */
69    public final static String JavaDoc STEREOTYPE_DEPENDENCTY_SERVICE_REF = "ServiceRef";
70    /** Dependency stereotypes: Exception */
71    public final static String JavaDoc STEREOTYPE_DEPENDENCTY_EXCEPTION = "Exception";
72
73
74     /* Model Tagged Values */
75
76     // Configuration part.
77

78     /** Determines the author of the application. */
79     public final static String JavaDoc TAGGED_VALUE_MODEL_AUTHOR = "author";
80     /** Determines the version of the application. */
81     public final static String JavaDoc TAGGED_VALUE_MODEL_VERSION = "version";
82     /** Determines the company of the application. */
83     public final static String JavaDoc TAGGED_VALUE_MODEL_COMPANY = "company";
84     /** Determines the template to be used. */
85     public final static String JavaDoc TAGGED_VALUE_MODEL_TEMPLATE = "template";
86     /** Determines the appserver to be used. */
87     public final static String JavaDoc TAGGED_VALUE_CONFIG_APPSERVER = "appserver";
88     /** Determines the business tier technology to be used. */
89     public final static String JavaDoc TAGGED_VALUE_CONFIG_BUSINESS_TIER = "business-tier";
90    /** Determines the business tier technology to be used. */
91    public final static String JavaDoc TAGGED_VALUE_CONFIG_SERVICE_TIER = "service-tier";
92     /** Determines the web tier technology to be used. */
93     public final static String JavaDoc TAGGED_VALUE_CONFIG_WEB_TIER = "web-tier";
94     /** Determines if relations should be used. */
95     public final static String JavaDoc TAGGED_VALUE_CONFIG_USE_RELATIONS = "use-relations";
96     /** Determines if a mock should be used. */
97     public final static String JavaDoc TAGGED_VALUE_CONFIG_USE_MOCK = "use-mock";
98     /** Determines if java5 should be used. */
99     public final static String JavaDoc TAGGED_VALUE_CONFIG_USE_JAVA5 = "use-java5";
100
101     // Application settings part.
102

103     /** Determines the name of the application. */
104     public final static String JavaDoc TAGGED_VALUE_MODEL_APPLICATION_NAME = "application-name";
105     /** Determines the description of the application. */
106     public final static String JavaDoc TAGGED_VALUE_MODEL_APPLICATION_VERSION = "application-version";
107     /** Determines the description of the application. */
108     public final static String JavaDoc TAGGED_VALUE_MODEL_DESCRIPTION = "description";
109     /** Determines the root package of the generated sources. */
110     public final static String JavaDoc TAGGED_VALUE_MODEL_ROOT_PACKAGE = "root-package";
111     /** Determines the description of the application. */
112     public final static String JavaDoc TAGGED_VALUE_MODEL_LOGGING = "logging";
113     /** Determines the date format. */
114     public final static String JavaDoc TAGGED_VALUE_MODEL_DATE_FORMAT = "date-format";
115     /** Determines the date format. */
116     public final static String JavaDoc TAGGED_VALUE_MODEL_TIMESTAMP_FORMAT = "timestamp-format";
117
118     // Paths part.
119

120     /** Determines the path to the service directory. */
121     public final static String JavaDoc TAGGED_VALUE_MODEL_SERVICE_PATH = "service-path";
122     /** Determines the path to the ejb directory. */
123     public final static String JavaDoc TAGGED_VALUE_MODEL_EJB_PATH = "ejb-path";
124     /** Determines the path to the web directory. */
125     public final static String JavaDoc TAGGED_VALUE_MODEL_WEB_PATH = "web-path";
126     /** Determines the path to the jsp directory. */
127     public final static String JavaDoc TAGGED_VALUE_MODEL_JSP_PATH = "jsp-path";
128     /** Determines the path to the service directory. */
129     public final static String JavaDoc TAGGED_VALUE_MODEL_TEST_PATH = "test-path";
130     /** Determines the path to the config directory. */
131     public final static String JavaDoc TAGGED_VALUE_MODEL_CONFIG_PATH = "config-path";
132    /** Determines the path to the config directory. */
133    public final static String JavaDoc TAGGED_VALUE_MODEL_MOCK_PATH = "mock-path";
134    /** Determines the path to the config directory. */
135    public final static String JavaDoc TAGGED_VALUE_MODEL_SWING_PATH = "swing-path";
136    /** Determines the path to the config directory. */
137    public final static String JavaDoc TAGGED_VALUE_MODEL_SPRING_PATH = "spring-path";
138    /** Determines the path to the config directory. */
139    public final static String JavaDoc TAGGED_VALUE_MODEL_HIBERNATE_PATH = "hibernate-path";
140
141
142
143
144    /* Class Tagged Values */
145
146     // Datasource part.
147

148     /** Class tagged value: DataSource JNDI name */
149     public final static String JavaDoc TAGGED_VALUE_CLASS_DATA_SOURCE_JNDI_NAME = "datasource-jndi-name";
150    /** Class tagged value: mapping, defines the database type: Oracle8, MySQL .. */
151    public final static String JavaDoc TAGGED_VALUE_CLASS_DATA_SOURCE_MAPPING = "mapping";
152    /** Class tagged value: jdbc-url, defines the connectstring to the database */
153    public final static String JavaDoc TAGGED_VALUE_CLASS_DATA_SOURCE_JDBC_URL = "jdbc-url";
154    /** Class tagged value: user-name, defines the user name to connect to the data source */
155    public final static String JavaDoc TAGGED_VALUE_CLASS_DATA_SOURCE_USER_NAME = "user-name";
156    /** Class tagged value: password, defines the password to connect to the data source */
157    public final static String JavaDoc TAGGED_VALUE_CLASS_DATA_SOURCE_PASSWORD = "password";
158
159     /** Class tagged value: table-name, used for Entity to map class on a database table. */
160     public final static String JavaDoc TAGGED_VALUE_CLASS_TABLE_NAME = "table-name";
161    /** Class tagged value: table-name, used for Entity to map class on a database table. */
162    public final static String JavaDoc TAGGED_VALUE_CLASS_COMPOSITE_PRIMARY_KEY = "composite-primary-key";
163    /** Class tagged value: description. */
164    public final static String JavaDoc TAGGED_VALUE_CLASS_DESCRIPTION = "description";
165    /** Class tagged value: display-name . */
166    public final static String JavaDoc TAGGED_VALUE_CLASS_DISPLAY_NAME = "display-name";
167    /** Class tagged value: is-association. */
168    public final static String JavaDoc TAGGED_VALUE_CLASS_IS_ASSOCIATION = "is-association";
169
170    /* Attribute Tagged Values */
171
172    /** Attribute tagged value: column-name, used to map a field to a database column */
173    public final static String JavaDoc TAGGED_VALUE_ATTRIBUTE_COLUMN_NAME = "column-name";
174    /** Attribute tagged value: sql-type, used to map a field type to a SQL type */
175    public final static String JavaDoc TAGGED_VALUE_ATTRIBUTE_SQL_TYPE = "sql-type";
176    /** Attribute tagged value: jdbc-type, used to map a field type to a JDBC type */
177    public final static String JavaDoc TAGGED_VALUE_ATTRIBUTE_JDBC_TYPE = "jdbc-type";
178     /** Attribute tagged value: autogenerated primary key. */
179     public final static String JavaDoc TAGGED_VALUE_ATTRIBUTE_AUTO_PRIMARY_KEY = "auto-primary-key";
180
181    /** Association tagged value: foreign-field */
182    public final static String JavaDoc TAGGED_VALUE_ASSOCIATION_FOREIGN_FIELD = "foreign-field";
183    /** Association tagged value: multiplicity */
184    public final static String JavaDoc TAGGED_VALUE_ASSOCIATION_MULTIPLICITY = "multiplicity";
185    public final static String JavaDoc TAGGED_VALUE_ASSOCIATION_MULTIPLICITY_MANY_TO_ONE = "many to one";
186    public final static String JavaDoc TAGGED_VALUE_ASSOCIATION_MULTIPLICITY_ONE_TO_ONE = "one to one";
187
188    /** Association tagged value: bidirectional */
189    public final static String JavaDoc TAGGED_VALUE_ASSOCIATION_BIDIRECTIONAL = "bidirectional";
190
191
192    /** Tagged value for all model elements: documentation */
193    public final static String JavaDoc TAGGED_VALUE_DOCUMENTATION = "documentation";
194
195    /**
196     * Determines a list of all constants using reflection and put them in a hashmap.
197     *
198     * @return HashMap with the names of all constants and their String values.
199     */

200    public synchronized static HashMap JavaDoc getConstants() {
201       if (map != null) {
202          return map;
203       }
204       map = new HashMap JavaDoc();
205       Field JavaDoc fields[] = null;
206
207       try {
208          fields = JagUMLProfile.class.getDeclaredFields();
209       }
210       catch (SecurityException JavaDoc e) {
211          e.printStackTrace();
212          return new HashMap JavaDoc();
213       }
214       if (fields != null) {
215          if (fields.length != 0) {
216             for (int i = 0; i < fields.length; i++) {
217                if (Modifier.isPublic(fields[i].getModifiers())
218                   && Modifier.isFinal(fields[i].getModifiers())
219                   && Modifier.isStatic(fields[i].getModifiers())
220                ) {
221                   // It's a constant!
222
try {
223                      map.put(fields[i].getName(), fields[i].get(null));
224                   }
225                   catch (Exception JavaDoc e) {
226                      e.printStackTrace();
227                      return new HashMap JavaDoc();
228                   }
229                }
230             }
231          }
232       }
233       return map;
234    }
235 }
236
237 /*
238         $Log: JagUMLProfile.java,v $
239         Revision 1.11 2005/12/24 13:35:48 ekkelenkamp
240         added new tagged values.
241
242         Revision 1.10 2005/09/23 07:23:58 ekkelenkamp
243         export service tier selection
244
245         Revision 1.9 2005/06/09 19:09:54 ekkelenkamp
246         java5 support.
247
248         Revision 1.8 2005/02/04 08:20:43 ekkelenkamp
249         UML synchronize up-to-date.
250
251         Revision 1.7 2005/01/19 21:44:58 ekkelenkamp
252         uml support for many-to-one relations and bidirectionality.
253
254         Revision 1.6 2004/12/05 23:27:44 ekkelenkamp
255         Fixes for relation fields update.
256
257         Revision 1.5 2004/11/27 19:30:07 ekkelenkamp
258         Improved UML/JAG synchronization.
259
260         Revision 1.4 2004/11/27 07:50:04 ekkelenkamp
261         Improved UML/JAG synchronization.
262
263         Revision 1.3 2004/11/26 22:36:13 ekkelenkamp
264         export all project settings to a Config class.
265
266         Revision 1.2 2004/03/28 11:55:34 ekkelenkamp
267         tagged values on model
268
269         Revision 1.1 2003/11/02 14:01:31 ekkelenkamp
270         Initial version of UML support in Jag
271
272 */
Popular Tags