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 8 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
56 changes: 56 additions & 0 deletions src/main/configurations/Translate/Common/xsl/AddBaseProfile.xsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

<xsl:param name="baseProfile" />

<xsl:template match="/">
<xsl:call-template name="processNode">
<xsl:with-param name="node" select="/" />
</xsl:call-template>
</xsl:template>

<xsl:template name="processNode">
<xsl:param name="node" />

<xsl:for-each select="$node/*">
<xsl:choose>
<xsl:when test="$baseProfile//*[name() = name(current())]">
<xsl:choose>
<xsl:when test="count(child::*) = 0">
<xsl:copy>
<xsl:value-of select="text()" />
</xsl:copy>
</xsl:when>
<xsl:otherwise>
<xsl:choose>
<xsl:when test="count(child::*) &gt; 0">
<xsl:copy>
<xsl:call-template name="processNode">
<xsl:with-param name="node" select="." />
</xsl:call-template>
</xsl:copy>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="." />
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="." />
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>

<xsl:for-each
select="$baseProfile/profile//*">
<xsl:if test="parent::*/@path = $node/@path">
<xsl:if test="not($node/*[@path = current()/@path])">
<xsl:copy-of select="." />
</xsl:if>
</xsl:if>
</xsl:for-each>

</xsl:template>

</xsl:stylesheet>
38 changes: 38 additions & 0 deletions src/main/configurations/Translate/Common/xsl/AddPathAttribute.xsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" />
<xsl:strip-space elements="*" />

<xsl:template match="text()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*" />
</xsl:copy>
</xsl:template>

<xsl:template match="*">
<xsl:copy>
<xsl:attribute name="path">
<xsl:call-template name="genPath" />
</xsl:attribute>
<xsl:apply-templates
select="node()|@*" />
</xsl:copy>
</xsl:template>

<xsl:template name="genPath">
<xsl:param name="prevPath" />
<xsl:variable name="currPath"
select="concat('/',name(),'[',
count(preceding-sibling::*[name() = name(current())])+1,']',$prevPath)" />
<xsl:for-each
select="parent::*">
<xsl:call-template name="genPath">
<xsl:with-param name="prevPath" select="$currPath" />
</xsl:call-template>
</xsl:for-each>
<xsl:if
test="not(parent::*)">
<xsl:value-of select="$currPath" />
</xsl:if>
</xsl:template>

</xsl:stylesheet>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output indent="yes" />

<xsl:template match="/">
<xsl:copy-of select="root/profile[zaakTypeIdentificatie = '*']" />
</xsl:template>

</xsl:stylesheet>
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<!-- Identity template: copy all nodes and attributes unchanged -->
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>

<!-- Template to remove a specific attribute -->
<xsl:template match="@path">
<!-- Do nothing, effectively removing the attribute -->
</xsl:template>

</xsl:stylesheet>
12 changes: 12 additions & 0 deletions src/main/configurations/Translate/Common/xsl/RemoveResultTags.xsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output indent='yes' />

<xsl:template match="/">
<root>
<xsl:copy-of select="//profile" />
</root>
</xsl:template>

</xsl:stylesheet>
2 changes: 2 additions & 0 deletions src/main/configurations/Translate/Configuration.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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 @@ -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
@@ -0,0 +1,62 @@
<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="IsXml" />
</LocalFileSystemPipe>

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

<JsonPipe name="JsonToXml" storeResultInSessionKey="profiles"/>

<ForEachChildElementPipe name="AddPathAttributeToEachProfile"
getInputFromSessionKey="profiles" targetElement="profile">
<XsltSender styleSheetName="Common\xsl\AddPathAttribute.xsl" indentXml="true"
omitXmlDeclaration="true">
<Param name="baseProfile" sessionKey="baseProfile" type="DOMDOC" />
DelanoWAF marked this conversation as resolved.
Show resolved Hide resolved
</XsltSender>
</ForEachChildElementPipe>

<XsltPipe name="RemoveResultTags" styleSheetName="Common\xsl\RemoveResultTags.xsl" storeResultInSessionKey="profiles"/>

<XsltPipe name="ExtractBaseProfile" styleSheetName="Common\xsl\ExtractBaseProfile.xsl"
omitXmlDeclaration="true" storeResultInSessionKey="baseProfile" outputType="XML">
</XsltPipe>

<!-- Failure here indicates missing baseProfile, or more than one baseProfile -->
<XmlWellFormedCheckerPipe name="checkBaseProfile">
<Forward name="success" path="AddBaseProfileToEachProfile" />
<Forward name="failure" path="EXCEPTION"/>
DelanoWAF marked this conversation as resolved.
Show resolved Hide resolved
</XmlWellFormedCheckerPipe>

<ForEachChildElementPipe name="AddBaseProfileToEachProfile"
getInputFromSessionKey="profiles" targetElement="profile">
<XsltSender styleSheetName="Common\xsl\AddBaseProfile.xsl" indentXml="true"
omitXmlDeclaration="true">
<Param name="baseProfile" sessionKey="baseProfile" type="DOMDOC" />
</XsltSender>
</ForEachChildElementPipe>

<XsltPipe name="RemoveResultTags2" styleSheetName="Common\xsl\RemoveResultTags.xsl"/>
<XsltPipe name="RemovePathAttribute" styleSheetName="Common\xsl\RemovePathAttribute.xsl"/>
</Pipeline>
</Adapter>
</Module>
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 7 additions & 3 deletions src/main/configurations/Translate/Profiles.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
{
"profile": [
{
"zaakTypeIdentificatie": "B9999",
"zaakTypeIdentificatie": "*",
"endCaseEndDate": {
"coalesceResultaat": "Onbekend"
},
"coalesceResultaat": "Onbekend",
"testval": "testvalue"
}
},
{
"zaakTypeIdentificatie": "B9999",
"endDateAndResultLastStatus": {
"coalesceResultaat": "Onbekend"
}
Expand Down
Loading