View Javadoc

1   /*
2    * UML2MMBase module.
3    *
4    * The contents of this file are subject to the Mozilla Public License
5    * Version 1.0 (the "License"); you may not use this file except in
6    * compliance with the License. You may obtain a copy of the License at
7    * http://www.mozilla.org/MPL/
8    *
9    * Software distributed under the License is distributed on an "AS IS"
10   * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
11   * License for the specific language governing rights and limitations
12   * under the License.
13   */
14  
15  package com.finalist.mmbase.umlprofile;
16  
17  import java.util.HashMap;
18  import java.lang.reflect.Field;
19  import java.lang.reflect.Modifier;
20  
21  /***
22   *
23   * Define all UML profile elements.
24   * A UML Profile uses UML Extensions like stereotypes and tagged values
25   * to add extra semantics to an UML model.
26   *
27   * Copyright 2003 Finalist IT-Group -- all rights reserved
28   *
29   * @author Rudie Ekkelenkamp.
30   * @version $Revision: 1.6 $, $Date: 2004/12/08 23:27:33 $
31   * @created Jul 15, 2003
32   *
33   *
34   */
35  public class MMBaseUMLProfile {
36     /* Private class that will keep a hashmap with all constants defined using reflection. */
37     private static HashMap map = null;
38  
39      /*** Package stereotypes: MMBasePackage */
40      public final static String STEREOTYPE_PACKAGE_MMBASE_PACKAGE = "MMBasePackage";
41  
42     /*** Class stereotypes: MMBase */
43     public final static String STEREOTYPE_CLASS_MMBASE = "MMBase";
44     /*** Class stereotypes: Relation */
45     public final static String STEREOTYPE_CLASS_RELATION = "Relation";
46      /*** Class stereotypes: Relation */
47      public final static String STEREOTYPE_CLASS_RELDEF = "RelDef";
48     /*** The stereotype of an optionlist */
49     public final static String STEREOTYPE_CLASS_OPTIONLIST = "OptionList";
50  
51     /*** Attribute stereotypes: required */
52     public final static String STEREOTYPE_ATTRIBUTE_REQUIRED = "required";
53  
54     /*** Dependencty stereotypes: required */
55     public final static String STEREOTYPE_DEPENDENCTY_REQUIRED = "required";
56  
57     /*** Class tagged values: title*/
58     public final static String TAGGED_VALUE_CLASS_TITLE = "title";
59     /*** Class tagged values: subtitle*/
60     public final static String TAGGED_VALUE_CLASS_SUBTITLE = "subtitle";
61     /*** Class tagged values: builder version */
62     public final static String TAGGED_VALUE_CLASS_VERSION = "version";
63     
64     /*** Attribute tagged values: minsize */
65     public final static String TAGGED_VALUE_ATTRIBUTE_MINSIZE = "minsize";
66     /*** Attribute tagged values: maxsize */
67     public final static String TAGGED_VALUE_ATTRIBUTE_MAXSIZE = "maxsize";
68     /*** Attribute tagged value: prompt */
69     public final static String TAGGED_VALUE_ATTRIBUTE_PROMPT = "prompt";
70     /*** Attribute tagged value: system */
71     public final static String TAGGED_VALUE_ATTRIBUTE_SYSTEM = "system";
72  
73     /* Dependency tagged values */
74  
75     /* General tagged value */
76  
77     /*** Documentation tagged value used on all model elements. */
78     public final static String TAGGED_VALUE_DOCUMENTATION = "documentation";
79  
80     /*** Type of a relation if no other type was specified in the model. */
81     public final static String DEFAULT_RELATION_TYPE = "related";
82     /*** Direction of a relation if this was nog specified in the model. */
83     public final static String DEFAULT_RELATION_DIRECTION = "bidirectional";
84  
85     /*** Standard relationbuilder if the name was not specified. */
86     public final static String DEFAULT_RELATION_BUILDER = "insrel";
87     /*** Standard objectbuilder for extending specified. */
88     public final static String DEFAULT_OBJECT_BUILDER = "object";
89  
90     /*** Standard builder images  */
91     public final static String BASIC_IMAGES_BUILDER = "images";
92     /*** Standard builder attachments  */
93     public final static String BASIC_ATTACHMENTS_BUILDER = "attachments";
94     /*** Standard builder urls  */
95     public final static String BASIC_URLS_BUILDER = "urls";
96  
97     /*** Standard relationbuilder  */
98     public final static String BASIC_INSREL_RELATION_BUILDER = "insrel";
99     /*** Standard relationbuilder  */
100    public final static String BASIC_POSREL_RELATION_BUILDER = "posrel";
101 
102    /*** MMBase string type */
103    public static final String MMBASE_STRING_TYPE = "string";
104    /*** MMBase int type */
105    public static final String MMBASE_INT_TYPE = "int";
106    /*** MMBase html type */
107    public static final String MMBASE_HTML_TYPE = "html";
108    /*** MMBase byte type */
109    public static final String MMBASE_BYTE_TYPE = "byte";
110    /*** MMBase date type */
111    public static final String MMBASE_DATE_TYPE = "date";
112    /*** MMBase boolean type */
113    public static final String MMBASE_BOOLEAN_TYPE = "boolean";
114    /*** MMBase eventtime type */
115    public static final String MMBASE_EVENTTIME_TYPE = "eventtime";
116    /*** MMBase field type */
117    public static final String MMBASE_FIELD_TYPE = "field";
118    /*** MMBase integer type */
119    public static final String MMBASE_INTEGER_TYPE = "integer";
120    /*** MMBase long type */
121    public static final String MMBASE_LONG_TYPE = "long";
122    /*** MMBase float type */
123    public static final String MMBASE_FLOAT_TYPE = "float";
124    /*** MMBase float type */
125    public static final String MMBASE_DOUBLE_TYPE = "double";
126    /*** MMBase newfile type */
127    public static final String MMBASE_NEWFILE_TYPE = "newfile";
128    /*** MMBase newimage type */
129    public static final String MMBASE_NEWIMAGE_TYPE = "newimage";
130 
131    /*** MMBase optionListType */
132    public static final String MMBASE_OPTIONLIST_TYPE = "string";
133    /*** MMBase posrel type */
134    public static final String POSREL_RELATION_BUILDER = "posrel";
135    /*** MMBase insrel type */
136    public static final String INSREL_RELATION_BUILDER = "insrel";
137 
138    /*** MMBase dutch language definition type */
139    public static final String DUTCH_LANGUAGE_ID = "nl";
140    /*** MMBase english language definition type */
141    public static final String ENGLISH_LANGUAGE_ID = "en";
142 
143    /*** Defines for which size a gui field will be rendered as a text field. */
144    public static final int MAX_SIZE_TEXT_FIELD = 40;
145 
146    /*** Attributes in the model should be protected or public to be visible in search fields. */
147    public final static String EDIT_WIZARD_SEARCH_VISIBILITY = "protected";
148    /*** Attributes in the model should be public to be visible in search fields of the web interface. */
149    public final static String WEB_SEARCH_VISBILITY = "public";
150 
151 
152    /***
153     * Determines a list of all constants using reflection and put them in a hashmap.
154     *
155     * @return HashMap with the names of all constants and their String values.
156     */
157    public synchronized static HashMap getConstants() {
158       if (map != null) {
159          return map;
160       }
161       map = new HashMap();
162       Field fields[] = null;
163 
164       try {
165          fields = MMBaseUMLProfile.class.getDeclaredFields();
166       }
167       catch (SecurityException e) {
168          e.printStackTrace();
169          return new HashMap();
170       }
171       if (fields != null) {
172          if (fields.length != 0) {
173             for (int i = 0; i < fields.length; i++) {
174                if (Modifier.isPublic(fields[i].getModifiers())
175                   && Modifier.isFinal(fields[i].getModifiers())
176                   && Modifier.isStatic(fields[i].getModifiers())
177                ) {
178                   // It's a constant!
179                   try {
180                      map.put(fields[i].getName(), fields[i].get(null));
181                   }
182                   catch (Exception e) {
183                      e.printStackTrace();
184                      return new HashMap();
185                   }
186                }
187             }
188          }
189       }
190       return map;
191    }
192 }