generated from intersystems-community/iris-interoperability-template
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add documentation for DTL support and JSON schema integration in IoP
- Loading branch information
1 parent
80d8764
commit b10f8d9
Showing
8 changed files
with
127 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
# DTL Support | ||
|
||
Starting with version 3.2.0, IoP supports DTL transformations. | ||
DTL the Data Transformation Layer in IRIS Interoperability. | ||
DTL transformations are used to transform data from one format to another with a graphical editor. | ||
It supports also `jsonschema` structures. | ||
|
||
## How to use DTL in with Message | ||
|
||
First you need to register you message class is a `settings.py` file. | ||
|
||
To do so, you need to add the following line in the `settings.py` file: | ||
|
||
`settings.py` | ||
``` | ||
from msg import MyMessage | ||
SCHEMAS = [MyMessage] | ||
``` | ||
|
||
Then you can use iop migration command to generate schema files for your message classes. | ||
|
||
```bash | ||
iop --migrate /path/to/your/project/settings.py | ||
``` | ||
|
||
### Example | ||
|
||
`msg.py` | ||
```python | ||
from iop import Message | ||
from dataclasses import dataclass | ||
|
||
@dataclass | ||
class MyMessage(Message): | ||
name: str = None | ||
age: int = None | ||
``` | ||
|
||
`settings.py` | ||
```python | ||
from msg import MyMessage | ||
|
||
SCHEMAS = [MyMessage] | ||
``` | ||
|
||
Migrate the schema files | ||
```bash | ||
iop --migrate /path/to/your/project/settings.py | ||
``` | ||
|
||
## Building a DTL Transformation | ||
|
||
To build a DTL transformation, you need to create a new DTL transformation class. | ||
|
||
Go to the IRIS Interoperability Management Portal and create a new DTL transformation. | ||
|
||
![DTL Transformation](./img/interop_dtl_management_portal.png) | ||
|
||
Then select the source and target message classes. | ||
|
||
![DTL Transformation](./img/dtl_wizard.png) | ||
|
||
And it's schema. | ||
|
||
![DTL Transformation](./img/vdoc_type.png) | ||
|
||
Then you can start building your transformation. | ||
|
||
![DTL Transformation](./img/complex_transform.png) | ||
|
||
You can even test your transformation. | ||
|
||
![DTL Transformation](./img/test_dtl.png) | ||
|
||
Example of payload to test as a source message: | ||
|
||
```xml | ||
<test> | ||
<Message> | ||
<json><![CDATA[ | ||
{ | ||
"list_str":["toto","titi"], | ||
"post":{"Title":"foo","Selftext":"baz"}, | ||
"list_post":[{"Title":"bar","Selftext":"baz"},{"Title":"foo","Selftext":"foo"}] | ||
} | ||
]]></json> | ||
</Message> | ||
</test> | ||
``` | ||
|
||
## JsonSchema Support | ||
|
||
Starting with version 3.2.0, IoP supports `jsonschema` structures for DTL transformations. | ||
|
||
Same as for message classes, you need to register your `jsonschema`. | ||
To do so, you need to invoke his iris command: | ||
|
||
```objectscript | ||
zw ##class(IOP.Message.JSONSchema).ImportFromFile("/irisdev/app/random_jsonschema.json","Demo","Demo") | ||
``` | ||
|
||
Where the first argument is the path to the jsonschema file, the second argument is the package name and the third argument is the name of the schema. | ||
|
||
Then you can use it in your DTL transformation. | ||
The schema will be available in the name of `Demo`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters