KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > caucho > amber > cfg > EntityMappingsConfig


1 /*
2  * Copyright (c) 1998-2006 Caucho Technology -- all rights reserved
3  *
4  * This file is part of Resin(R) Open Source
5  *
6  * Each copy or derived work must preserve the copyright notice and this
7  * notice unmodified.
8  *
9  * Resin Open Source is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * Resin Open Source is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
17  * of NON-INFRINGEMENT. See the GNU General Public License for more
18  * details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with Resin Open Source; if not, write to the
22  *
23  * Free Software Foundation, Inc.
24  * 59 Temple Place, Suite 330
25  * Boston, MA 02111-1307 USA
26  *
27  * @author Rodrigo Westrupp
28  */

29
30 package com.caucho.amber.cfg;
31
32 import com.caucho.vfs.Path;
33
34 import java.util.HashMap JavaDoc;
35
36 /**
37  * Top <entity-mappings> tag in the orm.xml
38  */

39 public class EntityMappingsConfig {
40   private Path _root;
41
42   // attributes
43
private String JavaDoc _version;
44
45   // elements
46
private String JavaDoc _description;
47   private PersistenceUnitMetaDataConfig _persistenceUnitMetaData;
48   private String JavaDoc _package;
49   private String JavaDoc _schema;
50   private String JavaDoc _catalog;
51   private AccessType _access;
52
53   private HashMap JavaDoc<String JavaDoc, SequenceGeneratorConfig> _sequenceGeneratorMap
54     = new HashMap JavaDoc<String JavaDoc, SequenceGeneratorConfig>();
55
56   private HashMap JavaDoc<String JavaDoc, TableGeneratorConfig> _tableGeneratorMap
57     = new HashMap JavaDoc<String JavaDoc, TableGeneratorConfig>();
58
59   private HashMap JavaDoc<String JavaDoc, NamedQueryConfig> _namedQueryMap
60     = new HashMap JavaDoc<String JavaDoc, NamedQueryConfig>();
61
62   private HashMap JavaDoc<String JavaDoc, NamedNativeQueryConfig> _namedNativeQueryMap
63     = new HashMap JavaDoc<String JavaDoc, NamedNativeQueryConfig>();
64
65   private HashMap JavaDoc<String JavaDoc, SqlResultSetMappingConfig> _sqlResultSetMappingMap
66     = new HashMap JavaDoc<String JavaDoc, SqlResultSetMappingConfig>();
67
68   private HashMap JavaDoc<String JavaDoc, MappedSuperclassConfig> _mappedSuperclassMap
69     = new HashMap JavaDoc<String JavaDoc, MappedSuperclassConfig>();
70
71   private HashMap JavaDoc<String JavaDoc, EntityConfig> _entityMap
72     = new HashMap JavaDoc<String JavaDoc, EntityConfig>();
73
74   private HashMap JavaDoc<String JavaDoc, EmbeddableConfig> _embeddableMap
75     = new HashMap JavaDoc<String JavaDoc, EmbeddableConfig>();
76
77
78   public AccessType getAccess()
79   {
80     return _access;
81   }
82
83   public String JavaDoc getCatalog()
84   {
85     return _catalog;
86   }
87
88   public String JavaDoc getDescription()
89   {
90     return _description;
91   }
92
93   public String JavaDoc getPackage()
94   {
95     return _package;
96   }
97
98   public PersistenceUnitMetaDataConfig getPersistenceUnitMetaData()
99   {
100     return _persistenceUnitMetaData;
101   }
102
103   public void setPersistenceUnitMetaData(PersistenceUnitMetaDataConfig persistenceUnitMetaData)
104   {
105     _persistenceUnitMetaData = persistenceUnitMetaData;
106   }
107
108   public Path getRoot()
109   {
110     return _root;
111   }
112
113   public String JavaDoc getSchema()
114   {
115     return _schema;
116   }
117
118   public String JavaDoc getVersion()
119   {
120     return _version;
121   }
122
123   public void setAccess(String JavaDoc access)
124   {
125     _access = AccessType.valueOf(access);
126   }
127
128   public void setCatalog(String JavaDoc catalog)
129   {
130     _catalog = catalog;
131   }
132
133   public void setDescription(String JavaDoc description)
134   {
135     _description = description;
136   }
137
138   public void setPackage(String JavaDoc packageName)
139   {
140     _package = packageName;
141   }
142
143   public void setRoot(Path root)
144   {
145     _root = root;
146   }
147
148   public void setSchema(String JavaDoc schema)
149   {
150     _schema = schema;
151   }
152
153   public void setVersion(String JavaDoc version)
154   {
155     _version = version;
156   }
157
158   /**
159    * Sets the schema location
160    */

161   public void setSchemaLocation(String JavaDoc schema)
162   {
163   }
164
165   /**
166    * Adds a new <entity>.
167    */

168   public void addEntity(EntityConfig entity)
169   {
170     String JavaDoc className = entity.getClassName();
171
172     // jpa/0s2d
173
if ((_package == null) || className.startsWith(_package + "."))
174       _entityMap.put(entity.getClassName(), entity);
175     else
176       _entityMap.put(_package + "." + entity.getClassName(),
177                      entity);
178   }
179
180   /**
181    * Returns an entity config.
182    */

183   public EntityConfig getEntityConfig(String JavaDoc name)
184   {
185     return _entityMap.get(name);
186   }
187
188   /**
189    * Returns the entity map.
190    */

191   public HashMap JavaDoc<String JavaDoc, EntityConfig> getEntityMap()
192   {
193     return _entityMap;
194   }
195
196   public void addSequenceGenerator(SequenceGeneratorConfig sequenceGenerator)
197   {
198     _sequenceGeneratorMap.put(sequenceGenerator.getName(), sequenceGenerator);
199   }
200
201   public SequenceGeneratorConfig getSequenceGenerator(String JavaDoc name)
202   {
203     return _sequenceGeneratorMap.get(name);
204   }
205
206   public HashMap JavaDoc<String JavaDoc, SequenceGeneratorConfig> getSequenceGeneratorMap()
207   {
208     return _sequenceGeneratorMap;
209   }
210
211   public void addTableGenerator(TableGeneratorConfig tableGenerator)
212   {
213     _tableGeneratorMap.put(tableGenerator.getName(), tableGenerator);
214   }
215
216   public TableGeneratorConfig getTableGenerator(String JavaDoc name)
217   {
218     return _tableGeneratorMap.get(name);
219   }
220
221   public HashMap JavaDoc<String JavaDoc, TableGeneratorConfig> getTableGeneratorMap()
222   {
223     return _tableGeneratorMap;
224   }
225
226   public void addNamedQuery(NamedQueryConfig namedQuery)
227   {
228     _namedQueryMap.put(namedQuery.getName(), namedQuery);
229   }
230
231   public NamedQueryConfig getNamedQuery(String JavaDoc name)
232   {
233     return _namedQueryMap.get(name);
234   }
235
236   public HashMap JavaDoc<String JavaDoc, NamedQueryConfig> getNamedQueryMap()
237   {
238     return _namedQueryMap;
239   }
240
241   public void addNamedNativeQuery(NamedNativeQueryConfig namedNativeQuery)
242   {
243     _namedNativeQueryMap.put(namedNativeQuery.getName(), namedNativeQuery);
244   }
245
246   public NamedNativeQueryConfig getNamedNativeQuery(String JavaDoc name)
247   {
248     return _namedNativeQueryMap.get(name);
249   }
250
251   public HashMap JavaDoc<String JavaDoc, NamedNativeQueryConfig> getNamedNativeQueryMap()
252   {
253     return _namedNativeQueryMap;
254   }
255
256   public void addSqlResultSetMapping(SqlResultSetMappingConfig sqlResultSetMapping)
257   {
258     _sqlResultSetMappingMap.put(sqlResultSetMapping.getName(), sqlResultSetMapping);
259   }
260
261   public SqlResultSetMappingConfig getSqlResultSetMapping(String JavaDoc name)
262   {
263     return _sqlResultSetMappingMap.get(name);
264   }
265
266   public HashMap JavaDoc<String JavaDoc, SqlResultSetMappingConfig> getSqlResultSetMappingMap()
267   {
268     return _sqlResultSetMappingMap;
269   }
270
271   public void addMappedSuperclass(MappedSuperclassConfig mappedSuperclass)
272   {
273     _mappedSuperclassMap.put(mappedSuperclass.getClassName(), mappedSuperclass);
274   }
275
276   public MappedSuperclassConfig getMappedSuperclass(String JavaDoc name)
277   {
278     return _mappedSuperclassMap.get(name);
279   }
280
281   public HashMap JavaDoc<String JavaDoc, MappedSuperclassConfig> getMappedSuperclassMap()
282   {
283     return _mappedSuperclassMap;
284   }
285
286   public void addEmbeddable(EmbeddableConfig embeddable)
287   {
288     _embeddableMap.put(embeddable.getClassName(), embeddable);
289   }
290
291   public EmbeddableConfig getEmbeddable(String JavaDoc name)
292   {
293     return _embeddableMap.get(name);
294   }
295
296   public HashMap JavaDoc<String JavaDoc, EmbeddableConfig> getEmbeddableMap()
297   {
298     return _embeddableMap;
299   }
300
301   public String JavaDoc toString()
302   {
303     return _entityMap.toString();
304   }
305 }
306
Popular Tags