Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: provide translation profile defaults for configuring common settings appliyng to all zaaktype related custom translation profiles #296

Merged
merged 31 commits into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
71255ce
feat: add full baseProfile system
DelanoWAF Mar 25, 2024
eb66d8d
feat: add cache
DelanoWAF Mar 26, 2024
d0ae399
refactor: add baseProfile with example values
DelanoWAF Mar 26, 2024
f5748e2
refactor: rename xslt file
DelanoWAF Mar 26, 2024
0895f33
refactor: add active property
DelanoWAF Mar 26, 2024
33c6249
Merge branch 'master' into 282-add-support-for-a-base-translation-pro…
DelanoWAF Mar 26, 2024
de4e4b6
fix: incorrect styleSheetName attribute
DelanoWAF Mar 27, 2024
1e5df31
refactor: add baseProfile check
DelanoWAF Mar 27, 2024
8df9a24
refactor: add error handling
DelanoWAF Mar 29, 2024
ca8f051
refactor: remove unnecessary check
DelanoWAF Mar 29, 2024
7e3204d
refactor: remove excess param
DelanoWAF Mar 29, 2024
88fc6eb
style: formatting
DelanoWAF Mar 29, 2024
939a97c
refactor: redo profiles structure
DelanoWAF Mar 29, 2024
1003d71
feat: add compatibility for new profiles structure
DelanoWAF Apr 2, 2024
a26f224
style: align formatting with other configurations
DelanoWAF Apr 2, 2024
42ffd03
refactor: relocate XSL files
DelanoWAF Apr 2, 2024
646d399
refactor: remove excess xsl
DelanoWAF Apr 2, 2024
7338c3f
refactor: integrate baseProfile into Overrides configuration
DelanoWAF Apr 2, 2024
d82ea54
feat: add overrides array compatibility
DelanoWAF Apr 4, 2024
c778339
Merge branch 'master' into 282-add-support-for-a-base-translation-pro…
DelanoWAF Apr 4, 2024
5a5c8d7
refactor: restore Profiles.json to original state
DelanoWAF Apr 4, 2024
465f910
refactor: add required minimum profileDefault
DelanoWAF Apr 4, 2024
0dc6e43
feat: add error handling
DelanoWAF Apr 4, 2024
7a2543d
docs: add comments to main XSLT
DelanoWAF Apr 4, 2024
06bddbe
feat: add calls to defaults system
DelanoWAF Apr 4, 2024
226017f
fix: add missing pipe
DelanoWAF Apr 4, 2024
ec47f7a
refactor to javascript solution
MLenterman Apr 17, 2024
3fa1034
readme profile defaults section
MLenterman Apr 17, 2024
6fc385b
Merge branch 'master' into 282-add-support-for-a-base-translation-pro…
MLenterman Apr 17, 2024
0bcdeab
fix error when elements not present in profiles.json
MLenterman Apr 17, 2024
89e3e46
add error feedback for errors during merging
MLenterman Apr 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 92 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,98 @@ The syntax for variable substitution is as follows {[variable-name][:formatting-

## Translation Profiles

### Profile Defaults
Profile defaults can be used to configure common translation profile settings. The settings configured in the `profileDefaults` section are applied to **all** zaaktypen. When a regular translation profile for a specific zaaktype is also configured, the settings are merged together. The more specific per zaaktype translation profile will always override any overlapping settings from the `profileDefaults` section. Items in array's like `valuesOverrides` will be combined instead, unless there is an overlapping key. Here the more specific per zaaktype translation profile will also always override any overlapping keys from the ones in the `profileDefaults` section.

For example, the following configuration:
```json
{
"profileDefaults": {
"endCaseEndDate": {
"coalesceResultaat": "Onbekend",
},
"valueOverrides": [
{
"key": "zgw.zaken-api.zaken.zaak.toelichting",
"value": "toelichting from profileDefaults"
}
]
},
"profile": [
{
"zaakTypeIdentificatie": "B9999",
"endDateAndResultLastStatus": {
"coalesceResultaat": "Onbekend"
},
"valueOverrides": [
{
"key": "zgw.zaken-api.zaken.zaak.communicatiekanaal",
"value": "http://example.com"
}
]
},
{
"zaakTypeIdentificatie": "B1026",
"endCaseEndDate": {
"coalesceResultaat": "Toegekend"
},
"valueOverrides": [
{
"key": "zgw.zaken-api.zaken.zaak.toelichting",
"value": "toelichting from specific translation profile"
}
]
}
]
}
```

Will result in:
```json
{
"profile": [
{
"zaakTypeIdentificatie": "B9999",
// highlight-start
"endCaseEndDate": {
"coalesceResultaat": "Onbekend",
},
// highlight-end
"endDateAndResultLastStatus": {
"coalesceResultaat": "Onbekend"
},
"valueOverrides": [
// highlight-start
{
"key": "zgw.zaken-api.zaken.zaak.toelichting",
"value": "toelichting from profileDefaults"
},
// // highlight-end
{
"key": "zgw.zaken-api.zaken.zaak.communicatiekanaal",
"value": "http://example.com"
}
]
},
{
"zaakTypeIdentificatie": "B1026",
"endCaseEndDate": {
// highlight-next-line
"coalesceResultaat": "Toegekend"
},
"valueOverrides": [
{
"key": "zgw.zaken-api.zaken.zaak.toelichting",
// highlight-next-line
"value": "toelichting from specific translation profile"
}
]
}
]
}
```


### Value Overrides
The translations from ZDS/StUF to ZGW are made to be as neutral as possible. With value overrides it is possible to diverge from the generic translation defaults or add static properties.

Expand Down
6 changes: 4 additions & 2 deletions src/main/configurations/Translate/Configuration.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<!ENTITY GetZgwZaakTypeByIdentificatie SYSTEM "./Configuration_GetZgwZaakTypeByIdentificatie.xml">
<!ENTITY HandleZgwZaakInformatieObjecten SYSTEM "./Configuration_HandleZgwZaakInformatieObjecten.xml">
<!ENTITY ImportFromLocalFS SYSTEM "./Configuration_ImportFromLocalFS.xml">
<!ENTITY ImportValueOverridesFromTranslationProfile SYSTEM "./Configuration_ImportValueOverridesFromTranslationProfile.xml">
<!ENTITY ApplyTranslationProfileValueOverrides SYSTEM "./Configuration_ApplyTranslationProfileValueOverrides.xml">
<!ENTITY MapZdsDeelzakenFromZgwDeelzaken SYSTEM "./Configuration_MapZdsDeelzakenFromZgwDeelzaken.xml">
<!ENTITY MapZdsHeeftFromZgwStatus SYSTEM "./Configuration_MapZdsHeeftFromZgwStatus.xml">
<!ENTITY MapZdsRelevanteAndereZaakFromZgwRelevanteAndereZaken SYSTEM "./Configuration_MapZdsRelevanteAndereZaakFromZgwRelevanteAndereZaken.xml">
Expand All @@ -55,6 +55,7 @@
<!ENTITY PostZaak SYSTEM "./Configuration_PostZaak.xml">
<!ENTITY PostZgwLock SYSTEM "./Configuration_PostZgwLock.xml">
<!ENTITY PutZgwZaakDocument SYSTEM "./Configuration_PutZgwZaakDocument.xml">
<!ENTITY ResolveProfileValues SYSTEM "./Configuration_ResolveProfileValues.xml">
<!ENTITY SetResultaatAndStatus SYSTEM "./Configuration_SetResultaatAndStatus.xml">
<!ENTITY SoapEndpointRouter_BeantwoordVraag SYSTEM "./Configuration_SoapEndpointRouter_BeantwoordVraag.xml">
<!ENTITY SoapEndpointRouter_BeantwoordVraag_v2 SYSTEM "./Configuration_SoapEndpointRouter_BeantwoordVraag_v2.xml">
Expand Down Expand Up @@ -116,7 +117,7 @@
&GetZgwZaakTypeByIdentificatie;
&HandleZgwZaakInformatieObjecten;
&ImportFromLocalFS;
&ImportValueOverridesFromTranslationProfile;
&ApplyTranslationProfileValueOverrides;
&MapZdsDeelzakenFromZgwDeelzaken;
&MapZdsHeeftFromZgwStatus;
&MapZdsRelevanteAndereZaakFromZgwRelevanteAndereZaken;
Expand All @@ -128,6 +129,7 @@
&PostZaak;
&PostZgwLock;
&PutZgwZaakDocument;
&ResolveProfileValues;
&SetResultaatAndStatus;
&SoapEndpointRouter_BeantwoordVraag;
&SoapEndpointRouter_BeantwoordVraag_v2;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<Module xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../FrankConfig.xsd">
<Adapter name="ImportValueOverridesFromTranslationProfile"
active="${ImportValueOverridesFromTranslationProfile.Active}"
<Adapter name="ApplyTranslationProfileValueOverrides"
active="${ApplyTranslationProfileValueOverrides.Active}"
description="">

<Receiver name="ImportValueOverridesFromTranslationProfile">
<JavaListener name="ImportValueOverridesFromTranslationProfile" returnedSessionKeys="Error" />
<Receiver name="ApplyTranslationProfileValueOverrides">
<JavaListener name="ApplyTranslationProfileValueOverrides" returnedSessionKeys="Error" />
</Receiver>

<Pipeline>
Expand All @@ -14,19 +14,17 @@
<Exit name="EXCEPTION" state="ERROR" />
</Exits>

<LocalFileSystemPipe name="ReadFile" action="read">
<Param name="filename" value="${configurations.directory}/Translate/Profiles.json" />
<Forward name="success" path="IsXml" />
</LocalFileSystemPipe>

<XmlWellFormedCheckerPipe name="IsXml">
<Forward name="success" path="EXIT" />
<Forward name="failure" path="JsonToXml" />
</XmlWellFormedCheckerPipe>

<JsonPipe name="JsonToXml">
<SenderPipe
name="ResolveProfileValuesSender"
>
<IbisLocalSender
name="ResolveProfileValuesLocalSender"
javaListener="ResolveProfileValues"
returnedSessionKeys="Error"
/>
<Forward name="success" path="ExtractValueOverridesFromTranslationProfile" />
</JsonPipe>
<Forward name="exception" path="EXCEPTION" />
</SenderPipe>

<XsltPipe
name="ExtractValueOverridesFromTranslationProfile"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@
>
<IbisLocalSender
name="ZaakBodyApplyValueOverridesFromTranslationProfileLocalSender"
javaListener="ImportValueOverridesFromTranslationProfile"
javaListener="ApplyTranslationProfileValueOverrides"
returnedSessionKeys="Error"
>
</IbisLocalSender>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<Module xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../FrankConfig.xsd">
<Adapter name="ResolveProfileValues"
active="${ResolveProfileValues.Active}"
description="">

<Receiver
name="ResolveProfileValues"
>
<JavaListener
name="ResolveProfileValues"
returnedSessionKeys="Error"
/>
</Receiver>

<Pipeline>
<Exits>
<Exit name="EXIT" state="SUCCESS" />
<Exit name="EXCEPTION" state="ERROR" />
</Exits>

<Cache />

<LocalFileSystemPipe
name="ReadFile"
action="read"
>
<Param name="filename" value="${configurations.directory}/Translate/Profiles.json" />
<Forward name="success" path="MergeProfileDefaultsWithProfilesSender" />
<Forward name="exception" path="MergeProfileDefaultsWithProfilesSender_TranslationProfilesMergeException" />
</LocalFileSystemPipe>

<SenderPipe
name="MergeProfileDefaultsWithProfilesSender"
storeResultInSessionKey="mergedProfiles"
>
<JavascriptSender
name="MergeProfileDefaultsWithProfilesJavascriptSender"
jsFileName="MergeProfileDefaultsWithProfiles.js"
jsFunctionName="mergeProfileDefaultsWithProfiles"
>
</JavascriptSender>
<Param name="profilesFile" />
<Forward name="success" path="JsonToXml" />
<Forward name="exception" path="MergeProfileDefaultsWithProfilesSender_TranslationProfilesMergeException" />
</SenderPipe>

<JsonPipe
name="JsonToXml"
>
<Forward name="success" path="EXIT" />
<Forward name="exception" path="MergeProfileDefaultsWithProfilesSender_TranslationProfilesMergeException" />
</JsonPipe>

<XsltPipe
name="MergeProfileDefaultsWithProfilesSender_TranslationProfilesMergeException"
getInputFromFixedValue="&lt;dummy/&gt;"
styleSheetName="Common/xsl/BuildError.xsl"
storeResultInSessionKey="Error"
>
<Param name="cause" sessionKey="Error" type="DOMDOC" />
<Param name="code" value="TechnicalError" /> <!-- codes: TechnicalError, TranslationError, ConfigurationError-->
<Param name="reason" value="Translation profiles merging operation failed" />
<Param name="details" pattern="{mergedProfiles}" ignoreUnresolvablePatternElements="true" />
<!-- <Param name="detailsXml" sessionKey="" type="DOMDOC" /> -->
<Forward name="success" path="EXCEPTION" />
<Forward name="exception" path="EXCEPTION" />
</XsltPipe>
</Pipeline>
</Adapter>
</Module>
Original file line number Diff line number Diff line change
Expand Up @@ -226,16 +226,15 @@

<XmlIfPipe name="CheckForResultaten"
xpathExpression="root/count = 0"
thenForwardName="GetProfileDataFromLocalFS_1"
thenForwardName="GetResolveProfileValuesSender_1"
elseForwardName="CheckForEindDatum">
</XmlIfPipe>

<SenderPipe name="GetProfileDataFromLocalFS_1">
<SenderPipe name="GetResolveProfileValuesSender_1">
<IbisLocalSender
name="CallImportFromLocalFS"
javaListener="ImportFromLocalFS"
name="CallResolveProfileValuesLocalSender_1"
javaListener="ResolveProfileValues"
returnedSessionKeys="Error">
<Param name="FileName" value="${FilePath_2}"/>
</IbisLocalSender>
<Forward name="success" path="GetCoalesceResultaat_1"/>
<Forward name="exception" path="EXCEPTION" />
Expand Down Expand Up @@ -290,17 +289,16 @@
<XmlIfPipe name="CheckForEindDatum"
getInputFromSessionKey="originalMessage"
xpathExpression="string-length(/*/object/einddatum) > 0 and $Beeindigd/beeindigd = 'false'"
thenForwardName="GetProfileDataFromLocalFS_2"
thenForwardName="GetResolveProfileValuesSender_2"
elseForwardName="PostStatusIterator">
<Param name="Beeindigd" sessionKey="Beeindigd" type="DOMDOC"/>
</XmlIfPipe>

<SenderPipe name="GetProfileDataFromLocalFS_2">
<SenderPipe name="GetResolveProfileValuesSender_2">
<IbisLocalSender
name="CallImportFromLocalFS"
javaListener="ImportFromLocalFS"
name="CallResolveProfileValuesLocalSender_2"
javaListener="ResolveProfileValues"
returnedSessionKeys="Error">
<Param name="FileName" value="${FilePath_2}"/>
</IbisLocalSender>
<Forward name="success" path="GetCoalesceResultaat_2"/>
<Forward name="exception" path="EXCEPTION" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ GetZgwZaakInformatieObjectByEnkelvoudigInformatieObjectUrl.Active=true
GetZgwZaakTypeByIdentificatie.Active=true
HandleZgwZaakInformatieObjecten.Active=true
ImportFromLocalFS.Active=true
ImportValueOverridesFromTranslationProfile.Active=true
ApplyTranslationProfileValueOverrides.Active=true
MapZdsDeelzakenFromZgwDeelzaken.Active=true
MapZdsHeeftFromZgwStatus.Active=true
MapZdsRelevanteAndereZaakFromZgwRelevanteAndereZaken.Active=true
Expand All @@ -64,6 +64,7 @@ Zaken_PostZgwStatus.Active=true
PostZaakAdapter.Active=true
PostZgwLock.Active=true
PutZgwZaakDocument.Active=true
ResolveProfileValues.Active=true
SetResultaatAndStatus.Active=true
SoapEndpointRouter_BeantwoordVraag.Active=true
SoapEndpointRouter_BeantwoordVraag_v2.Active=false
Expand Down
1 change: 1 addition & 0 deletions src/main/configurations/Translate/Profiles.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"profileDefaults": {},
"profile": [
{
"zaakTypeIdentificatie": "B9999",
Expand Down
35 changes: 35 additions & 0 deletions src/main/resources/MergeProfileDefaultsWithProfiles-orig.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
function mergeProfileDefaultsWithProfiles(profilesFile){
const json = JSON.parse(profilesFile);
const profileDefaults = {"profile": json["profileDefaults"]};
const profiles = { "profile": json["profile"] };

let result = {};
result["profile"] = [];
result["profileDefaults"] = json["profileDefaults"];

if(json["profileDefaults"] == null || json["profile"] == null){
return profilesFiles;
}

for(const pf of profiles.profile){
let pfres = {};
Object.keys(profileDefaults.profile)
.forEach(key => pfres[key] = profileDefaults.profile[key]);
Object.keys(pf)
.forEach(key => pfres[key] = pf[key]);

if(pf["valueOverrides"] == null){
result.profile.push(pfres);
break;
}

pfres["valueOverrides"] = pf.valueOverrides
.concat(profileDefaults.profile.valueOverrides
.filter((value) => pf.valueOverrides
.find((value2) => value2.key != value.key)));

result.profile.push(pfres);
}

return JSON.stringify(result, null, 4);
}
Loading
Loading