Package org.apache.ofbiz.entity.model
Class ModelReader
- java.lang.Object
-
- org.apache.ofbiz.entity.model.ModelReader
-
- All Implemented Interfaces:
java.io.Serializable
public class ModelReader extends java.lang.Object implements java.io.Serializable
Generic Entity - Entity Definition Reader- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Map<java.lang.String,ModelEntity>
entityCache
protected java.util.Map<java.lang.String,ResourceHandler>
entityResourceHandlerMap
for each entity contains a map to the ResourceHandler that the entity came fromprotected java.util.Collection<ResourceHandler>
entityResourceHandlers
collection of filenames for entity definitionsprotected java.lang.String
modelName
static java.lang.String
module
protected int
numAutoRelations
protected int
numEntities
protected int
numFields
protected int
numRelations
protected int
numViewEntities
protected java.util.Map<ResourceHandler,java.util.Collection<java.lang.String>>
resourceHandlerEntities
contains a collection of entity names for each ResourceHandler, populated as they are loaded
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addEntityToResourceHandler(java.lang.String entityName, java.lang.String loaderName, java.lang.String location)
ModelRelation
createRelation(ModelEntity entity, org.w3c.dom.Element relationElement)
java.util.Map<java.lang.String,java.util.TreeSet<java.lang.String>>
getEntitiesByPackage(java.util.Set<java.lang.String> packageFilterSet, java.util.Set<java.lang.String> entityFilterSet)
Get all entities, organized by packagejava.util.Map<java.lang.String,ModelEntity>
getEntityCache()
java.util.Set<java.lang.String>
getEntityNames()
Creates a Set with the entityName of each Entity defined in the specified XML Entity Descriptor file.java.util.Iterator<java.lang.String>
getEntityNamesIterator()
Creates a Iterator with the entityName of each Entity defined in the specified XML Entity Descriptor file.ResourceHandler
getEntityResourceHandler(java.lang.String entityName)
ModelEntity
getModelEntity(java.lang.String entityName)
Gets an Entity object based on a definition from the specified XML Entity descriptor file.ModelEntity
getModelEntityNoCheck(java.lang.String entityName)
static ModelReader
getModelReader(java.lang.String delegatorName)
java.util.Collection<java.lang.String>
getResourceHandlerEntities(ResourceHandler resourceHandler)
java.util.Iterator<ResourceHandler>
getResourceHandlerEntitiesKeyIterator()
void
incrementFieldCount(int amount)
void
rebuildResourceHandlerEntities()
rebuilds the resourceHandlerEntities Map of Collections based on the current entityResourceHandlerMap Map, must be done whenever a manual change is made to the entityResourceHandlerMap Map after the initial load to make them consistent again.java.lang.String
validateEntityName(java.lang.String entityName)
Util method to validate an entity name; if no entity is found with the name, characters are stripped from the beginning of the name until a valid entity name is found.
-
-
-
Field Detail
-
module
public static final java.lang.String module
-
entityCache
protected volatile java.util.Map<java.lang.String,ModelEntity> entityCache
-
numEntities
protected int numEntities
-
numViewEntities
protected int numViewEntities
-
numFields
protected int numFields
-
numRelations
protected int numRelations
-
numAutoRelations
protected int numAutoRelations
-
modelName
protected java.lang.String modelName
-
entityResourceHandlers
protected java.util.Collection<ResourceHandler> entityResourceHandlers
collection of filenames for entity definitions
-
resourceHandlerEntities
protected java.util.Map<ResourceHandler,java.util.Collection<java.lang.String>> resourceHandlerEntities
contains a collection of entity names for each ResourceHandler, populated as they are loaded
-
entityResourceHandlerMap
protected java.util.Map<java.lang.String,ResourceHandler> entityResourceHandlerMap
for each entity contains a map to the ResourceHandler that the entity came from
-
-
Method Detail
-
getModelReader
public static ModelReader getModelReader(java.lang.String delegatorName) throws GenericEntityException
- Throws:
GenericEntityException
-
getEntityCache
public java.util.Map<java.lang.String,ModelEntity> getEntityCache() throws GenericEntityException
- Throws:
GenericEntityException
-
rebuildResourceHandlerEntities
public void rebuildResourceHandlerEntities()
rebuilds the resourceHandlerEntities Map of Collections based on the current entityResourceHandlerMap Map, must be done whenever a manual change is made to the entityResourceHandlerMap Map after the initial load to make them consistent again.
-
getResourceHandlerEntitiesKeyIterator
public java.util.Iterator<ResourceHandler> getResourceHandlerEntitiesKeyIterator()
-
getResourceHandlerEntities
public java.util.Collection<java.lang.String> getResourceHandlerEntities(ResourceHandler resourceHandler)
-
addEntityToResourceHandler
public void addEntityToResourceHandler(java.lang.String entityName, java.lang.String loaderName, java.lang.String location)
-
getEntityResourceHandler
public ResourceHandler getEntityResourceHandler(java.lang.String entityName)
-
getModelEntity
public ModelEntity getModelEntity(java.lang.String entityName) throws GenericEntityException
Gets an Entity object based on a definition from the specified XML Entity descriptor file.- Parameters:
entityName
- The entityName of the Entity definition to use.- Returns:
- An Entity object describing the specified entity of the specified descriptor file.
- Throws:
GenericEntityException
-
getModelEntityNoCheck
public ModelEntity getModelEntityNoCheck(java.lang.String entityName)
-
getEntityNamesIterator
public java.util.Iterator<java.lang.String> getEntityNamesIterator() throws GenericEntityException
Creates a Iterator with the entityName of each Entity defined in the specified XML Entity Descriptor file.- Returns:
- A Iterator of entityName Strings
- Throws:
GenericEntityException
-
getEntityNames
public java.util.Set<java.lang.String> getEntityNames() throws GenericEntityException
Creates a Set with the entityName of each Entity defined in the specified XML Entity Descriptor file.- Returns:
- A Set of entityName Strings
- Throws:
GenericEntityException
-
getEntitiesByPackage
public java.util.Map<java.lang.String,java.util.TreeSet<java.lang.String>> getEntitiesByPackage(java.util.Set<java.lang.String> packageFilterSet, java.util.Set<java.lang.String> entityFilterSet) throws GenericEntityException
Get all entities, organized by package- Throws:
GenericEntityException
-
validateEntityName
public java.lang.String validateEntityName(java.lang.String entityName) throws GenericEntityException
Util method to validate an entity name; if no entity is found with the name, characters are stripped from the beginning of the name until a valid entity name is found. It is intended to be used to determine the entity name from a relation name.- Returns:
- A valid entityName or null
- Throws:
GenericEntityException
-
createRelation
public ModelRelation createRelation(ModelEntity entity, org.w3c.dom.Element relationElement)
-
incrementFieldCount
public void incrementFieldCount(int amount)
-
-