5.3.1.3. Model API Model Object

ModelObject is a child of ModelPackage and can contain Metadata, ModelAttribute children and ModelReference children.

All mentioned functions are available on ModelObject 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 ModelObject, which is always the currently active object.

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

For an image see API hierarchy

5.3.1.3.1. Overview

Table 5.24 API of ‘Model Object’

Modifier and Type

Method and Description

void

addMetaData(String key, String value)

void

addMetaData(String key, String value, String description)

void

addToAttributes(ModelAttribute attributes)

void

addToReferences(ModelReference references)

void

deleteFromAttributes(ModelAttribute attributes)

void

deleteFromReferences(ModelReference references)

ModelAttribute

findAttributeByMetaData(String key)

ModelAttribute

findAttributeByMetaData(String key, String value)

ModelAttribute

findAttributeByName(String attributeName)

ModelAttribute

findAttributeByType(String attributeType)

List<ModelAttribute>

findAttributesByMetaData(String key)

List<ModelAttribute>

findAttributesByMetaData(String key, String value)

List<ModelAttribute>

findAttributesByType(String attributeType)

List<IMetaDataEntry>

findMetaDataByKey(String expression)

ModelReference

findReferenceByMetaData(String key)

ModelReference

findReferenceByMetaData(String key, String value)

ModelReference

findReferenceByName(String referenceName)

ModelReference

findReferenceByType(String referenceType)

List<ModelReference>

findReferencesByMetaData(String key)

List<ModelReference>

findReferencesByMetaData(String key, String value)

List<ModelReference>

findReferencesByMultiplicity(String referenceMultiplicity)

List<ModelReference>

findReferencesByType(String referenceType)

List<ModelAttribute>

getAttributes()

String

getAttributeValue(String attributeName)

String

getFileComment()

String

getKind()

List<IMetaDataEntry>

getMetaData()

String

getMetaData(String metaDataKey)

String

getMetaData(String metaDataKey, boolean throwExceptionIfNotFound)

String

getMetaData(String metaDataKey, String defaultValue)

ModelPackage

getModelPackage()

String

getName()

List<ModelReference>

getReferences()

boolean

hasMetaData(String key)

boolean

hasMetaData(String key, String value)

void

setAttributes(List attributes)

void

setFileComment(String fileComment)

void

setModelPackage(ModelPackage modelPackage)

void

setName(String name)

void

setReferences(List references)

5.3.1.3.2. Details

5.3.1.3.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")}

5.3.1.3.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

5.3.1.3.2.3. addToAttributes(ModelAttribute attributes)

void addToAttributes(ModelAttribute attributes)

Description

Adds a single attribute to this ModelObject.

Example

none

5.3.1.3.2.4. addToReferences(ModelReference references)

void addToReferences(ModelReference references)

Description

Adds a single reference to this ModelObject.

Example

none

5.3.1.3.2.5. deleteFromAttributes(ModelAttribute attributes)

void deleteFromAttributes(ModelAttribute attributes)

Description

Delete a single attribute from this ModelObject.

Example

none

5.3.1.3.2.6. deleteFromReferences(ModelReference references)

void deleteFromReferences(ModelReference references)

Description

Delete a single reference from this ModelObject.

Example

none

5.3.1.3.2.7. findAttributeByMetaData(String key)

ModelAttribute findAttributeByMetaData(String key)

Description

Returns a single attribute of this ModelObject by given metadata key.

Example

none

5.3.1.3.2.8. findAttributeByMetaData(String key, String value)

ModelAttribute findAttributeByMetaData(String key, String value)

Description

Returns a single attribute of this ModelObject by given metadata key, while also passing the value that the content that this metadata should hold. For example, pass key ‘transientField’ with value ‘true’. Eye S Remember that there are no predefined metadata, you define them yourself.

Example

none

5.3.1.3.2.9. findAttributeByName(String attributeName)

ModelAttribute findAttributeByName(String attributeName)

Description

Returns a single attribute of this ModelObject by name.

Example

none

5.3.1.3.2.10. findAttributeByType(String attributeType)

ModelAttribute findAttributeByType(String attributeType)

Description

Returns a single attribute of this ModelObject by type. This type might be ‘String’, ‘integer’, ‘Integer’ or others.

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

Example

none

5.3.1.3.2.11. findAttributesByMetaData(String key)

List<ModelAttribute> findAttributesByMetaData(String key)

Description

Returns a list of attributes of this ModelObject by given metadata key.

Example

none

5.3.1.3.2.12. findAttributesByMetaData(String key, String value)

List<ModelAttribute> findAttributesByMetaData(String key, String value)

Description

Returns a list of attributes of this ModelObject by given metadata key, while also passing the value that the content that this metadata should hold. For example, pass key ‘transientField’ with value ‘true’.

Eye S Remember that there are no predefined metadata, you define them yourself.

Example

none

5.3.1.3.2.13. findAttributesByType(String attributeType)

List<ModelAttribute> findAttributesByType(String attributeType)

Description

Returns a list of attributes of this ModelObject by type. This type might be ‘String’, ‘integer’, ‘Integer’ or others. View the type mappings here.

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

Example

none

5.3.1.3.2.14. findMetaDataByKey(String expression)

Set<IMetaDataEntry> findMetaDataByKey(String expression) throws InvalidPatternException

Description

Finds Set of metadata by expression.

Example

none

5.3.1.3.2.15. findReferenceByMetaData(String key)


Description

Example

none

5.3.1.3.2.16. findReferenceByMetaData(String key, String value)

ModelReference findReferenceByMetaData(String key, String value)

Description

Returns a single reference of this ModelObject by MetaData key that has the given value.

Example

none

5.3.1.3.2.17. findReferenceByName(String referenceName)

ModelReference findReferenceByName(String referenceName)

Description

Returns a single referency of this ModelObject by name.

Example

none

5.3.1.3.2.18. findReferenceByType(String referenceType)

ModelReference findReferenceByType(String referenceType)

Description

Returns a single referency of this ModelObject by type. This type would be another ModelObject you have defined.

Example

none

5.3.1.3.2.19. findReferencesByMetaData(String key)

List<ModelReference> findReferencesByMetaData(String key)

Description

Returns a list of references of this ModelObject by MetaData key.

Example

none

5.3.1.3.2.20. findReferencesByMetaData(String key, String value)

List<ModelReference> findReferencesByMetaData(String key, String value)

Description

Returns a list of references of this ModelObject by MetaData key that has the given value.

Example

none

5.3.1.3.2.21. findReferencesByMultiplicity(String referenceMultiplicity)

List<ModelReference> findReferencesByMultiplicity(String referenceMultiplicity)

Description

Returns a list of references of this ModelObject by multiplicity, e.g. “0..1”.

Example

none

5.3.1.3.2.22. findReferencesByType(String referenceType)

List<ModelReference> findReferencesByType(String referenceType)

Description

Returns a list of references of this ModelObject by type. This type would be another ModelObject you have defined.

Example

none

5.3.1.3.2.23. getAttributes()

List<ModelAttribute> getAttributes()

Description

Returns a list of all attributes (type ModelAttribute) of a ModelObject.

Example

none

5.3.1.3.2.24. getAttributeValue(String attributeName)

Niet beschreven

5.3.1.3.2.25. getFileComment()

String getFileComment()

Description

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

Example

none

5.3.1.3.2.26. 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>

5.3.1.3.2.27. 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

5.3.1.3.2.28. getMetaData(String metaDataKey)

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

Description

Metadata finder that throws an exception if something went wrong.

Example

none

5.3.1.3.2.29. 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

5.3.1.3.2.30. 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


5.3.1.3.2.31. getModelPackage()

ModelPackage getModelPackage()

Description

Returns the ModelPackage parent of this ModelObject.

Example

none

5.3.1.3.2.32. getName()

void getName()

Description

Cross M Deprecated. Documented for compatibility reasons only.

Use getAttributeValue(“name”) instead.

Example

none

5.3.1.3.2.33. getReferences()

List<ModelReference> getReferences()

Description

Gets a list of all references of this ModelObject. You can use freemarker to iterate over it.

Freemarker example

<#assign allObjectReferences = modelObject.getReferences()>
<#list allObjectReferences as reference>
<#--Do something with the reference, like displaying it as a form input field.-->
</#list>

5.3.1.3.2.34. 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

5.3.1.3.2.35. 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

5.3.1.3.2.36. setAttributes(List attributes)

void setAttributes(List<ModelAttribute> attributes)

Description

Adds a set of attributes to this ModelObject.

Example

none

5.3.1.3.2.37. setFileComment(String fileComment)

void setFileComment(String fileComment)

Description

Set the comment String for every generated file.

Example

none

5.3.1.3.2.38. setModelPackage(ModelPackage modelPackage)

void setModelPackage(ModelPackage modelPackage)

Description

Sets the ModelPackage parent of this ModelObject.

Example

none

5.3.1.3.2.39. setName(String name)

void setName(String name)

Description

Sets the name of the attribute.

Freemarker example

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

none

5.3.1.3.2.40. setReferences(List references)

void setReferences(List<ModelReference> references)

Description

Adds a set of references to this ModelObject.

Example

none