|
SRJRCFrames v0.1.296 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.jgoodies.binding.beans.Model de.schwarzrot.data.support.AbstractEntity
public abstract class AbstractEntity
cuts off all persistence necessities from business objects. So the
business-classes could be coded and used like standard beans. This base class
in cooperation with Repository
and
EntityManager
s does all the tedious stuff you don't really wonna care
about.
Repository
,
EntityManager
,
EntityDescriptor
,
Serialized FormConstructor Summary | |
---|---|
AbstractEntity()
bean like constructor (use for "real" instances") |
|
AbstractEntity(AbstractEntity other)
|
Method Summary | ||
---|---|---|
|
adoptChildren(List<E> children)
|
|
|
adoptChildren(Map<?,E> children)
|
|
|
adoptGroupedChildren(Map<?,List<E>> children)
|
|
int |
compareTo(Entity other)
|
|
boolean |
equals(Object any)
|
|
Long |
getCModified()
returns the number of modifications that happened to this instance. |
|
Comparable<?> |
getCode()
|
|
List<SortInfo> |
getDefaultOrder()
returns a list of SortInfo , that build the order for default
list-queries. |
|
Date |
getDtCreated()
returns the timestamp when this instance was created |
|
Date |
getDtModified()
returns the timestamp of the last saving operation. |
|
Long |
getId()
returns the id of an Entity -instance. |
|
protected org.apache.commons.logging.Log |
getLogger()
|
|
Map<String,String> |
getMappings()
returns a map with mappings of logical property names to physical property names (column names in database terms). |
|
String |
getPersistenceName()
returns the name of the entity for persistance. |
|
String |
getSchemaName()
returns the schema for this entity. |
|
Map<String,Integer> |
getSkipList()
returns a map with property names, that EntityManager s should
ignore. |
|
Class<?> |
getSystemClass()
return the classtype for system usage |
|
String |
getUCreated()
returns the name of the user, that created this instance |
|
String |
getUModified()
returns the name of the user, that triggered the last write operation for this instance. |
|
List<String> |
getUniqColumnNames()
returns a list of property names, which serve to detect a uniq instance without the usage of the primary key. |
|
List<String> |
getUserAttributes()
return a list of properties, that are user attributes. |
|
String |
getVariantColumnName()
returns the name of the property that is used to distinguish Entity -variants. |
|
Map<Object,String> |
getVariantTypeMap()
returns a map with the content of getVariantColumnName as key and
fully qualified classnames as value. |
|
int |
hashCode()
|
|
boolean |
isDirty()
returns whether the instance contains changes not saved to persistence. |
|
boolean |
isUserType()
returns true, if this entity is a usertype and false, if it is a system type |
|
boolean |
isVirtual()
returns whether this class is virtual or real. |
|
void |
setCModified(Long modified)
set's the number of modifications, that happened to this instance. |
|
void |
setDirty(boolean dirty)
marks an instance as dirty, which means the instance has changes, not written to persistence yet. |
|
void |
setDtCreated(Date dtCreated)
set's the timestamp of the moment, this instance was created. |
|
void |
setDtModified(Date dtModified)
set's the timestamp of the last modification. |
|
void |
setId(Long id)
set's the id of this instance. |
|
static void |
setSchemaName(String schemaName)
|
|
void |
setUCreated(String created)
set's the name of the user, that created this instance. |
|
void |
setUModified(String modified)
set's the name of the user, that performed the last modification of this instance. |
|
String |
toString()
|
|
void |
validate(boolean read)
will be called just before saving and after loading, so it is intended to give the opportunity to calculate virtual fields. |
Methods inherited from class com.jgoodies.binding.beans.Model |
---|
addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, addVetoableChangeListener, equals, fireIndexedPropertyChange, fireIndexedPropertyChange, fireIndexedPropertyChange, fireMultiplePropertiesChanged, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, getPropertyChangeListeners, getPropertyChangeListeners, getVetoableChangeListeners, getVetoableChangeListeners, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, removeVetoableChangeListener |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface com.jgoodies.binding.beans.Observable |
---|
addPropertyChangeListener, removePropertyChangeListener |
Constructor Detail |
---|
public AbstractEntity()
public AbstractEntity(AbstractEntity other)
Method Detail |
---|
public <E extends ChildEntity> void adoptChildren(List<E> children)
public <E extends ChildEntity> void adoptChildren(Map<?,E> children)
public <E extends ChildEntity> void adoptGroupedChildren(Map<?,List<E>> children)
public int compareTo(Entity other) throws IllegalArgumentException
compareTo
in interface Comparable<Entity>
IllegalArgumentException
public boolean equals(Object any)
equals
in class Object
public final Long getCModified()
Entity
getCModified
in interface Entity
public Comparable<?> getCode()
public List<SortInfo> getDefaultOrder()
Entity
SortInfo
, that build the order for default
list-queries.
getDefaultOrder
in interface Entity
public final Date getDtCreated()
Entity
getDtCreated
in interface Entity
public final Date getDtModified()
Entity
getDtModified
in interface Entity
public final Long getId()
Entity
Entity
-instance. Normally the id are the
primary key for the instances in persistence layer.
getId
in interface Entity
public Map<String,String> getMappings()
Entity
Every implementation should respect the parents mappings. The following sample shows different mapping types:
public Map<String, String> getMappings() { Map<String, String> mappings = super.getMappings(); mappings.put("title", "name"); mappings.put("streams", Stream.class.getName()); mappings.put("pageDefinitions", "pageType|" + ThemeElement.class.getName()); return mappings; }The mappings explained:
List
, known (named) children are hold in a Map
.
The mapped value is used as classname to create child instances.Map
, that holds grouped
children. Known children are hold by a Map
, unknown children by a
List
, so "pageDefinitions" may contain elements of type
Map
, or List
. pageType, a property of
ThemeElement
, is used to group the children. The word before the
'|' is the property name used as key value for grouping and the type
after '|' is used to create instances.
getMappings
in interface Entity
Map
with property names as keys and column
names as values.public String getPersistenceName()
Entity
getClass().getSimpleName()
, but some storage may
have size limitations, or don't support case sensitive names, so this
call is to deal with that kind of limitations.
getPersistenceName
in interface Entity
public String getSchemaName()
Entity
getSchemaName
in interface Entity
public Map<String,Integer> getSkipList()
Entity
EntityManager
s should
ignore. These properties may be virtual properties, that not should be
saved to persistence and/or methods that start with 'get' and that are
not getters.
Implemention uses HashMaps
for performance reasons, but the
values are never used. So the map consists of propertynames as keys and
an Integer as Value.
Every implementation should use the Map from parent class:
public Map<String, Integer> getSkipList() { Map<String, Integer> skipList = super.getSkipList(); skipList.put("a_virtual_field", 1); return skipList; }
getSkipList
in interface Entity
public Class<?> getSystemClass()
Entity
getSystemClass
in interface Entity
public final String getUCreated()
Entity
getUCreated
in interface Entity
public final String getUModified()
Entity
getUModified
in interface Entity
public List<String> getUniqColumnNames()
Entity
getUniqColumnNames
in interface Entity
public List<String> getUserAttributes()
Entity
getUserAttributes
in interface Entity
public String getVariantColumnName()
Entity
Entity
-variants. This is neede, if several entities share the
same storage, so the real classname has to be determined by a stored
value.
getVariantColumnName
in interface Entity
public Map<Object,String> getVariantTypeMap()
Entity
getVariantColumnName
as key and
fully qualified classnames as value.
There are 2 types of polymorphism supported:
null
and the content of the getVariantColumnName
must hold the canonical class name of the java classes.
Example (for known children): suppose a table animals
that should hold entities Cat and Dog. The class
Animal
will overload the method
getPersistenceName
, wich returns "animal". Additionally it
will declare an Enum
as
Enum Animal { CAT, DOG };as well as a property
animalType
of type Animal
. The
constructor of Cat
initializes the property animalType
with CAT, the constructor of Dog initializes the property
animalType
with DOG. The variantTypeMap returned will
then look like:
Map<Animal, String> variantTypeMap = new HashMap<Animal, String>(); variantTypeMap.put(CAT, Cat.class.getName()); variantTypeMap.put(DOG, Dog.class.getName());
Example (for known children): if the sample from above should
support more animals, even those unknown at time of writing,
getVariantTypeMap()
should return null
. The content of
column animalType should then match Cat.class.getName()
instead
of just Cat.
getVariantTypeMap
in interface Entity
public int hashCode()
hashCode
in class Object
public final boolean isDirty()
Entity
isDirty
in interface Entity
public boolean isUserType()
Entity
isUserType
in interface Entity
public boolean isVirtual()
Entity
When you have a table, that should contain animals and you implent
classes for each animal type, you don't want that instances of class
Animal should exists. Normally you would make such a class
abstract
, but this is forbidden for beans and so for entities!
This method signals the EntityManager
that Animal
is
not the type of the entity. Instead it has to be determined by the
loaded content.
isVirtual
in interface Entity
true
for virtual (abstract) classes, default
false
public final void setCModified(Long modified)
Entity
setCModified
in interface Entity
modified
- the new modification counterpublic void setDirty(boolean dirty)
Entity
setDirty
in interface Entity
dirty
- - true if instance has unsafed changesAbstractEntity
public final void setDtCreated(Date dtCreated)
Entity
setDtCreated
in interface Entity
dtCreated
- a timestamppublic final void setDtModified(Date dtModified)
Entity
setDtModified
in interface Entity
dtModified
- a timestamppublic final void setId(Long id)
Entity
setId
in interface Entity
id
- the id for this instancepublic final void setUCreated(String created)
Entity
setUCreated
in interface Entity
created
- a usernamepublic final void setUModified(String modified)
Entity
setUModified
in interface Entity
modified
- a usernamepublic String toString()
toString
in class Object
public void validate(boolean read)
Entity
validate
in interface Entity
read
- signals whether calculation should be done for reading or for
writingprotected final org.apache.commons.logging.Log getLogger()
public static void setSchemaName(String schemaName)
|
SRJRCFrames v0.1.296 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |