adl.validator
Application Description Language: validator for ADL structure. TODO: this is at present largely a failed experiment.
all-data-types
*TODO: write docs
application-validations
*TODO: write docs
auxlist-validations
a subsidiary list, on which entities related to primary entities in the enclosing page or list are listed
property
: the property of the enclosing entity that this list displays (obviously, must be of type=‘list’)onselect
: the form or page of the listed entity to call when an item from the list is selectedcanadd
: true if the user should be able to add records to this list
cascade-actions
actions which should be cascaded to dependent objects. All these values except ‘manual’ are taken from Hibernate and should be passed through the adl2hibernate mapping transparently. Relevent only for properties with type=‘entity’, type=‘link’ and type=‘list’
all
: cascade delete, save and updateall-delete-orphan
: see hibernate documentation; relates to transient objects onlydelete
: cascade delete actions, but not save and updatemanual
: cascading will be handled in manually managed code, code to handle cascading should not be generatedsave-update
: cascade save and update actions, but not delete.
complex-data-types
data types which are more complex than SimpleDataTypes… * entity
: a foreign key link to another entity (i.e. the ‘many’ end of a one-to-many link); * list
: a list of some other entity that links to me (i.e. the ‘one’ end of a one-to-many link); * link
: a many to many link (via a link table); * defined
: a type defined by a typedef.
content
content, for things like pages (i.e. forms, lists, pages)
content-validations
*TODO: write docs
defineable-data-types
data types which can be used in a typedef to provide validation - e.g. a string can be used with a regexp or a scalar can be used with min and max values * string
: varchar java.sql.Types.VARCHAR * integer
: int java.sql.Types.INTEGER * real
: double java.sql.Types.DOUBLE * money
: money java.sql.Types.INTEGER * date
: date java.sql.Types.DATE * time
: time java.sql.Types.TIME * timestamp
: timestamp java.sql.Types.TIMESTAMP * uploadable
: varchar java.sql.Types.VARCHAR * image
: varchar java.sql.Types.VARCHAR
uploadable is as string but points to an uploaded file; image is as uploadable but points to an uploadable graphical image file.
disjunct-valid?
(disjunct-valid? o & validations)
Yes, this is a horrible hack. I should be returning the error structure not printing it. But I can’t see how to make that work with bouncer
. OK, so: most of the validators will (usually) fail, and that’s OK. How do we identify the one which ought not to have failed?
documentation-validations
contains documentation on the element which immediately contains it. For the time being, HTML markup is not permitted within documentation, but Markdown (which may include a string representation of HTML markup) should be.
entity-validations
an entity which has properties and relationships; maps onto a database table or a Java serialisable class - or, of course, various other things
name
: obviously, the name of this entitynatural-key
: if present, the name of a property of this entity which forms a natural primary key NOTE: Only partly implemented. NOTE: much of the present implementation assumes all primary keys will be integers. This needs to be fixed! DEPRECATED: remove; replace with the ‘key’ element, below.table
: the name of the table in which this entity is stored. Defaults to same as name of entity. Strongly recommend this is not used unless it needs to be different from the name of the entityforeign
: this entity is part of some other system; no code will be generated for it, although code which links to it will be generated
field-stuff
*TODO: write docs
field-validations
a field in a form or page
property
: the property which this field displays/edits.
fieldgroup-validations
a group of fields and other controls within a form or list, which the renderer might render as a single pane in a tabbed display, for example.
foot-validations
content to place in the bottom of the body of the generated document; this is any HTML block or inline level element.
form-validations
a form through which an entity may be added or edited
generator-actions
*TODO: write docs
generator-validations
marks a property which is auto-generated by some part of the system. This is based on the Hibernate construct, except that the Hibernate implementation folds both its internal generators and custom generators onto the same attribute. This separates them onto two attributes so we can police values for Hibernate’s ‘builtin’ generators.
action
: one of the supported Hibernate builtin generators, or ‘manual’. ‘native’ is strongly recommended in most instancesclass
: if action is ‘manual’, the name of a manually maintained class conforming to the Hibernate IdentifierGenerator interface, or its equivalent in other languages.
group-validations
a group of people with similar permissions to one another
name
: the name of this groupparent
: the name of a group of which this group is subset
head-validations
content to place in the head of the generated document; normally HTML.
help-validations
helptext about a property of an entity, or a field of a page, form or list, or a typedef. Typically there will be only one of these per property per locale; if there are more than one all those matching the locale may be concatenated, or just one may be used.
locale
: the locale in which to prefer this prompt
ifmissing-validations
helpful text to be shown if a property value is missing, typically when a form is submitted. Typically there will be only one of these per property per locale; if there are more than one all those matching the locale may be concatenated, or just one may be used. Later there may be more sophisticated behaviour here.
locale
: the locale in which to prefer this prompt
in-implementation-validations
information about how to translate a type into types known to different target languages. TODO: Once again I’m not wholly comfortable with the name; I’m not really comfortable that this belongs in ADL at all.
target
: the target languagevalue
: the type to use in that target languagekind
: OK, I confess I don’t understand this, but Andrew needs it…
key-validations
*TODO: write docs
list-validations
a list on which entities of a given type are listed
onselect
: name of form/page/list to go to when a selection is made from the list
option-validations
one of an explicit list of optional values a property may have NOTE: whether options get encoded at application layer or at database layer is UNDEFINED; either behaviour is correct. If at database layer it’s also UNDEFINED whether they’re encoded as a single reference data table or as separate reference data tables for each property.
value
: the value of this option.
order-validations
an ordering or records in a list * property
: the property on which to order * sequence
: the sequence in which to order
page-content
*TODO: write docs
page-stuff
*TODO: write docs
page-validations
a page on which an entity may be displayed
param-validations
A parameter passed to the generator. Again, based on the Hibernate implementation.
name
: the name of this parameter.
permission-validations
permissions policy on an entity, a page, form, list or field
group
: the group to which permission is grantedpermission
: the permission which is granted to that group
permissions
permissions a group may have on an entity, list, page, form or field permissions are deemed to increase as you go right. A group cannot have greater permission on a field than on the form it is in, or greater permission on form than the entity it belongs to
none
: noneread
: selectinsert
: insertnoedit
: select, insertedit
: select, insert, updateall
: select, insert, update, delete
pragma-validations
pragmatic advice to generators of lists and forms, in the form of name/value pairs which may contain anything. Over time some pragmas will become ‘well known’, but the whole point of having a pragma architecture is that it is extensible.
prompt-validations
a prompt for a property or field; used as the prompt text for a widget which edits it. Typically there will be only one of these per property per locale; if there are more than one all those matching the locale may be concatenated, or just one may be used.
prompt
: the prompt to uselocale
: the locale in which to prefer this prompt.
property-validations
a property (field) of an entity (table)
name
: the name of this property.type
: the type of this property.default
: the default value of this property. There will probably be magic values of this!typedef
: name of the typedef to use, it type = ‘defined’.distinct
: distinct=‘system’ required that every value in the system will be distinct (i.e. natural primary key); distinct=‘user’ implies that the value may be used by users in distinguishing entities even if values are not formally unique; distinct=‘all’ implies that the values are formally unique /and/ are user friendly (NOTE: not implemented).entity
: if type=‘entity’, the name of the entity this property is a foreign key link to. if type=‘list’, the name of the entity that has a foreign key link to this entityfarkey
: if type=‘list’, the name of farside key in the listed entity; if type=‘entity’ and the farside field to join to is not the farside primary key, then the name of that farside fieldrequired
: whether this propery is required (i.e. ‘not null’).immutable
: if true, once a value has been set it cannot be changed.size
: fieldwidth of the property if specified.concrete
: if set to ‘false’, this property is not stored in the database but must be computed (manually written code must be provided to support this)cascade
: what action(s) on the parent entity should be cascaded to entitie(s) linked on this property. Valid only if type=‘entity’, type=‘link’ or type=‘list’.column
: name of the column in a SQL database table in which this property is stored. TODO: Think about this.unsaved-value
: of a property whose persistent value is set on first being committed to persistent store, the value which it holds before it has been committed
reference-validations
The ‘specification’ and ‘reference’ elements are for documentation only, and do not contribute to the engineering of the application described.
A reference element is a reference to a specifying document.
abbr
: The abbreviated name of the specification to which this reference referssection
: The ‘anchor part’ (part following a hash character) which, when appended to the URL, will locate the exact section referenced.entity
: A reference to another entity within this ADL documentproperty
: A reference to another property within this ADL document; if entity is also specified then of that entity, else of the ancestor entity if any
sample-option
*TODO: write docs
sequences
*TODO: write docs
simple-data-types
data types which are fairly straightforward translations of JDBC data types * boolean
: boolean java.sql.Types.BIT or char(1) java.sql.Types.CHAR * text
: text or java.sql.Types.LONGVARCHAR memo java.sql.Types.CLOB
special-data-types
data types which require special handling - which don’t simply map onto common SQL data types * geopos
: a latitude/longitude pair (experimental and not yet implemented) * image
: a raster image file, in jpeg, gif, or png format (experimental, not yet implemented) * message
: an internationalised message, having different translations for different locales
specification-validations
The ‘specification’ and ‘reference’ elements are for documentation only, and do not contribute to the engineering of the application described.
A specification element is intended chiefly to declare the reference documents which may be used in documentation elements later in the document.
url
: The URL from which the document referenced can be retrievedname
: The full name (title) given to this documentabbr
: A convenient abbreviated name.
top-validations
content to place in the top of the body of the generated document; this is any HTML block or inline level element.
try-validate
(try-validate o validation)
Pass this validation
and the object o
to bouncer
typedef-validations
the definition of a defined type. At this stage a defined type is either * a string in which case it must have size and pattern, or * a scalar in which case it must have minimum and/or maximum pattern must be a regular expression as interpreted by org.apache.regexp.RE minimum and maximum must be of appropriate format for the datatype specified. Validation may be done client-side and/or server-side at application layer and/or server side at database layer.
name
: the name of this typedeftype
: the simple type on which this defined type is based; must be present unless in-implementation children are suppliedsize
: the data size of this defined typepattern
: a regular expression which values for this type must matchminimum
: the minimum value for this type (if base type is scalar)maximum
: the maximum value for this type (if base type is scalar)
valid-adl?
(valid-adl? src)
Return true
if src
is syntactically valid ADL.
validate-adl
(validate-adl src)
*TODO: write docs
validate-adl-file
(validate-adl-file filepath)
*TODO: write docs
verb-validations
a verb is something that may be done through a form. Probably the verbs ‘store’ and ‘delete’ are implied, but maybe they need to be explicitly declared. The ‘verb’ attribute of the verb is what gets returned to the controller
verb
what gets returned to the controller when this verb is selecteddangerous
true if this verb causes a destructive change.