001: /**********************************************************************
002: Copyright (c) 2007 Andy Jefferson and others. All rights reserved.
003: Licensed under the Apache License, Version 2.0 (the "License");
004: you may not use this file except in compliance with the License.
005: You may obtain a copy of the License at
006:
007: http://www.apache.org/licenses/LICENSE-2.0
008:
009: Unless required by applicable law or agreed to in writing, software
010: distributed under the License is distributed on an "AS IS" BASIS,
011: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
012: See the License for the specific language governing permissions and
013: limitations under the License.
014:
015: Contributors:
016: ...
017: **********************************************************************/package org.jpox.metadata;
018:
019: /**
020: * Default implementation of MetaDataFactory.
021: *
022: * @version $Revision: 1.4 $
023: */
024: public class DefaultMetaDataFactory implements MetaDataFactory {
025: /**
026: * Constructor for a ClassMetaData.
027: * Takes the basic string information found in the XML/annotations.
028: * @param pmd MetaData for the package that this class belongs to
029: * @param name Name of class
030: * @param identityType Type of identity
031: * @param objectidClass Class of the object id
032: * @param requiresExtent Whether the class requires an extent
033: * @param detachable Whether this is detachable
034: * @param embeddedOnly embedded-only tag
035: * @param modifier persistence modifier for the class
036: * @param persistenceCapableSuperclass PC superclass (optional)
037: * @param catalog Name for catalog
038: * @param schema Name for schema
039: * @param table Name of the table where to persist objects of this type
040: * @param entityName the entity name required by JPA §4.3.1
041: */
042: public ClassMetaData newClassObject(PackageMetaData pmd,
043: String name, String identityType, String objectidClass,
044: String requiresExtent, String detachable,
045: String embeddedOnly, String modifier,
046: String persistenceCapableSuperclass, String catalog,
047: String schema, String table, String entityName) {
048: ClassMetaData cmd = new ClassMetaData(pmd, name, identityType,
049: objectidClass, requiresExtent, detachable,
050: embeddedOnly, modifier, persistenceCapableSuperclass,
051: catalog, schema, table, entityName);
052: return cmd;
053: }
054:
055: /**
056: * Constructor for a FieldMetaData.
057: * @param md MetaData for the class that this field belongs to
058: * @param name Name of the field
059: * @param pk Whether it is a part of the PK
060: * @param modifier persistence-modifier
061: * @param defaultFetchGroup Whether it is in the DFG
062: * @param nullValue Action on null value inserts
063: * @param embedded Whether it is embedded
064: * @param serialized Whether it is serialised
065: * @param dependent Whether it is dependent for deletes
066: * @param mappedBy Field in other class that it is mapped using
067: * @param column Column name to store it
068: * @param table Table where it is stored
069: * @param catalog Catalog that the table is in
070: * @param schema Schema that the table is in
071: * @param deleteAction Any FK delete action
072: * @param indexed Whether it is indexed
073: * @param unique Whether it is unique
074: * @param recursionDepth Recursion depth to apply on fetch-plan operations
075: * @param loadFetchGroup Whether to load the fetch group
076: * @param valueStrategy Strategy for generating values for this field
077: * @param sequence Sequence name if the strategy is "sequence"
078: * @param fieldType Type of the field
079: * @return MetaData for the field
080: */
081: public FieldMetaData newFieldObject(MetaData md, String name,
082: String pk, String modifier, String defaultFetchGroup,
083: String nullValue, String embedded, String serialized,
084: String dependent, String mappedBy, String column,
085: String table, String catalog, String schema,
086: String deleteAction, String indexed, String unique,
087: String recursionDepth, String loadFetchGroup,
088: String valueStrategy, String sequence, String fieldType) {
089: FieldMetaData fmd = new FieldMetaData(md, name, pk, modifier,
090: defaultFetchGroup, nullValue, embedded, serialized,
091: dependent, mappedBy, column, table, catalog, schema,
092: deleteAction, indexed, unique, recursionDepth,
093: loadFetchGroup, valueStrategy, sequence, fieldType);
094: return fmd;
095: }
096:
097: /**
098: * Method to create a new field object copying from the supplied field
099: * @param md Parent metadata
100: * @param referenceFmd The reference field
101: * @return FieldMetaData object
102: */
103: public FieldMetaData newFieldObject(MetaData md,
104: AbstractMemberMetaData referenceFmd) {
105: FieldMetaData fmd = new FieldMetaData(md, referenceFmd);
106: return fmd;
107: }
108:
109: /**
110: * Constructor for a PropertyMetaData.
111: * @param md MetaData for the interface that this property belongs to
112: * @param name Name of the field
113: * @param pk Whether it is a part of the PK
114: * @param modifier persistence-modifier
115: * @param defaultFetchGroup Whether it is in the DFG
116: * @param nullValue Action on null value inserts
117: * @param embedded Whether it is embedded
118: * @param serialized Whether it is serialised
119: * @param dependent Whether it is dependent for deletes
120: * @param mappedBy Field in other class that it is mapped using
121: * @param column Column name to store it
122: * @param table Table where it is stored
123: * @param catalog Catalog that the table is in
124: * @param schema Schema that the table is in
125: * @param deleteAction Any FK delete action
126: * @param indexed Whether it is indexed
127: * @param unique Whether it is unique
128: * @param recursionDepth Recursion depth to apply on fetch-plan operations
129: * @param loadFetchGroup Whether to load the fetch group
130: * @param valueStrategy Strategy for generating values for this field
131: * @param sequence Sequence name if the strategy is "sequence"
132: * @param fieldType Type of the field
133: * @param fieldName Name of the field (relates to the implementation of this)
134: * @return MetaData for the field
135: */
136: public PropertyMetaData newPropertyObject(MetaData md, String name,
137: String pk, String modifier, String defaultFetchGroup,
138: String nullValue, String embedded, String serialized,
139: String dependent, String mappedBy, String column,
140: String table, String catalog, String schema,
141: String deleteAction, String indexed, String unique,
142: String recursionDepth, String loadFetchGroup,
143: String valueStrategy, String sequence, String fieldType,
144: String fieldName) {
145: PropertyMetaData pmd = new PropertyMetaData(md, name, pk,
146: modifier, defaultFetchGroup, nullValue, embedded,
147: serialized, dependent, mappedBy, column, table,
148: catalog, schema, deleteAction, indexed, unique,
149: recursionDepth, loadFetchGroup, valueStrategy,
150: sequence, fieldType, fieldName);
151: return pmd;
152: }
153:
154: /**
155: * Method to create a new property object copying from the supplied object.
156: * @param md Parent metadata
157: * @param referencePmd Property to copy from
158: * @return PropertyMetaData object
159: */
160: public PropertyMetaData newPropertyObject(MetaData md,
161: PropertyMetaData referencePmd) {
162: PropertyMetaData pmd = new PropertyMetaData(md, referencePmd);
163: return pmd;
164: }
165:
166: /**
167: * Constructor for an InterfaceMetaData.
168: * Takes the basic string information found in the XML/annotations.
169: * @param pmd MetaData for the package that this class belongs to
170: * @param name Name of class
171: * @param identityType Type of identity
172: * @param objectidClass Class of the object id
173: * @param requiresExtent Whether the class requires an extent
174: * @param detachable Whether this is detachable
175: * @param embeddedOnly embedded-only tag
176: * @param catalog Name for catalog
177: * @param schema Name for schema
178: * @param table Name of the table where to persist objects of this type
179: * @param entityName the entity name required by JPA §4.3.1
180: */
181: public InterfaceMetaData newInterfaceObject(
182: final PackageMetaData pmd, final String name,
183: final String identityType, final String objectidClass,
184: final String requiresExtent, final String detachable,
185: final String embeddedOnly, final String catalog,
186: final String schema, final String table,
187: final String entityName) {
188: InterfaceMetaData imd = new InterfaceMetaData(pmd, name,
189: identityType, objectidClass, requiresExtent,
190: detachable, embeddedOnly, catalog, schema, table,
191: entityName);
192: return imd;
193: }
194: }
|