Skip to content

Commit f0529f7

Browse files
authored
Merge pull request #140 from InseeFr/2.1.6-rc1-live
2.1.6 rc1 live
2 parents f8e3d60 + 6fcbfb5 commit f0529f7

File tree

8 files changed

+262
-3111
lines changed

8 files changed

+262
-3111
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ target/
44
!**/src/main/**/target/
55
!**/src/test/**/target/
66
!**/src/main/resources/application.properties
7-
7+
*.log
88
### STS ###
99
.apt_generated
1010
.classpath

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
</parent>
1212
<groupId>fr.insee.rmes</groupId>
1313
<artifactId>ddi-access-services</artifactId>
14-
<version>2.1.5</version>
14+
<version>2.1.6-rc1</version>
1515
<name>DDI Access Services</name>
1616
<description>Rest API to access to Colectica repository services</description>
1717
<properties>

src/main/resources/application.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ logging:
8686
rollingpolicy:
8787
max-file-size: 1MB
8888
file:
89-
name: XXXX
89+
name: output.log
9090

9191
auth:
9292
api:

src/main/resources/xslTransformerFiles/ddiDatarelationship2Json.xsl

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
44
xmlns:l="ddi:logicalproduct:3_3"
55
xmlns:r="ddi:reusable:3_3"
6-
>
6+
xmlns:ext="java:java.lang.System">
77

88
<xsl:output method="text" indent="yes" />
99

@@ -21,13 +21,20 @@
2121
<xsl:variable name="dataRelation_URN" select="r:URN" />
2222
<xsl:variable name="dataRelation_name" select="l:DataRelationshipName/r:String" />
2323
<xsl:variable name="dataRelation_libelle_fr" select="r:Label/r:Content" />
24+
<xsl:variable name="dataRelation_Version" select="r:Version" />
25+
<xsl:variable name="dataRelation_Versiondate" select="@versionDate" />
26+
2427

2528
<xsl:if test="position() > 1">
2629
<xsl:text>,&#10;</xsl:text>
2730
</xsl:if>
2831

2932
<xsl:text> {&#10; "id": "</xsl:text>
3033
<xsl:value-of select="$dataRelation_URN" />
34+
<xsl:text>",&#10; "version": "</xsl:text>
35+
<xsl:value-of select="$dataRelation_Version" />
36+
<xsl:text>",&#10; "versionDate": "</xsl:text>
37+
<xsl:value-of select="$dataRelation_Versiondate" />
3138
<xsl:text>",&#10; "nom": "</xsl:text>
3239
<xsl:value-of select="$dataRelation_name" />
3340
<xsl:text>",&#10; "label": [&#10; { "contenu": "</xsl:text>
@@ -38,6 +45,10 @@
3845
<xsl:variable name="VariableUsed_Agency" select="r:Agency" />
3946
<xsl:variable name="VariableUsed_ID" select="r:ID" />
4047
<xsl:variable name="VariableUsed_Version" select="r:Version" />
48+
49+
50+
51+
<!-- isGeographic="true"-->
4152
<xsl:variable name="VariableUsed_URN" select="concat('urn:ddi:', $VariableUsed_Agency, ':', $VariableUsed_ID, ':', $VariableUsed_Version)" />
4253

4354
<xsl:variable name="var" select="key('varByURN', $VariableUsed_URN)" />
@@ -53,14 +64,38 @@
5364
<xsl:value-of select="normalize-space($var/r:Label/r:Content)" />
5465
<xsl:text>", "langue": "fr" },&#10; { "contenu": "", "langue": "en" }&#10; ],&#10; "ordre": "</xsl:text>
5566
<xsl:number />
56-
<xsl:text>",&#10; "representation": </xsl:text>
57-
67+
<xsl:text>",&#10; "role": "</xsl:text>
68+
<xsl:choose>
69+
<xsl:when test="not(normalize-space($var/l:VariableRepresentation/l:VariableRole))">
70+
<!-- Si la valeur est vide, appliquer une valeur par défaut -->
71+
<xsl:value-of select="'Mesure'" />
72+
</xsl:when>
73+
<xsl:otherwise>
74+
<!-- Sinon, afficher la valeur existante -->
75+
<xsl:value-of select="normalize-space($var/l:VariableRepresentation/l:VariableRole)" />
76+
</xsl:otherwise>
77+
</xsl:choose>
78+
<xsl:text>",&#10; "variablegeographique": "</xsl:text>
79+
<xsl:value-of select="normalize-space($var/@isGeographic)" />
80+
<xsl:text>",&#10; "representation": {</xsl:text>
81+
<xsl:text>"type":</xsl:text>
5882
<xsl:choose>
5983
<xsl:when test="$var/l:VariableRepresentation/r:CodeRepresentation">
6084
<xsl:text>"codes"</xsl:text>
6185
</xsl:when>
6286
<xsl:when test="$var/l:VariableRepresentation/r:NumericRepresentation">
63-
<xsl:text>"numerique"</xsl:text>
87+
<xsl:variable name="NumericTypeCode" select="$var/l:VariableRepresentation/r:NumericRepresentation/r:NumericTypeCode" />
88+
<xsl:choose>
89+
<xsl:when test="not(normalize-space($NumericTypeCode))">
90+
<!-- Si la valeur est vide, appliquer une valeur par défaut -->
91+
<xsl:text>"numerique"</xsl:text>
92+
</xsl:when>
93+
<xsl:otherwise>
94+
<!-- Sinon, afficher la valeur existante -->
95+
<xsl:text>"</xsl:text><xsl:value-of select="$NumericTypeCode" /><xsl:text>"</xsl:text>
96+
</xsl:otherwise>
97+
</xsl:choose>
98+
6499
</xsl:when>
65100
<xsl:when test="$var/l:VariableRepresentation/r:TextRepresentation">
66101
<xsl:text>"texte"</xsl:text>
@@ -72,7 +107,7 @@
72107
<xsl:text>"null"</xsl:text>
73108
</xsl:otherwise>
74109
</xsl:choose>
75-
110+
<xsl:text>}</xsl:text>
76111
<!-- Process Code Representation -->
77112
<xsl:if test="$var/l:VariableRepresentation/r:CodeRepresentation">
78113
<xsl:text>,&#10; "controles": { "codes": [&#10;</xsl:text>

src/test/java/fr/insee/rmes/tocolecticaapi/controller/GetItemTest.java

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,27 +35,41 @@ class GetItemTest {
3535
@MockitoBean
3636
private ColecticaService colecticaService;
3737

38+
/***
39+
* This test will :
40+
* - use the method which generates the json from the DDI (colecticaService.searchColecticaInstanceByUuid()). This
41+
* method will use a hard coded DDI file /getItemTest/physicalInstance.xml.
42+
* - check that the json generated is conform with the expected json
43+
* @throws Exception
44+
*/
3845
@Test
3946
void whenGetDataRelationshipWithUuid_shouldReturnRightJson() throws Exception {
40-
String uuid="34abf2d5-f0bb-47df-b3d2-42ff7f8f5874";
47+
String uuid="9a7f1abd-10ec-48f3-975f-fcfedb7dc4cd";
4148
var dataRelationShipEndpoint="/Item/ddiFragment/"+uuid+"/dataRelationship";
4249
when(colecticaService.searchColecticaInstanceByUuid(uuid)).thenReturn(read("/getItemTest/physicalInstance.xml"));
4350
mockMvc.perform(get(dataRelationShipEndpoint).accept(MediaType.APPLICATION_JSON))
4451
.andExpect(status().isOk())
4552
.andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE))
46-
.andExpect(content().json(read("/getItemTest/34abf2d5-f0bb-47df-b3d2-42ff7f8f5874_expected.json")));
53+
.andExpect(content().json(read("/getItemTest/9a7f1abd-10ec-48f3-975f-fcfedb7dc4cd_expected.json")));
4754
}
4855

56+
/***
57+
* This test will :
58+
* - use the method which generates the json from the DDI (colecticaService.searchColecticaInstanceByUuid()). This
59+
* method will use a hard coded DDI file /getItemTest/physicalInstance.xml.
60+
* - check that the json generated is conform with the expected json
61+
* @throws Exception
62+
*/
4963
@Test
5064
void whenGetDataRelationshipWithUuidAndVersion_shouldReturnRightJson() throws Exception {
51-
String uuid="34abf2d5-f0bb-47df-b3d2-42ff7f8f5874";
65+
String uuid="9a7f1abd-10ec-48f3-975f-fcfedb7dc4cd9a7f1abd-10ec-48f3-975f-fcfedb7dc4cd";
5266
int version = 2;
5367
var dataRelationShipEndpoint="/Item/ddiFragment/"+uuid+"/"+version+"/dataRelationship";
5468
when(colecticaService.searchColecticaInstanceByUuid(uuid+"/"+version)).thenReturn(read("/getItemTest/physicalInstance.xml"));
5569
mockMvc.perform(get(dataRelationShipEndpoint).accept(MediaType.APPLICATION_JSON))
5670
.andExpect(status().isOk())
5771
.andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE))
58-
.andExpect(content().json(read("/getItemTest/34abf2d5-f0bb-47df-b3d2-42ff7f8f5874_expected.json")));
72+
.andExpect(content().json(read("/getItemTest/9a7f1abd-10ec-48f3-975f-fcfedb7dc4cd_expected.json")));
5973
}
6074

6175

0 commit comments

Comments
 (0)