diff options
Diffstat (limited to 'src/main')
19 files changed, 1293 insertions, 383 deletions
diff --git a/src/main/java/org/onap/dcaegen2/services/pmmapper/App.java b/src/main/java/org/onap/dcaegen2/services/pmmapper/App.java index c7d56e5..21e4441 100644 --- a/src/main/java/org/onap/dcaegen2/services/pmmapper/App.java +++ b/src/main/java/org/onap/dcaegen2/services/pmmapper/App.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019 Nordix Foundation. + * Copyright (C) 2019-2020 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -71,8 +71,8 @@ public class App { private static final ONAPLogAdapter logger = new ONAPLogAdapter(LoggerFactory.getLogger(App.class)); private static final int HTTP_PORT = 8081; private static final int HTTPS_PORT = 8443; - private static Path mappingTemplate = Paths.get("/opt/app/pm-mapper/etc/mapping.ftl"); - private static Path xmlSchema = Paths.get("/opt/app/pm-mapper/etc/measCollec_plusString.xsd"); + private static Path templates = Paths.get("/opt/app/pm-mapper/etc/templates/"); + private static Path schemas = Paths.get("/opt/app/pm-mapper/etc/schemas/"); private MapperConfig mapperConfig; private MetadataFilter metadataFilter; @@ -95,13 +95,13 @@ public class App { /** * Creates an instance of the application. - * @param mappingTemplate path to template used to convert xml to VES. - * @param xmlSchema path to schema used to verify incoming XML will work with template. + * @param templatesDirectory path to directory containing templates used for mapping. + * @param schemasDirectory path to directory containing schemas used to verify incoming XML will work with templates. * @param httpPort http port to start http server on. * @param httpsPort https port to start https server on. * @param configHandler instance of the ConfigurationHandler used to acquire config. */ - public App(Path mappingTemplate, Path xmlSchema, int httpPort, int httpsPort, ConfigHandler configHandler) { + public App(Path templatesDirectory, Path schemasDirectory, int httpPort, int httpsPort, ConfigHandler configHandler) { try { this.mapperConfig = configHandler.getMapperConfig(); } catch (EnvironmentConfigException | CBSServerError | MapperConfigException e) { @@ -113,9 +113,9 @@ public class App { this.metadataFilter = new MetadataFilter(mapperConfig); this.measConverter = new MeasConverter(); this.filterHandler = new MeasFilterHandler(measConverter); - this.mapper = new Mapper(mappingTemplate, this.measConverter); + this.mapper = new Mapper(templatesDirectory, this.measConverter); this.splitter = new MeasSplitter(measConverter); - this.validator = new XMLValidator(xmlSchema); + this.validator = new XMLValidator(schemasDirectory); this.vesPublisher = new VESPublisher(mapperConfig); this.flux = Flux.create(eventFluxSink -> this.fluxSink = eventFluxSink); @@ -176,7 +176,7 @@ public class App { } public static void main(String[] args) { - new App(mappingTemplate, xmlSchema, HTTP_PORT, HTTPS_PORT, new ConfigHandler()).start(); + new App(templates, schemas, HTTP_PORT, HTTPS_PORT, new ConfigHandler()).start(); } public static boolean filterByFileType(MeasFilterHandler filterHandler,Event event, MapperConfig config) { diff --git a/src/main/java/org/onap/dcaegen2/services/pmmapper/model/package-info.java b/src/main/java/org/onap/dcaegen2/services/pmmapper/exceptions/TemplateIdentificationException.java index 92c83be..2fa5da3 100644 --- a/src/main/java/org/onap/dcaegen2/services/pmmapper/model/package-info.java +++ b/src/main/java/org/onap/dcaegen2/services/pmmapper/exceptions/TemplateIdentificationException.java @@ -1,24 +1,28 @@ -/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2019 Nordix Foundation.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-@XmlSchema(namespace = "http://www.3gpp.org/ftp/specs/archive/32_series/32.435#measCollec", elementFormDefault = XmlNsForm.QUALIFIED)
-package org.onap.dcaegen2.services.pmmapper.model;
-import javax.xml.bind.annotation.XmlSchema;
-import javax.xml.bind.annotation.XmlNsForm;
\ No newline at end of file +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.dcaegen2.services.pmmapper.exceptions; + +public class TemplateIdentificationException extends RuntimeException { + + public TemplateIdentificationException(String message) { + super(message); + } +} diff --git a/src/main/java/org/onap/dcaegen2/services/pmmapper/filtering/MeasFilterHandler.java b/src/main/java/org/onap/dcaegen2/services/pmmapper/filtering/MeasFilterHandler.java index 562f46c..fb5772e 100644 --- a/src/main/java/org/onap/dcaegen2/services/pmmapper/filtering/MeasFilterHandler.java +++ b/src/main/java/org/onap/dcaegen2/services/pmmapper/filtering/MeasFilterHandler.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019 Nordix Foundation. + * Copyright (C) 2019-2020 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,13 +27,11 @@ import java.util.stream.Collectors; import org.apache.commons.io.FilenameUtils; import org.onap.dcaegen2.services.pmmapper.model.Event; -import org.onap.dcaegen2.services.pmmapper.model.MeasCollecFile; -import org.onap.dcaegen2.services.pmmapper.model.MeasCollecFile.MeasData; -import org.onap.dcaegen2.services.pmmapper.model.MeasCollecFile.MeasData.MeasInfo; -import org.onap.dcaegen2.services.pmmapper.model.MeasCollecFile.MeasData.MeasInfo.MeasType; -import org.onap.dcaegen2.services.pmmapper.model.MeasCollecFile.MeasData.MeasInfo.MeasValue; -import org.onap.dcaegen2.services.pmmapper.model.MeasCollecFile.MeasData.MeasInfo.MeasValue.R; import org.onap.dcaegen2.services.pmmapper.model.MeasFilterConfig.Filter; +import org.onap.dcaegen2.services.pmmapper.model.measurement.common.MeasurementData; +import org.onap.dcaegen2.services.pmmapper.model.measurement.common.MeasurementFile; +import org.onap.dcaegen2.services.pmmapper.model.measurement.common.MeasurementInfo; +import org.onap.dcaegen2.services.pmmapper.model.measurement.common.MeasurementInfo.MeasValue; import org.onap.dcaegen2.services.pmmapper.utils.MeasConverter; import org.onap.logging.ref.slf4j.ONAPLogAdapter; import org.slf4j.LoggerFactory; @@ -55,24 +53,24 @@ public class MeasFilterHandler { **/ public boolean filterByMeasType(Event event) { Optional<Filter> filter = Optional.ofNullable(event.getFilter()); - MeasCollecFile measCollecFile = event.getMeasCollecFile(); + MeasurementFile measurementFile = event.getMeasurement(); if (hasNoFilters(filter)) { logger.unwrap().info("Skipping filtering by measTypes as filter config does not contain measTypes."); return true; } - if (measCollecFile.getMeasData().isEmpty()) { + if (!measurementFile.getMeasurementData().isPresent() || measurementFile.getMeasurementData().get().isEmpty()) { logger.unwrap().info("Measurement file will not be processed further as MeasData is empty."); return false; } logger.unwrap().info("Filtering the measurement file by measTypes."); - MeasData measData = measCollecFile.getMeasData().get(0); - List<MeasInfo> measInfos = measData.getMeasInfo(); - List<MeasInfo> filteredMeasInfos = new ArrayList<>(); + MeasurementData measData = measurementFile.getMeasurementData().get().get(0); + List<MeasurementInfo> measInfos = measData.getMeasurementInfo(); + List<MeasurementInfo> filteredMeasInfos = new ArrayList<>(); - for (MeasInfo currentMeasInfo : measInfos) { + for (MeasurementInfo currentMeasInfo : measInfos) { List<String> measTypesNode = currentMeasInfo.getMeasTypes(); if (measTypesNode != null && !measTypesNode.isEmpty()) { setMeasInfosFromMeasTypes(currentMeasInfo, filteredMeasInfos, filter.get()); @@ -85,8 +83,8 @@ public class MeasFilterHandler { logger.unwrap().info("No filter match from the current measurement file."); return false; } - measData.setMeasInfo(filteredMeasInfos); - String filteredXMl = converter.convert(measCollecFile); + measData.setMeasurementInfo(filteredMeasInfos); + String filteredXMl = converter.convert(measurementFile); event.setBody(filteredXMl); logger.unwrap().info("Successfully filtered the measurement by measTypes."); return true; @@ -147,8 +145,8 @@ public class MeasFilterHandler { return FilenameUtils.getExtension(fileName).equals(XML_EXTENSION); } - private boolean hasMatchingResults(List<MeasType> filteredMeasTypes, MeasValue measValue ) { - List<R> filteredResults = new ArrayList<>(); + private boolean hasMatchingResults(List<MeasurementInfo.MeasType> filteredMeasTypes, MeasValue measValue ) { + List<MeasValue.R> filteredResults = new ArrayList<>(); filteredMeasTypes.forEach( mst -> measValue.getR().stream() @@ -164,8 +162,8 @@ public class MeasFilterHandler { return hasResults; } - private void setMeasInfoFromMeasType(MeasInfo currentMeasInfo, List<MeasInfo> filteredMeasInfos, Filter filter) { - List<MeasType> filteredMeasTypes = currentMeasInfo.getMeasType().stream() + private void setMeasInfoFromMeasType(MeasurementInfo currentMeasInfo, List<MeasurementInfo> filteredMeasInfos, Filter filter) { + List<MeasurementInfo.MeasType> filteredMeasTypes = currentMeasInfo.getMeasType().stream() .filter(mt -> filter.getMeasTypes().contains(mt.getValue())) .collect(Collectors.toList()); @@ -179,7 +177,7 @@ public class MeasFilterHandler { } } - private void setMeasInfosFromMeasTypes(MeasInfo currentMeasInfo, List<MeasInfo> filteredMeasInfos, Filter filter) { + private void setMeasInfosFromMeasTypes(MeasurementInfo currentMeasInfo, List<MeasurementInfo> filteredMeasInfos, Filter filter) { MeasValue currentMeasValue = currentMeasInfo.getMeasValue() .get(0); List<String> measTypesNode = currentMeasInfo.getMeasTypes(); diff --git a/src/main/java/org/onap/dcaegen2/services/pmmapper/mapping/Mapper.java b/src/main/java/org/onap/dcaegen2/services/pmmapper/mapping/Mapper.java index a9b7e86..89a4acc 100644 --- a/src/main/java/org/onap/dcaegen2/services/pmmapper/mapping/Mapper.java +++ b/src/main/java/org/onap/dcaegen2/services/pmmapper/mapping/Mapper.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019 Nordix Foundation. + * Copyright (C) 2019-2020 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,8 +24,11 @@ import freemarker.ext.dom.NodeModel; import freemarker.template.Configuration; import freemarker.template.Template; import freemarker.template.TemplateException; +import java.util.Optional; +import java.util.stream.Stream; import lombok.NonNull; import org.onap.dcaegen2.services.pmmapper.exceptions.MappingException; +import org.onap.dcaegen2.services.pmmapper.exceptions.TemplateIdentificationException; import org.onap.dcaegen2.services.pmmapper.exceptions.XMLParseException; import org.onap.dcaegen2.services.pmmapper.model.Event; import org.onap.dcaegen2.services.pmmapper.utils.MeasConverter; @@ -49,23 +52,33 @@ import java.util.UUID; public class Mapper { private static final ONAPLogAdapter logger = new ONAPLogAdapter(LoggerFactory.getLogger(Mapper.class)); - private Template mappingTemplate; + + private HashMap<String, Template> templates; private MeasConverter converter; - public Mapper(@NonNull Path pathToTemplate, MeasConverter converter) { - logger.unwrap().trace("Constructing Mapper from {}", pathToTemplate); + public Mapper(@NonNull Path templatesDirectory, MeasConverter converter) { + logger.unwrap().trace("Constructing Mapper from {}", templatesDirectory); + templates = new HashMap<>(); this.converter = converter; Configuration configuration = new Configuration(Configuration.VERSION_2_3_28); configuration.setTagSyntax(Configuration.ANGLE_BRACKET_TAG_SYNTAX); - try { - InputStreamReader templateInputStreamReader = new InputStreamReader(Files.newInputStream(pathToTemplate)); - mappingTemplate = new Template("pm", templateInputStreamReader, configuration, StandardCharsets.UTF_8.name()); + try (Stream<Path> paths = Files.walk(templatesDirectory)) { + paths.filter(Files::isRegularFile) + .forEach(template -> addTemplate(template, configuration)); + } catch (IOException exception) { + logger.unwrap().error("Failed to walk template directory {}", templatesDirectory, exception); + throw new IllegalArgumentException("Failed to walk template directory {}", exception); + } + } + private void addTemplate(Path template, Configuration config) { + logger.unwrap().debug("Loading template from {}", template.toString()); + try (InputStreamReader templateInputStreamReader = new InputStreamReader(Files.newInputStream(template))){ + templates.put(template.getFileName().toString(), new Template(template.getFileName().toString(), templateInputStreamReader, config, StandardCharsets.UTF_8.name())); } catch (IOException exception) { - logger.unwrap().error("Failed to read template from location {}", pathToTemplate, exception); + logger.unwrap().error("Failed to read template from location {}", template, exception); throw new IllegalArgumentException("Failed to read template from path", exception); } } - public List<Event> mapEvents(List<Event> events) { events.forEach(event -> event.setVes(this.map(event))); return events; @@ -75,8 +88,8 @@ public class Mapper { logger.unwrap().info("Mapping event"); NodeModel pmNodeModel; try { - String measCollecFile = converter.convert(event.getMeasCollecFile()); - pmNodeModel = NodeModel.parse(new InputSource(new StringReader(measCollecFile))); + String measurements = converter.convert(event.getMeasurement()); + pmNodeModel = NodeModel.parse(new InputSource(new StringReader(measurements))); } catch (IOException | SAXException | ParserConfigurationException exception) { logger.unwrap().error("Failed to parse input as XML", exception); throw new XMLParseException("Failed to parse input as XML", exception); @@ -86,8 +99,10 @@ public class Mapper { mappingData.put("metadata", event.getMetadata()); mappingData.put("eventId", makeEventId()); StringWriter mappedOutputWriter = new StringWriter(); + Template template = Optional.ofNullable(templates.get(event.getMetadata().getFileFormatType())) + .orElseThrow(() -> new TemplateIdentificationException("Failed to identify template")); try { - mappingTemplate.process(mappingData, mappedOutputWriter); + template.process(mappingData, mappedOutputWriter); } catch (IOException | TemplateException exception) { logger.unwrap().error("Failed to map XML", exception); throw new MappingException("Mapping failure", exception); diff --git a/src/main/java/org/onap/dcaegen2/services/pmmapper/model/Event.java b/src/main/java/org/onap/dcaegen2/services/pmmapper/model/Event.java index 9eadb8a..57d9570 100644 --- a/src/main/java/org/onap/dcaegen2/services/pmmapper/model/Event.java +++ b/src/main/java/org/onap/dcaegen2/services/pmmapper/model/Event.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019 Nordix Foundation. + * Copyright (C) 2020 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,6 +25,7 @@ import lombok.NonNull; import java.util.Map; import org.onap.dcaegen2.services.pmmapper.model.MeasFilterConfig.Filter; +import org.onap.dcaegen2.services.pmmapper.model.measurement.common.MeasurementFile; /** * Class used to pass around relevant inbound event data. @@ -42,7 +43,7 @@ public class Event { @NonNull private String publishIdentity; - private MeasCollecFile measCollecFile; + private MeasurementFile measurement; private Filter filter; diff --git a/src/main/java/org/onap/dcaegen2/services/pmmapper/model/MeasCollecFile.java b/src/main/java/org/onap/dcaegen2/services/pmmapper/model/MeasCollecFile.java deleted file mode 100644 index cc6ca0f..0000000 --- a/src/main/java/org/onap/dcaegen2/services/pmmapper/model/MeasCollecFile.java +++ /dev/null @@ -1,270 +0,0 @@ -/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2019 Nordix Foundation.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.dcaegen2.services.pmmapper.model;
-
-import java.math.BigInteger;
-import java.util.List;
-
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlAttribute;
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlList;
-import javax.xml.bind.annotation.XmlRootElement;
-import javax.xml.bind.annotation.XmlSchemaType;
-import javax.xml.bind.annotation.XmlType;
-import javax.xml.bind.annotation.XmlValue;
-import javax.xml.bind.annotation.adapters.CollapsedStringAdapter;
-import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
-import javax.xml.datatype.Duration;
-import javax.xml.datatype.XMLGregorianCalendar;
-import lombok.Data;
-
-@XmlAccessorType(XmlAccessType.FIELD)
-@XmlType(name = "", propOrder = {
- "fileHeader",
- "measData",
- "fileFooter"
-})
-@XmlRootElement(name = "measCollecFile")
-@Data
-public class MeasCollecFile {
-
- @XmlElement(required = true)
- protected MeasCollecFile.FileHeader fileHeader;
- protected List<MeasCollecFile.MeasData> measData;
- @XmlElement(required = true)
- protected MeasCollecFile.FileFooter fileFooter;
- @XmlAccessorType(XmlAccessType.FIELD)
- @XmlType(name = "", propOrder = {
- "measCollec"
- })
- @Data
- public static class FileFooter {
-
- @XmlElement(required = true)
- protected MeasCollecFile.FileFooter.MeasCollec measCollec;
-
- @XmlAccessorType(XmlAccessType.FIELD)
- @XmlType(name = "")
- public static class MeasCollec {
- @XmlAttribute(name = "endTime", required = true)
- @XmlSchemaType(name = "dateTime")
- protected XMLGregorianCalendar endTime;
- }
-
- }
-
-
- @XmlAccessorType(XmlAccessType.FIELD)
- @XmlType(name = "", propOrder = {
- "fileSender",
- "measCollec"
- })
- @Data
- public static class FileHeader {
- @XmlElement(required = true)
- protected MeasCollecFile.FileHeader.FileSender fileSender;
- @XmlElement(required = true)
- protected MeasCollecFile.FileHeader.MeasCollec measCollec;
- @XmlAttribute(name = "fileFormatVersion", required = true)
- protected String fileFormatVersion;
- @XmlAttribute(name = "vendorName")
- protected String vendorName;
- @XmlAttribute(name = "dnPrefix")
- protected String dnPrefix;
-
- @XmlAccessorType(XmlAccessType.FIELD)
- @XmlType(name = "")
- @Data
- public static class FileSender {
- @XmlAttribute(name = "localDn")
- protected String localDn;
- @XmlAttribute(name = "elementType")
- protected String elementType;
- }
-
-
- @XmlAccessorType(XmlAccessType.FIELD)
- @XmlType(name = "")
- @Data
- public static class MeasCollec {
- @XmlAttribute(name = "beginTime", required = true)
- @XmlSchemaType(name = "dateTime")
- protected XMLGregorianCalendar beginTime;
- }
-
- }
-
-
- @XmlAccessorType(XmlAccessType.FIELD)
- @XmlType(name = "", propOrder = {
- "managedElement",
- "measInfo"
- })
- @Data
- public static class MeasData {
- @XmlElement(required = true)
- protected MeasCollecFile.MeasData.ManagedElement managedElement;
- protected List<MeasCollecFile.MeasData.MeasInfo> measInfo;
-
- @XmlAccessorType(XmlAccessType.FIELD)
- @XmlType(name = "")
- @Data
- public static class ManagedElement {
- @XmlAttribute(name = "localDn")
- protected String localDn;
- @XmlAttribute(name = "userLabel")
- protected String userLabel;
- @XmlAttribute(name = "swVersion")
- protected String swVersion;
- }
-
- @XmlAccessorType(XmlAccessType.FIELD)
- @XmlType(name = "", propOrder = {
- "job",
- "granPeriod",
- "repPeriod",
- "measTypes",
- "measType",
- "measValue"
- })
- @Data
- public static class MeasInfo {
-
- protected MeasCollecFile.MeasData.MeasInfo.Job job;
- @XmlElement(required = true)
- protected MeasCollecFile.MeasData.MeasInfo.GranPeriod granPeriod;
- protected MeasCollecFile.MeasData.MeasInfo.RepPeriod repPeriod;
- @XmlList
- protected List<String> measTypes;
- protected List<MeasCollecFile.MeasData.MeasInfo.MeasType> measType;
- protected List<MeasCollecFile.MeasData.MeasInfo.MeasValue> measValue;
- @XmlAttribute(name = "measInfoId")
- protected String measInfoId;
-
- @XmlAccessorType(XmlAccessType.FIELD)
- @XmlType(name = "")
- @Data
- public static class GranPeriod {
- @XmlAttribute(name = "duration", required = true)
- protected Duration duration;
- @XmlAttribute(name = "endTime", required = true)
- @XmlSchemaType(name = "dateTime")
- protected XMLGregorianCalendar endTime;
- }
-
-
- @XmlAccessorType(XmlAccessType.FIELD)
- @XmlType(name = "")
- @Data
- public static class Job {
- @XmlAttribute(name = "jobId", required = true)
- protected String jobId;
- }
-
- @XmlAccessorType(XmlAccessType.FIELD)
- @XmlType(name = "", propOrder = {
- "value"
- })
- @Data
- public static class MeasType {
- @XmlValue
- @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
- @XmlSchemaType(name = "Name")
- protected String value;
- @XmlAttribute(name = "p", required = true)
- @XmlSchemaType(name = "positiveInteger")
- protected BigInteger p;
- }
-
- @XmlAccessorType(XmlAccessType.FIELD)
- @XmlType(name = "", propOrder = {
- "measResults",
- "r",
- "suspect"
- })
- @Data
- public static class MeasValue {
- @XmlList
- protected List<String> measResults;
- protected List<MeasCollecFile.MeasData.MeasInfo.MeasValue.R> r;
- protected Boolean suspect;
- @XmlAttribute(name = "measObjLdn", required = true)
- protected String measObjLdn;
-
- @XmlAccessorType(XmlAccessType.FIELD)
- @XmlType(name = "", propOrder = {
- "value"
- })
- @Data
- public static class R {
- @XmlValue
- protected String value;
- @XmlAttribute(name = "p", required = true)
- @XmlSchemaType(name = "positiveInteger")
- protected BigInteger p;
- }
- public void replaceR(List<R> filteredRs) {
- this.r = filteredRs;
-
- }
- public void replaceMeasResults(List<String> filteredMeasResults) {
- this.measResults = filteredMeasResults;
-
- }
- }
- @XmlAccessorType(XmlAccessType.FIELD)
- @XmlType(name = "")
- @Data
- public static class RepPeriod {
-
- @XmlAttribute(name = "duration", required = true)
- protected Duration duration;
- }
-
- public void replaceMeasTypes(List<String> newMeasTypes) {
- this.measTypes = newMeasTypes;
- }
-
- public void replaceMeasType(List<MeasType> filteredMeasTypes) {
- this.measType = filteredMeasTypes;
- }
-
- public void replaceMeasValue(List<MeasValue> filteredMeasValues) {
- this.measValue = filteredMeasValues;
- }
-
- }
-
-
- public void setMeasInfo(List<MeasInfo> filteredMeasInfos) {
- this.measInfo = filteredMeasInfos;
- }
-
- }
-
-
- public void replaceMeasData(List<MeasData> measDataList) {
- this.measData = measDataList;
- }
-
-}
diff --git a/src/main/java/org/onap/dcaegen2/services/pmmapper/model/measurement/common/MeasurementData.java b/src/main/java/org/onap/dcaegen2/services/pmmapper/model/measurement/common/MeasurementData.java new file mode 100644 index 0000000..f299064 --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/pmmapper/model/measurement/common/MeasurementData.java @@ -0,0 +1,29 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.dcaegen2.services.pmmapper.model.measurement.common; + +import java.util.List; + +public interface MeasurementData { + public List<MeasurementInfo> getMeasurementInfo(); + public void setMeasurementInfo(List<MeasurementInfo> measurementInfo); + public Object getManagedEntity(); +} diff --git a/src/main/java/org/onap/dcaegen2/services/pmmapper/model/measurement/common/MeasurementFile.java b/src/main/java/org/onap/dcaegen2/services/pmmapper/model/measurement/common/MeasurementFile.java new file mode 100644 index 0000000..3c44780 --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/pmmapper/model/measurement/common/MeasurementFile.java @@ -0,0 +1,30 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.dcaegen2.services.pmmapper.model.measurement.common; + +import java.util.List; +import java.util.Optional; + +public interface MeasurementFile { + + public Optional<List<MeasurementData>> getMeasurementData(); + public void replacementMeasurementData(List<MeasurementData> measurementData); +} diff --git a/src/main/java/org/onap/dcaegen2/services/pmmapper/model/measurement/common/MeasurementInfo.java b/src/main/java/org/onap/dcaegen2/services/pmmapper/model/measurement/common/MeasurementInfo.java new file mode 100644 index 0000000..c6042b1 --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/pmmapper/model/measurement/common/MeasurementInfo.java @@ -0,0 +1,147 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.dcaegen2.services.pmmapper.model.measurement.common; + +import java.math.BigInteger; +import java.util.List; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlList; +import javax.xml.bind.annotation.XmlSchemaType; +import javax.xml.bind.annotation.XmlType; +import javax.xml.bind.annotation.XmlValue; +import javax.xml.bind.annotation.adapters.CollapsedStringAdapter; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; +import javax.xml.datatype.Duration; +import javax.xml.datatype.XMLGregorianCalendar; +import lombok.Data; + +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = {"job", "granPeriod", "repPeriod", "measTypes", "measType", "measValue", "measInfoId"}) +@Data +public class MeasurementInfo { + + @XmlElement + protected Job job; + @XmlElement(required = true) + protected GranPeriod granPeriod; + protected RepPeriod repPeriod; + @XmlList + protected List<String> measTypes; + protected List<MeasType> measType; + protected List<MeasValue> measValue; + @XmlAttribute + protected String measInfoId; + + @XmlAccessorType(XmlAccessType.FIELD) + @XmlType(name = "") + @Data + public static class GranPeriod { + + @XmlAttribute(name = "duration", required = true) + protected Duration duration; + @XmlAttribute(name = "endTime", required = true) + @XmlSchemaType(name = "dateTime") + protected XMLGregorianCalendar endTime; + } + + + @XmlAccessorType(XmlAccessType.FIELD) + @XmlType(name = "") + @Data + public static class Job { + + @XmlAttribute(name = "jobId", required = true) + protected String jobId; + } + + @XmlAccessorType(XmlAccessType.FIELD) + @XmlType(name = "", propOrder = {"value"}) + @Data + public static class MeasType { + + @XmlValue + @XmlJavaTypeAdapter(CollapsedStringAdapter.class) + @XmlSchemaType(name = "Name") + protected String value; + @XmlAttribute(name = "p", required = true) + @XmlSchemaType(name = "positiveInteger") + protected BigInteger p; + } + + @XmlAccessorType(XmlAccessType.FIELD) + @XmlType(name = "", propOrder = {"measResults", "r", "suspect"}) + @Data + public static class MeasValue { + + @XmlList + protected List<String> measResults; + protected List<MeasurementInfo.MeasValue.R> r; + protected Boolean suspect; + @XmlAttribute(name = "measObjLdn", required = true) + protected String measObjLdn; + + @XmlAccessorType(XmlAccessType.FIELD) + @XmlType(name = "", propOrder = {"value"}) + @Data + public static class R { + + @XmlValue + protected String value; + @XmlAttribute(name = "p", required = true) + @XmlSchemaType(name = "positiveInteger") + protected BigInteger p; + } + + public void replaceR(List<R> filteredRs) { + this.r = filteredRs; + + } + + public void replaceMeasResults(List<String> filteredMeasResults) { + this.measResults = filteredMeasResults; + } + } + + @XmlAccessorType(XmlAccessType.FIELD) + @XmlType(name = "") + @Data + public static class RepPeriod { + + @XmlAttribute(name = "duration", required = true) + protected Duration duration; + } + + public void replaceMeasTypes(List<String> newMeasTypes) { + this.measTypes = newMeasTypes; + } + + public void replaceMeasType(List<MeasType> filteredMeasTypes) { + this.measType = filteredMeasTypes; + } + + public void replaceMeasValue(List<MeasValue> filteredMeasValues) { + this.measValue = filteredMeasValues; + } + +}
\ No newline at end of file diff --git a/src/main/java/org/onap/dcaegen2/services/pmmapper/model/measurement/lte/MeasCollecFile.java b/src/main/java/org/onap/dcaegen2/services/pmmapper/model/measurement/lte/MeasCollecFile.java new file mode 100644 index 0000000..d4dccef --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/pmmapper/model/measurement/lte/MeasCollecFile.java @@ -0,0 +1,179 @@ +/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019-2020 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcaegen2.services.pmmapper.model.measurement.lte;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import java.util.Optional;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlSchemaType;
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.datatype.XMLGregorianCalendar;
+import lombok.Data;
+import org.onap.dcaegen2.services.pmmapper.model.measurement.common.MeasurementData;
+import org.onap.dcaegen2.services.pmmapper.model.measurement.common.MeasurementFile;
+import org.onap.dcaegen2.services.pmmapper.model.measurement.common.MeasurementInfo;
+
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "", propOrder = {
+ "fileHeader",
+ "measData",
+ "fileFooter"
+})
+@XmlRootElement(name = "measCollecFile")
+@Data
+public class MeasCollecFile implements MeasurementFile {
+
+ @XmlElement(required = true)
+ protected MeasCollecFile.FileHeader fileHeader;
+ protected List<MeasCollecFile.MeasData> measData;
+ @XmlElement(required = true)
+ protected MeasCollecFile.FileFooter fileFooter;
+
+ @Override
+ public Optional<List<MeasurementData>> getMeasurementData() {
+ try {
+ List<MeasurementData> measurementDataList = new ArrayList<>(this.measData);
+ return Optional.of(measurementDataList);
+ } catch (NullPointerException exception) {
+ return Optional.empty();
+ }
+ }
+
+ @Override
+ public void replacementMeasurementData(List<MeasurementData> measurementData) {
+ measData.clear();
+ measurementData.forEach(measurementDatum -> {
+ MeasData measDatum = new MeasData();
+ measDatum.setManagedElement((MeasData.ManagedElement) measurementDatum.getManagedEntity());
+ measDatum.setMeasInfo(measurementDatum.getMeasurementInfo());
+ this.measData.add(measDatum);
+ });
+ }
+
+ @XmlAccessorType(XmlAccessType.FIELD)
+ @XmlType(name = "", propOrder = {
+ "measCollec"
+ })
+ @Data
+ public static class FileFooter {
+
+ @XmlElement(required = true)
+ protected MeasCollecFile.FileFooter.MeasCollec measCollec;
+
+ @XmlAccessorType(XmlAccessType.FIELD)
+ @XmlType(name = "")
+ public static class MeasCollec {
+ @XmlAttribute(name = "endTime", required = true)
+ @XmlSchemaType(name = "dateTime")
+ protected XMLGregorianCalendar endTime;
+ }
+
+ }
+
+
+ @XmlAccessorType(XmlAccessType.FIELD)
+ @XmlType(name = "", propOrder = {
+ "fileSender",
+ "measCollec"
+ })
+ @Data
+ public static class FileHeader {
+ @XmlElement(required = true)
+ protected MeasCollecFile.FileHeader.FileSender fileSender;
+ @XmlElement(required = true)
+ protected MeasCollecFile.FileHeader.MeasCollec measCollec;
+ @XmlAttribute(name = "fileFormatVersion", required = true)
+ protected String fileFormatVersion;
+ @XmlAttribute(name = "vendorName")
+ protected String vendorName;
+ @XmlAttribute(name = "dnPrefix")
+ protected String dnPrefix;
+
+ @XmlAccessorType(XmlAccessType.FIELD)
+ @XmlType(name = "")
+ @Data
+ public static class FileSender {
+ @XmlAttribute(name = "localDn")
+ protected String localDn;
+ @XmlAttribute(name = "elementType")
+ protected String elementType;
+ }
+
+
+ @XmlAccessorType(XmlAccessType.FIELD)
+ @XmlType(name = "")
+ @Data
+ public static class MeasCollec {
+ @XmlAttribute(name = "beginTime", required = true)
+ @XmlSchemaType(name = "dateTime")
+ protected XMLGregorianCalendar beginTime;
+ }
+
+ }
+
+
+ @XmlAccessorType(XmlAccessType.FIELD)
+ @XmlType(name = "", propOrder = {
+ "managedElement",
+ "measInfo"
+ })
+ @Data
+ public static class MeasData implements MeasurementData {
+ @XmlElement(required = true)
+ protected MeasCollecFile.MeasData.ManagedElement managedElement;
+ @XmlElement(required = true)
+ protected List<MeasurementInfo> measInfo;
+
+ @Override
+ public List<MeasurementInfo> getMeasurementInfo() {
+ return this.measInfo;
+ }
+
+ @Override
+ public void setMeasurementInfo(List<MeasurementInfo> measurementInfo) {
+ this.measInfo = measurementInfo;
+ }
+
+ @Override
+ public Object getManagedEntity() {
+ return this.managedElement;
+ }
+
+ @XmlAccessorType(XmlAccessType.FIELD)
+ @XmlType(name = "")
+ @Data
+ public static class ManagedElement {
+ @XmlAttribute(name = "localDn")
+ protected String localDn;
+ @XmlAttribute(name = "userLabel")
+ protected String userLabel;
+ @XmlAttribute(name = "swVersion")
+ protected String swVersion;
+ }
+ }
+
+}
diff --git a/src/main/java/org/onap/dcaegen2/services/pmmapper/model/measurement/nr/MeasDataFile.java b/src/main/java/org/onap/dcaegen2/services/pmmapper/model/measurement/nr/MeasDataFile.java new file mode 100644 index 0000000..1ef1a8b --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/pmmapper/model/measurement/nr/MeasDataFile.java @@ -0,0 +1,180 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.dcaegen2.services.pmmapper.model.measurement.nr; + +import java.util.ArrayList; +import java.util.List; + +import java.util.Optional; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlSchemaType; +import javax.xml.bind.annotation.XmlType; +import javax.xml.datatype.XMLGregorianCalendar; +import lombok.Data; +import org.onap.dcaegen2.services.pmmapper.model.measurement.common.MeasurementData; +import org.onap.dcaegen2.services.pmmapper.model.measurement.common.MeasurementFile; +import org.onap.dcaegen2.services.pmmapper.model.measurement.common.MeasurementInfo; + +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "fileHeader", + "measData", + "fileFooter" +}) +@XmlRootElement(name = "MeasDataFile") +@Data +public class MeasDataFile implements MeasurementFile { + + @XmlElement(required = true) + protected MeasDataFile.FileHeader fileHeader; + protected List<MeasDataFile.MeasData> measData; + @XmlElement(required = true) + protected MeasDataFile.FileFooter fileFooter; + + @Override + public Optional<List<MeasurementData>> getMeasurementData() { + try { + List<MeasurementData> measDataList = new ArrayList<>(this.measData); + return Optional.of(measDataList); + } catch (NullPointerException exception) { + return Optional.empty(); + } + } + + @Override + public void replacementMeasurementData(List<MeasurementData> measurementData) { + measData.clear(); + measurementData.forEach(measurementDatum -> { + MeasData measDatum = new MeasData(); + measDatum.setMeasuredEntity((MeasData.MeasuredEntity) measurementDatum.getManagedEntity()); + measDatum.setMeasInfo(measurementDatum.getMeasurementInfo()); + this.measData.add(measDatum); + }); + } + + @XmlAccessorType(XmlAccessType.FIELD) + @XmlType(name = "", propOrder = { + "measData" + }) + @Data + public static class FileFooter { + + @XmlElement(name = "MeasData", required = true) + protected MeasDataFile.FileFooter.MeasData measData; + + @XmlAccessorType(XmlAccessType.FIELD) + @XmlType(name = "") + public static class MeasData { + @XmlAttribute(name = "endTime", required = true) + @XmlSchemaType(name = "dateTime") + protected XMLGregorianCalendar endTime; + } + + } + + + @XmlAccessorType(XmlAccessType.FIELD) + @XmlType(name = "", propOrder = { + "fileSender", + "measData" + }) + @Data + public static class FileHeader { + @XmlElement(required = true) + protected MeasDataFile.FileHeader.FileSender fileSender; + @XmlElement(name = "MeasData", required = true) + protected MeasDataFile.FileHeader.MeasData measData; + @XmlAttribute(name = "fileFormatVersion", required = true) + protected String fileFormatVersion; + @XmlAttribute(name = "vendorName") + protected String vendorName; + @XmlAttribute(name = "dnPrefix") + protected String dnPrefix; + + @XmlAccessorType(XmlAccessType.FIELD) + @XmlType(name = "") + @Data + public static class FileSender { + @XmlAttribute(name = "senderName") + protected String senderName; + @XmlAttribute(name = "elementType") + protected String elementType; + } + + + @XmlAccessorType(XmlAccessType.FIELD) + @XmlType(name = "") + @Data + public static class MeasData { + @XmlAttribute(name = "beginTime", required = true) + @XmlSchemaType(name = "dateTime") + protected XMLGregorianCalendar beginTime; + } + + } + + + @XmlAccessorType(XmlAccessType.FIELD) + @XmlType(name = "", propOrder = { + "measuredEntity", + "measInfo" + }) + @Data + public static class MeasData implements MeasurementData { + @XmlElement(required = true) + protected MeasDataFile.MeasData.MeasuredEntity measuredEntity; + @XmlElement() + protected List<MeasurementInfo> measInfo; + + @Override + public List<MeasurementInfo> getMeasurementInfo() { + return this.measInfo; + } + + @Override + public void setMeasurementInfo(List<MeasurementInfo> measurementInfo) { + this.measInfo = measurementInfo; + } + + @Override + public Object getManagedEntity() { + return this.measuredEntity; + } + + @XmlAccessorType(XmlAccessType.FIELD) + @XmlType(name = "") + @Data + public static class MeasuredEntity { + @XmlAttribute(name = "localDn") + protected String localDn; + @XmlAttribute(name = "userLabel") + protected String userLabel; + @XmlAttribute(name = "swVersion") + protected String swVersion; + } + + } + +} diff --git a/src/main/java/org/onap/dcaegen2/services/pmmapper/utils/MeasConverter.java b/src/main/java/org/onap/dcaegen2/services/pmmapper/utils/MeasConverter.java index b9c01e6..70ad8ab 100644 --- a/src/main/java/org/onap/dcaegen2/services/pmmapper/utils/MeasConverter.java +++ b/src/main/java/org/onap/dcaegen2/services/pmmapper/utils/MeasConverter.java @@ -1,6 +1,6 @@ /*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019 Nordix Foundation.
+ * Copyright (C) 2019-2020 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -28,10 +28,19 @@ import javax.xml.bind.JAXBException; import javax.xml.bind.Marshaller;
import javax.xml.bind.Unmarshaller;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParserFactory;
+import javax.xml.transform.sax.SAXSource;
import org.onap.dcaegen2.services.pmmapper.exceptions.MappingException;
-import org.onap.dcaegen2.services.pmmapper.model.MeasCollecFile;
+import org.onap.dcaegen2.services.pmmapper.model.Event;
+import org.onap.dcaegen2.services.pmmapper.model.measurement.common.MeasurementFile;
+import org.onap.dcaegen2.services.pmmapper.model.measurement.lte.MeasCollecFile;
+import org.onap.dcaegen2.services.pmmapper.model.measurement.nr.MeasDataFile;
import org.onap.logging.ref.slf4j.ONAPLogAdapter;
import org.slf4j.LoggerFactory;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.XMLReader;
/**
* Converts 3GPP PM Measurement xml string to MeasCollecFil and vice versa.
@@ -39,38 +48,57 @@ import org.slf4j.LoggerFactory; public class MeasConverter {
private static final ONAPLogAdapter logger = new ONAPLogAdapter(LoggerFactory.getLogger(MeasConverter.class));
+ public static final String LTE_FILE_TYPE = "org.3GPP.32.435#measCollec";
+ public static final String NR_FILE_TYPE = "org.3GPP.28.550#measData";
+
+
/**
* Converts 3GPP Measurement xml string to MeasCollecFile.
**/
- public MeasCollecFile convert(String eventBody) {
- logger.unwrap().debug("Converting 3GPP xml string to MeasCollecFile");
- MeasCollecFile measCollecFile = null;
+ public MeasurementFile convert(Event event) {
+ logger.unwrap().debug("Converting 3GPP xml string to PM object");
+ Class targetClass = getPMFileClass(event);
try {
- JAXBContext jaxbContext = null;
- jaxbContext = JAXBContext.newInstance(MeasCollecFile.class);
+ JAXBContext jaxbContext = JAXBContext.newInstance(targetClass);
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
- measCollecFile = (MeasCollecFile) unmarshaller.unmarshal(new StringReader(eventBody));
- } catch (JAXBException e) {
- throw new MappingException("Unable to convert 3GPP xml to MeasCollecFile", e);
+ SAXParserFactory saxFactory = SAXParserFactory.newInstance();
+ saxFactory.setNamespaceAware(false);
+ XMLReader reader = saxFactory.newSAXParser().getXMLReader();
+ SAXSource source = new SAXSource(reader,new InputSource(new StringReader(event.getBody())));
+ return (MeasurementFile) unmarshaller.unmarshal(source);
+ } catch (JAXBException | ParserConfigurationException | SAXException e) {
+ throw new MappingException("Unable to convert 3GPP xml to PM Measurement", e);
}
- return measCollecFile;
}
/**
* Converts MeasCollecFile to 3GPP Measurement xml string.
**/
- public String convert(MeasCollecFile measCollecFile) {
- logger.unwrap().debug("Converting MeasCollecFile to 3GPP xml string");
+ public String convert(MeasurementFile measurement) {
+ logger.unwrap().debug("Converting Measurement to 3GPP xml string");
StringWriter writer = new StringWriter();
try {
- JAXBContext jaxbContext = JAXBContext.newInstance(MeasCollecFile.class);
+ JAXBContext jaxbContext = JAXBContext.newInstance(measurement.getClass());
Marshaller marshaller = jaxbContext.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
marshaller.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.TRUE);
- marshaller.marshal(measCollecFile, writer);
+ marshaller.marshal(measurement, writer);
} catch (JAXBException e) {
- throw new MappingException("Unable to convert MeasCollecFile to 3GPP xml", e);
+ throw new MappingException("Unable to convert Measurement to 3GPP xml", e);
}
return writer.toString();
}
+
+ private Class getPMFileClass(Event event) {
+ Class pmFileClass;
+ if (event.getMetadata().getFileFormatType().equals(MeasConverter.LTE_FILE_TYPE)) {
+ pmFileClass = MeasCollecFile.class;
+ } else if(event.getMetadata().getFileFormatType().equals(NR_FILE_TYPE)) {
+ pmFileClass = MeasDataFile.class;
+ } else {
+ throw new MappingException("Failed to discover file type with first class support", new RuntimeException());
+ }
+ return pmFileClass;
+ }
+
}
diff --git a/src/main/java/org/onap/dcaegen2/services/pmmapper/utils/MeasSplitter.java b/src/main/java/org/onap/dcaegen2/services/pmmapper/utils/MeasSplitter.java index 92d9e17..b3e73fd 100644 --- a/src/main/java/org/onap/dcaegen2/services/pmmapper/utils/MeasSplitter.java +++ b/src/main/java/org/onap/dcaegen2/services/pmmapper/utils/MeasSplitter.java @@ -1,6 +1,6 @@ /*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019 Nordix Foundation.
+ * Copyright (C) 2019-2020 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,8 +27,8 @@ import java.util.stream.Collectors; import org.onap.dcaegen2.services.pmmapper.model.Event;
import java.util.NoSuchElementException;
-import org.onap.dcaegen2.services.pmmapper.model.MeasCollecFile;
-import org.onap.dcaegen2.services.pmmapper.model.MeasCollecFile.MeasData;
+import org.onap.dcaegen2.services.pmmapper.model.measurement.common.MeasurementData;
+import org.onap.dcaegen2.services.pmmapper.model.measurement.common.MeasurementFile;
import org.onap.logging.ref.slf4j.ONAPLogAdapter;
import org.slf4j.LoggerFactory;
@@ -47,33 +47,32 @@ public class MeasSplitter { * Splits the MeasCollecFile to multiple MeasCollecFile based on the number of MeasData
**/
public List<Event> split(Event event) {
- logger.unwrap().debug("Splitting 3GPP xml MeasData to individual MeasCollecFile");
- MeasCollecFile currentMeasurement = converter.convert(event.getBody());
- event.setMeasCollecFile(currentMeasurement);
- if (currentMeasurement.getMeasData() == null || currentMeasurement.getMeasData().isEmpty()) {
+ logger.unwrap().debug("Splitting 3GPP xml MeasData to individual Measurements");
+ MeasurementFile currentMeasurement = converter.convert(event);
+ event.setMeasurement(currentMeasurement);
+
+ if (!currentMeasurement.getMeasurementData().isPresent() || currentMeasurement.getMeasurementData().get().isEmpty()) {
throw new NoSuchElementException("MeasData is empty.");
}
- return currentMeasurement.getMeasData().stream().map(measData -> {
+ return currentMeasurement.getMeasurementData().get().stream().map(measData -> {
Event newEvent = generateNewEvent(event);
- MeasCollecFile newMeasCollec = generateNewMeasCollec(newEvent,measData);
- newEvent.setMeasCollecFile(newMeasCollec);
+ MeasurementFile newMeasurement = makeMeasurement(newEvent,measData);
+ newEvent.setMeasurement(newMeasurement);
return newEvent;
}).collect(Collectors.toList());
}
- private MeasCollecFile generateNewMeasCollec(Event event, MeasData measData) {
- MeasCollecFile measCollec = new MeasCollecFile();
- measCollec.replaceMeasData(Arrays.asList(measData));
- measCollec.setFileHeader(event.getMeasCollecFile().getFileHeader());
- measCollec.setFileFooter(event.getMeasCollecFile().getFileFooter());
- return measCollec;
+ private MeasurementFile makeMeasurement(Event event, MeasurementData measData) {
+ MeasurementFile measurement = converter.convert(event);
+ measurement.replacementMeasurementData(Arrays.asList(measData));
+ return measurement;
}
private Event generateNewEvent(Event event) {
Event modifiedEvent = new Event(event.getHttpServerExchange(),
event.getBody(), event.getMetadata(), event.getMdc(),
event.getPublishIdentity());
- modifiedEvent.setMeasCollecFile(event.getMeasCollecFile());
+ modifiedEvent.setMeasurement(event.getMeasurement());
modifiedEvent.setFilter(event.getFilter());
return modifiedEvent;
}
diff --git a/src/main/java/org/onap/dcaegen2/services/pmmapper/utils/XMLValidator.java b/src/main/java/org/onap/dcaegen2/services/pmmapper/utils/XMLValidator.java index a00f80b..9fa3e85 100644 --- a/src/main/java/org/onap/dcaegen2/services/pmmapper/utils/XMLValidator.java +++ b/src/main/java/org/onap/dcaegen2/services/pmmapper/utils/XMLValidator.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019 Nordix Foundation. + * Copyright (C) 2019-2020 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,6 +20,9 @@ package org.onap.dcaegen2.services.pmmapper.utils; +import java.nio.file.Files; +import java.util.HashMap; +import java.util.stream.Stream; import lombok.NonNull; import org.onap.dcaegen2.services.pmmapper.mapping.Mapper; import org.onap.dcaegen2.services.pmmapper.model.Event; @@ -38,20 +41,32 @@ import java.nio.file.Path; public class XMLValidator { private static final ONAPLogAdapter logger = new ONAPLogAdapter(LoggerFactory.getLogger(Mapper.class)); - private Schema schema; - public XMLValidator(Path xmlSchemaDefinition) { - SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); - try { - schema = schemaFactory.newSchema(xmlSchemaDefinition.toFile()); - } catch (SAXException exception) { - logger.unwrap().error("Failed to read schema", exception); - throw new IllegalArgumentException("Bad Schema", exception); + private HashMap<String, Schema> schemas; + private SchemaFactory schemaFactory; + public XMLValidator(Path schemaDirectory) { + logger.unwrap().trace("Constructing schema from {}", schemaDirectory); + schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); + schemas = new HashMap<>(); + try (Stream<Path> paths = Files.walk(schemaDirectory)) { + paths.filter(Files::isRegularFile).forEach(this::addSchema); + } catch (IOException exception) { + logger.unwrap().error("Failed to walk schema directory {}", schemaDirectory, exception); + throw new IllegalArgumentException("Failed to walk template directory {}", exception); } } + private void addSchema(Path schema) { + logger.unwrap().debug("Loading schema from {}", schema.toString()); + try { + schemas.put(schema.getFileName().toString(), schemaFactory.newSchema(schema.toFile())); + } catch(SAXException exception) { + logger.unwrap().error("Failed to discover a valid schema at {}", schema, exception); + throw new IllegalArgumentException("Failed to discover a valid schema from given path", exception); + } + } public boolean validate(@NonNull Event event) { try { - Validator validator = schema.newValidator(); + Validator validator = schemas.get(event.getMetadata().getFileFormatType()).newValidator(); validator.validate(new StreamSource(new StringReader(event.getBody()))); logger.unwrap().info("XML validation successful {}", event); return true; diff --git a/src/main/resources/Dockerfile b/src/main/resources/Dockerfile index bf59524..c4eeb2e 100644 --- a/src/main/resources/Dockerfile +++ b/src/main/resources/Dockerfile @@ -1,6 +1,6 @@ # # ============LICENSE_START======================================================= -# Copyright (C) 2019 Nordix Foundation. +# Copyright (C) 2019-2020 Nordix Foundation. # ================================================================================ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -34,8 +34,8 @@ USER pm-mapper COPY ${project.build.directory}/${ext.dep.dir.path}/ ${ext.dep.dir.path}/ COPY ${project.build.directory}/${JAR} . -COPY ${project.build.directory}/classes/mapping.ftl ./etc/mapping.ftl -COPY ${project.build.directory}/classes/measCollec_plusString.xsd ./etc/measCollec_plusString.xsd +COPY ${project.build.directory}/classes/schemas ./etc/schemas/ +COPY ${project.build.directory}/classes/templates ./etc/templates/ COPY ${project.build.directory}/classes/reconfigure.sh ./etc/reconfigure.sh COPY --chown=pm-mapper ${project.build.directory}/classes/logback.xml ./etc/logback.xml diff --git a/src/main/resources/schemas/org.3GPP.28.550#measData b/src/main/resources/schemas/org.3GPP.28.550#measData new file mode 100644 index 0000000..d3a9fef --- /dev/null +++ b/src/main/resources/schemas/org.3GPP.28.550#measData @@ -0,0 +1,131 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + 3GPP TS 28.550 Measurements data XML file format definition + data file XML schema + measData.xsd +--> +<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:md="http://www.3gpp.org/ftp/specs/archive/28_series/28.550#measData" targetNamespace="http://www.3gpp.org/ftp/specs/archive/28_series/28.550#measData" elementFormDefault="qualified"> + <!-- Measurement collection data file root XML element --> + <element name="MeasDataFile"> + <complexType> + <sequence> + <element name="fileHeader"> + <complexType> + <sequence> + <element name="fileSender"> + <complexType> + <attribute name="senderName" type="string" use="optional"/> + <attribute name="senderType" type="string" use="optional"/> + </complexType> + </element> + <element name="MeasData"> + <complexType> + <attribute name="beginTime" type="dateTime" use="required"/> + </complexType> + </element> + </sequence> + <attribute name="fileFormatVersion" type="string" use="required"/> + <attribute name="vendorName" type="string" use="optional"/> + <attribute name="dnPrefix" type="string" use="optional"/> + </complexType> + </element> + <element name="measData" minOccurs="0" maxOccurs="unbounded"> + <complexType> + <sequence> + <element name="measuredEntity"> + <complexType> + <attribute name="userLabel" type="string" use="optional"/> + <attribute name="localDn" type="string" use="optional"/> + <attribute name="swVersion" type="string" use="optional"/> + </complexType> + </element> + <element name="measInfo" minOccurs="0" maxOccurs="unbounded"> + <complexType> + <sequence> + <element name="job" minOccurs="0"> + <complexType> + <attribute name="jobId" type="string" use="required"/> + </complexType> + </element> + <element name="granPeriod"> + <complexType> + <attribute name="duration" type="duration" use="required"/> + <attribute name="endTime" type="dateTime" use="required"/> + </complexType> + </element> + <element name="repPeriod" minOccurs="0"> + <complexType> + <attribute name="duration" type="duration" use="required"/> + </complexType> + </element> + <choice> + <element name="measTypes"> + <simpleType> + <list itemType="Name"/> + </simpleType> + </element> + <element name="measType" minOccurs="0" maxOccurs="unbounded"> + <complexType> + <simpleContent> + <extension base="Name"> + <attribute name="p" type="positiveInteger" use="required"/> + </extension> + </simpleContent> + </complexType> + </element> + </choice> + <element name="measValue" minOccurs="0" maxOccurs="unbounded"> + <complexType> + <sequence> + <choice> + <element name="measResults"> + <simpleType> + <list itemType="md:measResultType"/> + </simpleType> + </element> + <element name="r" minOccurs="0" maxOccurs="unbounded"> + <complexType> + <simpleContent> + <extension base="md:measResultType"> + <attribute name="p" type="positiveInteger" use="required"/> + </extension> + </simpleContent> + </complexType> + </element> + </choice> + <element name="suspect" type="boolean" minOccurs="0"/> + </sequence> + <attribute name="measObjLdn" type="string" use="required"/> + </complexType> + </element> + </sequence> + <attribute name="measInfoId" type="string" use="optional"/> + </complexType> + </element> + </sequence> + </complexType> + </element> + <element name="fileFooter"> + <complexType> + <sequence> + <element name="MeasData"> + <complexType> + <attribute name="endTime" type="dateTime" use="required"/> + </complexType> + </element> + </sequence> + </complexType> + </element> + </sequence> + </complexType> + </element> + <simpleType name="measResultType"> + <union memberTypes="integer float string"> + <simpleType> + <restriction base="string"> + <enumeration value="NULL"/> + </restriction> + </simpleType> + </union> + </simpleType> +</schema>
\ No newline at end of file diff --git a/src/main/resources/schemas/org.3GPP.32.435#measCollec b/src/main/resources/schemas/org.3GPP.32.435#measCollec new file mode 100644 index 0000000..309bcb9 --- /dev/null +++ b/src/main/resources/schemas/org.3GPP.32.435#measCollec @@ -0,0 +1,159 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!-- + Modified PM XML file format definition to allow arbitrary string values. + Based on 3GPP TS 32.435 Performance Measurement XML file format definition + data file XML schema + measCollec.xsd +--> + +<schema + targetNamespace= + "http://www.3gpp.org/ftp/specs/archive/32_series/32.435#measCollec" + elementFormDefault="qualified" + xmlns="http://www.w3.org/2001/XMLSchema" + xmlns:mc= + "http://www.3gpp.org/ftp/specs/archive/32_series/32.435#measCollec" +> + + <!-- Measurement collection data file root XML element --> + + <element name="measCollecFile"> + <complexType> + <sequence> + <element name="fileHeader"> + <complexType> + <sequence> + <element name="fileSender"> + <complexType> + <attribute name="localDn" type="string" use="optional"/> + <attribute name="elementType" type="string" use="optional"/> + </complexType> + </element> + <element name="measCollec"> + <complexType> + <attribute name="beginTime" type="dateTime" use="required"/> + </complexType> + </element> + </sequence> + <attribute name="fileFormatVersion" type="string" use="required"/> + <attribute name="vendorName" type="string" use="optional"/> + <attribute name="dnPrefix" type="string" use="optional"/> + </complexType> + </element> + <element name="measData" minOccurs="0" maxOccurs="unbounded"> + <complexType> + <sequence> + <element name="managedElement"> + <complexType> + <attribute name="localDn" type="string" use="optional"/> + <attribute name="userLabel" type="string" use="optional"/> + <attribute name="swVersion" type="string" use="optional"/> + </complexType> + </element> + <element name="measInfo" minOccurs="0" maxOccurs="unbounded"> + <complexType> + <sequence> + <element name="job" minOccurs="0"> + <complexType> + <attribute name="jobId" type="string" use="required"/> + </complexType> + </element> + <element name="granPeriod"> + <complexType> + <attribute + name="duration" + type="duration" + use="required" + /> + <attribute + name="endTime" + type="dateTime" + use="required" + /> + </complexType> + </element> + <element name="repPeriod" minOccurs="0"> + <complexType> + <attribute name="duration" + type="duration" use="required"/> + </complexType> + </element> + <choice> + <element name="measTypes"> + <simpleType> + <list itemType="Name"/> + </simpleType> + </element> + <element name="measType" + minOccurs="0" maxOccurs="unbounded"> + <complexType> + <simpleContent> + <extension base="Name"> + <attribute name="p" + type="positiveInteger" use="required"/> + </extension> + </simpleContent> + </complexType> + </element> + </choice> + <element name="measValue" + minOccurs="0" maxOccurs="unbounded"> + <complexType> + <sequence> + <choice> + <element name="measResults"> + <simpleType> + <list itemType="mc:measResultType"/> + </simpleType> + </element> + <element name="r" + minOccurs="0" maxOccurs="unbounded"> + <complexType> + <simpleContent> + <extension base="mc:measResultType"> + <attribute name="p" type="positiveInteger" + use="required"/> + </extension> + </simpleContent> + </complexType> + </element> + </choice> + <element name="suspect" type="boolean" minOccurs="0"/> + </sequence> + <attribute name="measObjLdn" + type="string" use="required"/> + </complexType> + </element> + </sequence> + <attribute name="measInfoId" type="string" use="optional"/> + </complexType> + </element> + </sequence> + </complexType> + </element> + <element name="fileFooter"> + <complexType> + <sequence> + <element name="measCollec"> + <complexType> + <attribute name="endTime" type="dateTime" use="required"/> + </complexType> + </element> + </sequence> + </complexType> + </element> + </sequence> + </complexType> + </element> + + <!-- + Removed the 'NIL' restriction. + --> + + <simpleType name="measResultType"> + <union memberTypes="float string"> + </union> + </simpleType> + +</schema>
\ No newline at end of file diff --git a/src/main/resources/templates/org.3GPP.28.550#measData b/src/main/resources/templates/org.3GPP.28.550#measData new file mode 100644 index 0000000..653077e --- /dev/null +++ b/src/main/resources/templates/org.3GPP.28.550#measData @@ -0,0 +1,132 @@ +<#ftl> +<#-- + ============LICENSE_START======================================================= + Copyright (C) 2019-2020 Nordix Foundation. + ================================================================================ + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + SPDX-License-Identifier: Apache-2.0 + ============LICENSE_END========================================================= + --> +<#compress> +<#assign fileHeader = xml.MeasDataFile.fileHeader> +<#assign fileFooter = xml.MeasDataFile.fileFooter> +<#assign measData = xml.MeasDataFile.measData> +<#setting datetime_format="iso"> +{ + "event": { + "commonEventHeader": <@commonEventHeader/> + <#if measData?has_content>, + "perf3gppFields": <@perf3gppFields/> + </#if> + } +} + + +<#macro commonEventHeader> +{ + "domain": "perf3gpp", + "eventId": "${eventId}", + "sequence": 0, + "eventName": "perf3gpp_${metadata.productName}-${metadata.vendorName}_pmMeasResult", + "sourceName": "${metadata.sourceName}", + "reportingEntityName": "", + "priority": "Normal", + "startEpochMicrosec": ${fileHeader.MeasData.@beginTime?datetime?long?c}, + "lastEpochMicrosec": ${fileFooter.MeasData.@endTime?datetime?long?c}, + "version": "4.0", + "vesEventListenerVersion": "7.1", + "timeZoneOffset": "${metadata.timeZoneOffset}" +} +</#macro> + + +<#macro measTypes measInfo> +{ + "sMeasTypesList":[ + <#if measInfo.measType?has_content> + <#list measInfo.measType as measType> + "${measType}"<#sep>,</#sep> + </#list> + <#else> + <#list measInfo.measTypes?split(" ") as measType> + "${measType}"<#sep>,</#sep> + </#list> + </#if> + ] +} +</#macro> + + +<#macro measValuesList measInfo> +[ +<#list measInfo.measValue as measValue> + { + "measObjInstId": "${measValue.@measObjLdn[0]!}", + "suspectFlag": "${measValue.suspect[0]! "false"}", + "measResults": [ + <#if measValue.r?has_content> + <#list measValue.r as r> + { + "p": ${r.@p}, + "sValue": "${r}" + }<#sep>,</#sep> + </#list> + <#else> + <#list measValue.measResults?split(" ") as r> + { + "p":${r?index+1}, + "sValue": "${r}" + }<#sep>,</#sep> + </#list> + </#if> + ] + } +<#sep>,</#sep> +</#list> +] +</#macro> + + +<#macro measInfoList> +[ +<#list measData.measInfo as measInfo> + { + "measInfoId": { + "sMeasInfoId": "${measInfo.@measInfoId[0]!}" + }, + "measTypes": <@measTypes measInfo/>, + "measValuesList": <@measValuesList measInfo/> + }<#sep>,</#sep> +</#list> +] +</#macro> + + +<#macro measDataCollection> +{ + "granularityPeriod": ${measData.measInfo.granPeriod.@endTime[0]!?datetime?long?c}, + "measuredEntityUserName": "${measData.measuredEntity.@userLabel[0]!}", + "measuredEntityDn": "${measData.measuredEntity.@localDn[0]!}", + "measuredEntitySoftwareVersion": "${measData.measuredEntity.@swVersion[0]!}", + "measInfoList": <@measInfoList/> +} +</#macro> + +<#macro perf3gppFields> +{ + "perf3gppFieldsVersion": "1.0", + "measDataCollection": <@measDataCollection/> +} +</#macro> +</#compress>
\ No newline at end of file diff --git a/src/main/resources/templates/org.3GPP.32.435#measCollec b/src/main/resources/templates/org.3GPP.32.435#measCollec new file mode 100644 index 0000000..422977e --- /dev/null +++ b/src/main/resources/templates/org.3GPP.32.435#measCollec @@ -0,0 +1,133 @@ +<#ftl> +<#-- + ============LICENSE_START======================================================= + Copyright (C) 2019-2020 Nordix Foundation. + ================================================================================ + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + SPDX-License-Identifier: Apache-2.0 + ============LICENSE_END========================================================= + --> +<#compress> +<#assign fileHeader = xml.measCollecFile.fileHeader> +<#assign fileFooter = xml.measCollecFile.fileFooter> +<#assign measData = xml.measCollecFile.measData> +<#setting datetime_format="iso"> +{ + "event": { + "commonEventHeader": <@commonEventHeader/> + <#if measData?has_content>, + "perf3gppFields": <@perf3gppFields/> + </#if> + } +} + + +<#macro commonEventHeader> +{ + "domain": "perf3gpp", + "eventId": "${eventId}", + "sequence": 0, + "eventName": "perf3gpp_${metadata.productName}-${metadata.vendorName}_pmMeasResult", + "sourceName": "${metadata.sourceName}", + "reportingEntityName": "", + "priority": "Normal", + "startEpochMicrosec": ${fileHeader.measCollec.@beginTime?datetime?long?c}, + "lastEpochMicrosec": ${fileFooter.measCollec.@endTime?datetime?long?c}, + "version": "4.0", + "vesEventListenerVersion": "7.1", + "timeZoneOffset": "${metadata.timeZoneOffset}" +} +</#macro> + + +<#macro measTypes measInfo> +{ + "sMeasTypesList":[ + <#if measInfo.measType?has_content> + <#list measInfo.measType as measType> + "${measType}"<#sep>,</#sep> + </#list> + <#else> + <#list measInfo.measTypes?split(" ") as measType> + "${measType}"<#sep>,</#sep> + </#list> + </#if> + ] +} +</#macro> + + +<#macro measValuesList measInfo> +[ +<#list measInfo.measValue as measValue> + { + "measObjInstId": "${measValue.@measObjLdn[0]!}", + "suspectFlag": "${measValue.suspect[0]! "false"}", + "measResults": [ + <#if measValue.r?has_content> + <#list measValue.r as r> + { + "p": ${r.@p}, + "sValue": "${r}" + }<#sep>,</#sep> + </#list> + <#else> + <#list measValue.measResults?split(" ") as r> + { + "p":${r?index+1}, + "sValue": "${r}" + }<#sep>,</#sep> + </#list> + </#if> + ] + } +<#sep>,</#sep> +</#list> +] +</#macro> + + +<#macro measInfoList> +[ +<#list measData.measInfo as measInfo> + { + "measInfoId": { + "sMeasInfoId": "${measInfo.@measInfoId[0]!}" + }, + "measTypes": <@measTypes measInfo/>, + "measValuesList": <@measValuesList measInfo/> + }<#sep>,</#sep> +</#list> +] +</#macro> + + +<#macro measDataCollection> +{ + "granularityPeriod": ${measData.measInfo.granPeriod.@endTime[0]!?datetime?long?c}, + "measuredEntityUserName": "${measData.managedElement.@userLabel[0]!}", + "measuredEntityDn": "${measData.managedElement.@localDn[0]!}", + "measuredEntitySoftwareVersion": "${measData.managedElement.@swVersion[0]!}", + "measInfoList": <@measInfoList/> +} +</#macro> + + +<#macro perf3gppFields> +{ + "perf3gppFieldsVersion": "1.0", + "measDataCollection": <@measDataCollection/> +} +</#macro> +</#compress>
\ No newline at end of file |