public class DataMap extends Object implements Serializable, ConfigurationNode, XMLSerializable, MappingNamespace, DbEntityListener, ObjEntityListener, Comparable<DataMap>
Modifier and Type | Field and Description |
---|---|
static String |
CLIENT_SUPPORTED_PROPERTY
Defines whether a DataMap supports client entities.
|
protected boolean |
clientSupported |
protected Resource |
configurationSource |
protected DataChannelDescriptor |
dataChannelDescriptor |
static String |
DEFAULT_CLIENT_PACKAGE_PROPERTY
Defines the name of the property for default client Java class package.
|
static String |
DEFAULT_CLIENT_SUPERCLASS_PROPERTY
Defines the name of the property for default client Java superclass.
|
static String |
DEFAULT_LOCK_TYPE_PROPERTY
Defines the name of the property for default DB schema.
|
static String |
DEFAULT_PACKAGE_PROPERTY
Defines the name of the property for default Java class package.
|
static String |
DEFAULT_QUOTE_SQL_IDENTIFIERS_PROPERTY |
static String |
DEFAULT_SCHEMA_PROPERTY
Defines the name of the property for default DB schema.
|
static String |
DEFAULT_SUPERCLASS_PROPERTY
Defines the name of the property for default Java superclass.
|
protected String |
defaultClientPackage |
protected String |
defaultClientSuperclass |
protected int |
defaultLockType |
protected String |
defaultPackage |
protected String |
defaultSchema |
protected String |
defaultSuperclass |
protected String |
location |
protected String |
name |
protected MappingNamespace |
namespace |
protected Boolean |
quotingSQLIdentifiers |
static String |
SCHEMA_XSD
The namespace in which the data map XML file will be created.
|
Constructor and Description |
---|
DataMap()
Creates a new unnamed DataMap.
|
DataMap(String mapName)
Creates a new named DataMap.
|
DataMap(String mapName,
Map<String,Object> properties) |
Modifier and Type | Method and Description |
---|---|
<T> T |
acceptVisitor(ConfigurationNodeVisitor<T> visitor) |
void |
addDbEntity(DbEntity entity)
Adds a new DbEntity to this DataMap.
|
void |
addDefaultEntityListener(EntityListener listener)
Adds a new EntityListener.
|
void |
addEmbeddable(Embeddable embeddable)
Adds an embeddable object to the DataMap.
|
void |
addObjEntity(ObjEntity entity)
Adds a new ObjEntity to this DataMap.
|
void |
addProcedure(Procedure procedure)
Adds stored procedure to the list of procedures.
|
void |
addQuery(Query query)
Stores a query under its name.
|
void |
addResult(SQLResult result)
Adds a named SQLResultSet to the DataMap.
|
void |
clearDbEntities() |
void |
clearEmbeddables()
Removes all stored embeddable objects from the map.
|
void |
clearObjEntities() |
void |
clearProcedures() |
void |
clearQueries() |
void |
clearResultSets() |
int |
compareTo(DataMap o) |
void |
dbEntityAdded(EntityEvent e)
New entity has been created/added.
|
void |
dbEntityChanged(EntityEvent e)
DbEntity property changed.
|
void |
dbEntityRemoved(EntityEvent e)
Entity has been removed.
|
void |
encodeAsXML(PrintWriter pw)
Deprecated.
since 3.1, as
XMLSerializable objects should only save XML
segments. Saving full XML files is responsibilty of the callers. |
void |
encodeAsXML(XMLEncoder encoder)
Prints itself as XML to the provided PrintWriter.
|
DataMap |
getClientDataMap(EntityResolver serverResolver)
Returns a DataMap stripped of any server-side information, such as DbEntity
mapping, or ObjEntities that are not allowed in the client tier.
|
Resource |
getConfigurationSource() |
DataChannelDescriptor |
getDataChannelDescriptor() |
Collection<DbEntity> |
getDbEntities()
Returns all DbEntities in this DataMap.
|
DbEntity |
getDbEntity(String dbEntityName)
Returns DbEntity matching the
name parameter. |
SortedMap<String,DbEntity> |
getDbEntityMap()
Returns a sorted unmodifiable map of DbEntities contained in this DataMap, keyed by
DbEntity name.
|
String |
getDefaultClientPackage()
Returns default client package.
|
String |
getDefaultClientSuperclass()
Returns default client superclass.
|
EntityListener |
getDefaultEntityListener(String className) |
List<EntityListener> |
getDefaultEntityListeners()
Returns an unmodifiable list of default
EntityListener objects. |
int |
getDefaultLockType() |
String |
getDefaultPackage() |
String |
getDefaultSchema() |
String |
getDefaultSuperclass() |
Embeddable |
getEmbeddable(String className)
Returns an
Embeddable matching class name or null if such Embeddable is not
mapped. |
Map<String,Embeddable> |
getEmbeddableMap() |
Collection<Embeddable> |
getEmbeddables()
Returns a collection of
Embeddable mappings stored in the DataMap. |
String |
getLocation()
Returns "location" property value.
|
Collection<ObjEntity> |
getMappedEntities(DbEntity dbEntity)
Returns all ObjEntities mapped to the given DbEntity.
|
String |
getName()
Returns the name of this DataMap.
|
MappingNamespace |
getNamespace()
Returns a parent namespace where this DataMap resides.
|
Collection<ObjEntity> |
getObjEntities()
Returns an unmodifiable collection of ObjEntities stored in this DataMap.
|
ObjEntity |
getObjEntity(String objEntityName)
Returns an ObjEntity for a given name.
|
ObjEntity |
getObjEntityForJavaClass(String javaClassName)
Returns an ObjEntity for a DataObject class name.
|
SortedMap<String,ObjEntity> |
getObjEntityMap()
Returns a sorted unmodifiable map of ObjEntities contained in this DataMap, keyed
by ObjEntity name.
|
Procedure |
getProcedure(String procedureName)
Returns a Procedure for a given name or null if no such procedure exists.
|
SortedMap<String,Procedure> |
getProcedureMap()
Returns a sorted unmodifiable map of Procedures in this DataMap keyed by name.
|
Collection<Procedure> |
getProcedures()
Returns stored procedures associated with this DataMap.
|
Collection<Query> |
getQueries()
Returns an unmodifiable collection of mapped queries.
|
Query |
getQuery(String queryName)
Returns a named query associated with this DataMap.
|
SortedMap<String,Query> |
getQueryMap() |
SQLResult |
getResult(String name)
Returns a named result set mapping.
|
Collection<SQLResult> |
getResults() |
Map<String,SQLResult> |
getResultsMap() |
void |
initWithProperties(Map<String,Object> properties)
Performs DataMap initialization from a set of properties, using defaults for the
missing properties.
|
boolean |
isClientSupported() |
boolean |
isQuotingSQLIdentifiers() |
void |
mergeWithDataMap(DataMap map)
Adds all Object and DB entities and Queries from another map to this map.
|
void |
objEntityAdded(EntityEvent e)
New entity has been created/added.
|
void |
objEntityChanged(EntityEvent e)
ObjEntity property changed.
|
void |
objEntityRemoved(EntityEvent e)
Entity has been removed.
|
void |
removeDbEntity(String dbEntityName)
"Dirty" remove of the DbEntity from the data map.
|
void |
removeDbEntity(String dbEntityName,
boolean clearDependencies)
Removes DbEntity from the DataMap.
|
void |
removeDefaultEntityListener(String className)
Removes a listener matching class name.
|
void |
removeEmbeddable(String className)
Removes an
Embeddable descriptor with matching class name. |
void |
removeObjEntity(String objEntityName)
"Dirty" remove of the ObjEntity from the data map.
|
void |
removeObjEntity(String objEntityName,
boolean clearDependencies)
Removes ObjEntity from the DataMap.
|
void |
removeProcedure(String name) |
void |
removeQuery(String queryName)
Removes a named query from the DataMap.
|
void |
removeResult(String name) |
void |
setClientSupported(boolean clientSupport) |
void |
setConfigurationSource(Resource configurationSource) |
void |
setDataChannelDescriptor(DataChannelDescriptor dataChannelDescriptor) |
void |
setDefaultClientPackage(String defaultClientPackage) |
void |
setDefaultClientSuperclass(String defaultClientSuperclass) |
void |
setDefaultLockType(int defaultLockType) |
void |
setDefaultPackage(String defaultPackage) |
void |
setDefaultSchema(String defaultSchema) |
void |
setDefaultSuperclass(String defaultSuperclass) |
void |
setLocation(String location)
Sets "location" property.
|
void |
setName(String name)
Set the name of this DataMap.
|
void |
setNamespace(MappingNamespace namespace)
Sets a parent namespace where this DataMap resides.
|
void |
setQuotingSQLIdentifiers(boolean quotingSqlIdentifiers) |
String |
toString() |
public static final String CLIENT_SUPPORTED_PROPERTY
public static final String DEFAULT_CLIENT_PACKAGE_PROPERTY
public static final String DEFAULT_CLIENT_SUPERCLASS_PROPERTY
public static final String DEFAULT_SCHEMA_PROPERTY
public static final String DEFAULT_PACKAGE_PROPERTY
public static final String DEFAULT_SUPERCLASS_PROPERTY
public static final String DEFAULT_LOCK_TYPE_PROPERTY
public static final String DEFAULT_QUOTE_SQL_IDENTIFIERS_PROPERTY
public static final String SCHEMA_XSD
protected String name
protected String location
protected MappingNamespace namespace
protected Boolean quotingSQLIdentifiers
protected String defaultSchema
protected String defaultPackage
protected String defaultSuperclass
protected int defaultLockType
protected boolean clientSupported
protected String defaultClientPackage
protected String defaultClientSuperclass
protected Resource configurationSource
protected DataChannelDescriptor dataChannelDescriptor
public DataMap()
public DataMap(String mapName)
public DataChannelDescriptor getDataChannelDescriptor()
public void setDataChannelDescriptor(DataChannelDescriptor dataChannelDescriptor)
public <T> T acceptVisitor(ConfigurationNodeVisitor<T> visitor)
acceptVisitor
in interface ConfigurationNode
public int compareTo(DataMap o)
compareTo
in interface Comparable<DataMap>
public boolean isQuotingSQLIdentifiers()
public void setQuotingSQLIdentifiers(boolean quotingSqlIdentifiers)
public void initWithProperties(Map<String,Object> properties)
public DataMap getClientDataMap(EntityResolver serverResolver)
@Deprecated public void encodeAsXML(PrintWriter pw)
XMLSerializable
objects should only save XML
segments. Saving full XML files is responsibilty of the callers.encodeAsXML(XMLEncoder)
stores DataMap assuming it is a part of a bigger
document.public void encodeAsXML(XMLEncoder encoder)
encodeAsXML
in interface XMLSerializable
public String getName()
public void setName(String name)
public void mergeWithDataMap(DataMap map)
TODO: will need to implement advanced merge that allows different policies for overwriting entities / queries.
public String getLocation()
public void setLocation(String location)
public SortedMap<String,ObjEntity> getObjEntityMap()
public SortedMap<String,DbEntity> getDbEntityMap()
public Query getQuery(String queryName)
getQuery
in interface MappingNamespace
public void addQuery(Query query)
public void removeQuery(String queryName)
public void clearEmbeddables()
public void clearResultSets()
public void clearQueries()
public void clearObjEntities()
public void clearDbEntities()
public void clearProcedures()
public Collection<Query> getQueries()
getQueries
in interface MappingNamespace
public void addEmbeddable(Embeddable embeddable)
public void addResult(SQLResult result)
public void addObjEntity(ObjEntity entity)
public void addDbEntity(DbEntity entity)
public Collection<ObjEntity> getObjEntities()
getObjEntities
in interface MappingNamespace
public Map<String,Embeddable> getEmbeddableMap()
public Collection<Embeddable> getEmbeddables()
Embeddable
mappings stored in the DataMap.public Collection<SQLResult> getResults()
public Embeddable getEmbeddable(String className)
MappingNamespace
Embeddable
matching class name or null if such Embeddable is not
mapped.getEmbeddable
in interface MappingNamespace
public SQLResult getResult(String name)
MappingNamespace
getResult
in interface MappingNamespace
public List<EntityListener> getDefaultEntityListeners()
EntityListener
objects. Note that
since the order of listeners is significant a list, not just a generic Collection
is returned.public void addDefaultEntityListener(EntityListener listener)
IllegalArgumentException
- if a listener for the same class name is already
registered.public void removeDefaultEntityListener(String className)
public EntityListener getDefaultEntityListener(String className)
public Collection<DbEntity> getDbEntities()
getDbEntities
in interface MappingNamespace
public DbEntity getDbEntity(String dbEntityName)
name
parameter. No dependencies will be
searched.getDbEntity
in interface MappingNamespace
public ObjEntity getObjEntityForJavaClass(String javaClassName)
public ObjEntity getObjEntity(String objEntityName)
getObjEntity
in interface MappingNamespace
public Collection<ObjEntity> getMappedEntities(DbEntity dbEntity)
public void removeEmbeddable(String className)
Embeddable
descriptor with matching class name.public void removeResult(String name)
public void removeDbEntity(String dbEntityName)
public void removeDbEntity(String dbEntityName, boolean clearDependencies)
clearDependencies
is true, all
DbRelationships that reference this entity are also removed. ObjEntities that rely
on this entity are cleaned up.public void removeObjEntity(String objEntityName)
public void removeObjEntity(String objEntityName, boolean clearDependencies)
clearDependencies
is true, all
ObjRelationships that reference this entity are also removed.public Collection<Procedure> getProcedures()
getProcedures
in interface MappingNamespace
public Procedure getProcedure(String procedureName)
getProcedure
in interface MappingNamespace
public void addProcedure(Procedure procedure)
public void removeProcedure(String name)
public SortedMap<String,Procedure> getProcedureMap()
public MappingNamespace getNamespace()
public void setNamespace(MappingNamespace namespace)
public int getDefaultLockType()
public void setDefaultLockType(int defaultLockType)
public boolean isClientSupported()
public void setClientSupported(boolean clientSupport)
public String getDefaultClientPackage()
public void setDefaultClientPackage(String defaultClientPackage)
public String getDefaultClientSuperclass()
public void setDefaultClientSuperclass(String defaultClientSuperclass)
public String getDefaultPackage()
public void setDefaultPackage(String defaultPackage)
public String getDefaultSchema()
public void setDefaultSchema(String defaultSchema)
public String getDefaultSuperclass()
public void setDefaultSuperclass(String defaultSuperclass)
public void dbEntityChanged(EntityEvent e)
dbEntityChanged
in interface DbEntityListener
public void dbEntityAdded(EntityEvent e)
dbEntityAdded
in interface DbEntityListener
public void dbEntityRemoved(EntityEvent e)
dbEntityRemoved
in interface DbEntityListener
public void objEntityChanged(EntityEvent e)
objEntityChanged
in interface ObjEntityListener
public void objEntityAdded(EntityEvent e)
objEntityAdded
in interface ObjEntityListener
public void objEntityRemoved(EntityEvent e)
objEntityRemoved
in interface ObjEntityListener
public Resource getConfigurationSource()
public void setConfigurationSource(Resource configurationSource)
Copyright © 2001–2014 Apache Cayenne. All rights reserved.