5.3.1.5. Model API Model Reference
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
Getter functions in Freemarker/Velocity can be accessed as an object property, so modelReference.getName() can be written as modelReference.name.
5.3.1.5.1. Overview
Modifier and Type |
Method and Description |
---|---|
void |
|
void |
|
List<IMetaDataEntry> |
|
String |
|
String |
|
Integer |
|
List<IMetaDataEntry> |
|
String |
|
String |
getMetaData(String metaDataKey, boolean throwExceptionIfNotFound) |
String |
|
String |
|
String |
|
Boolean |
|
ModelObject |
|
String |
|
boolean |
|
boolean |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
5.3.1.5.2. Details
5.3.1.5.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.5.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.5.2.3. findMetaDataByKey(String expression)
Set<IMetaDataEntry> findMetaDataByKey(String expression) throws InvalidPatternException
Description
Finds Set of metadata by expression.
Example
none
5.3.1.5.2.4. getFileComment()
String getFileComment()
Description
Returns the comment String set by the developer for file generation.
Example
none
5.3.1.5.2.5. 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.5.2.6. 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
5.3.1.5.2.7. 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.5.2.8. 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.5.2.9. 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.5.2.10. 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.5.2.11. getMultiplicity()
String getMultiplicity()
Description
Returns the Multiplicity value of this reference, which can be “0..1”, “1..1”, “0..n” or “1..1”.
Example
none
5.3.1.5.2.12. getName()
void getName()
Description
Deprecated. Documented for compatibility reasons only.
Use getAttributeValue(“name”) instead.
Example
none
5.3.1.5.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
5.3.1.5.2.14. getObject()
ModelObject getObject()
Description
Returns the ModelObject parent of this ModeAttribute.
Example
none
5.3.1.5.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
5.3.1.5.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
5.3.1.5.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
5.3.1.5.2.18. setFileComment(String fileComment)
void setFileComment(String fileComment)
Description
Set the comment String for every generated file.
Example
none
5.3.1.5.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
5.3.1.5.2.20. setMultiplicity()
void setMultiplicity(String multiplicity)
Description
Sets the Multiplicity value of this reference, which should be “0..1”, “1..1”, “0..n” or “1..1”.
Example
none
5.3.1.5.2.21. 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.5.2.22. setNotnull(Boolean notnull)
void setNotnull(Boolean notnull)
Description
Sets the ‘notnull’ property of ModelAttribute with true, false, or null.
Example
none
5.3.1.5.2.23. setObject(ModelObject object)
void setObject(ModelObject object)
Description
Sets the ModelObject parent of this ModeAttribute.
Example
none
5.3.1.5.2.24. setType(String type)
void setType(String type)
Description
Sets the type of Attribute. This type might be ‘String’, ‘integer’, ‘Integer’ or others.
For details on data types see: Data type mappings
Example
none