When the application inserts or updates an object, it will set these fields and they will be stored in the database. JPA events could also be used to record the audit information, or to write to a separate audit table.
log in options: log in with user name/password and log in with certificate
how to create custom realm and how to handle multi-realm scenario
account credentials and access rights are stored in database. Stored passwords are hashed and salted.
Authorization
If the realm wishes to do also authorization, it has to implement Authorizer interface. Each Authorizer method takes principal as parameter and checks either role(s) or permission(s)
Permissions are supplied either as strings or as permission objects
use WildcardPermissionResolver to convert strings into permission objects
connect application to database and create tables to store all user account data
replace IniRealm with realm able to read from database and salt passwords.
not been able to find information about standard room types
OpenTravel schema allows for a RoomTypeCode to be passed, but it is simply a string length of 1 to 16 characters to be able to accommodate the plethora of room type codes that are in use
Updated Groovy template for GraniteDS Builder (gas3)
also stripped out the specialized GraniteDS datatypes in favor of the LCDS serialization convention that Adobe uses (i.e. a Java map should translate to an 'Object' type, a Java enum should translate to a 'String', and Java collections should always serialize as 'ArrayCollection')
didn't do a 'base' version and a version that doesnt get touched by the code generator, but you could easily do so by modifying this template
Entity–attribute–value model (EAV) is a data model to describe entities where the number of attributes (properties, parameters) that can be used to describe them is potentially vast, but the number that will actually apply to a given entity is relatively modest
also known as object–attribute–value model, vertical database model and open schema
In an EAV data model, each attribute-value pair is a fact describing an entity, and a row in an EAV table stores a single fact
EAV tables are often described as "long and skinny": "long" refers to the number of rows, "skinny" to the few columns
Data is recorded as three columns:
The entity: the item being described.
The attribute or parameter: a foreign key into a table of attribute definitions. At the very least, the attribute definitions table would contain the following columns: an attribute ID, attribute name, description, data type, and columns assisting input validation
The value of the attribute
Row modeling, where facts about something (in this case, a sales transaction) are recorded as multiple rows rather than multiple columns
differences between row modeling and EAV (which may be considered a generalization of row-modeling) are:
A row-modeled table is homogeneous in the facts that it describes
The data type of the value column/s in a row-modeled table is pre-determined by the nature of the facts it records. By contrast, in an EAV table, the conceptual data type of a value in a particular row depend on the attribute in that row
In the EAV table itself, this is just an attribute ID, a foreign key into an Attribute Definitions table
The Attribute
The Value
Coercing all values into strings
larger systems use separate EAV tables for each data type (including binary large objects, "BLOBS"), with the metadata for a given attribute identifying the EAV table in which its data will be stored
Where an EAV system is implemented through RDF, the RDF Schema language may conveniently be used to express such metadata
access to metadata must be restricted, and an audit trail of accesses and changes put into place to deal with situations where multiple individuals have metadata access
quality of the annotation and documentation within the metadata (i.e., the narrative/explanatory text in the descriptive columns of the metadata sub-schema) must be much higher, in order to facilitate understanding by various members of the development team.
Attribute metadata
Validation metadata include data type, range of permissible values or membership in a set of values, regular expression match, default value, and whether the value is permitted to be null
Presentation metadata: how the attribute is to be displayed to the user
Grouping metadata: Attributes are typically presented as part of a higher-order group, e.g., a specialty-specific form. Grouping metadata includes information such as the order in which attributes are presented
used
as a base class for JPA/Hibernate persisted permissions that wish to store the parts of the permission string
in separate columns (e.g. 'domain', 'actions' and 'targets' columns)
one option would be to embed the hierarchy of locations in the
permission strings
since you can have any
number of elements separated by colons
Another option would be to create your own Permission instances and
implement the isPermitted() method such that it delegates to
Location.isIn(Location) for permission checks
best strategies for implementation of equals() and hashcode() in your persistent classes
The general contract is: if you want to store an object in a List, Map or a Set then it is an requirement that equals and hashCode are implemented so they obey the standard contract as specified in the documentation
Why are equals() and hashcode() importantNormally, most Java objects provide a built-in equals() and hashCode() based on the object's identity; so each new() object will be different from all others.
recommend using the "semi"-unique attributes of your persistent class to implement equals() (and hashCode()
The database identifier property should only be an object identifier, and basically should be used by Hibernate only
Instead of using the database identifier for the equality comparison, you should use a set of properties for equals() that identify your individual objects
"name" String and "created" Date, I can use both to implement a good equals() method
Workaround by forcing a save/flush
work around by forcing a save() / flush() after object creation and before insertion into the set
Note that it's highly inefficient and thus not recommended
"Bean Validation" specification (aka JSR-303) standardizes an annotation-based validation framework for Java
Flex doesn't provide by itself such framework. The standard way of processing validation is to use Validator subclasses and to bind each validator to each user input (see Validating data). This method is at least time consuming for the developer, source of inconsistancies between the client-side and the server-side validation processes, and source of redundancies in your MXML code.
GraniteDS introduces an ActionsScript3 implementation of the Bean Validation specification and provides code generation tools integration so that your Java constraint annotations are reproduced in your AS3 beans
GraniteDS validation framework provides a set of standard constraints
Constraint
Description
AssertFalse
The annotated element must be false
AssertTrue
The annotated element must be true
DecimalMax
The annotated element must be a number whose value must be lower or equal to the specified maximum
DecimalMin
The annotated element must be a number whose value must be greater or equal to the specified minimum
Digits
The annotated element must be a number whithin accepted range
Future
The annotated element must be a date in the future
Max
The annotated element must be a number whose value must be lower or equal to the specified maximum
Min
The annotated element must be a number whose value must be greater or equal to the specified minimum
NotNull
The annotated element must not be null
Null
The annotated element must be null
Past
The annotated element must be a date in the past
Pattern
The annotated String must match the supplied regular expression
Size
The annotated element size must be between the specified boundaries (included)
Constraint annotations must be placed on public properties, either public variables or public accessors
When updating existing entities coming from the database
id is defined and is maintained
in the three layers during the different serialization/persistence operations
when a new entity is being created in any of the two upper layers (Flex/JPA)
new entity has no id until it has been persisted to the database
most common solution is to
have a second persisted id, the uid
which is created by the client and persisted along with the entity
recommended approach to avoid any kind of subtle problems is to have a real uid property which will be persisted
in the database but is not a primary key for efficiency concerns
You can now ask Tide to
limit the object graph before sending it
Flex with the following API :
EntityGraphUnintializer
uninitializeEntityGraph
Person object will be uninitialized
uperson contains
only the minimum of data
to correctly merge your changes in the server persistence context
Tide uses the
client data tracking
to determine which parts of the graph
need to be sent
Calling the EntityGraphUninitializer manually is a bit tedious and ugly, so there is a cleaner possibility when you are using
generated typesafe service proxies
annotate your service method arguments with @org.granite.tide.data.Lazy :
@Lazy
take care that you have added the [Lazy] annotation to your Flex
metadata compilation configuration
in the Flex application, register the UninitializeArgumentPreprocessor component in Tide as follows :
[UninitializeArgumentPreprocessor]
all calls to PersonService.save() will
automatically use a properly uninitialized version
of the person
argument.
15.4. Dirty Checking and Conflict Handling
simplify the handling of data between Flex and Java EE
Chapter 15. Data Management
Tide maintains a client-side cache of entity instances and ensures that every instance is unique in the Flex client context
uid().hashCode();
Tide currently only supports Integer or Long version fields, not timestamps and that the field must be nullable