Creating a Smart Access
If you want your model to aggregate information coming from different sources, you need a smart access.
On this page
General
The Smart Access is the delegating layer that controls the logic from which integration access data is read and written. This logic is provided by the integrated Smart Mapper which maps integration entities and properties to Smart Model equivalents, along with the relevant integration accesses through which the integration entities can be accessed.
For more information, see Smart Access
Prerequisites and Use-Case
In this tutorial, you will use the integration accesses you created as part of the Connecting a MySQL Database and Connecting an Oracle Database procedures to create an access which aggregates data from MySQL and Oracle. The two accesses you created contain the following entity types:
- Person
- Company
The smart access you create in this tutorial will work with the AssigneeListModel as its metamodel. The AssigneeListModel smart model will contain a list of Person entities with their respective Company entities assigned. The Person entity data will come from an MySQL database and the Company entity data will come from an Oracle database.
The use case can be summarized as follows:
- Create database connections:
- Create an aggregation ParticipantModelwhich will serve as a source to save theParticipantentity and assign it to a newly created SMOOD access.
- Create a AssigneeListModelcombining all the entities and map the entities' properties.
- Create a smart access.
Creating a ParticipantModel
- In Control Center, go to Custom Models, click New and configure your model as follows:
| Name | Value | 
|---|---|
| groupId | custom.model | 
| name | ParticipantModel | 
- Using Modeler, create a new Participantentity and add two properties to it:
| Name | Data Type | 
|---|---|
| personId | integer | 
| companyId | long | 
The difference between the data types comes from how each database treats the ID property.
- Make sure that your ParticipanthasStandardIntegerIdetifiableas a supertype instead of theRootModel.
- Click Commit to save your changes.
Creating a SMOOD Access
- 
In Control Center, go to Custom Accesses and click New. 
- 
Select SmoodAccess and configure it as follows: Name | Value | Description externalId|smood.local| External ID of your access.name|smood| Name of your access.metaModel|ParticipantModel| Model this access uses. Assign your newly createdParticipantModelhere.
- 
Click Apply, then Commit. 
- 
Right-click your new access and select Deploy. 
Changing the Company Model
Because the Company entity comes from an Oracle database and this might result in id translation errors, you must change it so that it has a StandardIdentifiable instead of the RootModel as a supertype. To change the model:
- In Control Center, go to Custom Models.
- Double-click the Companymodel to open Modeler.
- In Modeler, click the Companyentity and go to Details -> superTypes.
- Unassign the RootModel, assignStandardIdentifiableas a super type, and commit your changes.
Creating an AssigneeListModel
- In Control Center, go to Custom Models, click New and configure your model as follows:
| Name | Value | 
|---|---|
| groupId | custom.model | 
| name | AssigneeListModel | 
| dependencies | CompanyOraclePersonModelMySQLParticipantModel | 
Make sure to add all models you want to use in your model.
- 
In Modeler, add the Companyentity to the model.Make sure the entity you add comes from your custom Oracle access. In other words, make sure the fully qualified name of the entity corresponds to the fully qualified name of the Companyentity fromCompanyModelyou imported from the Oracle database.
- 
In Modeler, add the Personentity to the model.Make sure the entity you add comes from your custom MySQL access. In other words, make sure the fully qualified name of the entity corresponds to the fully qualified name of the Personentity from thePersonModelMySQLmodel you persisted in the MySQL database.
- 
In Modeler, add the Participantentity to the model.
- 
Create a SmartParticipantentity.
- 
Drag and drop your mouse pointer from the SmartParticipantentity to thePersonentity creating a single aggregation (has a) relation and name the relationperson.
- 
Drag and drop your mouse pointer from the SmartParticipantentity to theCompanyentity creating a single aggregation (has a) relation and name the relationcompany.
Using Smart Mapper
Smart mapper allows you to create relationships between data structures coming from different data sources. To map your entities using smart mapper:
- In Modeler, click the Personentity, navigate to the Filter tab, mark the Mapper checkbox, and click Commit.
- On the Personentity, type the name of the entity you want to map thePersonentity to in the Choose mapping type link. In this case, we want to map to the smart modelPersonentity to thePersonentity 1:1. When you typed the name of the entity, click on its name. The mapping view is displayed.
- In the mapping view, in the IncrementalAccess link, type the name of the access the mapping data comes from. In the case of the Personentity, this is themySQLAccess, because thePersonentity data is stored in a MySQL database.
- Still in the mapping view, click Assign all as is and click Commit. This means you want to map the properties of your Personentity in the smart access to the properties of thePersonentity coming from the MySQL database. Once you did that, click Back
- Repeat steps 2 - 4 for the Companyentity. Make sure to map theCompanyentity using the Oracle access, because that is where theCompanyentity data is stored.
- Map the SmartParticipantentity to theParticipantentity and open the mapping view.
- In the mapping view, assign the SMOOD access you created to store the Participantentity data in theIncrementalAccesslink.
- Create a new join for the companyproperty by selecting Join from the drop-down list that appears when you click the downward arrow button. Thecompanyproperty is the has-a relation betweenSmartParticipantandCompanyentities you created in Modeler. Map theParticipant.companyIdproperty to the Company.idproperty.
- Create a new join for the personproperty by selecting Join from the drop-down list that appears when you click the downward arrow button. Thepersonproperty is the has-a relation betweenSmartParticipantandPropertyentities you created in Modeler. Map theParticipant.personIdproperty to thePerson.idproperty.
- Assign the idproperty as is and commit your changes.
Creating a Smart Access
To create a smart access:
- In Control Center, navigate to Custom Accesses, click New, select the SmartAccess entry, and configure it as follows:
| Name | Value | 
|---|---|
| externalId | access.smart | 
| name | SmartAccess | 
| metaModel | AssigneeListModel | 
| delegates | smoodmySQLAccessmyOracleAccess | 
- Click Apply, then Commit, then Deploy.
Testing a Smart Access
- In Control Center, navigate to Custom Accesses, and switch to your smart access.
- In Explorer, in the Quick Access search box, type SmartParticipant. A new, empty tab is opened.
- In the SmartParticipant tab, click New. A new modal window is opened.
- In the modal window, assign an instance of Companyand an instance ofPersonto the respective properties, click Apply, and then Commit.
- Your new instance of SmartParticipantis created.