4.3.1.4. Model API Model Attribute

ModelAttribute is a child of ModelObject and can contain Metadata.

All mentioned functions are available on ModelAttribute which is made available in Freemarker/Velocity by iterating over the element tree in model.xml. In any step of the operation process you can access ModelAttribute, which is always the currently active attribute.

For an image see API hierarchy

Eye M Getter functions in Freemarker/Velocity can be accessed as an object property, so modelAttribute.getName() can be written as modelAttribute.name.

4.3.1.4.2. Details

4.3.1.4.2.1. addMetaData(String key, String value)

void addMetaData(String key, String value)

Description

Adds metadata with a given key to a package, object, attribute or reference.

Freemarker Example

${modelObject.addMetaData("enableCrud", "true")}

4.3.1.4.2.2. addMetaData(String key, String value, String description)

void addMetaData(String key, String value, String description)

Description

Adds metadata with a given key to ModelRoot. It also adds a description.

Example

none

4.3.1.4.2.3. findMetaDataByKey(String expression)

Set<IMetaDataEntry> findMetaDataByKey(String expression) throws InvalidPatternException

Description

Finds Set of metadata by expression.

Example

none

4.3.1.4.2.4. getAttributeValue(String attributeName)

Niet beschreven

4.3.1.4.2.5. getFileComment()

String getFileComment()

Description

Returns the comment String set by the developer for file generation.

Example

none

4.3.1.4.2.6. getKind()

String getKind()

Description

The kind of model element, which is either of the following:

  • root,

  • package,

  • attribute,

  • reference or

  • metadata.

This can be a useful tool when performing a type specific action on a list with various types of items.

For the modelRoot getKind() should always return “root”.

Freemarker Example

<#assign shouldBeRoot = modelRoot.kind>
<#if shouldBeRoot == "root">
        <#--Do some action which is only intended for an expected root, and not for packages, attributes, references-->
</#if>

4.3.1.4.2.7. getLength()

Integer getLength()

Description

Returns the ‘length’ property of ModeAttribute. This property can for example be used to limit the number of characters for the attribute.

Example

none

4.3.1.4.2.8. getMetaData()

Set<Map.Entry<String,Set<IMetaDataEntry>>> getMetaData()

Description

Get all metdata for this ModelRoot. In Freemarker this would be a list, which you can iterate.

Example

none

4.3.1.4.2.9. getMetaData(String metaDataKey)

String getMetaData(String metaDataKey) throws InvalidPatternException, InvalidPropertyException, PropertyNotFoundException

Description

Metadata finder that throws an exception if something went wrong.

Example

none

4.3.1.4.2.10. getMetaData(String metaDataKey, boolean throwExceptionIfNotFound)

String getMetaData(String metaDataKey, String defaultValue) throws InvalidPatternException

Description

Metadata finder that accepts a key and sets a default value if the metadata property doesn’t exist.

Example

none

4.3.1.4.2.11. getMetaData(String metaDataKey, String defaultValue)

String getMetaData(String metaDataKey, String defaultValue) throws InvalidPatternException

Description

Metadata finder that accepts a key and sets a default value if the metadata property doesn’t exist.

Example


4.3.1.4.2.12. getName()

void getName()

Description

Cross M Deprecated. Documented for compatibility reasons only.

Use getAttributeValue(“name”) instead.

Example

none

4.3.1.4.2.13. getNotnull()

Boolean getNotnull()

Description

Returns the ‘notnull’ property of ModelAttribute. This Java boolean wrapper type returns true or false if present and otherwise null.

Example

none

4.3.1.4.2.14. getObject()

ModelObject getObject()

Description

Returns the ModelObject parent of this ModeAttribute.

Example

none

4.3.1.4.2.15. getType()

String getType()

Description

Returns the type of Attribute. This type might be ‘String’, ‘integer’, ‘Integer’ or others.

Loupe S| For details on data types see Data type mappings

Example

none

4.3.1.4.2.16. hasMetaData(String key)

boolean hasMetaData(String key)

Description

Checks if metadata with a given key and value is present in this ModelAPI object instance (Root, Package, Object, Attribute, Reference).

Example

none

4.3.1.4.2.17. hasMetaData(String key, String value)

boolean hasMetaData(String key, String value)

Description

Checks if metadata with a given key and value is present in this ModelAPI object instance (Root, Package, Object, Attribute, Reference).

Example

none

4.3.1.4.2.18. setFileComment(String fileComment)

void setFileComment(String fileComment)

Description

Set the comment String for every generated file.

Example

none

4.3.1.4.2.19. setLength(Integer length)

void setLength(Integer length)

Description

Sets the ‘length’ property of ModeAttribute. This property can for example be used to limit the number of characters for the attribute.

Example

none

4.3.1.4.2.20. setName(String name)

void setName(String name)

Description

Sets the name of the attribute.

Freemarker example

${modelAttribute.setName("Set a name")

none

4.3.1.4.2.21. setNotnull(Boolean notnull)

void setNotnull(Boolean notnull)

Description

Sets the ‘notnull’ property of ModelAttribute with true, false, or null.

Example

none

4.3.1.4.2.22. setObject(ModelObject object)

void setObject(ModelObject object)

Description

Sets the ModelObject parent of this ModeAttribute.

Example

none

4.3.1.4.2.23. setType(String type)

void setType(String type)

Description

Sets the type of Attribute. This type might be ‘String’, ‘integer’, ‘Integer’ or others.

Glasses S For details on data types see: Data type mappings

Example

none