View Javadoc

1   /* (c) Copyright 2003 Caleigo AB, All rights reserved. 
2    * 
3    * This library is free software; you can redistribute it and/or
4    * modify it under the terms of the GNU Lesser General Public
5    * License as published by the Free Software Foundation; either
6    * version 2.1 of the License, or (at your option) any later version.
7    * 
8    * This library is distributed in the hope that it will be useful,
9    * but WITHOUT ANY WARRANTY; without even the implied warranty of
10   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11   * Lesser General Public License for more details.
12   * 
13   * You should have received a copy of the GNU Lesser General Public
14   * License along with this library; if not, write to the Free Software
15   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16   *  
17   */
18  package org.caleigo.core.meta;
19  
20  import org.caleigo.core.*;
21  
22  /*** Meta is the descriptor for MetaDataSourceDescriptor
23   * instances.
24   *
25   * @author dennis
26   * @version 1.0
27   *//*
28   * WHEN    WHO                WHY & WHAT 
29   * ------------------------------------------------------------------------------
30   * 030627  dennis   Creation
31   */
32  public class Meta extends AbstractDataSourceDescriptor 
33  {
34      // Static data members -----------------------------------------------------
35      public final static Meta instance;
36      
37      // Static methods ----------------------------------------------------------
38      static
39      {
40          Object[] entityList = new Object[8];
41          
42          entityList[0] = "org.caleigo.core.meta.MetaDataSourceDescriptor";
43          entityList[1] = "org.caleigo.core.meta.MetaDataType";
44          entityList[2] = "org.caleigo.core.meta.MetaEntityDescriptor";
45          entityList[3] = "org.caleigo.core.meta.MetaEntityRelation";
46          entityList[4] = "org.caleigo.core.meta.MetaEntityType";
47          entityList[5] = "org.caleigo.core.meta.MetaFieldDescriptor";
48          entityList[6] = "org.caleigo.core.meta.MetaFieldRelation";
49          entityList[7] = "org.caleigo.core.meta.MetaSizeType";
50          
51          instance = new Meta(entityList);
52      }
53      
54      // Constructors ------------------------------------------------------------
55      
56      /*** Creates new DataSourceDescriptor
57       */
58      private Meta(Object[] entityList) 
59      {
60          super("Meta", "Meta", "Meta", "1.0", false, entityList);
61      }
62      
63      // Action methods ----------------------------------------------------------
64  
65      public void createMetaEntities()
66      {
67          if (this.getDefaultDataService() != null)
68          {
69              if (this.getDefaultDataService() instanceof AbstractDataService)
70                  ((AbstractDataService) this.getDefaultDataService()).setValidating(false);
71              
72              MetaDataTypeEntity dataTypeEntity = MetaDataType.create();
73              dataTypeEntity.setID(0);
74              dataTypeEntity.setName("UNKNOWN");
75              dataTypeEntity.setDataType("Object");
76              dataTypeEntity.setObjectType("");
77              dataTypeEntity.setDataTypeClass("Object");
78              dataTypeEntity.setObjectTypeClass(DataType.UNKNOWN.getDataClass().getName());
79              dataTypeEntity.store();
80              
81              dataTypeEntity = MetaDataType.create();
82              dataTypeEntity.setID(1);
83              dataTypeEntity.setName("STRING");
84              dataTypeEntity.setDataType("String");
85              dataTypeEntity.setObjectType("String");
86              dataTypeEntity.setDataTypeClass("String");
87              dataTypeEntity.setObjectTypeClass(DataType.STRING.getDataClass().getName());
88              dataTypeEntity.store();
89              
90              dataTypeEntity = MetaDataType.create();
91              dataTypeEntity.setID(2);
92              dataTypeEntity.setName("BYTE");
93              dataTypeEntity.setDataType("byte");
94              dataTypeEntity.setObjectType("Byte");
95              dataTypeEntity.setDataTypeClass("byte");
96              dataTypeEntity.setObjectTypeClass(DataType.BYTE.getDataClass().getName());
97              dataTypeEntity.store();
98              
99              dataTypeEntity = MetaDataType.create();
100             dataTypeEntity.setID(3);
101             dataTypeEntity.setName("SHORT");
102             dataTypeEntity.setDataType("short");
103             dataTypeEntity.setObjectType("Short");
104             dataTypeEntity.setDataTypeClass("short");
105             dataTypeEntity.setObjectTypeClass(DataType.SHORT.getDataClass().getName());
106             dataTypeEntity.store();
107             
108             dataTypeEntity = MetaDataType.create();
109             dataTypeEntity.setID(4);
110             dataTypeEntity.setName("INTEGER");
111             dataTypeEntity.setDataType("int");
112             dataTypeEntity.setObjectType("Integer");
113             dataTypeEntity.setDataTypeClass("int");
114             dataTypeEntity.setObjectTypeClass(DataType.INTEGER.getDataClass().getName());
115             dataTypeEntity.store();
116             
117             dataTypeEntity = MetaDataType.create();
118             dataTypeEntity.setID(5);
119             dataTypeEntity.setName("LONG");
120             dataTypeEntity.setDataType("long");
121             dataTypeEntity.setObjectType("Long");
122             dataTypeEntity.setDataTypeClass("long");
123             dataTypeEntity.setObjectTypeClass(DataType.LONG.getDataClass().getName());
124             dataTypeEntity.store();
125             
126             dataTypeEntity = MetaDataType.create();
127             dataTypeEntity.setID(6);
128             dataTypeEntity.setName("FLOAT");
129             dataTypeEntity.setDataType("float");
130             dataTypeEntity.setObjectType("Float");
131             dataTypeEntity.setDataTypeClass("float");
132             dataTypeEntity.setObjectTypeClass(DataType.FLOAT.getDataClass().getName());
133             dataTypeEntity.store();
134             
135             dataTypeEntity = MetaDataType.create();
136             dataTypeEntity.setID(7);
137             dataTypeEntity.setName("DOUBLE");
138             dataTypeEntity.setDataType("double");
139             dataTypeEntity.setObjectType("Double");
140             dataTypeEntity.setDataTypeClass("double");
141             dataTypeEntity.setObjectTypeClass(DataType.DOUBLE.getDataClass().getName());
142             dataTypeEntity.store();
143             
144             dataTypeEntity = MetaDataType.create();
145             dataTypeEntity.setID(8);
146             dataTypeEntity.setName("BOOLEAN");
147             dataTypeEntity.setDataType("boolean");
148             dataTypeEntity.setObjectType("Boolean");
149             dataTypeEntity.setDataTypeClass("boolean");
150             dataTypeEntity.setObjectTypeClass(DataType.BOOLEAN.getDataClass().getName());
151             dataTypeEntity.store();
152             
153             dataTypeEntity = MetaDataType.create();
154             dataTypeEntity.setID(9);
155             dataTypeEntity.setName("DATE");
156             dataTypeEntity.setDataType(DataType.DATE.getDataClass().getName());
157             dataTypeEntity.setObjectType(DataType.DATE.getDataClass().getName());
158             dataTypeEntity.setDataTypeClass(DataType.DATE.getDataClass().getName());
159             dataTypeEntity.setObjectTypeClass(DataType.DATE.getDataClass().getName());
160             dataTypeEntity.store();
161             
162             dataTypeEntity = MetaDataType.create();
163             dataTypeEntity.setID(10);
164             dataTypeEntity.setName("BIG_DECIMAL");
165             dataTypeEntity.setDataType(DataType.BIG_DECIMAL.getDataClass().getName());
166             dataTypeEntity.setObjectType(DataType.BIG_DECIMAL.getDataClass().getName());
167             dataTypeEntity.setDataTypeClass(DataType.BIG_DECIMAL.getDataClass().getName());
168             dataTypeEntity.setObjectTypeClass(DataType.BIG_DECIMAL.getDataClass().getName());
169             dataTypeEntity.store();
170             
171             dataTypeEntity = MetaDataType.create();
172             dataTypeEntity.setID(11);
173             dataTypeEntity.setName("IMAGE");
174             dataTypeEntity.setDataType("byte[]");
175             dataTypeEntity.setObjectType("byte[]");
176             dataTypeEntity.setDataTypeClass("byte[]");
177             dataTypeEntity.setObjectTypeClass(DataType.IMAGE.getDataClass().getName());
178             dataTypeEntity.store();
179             
180             MetaEntityTypeEntity entityTypeEntity = MetaEntityType.create();
181             entityTypeEntity.setID(IEntityDescriptor.MASTER_ENTITY);
182             entityTypeEntity.setName("MASTER");
183             entityTypeEntity.setHint("Central entity for wich a seperate work view should be created.");
184             entityTypeEntity.store();
185             entityTypeEntity = MetaEntityType.create();
186             entityTypeEntity.setID(IEntityDescriptor.SLAVE_ENTITY); 
187             entityTypeEntity.setName("SLAVE");
188             entityTypeEntity.setHint("Entity that is always displayed as a slave to another entity.");
189             entityTypeEntity.store();
190             entityTypeEntity = MetaEntityType.create();
191             entityTypeEntity.setID(IEntityDescriptor.LINK_ENTITY);
192             entityTypeEntity.setName("LINK");
193             entityTypeEntity.setHint("Entity whose only purpose is to link other entities together in N to N relationships.");
194             entityTypeEntity.store();
195             entityTypeEntity = MetaEntityType.create();
196             entityTypeEntity.setID(IEntityDescriptor.STATIC_ENTITY);
197             entityTypeEntity.setName("STATIC");
198             entityTypeEntity.setHint("Entity used to store system constants that rarely or never change.");
199             entityTypeEntity.store();
200             entityTypeEntity = MetaEntityType.create();
201             entityTypeEntity.setID(IEntityDescriptor.CUSTOM_ENTITY);
202             entityTypeEntity.setName("CUSTOM");
203             entityTypeEntity.setHint("Custom entities are made hidden and left for manual handling.");
204             entityTypeEntity.store();
205             
206             MetaSizeTypeEntity sizeTypeEntity = MetaSizeType.create();
207             sizeTypeEntity.setID(0);
208             sizeTypeEntity.setName("HUGE");
209             sizeTypeEntity.setHint("Predicted size is huge and table scan should avoided.");
210             sizeTypeEntity.store();
211             sizeTypeEntity = MetaSizeType.create();
212             sizeTypeEntity.setID(AbstractEntityDescriptor.SELECTABLE);
213             sizeTypeEntity.setName("SELECTABLE");
214             sizeTypeEntity.setHint("Predicted Size is very small (<20), comboboxes can be used for references.");
215             sizeTypeEntity.store();
216             sizeTypeEntity = MetaSizeType.create();
217             sizeTypeEntity.setID(AbstractEntityDescriptor.LISTABLE);
218             sizeTypeEntity.setName("LISTABLE");
219             sizeTypeEntity.setHint("Size (<200) makes it meaningfull to display ALL existing entities for the end-user.");
220             sizeTypeEntity.store();
221             sizeTypeEntity = MetaSizeType.create();
222             sizeTypeEntity.setID(AbstractEntityDescriptor.CACHEABLE);
223             sizeTypeEntity.setName("CACHEABLE");
224             sizeTypeEntity.setHint("Size and structure (<1000) makes it acceptable to cache entire table on clients.");
225             sizeTypeEntity.store();
226             sizeTypeEntity = MetaSizeType.create();
227             sizeTypeEntity.setID(AbstractEntityDescriptor.SCANABLE);
228             sizeTypeEntity.setName("SCANABLE");
229             sizeTypeEntity.setHint("Size and structure (<100.000) makes it acceptable to perform table scans on table.");
230             sizeTypeEntity.store();
231             
232             if (this.getDefaultDataService() instanceof AbstractDataService)
233                 ((AbstractDataService) this.getDefaultDataService()).setValidating(true);
234         }
235     }
236 
237 }