Abstracting Data of Add-On Modules
Introduction
Add-on modules allow you to abstract your domain model and use view entities to only show the user select details. Add-ons are commonly used for building connectors to other systems, which allows you to abstract away the caching mechanism from outside the module, so users who use the add-on do not have to consider it.
Use Case
For this purpose of this use case, the following domain model is used:
![](/attachments/refguide/modeling/domain-model/view-entities/abstracting-data/domain-model.png)
You have a module that manages the inventory and stock of your shop products. You want to export this module so you can reuse it in different projects. To increase security, you do not want to expose the persistable entities, so you want to create view entities that represent the data you want to share outside the module.
Create an Add-On Module
-
Create a new module.
-
Open the module Settings and click the Export tab.
-
Select Add-on module as the module type, then click OK.
With the add-on enabled, you should see an additional configurable property in the documents and other elements of your module called Export level. This is set to Hidden by default, which means users of your add-on cannot access them.
![](/attachments/refguide/modeling/domain-model/view-entities/abstracting-data/export-level.png)
Create a View Entity
You want to make an interface that shows products where you can filter the results by category. Do this by creating a view entity what joins the Product and Category entities. Follow the steps below:
-
Open your domain model and create a new view entity named ProductCategoryVE.
-
Add the following query to the OQL editor:
SELECT p.ProductId as ProductId , p.ProductName as ProductName , p.QuantityPerUnit as QuantityPerUnit , p.Discontinued as Discontinued , c.CategoryName as Category , c.CategoryId as CategoryId FROM ShopAddOn.Product as p JOIN p/ShopAddOn.Product_Category/ShopAddOn.Category as c
-
Double-click ProductCategoryVE and set the export level to Usable.
-
Export the add-on module by right-clicking it and selecting Export add-on module package.