adl-support.utils

Application Description Language support - utility functions.

*locale*

dynamic

The locale for which files will be generated.

*output-path*

dynamic

The path to which generated files will be written.

*verbosity*

dynamic

The verbosity of output from the generator.

all-properties

macro

(all-properties entity)

Return all properties of this entity (including key properties).

attributes

(attributes element)(attributes element predicate)

Return the attributes of this element; if predicate is passed, return only those attributes satisfying the predicate.

base-type

(base-type property application)

FIXME: write docs

capitalise

(capitalise s)

Return a string like s but with each token capitalised.

child

(child element predicate)

Return the first child of this element satisfying this predicate.

child-with-tag

(child-with-tag element tag)(child-with-tag element tag predicate)

Return the first child of this element which has this tag; if element is nil, return nil. If predicate is supplied, return only the first child with the specified tag which satisfies the predicate.

children

(children element)(children element predicate)

Return the children of this element; if predicate is passed, return only those children satisfying the predicate.

children-with-tag

(children-with-tag element tag)(children-with-tag element tag predicate)

Return all children of this element which have this tag; if element is nil, return nil. If predicate is supplied, return only those children with the specified tag which satisfy the predicate.

column-name

(column-name property)

Return, as a string, the name for the column which represents this property.

descendant-with-tag

(descendant-with-tag element tag)(descendant-with-tag element tag predicate)

Return the first descendant of this element, recursively, which has this tag. If predicate is specified, return the first also satisfying this predicate.

descendants-with-tag

(descendants-with-tag element tag)(descendants-with-tag element tag predicate)

Return all descendants of this element, recursively, which have this tag. If predicate is specified, return only those also satisfying this predicate.

distinct-properties

(distinct-properties entity)

FIXME: write docs

editor-name

(editor-name entity application)

Return the path-part of the editor form for this entity. Note: assumes the editor form is the first form listed for the entity.

element?

(element? o)

True if o is a Clojure representation of an XML element.

emit-header

(emit-header prefix & content)

Emit this content as a sequence of wrapped lines each prefixed with prefix, and the whole delimited by rules.

entity-by-name

macro

(entity-by-name entity-name application)

Return the entity with this entity-name in this application. TODO: Candidate for move to adl-support.utils.

entity-for-property

(entity-for-property property application)

If this property references an entity, return that entity from this application

entity?

(entity? x)

Return true if x is an ADL entity.

find-permissions

(find-permissions & elements)

Return appropriate the permissions of the first of these elements which has permissions.

formal-primary-key?

(formal-primary-key? prop-or-name entity)

Does this prop-or-name appear to be a property (or the name of a property) which is a formal primary key of this entity?

has-non-key-properties?

(has-non-key-properties? entity)

FIXME: write docs

has-primary-key?

(has-primary-key? entity)

FIXME: write docs

insertable-key-properties

macro

(insertable-key-properties entity)

FIXME: write docs

insertable-properties

macro

(insertable-properties entity)

Return all the properties of this entity (including key properties) into which user-supplied data can be inserted

insertable?

(insertable? property)

Return true it the value of this property may be set from user-supplied data.

is-quotable-type?

(is-quotable-type? property application)

True if the value for this field should be quoted.

key-names

(key-names entity)(key-names entity as-keywords?)

FIXME: write docs

key-properties

macro

(key-properties entity)

FIXME: write docs

order-preserving-set

(order-preserving-set collection)

The Clojure set function does not preserve the order in which elements are passed to it. This function is like set, except 1. It returns a list, not a hashset, and 2. It is order-preserving.

path-part

(path-part form entity application)

Return the URL path part for this form of this entity within this application. Note that form may be a Clojure XML representation of a form, list or page ADL element, or may be one of the keywords :form, :list, :page in which case the first child of the entity of the specified type will be used.

permission-groups

(permission-groups permissions predicate)

Return a list of names of groups to which this predicate is true of some permission taken from these permissions, else nil.

pretty-name

(pretty-name element)

Return a version of the name of this element (entity, field, form, list, page, property) suitable for use in text visible to the user.

prompt

(prompt field-or-property form entity application)

Return an appropriate prompt for the given field-or-property taken from this form of this entity of this application, in the context of the current binding of *locale*. TODO: something more sophisticated about i18n

properties

macro

(properties entity)

Return all the properties of this entity.

property-for-field

(property-for-field field entity)

Return the property within this entity which matches this field.

property?

(property? o)

True if o is a property.

required-properties

(required-properties entity)

Return the properties of this entity which are required and are not system generated.

safe-name

(safe-name o)(safe-name o convention)

Return a safe name for the object o, given the specified convention. o is expected to be either a string or an element. Recognised values for convention are: #{:c :c-sharp :java :sql}

singularise

(singularise string)

Attempt to construct an idiomatic English-language singular of this string.

sort-by-name

(sort-by-name elements)

Sort these elements by their :name attribute.

system-generated?

(system-generated? property)

True if the value of the property is system generated, and should not be set by the user.

type-for-defined

(type-for-defined property application)

FIXME: write docs

typedef

(typedef property application)

If this property is of type defined, return its type definition from this application, else nil.

unique-link?

(unique-link? e1 e2)

True if there is exactly one link between entities e1 and e2.

user-distinct-properties

(user-distinct-properties entity)

Return the properties of this entity which are user distinct

user-distinct-property-names

(user-distinct-property-names entity)

Return, as a set, the names of properties which are user distinct

visible-to

(visible-to permissions)

Return a list of names of groups to which are granted read access, given these permissions, else nil.

volatility

(volatility entity)

Return the cache ttl in seconds for records of this entity.

wrap-lines

(wrap-lines width text)(wrap-lines text)

Wrap lines in this text to this width; return a list of lines.

writeable-by

(writeable-by permissions)(writeable-by permissions has-value?)

Return a list of names of groups to which are granted write access, given these permissions, else nil. TODO: TOTHINKABOUT: properties are also writeable by insert and noedit, but only if the current value is nil.