001: /* Copyright (C) 2003 Finalist IT Group
002: *
003: * This file is part of JAG - the Java J2EE Application Generator
004: *
005: * JAG is free software; you can redistribute it and/or modify
006: * it under the terms of the GNU General Public License as published by
007: * the Free Software Foundation; either version 2 of the License, or
008: * (at your option) any later version.
009: * JAG is distributed in the hope that it will be useful,
010: * but WITHOUT ANY WARRANTY; without even the implied warranty of
011: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
012: * GNU General Public License for more details.
013: * You should have received a copy of the GNU General Public License
014: * along with JAG; if not, write to the Free Software
015: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
016: */
017:
018: package com.finalist.jag.uml;
019:
020: import java.util.HashMap;
021: import java.lang.reflect.Field;
022: import java.lang.reflect.Modifier;
023:
024: /**
025: *
026: * Define all UML profile elements for generating a UML model from JAG.
027: * A UML Profile uses UML Extensions like stereotypes and tagged values
028: * to add extra semantics to an UML model.
029: *
030: * @author Rudie Ekkelenkamp.
031: * @version $Revision: 1.11 $, $Date: 2005/12/24 13:35:48 $
032: * @created Octobre 23, 2003
033: *
034: */
035: public class JagUMLProfile {
036: /* Private class that will keep a hashmap with all constants defined using reflection. */
037: private static HashMap map = null;
038:
039: /* Class StereoTypes */
040:
041: /** Class stereotype: Service for for example a Session EJB */
042: public final static String STEREOTYPE_CLASS_SERVICE = "Service";
043: /** Class stereotypes: Entity */
044: public final static String STEREOTYPE_CLASS_ENTITY = "Entity";
045: /** Class stereotypes: ValueObject*/
046: public final static String STEREOTYPE_CLASS_VALUE_OBJECT = "ValueObject";
047: /** Class stereotypes: DataSource used to configure a datasource to be used with the application */
048: public final static String STEREOTYPE_CLASS_DATA_SOURCE = "DataSource";
049: /** Class stereotypes: JagConfig used to configure JAG */
050: public final static String STEREOTYPE_CLASS_JAG_CONFIG = "JagConfig";
051:
052: /* Attribute StereoTypes */
053:
054: /** Attribute stereotypes: PrimaryKey */
055: public final static String STEREOTYPE_ATTRIBUTE_PRIMARY_KEY = "PrimaryKey";
056: /** Attribute stereotypes: ForeignKey */
057: public final static String STEREOTYPE_ATTRIBUTE_FOREIGN_KEY = "ForeignKey";
058: /** Attribute stereotypes: Required field */
059: public final static String STEREOTYPE_ATTRIBUTE_REQUIRED = "Required";
060: /** Operation stereotypes: FinderMethod */
061: public final static String STEREOTYPE_OPERATION_FINDER_METHOD = "FinderMethod";
062:
063: /* Dependency StereoTypes */
064:
065: /** Dependency stereotypes: EntityRef */
066: public final static String STEREOTYPE_DEPENDENCTY_ENTITY_REF = "EntityRef";
067: /** Dependency stereotypes: ServiceRef */
068: public final static String STEREOTYPE_DEPENDENCTY_SERVICE_REF = "ServiceRef";
069: /** Dependency stereotypes: Exception */
070: public final static String STEREOTYPE_DEPENDENCTY_EXCEPTION = "Exception";
071:
072: /* Model Tagged Values */
073:
074: // Configuration part.
075: /** Determines the author of the application. */
076: public final static String TAGGED_VALUE_MODEL_AUTHOR = "author";
077: /** Determines the version of the application. */
078: public final static String TAGGED_VALUE_MODEL_VERSION = "version";
079: /** Determines the company of the application. */
080: public final static String TAGGED_VALUE_MODEL_COMPANY = "company";
081: /** Determines the template to be used. */
082: public final static String TAGGED_VALUE_MODEL_TEMPLATE = "template";
083: /** Determines the appserver to be used. */
084: public final static String TAGGED_VALUE_CONFIG_APPSERVER = "appserver";
085: /** Determines the business tier technology to be used. */
086: public final static String TAGGED_VALUE_CONFIG_BUSINESS_TIER = "business-tier";
087: /** Determines the business tier technology to be used. */
088: public final static String TAGGED_VALUE_CONFIG_SERVICE_TIER = "service-tier";
089: /** Determines the web tier technology to be used. */
090: public final static String TAGGED_VALUE_CONFIG_WEB_TIER = "web-tier";
091: /** Determines if relations should be used. */
092: public final static String TAGGED_VALUE_CONFIG_USE_RELATIONS = "use-relations";
093: /** Determines if a mock should be used. */
094: public final static String TAGGED_VALUE_CONFIG_USE_MOCK = "use-mock";
095: /** Determines if java5 should be used. */
096: public final static String TAGGED_VALUE_CONFIG_USE_JAVA5 = "use-java5";
097:
098: // Application settings part.
099:
100: /** Determines the name of the application. */
101: public final static String TAGGED_VALUE_MODEL_APPLICATION_NAME = "application-name";
102: /** Determines the description of the application. */
103: public final static String TAGGED_VALUE_MODEL_APPLICATION_VERSION = "application-version";
104: /** Determines the description of the application. */
105: public final static String TAGGED_VALUE_MODEL_DESCRIPTION = "description";
106: /** Determines the root package of the generated sources. */
107: public final static String TAGGED_VALUE_MODEL_ROOT_PACKAGE = "root-package";
108: /** Determines the description of the application. */
109: public final static String TAGGED_VALUE_MODEL_LOGGING = "logging";
110: /** Determines the date format. */
111: public final static String TAGGED_VALUE_MODEL_DATE_FORMAT = "date-format";
112: /** Determines the date format. */
113: public final static String TAGGED_VALUE_MODEL_TIMESTAMP_FORMAT = "timestamp-format";
114:
115: // Paths part.
116:
117: /** Determines the path to the service directory. */
118: public final static String TAGGED_VALUE_MODEL_SERVICE_PATH = "service-path";
119: /** Determines the path to the ejb directory. */
120: public final static String TAGGED_VALUE_MODEL_EJB_PATH = "ejb-path";
121: /** Determines the path to the web directory. */
122: public final static String TAGGED_VALUE_MODEL_WEB_PATH = "web-path";
123: /** Determines the path to the jsp directory. */
124: public final static String TAGGED_VALUE_MODEL_JSP_PATH = "jsp-path";
125: /** Determines the path to the service directory. */
126: public final static String TAGGED_VALUE_MODEL_TEST_PATH = "test-path";
127: /** Determines the path to the config directory. */
128: public final static String TAGGED_VALUE_MODEL_CONFIG_PATH = "config-path";
129: /** Determines the path to the config directory. */
130: public final static String TAGGED_VALUE_MODEL_MOCK_PATH = "mock-path";
131: /** Determines the path to the config directory. */
132: public final static String TAGGED_VALUE_MODEL_SWING_PATH = "swing-path";
133: /** Determines the path to the config directory. */
134: public final static String TAGGED_VALUE_MODEL_SPRING_PATH = "spring-path";
135: /** Determines the path to the config directory. */
136: public final static String TAGGED_VALUE_MODEL_HIBERNATE_PATH = "hibernate-path";
137:
138: /* Class Tagged Values */
139:
140: // Datasource part.
141: /** Class tagged value: DataSource JNDI name */
142: public final static String TAGGED_VALUE_CLASS_DATA_SOURCE_JNDI_NAME = "datasource-jndi-name";
143: /** Class tagged value: mapping, defines the database type: Oracle8, MySQL .. */
144: public final static String TAGGED_VALUE_CLASS_DATA_SOURCE_MAPPING = "mapping";
145: /** Class tagged value: jdbc-url, defines the connectstring to the database */
146: public final static String TAGGED_VALUE_CLASS_DATA_SOURCE_JDBC_URL = "jdbc-url";
147: /** Class tagged value: user-name, defines the user name to connect to the data source */
148: public final static String TAGGED_VALUE_CLASS_DATA_SOURCE_USER_NAME = "user-name";
149: /** Class tagged value: password, defines the password to connect to the data source */
150: public final static String TAGGED_VALUE_CLASS_DATA_SOURCE_PASSWORD = "password";
151:
152: /** Class tagged value: table-name, used for Entity to map class on a database table. */
153: public final static String TAGGED_VALUE_CLASS_TABLE_NAME = "table-name";
154: /** Class tagged value: table-name, used for Entity to map class on a database table. */
155: public final static String TAGGED_VALUE_CLASS_COMPOSITE_PRIMARY_KEY = "composite-primary-key";
156: /** Class tagged value: description. */
157: public final static String TAGGED_VALUE_CLASS_DESCRIPTION = "description";
158: /** Class tagged value: display-name . */
159: public final static String TAGGED_VALUE_CLASS_DISPLAY_NAME = "display-name";
160: /** Class tagged value: is-association. */
161: public final static String TAGGED_VALUE_CLASS_IS_ASSOCIATION = "is-association";
162:
163: /* Attribute Tagged Values */
164:
165: /** Attribute tagged value: column-name, used to map a field to a database column */
166: public final static String TAGGED_VALUE_ATTRIBUTE_COLUMN_NAME = "column-name";
167: /** Attribute tagged value: sql-type, used to map a field type to a SQL type */
168: public final static String TAGGED_VALUE_ATTRIBUTE_SQL_TYPE = "sql-type";
169: /** Attribute tagged value: jdbc-type, used to map a field type to a JDBC type */
170: public final static String TAGGED_VALUE_ATTRIBUTE_JDBC_TYPE = "jdbc-type";
171: /** Attribute tagged value: autogenerated primary key. */
172: public final static String TAGGED_VALUE_ATTRIBUTE_AUTO_PRIMARY_KEY = "auto-primary-key";
173:
174: /** Association tagged value: foreign-field */
175: public final static String TAGGED_VALUE_ASSOCIATION_FOREIGN_FIELD = "foreign-field";
176: /** Association tagged value: multiplicity */
177: public final static String TAGGED_VALUE_ASSOCIATION_MULTIPLICITY = "multiplicity";
178: public final static String TAGGED_VALUE_ASSOCIATION_MULTIPLICITY_MANY_TO_ONE = "many to one";
179: public final static String TAGGED_VALUE_ASSOCIATION_MULTIPLICITY_ONE_TO_ONE = "one to one";
180:
181: /** Association tagged value: bidirectional */
182: public final static String TAGGED_VALUE_ASSOCIATION_BIDIRECTIONAL = "bidirectional";
183:
184: /** Tagged value for all model elements: documentation */
185: public final static String TAGGED_VALUE_DOCUMENTATION = "documentation";
186:
187: /**
188: * Determines a list of all constants using reflection and put them in a hashmap.
189: *
190: * @return HashMap with the names of all constants and their String values.
191: */
192: public synchronized static HashMap getConstants() {
193: if (map != null) {
194: return map;
195: }
196: map = new HashMap();
197: Field fields[] = null;
198:
199: try {
200: fields = JagUMLProfile.class.getDeclaredFields();
201: } catch (SecurityException e) {
202: e.printStackTrace();
203: return new HashMap();
204: }
205: if (fields != null) {
206: if (fields.length != 0) {
207: for (int i = 0; i < fields.length; i++) {
208: if (Modifier.isPublic(fields[i].getModifiers())
209: && Modifier.isFinal(fields[i]
210: .getModifiers())
211: && Modifier.isStatic(fields[i]
212: .getModifiers())) {
213: // It's a constant!
214: try {
215: map.put(fields[i].getName(), fields[i]
216: .get(null));
217: } catch (Exception e) {
218: e.printStackTrace();
219: return new HashMap();
220: }
221: }
222: }
223: }
224: }
225: return map;
226: }
227: }
228:
229: /*
230: $Log: JagUMLProfile.java,v $
231: Revision 1.11 2005/12/24 13:35:48 ekkelenkamp
232: added new tagged values.
233:
234: Revision 1.10 2005/09/23 07:23:58 ekkelenkamp
235: export service tier selection
236:
237: Revision 1.9 2005/06/09 19:09:54 ekkelenkamp
238: java5 support.
239:
240: Revision 1.8 2005/02/04 08:20:43 ekkelenkamp
241: UML synchronize up-to-date.
242:
243: Revision 1.7 2005/01/19 21:44:58 ekkelenkamp
244: uml support for many-to-one relations and bidirectionality.
245:
246: Revision 1.6 2004/12/05 23:27:44 ekkelenkamp
247: Fixes for relation fields update.
248:
249: Revision 1.5 2004/11/27 19:30:07 ekkelenkamp
250: Improved UML/JAG synchronization.
251:
252: Revision 1.4 2004/11/27 07:50:04 ekkelenkamp
253: Improved UML/JAG synchronization.
254:
255: Revision 1.3 2004/11/26 22:36:13 ekkelenkamp
256: export all project settings to a Config class.
257:
258: Revision 1.2 2004/03/28 11:55:34 ekkelenkamp
259: tagged values on model
260:
261: Revision 1.1 2003/11/02 14:01:31 ekkelenkamp
262: Initial version of UML support in Jag
263:
264: */
|