You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+13-19Lines changed: 13 additions & 19 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -85,7 +85,7 @@ During map generation, by default, the Adaptor sets export and Import conversion
85
85
86
86
### How could we configure our mapping for serialization?
87
87
88
-
We can have as much mapping definitions for a class as we need. An easy way to start to define our customized maps is exporting the default MAP0 and importing it again with a different name, then we can make changes in the map regarding the properties that should be exported /imported, names, conversor methods to apply(See `OPNLib.Serialize.Util` class for tools to export/import maps, get / set property mappings,etc…).
88
+
We can have as much mapping definitions for a class as we need. An easy way to start to define our customized maps is exporting the default MAP0 and importing it again with a different name, then we can make changes in the map regarding the properties that should be exported /imported, names, conversor methods to apply. To do this, we can modify directly in the global, or do it programatically (See `OPNLib.Serialize.Util` class for tools to export/import maps, get / set property mappings,etc…)
89
89
90
90
---
91
91
**Example:**
@@ -102,10 +102,10 @@ We can have as much mapping definitions for a class as we need. An easy way to s
102
102
;Overwrite map (2) ofSampleApps.Serialize.MapTestingwith map in object:json
103
103
set tSC = ##class(OPNLib.Serialize.Util).ImportMapsFromJSON(json,2,tClassName)
104
104
105
-
;Get settings of one of the properties. They're returned in a json object
105
+
;Get settings of one of the properties. They are returned in a json object
106
106
set propExprt = ##class(SampleApps.Serialize.MapTesting).GetMappedPropSettings("code","MAP1",tClassName,1)
107
107
108
-
;We'll change the targetPropertyName setting
108
+
;We change the targetPropertyName setting
109
109
set $ListUpdate(propExprt.settings,1) ="codeAccepted"
110
110
do ##class(SampleApps.Serialize.MapTesting).SetMappedPropSettings("code",propExprt,"MAP1",tClassName,1)
111
111
@@ -116,8 +116,6 @@ We can have as much mapping definitions for a class as we need. An easy way to s
116
116
117
117
```
118
118
119
-
120
-
121
119
We also have the possibility of changing a bit the way in which default map `MAP0` is generated :
122
120
* Change the name of default map.
123
121
* Use parameter `EXPTDEFAULTMAP` to indicate a name for default map before compiling the class
@@ -128,30 +126,26 @@ We also have the possibility of changing a bit the way in which default map `MAP
128
126
* Drill down levels
129
127
* Use `EXPTDRILLDOWN`To indicate up to what number of levels that the export/import logic should follow through object references. 0 means no drill down. A positive number(n) means to drill down n times through the chain of references.
130
128
129
+
## How did it work the default mechanism?
131
130
131
+
Both methods, `Export` and `Import` will call the generated methods: `exportStd` and `importStd` respectively. These two methods will go through the global `^MAPS` and `^MAPSREV` respectively, looking for the properties to export /import and applying the required conversions.
132
+
Both methods work over an already instantiated method. This is particularly interesting for import, as we can have an object in memory with some data already and import the rest of the data from a serialized object. The import mechanism will replace with the new content the properties contained in the serialization but will preserve other properties already set in the instance that are not included in the serialization that we import.
132
133
133
-
How did it work the default mechanism?
134
-
135
-
Both methods, export and Import will call the generated methods: exportStd and imoortStd respectively. These two methods will go through the global ^MAPS and ^MAPSREV respectively, looking for the properties to export /import and applying the required conversions.
136
-
Both methods work over an already instantiated method. This is particularly important for import, as we can have an object in memory with some data already and import the rest of the data from a serialized object. The import mechanism will replace with the new content the properties contained in the serialization but will preserve other properties already set in the instance that are not included in the serialization that we import.
137
-
138
-
Example:
134
+
This way of working give us the flexibility of using different mappings using the same autogenerated code but it can have a penalty in performance if we use it massively in loops or in very high concurrency use cases. Anyway, better test in such scenarios.
139
135
140
-
<< import a JSON with just some properties in an object where we already have some others set >>>
136
+
## Some considerations about performance
141
137
142
-
This way of working give us the flexibility of using different mappings using the same autogenerated code but it can have a penalty in performance if we use it massively in loops or in very high concurrency use cases. Anyway,better test in such scenarios.
138
+
As it was already mentioned, the default mechanism resolve the mapping sets at real time, trasversing a global to set the properties to export/import targets. That means that this mechanism will always be slower than if we already had that settings resolved at compile time. In order to provide that functionality, we can use the Template classes.
143
139
144
-
Some considerations about performance
140
+
## What are the template classes for?
145
141
146
-
As we already mentioned, the default mechanism resolve the mapping sets at real time, trasversing a global to set the properties to export/import targets. That means that this mechanism will always be slower than if we already had that settings resolved at compile time. In order to provide that functionality, we can use the Template classes.
147
-
148
-
What are the template classes for?
149
-
150
-
The templates classes allow us to generate the logic to export /import at compile time.
142
+
The templates classes allow us to generate the logic to export/import at compile time.
151
143
This have benefits over performance but comes at the price of having to use a different class for each type of serialization format and mapping.
152
144
153
145
Anyway, the primary class is not affected and doesn't have to be changed no matter how many templates define to handle the serialization of its objects.
154
146
147
+
148
+
155
149
Example :
156
150
157
151
<<< define and use different template classes, for different maps in JSON and also for different serialization (CSV)
0 commit comments