Skip to content

Commit

Permalink
feat: rol_create database implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
MLenterman committed Oct 11, 2023
1 parent 5711a5b commit 8f9dd84
Show file tree
Hide file tree
Showing 13 changed files with 1,015 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/main/configurations/Zaken API - 1.2.0/Configuration.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
<!ENTITY resultaat_partial_update SYSTEM "./configuration_zaken_resultaat_partial_update.xml">
<!ENTITY rol_list SYSTEM "./configuration_zaken_rol_list.xml">
<!ENTITY rol_create SYSTEM "./configuration_zaken_rol_create.xml">
<!ENTITY rol_create_db SYSTEM "./configuration_zaken_rol_create_db.xml">
<!ENTITY rol_create_proxy SYSTEM "./configuration_zaken_rol_create_proxy.xml">
<!ENTITY rol_read SYSTEM "./configuration_zaken_rol_read.xml">
<!ENTITY rol_delete SYSTEM "./configuration_zaken_rol_delete.xml">
<!ENTITY status_list SYSTEM "./configuration_zaken_status_list.xml">
Expand Down Expand Up @@ -70,6 +72,8 @@
&resultaat_partial_update;
&rol_list;
&rol_create;
&rol_create_db;
&rol_create_proxy;
&rol_read;
&rol_delete;
&status_list;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ zaak_create.active=false
zaak_create_db.active=true
zaak_create_proxy.active=false

rol_create.active=false
rol_create_db.active=true
rol_create_proxy.active=false

zgw.zaken-api.db-backend=true
zgw.zaken-api.proxy-backend=false

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
>
<Adapter
name="rol_create"

active="${rol_create.active}"
>
<Receiver name="rol_create">
<ApiListener
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
<Module
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../FrankConfig.xsd"
>
<Adapter
name="rol_create_db"
active="${rol_create_db.active}"
>
<Receiver name="rol_create">
<ApiListener
name="rol_create"
method="POST"
uriPattern="/zaken/api/v1/rollen"
headerParams="Host,X-Forwarded-Proto"
produces="JSON"
consumes="JSON"
/>
</Receiver>
<Pipeline>
<Exits>
<Exit name="Created" state="SUCCESS" code="201" />
<Exit name="BadRequest" state="ERROR" code="400" />
<Exit name="Unauthorized" state="ERROR" code="401" />
<Exit name="Forbidden" state="ERROR" code="403" />
<Exit name="NotAcceptable" state="ERROR" code="406" />
<Exit name="Conflict" state="ERROR" code="409" />
<Exit name="Gone" state="ERROR" code="410" />
<Exit name="PreconditionFailed" state="ERROR" code="412" />
<Exit name="UnsupportedMediaType" state="ERROR" code="415" />
<Exit name="TooManyRequests" state="ERROR" code="429" />
<Exit name="InternalServerError" state="ERROR" code="500" />
</Exits>

<JsonPipe
name="JsonToXml"
storeResultInSessionKey="orginalMessageXml"
>
<Forward name="success" path="UnwrapOpenZaakEnvelopeToSingle"/>
</JsonPipe>

<XsltPipe
name="UnwrapOpenZaakEnvelopeToSingle"
styleSheetName="Zgw/UnwrapOpenZaakApiEnvelopeToSingle.xslt"
>
<Param name="Type" value="ZgwRol"/>
<Forward name="success" path="GenerateUuid"/>
<Forward name="error" path="InternalServerError"/>
</XsltPipe>

<UUIDGeneratorPipe
name="GenerateUuid"
preserveInput="true"
storeResultInSessionKey="uuid"
>
<Forward name="success" path="CreateZgwRol"/>
<Forward name="error" path="InternalServerError"/>
</UUIDGeneratorPipe>

<!--
TODO: Add omschrijving and omschrijvingGeneriek fields with values from the provided roltype
https://github.com/wearefrank/openforms2bpel/issues/15
-->
<XsltPipe
name="CreateZgwRol"
styleSheetName="Zgw/Zaken/Model/ZgwRol.xslt"
storeResultInSessionKey="ZgwRol"
>
<Param name="Uuid" sessionKey="uuid"/>
<Param name="Registratiedatum" xpathExpression="string($NowDateTime)" >
<Param name="NowDateTime" pattern="{now}" type="DATETIME" />
</Param>
<Forward name="success" path="InsertZgwRolSender"/>
<Forward name="error" path="InternalServerError"/>
</XsltPipe>

<SenderPipe
name="InsertZgwRolSender"
>
<FixedQuerySender
name="InsertZgwRolFixedQuerySender"
query="INSERT INTO ROL (ID, DATA) VALUES (?{id}, ?{data})"
queryType="OTHER"
/>
<Param name="id" sessionKey="uuid" />
<Param name="data" />
<Forward name="success" path="SelectZgwRolSender" />
<Forward name="exception" path="InternalServerError" />
</SenderPipe>

<SenderPipe
name="SelectZgwRolSender"
>
<FixedQuerySender
name="SelectZgwRolFixedQuerySender"
query="SELECT PK,ID,DATA FROM ROL WHERE ID = ?{id}"
queryType="SELECT"
/>
<Param name="id" sessionKey="uuid"/>
<Forward name="success" path="StoreSubstitutionVars" />
<Forward name="exception" path="InternalServerError" />
</SenderPipe>

<PutInSessionPipe
name="StoreSubstitutionVars"
>
<Param name="scheme" sessionKey="headers" xpathExpression="/headers/header[@name = 'X-Forwarded-Proto']/text()" defaultValue="http" />
<Param name="host" sessionKey="headers" xpathExpression="/headers/header[@name = 'Host']/text()" />
<Param name="ZgwRol" xpathExpression="/result/rowset/row[@number = '0']/field[@name = 'DATA']/text()" />
<Forward name="success" path="EnrichZgwRol" />
<Forward name="exception" path="InternalServerError" />
</PutInSessionPipe>

<XsltPipe
name="EnrichZgwRol"
styleSheetName="Zgw/Zaken/Model/ZgwRol.xslt"
getInputFromSessionKey="ZgwRol"
>
<Param name="Url" pattern="{scheme}://{host}/zaken/api/v1/zaken/{uuid}" />
<Forward name="success" path="XmlToJson"/>
<Forward name="error" path="InternalServerError"/>
</XsltPipe>

<!--
TODO: Refactor other betrokkeneType XSD's and implement switch based on betrokkeneType delimiter for those XSD's
https://github.com/wearefrank/openforms2bpel/issues/16
-->
<Json2XmlValidatorPipe
name="XmlToJson"
schema="Zgw/Zaken/Model/ZgwRolNatuurlijkPersoon.xsd"
outputFormat="JSON"
deepSearch="true"
throwException="true"
>
<Forward name="success" path="Created"/>
<Forward name="error" path="InternalServerError"/>
</Json2XmlValidatorPipe>
</Pipeline>
</Adapter>
</Module>
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<Module
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../FrankConfig.xsd"
>
<Adapter
name="rol_create_proxy"
active="${rol_create_proxy.active}"
>
<Receiver name="rol_create">
<ApiListener
name="rol_create"
method="POST"
uriPattern="/zaken/api/v1/rollen"
headerParams="Host"
produces="JSON"
consumes="JSON"
/>
</Receiver>
<Pipeline>
<Exits>
<Exit name="Created" state="SUCCESS" code="201" />
<Exit name="BadRequest" state="ERROR" code="400" />
<Exit name="Unauthorized" state="ERROR" code="401" />
<Exit name="Forbidden" state="ERROR" code="403" />
<Exit name="NotAcceptable" state="ERROR" code="406" />
<Exit name="Conflict" state="ERROR" code="409" />
<Exit name="Gone" state="ERROR" code="410" />
<Exit name="PreconditionFailed" state="ERROR" code="412" />
<Exit name="UnsupportedMediaType" state="ERROR" code="415" />
<Exit name="TooManyRequests" state="ERROR" code="429" />
<Exit name="InternalServerError" state="ERROR" code="500" />
</Exits>

<!-- <FixedResultPipe name="Helloworld" returnString="{&quot;count&quot;:123,&quot;next&quot;:&quot;http://api.example.org/accounts/?page=4&quot;,&quot;previous&quot;:&quot;http://api.example.org/accounts/?page=2&quot;,&quot;results&quot;:[{&quot;url&quot;:&quot;string&quot;,&quot;uuid&quot;:&quot;3fa85f64-5717-4562-b3fc-2c963f66afa6&quot;,&quot;zaak&quot;:&quot;string&quot;,&quot;resultaattype&quot;:&quot;string&quot;,&quot;toelichting&quot;:&quot;string&quot;}]}" /> -->

<XsltPipe
name="SetRolUrl"
styleSheetName="Common/xsl/CreateURL.xsl"
getInputFromFixedValue="&lt;dummy/&gt;"
storeResultInSessionKey="UrlParam"
>
<Param name="BaseUrl" value="${zaakbrug.staging.zaken-api.root-url}" />
<Param name="UrlParam" sessionKey="uri" />
<Forward name="success" path="CreateRolSender"/>
</XsltPipe>

<SenderPipe name="CreateRolSender"
getInputFromSessionKey="originalMessage">
<HttpSender name="CreateRolSender"
methodType="POST"
headersParams="Authorization,Accept-Crs,Content-Crs,Accept,Host"
timeout="${zaakbrug.zgw.zaken-api.timeout}"
maxExecuteRetries="5"
contentType="application/json">
<Param name="url" sessionKey="UrlParam" />
<Param name="Accept-Crs" value="EPSG:4326" />
<Param name="Accept" value="application/json" />
<Param name="Content-Crs" value="EPSG:4326" />
<Param name="Host" sessionKey="headers" xpathExpression="/headers/header[@name = 'Host']/text()" />
<Param name="Authorization" value="Bearer @@zaken-api.jwt@@"/>
</HttpSender>

<Forward name="201" path="Created" />
<Forward name="400" path="BadRequest" />
<Forward name="401" path="Unauthorized" />
<Forward name="403" path="Forbidden" />
<Forward name="406" path="NotAcceptable" />
<Forward name="409" path="Conflict" />
<Forward name="410" path="Gone" />
<Forward name="412" path="PreconditionFailed" />
<Forward name="415" path="UnsupportedMediaType" />
<Forward name="429" path="TooManyRequests" />
<Forward name="500" path="InternalServerError" />
</SenderPipe>
</Pipeline>
</Adapter>
</Module>
15 changes: 15 additions & 0 deletions src/main/configurations/bpel/BpelDatabaseChangelog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,19 @@
</column>
</createTable>
</changeSet>

<changeSet id="Openforms2bpel:1.3" author="MLenterman">
<comment>Add rol table</comment>
<createTable tableName="ROL">
<column name="PK" type="INTEGER" autoIncrement="true">
<constraints primaryKey="true" nullable="false" primaryKeyName="PK_ROL"/>
</column>
<column name="ID" type="VARCHAR(36)">
<constraints nullable="false" unique="true" />
</column>
<column name="DATA" type="CLOB">
<constraints nullable="false" />
</column>
</createTable>
</changeSet>
</databaseChangeLog>
Loading

0 comments on commit 8f9dd84

Please sign in to comment.