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
ParticipantModel
which will serve as a source to save theParticipant
entity and assign it to a newly created SMOOD access. - Create a
AssigneeListModel
combining 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
Participant
entity 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
Participant
hasStandardIntegerIdetifiable
as 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 createdParticipantModel
here. -
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
Company
model to open Modeler. - In Modeler, click the
Company
entity and go to Details -> superTypes. - Unassign the
RootModel
, assignStandardIdentifiable
as 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 | CompanyOracle PersonModelMySQL ParticipantModel |
Make sure to add all models you want to use in your model.
-
In Modeler, add the
Company
entity 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
Company
entity fromCompanyModel
you imported from the Oracle database. -
In Modeler, add the
Person
entity 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
Person
entity from thePersonModelMySQL
model you persisted in the MySQL database. -
In Modeler, add the
Participant
entity to the model. -
Create a
SmartParticipant
entity. -
Drag and drop your mouse pointer from the
SmartParticipant
entity to thePerson
entity creating a single aggregation (has a) relation and name the relationperson
. -
Drag and drop your mouse pointer from the
SmartParticipant
entity to theCompany
entity 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
Person
entity, navigate to the Filter tab, mark the Mapper checkbox, and click Commit. - On the
Person
entity, type the name of the entity you want to map thePerson
entity to in the Choose mapping type link. In this case, we want to map to the smart modelPerson
entity to thePerson
entity 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
Person
entity, this is themySQLAccess
, because thePerson
entity 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
Person
entity in the smart access to the properties of thePerson
entity coming from the MySQL database. Once you did that, click Back - Repeat steps 2 - 4 for the
Company
entity. Make sure to map theCompany
entity using the Oracle access, because that is where theCompany
entity data is stored. - Map the
SmartParticipant
entity to theParticipant
entity and open the mapping view. - In the mapping view, assign the SMOOD access you created to store the
Participant
entity data in theIncrementalAccess
link. - Create a new join for the
company
property by selecting Join from the drop-down list that appears when you click the downward arrow button. Thecompany
property is the has-a relation betweenSmartParticipant
andCompany
entities you created in Modeler. Map theParticipant.companyId
property to the Company.id
property. - Create a new join for the
person
property by selecting Join from the drop-down list that appears when you click the downward arrow button. Theperson
property is the has-a relation betweenSmartParticipant
andProperty
entities you created in Modeler. Map theParticipant.personId
property to thePerson.id
property. - Assign the
id
property 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 | smood mySQLAccess myOracleAccess |
- 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
Company
and an instance ofPerson
to the respective properties, click Apply, and then Commit. - Your new instance of
SmartParticipant
is created.