|
SRJRCFrames v0.1.296 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Entity
Entity is the interface to bring persistence to business objects. As business
objects should not contain any stuff tied to any persistence layer, but the
persistencs layers needs some additional information for proper handling, the
AbstractEntity
will contain all that stuff.
As this frameworks main focus is the rich client application, every entity is a model for gui-handling by intention, so it will integrate to jgoodies forms or glazedlists or the like.
As we provide type overloading at persistence level, the meta-information is held in POJO instances and not in annotations. But ... this may subject of change some day.
AbstractEntity
Method Summary | |
---|---|
Long |
getCModified()
returns the number of modifications that happened to this instance. |
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. |
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. |
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. |
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. |
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 interface java.lang.Comparable |
---|
compareTo |
Methods inherited from interface com.jgoodies.binding.beans.Observable |
---|
addPropertyChangeListener, removePropertyChangeListener |
Method Detail |
---|
Long getCModified()
List<SortInfo> getDefaultOrder()
SortInfo
, that build the order for default
list-queries.
Date getDtCreated()
Date getDtModified()
Long getId()
Entity
-instance. Normally the id are the
primary key for the instances in persistence layer.
Map<String,String> getMappings()
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.
Map
with property names as keys and column
names as values.String getPersistenceName()
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.
String getSchemaName()
Map<String,Integer> getSkipList()
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; }
Class<?> getSystemClass()
String getUCreated()
String getUModified()
List<String> getUniqColumnNames()
List<String> getUserAttributes()
String getVariantColumnName()
Entity
-variants. This is neede, if several entities share the
same storage, so the real classname has to be determined by a stored
value.
Map<Object,String> getVariantTypeMap()
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.
boolean isDirty()
boolean isUserType()
boolean isVirtual()
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.
true
for virtual (abstract) classes, default
false
void setCModified(Long modified)
modified
- the new modification countervoid setDirty(boolean dirty)
dirty
- - true if instance has unsafed changesAbstractEntity
void setDtCreated(Date dtCreated)
dtCreated
- a timestampvoid setDtModified(Date dtModified)
dtModified
- a timestampvoid setId(Long id)
id
- the id for this instancevoid setUCreated(String created)
created
- a usernamevoid setUModified(String modified)
modified
- a usernamevoid validate(boolean read)
read
- signals whether calculation should be done for reading or for
writing
|
SRJRCFrames v0.1.296 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |