4.3.1.2. Model API Model Package

A model can have multiple packages and are thus a way of grouping generated objects. If you use only one package then you will not need this API.

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

For an image see API hierarchy

Note

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

As a reference the following model.xml is used to explain the model package api.

<!--Some File comment of this model.xml file-->
<package name="domain">
        <properties>
                <example.metadata>BookStore</example.metadata>
                <!--Descriptive comment-->
        </properties>
        <object name="Author">
                ..
        </object>
        <object name="Book">
                ..
        </object>
</package>

4.3.1.2.2. Details

4.3.1.2.2.1. deleteFromObjects(ModelObject objects)

void deleteFromObjects(ModelObject objects)

Description

Deletes a single ModelObjects from the list of ModelObject children that this ModelPackage contains.

Example

none

4.3.1.2.2.2. findMetaDataByKey(String expression)

Set<IMetaDataEntry> findMetaDataByKey(String expression) throws InvalidPatternException

Description

Finds Set of metadata by expression.

Example

none

4.3.1.2.2.3. findObjectByMetaData(String key)

ModelObject findObjectByMetaData(String key)

Description

Returns a single ModelObject child by Metadata property.

Example

none

4.3.1.2.2.4. findObjectByMetaData(String key, String value)

ModelObject findObjectByMetaData(String key, String value)

Description

Returns a single ModelObject child by Metadata property and the value that this property must have.

Example

none

4.3.1.2.2.5. findObjectByName(String objectName)

ModelObject findObjectByName(String objectName)

Description

Returns a ModelObject child by name.

Example

none

4.3.1.2.2.6. findObjectsByMetaData(String key)

List<ModelObject> findObjectsByMetaData(String key)

Description

Returns a list of ModelObject children by Metadata property.

Example

none

4.3.1.2.2.7. findObjectsByMetaData(String key, String value)

List<ModelObject> findObjectsByMetaData(String key, String value)

Description

Returns a list of ModelObject children by Metadata property and the value that this property must have.

Example

none

4.3.1.2.2.8. getChilderen()

List<RelationDecorator> getChilderen()

Description

Returns a list of all child model objects of this ModelAPI object instance (Root or Package).

Example

none

4.3.1.2.2.9. getFileComment()

String getFileComment()

Description

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

Example

none

4.3.1.2.2.10. 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.2.2.11. 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.2.2.12. 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.2.2.13. 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.2.2.14. 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.2.2.15. getName()

void getName()

Description

Cross M Deprecated. Documented for compatibility reasons only.

Use getAttributeValue(“name”) instead.

Example

none

4.3.1.2.2.16. getObjects()

List<ModelObject> getObjects()

Description

Returns the list of ModelObject children that this ModelPackage contains.

Example

none

4.3.1.2.2.17. getParent()

RelationDecorator getParent()

Description

Returns the the parent of this of this ModelAPI object instance (Root or Package).

Example

none

4.3.1.2.2.18. getRoot()

ModelRoot getRoot()

Description

Returns the ModelRoot parent of ModelPackage.

Example

none

4.3.1.2.2.19. getText()

String getText()

Description

?

Example

none

4.3.1.2.2.20. 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.2.2.21. 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