Update mapping
*Add support for multiple measvalue
*Fix failure when optional attribute swVersion missing
Issue-ID: DCAEGEN2-1038
Change-Id: I2408c0134a5d5bb2d90ad85ae2eac600fa89d52b
Signed-off-by: JoeOLeary <joseph.o.leary@est.tech>
diff --git a/src/main/resources/mapping.ftl b/src/main/resources/mapping.ftl
index 0b35c54..2819de6 100644
--- a/src/main/resources/mapping.ftl
+++ b/src/main/resources/mapping.ftl
@@ -69,19 +69,20 @@
<#macro measValuesList measInfo>
[
+<#list measInfo.measValue as measValue>
{
- "measObjInstId": "${measInfo.measValue.@measObjLdn[0]!}",
- "suspectFlag": "${measInfo.measValue.suspect[0]! "false"}",
+ "measObjInstId": "${measValue.@measObjLdn[0]!}",
+ "suspectFlag": "${measValue.suspect[0]! "false"}",
"measResults": [
- <#if measInfo.measValue.r?has_content>
- <#list measInfo.measValue.r as r>
+ <#if measValue.r?has_content>
+ <#list measValue.r as r>
{
"p": ${r.@p},
"sValue": "${r}"
}<#sep>,</#sep>
</#list>
<#else>
- <#list measInfo.measValue.measResults?split(" ") as r>
+ <#list measValue.measResults?split(" ") as r>
{
"p":${r?index+1},
"sValue": "${r}"
@@ -90,6 +91,8 @@
</#if>
]
}
+<#sep>,</#sep>
+</#list>
]
</#macro>
@@ -114,7 +117,7 @@
"granularityPeriod": ${measData.measInfo.granPeriod.@endTime[0]!?datetime?long?c},
"measuredEntityUserName": "${measData.managedElement.@userLabel[0]!}",
"measuredEntityDn": "${measData.managedElement.@localDn}",
- "measuredEntitySoftwareVersion": "${measData.managedElement.@swVersion}",
+ "measuredEntitySoftwareVersion": "${measData.managedElement.@swVersion[0]!}",
"measInfoList": <@measInfoList/>
}
</#macro>
diff --git a/src/test/resources/mapper_test/mapping_data/valid_data/meas_type_and_r_many_meas_values.xml b/src/test/resources/mapper_test/mapping_data/valid_data/meas_type_and_r_many_meas_values.xml
new file mode 100644
index 0000000..1b1dc26
--- /dev/null
+++ b/src/test/resources/mapper_test/mapping_data/valid_data/meas_type_and_r_many_meas_values.xml
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<measCollecFile xmlns="http://www.3gpp.org/ftp/specs/archive/32_series/32.435#measCollec">
+ <fileHeader dnPrefix="some dnPrefix" vendorName="FooBar Ltd"
+ fileFormatVersion="32.435 V10.0">
+ <fileSender localDn="Dublin"/>
+ <measCollec beginTime="2018-10-02T12:00:00+01:00"/>
+ </fileHeader>
+ <measData>
+ <managedElement swVersion="r0.1" localDn="Dublin"/>
+ <measInfo measInfoId="some measInfoId">
+ <job jobId="some Job Id"/>
+ <granPeriod endTime="2018-10-02T12:15:00Z" duration="PT900S"/>
+ <repPeriod duration="PT900S"/>
+ <measType p="1">a</measType>
+ <measType p="2">b</measType>
+ <measType p="3">c</measType>
+ <measValue measObjLdn="some measObjLdn">
+ <r p="1">86</r>
+ <r p="2">67</r>
+ <r p="3">14</r>
+ <suspect>false</suspect>
+ </measValue>
+ <measValue measObjLdn="some other measObjLdn">
+ <r p="1">5</r>
+ <r p="2">6</r>
+ <r p="3">14</r>
+ <suspect>false</suspect>
+ </measValue>
+ </measInfo>
+ </measData>
+ <fileFooter>
+ <measCollec endTime="2018-10-02T12:15:00+01:00"/>
+ </fileFooter>
+</measCollecFile>
diff --git a/src/test/resources/mapper_test/mapping_data/valid_data/meas_types_and_meas_results_many_meas_values.xml b/src/test/resources/mapper_test/mapping_data/valid_data/meas_types_and_meas_results_many_meas_values.xml
new file mode 100644
index 0000000..4ed9f95
--- /dev/null
+++ b/src/test/resources/mapper_test/mapping_data/valid_data/meas_types_and_meas_results_many_meas_values.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<measCollecFile xmlns="http://www.3gpp.org/ftp/specs/archive/32_series/32.435#measCollec">
+ <fileHeader dnPrefix="some dnPrefix" vendorName="FooBar Ltd"
+ fileFormatVersion="32.435 V10.0">
+ <fileSender localDn="Dublin"/>
+ <measCollec beginTime="2018-10-02T12:00:00+01:00"/>
+ </fileHeader>
+ <measData>
+ <managedElement swVersion="r0.1" localDn="Dublin"/>
+ <measInfo measInfoId="some measInfoId">
+ <job jobId="jobId"/>
+ <granPeriod endTime="2018-10-02T12:15:00Z" duration="PT900S"/>
+ <repPeriod duration="PT900S"/>
+ <measTypes>a b c</measTypes>
+ <measValue measObjLdn="objLdn">
+ <measResults>76 27 98</measResults>
+ <suspect>false</suspect>
+ </measValue>
+ <measValue measObjLdn="some other objLdn">
+ <measResults>1 2 9</measResults>
+ <suspect>false</suspect>
+ </measValue>
+ </measInfo>
+ </measData>
+ <fileFooter>
+ <measCollec endTime="2018-10-02T12:15:00+01:00"/>
+ </fileFooter>
+</measCollecFile>
diff --git a/src/test/resources/mapper_test/mapping_data/valid_data/no_sw_version.xml b/src/test/resources/mapper_test/mapping_data/valid_data/no_sw_version.xml
new file mode 100644
index 0000000..bc435c0
--- /dev/null
+++ b/src/test/resources/mapper_test/mapping_data/valid_data/no_sw_version.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<measCollecFile xmlns="http://www.3gpp.org/ftp/specs/archive/32_series/32.435#measCollec">
+ <fileHeader dnPrefix="some dnPrefix" vendorName="FooBar Ltd"
+ fileFormatVersion="32.435 V10.0">
+ <fileSender localDn="Dublin"/>
+ <measCollec beginTime="2018-10-02T12:00:00+01:00"/>
+ </fileHeader>
+ <measData>
+ <managedElement localDn="Dublin"/>
+ <measInfo measInfoId="some measInfoId">
+ <job jobId="some Job Id"/>
+ <granPeriod endTime="2018-10-02T12:15:00Z" duration="PT900S"/>
+ <repPeriod duration="PT900S"/>
+ <measType p="1">a</measType>
+ <measType p="2">b</measType>
+ <measType p="3">c</measType>
+ <measValue measObjLdn="some measObjLdn">
+ <r p="1">86</r>
+ <r p="2">67</r>
+ <r p="3">14</r>
+ <suspect>false</suspect>
+ </measValue>
+ </measInfo>
+ </measData>
+ <fileFooter>
+ <measCollec endTime="2018-10-02T12:15:00+01:00"/>
+ </fileFooter>
+</measCollecFile>