SDN-R add updated app
add updated data-provider
Issue-ID: SDNC-1026
Signed-off-by: herbert <herbert.eiselt@highstreet-technologies.com>
Change-Id: I641f8144955fcfb196d0cb19d57452c1d1a69a92
Signed-off-by: herbert <herbert.eiselt@highstreet-technologies.com>
diff --git a/sdnr/wt/README.md b/sdnr/wt/README.md
index 1a8d1e9..33e7084 100644
--- a/sdnr/wt/README.md
+++ b/sdnr/wt/README.md
@@ -1,33 +1,57 @@
# wt - wireless transport microservices
-## apigateway
+## apigateway (osgi)
-The API gateway provides WEB access to all wt related web service providers to prevent cross site requests. The Opendaylight default UI port is extendet by additonal URIs.
+The API gateway provides WEB access to all wt related web service providers to prevent cross site requests. The Opendaylight default Web server is extended by additional URIs.
* /database to access elasticsearch
* /aai to access AAI
- * /ms to access mediator servers
-## devicemodel
+## common (osgi)
-Model classes, specified by ONF Model and provided as yang files for Java class generation for NETCONF devices.
+Common classes, included into most bundles
-## websocketmanager2
+## data-provider (osgi)
-Notification service for browser clients.
+Interface to devicemanager database. In Frankfurt database is elasticsearch.
-## devicemanager
+## devicemanager (osgi)
-Management application for NETCONF devices.
+Devicemanager services, used by specfic devicemanagers for NETCONF devices.
-## odlux
+## devicemanager-specific (osgi)
-Web applications for user operations for devices
+Devicemanager implementation for specfic devicemodel. Today available are:
+ * onf: ONF Core model
+ * oran: O-RAN model
+ * gran: 3GPP model
-## helpserver
+## featureaggregator (osgi)
+
+karaf features
+ * sdnr-wt-feature-aggregator to start all services
+ * sdnr-wt-feature-aggregator-devicemanager to start devicemanager service
+
+## helpserver (osgi)
Providing help pages for related web applications
-## featureaggregator
+## netconfnode-state-provider (osgi)
-karaf feature with name sdnr-wt-feature-aggregator to start all services.
+Provide netconf state information to devicemanager and mountpoint-state-provider
+
+## odlux (osgi)
+
+Web applications for user operations for devices
+
+## websocketmanager2 (osgi)
+
+Notification service for browser clients.
+
+## readthedocs
+
+readthedocs - Providing documentation. Scripts to convert documentation within helpserver to the [ccsdk/features]/doc folder
+~
+~
+~
+~
diff --git a/sdnr/wt/common/pom.xml b/sdnr/wt/common/pom.xml
index 1010fa8..d942925 100644
--- a/sdnr/wt/common/pom.xml
+++ b/sdnr/wt/common/pom.xml
@@ -30,7 +30,7 @@
<version>0.7.1-SNAPSHOT</version>
<packaging>jar</packaging>
- <name>ccsdk-features-sdnr-wt :: ${project.artifactId}</name>
+ <name>ccsdk-features :: ${project.artifactId}</name>
<licenses>
<license>
<name>Apache License, Version 2.0</name>
diff --git a/sdnr/wt/data-provider/README.md b/sdnr/wt/data-provider/README.md
new file mode 100644
index 0000000..e8edcb9
--- /dev/null
+++ b/sdnr/wt/data-provider/README.md
@@ -0,0 +1,16 @@
+# sdnr-wt-data-provider
+
+Data-provider bundle manages all access to SDN-R database.
+Database is actually ElasticSearch.
+
+## ES-INIT Script
+
+Central SDN-R script initializing and preparing the database BEFORE SDN-R usage.
+
+Name: es-init.sh
+Dir: provider/src/main/resources
+
+ * Elasticsearch database initialization script using bash and curl commands.
+ * Intended to be executed in a linux command line environment
+ * Needs to be executed before the database is used to initialize type mapping of the indexes
+ * The script is included into the ZIP created by sdnr-wt-feature-aggregator to be available in containers
diff --git a/sdnr/wt/data-provider/daexim/pom.xml b/sdnr/wt/data-provider/daexim/pom.xml
new file mode 100644
index 0000000..a5e46a9
--- /dev/null
+++ b/sdnr/wt/data-provider/daexim/pom.xml
@@ -0,0 +1,160 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ * ============LICENSE_START=======================================================
+ * ONAP : CCSDK.sdnr.wt.data-provider.model
+ * ================================================================================
+ * Copyright (C) 2018 highstreet technologies GmbH Intellectual Property.
+ * All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.onap.ccsdk.features.sdnr.wt</groupId>
+ <artifactId>sdnr-wt-data-provider-daexim</artifactId>
+ <version>0.7.1-SNAPSHOT</version>
+ <name>ccsdk-features :: ${project.artifactId}</name>
+ <packaging>bundle</packaging>
+
+ <parent>
+ <groupId>org.onap.ccsdk.parent</groupId>
+ <artifactId>binding-parent</artifactId>
+ <version>1.5.2-SNAPSHOT</version>
+ <relativePath />
+ </parent>
+
+ <properties>
+ <maven.javadoc.skip>true</maven.javadoc.skip>
+ <databaseport>49401</databaseport>
+ </properties>
+
+ <licenses>
+ <license>
+ <name>Apache License, Version 2.0</name>
+ <url>http://www.apache.org/licenses/LICENSE-2.0</url>
+ </license>
+ </licenses>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.netconf</groupId>
+ <artifactId>sal-netconf-connector</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>sdnr-wt-common</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>sdnr-wt-data-provider-model</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.jacoco</groupId>
+ <artifactId>jacoco-maven-plugin</artifactId>
+ <configuration>
+ <excludes>
+ <exclude>**/gen/**</exclude>
+ <exclude>**/generated-sources/**</exclude>
+ <exclude>**/yang-gen-sal/**</exclude>
+ <exclude>**/pax/**</exclude>
+ </excludes>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>exec-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>generateDTOs</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>exec</goal>
+ </goals>
+ <configuration>
+ <skip>${skipTests}</skip>
+ <executable>bash</executable>
+ <arguments>
+ <argument>${basedir}/../data-provider/provider/src/main/resources/es-init.sh</argument>
+ <argument>initfile</argument>
+ <argument>-f</argument>
+ <argument>${project.build.directory}/EsInit.script</argument>
+ </arguments>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>com.github.alexcojocaru</groupId>
+ <artifactId>elasticsearch-maven-plugin</artifactId>
+ <version>6.16</version>
+ <configuration>
+ <skip>${skipTests}</skip>
+ <clusterName>testCluster</clusterName>
+ <transportPort>9500</transportPort>
+ <httpPort>${databaseport}</httpPort>
+ <version>6.5.0</version>
+ <pathInitScript>${project.build.directory}/EsInit.script</pathInitScript>
+ </configuration>
+ <executions>
+ <execution>
+ <id>start-elasticsearch</id>
+ <phase>process-test-classes</phase>
+ <goals>
+ <goal>runforked</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>stop-elasticsearch</id>
+ <phase>prepare-package</phase>
+ <goals>
+ <goal>stop</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <systemProperties>
+ <property>
+ <name>databaseport</name>
+ <value>${databaseport}</value>
+ </property>
+ </systemProperties>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/sdnr/wt/data-provider/feature/pom.xml b/sdnr/wt/data-provider/feature/pom.xml
new file mode 100644
index 0000000..35d8670
--- /dev/null
+++ b/sdnr/wt/data-provider/feature/pom.xml
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ * ============LICENSE_START=======================================================
+ * ONAP : CCSDK.sdnr.wt.dataprovider.feature
+ * ================================================================================
+ * Copyright (C) 2018 highstreet technologies GmbH Intellectual Property.
+ * All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.onap.ccsdk.parent</groupId>
+ <artifactId>single-feature-parent</artifactId>
+ <version>1.5.2-SNAPSHOT</version>
+ <relativePath />
+ </parent>
+
+ <groupId>org.onap.ccsdk.features.sdnr.wt</groupId>
+ <artifactId>sdnr-wt-data-provider-feature</artifactId>
+ <version>0.7.1-SNAPSHOT</version>
+ <packaging>feature</packaging>
+
+ <name>ccsdk-features :: ${project.artifactId} :: feature</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>sdnr-wt-data-provider-provider</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/sdnr/wt/data-provider/installer/pom.xml b/sdnr/wt/data-provider/installer/pom.xml
new file mode 100755
index 0000000..f83c21f
--- /dev/null
+++ b/sdnr/wt/data-provider/installer/pom.xml
@@ -0,0 +1,139 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ * ============LICENSE_START=======================================================
+ * ONAP : CCSDK.sdnr.wt.dataprovider.installer
+ * ================================================================================
+ * Copyright (C) 2018 highstreet technologies GmbH Intellectual Property.
+ * All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.onap.ccsdk.parent</groupId>
+ <artifactId>odlparent-lite</artifactId>
+ <version>1.5.2-SNAPSHOT</version>
+ <relativePath/>
+ </parent>
+
+ <groupId>org.onap.ccsdk.features.sdnr.wt</groupId>
+ <artifactId>sdnr-wt-data-provider-installer</artifactId>
+ <version>0.7.1-SNAPSHOT</version>
+ <packaging>pom</packaging>
+
+ <name>ccsdk-features :: ${project.artifactId}</name>
+
+ <properties>
+ <application.name>sdnr-wt-data-provider</application.name>
+ <include.transitive.dependencies>false</include.transitive.dependencies>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.onap.ccsdk.features.sdnr.wt</groupId>
+ <artifactId>${application.name}-feature</artifactId>
+ <version>${project.version}</version>
+ <type>xml</type>
+ <classifier>features</classifier>
+ <exclusions>
+ <exclusion>
+ <groupId>*</groupId>
+ <artifactId>*</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.ccsdk.features.sdnr.wt</groupId>
+ <artifactId>${application.name}-provider</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>maven-repo-zip</id>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ <phase>package</phase>
+ <configuration>
+ <attach>true</attach>
+ <finalName>stage/${application.name}-${project.version}</finalName>
+ <descriptors>
+ <descriptor>src/assembly/assemble_mvnrepo_zip.xml</descriptor>
+ </descriptors>
+ <appendAssemblyId>true</appendAssemblyId>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>copy-nested-dependencies</id>
+ <goals>
+ <goal>copy-dependencies</goal>
+ </goals>
+ <phase>prepare-package</phase>
+ <configuration>
+ <transitive>true</transitive>
+ <outputDirectory>${project.build.directory}/assembly/system</outputDirectory>
+ <overWriteReleases>false</overWriteReleases>
+ <overWriteSnapshots>true</overWriteSnapshots>
+ <overWriteIfNewer>true</overWriteIfNewer>
+ <useRepositoryLayout>true</useRepositoryLayout>
+ <addParentPoms>false</addParentPoms>
+ <copyPom>false</copyPom>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-resources-plugin</artifactId>
+ <version>2.6</version>
+ <executions>
+ <execution>
+ <id>copy-schemas</id>
+ <goals>
+ <goal>copy-resources</goal>
+ </goals>
+ <phase>validate</phase>
+ <configuration>
+ <outputDirectory>${project.build.directory}/assembly/cache/schema</outputDirectory>
+ <resources>
+ <resource>
+ <directory>${basedir}/../provider/src/main/resources/preload.cache.schema</directory>
+ <includes>
+ <include>*.yang</include>
+ </includes>
+ <filtering>true</filtering>
+ </resource>
+ </resources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/sdnr/wt/data-provider/installer/src/assembly/assemble_mvnrepo_zip.xml b/sdnr/wt/data-provider/installer/src/assembly/assemble_mvnrepo_zip.xml
new file mode 100644
index 0000000..c4eb9aa
--- /dev/null
+++ b/sdnr/wt/data-provider/installer/src/assembly/assemble_mvnrepo_zip.xml
@@ -0,0 +1,49 @@
+<!--
+ ============LICENSE_START=======================================================
+ ONAP : CCSDK
+ ================================================================================
+ Copyright (C) 2017 AT&T Intellectual Property. All rights
+ reserved.
+ ================================================================================
+ 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.
+ ============LICENSE_END=========================================================
+ -->
+
+<!-- Defines how we build the .zip file which is our distribution. -->
+
+<assembly
+ xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
+ <id>repo</id>
+ <formats>
+ <format>zip</format>
+ </formats>
+
+ <!-- we want "system" and related files right at the root level
+ as this file is suppose to be unzip on top of a karaf
+ distro. -->
+ <includeBaseDirectory>false</includeBaseDirectory>
+
+ <fileSets>
+ <fileSet>
+ <directory>target/assembly/</directory>
+ <outputDirectory>.</outputDirectory>
+ <excludes>
+ </excludes>
+ </fileSet>
+ </fileSets>
+
+
+
+</assembly>
diff --git a/sdnr/wt/data-provider/model/pom.xml b/sdnr/wt/data-provider/model/pom.xml
new file mode 100644
index 0000000..b84639e
--- /dev/null
+++ b/sdnr/wt/data-provider/model/pom.xml
@@ -0,0 +1,80 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ * ============LICENSE_START=======================================================
+ * ONAP : CCSDK.sdnr.wt.data-provider.model
+ * ================================================================================
+ * Copyright (C) 2018 highstreet technologies GmbH Intellectual Property.
+ * All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.onap.ccsdk.parent</groupId>
+ <artifactId>binding-parent</artifactId>
+ <version>1.5.2-SNAPSHOT</version>
+ <relativePath />
+ </parent>
+
+ <groupId>org.onap.ccsdk.features.sdnr.wt</groupId>
+ <artifactId>sdnr-wt-data-provider-model</artifactId>
+ <version>0.7.1-SNAPSHOT</version>
+ <packaging>bundle</packaging>
+
+ <name>ccsdk-features :: ${project.artifactId}</name>
+ <licenses>
+ <license>
+ <name>Apache License, Version 2.0</name>
+ <url>http://www.apache.org/licenses/LICENSE-2.0</url>
+ </license>
+ </licenses>
+
+ <properties>
+ <maven.javadoc.skip>true</maven.javadoc.skip>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.opendaylight.netconf</groupId>
+ <artifactId>sal-netconf-connector</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>sdnr-wt-common</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.jacoco</groupId>
+ <artifactId>jacoco-maven-plugin</artifactId>
+ <configuration>
+ <excludes>
+ <exclude>**/gen/**</exclude>
+ <exclude>**/generated-sources/**</exclude>
+ <exclude>**/yang-gen-sal/**</exclude>
+ <exclude>**/pax/**</exclude>
+ </excludes>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/sdnr/wt/data-provider/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/model/ArchiveCleanProvider.java b/sdnr/wt/data-provider/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/model/ArchiveCleanProvider.java
new file mode 100644
index 0000000..00ec2e6
--- /dev/null
+++ b/sdnr/wt/data-provider/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/model/ArchiveCleanProvider.java
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
+ * =================================================================================================
+ * 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.
+ * ============LICENSE_END==========================================================================
+ ******************************************************************************/
+package org.onap.ccsdk.features.sdnr.wt.dataprovider.model;
+
+import java.util.Date;
+
+public interface ArchiveCleanProvider {
+
+ /**
+ * Remove all index data older, than specified
+ * @param olderAreOutdated time to specify older elements
+ * @return number of removed elements
+ */
+ int doIndexClean(Date olderAreOutdated);
+
+ /**
+ * Get number of elements older then
+ * @param olderAreOutdated date to compare with and specify older elements
+ * @return number of elements
+ */
+ public int getNumberOfOldObjects(Date olderAreOutdated);
+
+
+}
diff --git a/sdnr/wt/data-provider/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/model/DataProvider.java b/sdnr/wt/data-provider/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/model/DataProvider.java
new file mode 100644
index 0000000..fd25661
--- /dev/null
+++ b/sdnr/wt/data-provider/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/model/DataProvider.java
@@ -0,0 +1,102 @@
+/**
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
+ * =================================================================================================
+ * 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.
+ * ============LICENSE_END==========================================================================
+ */
+package org.onap.ccsdk.features.sdnr.wt.dataprovider.model;
+
+import java.util.Date;
+import java.util.List;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ConnectionlogEntity;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.EventlogEntity;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.FaultcurrentEntity;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.FaultlogEntity;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.Inventory;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.NetworkElementConnectionEntity;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.PmdataEntity;
+
+public interface DataProvider extends ArchiveCleanProvider {
+
+ // -- Connection log
+ void writeConnectionLog(ConnectionlogEntity event);
+
+ // -- Event log
+ void writeEventLog(EventlogEntity event);
+
+ void writeFaultLog(FaultlogEntity fault);
+
+ void updateFaultCurrent(FaultcurrentEntity fault);
+
+ /**
+ * Remove all entries for one node
+ *
+ * @param nodeName contains the mountpointname
+ * @return number of deleted entries
+ */
+ int clearFaultsCurrentOfNode(String nodeName);
+
+ /**
+ * Remove all entries for one node
+ *
+ * @param nodeName contains the mountpointname
+ * @param objectId of element to be deleted
+ * @return number of deleted entries
+ */
+ int clearFaultsCurrentOfNodeWithObjectId(String nodeName, String objectId);
+
+ /**
+ * Deliver list with all mountpoint/node-names in the database.
+ *
+ * @return List of all mountpoint/node-names the had active alarms.
+ */
+ List<String> getAllNodesWithCurrentAlarms();
+
+ /**
+ * write internal equipment to database
+ * @param internalEquipment with mandatory fields.
+ */
+ void writeInventory(Inventory internalEquipment);
+
+ /**
+ *
+ * @param networkElementConnectionEntitiy to wirte to DB
+ * @param nodeId Id for this DB element
+ */
+ void updateNetworkConnectionDeviceType(NetworkElementConnectionEntity networkElementConnectionEntitiy,
+ String nodeId);
+
+ /**
+ * Update after new mountpoint registration
+ * @param networkElementConnectionEntitiy data
+ * @param nodeId of device (mountpoint name)
+ */
+ void updateNetworkConnection22(NetworkElementConnectionEntity networkElementConnectionEntitiy, String nodeId);
+
+ void removeNetworkConnection(String nodeId);
+
+ @Override
+ int doIndexClean(Date olderAreOutdated);
+
+ @Override
+ int getNumberOfOldObjects(Date olderAreOutdated);
+
+ List<NetworkElementConnectionEntity> getNetworkElementConnections();
+
+ /**
+ * @param list
+ */
+ void doWritePerformanceData(List<PmdataEntity> list);
+
+}
diff --git a/sdnr/wt/data-provider/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/model/HtDatabaseMaintenance.java b/sdnr/wt/data-provider/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/model/HtDatabaseMaintenance.java
new file mode 100644
index 0000000..11681c0
--- /dev/null
+++ b/sdnr/wt/data-provider/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/model/HtDatabaseMaintenance.java
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
+ * =================================================================================================
+ * 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.
+ * ============LICENSE_END==========================================================================
+ ******************************************************************************/
+package org.onap.ccsdk.features.sdnr.wt.dataprovider.model;
+
+import java.util.List;
+import org.eclipse.jdt.annotation.Nullable;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.MaintenanceEntity;
+
+/**
+ * @author herbert
+ *
+ */
+public interface HtDatabaseMaintenance {
+
+ /**
+ * @param mountPointNodeName
+ */
+ MaintenanceEntity createIfNotExists(String mountPointNodeName);
+
+ /**
+ * @param mountPointNodeName
+ */
+ void deleteIfNotRequired(String mountPointNodeName);
+
+ /**
+ * @return
+ */
+ List<MaintenanceEntity> getAll();
+
+ /**
+ * @param mountpointName
+ * @return
+ */
+ MaintenanceEntity getMaintenance(@Nullable String mountpointName);
+
+ /**
+ * @param m
+ */
+ MaintenanceEntity setMaintenance(MaintenanceEntity m);
+
+}
diff --git a/sdnr/wt/data-provider/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/model/IEntityDataProvider.java b/sdnr/wt/data-provider/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/model/IEntityDataProvider.java
new file mode 100644
index 0000000..95ea075
--- /dev/null
+++ b/sdnr/wt/data-provider/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/model/IEntityDataProvider.java
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
+ * =================================================================================================
+ * 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.
+ * ============LICENSE_END==========================================================================
+ ******************************************************************************/
+package org.onap.ccsdk.features.sdnr.wt.dataprovider.model;
+
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.StatusChangedHandler.StatusKey;
+
+public interface IEntityDataProvider {
+
+ /** Get provider for database read/write operations **/
+ public DataProvider getDataProvider();
+
+ /** Get provider to access read/write operations for maintenance **/
+ public HtDatabaseMaintenance getHtDatabaseMaintenance();
+
+ /** Set overall ready status from outside of this data-provider **/
+ public void setReadyStatus(boolean status);
+
+ /** Set some static status information after startup */
+ public void setStatus(StatusKey key,String value);
+
+ /** Database configuration information **/
+ public IEsConfig getEsConfig();
+
+ /** Provide NetconfTimeStamp handler **/
+ public NetconfTimeStamp getConverter();
+}
diff --git a/sdnr/wt/data-provider/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/model/IEsConfig.java b/sdnr/wt/data-provider/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/model/IEsConfig.java
new file mode 100644
index 0000000..f41095d
--- /dev/null
+++ b/sdnr/wt/data-provider/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/model/IEsConfig.java
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
+ * =================================================================================================
+ * 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.
+ * ============LICENSE_END==========================================================================
+ ******************************************************************************/
+package org.onap.ccsdk.features.sdnr.wt.dataprovider.model;
+
+import org.onap.ccsdk.features.sdnr.wt.common.configuration.filechange.IConfigChangedListener;
+
+public interface IEsConfig {
+
+ String getCluster();
+
+ /**
+ * @return seconds
+ */
+ long getArchiveCheckIntervalSeconds();
+
+ /**
+ * @return seconds
+ */
+ long getArchiveLifetimeSeconds();
+
+ /**
+ * @param archiveCleanService
+ */
+ void unregisterConfigChangedListener(IConfigChangedListener archiveCleanService);
+
+ /**
+ * @param archiveCleanService
+ */
+ void registerConfigChangedListener(IConfigChangedListener archiveCleanService);
+
+
+
+}
diff --git a/sdnr/wt/data-provider/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/model/NetconfTimeStamp.java b/sdnr/wt/data-provider/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/model/NetconfTimeStamp.java
new file mode 100644
index 0000000..5bed9f7
--- /dev/null
+++ b/sdnr/wt/data-provider/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/model/NetconfTimeStamp.java
@@ -0,0 +1,87 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
+ * =================================================================================================
+ * 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.
+ * ============LICENSE_END==========================================================================
+ ******************************************************************************/
+package org.onap.ccsdk.features.sdnr.wt.dataprovider.model;
+
+import java.time.LocalDateTime;
+import java.util.Date;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime;
+
+/**
+ * @author herbert
+ *
+ */
+public interface NetconfTimeStamp {
+
+ /**
+ * Get actual timestamp as NETCONF specific type NETCONF/YANG 1.0 Format
+ *
+ * @return String with Date in NETCONF/YANG Format Version 1.0.
+ */
+ String getTimeStampAsNetconfString();
+
+ /**
+ * Get actual timestamp as NETCONF specific type NETCONF/YANG 1.0 Format
+
+ * @return String with Date in NETCONF/YANG Format Version 1.0.
+ */
+ String getTimeStampAsNetconfString(Date date);
+
+ /**
+ * Get actual timestamp as NETCONF specific type NETCONF/YANG 1.0 Format in GMT
+ *
+ * @return DateAndTime Type 1.0. Date in NETCONF/YANG Format Version 1.0.
+ */
+ DateAndTime getTimeStamp();
+
+ /**
+ * Get time from date as NETCONF specific type NETCONF/YANG 1.0 Format in GMT
+ * @param date specifying the date and time
+ * @return DateAndTime Type 1.0. Date in NETCONF/YANG Format Version 1.0.
+ */
+ DateAndTime getTimeStamp(Date date);
+
+ /**
+ * Get time from date as NETCONF specific type NETCONF/YANG 1.0 Format in GMT
+ * @param date specifying the date and time
+ * @return DateAndTime Type 1.0. Date in NETCONF/YANG Format Version 1.0.
+ */
+ DateAndTime getTimeStamp(String date);
+
+ /**
+ * Return the String with a NETCONF time converted to long
+ *
+ * @param netconfTime as String according the formats given above
+ * @return Epoch milliseconds
+ * @throws IllegalArgumentException In case of no compliant time format definition for the string
+ */
+ long getTimeStampFromNetconfAsMilliseconds(String netconfTime) throws IllegalArgumentException;
+
+ /**
+ * Deliver String result.
+ *
+ * @param netconfTime as String according the formats given above
+ * @return If successful: String in ISO8601 Format for database and presentation. If "wrong formed
+ * input" the Input string with the prefix "Maleformed date" is delivered back.
+ */
+ String getTimeStampFromNetconf(String netconfTime);
+
+ Date getDateFromNetconf(String netconfTime);
+
+ String getTimeStampAsNetconfString(LocalDateTime dt);
+
+}
\ No newline at end of file
diff --git a/sdnr/wt/data-provider/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/model/StatusChangedHandler.java b/sdnr/wt/data-provider/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/model/StatusChangedHandler.java
new file mode 100644
index 0000000..fa64d4d
--- /dev/null
+++ b/sdnr/wt/data-provider/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/model/StatusChangedHandler.java
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
+ * =================================================================================================
+ * 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.
+ * ============LICENSE_END==========================================================================
+ ******************************************************************************/
+package org.onap.ccsdk.features.sdnr.wt.dataprovider.model;
+
+
+public interface StatusChangedHandler {
+
+ public enum StatusKey {
+ CLUSTER_SIZE,
+
+ }
+ public void onStatusChanged(StatusKey key,String newValue);
+
+}
diff --git a/sdnr/wt/data-provider/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/model/types/NetconfTimeStampImpl.java b/sdnr/wt/data-provider/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/model/types/NetconfTimeStampImpl.java
new file mode 100644
index 0000000..f5dd652
--- /dev/null
+++ b/sdnr/wt/data-provider/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/model/types/NetconfTimeStampImpl.java
@@ -0,0 +1,215 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
+ * =================================================================================================
+ * 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.
+ * ============LICENSE_END==========================================================================
+ ******************************************************************************/
+package org.onap.ccsdk.features.sdnr.wt.dataprovider.model.types;
+
+import java.time.LocalDateTime;
+import java.time.OffsetDateTime;
+import java.time.ZoneOffset;
+import java.time.ZonedDateTime;
+import java.time.format.DateTimeFormatter;
+import java.time.format.DateTimeParseException;
+import java.util.Date;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.NetconfTimeStamp;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * 2019/06/17 Redesign to ZonedDateTime because of sync problems.
+ *
+ * Function is handling the NETCONF and the format used by database and restconf communication.
+ *
+ * Input supported for the formats used in NETCONF messages:
+ *
+ * Format1 ISO 8601 2017-01-18T11:44:49.482-05:00
+ *
+ * Format2 NETCONF - pattern from ietf-yang-types "2013-07-15" Pattern:
+ * "\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[\+\-](\d{2}):(\d{2}))"
+ *
+ * Format3 NETCONF DateAndTime CoreModel-CoreFoundationModule-TypeDefinitions vom
+ * 2016-07-01 Example1: 20170118114449.1Z Example2: 20170118114449.1-0500 Pattern:
+ * "\d{4}\d{2}\d{2}\d{2}\d{2}\d{2}.\d+?(Z|[\+\-](\d{2})(\d{2}))" typedef DateAndTime { description
+ * "This primitive type defines the date and time according to the following structure:
+ * 'yyyyMMddhhmmss.s[Z|{+|-}HHMm]' where: yyyy '0000'..'9999' year MM '01'..'12' month dd '01'..'31'
+ * day hh '00'..'23' hour mm '00'..'59' minute ss '00'..'59' second s '.0'..'.9' tenth of second
+ * (set to '.0' if EMS or NE cannot support this granularity) Z 'Z' indicates UTC (rather than local
+ * time) {+|-} '+' or '-' delta from UTC HH '00'..'23' time zone difference in hours Mm '00'..'59'
+ * time zone difference in minutes."; type string; } Format4 E/// specific Example1:
+ * 2017-01-23T13:32:38-05:00 Example2: 2017-01-23T13:32-05:00
+ *
+ * Input formats netconfTime as String according the formats given above
+ *
+ * Return format is String in ISO8601 Format for database and presentation.
+ *
+ * Example formats:
+ * 1) ISO8601. Example 2017-01-18T11:44:49.482-05:00
+ * 2) Microwave ONF. Examples 20170118114449.1Z, 20170118114449.1-0500
+ * 3.1) Ericson. Example: 2017-01-23T13:32:38-05:00
+ * 3.2) Ericson. Example: 2017-01-23T13:32-05:00
+ * Always 10 Groups,
+ * 1:Year 2:Month 3:day 4:Hour 5:minute 6:optional sec 7:optional ms 8:optional Z or 9:offset
+ * signedhour 10:min
+ *
+ * Template:
+ * private static final NetconfTimeStamp NETCONFTIME_CONVERTER = NetconfTimeStamp.getConverter();
+ */
+
+public class NetconfTimeStampImpl implements NetconfTimeStamp {
+ private static final Logger LOG = LoggerFactory.getLogger(NetconfTimeStamp.class);
+
+ private static final NetconfTimeStamp CONVERTER = new NetconfTimeStampImpl();
+
+ /**
+ * Specify the input format expected from netconf, and from specific devices.
+ */
+ private static DateTimeFormatter formatterInput = DateTimeFormatter.ofPattern(""
+ + "[yyyy-MM-dd'T'HH:mm[:ss][.SSS][.SS][.S][xxx][xx][X][Z]]"
+ + "[yyyyMMddHHmmss[.SSS][.SS][.S][xxx][xx][X][Z]]"
+ ).withZone(ZoneOffset.UTC);
+
+ /**
+ * Specify output format that is used internally
+ */
+ private static DateTimeFormatter formatterOutput = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.S'Z'")
+ .withZone(ZoneOffset.UTC);
+
+ /**
+ * Use static access
+ */
+ private NetconfTimeStampImpl() {
+ }
+
+ /*
+ * ------------------------------------ Public function
+ */
+
+ /**
+ * Use this function to get the converter
+ * @return global converter
+ */
+ public static NetconfTimeStamp getConverter() {
+ return CONVERTER;
+ }
+
+ /**
+ * Get actual timestamp as NETCONF specific type NETCONF/YANG 1.0 Format
+ *
+ * @return String with Date in NETCONF/YANG Format Version 1.0.
+ */
+ @Override
+ public String getTimeStampAsNetconfString() {
+ return ZonedDateTime.now(ZoneOffset.UTC).format(formatterOutput);
+ }
+
+ /**
+ * Get actual timestamp as NETCONF specific type NETCONF/YANG 1.0 Format
+
+ * @return String with Date in NETCONF/YANG Format Version 1.0.
+ */
+ @Override
+ public String getTimeStampAsNetconfString(Date date) {
+ return ZonedDateTime.ofInstant(date.toInstant(),ZoneOffset.UTC).format(formatterOutput);
+ }
+
+
+
+ /**
+ * Get actual timestamp as NETCONF specific type NETCONF/YANG 1.0 Format in GMT
+ *
+ * @return DateAndTime Type 1.0. Date in NETCONF/YANG Format Version 1.0.
+ */
+ @Override
+ public DateAndTime getTimeStamp() {
+ return DateAndTime.getDefaultInstance(getTimeStampAsNetconfString());
+ }
+
+ /**
+ * Get time from date as NETCONF specific type NETCONF/YANG 1.0 Format in GMT
+ * @param date specifying the date and time
+ * @return DateAndTime Type 1.0. Date in NETCONF/YANG Format Version 1.0.
+ */
+ @Override
+ public DateAndTime getTimeStamp(Date date) {
+ return DateAndTime.getDefaultInstance(getTimeStampAsNetconfString(date));
+ }
+ /**
+ * Get time from date as NETCONF specific type NETCONF/YANG 1.0 Format in GMT
+ * @param date specifying the date and time
+ * @return DateAndTime Type 1.0. Date in NETCONF/YANG Format Version 1.0.
+ */
+ @Override
+ public DateAndTime getTimeStamp(String date) {
+ return DateAndTime.getDefaultInstance(date);
+ }
+
+ /**
+ * Return the String with a NETCONF time converted to long
+ *
+ * @param netconfTime as String according the formats given above
+ * @return Epoch milliseconds
+ * @throws IllegalArgumentException In case of no compliant time format definition for the string
+ */
+ @Override
+ public long getTimeStampFromNetconfAsMilliseconds(String netconfTime) throws IllegalArgumentException {
+ try {
+ long utcMillis = doParse(netconfTime).toInstant().toEpochMilli();
+ return utcMillis;
+ } catch (DateTimeParseException e) {
+ throw new IllegalArgumentException(
+ "No pattern for NETCONF data string: " + netconfTime + " Msg:" + e.getMessage());
+ }
+ }
+
+ /**
+ * Deliver String result.
+ *
+ * @param netconfTime as String according the formats given above
+ * @return If successful: String in ISO8601 Format for database and presentation. If "wrong formed
+ * input" the Input string with the prefix "Maleformed date" is delivered back.
+ */
+ @Override
+ public String getTimeStampFromNetconf(String netconfTime) {
+ try {
+ String inputUTC = doParse(netconfTime).format(formatterOutput);
+ return inputUTC;
+ } catch (Exception e) {
+ LOG.info(e.getMessage());
+ }
+ LOG.debug("No pattern for NETCONF data string: {}", netconfTime);
+ return "Malformed date: " + netconfTime; // Error handling
+ }
+
+ /*----------------------------------------------------
+ * Private functions
+ */
+
+ private OffsetDateTime doParse(String netconfTime) {
+ return OffsetDateTime.parse(netconfTime, formatterInput);
+ }
+
+ @Override
+ public Date getDateFromNetconf(String netconfTime) {
+ return Date.from(LocalDateTime.parse(netconfTime, formatterInput).atZone(ZoneOffset.UTC).toInstant());
+ }
+
+ @Override
+ public String getTimeStampAsNetconfString(LocalDateTime dt) {
+ return formatterOutput.format(dt);
+ }
+
+}
diff --git a/sdnr/wt/data-provider/model/src/main/yang/dataprovider.yang b/sdnr/wt/data-provider/model/src/main/yang/dataprovider.yang
new file mode 100644
index 0000000..3a56661
--- /dev/null
+++ b/sdnr/wt/data-provider/model/src/main/yang/dataprovider.yang
@@ -0,0 +1,1228 @@
+module data-provider {
+
+ yang-version 1;
+ namespace "urn:opendaylight:params:xml:ns:yang:data-provider";
+ prefix "odluxprovider";
+
+ import ietf-yang-types { prefix "yang"; revision-date 2013-07-15; }
+ import netconf-node-topology { prefix "nettop"; revision-date 2015-01-14; }
+ description
+ "data-provider api module";
+
+ revision "2019-08-01" {
+ description
+ "Initial revision";
+ }
+ // --- typedef
+ typedef Entity {
+ description "Data type and alias for elasticsearch or table name for SQL database.";
+ type enumeration {
+ enum connectionlog {
+ description "logs mountpoint connection state changes";
+ }
+ enum faultcurrent {
+ description "current faults";
+ }
+ enum eventlog {
+ description "logs for all notifications e.g. netconf, ves and internal events";
+ }
+ enum faultlog {
+ description "faultlog information";
+ }
+ enum historicalperformance15min {
+ description "performance data";
+ }
+ enum historicalperformance24h {
+ description "performance data";
+ }
+ enum mediator-server {
+ description "list of mediator servers";
+ }
+ enum networkelement-connection {
+ description "list of mountpoints for netconf devices (joint required-network-element+mdsal
+ state";
+ }
+ enum inventoryequipment {
+ description "list of equipment inventory";
+ }
+ enum maintenancemode {
+ description "list of maintenance setting";
+ }
+ }
+ }
+ typedef SortOrder {
+ type enumeration {
+ enum ascending {
+ }
+ enum descending {
+ }
+ }
+ description "Entities for odlux clients";
+ }
+ typedef FilterProperty {
+ type string;
+ }
+
+ typedef NotificationType {
+ type enumeration {
+ enum ProblemNotificationXml {
+ description "";
+ }
+ enum AttributeValueChangedNotificationXml {
+ description "";
+ }
+ }
+ }
+
+ typedef ConnectionLogStatus {
+ type enumeration {
+ enum Mounted {
+ description "Mountpoint created";
+ }
+ enum Unmounted {
+ description "Mountpoint removed";
+ }
+ enum Connecting {
+ description "Mountpoint establishing connection";
+ }
+ enum Connected {
+ description "Mountpoint connection established";
+ }
+ enum UnableToConnect {
+ description "Mountpoint connection not possible";
+ }
+ enum Disconnected {
+ description "Required and mountpoint removed";
+ }
+ enum Undefined {
+ description "Status not available";
+ }
+ }
+ }
+ typedef NetworkElementDeviceType {
+ type enumeration {
+ enum Wireless {
+ description "implements microwave-model.yang or air-interface.yang";
+ }
+ enum RAN {
+ description "implements sth. like o-ran*.yang";
+ }
+ enum ORAN {
+ description "implements RAN according to o-ran*.yang";
+ }
+ enum RAN3GPP {
+ description "implements RAN according to _3gpp-ran*.yang";
+ }
+ enum Optical {
+ description "implements tapi-*.yang or org-openroadm*.yang";
+ }
+ enum Router {
+ description "implements vlan-interface.yang";
+ }
+ enum NtsManager {
+
+ description "Simulation of device";
+ }
+ enum Nonsupported {
+ description "Device type known, but not support";
+ }
+ enum Unknown {
+ description "Device type at this point of time unknown";
+ }
+ }
+ }
+ typedef severity-type {
+ type enumeration {
+ enum NonAlarmed {
+ description "problem cleared indication";
+ }
+ enum Warning {
+ description "problem level";
+ }
+ enum Minor {
+ description "problem level";
+ }
+ enum Major {
+ description "problem level";
+ }
+ enum Critical {
+ description "problem level";
+ }
+ }
+ description "According to ITU-T M.3160";
+ }
+ typedef source-type {
+ type enumeration {
+ enum ves {
+ description "VES Interface";
+ }
+ enum netconf {
+ description "NETCONF Interface";
+ }
+ enum controller {
+ description "SDN Controller";
+ }
+ enum unknown {
+ description "Unknown source";
+ }
+ }
+ }
+ typedef granularity-period-type {
+ type enumeration {
+ enum unknown {
+ description "none";
+ }
+ enum period-15-min {
+ description "none";
+ }
+ enum period-24-hours {
+ description "none";
+ }
+ }
+ description "The enumeration with the options for granularity period of the performance data similar to g.874.1-model";
+ }
+ // --- grouping and builder-container
+ grouping connectionlog-entity {
+ leaf id {
+ type string;
+ description "database id";
+ }
+ leaf node-id {
+ type string;
+ description "the node/mountpoint which connection state has changed";
+ }
+ leaf timestamp {
+ type yang:date-and-time;
+ description "timestamp when event happened";
+ }
+ leaf status {
+ type ConnectionLogStatus;
+ description "new state of the connection of the device";
+ }
+ }
+ container connectionlog {
+ description "builder";
+ uses connectionlog-entity;
+ }
+ grouping object-change-reference {
+ description "Reference of of object (e.g. Interface pack) owned by a node";
+ leaf node-id {
+ type string;
+ }
+ leaf counter {
+ type int32;
+ }
+ leaf timestamp {
+ type yang:date-and-time;
+ }
+ leaf object-id {
+ type string;
+ }
+ }
+ grouping source-reference {
+ description "Identify a source";
+ leaf source-type {
+ type source-type;
+ }
+ }
+ grouping fault {
+ description "Fault event of an object";
+ leaf problem {
+ type string;
+ }
+ leaf severity {
+ type severity-type;
+ }
+ }
+ grouping attribute-change {
+ description "update change of an attribute";
+ leaf attribute-name {
+ type string;
+ }
+ leaf new-value {
+ type string;
+ }
+ }
+ grouping entity-id {
+ description "Unique database id of entity";
+ leaf id {
+ type string;
+ }
+ }
+ grouping faultcurrent-entity {
+ description "Current fault status";
+ uses object-change-reference;
+ uses fault;
+ uses entity-id;
+ }
+ container faultcurrent {
+ description "builder";
+ uses faultcurrent-entity;
+ }
+ grouping faultlog-entity {
+ description "Changed fault indication";
+ uses source-reference;
+ uses object-change-reference;
+
+ uses fault;
+ uses entity-id;
+ }
+ container faultlog {
+ description "builder";
+ uses faultlog-entity;
+ }
+ grouping eventlog-entity {
+ description "One change event of devices";
+ uses source-reference;
+ uses object-change-reference;
+ uses attribute-change;
+ uses entity-id;
+ }
+ container eventlog {
+ description "builder";
+ uses eventlog-entity;
+ }
+ grouping filter {
+ leaf description {
+ type string;
+ description "Filter specific description";
+ }
+ leaf start {
+ type yang:date-and-time;
+ description "begin of maintenance-mode";
+ }
+ leaf end {
+ type yang:date-and-time;
+ description "end of maintenance-mode";
+ }
+ leaf object-id-ref {
+ type string;
+ description "object id to filter on, or empty for all";
+ }
+ leaf problem {
+ type string;
+ description "name of the problem to filter or empty for all";
+ }
+ }
+ grouping maintenance-entity {
+ description "Maintenance mode for a device. ";
+ leaf id {
+ mandatory true;
+ type string;
+ description "Key to get/set configuration entry in database. Normally Mountpoint-name
+ is used as key id of node.";
+ }
+ leaf node-id {
+ mandatory true;
+ type string;
+ description "";
+ }
+ leaf active {
+ type boolean;
+ description "Configuration to activate or deactivate this entry";
+ }
+ uses filter;
+ }
+ container maintenance {
+ description "builder";
+ uses maintenance-entity;
+ }
+ grouping mediator-server-entity {
+ leaf id {
+ mandatory true;
+ type string;
+ }
+ leaf url {
+ type string;
+ }
+ leaf name {
+ type string;
+ }
+ }
+ grouping pmdata-base {
+ description "Performance data base information";
+ leaf node-name {
+ type string;
+ }
+ leaf uuid-interface {
+ type string;
+ }
+ leaf layer-protocol-name {
+ type string;
+ }
+ leaf radio-signal-id {
+ type string;
+ }
+ leaf time-stamp {
+ type yang:date-and-time;
+ }
+ leaf suspect-interval-flag {
+ type boolean;
+ }
+ leaf granularity-period {
+ type granularity-period-type;
+ }
+ leaf scanner-id {
+ type string;
+ }
+ }
+ grouping pmdata-microwave {
+ description "Consolidated performance information of all microwave model interface pacs";
+ leaf es {
+ type int32;
+ units "s";
+ default -1;
+ config false;
+ description "Number of errored seconds.";
+ }
+ leaf ses {
+ type int32;
+ units "s";
+ default -1;
+ config false;
+ description "Number of severely errored seconds.";
+ }
+ leaf cses {
+ type int32;
+ units "s";
+ default -1;
+ config false;
+ description "Number of consecutive severely errored seconds.";
+ }
+ leaf unavailability {
+ type int32;
+ units "s";
+ default -1;
+ config false;
+ description "Total time of unavailability in seconds.";
+ }
+ leaf tx-level-min {
+ type int8;
+ units "dBm";
+ default 99;
+ config false;
+ description "Minimum transmit power. Signed integers are required.";
+ }
+ leaf tx-level-max {
+ type int8;
+ units "dBm";
+ default 99;
+ config false;
+ description "Maximum transmit power. Signed integers are required.";
+ }
+ leaf tx-level-avg {
+ type int8;
+ units "dBm";
+ default 99;
+ config false;
+ description "Averaged transmit power. Signed integers are required.";
+ }
+ leaf rx-level-min {
+ type int8;
+ units "dBm";
+ default 99;
+ config false;
+ description "Minimum receive level. Signed integers are required.";
+ }
+ leaf rx-level-max {
+ type int8;
+ units "dBm";
+ default 99;
+ config false;
+ description "Maximum receive level. Signed integers are required.";
+ }
+ leaf rx-level-avg {
+ type int8;
+ units "dBm";
+ default 99;
+ config false;
+ description "Averaged receive level. Signed integers are required.";
+ }
+ leaf time2-states {
+ type int32;
+ units "s";
+ default -1;
+ config false;
+ description "Sum of all seconds the transmitter operated in e.g. BPSK.";
+ }
+ leaf time4-states-s {
+ type int32;
+ units "s";
+ default -1;
+ config false;
+ description "none";
+ }
+ leaf time4-states {
+ type int32;
+ units "s";
+ default -1;
+ config false;
+ description "none";
+ }
+ leaf time8-states {
+ type int32;
+ units "s";
+ default -1;
+ config false;
+ description "none";
+ }
+ leaf time16-states-s {
+ type int32;
+ units "s";
+ default -1;
+ config false;
+ description "none";
+ }
+ leaf time16-states {
+ type int32;
+ units "s";
+ default -1;
+ config false;
+ description "none";
+ }
+ leaf time32-states {
+ type int32;
+ units "s";
+ default -1;
+ config false;
+ description "none";
+ }
+ leaf time64-states {
+ type int32;
+ units "s";
+ default -1;
+ config false;
+ description "none";
+ }
+ leaf time128-states {
+ type int32;
+ units "s";
+ default -1;
+ config false;
+ description "none";
+ }
+ leaf time256-states {
+ type int32;
+ units "s";
+ default -1;
+ config false;
+ description "none";
+ }
+ leaf time512-states {
+ type int32;
+ units "s";
+ default -1;
+ config false;
+ description "none";
+ }
+ leaf time512-states-l {
+ type int32;
+ units "s";
+ default -1;
+ config false;
+ description "none";
+ }
+ leaf time1024-states {
+ type int32;
+ units "s";
+ default -1;
+ config false;
+ description "none";
+ }
+ leaf time1024-states-l {
+ type int32;
+ units "s";
+ default -1;
+ config false;
+ description "none";
+ }
+ leaf time2048-states {
+ type int32;
+ units "s";
+ default -1;
+ config false;
+ description "none";
+ }
+ leaf time2048-states-l {
+ type int32;
+ units "s";
+ default -1;
+ config false;
+ description "none";
+ }
+ leaf time4096-states {
+ type int32;
+ units "s";
+ default -1;
+ config false;
+ description "none";
+ }
+ leaf time4096-states-l {
+ type int32;
+ units "s";
+ default -1;
+ config false;
+ description "none";
+ }
+ leaf time8192-states {
+ type int32;
+ units "s";
+ default -1;
+ config false;
+ description "none";
+ }
+ leaf time8192-states-l {
+ type int32;
+ units "s";
+ default -1;
+ config false;
+ description "none";
+ }
+ leaf snir-min {
+ type int8;
+ units "dB";
+ default -99;
+ config false;
+ description "Minimum signal to (noise+interference) ratio.";
+ }
+ leaf snir-max {
+ type int8;
+ units "dB";
+ default -99;
+ config false;
+ description "Maximum signal to (noise+interference) ratio.";
+ }
+ leaf snir-avg {
+ type int8;
+ units "dB";
+ default -99;
+ config false;
+ description "Averaged signal to (noise+interference) ratio.";
+ }
+ leaf xpd-min {
+ type int8;
+ units "dB";
+ default -99;
+ config false;
+ description "Minimum cross polarization discrimination.";
+ }
+ leaf xpd-max {
+ type int8;
+ units "dB";
+ default -99;
+ config false;
+ description "Maximum cross polarization discrimination.";
+ }
+ leaf xpd-avg {
+ type int8;
+ units "dB";
+ default -99;
+ config false;
+ description "Averaged cross polarization discrimination.";
+ }
+ leaf rf-temp-min {
+ type int8;
+ units "C";
+ default -99;
+ config false;
+ description "Lowest temperature (in degree Celsius) of the radio module inside the outdoor unit.";
+ }
+ leaf rf-temp-max {
+ type int8;
+ units "C";
+ default -99;
+ config false;
+ description "Highest temperature (in degree Celsius) of the radio module inside the outdoor unit.";
+ }
+ leaf rf-temp-avg {
+ type int8;
+ units "C";
+ default -99;
+ config false;
+ description "Averaged temperature (in degree Celsius) of the radio module inside the outdoor unit.";
+ }
+ leaf defect-blocks-sum {
+ type int16;
+ units "blocks";
+ default -1;
+ config false;
+ description "Total number of blocks that were defect after receiving and could not be corrected by the FEC.";
+ }
+ leaf time-period {
+ type int32;
+ units "s";
+ default -1;
+ config false;
+ description "Total length of the measurement period.";
+ }
+ }
+ grouping pmdata-ethernet {
+ description "Consolidated performance information for ethernet.";
+ leaf tx-ethernet-bytes-max-s {
+ type int32;
+ units "Bytes/s";
+ default -1;
+ config false;
+ description "Counts the number of Bytes of Ethernet traffic (before header compression) transmitted within a second and keeps the highest value within the measurement period. Field to be left blank for all types of TDM containers.";
+ }
+ leaf tx-ethernet-bytes-max-m {
+ type int64;
+ units "Bytes/min";
+ default -1;
+ config false;
+ description "Counts the number of Bytes of Ethernet traffic (before header compression) transmitted within a minute and keeps the highest value with in the measurement period. Field to be left blank for all types of TDM containers.";
+ }
+ leaf tx-ethernet-bytes-sum {
+ type int64;
+ units "Bytes";
+ default -1;
+ config false;
+ description "Total number of Bytes of Ethernet traffic (before header compression) transmitted (in direction out of the device) during the measurement period. Field to be left blank for all types of TDM containers.";
+ }
+ }
+ container pmdata-entity {
+ description "builder";
+ uses pmdata-base;
+ container performance-data {
+ uses pmdata-microwave;
+ uses pmdata-ethernet;
+ }
+ }
+ grouping pmdata15m-entity {
+ uses pmdata-base;
+ container performance-data {
+ uses pmdata-microwave;
+ uses pmdata-ethernet;
+ }
+ }
+ grouping pmdata24h-entity {
+ uses pmdata-base;
+ container performance-data {
+ uses pmdata-microwave;
+ uses pmdata-ethernet;
+ }
+ }
+ grouping inventory-entity {
+ description "One equipment entity in a list of a network element that could be rack, card, backplane, module";
+
+ leaf id {
+ description "Unique database id, node-id/uuid";
+ mandatory true;
+ type string;
+ }
+ leaf tree-level {
+ description "Containment level, starting with 0..";
+ type uint32;
+ }
+ leaf parent-uuid {
+ description "Unique inventory id of holder";
+ type string;
+ }
+ leaf node-id {
+ description "Unique node id of network element";
+ type string;
+ }
+ leaf uuid {
+ description "Unique inventory id of this node for this equipement, provided by network element";
+ type string;
+ }
+ leaf-list contained-holder {
+ description "List of uuid of contained equipment";
+ type string;
+ }
+ leaf manufacturer-name {
+ description "manufactured-thing/manufacturer-properties/manufacturer-name";
+ type string;
+ }
+ leaf manufacturer-identifier {
+ description "manufactured-thing/manufacturer-properties/manufacturer-identifier";
+ type string;
+ }
+ leaf serial {
+ description "manufactured-thing/equipment-instance/serial";
+ type string;
+ }
+ leaf date {
+ description "manufactured-thing/equipment-instance/manufacture-date: Date information provided by manufacturer. No specific format. ()";
+ type string;
+ }
+ leaf version {
+ description "manufactured-thing/equipment-type/version";
+ type string;
+ }
+ leaf description {
+ description "manufactured-thing/equipment-type/description";
+ type string;
+ }
+ leaf part-type-id {
+ description "manufactured-thing/equipment-type/part-type-identifier";
+ type string;
+ }
+ leaf model-identifier {
+ description "manufactured-thing/equipment-type/model-identifier";
+ type string;
+ }
+ leaf type-name {
+ description "manufactured-thing/equipment-type/type-name";
+ type string;
+ }
+ }
+ container inventory {
+ description "builder";
+ uses inventory-entity;
+ }
+ grouping node-details-g {
+ leaf-list available-capabilities {
+ type string;
+ }
+ leaf-list unavailable-capabilities {
+ type string;
+ }
+ }
+ grouping network-element-connection-entity {
+
+ leaf id {
+ type string;
+ description "database id/key. here is equal to node-id";
+ }
+ leaf node-id {
+ type string;
+ description "mountpoint name of device in controller";
+ }
+ leaf host {
+ type string;
+ description "netconf hostname or ip address of device";
+ }
+ leaf port {
+ type uint32;
+ description "netconf port of device";
+ }
+ leaf username {
+ type string;
+ description "netconf username";
+ }
+ leaf password {
+ type string;
+ description "netconf password. should be removed asap";
+ }
+ leaf core-model-capability {
+ type string;
+ description "revision of core-model capability";
+ }
+ leaf device-type {
+ type NetworkElementDeviceType;
+ description "categoried type of ne based on implemented yang specs";
+ }
+ leaf is-required {
+ type boolean;
+ description "entry exists in db index required-networkelement";
+ }
+ container node-details {
+ uses node-details-g;
+ description "holder of available and unavailable capabilities";
+ }
+ leaf status {
+ type ConnectionLogStatus;
+ description "current connection status. default Disconnected";
+ }
+ }
+ container network-element-connection {
+ description "builder";
+ uses network-element-connection-entity;
+ }
+ grouping status-entity {
+ container faults {
+ leaf criticals {
+ type uint32;
+ }
+ leaf majors {
+ type uint32;
+ }
+ leaf minors {
+ type uint32;
+ }
+ leaf warnings {
+ type uint32;
+ }
+ }
+ }
+ container status {
+ description "builder";
+ uses status-entity;
+ }
+ grouping entity-input {
+ list filter {
+ key property;
+ leaf property {
+ type string;
+ }
+ leaf filtervalue {
+ type string;
+ }
+ description "List with filter criteria. Not listed means all.";
+ }
+ list sortorder {
+ key property;
+ leaf property {
+ type string;
+ }
+ leaf sortorder {
+ type SortOrder;
+ }
+ description "List with sort order. Not listed means default";
+ }
+ container pagination {
+ leaf size {
+ type uint32 {
+ range "1..max";
+ }
+ default 20;
+ description "Number of entries to be delivered";
+ }
+ leaf page {
+ type uint64 {
+ range "1..max";
+ }
+ default 1;
+ description "Number to be used to calculate starting entry to deliver";
+ }
+ }
+ }
+ grouping pagination-output-g {
+ leaf size {
+ type uint32 {
+ range "1..max";
+ }
+ default 20;
+ description "Number of entries to be delivered";
+ }
+ leaf page {
+ type uint64 {
+ range "1..max";
+ }
+ default 1;
+ description "Number to be used to calculate starting entry to deliver";
+ }
+ leaf total {
+ type uint64 {
+ range "0..max";
+ }
+ default 0;
+ description "Number to be used to calculate starting entry to deliver";
+ }
+ }
+ container pagination-output {
+ description "builder";
+ uses pagination-output-g;
+ }
+ // --- rpc
+ rpc read-faultcurrent-list {
+ description
+ "Get list of faultcurrent entries according to filter";
+ input {
+ uses entity-input;
+ }
+ output {
+ container pagination {
+ uses pagination-output-g;
+ }
+ list data {
+ uses faultcurrent-entity;
+ }
+ }
+ }
+ rpc read-faultlog-list {
+ description
+ "Get list of faultlog entries according to filter";
+ input {
+ uses entity-input;
+ }
+ output {
+ container pagination {
+ uses pagination-output-g;
+ }
+ list data {
+ uses faultlog-entity;
+ }
+ }
+ }
+
+ rpc read-eventlog-list {
+ description
+ "Get list of eventlog entities according to filter";
+ input {
+ uses entity-input;
+ }
+ output {
+ container pagination {
+ uses pagination-output-g;
+ }
+ list data {
+ uses eventlog-entity;
+ }
+ }
+ }
+ rpc read-connectionlog-list {
+ description
+ "Get list of eventlog entities according to filter";
+ input {
+ uses entity-input;
+ }
+ output {
+ container pagination {
+ uses pagination-output-g;
+ }
+ list data {
+ uses connectionlog-entity;
+ }
+ }
+ }
+ rpc read-maintenance-list {
+ description
+ "Get list of maintenance entries according to filter";
+ input {
+ uses entity-input;
+ }
+ output {
+ container pagination {
+ uses pagination-output-g;
+ }
+ list data {
+ uses maintenance-entity;
+ }
+ }
+ }
+ rpc create-maintenance {
+ description
+ "insert new entry of maintenance";
+ input {
+ uses maintenance-entity;
+ }
+ output {
+ uses maintenance-entity;
+ }
+ }
+ rpc update-maintenance {
+ description
+ "update existing entity of maintenance";
+ input {
+ uses maintenance-entity;
+ }
+ output {
+ uses maintenance-entity;
+ }
+ }
+ rpc delete-maintenance {
+ description
+ "delete entity of maintenance";
+ input {
+ uses maintenance-entity;
+ }
+ output {
+ }
+ }
+
+ rpc read-mediator-server-list {
+ description
+ "Get list of mediator-servers according to filter";
+ input {
+ uses entity-input;
+ }
+ output {
+ container pagination {
+ uses pagination-output-g;
+ }
+ list data {
+ uses mediator-server-entity;
+ }
+ }
+ }
+ rpc create-mediator-server {
+ description
+ "create new entry of entity mediator-server";
+ input {
+ uses mediator-server-entity;
+ }
+ output {
+ uses mediator-server-entity;
+ }
+ }
+ rpc update-mediator-server {
+ description
+ "update entry of entity mediator-server";
+ input {
+ uses mediator-server-entity;
+ }
+ output {
+ uses mediator-server-entity;
+ }
+ }
+ rpc delete-mediator-server {
+ description
+ "delete entry of entity mediator-server";
+ input {
+ uses mediator-server-entity;
+ }
+ output {
+ }
+ }
+ rpc read-network-element-connection-list {
+ description
+ "Get list of networkelement-connections according to filter";
+ input {
+ uses entity-input;
+ }
+ output {
+ container pagination {
+ uses pagination-output-g;
+ }
+ list data {
+ uses network-element-connection-entity;
+ }
+ }
+ }
+ rpc create-network-element-connection {
+ description "create entry in networkelement-connection";
+ input {
+ uses network-element-connection-entity;
+ }
+ output {
+ uses network-element-connection-entity;
+ }
+ }
+ rpc update-network-element-connection {
+ description "Put an element to ne-entity";
+ input {
+ uses network-element-connection-entity;
+ }
+ output {
+ uses network-element-connection-entity;
+ }
+ }
+ rpc delete-network-element-connection {
+ description "!ONLY FOR TESTING! Put an element to ne-entity";
+ input {
+ uses network-element-connection-entity;
+ }
+ output {
+ }
+ }
+
+ rpc read-pmdata-15m-ltp-list {
+ description
+ "Get list of ltps for one mountpoint with historical pmdata";
+ input {
+ uses entity-input;
+ }
+ output {
+ container pagination {
+ uses pagination-output-g;
+ }
+ leaf-list data {
+ type string;
+ }
+ }
+ }
+ rpc read-pmdata-24h-ltp-list {
+ description
+ "Get list of ltps for one mountpoint with historical pmdata";
+ input {
+ uses entity-input;
+ }
+
+ output {
+ container pagination {
+ uses pagination-output-g;
+ }
+ leaf-list data {
+ type string;
+ }
+ }
+ }
+ rpc read-pmdata-15m-device-list {
+ description
+ "Get list of mountpoints with historical pmdata";
+ input {
+ uses entity-input;
+ }
+ output {
+ container pagination {
+ uses pagination-output-g;
+ }
+ leaf-list data {
+ type string;
+ }
+ }
+ }
+ rpc read-pmdata-24h-device-list {
+ description
+ "Get list of mountpoints with historical pmdata";
+ input {
+ uses entity-input;
+ }
+ output {
+ container pagination {
+ uses pagination-output-g;
+ }
+ leaf-list data {
+ type string;
+ }
+ }
+ }
+
+ rpc read-pmdata-15m-list {
+ description
+ "Get list of entities according to filter";
+ input {
+ uses entity-input;
+ }
+ output {
+ container pagination {
+ uses pagination-output-g;
+ }
+ list data {
+ uses pmdata15m-entity;
+ }
+ }
+ }
+ rpc read-pmdata-24h-list {
+ description
+ "Get list of historical pmdata according to filter";
+ input {
+ uses entity-input;
+ }
+ output {
+ container pagination {
+ uses pagination-output-g;
+ }
+ list data {
+ uses pmdata24h-entity;
+ }
+ }
+ }
+ rpc read-inventory-list {
+ description
+ "Get list of inventory according to filter";
+ input {
+ uses entity-input;
+ }
+ output {
+ container pagination {
+ uses pagination-output-g;
+ }
+ list data {
+ uses inventory-entity;
+ }
+ }
+ }
+ rpc read-status {
+ description
+ "Read status information of controller";
+ output {
+ list data {
+ uses status-entity;
+ }
+ }
+ }
+}
+
diff --git a/sdnr/wt/data-provider/pom.xml b/sdnr/wt/data-provider/pom.xml
new file mode 100755
index 0000000..1d2a255
--- /dev/null
+++ b/sdnr/wt/data-provider/pom.xml
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ * ============LICENSE_START=======================================================
+ * ONAP : CCSDK.sdnr.wt.data-provider
+ * ================================================================================
+ * Copyright (C) 2018 highstreet technologies GmbH Intellectual Property.
+ * All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.onap.ccsdk.parent</groupId>
+ <artifactId>odlparent-lite</artifactId>
+ <version>1.5.2-SNAPSHOT</version>
+ <relativePath/>
+ </parent>
+
+ <groupId>org.onap.ccsdk.features.sdnr.wt</groupId>
+ <artifactId>sdnr-wt-data-provider-top</artifactId>
+ <version>0.7.1-SNAPSHOT</version>
+ <packaging>pom</packaging>
+
+ <name>ccsdk-features :: ${project.artifactId}</name>
+
+ <modules>
+ <module>model</module>
+ <module>provider</module>
+ <module>feature</module>
+ <module>installer</module>
+ </modules>
+
+ <properties>
+ <feature-name>sdnr-wt-data-provider</feature-name>
+ </properties>
+</project>
diff --git a/sdnr/wt/data-provider/provider/copyright b/sdnr/wt/data-provider/provider/copyright
new file mode 100644
index 0000000..754b621
--- /dev/null
+++ b/sdnr/wt/data-provider/provider/copyright
@@ -0,0 +1,17 @@
+/**
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
+ * =================================================================================================
+ * 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.
+ * ============LICENSE_END==========================================================================
+ */
diff --git a/sdnr/wt/data-provider/provider/pom.xml b/sdnr/wt/data-provider/provider/pom.xml
new file mode 100644
index 0000000..e862b2e
--- /dev/null
+++ b/sdnr/wt/data-provider/provider/pom.xml
@@ -0,0 +1,187 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ============LICENSE_START=======================================================
+ ONAP : CCSDK / SDNR / WT / data-provider
+ ================================================================================
+ Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All
+ rights reserved.
+ ================================================================================
+ 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.
+ ============LICENSE_END=========================================================
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.onap.ccsdk.parent</groupId>
+ <artifactId>binding-parent</artifactId>
+ <version>1.5.2-SNAPSHOT</version>
+ <relativePath />
+ </parent>
+
+ <groupId>org.onap.ccsdk.features.sdnr.wt</groupId>
+ <artifactId>sdnr-wt-data-provider-provider</artifactId>
+ <version>0.7.1-SNAPSHOT</version>
+ <packaging>bundle</packaging>
+
+ <name>ccsdk-features :: ${project.artifactId}</name>
+ <licenses>
+ <license>
+ <name>Apache License, Version 2.0</name>
+ <url>http://www.apache.org/licenses/LICENSE-2.0</url>
+ </license>
+ </licenses>
+
+ <properties>
+ <checkstyle.skip>true</checkstyle.skip> <!-- POM configuration -->
+ <maven.javadoc.skip>true</maven.javadoc.skip>
+ <maven.build.timestamp.format>yyyy-MM-dd HH:mm</maven.build.timestamp.format>
+ <buildtime>${maven.build.timestamp}</buildtime>
+ <databaseport>49402</databaseport>
+ <odlux.buildno>39.0e1988b(20/01/12)</odlux.buildno>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>sdnr-wt-common</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>sdnr-wt-data-provider-model</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.karaf.shell</groupId>
+ <artifactId>org.apache.karaf.shell.core</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.netconf</groupId>
+ <artifactId>sal-netconf-connector</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.mdsal.binding.model.ietf</groupId>
+ <artifactId>rfc6991-ietf-yang-types</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.mdsal</groupId>
+ <artifactId>yang-binding</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.mdsal</groupId>
+ <artifactId>mdsal-singleton-common-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.json</groupId>
+ <artifactId>json</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.jacoco</groupId>
+ <artifactId>jacoco-maven-plugin</artifactId>
+ <configuration>
+ <excludes>
+ <exclude>**/gen/**</exclude>
+ <exclude>**/generated-sources/**</exclude>
+ <exclude>**/yang-gen-sal/**</exclude>
+ <exclude>**/pax/**</exclude>
+ </excludes>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>exec-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>generateDTOs</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>exec</goal>
+ </goals>
+ <configuration>
+ <executable>bash</executable>
+ <arguments>
+ <argument>${basedir}/../../data-provider/provider/src/main/resources/es-init.sh</argument>
+ <argument>initfile</argument>
+ <argument>-f</argument>
+ <argument>${project.build.directory}/EsInit.script</argument>
+ </arguments>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>com.github.alexcojocaru</groupId>
+ <artifactId>elasticsearch-maven-plugin</artifactId>
+ <version>6.16</version>
+ <configuration>
+ <skip>${skipTests}</skip>
+ <clusterName>testCluster</clusterName>
+ <transportPort>9500</transportPort>
+ <httpPort>${databaseport}</httpPort>
+ <version>6.5.0</version>
+ <timeout>120</timeout>
+ <pathInitScript>${project.build.directory}/EsInit.script</pathInitScript>
+ </configuration>
+ <executions>
+ <execution>
+ <id>start-elasticsearch</id>
+ <phase>process-test-classes</phase>
+ <goals>
+ <goal>runforked</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>stop-elasticsearch</id>
+ <phase>prepare-package</phase>
+ <goals>
+ <goal>stop</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <systemProperties>
+ <property>
+ <name>databaseport</name>
+ <value>${databaseport}</value>
+ </property>
+ </systemProperties>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/DataObjectAcessor.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/DataObjectAcessor.java
new file mode 100644
index 0000000..aef6356
--- /dev/null
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/DataObjectAcessor.java
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
+ * =================================================================================================
+ * 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.
+ * ============LICENSE_END==========================================================================
+ ******************************************************************************/
+package org.onap.ccsdk.features.sdnr.wt.dataprovider.data;
+
+import org.onap.ccsdk.features.sdnr.wt.common.database.HtDatabaseClient;
+import org.onap.ccsdk.features.sdnr.wt.common.database.SearchResult;
+import org.onap.ccsdk.features.sdnr.wt.common.database.queries.QueryBuilder;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.EsDataObjectReaderWriter;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.Entity;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.EntityInput;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class DataObjectAcessor<T extends DataObject> extends EsDataObjectReaderWriter<T> {
+
+ private static final Logger LOG = LoggerFactory.getLogger(DataObjectAcessor.class);
+
+ public DataObjectAcessor(HtDatabaseClient dbClient, Entity entity, Class<T> clazz) throws ClassNotFoundException {
+ this(dbClient, entity, clazz, true);
+ LOG.info("Create {}", this.getClass().getName());
+ }
+
+ public DataObjectAcessor(HtDatabaseClient dbClient, Entity entity, Class<T> clazz, boolean idSupported) throws ClassNotFoundException {
+ super(dbClient, entity, clazz);
+ if (idSupported) {
+ setEsIdAttributeName("_id");
+ }
+ }
+
+ QueryResult<T> getData(EntityInput input) {
+ long page = QueryByFilter.getPage(input);
+ long pageSize = QueryByFilter.getPageSize(input);
+ LOG.info("Request: {}", this.getDataTypeName());
+ QueryBuilder query = QueryByFilter.fromFilter(input.getFilter()).from((page - 1) * pageSize).size(pageSize);
+ QueryByFilter.setSortOrder(query, input.getSortorder());
+ SearchResult<T> result = doReadAll(query,query.contains("range"));
+ return new QueryResult<>(page, pageSize, result);
+ }
+
+}
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/DataObjectAcessorPm.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/DataObjectAcessorPm.java
new file mode 100644
index 0000000..a145a9f
--- /dev/null
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/DataObjectAcessorPm.java
@@ -0,0 +1,161 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
+ * =================================================================================================
+ * 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.
+ * ============LICENSE_END==========================================================================
+ ******************************************************************************/
+package org.onap.ccsdk.features.sdnr.wt.dataprovider.data;
+
+import java.io.IOException;
+
+import org.onap.ccsdk.features.sdnr.wt.common.database.ExtRestClient;
+import org.onap.ccsdk.features.sdnr.wt.common.database.HtDatabaseClient;
+import org.onap.ccsdk.features.sdnr.wt.common.database.SearchResult;
+import org.onap.ccsdk.features.sdnr.wt.common.database.queries.QueryBuilder;
+import org.onap.ccsdk.features.sdnr.wt.common.database.queries.QueryBuilders;
+import org.onap.ccsdk.features.sdnr.wt.common.database.requests.SearchRequest;
+import org.onap.ccsdk.features.sdnr.wt.common.database.responses.AggregationEntries;
+import org.onap.ccsdk.features.sdnr.wt.common.database.responses.SearchResponse;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.Entity;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.EntityInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.SortOrder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.entity.input.Filter;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.entity.input.Sortorder;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class DataObjectAcessorPm<T extends DataObject> extends DataObjectAcessor<T> {
+
+ private final Logger LOG = LoggerFactory.getLogger(DataObjectAcessorPm.class);
+
+ private static final String UUID_KEY = "uuid-interface";
+ private static final String NODE_KEY = "node-name";
+ private static final String KEY = "node-name";
+
+
+ enum Intervall {
+ PMDATA15M("historicalperformance15min", "historicalperformance15min"),
+ PMDATA24H("historicalperformance24h", "historicalperformance24h");
+
+ String index;
+ String type;
+
+ Intervall(String index, String type) {
+ this.index = index;
+ this.type = type;
+ }
+
+ public String getIndex() {
+ return index;
+ }
+
+ public String getType() {
+ return type;
+ }
+ }
+
+ private ExtRestClient dbClient;
+ private Intervall mode;
+
+ public DataObjectAcessorPm(HtDatabaseClient dbClient, Intervall mode, Entity entity, Class<T> clazz) throws ClassNotFoundException {
+ super(dbClient, entity, clazz, false);
+ this.dbClient = dbClient;
+ this.mode = mode;
+ }
+
+ /**
+ * get aggregated list of ltps for filter NODE_KEY
+ * @param input
+ * @return
+ * @throws IOException
+ */
+ QueryResult<String> getDataLtpList(EntityInput input) throws IOException {
+ long page = QueryByFilter.getPage(input);
+ long pageSize = QueryByFilter.getPageSize(input);
+ Filter nodeFilter = QueryByFilter.getFilter(input.getFilter(), NODE_KEY);
+ if (nodeFilter != null) {
+ SearchRequest request = new SearchRequest(mode.getIndex(), mode.getType());
+ request.setQuery(QueryBuilders.matchQuery(NODE_KEY, nodeFilter.getFiltervalue()).aggregations(UUID_KEY).size(0));
+ try {
+ SearchResponse response = this.dbClient.search(request);
+ AggregationEntries aggs = response.getAggregations(UUID_KEY);
+ String[] uuids = aggs.getKeysAsPagedStringList(pageSize, pageSize * (page - 1));
+ long totalSize = aggs.size();
+ return new QueryResult<String>(page, pageSize, new SearchResult<String>(uuids, totalSize));
+ } catch (IOException e) {
+ throw new IOException("problem reading ltps for req="+request, e);
+ }
+ } else {
+ String msg = "no nodename in filter found ";
+ LOG.debug(msg);
+ throw new IllegalArgumentException(msg);
+ }
+ }
+
+// QueryResult<String> getDataDeviceList(EntityInput input) throws IOException {
+//
+// long page = QueryByFilter.getPage(input);
+// long pageSize = QueryByFilter.getPageSize(input);
+//
+// SearchRequest request = new SearchRequest(mode.getIndex(), mode.getType());
+// request.setQuery(QueryBuilders.matchAllQuery().aggregations(KEY).size(0));
+//// try {
+// SearchResponse response = this.dbClient.search(request);
+// AggregationEntries aggs = response.getAggregations(KEY);
+// String[] uuids = aggs.getKeysAsPagedStringList(pageSize, pageSize * (page - 1));
+// long totalSize = aggs.size();
+// return new QueryResult<String>(page, pageSize, new SearchResult<String>(uuids, totalSize));
+//// } catch (IOException e) {
+//// throw new IOException("problem reading nodes for req="+request, e);
+//// }
+// }
+ /**
+ * get aggregated devices list
+ * @param input filter should be empty/no filter handled, only sortorder for KEY ('node-name')
+ * @return
+ * @throws IOException
+ */
+ QueryResult<String> getDataDeviceList(EntityInput input) throws IOException {
+
+ long page = QueryByFilter.getPage(input);
+ long pageSize = QueryByFilter.getPageSize(input);
+
+ Sortorder soNode = QueryByFilter.getSortOrder(input.getSortorder(), KEY);
+ SearchRequest request = new SearchRequest(mode.getIndex(), mode.getType());
+ QueryBuilder query = null;
+ if (soNode != null) {
+ query = QueryBuilders.matchAllQuery()
+ .aggregations(KEY,
+ soNode.getSortorder() == SortOrder.Ascending
+ ? org.onap.ccsdk.features.sdnr.wt.common.database.queries.SortOrder.ASCENDING
+ : org.onap.ccsdk.features.sdnr.wt.common.database.queries.SortOrder.DESCENDING)
+ .size(0);
+ } else {
+ query = QueryBuilders.matchAllQuery().aggregations(KEY).size(0);
+ }
+ request.setQuery(query);
+ try {
+ SearchResponse response = this.dbClient.search(request);
+ AggregationEntries aggs = response.getAggregations(KEY);
+ String[] uuids = aggs.getKeysAsPagedStringList(pageSize, pageSize * (page - 1));
+ long totalSize = aggs.size();
+ return new QueryResult<String>(page, pageSize, new SearchResult<String>(uuids, totalSize));
+ } catch (IOException e) {
+ throw new IOException("problem reading nodes for req=" + request, e);
+ }
+
+ }
+
+}
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/DataObjectAcessorStatus.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/DataObjectAcessorStatus.java
new file mode 100644
index 0000000..5970d54
--- /dev/null
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/DataObjectAcessorStatus.java
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
+ * =================================================================================================
+ * 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.
+ * ============LICENSE_END==========================================================================
+ ******************************************************************************/
+package org.onap.ccsdk.features.sdnr.wt.dataprovider.data;
+
+import java.io.IOException;
+
+import org.onap.ccsdk.features.sdnr.wt.common.database.ExtRestClient;
+import org.onap.ccsdk.features.sdnr.wt.common.database.HtDatabaseClient;
+import org.onap.ccsdk.features.sdnr.wt.common.database.SearchResult;
+import org.onap.ccsdk.features.sdnr.wt.common.database.queries.QueryBuilders;
+import org.onap.ccsdk.features.sdnr.wt.common.database.requests.SearchRequest;
+import org.onap.ccsdk.features.sdnr.wt.common.database.responses.AggregationEntries;
+import org.onap.ccsdk.features.sdnr.wt.common.database.responses.SearchResponse;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.Entity;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.status.output.Data;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.status.output.DataBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.status.entity.FaultsBuilder;
+
+public class DataObjectAcessorStatus extends DataObjectAcessor<Data> {
+
+ final String ESDATATYPE_FAULTCURRENT_SEVERITY_KEY = "severity";
+
+ private final ExtRestClient dbClient;
+ private final Entity entity;
+
+ public DataObjectAcessorStatus(HtDatabaseClient dbClient, Entity entity)
+ throws ClassNotFoundException {
+ super(dbClient, entity, Data.class, false);
+ this.dbClient = dbClient;
+ this.entity = entity;
+ }
+
+ QueryResult<Data> getDataStatus() throws IOException {
+ SearchRequest request = getNewInstanceOfSearchRequest(entity);
+ request.setQuery(
+ QueryBuilders.matchAllQuery().aggregations(ESDATATYPE_FAULTCURRENT_SEVERITY_KEY).size(0));
+ SearchResponse response = this.dbClient.search(request);
+ AggregationEntries aggs = response.getAggregations(ESDATATYPE_FAULTCURRENT_SEVERITY_KEY);
+
+ Data[] data = { new DataBuilder().setFaults(new FaultsBuilder().
+ setCriticals(aggs.getOrDefault("Critical",0L)).
+ setMajors(aggs.getOrDefault("Major", 0L)).
+ setMinors(aggs.getOrDefault("Minor", 0L)).
+ setWarnings(aggs.getOrDefault("Warning", 0L)).
+ build()).build() };
+ long toalsize = data.length;
+ return new QueryResult<Data>(1L, 1L, new SearchResult<Data>(data, toalsize));
+
+ }
+
+
+ private static SearchRequest getNewInstanceOfSearchRequest(Entity entity) {
+ return new SearchRequest(entity.getName(), entity.getName());
+ }
+
+
+}
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/ElasticSearchDataProvider.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/ElasticSearchDataProvider.java
new file mode 100644
index 0000000..4878d89
--- /dev/null
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/ElasticSearchDataProvider.java
@@ -0,0 +1,445 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
+ * =================================================================================================
+ * 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.
+ * ============LICENSE_END==========================================================================
+ ******************************************************************************/
+package org.onap.ccsdk.features.sdnr.wt.dataprovider.data;
+
+import java.io.IOException;
+import java.util.concurrent.TimeUnit;
+
+import org.onap.ccsdk.features.sdnr.wt.common.database.HtDatabaseClient;
+import org.onap.ccsdk.features.sdnr.wt.common.database.config.HostInfo;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.data.DataObjectAcessorPm.Intervall;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.HtDatabaseMaintenance;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.CreateMaintenanceInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.CreateMaintenanceOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.CreateMediatorServerInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.CreateMediatorServerOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.CreateNetworkElementConnectionOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.DeleteMaintenanceInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.DeleteMaintenanceOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.DeleteMediatorServerInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.DeleteMediatorServerOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.DeleteNetworkElementConnectionInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.DeleteNetworkElementConnectionOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.Entity;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.EntityInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.MaintenanceEntity;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.MediatorServerEntity;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.NetworkElementConnectionEntity;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ReadConnectionlogListOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ReadEventlogListInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ReadEventlogListOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ReadFaultcurrentListOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ReadFaultlogListOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ReadInventoryListOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ReadMaintenanceListOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ReadMediatorServerListOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ReadNetworkElementConnectionListOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ReadPmdata15mDeviceListOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ReadPmdata15mListOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ReadPmdata15mLtpListOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ReadPmdata24hDeviceListOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ReadPmdata24hListOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ReadPmdata24hLtpListOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ReadStatusOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.UpdateMaintenanceInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.UpdateMaintenanceOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.UpdateMediatorServerInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.UpdateMediatorServerOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.UpdateNetworkElementConnectionInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.UpdateNetworkElementConnectionOutputBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class ElasticSearchDataProvider /*extends BaseStatusProvider /* implements IEntityDataProvider*/ {
+
+ private static final Logger LOG = LoggerFactory.getLogger(ElasticSearchDataProvider.class);
+
+ private static final String EXCEPTION_UNABLE_TO_WRITE_IN_DATABASE = "unable to write data to database";
+ private static final String EXCEPTION_UNABLE_TO_UPDATE_IN_DATABASE = "unable to update data in database";
+ private static final String EXCEPTION_UNABLE_TO_REMOVE_FROM_DATABASE = "unable to remove data from database";
+
+ private final HtDatabaseClient dbClient;
+ private final DataObjectAcessor<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.faultcurrent.list.output.Data> eventRWFaultCurrent;
+ private final DataObjectAcessor<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.faultlog.list.output.Data> eventRWFaultLog;
+ private final DataObjectAcessor<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.mediator.server.list.output.Data> mediatorserverRW;
+ private final DataObjectAcessor<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.maintenance.list.output.Data> maintenanceRW;
+ private final DataObjectAcessor<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.inventory.list.output.Data> equipmentRW;
+ private final DataObjectAcessor<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.connectionlog.list.output.Data> connnectionlogRW;
+ private final DataObjectAcessor<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.eventlog.list.output.Data> eventlogRW;
+ private final DataObjectAcessor<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.network.element.connection.list.output.Data> networkelementConnectionRW;
+ private final DataObjectAcessorPm<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.pmdata._15m.list.output.Data> pm15mRW;
+ private final DataObjectAcessorPm<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.pmdata._24h.list.output.Data> pm24hRW;
+
+ private final DataObjectAcessorStatus readStatus;
+ private final HtDatabaseEventsService databaseService;
+ private final HtDatabaseMaintenanceService databaseMaintenanceService;
+ public ElasticSearchDataProvider(HostInfo[] hosts) throws Exception {
+ this(hosts,null,null);
+ }
+ public ElasticSearchDataProvider(HostInfo[] hosts,String authUsername,String authPassword) throws Exception {
+ super();
+ LOG.info("Start {}", this.getClass().getName());
+
+ this.dbClient = new HtDatabaseClient(hosts,authUsername,authPassword);
+ this.mediatorserverRW = new DataObjectAcessor<>(dbClient, Entity.MediatorServer,
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.mediator.server.list.output.Data.class);
+ this.mediatorserverRW.setWriteInterface(MediatorServerEntity.class);
+
+ this.maintenanceRW = new DataObjectAcessor<>(dbClient, Entity.Maintenancemode,
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.maintenance.list.output.Data.class);
+ this.maintenanceRW.setWriteInterface(MaintenanceEntity.class);
+
+ this.equipmentRW = new DataObjectAcessor<>(dbClient, Entity.Inventoryequipment,
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.inventory.list.output.Data.class);
+
+ this.eventRWFaultCurrent = new DataObjectAcessor<>(dbClient, Entity.Faultcurrent,
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.faultcurrent.list.output.Data.class);
+
+ this.eventRWFaultLog = new DataObjectAcessor<>(dbClient, Entity.Faultlog,
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.faultlog.list.output.Data.class);
+
+ this.connnectionlogRW = new DataObjectAcessor<>(dbClient, Entity.Connectionlog,
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.connectionlog.list.output.Data.class);
+
+ this.eventlogRW = new DataObjectAcessor<>(dbClient, Entity.Eventlog,
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.eventlog.list.output.Data.class);
+
+ this.networkelementConnectionRW = new DataObjectAcessor<>(dbClient, Entity.NetworkelementConnection,
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.network.element.connection.list.output.Data.class);
+ this.networkelementConnectionRW.setWriteInterface(NetworkElementConnectionEntity.class);
+
+ this.pm15mRW = new DataObjectAcessorPm<>(dbClient, Intervall.PMDATA15M, Entity.Historicalperformance15min,
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.pmdata._15m.list.output.Data.class);
+
+ this.pm24hRW = new DataObjectAcessorPm<>(dbClient, Intervall.PMDATA24H, Entity.Historicalperformance24h,
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.pmdata._24h.list.output.Data.class);
+
+ this.readStatus = new DataObjectAcessorStatus(dbClient, Entity.Faultcurrent );
+
+ this.databaseService = new HtDatabaseEventsService(dbClient, this);
+ this.databaseMaintenanceService = new HtDatabaseMaintenanceService(dbClient);
+ }
+
+ /*-------------------------
+ * Provide access to model API
+ */
+
+ //org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.faultcurrent.list.output.Data
+ //org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.faultcurrent.list.output.PaginationBuilder
+ //eventRWFaultCurrent
+ public ReadFaultcurrentListOutputBuilder readFaultCurrentList(EntityInput input) {
+
+ ReadFaultcurrentListOutputBuilder outputBuilder = new ReadFaultcurrentListOutputBuilder();
+
+ QueryResult<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.faultcurrent.list.output.Data> result = this.eventRWFaultCurrent
+ .getData(input);
+ outputBuilder.setData(result.getResult().getHits());
+ outputBuilder.setPagination(
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.faultcurrent.list.output.PaginationBuilder(
+ result.getPagination()).build());
+ return outputBuilder;
+ }
+
+ //org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.faultlog.list.output.Data
+ //org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.faultlog.list.output.PaginationBuilder
+ //eventRWFaultLog
+ public ReadFaultlogListOutputBuilder readFaultLogList(EntityInput input) {
+ ReadFaultlogListOutputBuilder outputBuilder = new ReadFaultlogListOutputBuilder();
+ QueryResult<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.faultlog.list.output.Data> result = this.eventRWFaultLog
+ .getData(input);
+ outputBuilder.setData(result.getResult().getHits());
+ outputBuilder.setPagination(
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.faultlog.list.output.PaginationBuilder(
+ result.getPagination()).build());
+ return outputBuilder;
+ }
+
+ //org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.maintenance.list.output.Data
+ //org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.maintenance.list.output.PaginationBuilder
+ //maintenanceRW
+ public ReadMaintenanceListOutputBuilder readMaintenanceList(EntityInput input) {
+ ReadMaintenanceListOutputBuilder outputBuilder = new ReadMaintenanceListOutputBuilder();
+ QueryResult<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.maintenance.list.output.Data> result = this.maintenanceRW
+ .getData(input);
+ outputBuilder.setData(result.getResult().getHits());
+ outputBuilder.setPagination(
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.maintenance.list.output.PaginationBuilder(
+ result.getPagination()).build());
+ return outputBuilder;
+ }
+
+ //org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.mediator.server.list.output.Data
+ //org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.mediator.server.list.output.Pagination
+ //mediatorserverRW
+ public ReadMediatorServerListOutputBuilder readMediatorServerList(EntityInput input) {
+
+ ReadMediatorServerListOutputBuilder outputBuilder = new ReadMediatorServerListOutputBuilder();
+ QueryResult<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.mediator.server.list.output.Data> result = this.mediatorserverRW
+ .getData(input);
+ outputBuilder.setData(result.getResult().getHits());
+ outputBuilder.setPagination(
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.mediator.server.list.output.PaginationBuilder(
+ result.getPagination()).build());
+ return outputBuilder;
+ }
+
+ //org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.network.element.connection.list.output.Data
+ //org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.network.element.connection.list.output.PaginationBuilder
+ //networkelementConnectionRW
+ public ReadNetworkElementConnectionListOutputBuilder readNetworkElementConnectionList(
+ EntityInput input) {
+ ReadNetworkElementConnectionListOutputBuilder outputBuilder = new ReadNetworkElementConnectionListOutputBuilder();
+ QueryResult<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.network.element.connection.list.output.Data> result = this.networkelementConnectionRW
+ .getData(input);
+ outputBuilder.setData(result.getResult().getHits());
+ outputBuilder.setPagination(
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.network.element.connection.list.output.PaginationBuilder(
+ result.getPagination()).build());
+ return outputBuilder;
+ }
+
+ //org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.inventory.list.output.Data
+ //org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.inventory.list.output.PaginationBuilder
+ //equipmentRW
+ public ReadInventoryListOutputBuilder readInventoryList(EntityInput input) {
+ ReadInventoryListOutputBuilder outputBuilder = new ReadInventoryListOutputBuilder();
+ QueryResult<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.inventory.list.output.Data> result = this.equipmentRW
+ .getData(input);
+ outputBuilder.setData(result.getResult().getHits());
+ outputBuilder.setPagination(
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.inventory.list.output.PaginationBuilder(
+ result.getPagination()).build());
+ return outputBuilder;
+ }
+
+ //org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.inventory.list.output.Data
+ //org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.inventory.list.output.PaginationBuilder
+ //connnectionlogRW
+ public ReadConnectionlogListOutputBuilder readConnectionlogList(EntityInput input) {
+ ReadConnectionlogListOutputBuilder outputBuilder = new ReadConnectionlogListOutputBuilder();
+ QueryResult<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.connectionlog.list.output.Data> result = this.connnectionlogRW
+ .getData(input);
+ outputBuilder.setData(result.getResult().getHits());
+ outputBuilder.setPagination(
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.connectionlog.list.output.PaginationBuilder(
+ result.getPagination()).build());
+ return outputBuilder;
+ }
+
+ //org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.eventlog.list.output.Data
+ //org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.eventlog.list.output.PaginationBuilder
+ //eventlogRW
+ public ReadEventlogListOutputBuilder readEventlogList(ReadEventlogListInput input) throws IOException {
+ ReadEventlogListOutputBuilder outputBuilder = new ReadEventlogListOutputBuilder();
+ QueryResult<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.eventlog.list.output.Data> result = this.eventlogRW
+ .getData(input);
+ outputBuilder.setData(result.getResult().getHits());
+ outputBuilder.setPagination(
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.eventlog.list.output.PaginationBuilder(
+ result.getPagination()).build());
+ return outputBuilder;
+ }
+
+ //org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.pmdata._15m.list.output.Data
+ //org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.pmdata._15m.list.output.PaginationBuilder
+ public ReadPmdata15mListOutputBuilder readPmdata15mList(EntityInput input) {
+ ReadPmdata15mListOutputBuilder outputBuilder = new ReadPmdata15mListOutputBuilder();
+ QueryResult<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.pmdata._15m.list.output.Data> result = this.pm15mRW
+ .getData(input);
+ outputBuilder.setData(result.getResult().getHits());
+ outputBuilder.setPagination(
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.pmdata._15m.list.output.PaginationBuilder(
+ result.getPagination()).build());
+ return outputBuilder;
+ }
+
+ //org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.pmdata._24h.list.output.Data
+ //org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.pmdata._24h.list.output.Pagination
+ public ReadPmdata24hListOutputBuilder readPmdata24hList(EntityInput input) {
+ ReadPmdata24hListOutputBuilder outputBuilder = new ReadPmdata24hListOutputBuilder();
+ QueryResult<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.pmdata._24h.list.output.Data> result = this.pm24hRW
+ .getData(input);
+ outputBuilder.setData(result.getResult().getHits());
+ outputBuilder.setPagination(
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.pmdata._24h.list.output.PaginationBuilder(
+ result.getPagination()).build());
+ return outputBuilder;
+ }
+
+ public ReadPmdata15mLtpListOutputBuilder readPmdata15mLtpList(EntityInput input) throws IOException {
+ ReadPmdata15mLtpListOutputBuilder outputBuilder = new ReadPmdata15mLtpListOutputBuilder();
+ QueryResult<String> result = pm15mRW.getDataLtpList(input);
+ outputBuilder.setPagination(
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.pmdata._15m.ltp.list.output.PaginationBuilder(
+ result.getPagination()).build());
+ outputBuilder.setData(result.getResult().getHits());
+ return outputBuilder;
+ }
+
+ public ReadPmdata15mDeviceListOutputBuilder readPmdata15mDeviceList(EntityInput input) throws IOException {
+ ReadPmdata15mDeviceListOutputBuilder outputBuilder = new ReadPmdata15mDeviceListOutputBuilder();
+ QueryResult<String> result = pm15mRW.getDataDeviceList(input);
+ outputBuilder.setPagination(
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.pmdata._15m.device.list.output.PaginationBuilder(
+ result.getPagination()).build());
+ outputBuilder.setData(result.getResult().getHits());
+ return outputBuilder;
+ }
+
+ public ReadPmdata24hLtpListOutputBuilder readPmdata24hLtpList(EntityInput input) throws IOException {
+
+ QueryResult<String> result = pm24hRW.getDataLtpList(input);
+
+ ReadPmdata24hLtpListOutputBuilder outputBuilder = new ReadPmdata24hLtpListOutputBuilder();
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.pmdata._24h.ltp.list.output.PaginationBuilder();
+ outputBuilder.setPagination(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.pmdata._24h.ltp.list.output.PaginationBuilder(
+ result.getPagination()).build());
+ outputBuilder.setData(result.getResult().getHits());
+ return outputBuilder;
+ }
+
+ public ReadPmdata24hDeviceListOutputBuilder readPmdata24hDeviceList(EntityInput input)
+ throws IOException {
+
+ QueryResult<String> result = pm24hRW.getDataDeviceList(input);
+
+ ReadPmdata24hDeviceListOutputBuilder outputBuilder = new ReadPmdata24hDeviceListOutputBuilder();
+ outputBuilder.setPagination(
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.pmdata._24h.device.list.output.PaginationBuilder(
+ result.getPagination()).build());
+ outputBuilder.setData(result.getResult().getHits());
+ return outputBuilder;
+ }
+
+ public ReadStatusOutputBuilder readStatus() throws IOException {
+ QueryResult<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.status.output.Data> result = readStatus.getDataStatus();
+
+ ReadStatusOutputBuilder outputBuilder = new ReadStatusOutputBuilder();
+ outputBuilder.setData(result.getResult().getHits());
+ return outputBuilder;
+ }
+
+ public boolean waitForYellowDatabaseStatus(long timeout, TimeUnit unit) {
+ return this.dbClient.waitForYellowStatus(unit.toMillis(timeout));
+ }
+
+ public CreateNetworkElementConnectionOutputBuilder createNetworkElementConnection(
+ NetworkElementConnectionEntity input) throws IOException {
+ String id = this.networkelementConnectionRW.update(input, input.getNodeId());
+ if (id == null) {
+ throw new IOException(EXCEPTION_UNABLE_TO_WRITE_IN_DATABASE);
+ }
+ CreateNetworkElementConnectionOutputBuilder builder = new CreateNetworkElementConnectionOutputBuilder();
+ builder.setId(id).setNodeId(input.getNodeId()).setHost(input.getHost()).setPort(input.getPort())
+ .setUsername(input.getUsername()).setPassword(input.getPassword()).setIsRequired(input.isIsRequired())
+ .setCoreModelCapability(input.getCoreModelCapability()).setDeviceType(input.getDeviceType());
+ return builder;
+ }
+
+ public UpdateNetworkElementConnectionOutputBuilder updateNetworkElementConnection(
+ UpdateNetworkElementConnectionInput input) throws IOException {
+ String id = this.networkelementConnectionRW.update(input, input.getId());
+ if (id == null) {
+ throw new IOException(EXCEPTION_UNABLE_TO_UPDATE_IN_DATABASE);
+ }
+ UpdateNetworkElementConnectionOutputBuilder builder = new UpdateNetworkElementConnectionOutputBuilder();
+ builder.setId(id).setNodeId(input.getNodeId()).setHost(input.getHost()).setPort(input.getPort())
+ .setUsername(input.getUsername()).setPassword(input.getPassword())
+ .setCoreModelCapability(input.getCoreModelCapability()).setDeviceType(input.getDeviceType());
+ return builder;
+ }
+
+ public DeleteNetworkElementConnectionOutputBuilder deleteNetworkElementConnection(DeleteNetworkElementConnectionInput input) throws IOException {
+ boolean removed = this.networkelementConnectionRW.remove(input.getId());
+ if (!removed) {
+ throw new IOException(EXCEPTION_UNABLE_TO_REMOVE_FROM_DATABASE);
+ }
+ return new DeleteNetworkElementConnectionOutputBuilder();
+ }
+
+ public DeleteMediatorServerOutputBuilder deleteMediatorServer(DeleteMediatorServerInput input) throws IOException {
+ boolean removed = this.mediatorserverRW.remove(input.getId());
+ if (!removed) {
+ throw new IOException(EXCEPTION_UNABLE_TO_REMOVE_FROM_DATABASE);
+ }
+ return new DeleteMediatorServerOutputBuilder();
+ }
+
+ public DeleteMaintenanceOutputBuilder deleteMaintenance(DeleteMaintenanceInput input) throws IOException {
+ boolean removed = this.maintenanceRW.remove(input.getId());
+ if (!removed) {
+ throw new IOException(EXCEPTION_UNABLE_TO_REMOVE_FROM_DATABASE);
+ }
+ return new DeleteMaintenanceOutputBuilder();
+ }
+
+ public UpdateMaintenanceOutputBuilder updateMaintenance(UpdateMaintenanceInput input) throws IOException {
+ if (input.getId() == null) {
+ throw new IOException("please give the id for updating entry");
+ }
+ String id = this.maintenanceRW.update(input, input.getId());
+ if (id == null) {
+ throw new IOException(EXCEPTION_UNABLE_TO_UPDATE_IN_DATABASE);
+ }
+ UpdateMaintenanceOutputBuilder builder = new UpdateMaintenanceOutputBuilder(input).setId(id);
+ return builder;
+ }
+
+ public UpdateMediatorServerOutputBuilder updateMediatorServer(UpdateMediatorServerInput input) throws IOException {
+ if (input.getId() == null) {
+ throw new IOException("please give the id for updating entry");
+ }
+ String id = this.mediatorserverRW.update(input, input.getId());
+ if (id == null) {
+ throw new IOException(EXCEPTION_UNABLE_TO_UPDATE_IN_DATABASE);
+ }
+ UpdateMediatorServerOutputBuilder builder = new UpdateMediatorServerOutputBuilder();
+ builder.setId(id).setName(input.getName()).setUrl(input.getUrl());
+ return builder;
+ }
+
+ public CreateMaintenanceOutputBuilder createMaintenance(CreateMaintenanceInput input) throws IOException {
+ String id = this.maintenanceRW.write(input, input.getNodeId());
+ if (id == null) {
+ throw new IOException(EXCEPTION_UNABLE_TO_WRITE_IN_DATABASE);
+ }
+ CreateMaintenanceOutputBuilder builder = new CreateMaintenanceOutputBuilder(input).setId(id);
+ return builder;
+ }
+
+ public CreateMediatorServerOutputBuilder createMediatorServer(CreateMediatorServerInput input) throws IOException {
+ String id = this.mediatorserverRW.write(input, null);
+
+ if (id == null) {
+ throw new IOException(EXCEPTION_UNABLE_TO_WRITE_IN_DATABASE);
+ }
+ CreateMediatorServerOutputBuilder builder = new CreateMediatorServerOutputBuilder();
+ builder.setId(id).setName(input.getName()).setUrl(input.getUrl());
+ return builder;
+ }
+
+ public DataProvider getDataProvider() {
+ return this.databaseService;
+ }
+
+ public HtDatabaseMaintenance getHtDatabaseMaintenance() {
+ return this.databaseMaintenanceService;
+ }
+
+}
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/FaultEntityManager.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/FaultEntityManager.java
new file mode 100644
index 0000000..f26a30d
--- /dev/null
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/FaultEntityManager.java
@@ -0,0 +1,91 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
+ * =================================================================================================
+ * 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.
+ * ============LICENSE_END==========================================================================
+ ******************************************************************************/
+package org.onap.ccsdk.features.sdnr.wt.dataprovider.data;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import javax.annotation.Nonnull;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.Fault;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.FaultcurrentEntity;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.SeverityType;
+
+public class FaultEntityManager {
+
+ private static final Pattern pattern = Pattern.compile(".*\\[layerProtocol=(.*)\\]");
+
+ /**
+ * The leading indication for notification or events that are not in the
+ * currentProblem data of the ONF Coremodel
+ */
+ private static final String NOCURRENTPROBLEMINDICATION = "#";
+
+ /**
+ * Specific problems are not moving into current problem list
+ * @param problemName to be verified
+ * @return true if problem is current
+ */
+ public static boolean isManagedAsCurrentProblem(String problemName) {
+ return ! problemName.startsWith(NOCURRENTPROBLEMINDICATION);
+ }
+
+ public static boolean isManagedAsCurrentProblem(Fault problem) {
+ return isManagedAsCurrentProblem(problem.getProblem());
+ }
+
+ /**
+ * Specific problems are not moving into current problem list
+ * @param fault to be verified
+ * @return true if cleared indication
+ */
+ public static boolean isNoAlarmIndication(@Nonnull Fault fault) {
+ return SeverityType.NonAlarmed.equals(fault.getSeverity());
+ }
+
+ /**
+ * Create a specific ES id for the current log.
+ * @return a string with the generated ES Id
+ */
+ public static String genSpecificEsId(String nodeName, String objectId, String problemName) {
+
+ String uuId;
+
+ Matcher matcher = pattern.matcher(objectId);
+ if (matcher.matches() && matcher.groupCount() == 1) {
+ uuId = matcher.group(1);
+ } else {
+ uuId = objectId;
+ }
+
+ StringBuffer strBuf = new StringBuffer();
+ strBuf.append(nodeName);
+ strBuf.append("/");
+ strBuf.append(uuId);
+ strBuf.append("/");
+ strBuf.append(problemName);
+ return strBuf.toString();
+ }
+
+ /**
+ * Create Es id
+ * @param fault used to create uuid for faultcurrent
+ * @return String with Id
+ */
+ public static String genSpecificEsId(FaultcurrentEntity fault) {
+ return genSpecificEsId(fault.getNodeId(), fault.getObjectId(), fault.getProblem());
+ }
+}
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/HtDatabaseEventsService.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/HtDatabaseEventsService.java
new file mode 100644
index 0000000..63d92b6
--- /dev/null
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/HtDatabaseEventsService.java
@@ -0,0 +1,442 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
+ * =================================================================================================
+ * 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.
+ * ============LICENSE_END==========================================================================
+ ******************************************************************************/
+package org.onap.ccsdk.features.sdnr.wt.dataprovider.data;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.List;
+
+import javax.annotation.Nonnull;
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
+import org.onap.ccsdk.features.sdnr.wt.common.database.HtDatabaseClient;
+import org.onap.ccsdk.features.sdnr.wt.common.database.queries.BoolQueryBuilder;
+import org.onap.ccsdk.features.sdnr.wt.common.database.queries.QueryBuilder;
+import org.onap.ccsdk.features.sdnr.wt.common.database.queries.QueryBuilders;
+import org.onap.ccsdk.features.sdnr.wt.common.database.queries.RangeQueryBuilder;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.EsDataObjectReaderWriter2;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.ArchiveCleanProvider;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.NetconfTimeStamp;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.types.NetconfTimeStampImpl;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ConnectionLogStatus;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ConnectionlogBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ConnectionlogEntity;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.Entity;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.EventlogBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.EventlogEntity;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.FaultcurrentBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.FaultcurrentEntity;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.FaultlogBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.FaultlogEntity;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.GranularityPeriodType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.Inventory;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.InventoryBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.InventoryEntity;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.NetworkElementConnectionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.NetworkElementConnectionEntity;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.PmdataEntity;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.PmdataEntityBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.UpdateNetworkElementConnectionInputBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Event service, writing all events into the database into the appropriate
+ * index.
+ *
+ * @author herbert
+ */
+public class HtDatabaseEventsService implements ArchiveCleanProvider, DataProvider {
+ private static final Logger LOG = LoggerFactory.getLogger(HtDatabaseEventsService.class);
+
+ private static final NetconfTimeStamp NETCONFTIME_CONVERTER = NetconfTimeStampImpl.getConverter();
+
+ private HtDatabaseClient client;
+ private EsDataObjectReaderWriter2<EventlogEntity> eventRWEventLogDevicemanager;
+ private EsDataObjectReaderWriter2<InventoryEntity> eventRWEquipment;
+ private EsDataObjectReaderWriter2<FaultcurrentEntity> eventRWFaultCurrentDB;
+ private EsDataObjectReaderWriter2<FaultlogEntity> eventRWFaultLogDB;
+ private EsDataObjectReaderWriter2<ConnectionlogEntity> eventRWConnectionLogDB;
+ private final EsDataObjectReaderWriter2<NetworkElementConnectionEntity> networkelementConnectionDB;
+ private final EsDataObjectReaderWriter2<PmdataEntity> pmData15mDB;
+ private final EsDataObjectReaderWriter2<PmdataEntity> pmData24hDB;
+
+ @SuppressWarnings("unused")
+ private final ElasticSearchDataProvider dataProvider;
+ // --- Construct and initialize
+
+
+ public HtDatabaseEventsService(HtDatabaseClient client, ElasticSearchDataProvider elasticSearchDataProvider) throws Exception {
+
+ LOG.info("Create {} start", HtDatabaseEventsService.class);
+ this.dataProvider = elasticSearchDataProvider;
+
+ try {
+ // Create control structure
+ this.client = client;
+
+ eventRWEventLogDevicemanager = new EsDataObjectReaderWriter2<>(client, Entity.Eventlog,
+ EventlogEntity.class, EventlogBuilder.class);
+
+ eventRWEquipment = new EsDataObjectReaderWriter2<>(client, Entity.Inventoryequipment,
+ InventoryEntity.class, InventoryBuilder.class);
+
+ eventRWFaultCurrentDB = new EsDataObjectReaderWriter2<>(client, Entity.Faultcurrent,
+ FaultcurrentEntity.class, FaultcurrentBuilder.class);
+
+ eventRWFaultLogDB = new EsDataObjectReaderWriter2<>(client, Entity.Faultlog,
+ FaultlogEntity.class, FaultlogBuilder.class);
+
+ eventRWConnectionLogDB = new EsDataObjectReaderWriter2<>(client, Entity.Connectionlog,
+ ConnectionlogEntity.class, ConnectionlogBuilder.class);
+
+ networkelementConnectionDB = new EsDataObjectReaderWriter2<>(client, Entity.NetworkelementConnection,
+ NetworkElementConnectionEntity.class, NetworkElementConnectionBuilder.class)
+ .setEsIdAttributeName("_id");
+
+ pmData15mDB = new EsDataObjectReaderWriter2<>(client, Entity.Historicalperformance15min,
+ PmdataEntity.class, PmdataEntityBuilder.class);
+
+ pmData24hDB = new EsDataObjectReaderWriter2<>(client, Entity.Historicalperformance24h,
+ PmdataEntity.class, PmdataEntityBuilder.class);
+
+ } catch (Exception e) {
+ LOG.error("Can not start database client. Exception: {}", e);
+ throw new Exception("Can not start database client. Exception: {}", e);
+ }
+ LOG.info("Create {} finished. DB Service {} started.", HtDatabaseEventsService.class,
+ client != null ? "sucessfully" : "not");
+ }
+
+ // --- Function
+
+ // -- Connection log
+ @Override
+ public void writeConnectionLog(ConnectionlogEntity event) {
+ if (assertIfClientNull(event)) {
+ return;
+ }
+ LOG.debug("Write event: {}", event);
+ eventRWConnectionLogDB.write(event, null);
+
+ }
+ // -- Event log
+ @Override
+ public void writeEventLog(EventlogEntity event) {
+ if (assertIfClientNull("No client to write {}", event)) {
+ return;
+ }
+
+ LOG.debug("Write event: {}", event.toString());
+ eventRWEventLogDevicemanager.write(event, null);
+ }
+
+
+ // -- Fault log
+
+ @Override
+ public void writeFaultLog(FaultlogEntity fault) {
+ if (assertIfClientNull(fault)) {
+ return;
+ }
+
+ LOG.debug("Write fault to faultlog: {}", fault.toString());
+ eventRWFaultLogDB.write(fault,null);
+ }
+
+ // -- Fault current
+
+ @Override
+ public void updateFaultCurrent(FaultcurrentEntity fault) {
+ if (assertIfClientNull(fault)) {
+ return;
+ }
+
+ if (FaultEntityManager.isManagedAsCurrentProblem(fault)) {
+ if (FaultEntityManager.isNoAlarmIndication(fault)) {
+ LOG.debug("Remove from currentFaults: {}", fault.toString());
+ eventRWFaultCurrentDB.remove(FaultEntityManager.genSpecificEsId(fault));
+ } else {
+ LOG.debug("Write to currentFaults: {}", fault.toString());
+ eventRWFaultCurrentDB.write(fault, FaultEntityManager.genSpecificEsId(fault));
+ }
+ } else {
+ LOG.debug("Ingnore for currentFaults: {}", fault.toString());
+ }
+ }
+
+ /**
+ * Remove all entries for one node
+ *
+ * @param nodeName contains the mountpointname
+ * @return number of deleted entries
+ */
+ @Override
+ public int clearFaultsCurrentOfNode(String nodeName) {
+ if (assertIfClientNullForNodeName(nodeName)) {
+ return -1;
+ }
+
+ LOG.debug("Remove from currentFaults all faults for node: {}", nodeName);
+ return eventRWFaultCurrentDB.remove(EsFaultCurrent.getQueryForOneNode(nodeName));
+ }
+
+ /**
+ * Remove all entries for one node
+ *
+ * @param nodeName contains the mountpointname
+ * @param objectId of element to be deleted
+ * @return number of deleted entries
+ */
+ @Override
+ public int clearFaultsCurrentOfNodeWithObjectId(String nodeName, String objectId) {
+ if (assertIfClientNullForNodeName(nodeName)) {
+ return -1;
+ }
+
+ LOG.debug("Remove from currentFaults all faults for node/objectId: {}/{}", nodeName, objectId);
+ return eventRWFaultCurrentDB.remove(EsFaultCurrent.getQueryForOneNodeAndObjectId(nodeName, objectId));
+ }
+
+ /**
+ * Deliver list with all mountpoint/node-names in the database.
+ *
+ * @return List of all mountpoint/node-names the had active alarms.
+ */
+ @Override
+ public @Nonnull List<String> getAllNodesWithCurrentAlarms() {
+ if (assertIfClientNull("No DB, can not delete for all nodes", null)) {
+ return new ArrayList<>();
+ }
+
+ LOG.debug("Remove from currentFaults faults for all node");
+ List<String> nodeNames = new ArrayList<>();
+
+ for (FaultcurrentEntity fault : eventRWFaultCurrentDB.doReadAll().getHits()) {
+ String nodeName = fault.getNodeId();
+ if (!nodeNames.contains(nodeName)) {
+ // this.clearFaultsCurrentOfNode(nodeName); -> Function shifted
+ nodeNames.add(nodeName);
+ }
+ }
+ return nodeNames;
+ }
+
+ // -- Inventory and equipment current
+
+ /**
+ * write internal equipment to database
+ * @param internalEquipment with mandatory fields.
+ */
+ @Override
+ public void writeInventory(Inventory internalEquipment) {
+
+ if (assertIfClientNullForNodeName(internalEquipment.getNodeId())) {
+ return;
+ }
+ eventRWEquipment.write(internalEquipment, internalEquipment.getNodeId()+"/"+internalEquipment.getUuid());
+ }
+
+
+ // -- Networkelement
+
+ /**
+ *
+ * @param networkElementConnectionEntitiy to wirte to DB
+ * @param nodeId Id for this DB element
+ */
+ @Override
+ public void updateNetworkConnectionDeviceType(NetworkElementConnectionEntity networkElementConnectionEntitiy, String nodeId) {
+ this.networkelementConnectionDB.update(networkElementConnectionEntitiy, nodeId);
+ }
+
+ /**
+ * Update after new mountpoint registration
+ * @param networkElementConnectionEntitiy data
+ * @param nodeId of device (mountpoint name)
+ */
+ @Override
+ public void updateNetworkConnection22(NetworkElementConnectionEntity networkElementConnectionEntitiy, String nodeId) {
+ this.networkelementConnectionDB.updateOrCreate(networkElementConnectionEntitiy, nodeId, Arrays.asList("is-required", "username", "password"));
+ }
+
+ /* please do not remove */
+ // public void cleanNetworkElementConnections() {
+ // this.networkelementConnectionDB.remove(QueryBuilders.matchQuery("is-required", false));
+ // CreateNetworkElementConnectionInput x = new CreateNetworkElementConnectionInputBuilder().setStatus(ConnectionLogStatus.Disconnected).build();
+ // this.networkelementConnectionDB.update(x,QueryBuilders.matchAllQuery());
+ // }
+
+ @Override
+ public void removeNetworkConnection(String nodeId) {
+ Boolean isRequired;
+ NetworkElementConnectionEntity e = this.networkelementConnectionDB.read(nodeId);
+ if (e != null && (isRequired = e.isIsRequired()) != null) {
+ if (isRequired) {
+ LOG.debug("updating connection status for {} of required ne to disconnected",nodeId);
+ this.networkelementConnectionDB.update(new UpdateNetworkElementConnectionInputBuilder().setStatus(ConnectionLogStatus.Disconnected).build(), nodeId);
+ } else {
+ LOG.debug("remove networkelement-connection for {} entry because of non-required",nodeId);
+ this.networkelementConnectionDB.remove(nodeId);
+ }
+ }
+ else {
+ LOG.warn("Unable to update connection-status. dbentry for {} not found in networkelement-connection",nodeId);
+ }
+ }
+
+ // -- Multiple areas
+
+ @Override
+ public int doIndexClean(Date olderAreOutdated) {
+
+ String netconfTimeStamp = NETCONFTIME_CONVERTER.getTimeStampAsNetconfString(olderAreOutdated);
+ int removed = 0;
+
+ QueryBuilder queryEventBase = EsEventBase.getQueryForTimeStamp(netconfTimeStamp);
+ removed += eventRWEventLogDevicemanager.remove(queryEventBase);
+
+ QueryBuilder queryFaultLog = EsFaultLogDevicemanager.getQueryForTimeStamp(netconfTimeStamp);
+ removed += eventRWFaultLogDB.remove(queryFaultLog);
+ return removed;
+ }
+
+ @Override
+ public int getNumberOfOldObjects(Date olderAreOutdated) {
+
+ String netconfTimeStamp = NETCONFTIME_CONVERTER.getTimeStampAsNetconfString(olderAreOutdated);
+ int numberOfElements = 0;
+
+ QueryBuilder queryEventBase = EsEventBase.getQueryForTimeStamp(netconfTimeStamp);
+ numberOfElements += eventRWEventLogDevicemanager.doReadAll(queryEventBase).getTotal();
+
+ QueryBuilder queryFaultLog = EsFaultLogDevicemanager.getQueryForTimeStamp(netconfTimeStamp);
+ numberOfElements += eventRWFaultLogDB.doReadAll(queryFaultLog).getTotal();
+
+ return numberOfElements;
+ }
+
+ // -- Helper
+
+ /**
+ * Verify status of client
+ * @param event that is printed with message
+ * @return true if client is null
+ */
+ private boolean assertIfClientNull(Object event) {
+ return assertIfClientNull("No DB, can not write: {}", event);
+ }
+
+ private boolean assertIfClientNullForNodeName(Object object) {
+ return assertIfClientNull("No DB, can not handle node: {}", object);
+ }
+ /**
+ * Verify status of client
+ * @param message to print including {} for object printout.
+ * @return true if client is null
+ */
+ private boolean assertIfClientNull(String message, Object object) {
+ if (client == null) {
+ LOG.debug(message, object);
+ return true;
+ }
+ return false;
+ }
+
+ // ### sub classes
+
+
+ private static class EsEventBase {
+ /**
+ * Query to get older Elements
+ * @param netconfTimeStamp to identify older Elements
+ * @return QueryBuilder for older elements related to timestamp
+ */
+ private static QueryBuilder getQueryForTimeStamp(String netconfTimeStamp) {
+ return new RangeQueryBuilder("event.timeStamp").lte(netconfTimeStamp);
+ }
+ }
+ private static class EsFaultLogDevicemanager {
+ /**
+ * Get older Elements
+ * @param netconfTimeStamp to identify query elements older than this timestamp.
+ * @return QueryBuilder for related elements
+ */
+ public static QueryBuilder getQueryForTimeStamp(String netconfTimeStamp) {
+ return new RangeQueryBuilder("timestamp").lte(netconfTimeStamp);
+ }
+ }
+ public static class EsFaultCurrent {
+ /**
+ * @param nodeName name of the node
+ * @return query builder
+ */
+ public static QueryBuilder getQueryForOneNode( String nodeName) {
+ return QueryBuilders.matchQuery("node-id", nodeName);
+ }
+
+ public static QueryBuilder getQueryForOneNodeAndObjectId( String nodeName, String objectId) {
+ BoolQueryBuilder bq = QueryBuilders.boolQuery();
+ bq.must(QueryBuilders.matchQuery("node-id", nodeName));
+ bq.must(QueryBuilders.matchQuery("object-id", objectId));
+ return bq;
+ }
+ }
+ @Override
+ public List<NetworkElementConnectionEntity> getNetworkElementConnections() {
+ return this.networkelementConnectionDB.doReadAll().getHits();
+ }
+
+ @Override
+ public void doWritePerformanceData(List<PmdataEntity> list) {
+
+ list.forEach(elem -> {
+ GranularityPeriodType granularityPeriod = nnGetGranularityPeriodType(elem.getGranularityPeriod());
+ //_id": "Sim12600/LP-MWPS-TTP-01/2017-07-04T15:15:00.0+00:00"
+ StringBuffer id = new StringBuffer();
+ DateAndTime date = elem.getTimeStamp();
+ id.append(elem.getNodeName());
+ id.append("/");
+ id.append(elem.getUuidInterface());
+ id.append("/");
+ id.append(date != null ? date.getValue() : "null");
+
+ switch (granularityPeriod) {
+ case Period15Min:
+ pmData15mDB.write(elem, id.toString());
+ break;
+ case Period24Hours:
+ pmData24hDB.write(elem, id.toString());
+ break;
+ case Unknown:
+ default:
+ LOG.debug("Unknown granularity {} id {}", granularityPeriod, id);
+ break;
+ }
+ } );
+
+ }
+
+ @NonNull GranularityPeriodType nnGetGranularityPeriodType(@Nullable GranularityPeriodType granularityPeriod) {
+ return granularityPeriod != null ? granularityPeriod : GranularityPeriodType.Unknown;
+ }
+
+}
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/HtDatabaseMaintenanceService.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/HtDatabaseMaintenanceService.java
new file mode 100644
index 0000000..45d989d
--- /dev/null
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/HtDatabaseMaintenanceService.java
@@ -0,0 +1,167 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
+ * =================================================================================================
+ * 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.
+ * ============LICENSE_END==========================================================================
+ ******************************************************************************/
+
+package org.onap.ccsdk.features.sdnr.wt.dataprovider.data;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
+import org.onap.ccsdk.features.sdnr.wt.common.HtAssert;
+import org.onap.ccsdk.features.sdnr.wt.common.database.HtDatabaseClient;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.EsDataObjectReaderWriter2;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.HtDatabaseMaintenance;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.types.NetconfTimeStampImpl;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.Entity;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.MaintenanceBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.MaintenanceEntity;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.NetworkElementConnectionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.NetworkElementConnectionEntity;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class HtDatabaseMaintenanceService implements HtDatabaseMaintenance {
+
+ private static final Logger LOG = LoggerFactory.getLogger(HtDatabaseMaintenanceService.class);
+
+ private final EsDataObjectReaderWriter2<MaintenanceEntity> maintenanceRW;
+ private final EsDataObjectReaderWriter2<NetworkElementConnectionEntity> requiredNeRW;
+
+ HtDatabaseMaintenanceService(@NonNull HtDatabaseClient client) throws ClassNotFoundException {
+ HtAssert.nonnull(client);
+
+ // Create control structure
+ maintenanceRW = new EsDataObjectReaderWriter2<>(client, Entity.Maintenancemode, MaintenanceEntity.class,
+ MaintenanceBuilder.class).setEsIdAttributeName("_id");
+
+ requiredNeRW = new EsDataObjectReaderWriter2<>(client, Entity.NetworkelementConnection,
+ NetworkElementConnectionEntity.class, NetworkElementConnectionBuilder.class)
+ .setEsIdAttributeName("_id");
+
+ }
+
+ /**
+ * Get existing object for mountpoint to manage maintenance mode
+ * @return Object with configuration
+ */
+ @Override
+ @Nullable
+ public MaintenanceEntity getMaintenance(@Nullable String mountpointId) {
+ MaintenanceEntity deviceMaintenanceMode = null;
+ if (maintenanceRW != null && mountpointId != null) {
+ deviceMaintenanceMode = maintenanceRW.read(mountpointId);
+ }
+ return deviceMaintenanceMode;
+ }
+
+ @Override
+ public
+ MaintenanceEntity setMaintenance(MaintenanceEntity m) {
+ if (maintenanceRW != null) {
+ if (maintenanceRW.write(m, m.getNodeId() ) == null) {
+ throw new IllegalArgumentException("Problem writing to database: "+m.getId());
+ }
+ LOG.info("Wrote maintenance object {}", m.toString());
+ }
+ return m;
+ }
+
+ @Override
+ public
+ List<MaintenanceEntity> getAll() {
+ return maintenanceRW != null ? maintenanceRW.doReadAll().getHits() : new ArrayList<>();
+ }
+
+ @Override
+ public
+ MaintenanceEntity createIfNotExists(String mountpointId) {
+ MaintenanceEntity deviceMaintenanceMode = null;
+ if (maintenanceRW != null) {
+ deviceMaintenanceMode = maintenanceRW.read(mountpointId);
+ if (deviceMaintenanceMode == null) {
+ LOG.debug("creating empty maintenance object in database");
+ deviceMaintenanceMode = getDefaultMaintenance(mountpointId);
+ maintenanceRW.write(deviceMaintenanceMode, mountpointId);
+ } else {
+ LOG.debug("maintenance object already exists in database");
+ }
+ } else {
+ LOG.warn("cannot create maintenance obj. db reader/writer is null");
+ }
+ return deviceMaintenanceMode;
+ }
+
+ @Override
+ public
+ void deleteIfNotRequired(String mountPointNodeName) {
+
+ if (!this.isRequireNe(mountPointNodeName)) {
+ if (maintenanceRW != null) {
+ LOG.debug("removing maintenance object in database for " + mountPointNodeName);
+ maintenanceRW.remove(mountPointNodeName);
+ } else {
+ LOG.warn("cannot create maintenance obj. db reader/writer is null");
+ }
+ }
+
+ }
+
+ /**
+ * Provide default maintenanceinformation for a device
+ * @param mountpointId nodeId of device
+ * @return default data
+ */
+ static private MaintenanceEntity getDefaultMaintenance(String mountpointId) {
+
+ DateAndTime now = NetconfTimeStampImpl.getConverter().getTimeStamp();
+
+ MaintenanceBuilder deviceMaintenanceModeBuilder = new MaintenanceBuilder();
+ deviceMaintenanceModeBuilder.setNodeId(mountpointId).setId(mountpointId);
+ // Use time from mountpoint creation
+ deviceMaintenanceModeBuilder.setDescription("");
+ // Use time from mountpoint creation
+ deviceMaintenanceModeBuilder.setStart(now);
+ deviceMaintenanceModeBuilder.setEnd(now);
+ // Reference to all
+ deviceMaintenanceModeBuilder.setObjectIdRef("");
+ deviceMaintenanceModeBuilder.setProblem("");
+ deviceMaintenanceModeBuilder.setActive(false);
+
+ return deviceMaintenanceModeBuilder.build();
+ }
+
+ // -- Private
+ /**
+ * Check in required ne if entry exists for mountpointNodeName
+ *
+ * @param mountPointNodeName
+ * @return
+ */
+ private boolean isRequireNe(String mountPointNodeName) {
+ NetworkElementConnectionEntity ne = null;
+ if (requiredNeRW != null) {
+ LOG.debug("searching for entry in required-networkelement for " + mountPointNodeName);
+ ne = requiredNeRW.read(mountPointNodeName);
+ } else {
+ LOG.warn("cannot read db. no db reader writer initialized");
+ }
+ return ne != null;
+ }
+
+}
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/MediatorServerDataProvider.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/MediatorServerDataProvider.java
new file mode 100644
index 0000000..bc61e81
--- /dev/null
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/MediatorServerDataProvider.java
@@ -0,0 +1,96 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
+ * =================================================================================================
+ * 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.
+ * ============LICENSE_END==========================================================================
+ ******************************************************************************/
+package org.onap.ccsdk.features.sdnr.wt.dataprovider.data;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+
+import org.onap.ccsdk.features.sdnr.wt.common.database.HtDatabaseClient;
+import org.onap.ccsdk.features.sdnr.wt.common.database.SearchResult;
+import org.onap.ccsdk.features.sdnr.wt.common.database.config.HostInfo;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.Entity;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.mediator.server.list.output.Data;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class MediatorServerDataProvider implements AutoCloseable {
+
+ private static final Logger LOG = LoggerFactory.getLogger(MediatorServerDataProvider.class);
+
+ private final HtDatabaseClient dbClient;
+ private final DataObjectAcessor<Data> mediatorserverRW;
+ private final int REFRESH_INTERVAL = 60;
+ private final Map<String, Data> entries;
+ private final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
+ private boolean isRunning;
+
+ public MediatorServerDataProvider(HostInfo[] hosts) throws Exception {
+ this(hosts, null, null);
+ }
+
+ public MediatorServerDataProvider(HostInfo[] hosts, String authUsername, String authPassword) throws Exception {
+ super();
+ LOG.info("Start {}", this.getClass().getName());
+ this.entries = new HashMap<>();
+ this.dbClient = new HtDatabaseClient(hosts, authUsername, authPassword);
+ this.mediatorserverRW = new DataObjectAcessor<>(dbClient, Entity.MediatorServer, Data.class);
+ this.scheduler.scheduleAtFixedRate(onTick, this.REFRESH_INTERVAL, this.REFRESH_INTERVAL, TimeUnit.SECONDS);
+ }
+
+ private final Runnable onTick = new Runnable() {
+
+ @Override
+ public void run() {
+ isRunning = true;
+ SearchResult<Data> result = MediatorServerDataProvider.this.mediatorserverRW.doReadAll();
+ List<Data> data = result.getHits();
+ for (Data item : data) {
+ MediatorServerDataProvider.this.entries.put(item.getId(), item);
+ }
+ isRunning = false;
+ }
+
+ };
+
+ public String getHostUrl(String dbServerId) {
+ Data info = this.entries.getOrDefault(dbServerId, null);
+ return info == null ? null : info.getUrl();
+ }
+
+ public boolean triggerReloadSync() {
+ new Thread(onTick).start();
+ int i = 20;
+ while (isRunning && i-- > 0) {
+ try {
+ Thread.sleep(500);
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ }
+ }
+ return i > 0;
+ }
+
+ @Override
+ public void close() throws Exception {
+ this.scheduler.shutdown();
+ }
+}
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/ODLVersionLUT.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/ODLVersionLUT.java
new file mode 100644
index 0000000..adf5d3b
--- /dev/null
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/ODLVersionLUT.java
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
+ * =================================================================================================
+ * 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.
+ * ============LICENSE_END==========================================================================
+ ******************************************************************************/
+package org.onap.ccsdk.features.sdnr.wt.dataprovider.data;
+
+public class ODLVersionLUT {
+
+ public static String getONAPReleaseName(String onapCCSDKVersion,String def) {
+ if(onapCCSDKVersion==null) {
+ return def;
+ }
+ if(onapCCSDKVersion.startsWith("1.6.")) {
+ return "ONAP Guillin";
+ }
+ if(onapCCSDKVersion.startsWith("1.5.")) {
+ return "ONAP Frankfurt";
+ }
+ if(onapCCSDKVersion.startsWith("1.4.")) {
+ return "ONAP El Alto";
+ }
+ if(onapCCSDKVersion.startsWith("1.3.")) {
+ return "ONAP El Alto";
+ }
+ return def;
+ }
+ public static String getOdlVersion(String onapCCSDKVersion,String def) {
+
+ if(onapCCSDKVersion==null) {
+ return def;
+ }
+ if(onapCCSDKVersion.startsWith("1.6.")) {
+ return "sodium-SRX (0.11.X)";
+ }
+ if(onapCCSDKVersion.startsWith("1.5.")) {
+ return "neon-SR1 (0.10.1)";
+ }
+ if(onapCCSDKVersion.startsWith("1.4.")) {
+ return "neon-SR1 (0.10.1)";
+ }
+ if(onapCCSDKVersion.startsWith("1.3.")) {
+ return "fluorine-SR2 (0.9.2)";
+ }
+ return def;
+ }
+}
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/QueryByFilter.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/QueryByFilter.java
new file mode 100644
index 0000000..db52795
--- /dev/null
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/QueryByFilter.java
@@ -0,0 +1,343 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
+ * =================================================================================================
+ * 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.
+ * ============LICENSE_END==========================================================================
+ ******************************************************************************/
+package org.onap.ccsdk.features.sdnr.wt.dataprovider.data;
+
+import java.util.Calendar;
+import java.util.Date;
+import java.util.List;
+import java.util.TimeZone;
+
+import org.eclipse.jdt.annotation.Nullable;
+import org.onap.ccsdk.features.sdnr.wt.common.database.data.DbFilter;
+import org.onap.ccsdk.features.sdnr.wt.common.database.queries.BoolQueryBuilder;
+import org.onap.ccsdk.features.sdnr.wt.common.database.queries.QueryBuilder;
+import org.onap.ccsdk.features.sdnr.wt.common.database.queries.QueryBuilders;
+import org.onap.ccsdk.features.sdnr.wt.common.database.queries.RangeQueryBuilder;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.NetconfTimeStamp;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.types.NetconfTimeStampImpl;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.EntityInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.SortOrder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.entity.input.Filter;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.entity.input.Sortorder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class QueryByFilter {
+
+ private static final Logger LOG = LoggerFactory.getLogger(DataObjectAcessorPm.class);
+
+ private QueryByFilter() {
+ //Hide
+ }
+
+ static long getPage(EntityInput input) {
+ return getPage(input, 1);
+ }
+
+ @SuppressWarnings("null")
+ private static long getPage(EntityInput input, long defaultValue) {
+ return input.getPagination() != null ? input.getPagination().getPage().longValue() : defaultValue;
+ }
+
+ static long getPageSize(EntityInput input) {
+ return getPageSize(input, 1);
+ }
+
+ @SuppressWarnings("null")
+ private static long getPageSize(EntityInput input, long defaultValue) {
+ return input.getPagination() != null ? input.getPagination().getSize().longValue() : defaultValue;
+ }
+
+
+ public static QueryBuilder setSortOrder(QueryBuilder query, @Nullable List<Sortorder> sortorder) {
+ return setSortOrder(query, sortorder, "");
+ }
+
+ private static QueryBuilder setSortOrder(QueryBuilder query, @Nullable List<Sortorder> sortorder, String prefix) {
+ if (sortorder != null && sortorder.size() > 0) {
+ for (Sortorder so : sortorder) {
+ query.sort((prefix != null ? prefix : "") + so.getProperty(),
+ so.getSortorder() == SortOrder.Ascending
+ ? org.onap.ccsdk.features.sdnr.wt.common.database.queries.SortOrder.ASCENDING
+ : org.onap.ccsdk.features.sdnr.wt.common.database.queries.SortOrder.DESCENDING);
+ }
+ }
+ return query;
+
+ }
+
+
+ public static Sortorder getSortOrder(@Nullable List<Sortorder> list, String prop) {
+ if (list == null) {
+ return null;
+ }
+ for (Sortorder o : list) {
+ if (prop.equals(o.getProperty())) {
+ return o;
+ }
+ }
+ return null;
+ }
+
+ public static Filter getFilter(@Nullable List<Filter> list, String prop) {
+ if (list == null) {
+ return null;
+ }
+ for (Filter f : list) {
+ if (prop.equals(f.getProperty())) {
+ return f;
+ }
+ }
+ return null;
+ }
+
+ public static QueryBuilder fromFilter(@Nullable List<Filter> filters) {
+ return fromFilter(filters, "");
+ }
+
+ private static String fillTimeStamp(String value) {
+ int idx=value.lastIndexOf("*");
+ final String REPLACE="0000-00-00T00:00:00.0Z";
+ String s = value.substring(0,idx)+REPLACE.substring(idx);
+ if(Integer.parseInt(s.substring(5,7))==0) {
+ s=s.substring(0,5)+"01-"+s.substring(8);
+ }
+ if(Integer.parseInt(s.substring(8,10))==0) {
+ s=s.substring(0,8)+"01"+s.substring(10);
+ }
+
+ return s;
+ }
+ /**
+ * convert timestamp with ending placeholder in filter to elasticsearch filter
+ * e.g. 2017* => gte: 2017-01-01T00:00:00Z, lt:2018-01-01T00:00:00Z
+ *
+ * 201* => 2010-01... 2020 ..
+ * 2018-* => 2018-01... <=> 2019-01
+ *
+ */
+ private static @Nullable QueryBuilder fromTimestampSearchFilter(String property,String value) {
+ if(!value.endsWith("*")) {
+ return null;
+ }
+ int idx=value.lastIndexOf("*");
+ String lowerEnd = fillTimeStamp(value);
+ String upperEnd =null;
+ NetconfTimeStamp converter = NetconfTimeStampImpl.getConverter();
+ Date dt = null;
+ try{
+ dt=converter.getDateFromNetconf(lowerEnd);
+ }
+ catch(Exception e) {
+
+ }
+ if(dt==null) {
+ return null;
+ }
+// property.substring(0,idx)+REPLACE.substring(idx+1);
+ Calendar c = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
+ c.setTime(dt);
+ int tmpvalue;
+ switch(idx) {
+ case 1: // (2*)
+ c.set(Calendar.YEAR,c.get(Calendar.YEAR)+1000);
+ upperEnd = converter.getTimeStampAsNetconfString(c.getTime());
+ break;
+ case 2: // (20*)
+ c.set(Calendar.YEAR,c.get(Calendar.YEAR)+100);
+ upperEnd = converter.getTimeStampAsNetconfString(c.getTime());
+ break;
+ case 3: // (200*)
+ c.set(Calendar.YEAR,c.get(Calendar.YEAR)+10);
+ upperEnd = converter.getTimeStampAsNetconfString(c.getTime());
+ break;
+ case 4: // (2000*)
+ case 5: // (2000-*)
+ c.set(Calendar.YEAR,c.get(Calendar.YEAR)+1);
+ upperEnd = converter.getTimeStampAsNetconfString(c.getTime());
+ break;
+ case 6: //switch 10 months (2000-0* or 2000-1*)
+ tmpvalue = c.get(Calendar.MONTH);
+ if(tmpvalue<9) {
+ c.set(Calendar.MONTH,9);
+ }
+ else {
+ c.set(Calendar.YEAR,c.get(Calendar.YEAR)+1);
+ c.set(Calendar.MONTH,0);
+ }
+ upperEnd = converter.getTimeStampAsNetconfString(c.getTime());
+
+ break;
+ case 7: //switch one month (2018-01* or 2018-01-*)
+ case 8:
+ c.add(Calendar.MONTH, 1);
+ upperEnd = converter.getTimeStampAsNetconfString(c.getTime());
+ break;
+ case 9: // (2018-01-0*)
+ tmpvalue = c.get(Calendar.DAY_OF_MONTH);
+ if(tmpvalue==1) {
+ c.set(Calendar.DAY_OF_MONTH, 10);
+ }else if(tmpvalue==10) {
+ c.set(Calendar.DAY_OF_MONTH, 20);
+ }else if(tmpvalue==20) {
+ if(c.getActualMaximum(Calendar.DAY_OF_MONTH)<30) {
+ c.set(Calendar.DAY_OF_MONTH,1);
+ c.add(Calendar.MONTH,1);
+ }
+ else {
+ c.set(Calendar.DAY_OF_MONTH,30);
+ }
+ }else if(tmpvalue==30) {
+ c.set(Calendar.DAY_OF_MONTH,1);
+ c.add(Calendar.MONTH,1);
+ }
+ else {
+ break;
+ }
+ upperEnd = converter.getTimeStampAsNetconfString(c.getTime());
+ break;
+ case 10: // (2018-01-01*)
+ case 11: // (2018-01-01T*)
+ c.add(Calendar.DAY_OF_MONTH,1);
+ upperEnd = converter.getTimeStampAsNetconfString(c.getTime());
+ break;
+ case 12: // (2018-01-01T1*)
+ tmpvalue = c.get(Calendar.HOUR_OF_DAY);
+ if(tmpvalue==20) {
+ c.set(Calendar.HOUR_OF_DAY,0);
+ c.add(Calendar.DAY_OF_MONTH,1);
+ }
+ else {
+ c.add(Calendar.HOUR_OF_DAY,10);
+ }
+ upperEnd = converter.getTimeStampAsNetconfString(c.getTime());
+ break;
+ case 13: // (2018-01-01T11*)
+ case 14: // (2018-01-01T11-*)
+ c.add(Calendar.HOUR_OF_DAY,1);
+ upperEnd = converter.getTimeStampAsNetconfString(c.getTime());
+ break;
+ case 15: // (2018-01-01T11-3*)
+ c.add(Calendar.MINUTE,10);
+ upperEnd = converter.getTimeStampAsNetconfString(c.getTime());
+ break;
+ case 16: // (2018-01-01T11-32*)
+ case 17: // (2018-01-01T11-32-*)
+ c.add(Calendar.MINUTE,1);
+ upperEnd = converter.getTimeStampAsNetconfString(c.getTime());
+ break;
+ case 18: // (2018-01-01T11-32-1*)
+ c.add(Calendar.SECOND,10);
+ upperEnd = converter.getTimeStampAsNetconfString(c.getTime());
+ break;
+ case 19: // (2018-01-01T11-32-11*)
+ case 20: // (2018-01-01T11-32-11.*)
+ c.add(Calendar.SECOND,1);
+ upperEnd = converter.getTimeStampAsNetconfString(c.getTime());
+ break;
+
+ default:
+ break;
+ }
+
+ if(upperEnd==null) {
+ return null;
+ }
+ return QueryBuilders.rangeQuery(property).gte(lowerEnd).lt(upperEnd);
+
+ }
+ private static QueryBuilder fromFilter(@Nullable List<Filter> filters, String prefix) {
+ if (filters == null || filters.size() == 0) {
+ return QueryBuilders.matchAllQuery();
+
+ } else if (filters.size() == 1) {
+ QueryBuilder query;
+ String p = filters.get(0).getProperty();
+ String v= filters.get(0).getFiltervalue();
+ if ("id".equals(p)) {
+ p = "_id";
+ }
+ else {
+ // v=v.toLowerCase();
+ }
+ if (DbFilter.hasSearchParams(v)) {
+ if(p!=null && "timestamp".equals(p.toLowerCase())) {
+ query = fromTimestampSearchFilter(p,v);
+ if(query!=null) {
+ return query;
+ }
+ }
+ return QueryBuilders.regex(p, DbFilter.createDatabaseRegex(v));
+
+
+ } else if (DbFilter.isComparisonValid(v)) {
+ RangeQueryBuilder q = DbFilter.getRangeQuery((prefix != null ? prefix : "") + p, v);
+ if (q != null) {
+ return q;
+ }
+ else {
+ return QueryBuilders.matchQuery((prefix != null ? prefix : "") + p, v);
+ }
+ }
+ else {
+ return QueryBuilders.matchQuery((prefix != null ? prefix : "") + p, v);
+ }
+ }
+ else {
+ BoolQueryBuilder query = new BoolQueryBuilder();
+ QueryBuilder tmpQuery;
+ for (Filter fi : filters) {
+ String p = fi.getProperty();
+ String v=fi.getFiltervalue();
+ if ("id".equals(p)) {
+ p = "_id";
+ }
+ else {
+ // v=v.toLowerCase();
+ }
+ if(DbFilter.hasSearchParams(v)) {
+ if(p!=null && "timestamp".equals(p.toLowerCase())) {
+ tmpQuery=fromTimestampSearchFilter(p,v);
+ if(tmpQuery!=null) {
+ query.must(tmpQuery);
+ }else {
+ query.must(QueryBuilders.regex((prefix != null ? prefix : "") + p,DbFilter.createDatabaseRegex(v)));
+ }
+ }else {
+ query.must(QueryBuilders.regex((prefix != null ? prefix : "") + p,DbFilter.createDatabaseRegex(v)));
+ }
+ }
+ else if (DbFilter.isComparisonValid(v)) {
+ RangeQueryBuilder q = DbFilter.getRangeQuery((prefix != null ? prefix : "") + p,v);
+ if(q!=null) {
+ query.must(q);
+ }
+ else {
+ query.must(QueryBuilders.matchQuery((prefix != null ? prefix : "") + p,v));
+ }
+ }
+ else {
+ query.must(QueryBuilders.matchQuery((prefix != null ? prefix : "") + p,v));
+ }
+ }
+ LOG.trace("Query result. {}", query.toJSON());
+ return query;
+ }
+ }
+
+}
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/QueryResult.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/QueryResult.java
new file mode 100644
index 0000000..9cbe943
--- /dev/null
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/QueryResult.java
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
+ * =================================================================================================
+ * 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.
+ * ============LICENSE_END==========================================================================
+ ******************************************************************************/
+package org.onap.ccsdk.features.sdnr.wt.dataprovider.data;
+
+import java.math.BigInteger;
+
+import org.onap.ccsdk.features.sdnr.wt.common.database.SearchResult;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.PaginationOutputG;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.connectionlog.list.output.PaginationBuilder;
+
+public class QueryResult<T> {
+
+ private SearchResult<T> result;
+ private PaginationOutputG pagination;
+
+ public QueryResult(long page, long pageSize, SearchResult<T> result) {
+ this.result = result;
+
+ PaginationBuilder x = new PaginationBuilder();
+ x.setPage(BigInteger.valueOf(page));
+ x.setSize(pageSize);
+ x.setTotal(BigInteger.valueOf(result.getTotal()));
+ pagination = x.build();
+ }
+
+ public SearchResult<T> getResult() {
+ return result;
+ }
+
+ PaginationOutputG getPagination() {
+ return pagination;
+ }
+
+
+
+
+}
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/SystemInfo.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/SystemInfo.java
new file mode 100644
index 0000000..2b3ebd8
--- /dev/null
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/SystemInfo.java
@@ -0,0 +1,331 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
+ * =================================================================================================
+ * 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.
+ * ============LICENSE_END==========================================================================
+ ******************************************************************************/
+package org.onap.ccsdk.features.sdnr.wt.dataprovider.data;
+
+import java.io.File;
+import java.io.IOException;
+import java.lang.management.ClassLoadingMXBean;
+import java.lang.management.GarbageCollectorMXBean;
+import java.lang.management.ManagementFactory;
+import java.lang.management.MemoryMXBean;
+import java.lang.management.MemoryPoolMXBean;
+import java.lang.management.MemoryType;
+import java.lang.management.MemoryUsage;
+import java.lang.management.OperatingSystemMXBean;
+import java.lang.management.RuntimeMXBean;
+import java.lang.management.ThreadMXBean;
+import java.lang.reflect.Method;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.text.DecimalFormat;
+import java.text.DecimalFormatSymbols;
+import java.text.NumberFormat;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.concurrent.Callable;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import java.util.stream.Stream;
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.FrameworkUtil;
+
+public class SystemInfo {
+ private static NumberFormat fmtI = new DecimalFormat("###,###", new DecimalFormatSymbols(Locale.ENGLISH));
+ private static NumberFormat fmtDec = new DecimalFormat("###,###.##", new DecimalFormatSymbols(Locale.ENGLISH));
+ private static NumberFormat fmtD = new DecimalFormat("###,##0.000", new DecimalFormatSymbols(Locale.ENGLISH));
+ private static OperatingSystemMXBean os = ManagementFactory.getOperatingSystemMXBean();
+ protected static boolean showMemoryPools = false;
+
+ public static String getMdSalVersion(String def) {
+ return getMdSalVersion("", def);
+ }
+ public static String getYangToolsVersion(String def) {
+ return getYangToolsVersion("", def);
+ }
+
+ public static String getMdSalVersion(String baseOdlDirectory,String def) {
+ return getFeatureVersionByFolder(baseOdlDirectory,"system/org/opendaylight/mdsal/mdsal-binding-api/",def);
+ }
+ public static String getYangToolsVersion(String baseOdlDirectory,String def) {
+ return getFeatureVersionByFolder(baseOdlDirectory,"system/org/opendaylight/yangtools/odl-yangtools-common/",def);
+ }
+ private static String getFeatureVersionByFolder(String baseOdlDirectory,String dir,String def) {
+ final String regex = "^[0-9]+\\.[0-9]+\\.[0-9]+(-SNAPSHOT)?$";
+ Stream<Path> entries=null;
+ try {
+ if(baseOdlDirectory!=null && baseOdlDirectory.length()>0 && !baseOdlDirectory.endsWith("/")) {
+ baseOdlDirectory+="/";
+ }
+ entries = Files.list(new File(baseOdlDirectory+dir).toPath());
+ } catch (IOException e) {
+
+ }
+ if(entries==null) {
+ return def;
+ }
+ final Pattern pattern = Pattern.compile(regex);
+
+ Iterator<Path> it = entries.iterator();
+ Path p;File f;
+ while(it.hasNext()) {
+ p = it.next();
+ f=p.toFile();
+ if(f.isDirectory()) {
+ final Matcher matcher = pattern.matcher(f.getName().toString());
+ if(matcher.find()) {
+ def= matcher.group(0);
+ break;
+ }
+ }
+ }
+ entries.close();
+ return def;
+ }
+ public static String get() throws Exception {
+ StringBuilder sb = new StringBuilder();
+ int maxNameLen;
+
+ RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean();
+ ThreadMXBean threads = ManagementFactory.getThreadMXBean();
+ MemoryMXBean mem = ManagementFactory.getMemoryMXBean();
+ ClassLoadingMXBean cl = ManagementFactory.getClassLoadingMXBean();
+
+ //
+ // print Karaf informations
+ //
+ maxNameLen = 25;
+ sb.append("Karaf\n");
+ printValue(sb, "Karaf version", maxNameLen, System.getProperty("karaf.version"));
+ printValue(sb, "Karaf home", maxNameLen, System.getProperty("karaf.home"));
+ printValue(sb, "Karaf base", maxNameLen, System.getProperty("karaf.base"));
+ String osgi = getOsgiFramework();
+ if (osgi != null) {
+ printValue(sb, "OSGi Framework", maxNameLen, osgi);
+ }
+
+ sb.append("JVM\n");
+ printValue(sb, "Java Virtual Machine", maxNameLen, runtime.getVmName() + " version " + runtime.getVmVersion());
+ printValue(sb, "Version", maxNameLen, System.getProperty("java.version"));
+ printValue(sb, "Vendor", maxNameLen, runtime.getVmVendor());
+ printValue(sb, "Pid", maxNameLen, getPid());
+ printValue(sb, "Uptime", maxNameLen, printDuration(runtime.getUptime()));
+ try {
+ Class<?> sunOS = Class.forName("com.sun.management.OperatingSystemMXBean");
+ printValue(sb, "Process CPU time", maxNameLen,
+ printDuration(getValueAsLong(sunOS, "getProcessCpuTime") / 1000000.0));
+ printValue(sb, "Process CPU load", maxNameLen, fmtDec.format(getValueAsDouble(sunOS, "getProcessCpuLoad")));
+ printValue(sb, "System CPU load", maxNameLen, fmtDec.format(getValueAsDouble(sunOS, "getSystemCpuLoad")));
+ } catch (Throwable t) {
+ }
+ try {
+ Class<?> unixOS = Class.forName("com.sun.management.UnixOperatingSystemMXBean");
+ printValue(sb, "Open file descriptors", maxNameLen,
+ printLong(getValueAsLong(unixOS, "getOpenFileDescriptorCount")));
+ printValue(sb, "Max file descriptors", maxNameLen,
+ printLong(getValueAsLong(unixOS, "getMaxFileDescriptorCount")));
+ } catch (Throwable t) {
+ }
+ printValue(sb, "Total compile time", maxNameLen,
+ printDuration(ManagementFactory.getCompilationMXBean().getTotalCompilationTime()));
+
+ sb.append("Threads\n");
+ printValue(sb, "Live threads", maxNameLen, Integer.toString(threads.getThreadCount()));
+ printValue(sb, "Daemon threads", maxNameLen, Integer.toString(threads.getDaemonThreadCount()));
+ printValue(sb, "Peak", maxNameLen, Integer.toString(threads.getPeakThreadCount()));
+ printValue(sb, "Total started", maxNameLen, Long.toString(threads.getTotalStartedThreadCount()));
+
+ sb.append("Memory\n");
+ printValue(sb, "Current heap size", maxNameLen, printSizeInKb(mem.getHeapMemoryUsage().getUsed()));
+ printValue(sb, "Maximum heap size", maxNameLen, printSizeInKb(mem.getHeapMemoryUsage().getMax()));
+ printValue(sb, "Committed heap size", maxNameLen, printSizeInKb(mem.getHeapMemoryUsage().getCommitted()));
+ printValue(sb, "Pending objects", maxNameLen, Integer.toString(mem.getObjectPendingFinalizationCount()));
+ for (GarbageCollectorMXBean gc : ManagementFactory.getGarbageCollectorMXBeans()) {
+ String val = "Name = '" + gc.getName() + "', Collections = " + gc.getCollectionCount() + ", Time = "
+ + printDuration(gc.getCollectionTime());
+ printValue(sb, "Garbage collector", maxNameLen, val);
+ }
+
+ if (showMemoryPools) {
+ List<MemoryPoolMXBean> memoryPools = ManagementFactory.getMemoryPoolMXBeans();
+ sb.append("Memory Pools\n");
+ printValue(sb, "Total Memory Pools", maxNameLen, printLong(memoryPools.size()));
+ String spaces4 = " ";
+ for (MemoryPoolMXBean pool : memoryPools) {
+ String name = pool.getName();
+ MemoryType type = pool.getType();
+ printValue(sb, spaces4 + "Pool (" + type + ")", maxNameLen, name);
+
+ // PeakUsage/CurrentUsage
+ MemoryUsage peakUsage = pool.getPeakUsage();
+ MemoryUsage usage = pool.getUsage();
+
+ if (usage != null && peakUsage != null) {
+ long init = peakUsage.getInit();
+ long used = peakUsage.getUsed();
+ long committed = peakUsage.getCommitted();
+ long max = peakUsage.getMax();
+ sb.append(spaces4 + spaces4 + "Peak Usage\n");
+ printValue(sb, spaces4 + spaces4 + spaces4 + "init", maxNameLen, printLong(init));
+ printValue(sb, spaces4 + spaces4 + spaces4 + "used", maxNameLen, printLong(used));
+ printValue(sb, spaces4 + spaces4 + spaces4 + "committed", maxNameLen, printLong(committed));
+ printValue(sb, spaces4 + spaces4 + spaces4 + "max", maxNameLen, printLong(max));
+
+ init = usage.getInit();
+ used = usage.getUsed();
+ committed = usage.getCommitted();
+ max = usage.getMax();
+ sb.append(spaces4 + spaces4 + "Current Usage\n");
+ printValue(sb, spaces4 + spaces4 + spaces4 + "init", maxNameLen, printLong(init));
+ printValue(sb, spaces4 + spaces4 + spaces4 + "used", maxNameLen, printLong(used));
+ printValue(sb, spaces4 + spaces4 + spaces4 + "committed", maxNameLen, printLong(committed));
+ printValue(sb, spaces4 + spaces4 + spaces4 + "max", maxNameLen, printLong(max));
+ }
+ }
+ }
+
+ sb.append("Classes\n");
+ printValue(sb, "Current classes loaded", maxNameLen, printLong(cl.getLoadedClassCount()));
+ printValue(sb, "Total classes loaded", maxNameLen, printLong(cl.getTotalLoadedClassCount()));
+ printValue(sb, "Total classes unloaded", maxNameLen, printLong(cl.getUnloadedClassCount()));
+
+ sb.append("Operating system\n");
+ printValue(sb, "Name", maxNameLen, os.getName() + " version " + os.getVersion());
+ printValue(sb, "Architecture", maxNameLen, os.getArch());
+ printValue(sb, "Processors", maxNameLen, Integer.toString(os.getAvailableProcessors()));
+ try {
+ printValue(sb, "Total physical memory", maxNameLen,
+ printSizeInKb(getSunOsValueAsLong(os, "getTotalPhysicalMemorySize")));
+ printValue(sb, "Free physical memory", maxNameLen,
+ printSizeInKb(getSunOsValueAsLong(os, "getFreePhysicalMemorySize")));
+ printValue(sb, "Committed virtual memory", maxNameLen,
+ printSizeInKb(getSunOsValueAsLong(os, "getCommittedVirtualMemorySize")));
+ printValue(sb, "Total swap space", maxNameLen,
+ printSizeInKb(getSunOsValueAsLong(os, "getTotalSwapSpaceSize")));
+ printValue(sb, "Free swap space", maxNameLen,
+ printSizeInKb(getSunOsValueAsLong(os, "getFreeSwapSpaceSize")));
+ } catch (Throwable t) {
+ }
+ return sb.toString();
+ }
+
+ private static String getPid() {
+ // In Java 9 the new process API can be used:
+ // long pid = ProcessHandle.current().getPid();
+ String name = ManagementFactory.getRuntimeMXBean().getName();
+ String[] parts = name.split("@");
+ return parts[0];
+ }
+
+ private static long getSunOsValueAsLong(OperatingSystemMXBean os, String name) throws Exception {
+ Method mth = os.getClass().getMethod(name);
+ return (Long) mth.invoke(os);
+ }
+
+ private static long getValueAsLong(Class<?> osImpl, String name) throws Exception {
+ if (osImpl.isInstance(os)) {
+ Method mth = osImpl.getMethod(name);
+ return (Long) mth.invoke(os);
+ }
+ return -1;
+ }
+
+ private static double getValueAsDouble(Class<?> osImpl, String name) throws Exception {
+ if (osImpl.isInstance(os)) {
+ Method mth = osImpl.getMethod(name);
+ return (Double) mth.invoke(os);
+ }
+ return -1;
+ }
+
+ private static String printLong(long i) {
+ return fmtI.format(i);
+ }
+
+ private static String printSizeInKb(double size) {
+ return fmtI.format((long) (size / 1024)) + " kbytes";
+ }
+
+ protected static String printDuration(double uptime) {
+ uptime /= 1000;
+ if (uptime < 60) {
+ return fmtD.format(uptime) + " seconds";
+ }
+ uptime /= 60;
+ if (uptime < 60) {
+ long minutes = (long) uptime;
+ String s = fmtI.format(minutes) + (minutes > 1 ? " minutes" : " minute");
+ return s;
+ }
+ uptime /= 60;
+ if (uptime < 24) {
+ long hours = (long) uptime;
+ long minutes = (long) ((uptime - hours) * 60);
+ String s = fmtI.format(hours) + (hours > 1 ? " hours" : " hour");
+ if (minutes != 0) {
+ s += " " + fmtI.format(minutes) + (minutes > 1 ? " minutes" : " minute");
+ }
+ return s;
+ }
+ uptime /= 24;
+ long days = (long) uptime;
+ long hours = (long) ((uptime - days) * 24);
+ String s = fmtI.format(days) + (days > 1 ? " days" : " day");
+ if (hours != 0) {
+ s += " " + fmtI.format(hours) + (hours > 1 ? " hours" : " hour");
+ }
+ return s;
+ }
+
+ static void printSysValue(StringBuilder sb, String prop, int pad) {
+ printValue(sb, prop, pad, System.getProperty(prop));
+ }
+
+ static void printValue(StringBuilder sb, String name, int pad, String value) {
+ sb.append(" " + // SimpleAnsi.INTENSITY_BOLD +
+ name + // SimpleAnsi.INTENSITY_NORMAL +
+ spaces(pad - name.length()) + " " + value + "\n");
+ }
+
+ static String spaces(int nb) {
+ StringBuilder sb = new StringBuilder();
+ for (int i = 0; i < nb; i++) {
+ sb.append(' ');
+ }
+ return sb.toString();
+ }
+
+ static String getOsgiFramework() {
+ try {
+ Callable<String> call = new Callable<String>() {
+ @Override
+ public String call() throws Exception {
+ BundleContext context = FrameworkUtil.getBundle(getClass()).getBundleContext();
+ Bundle sysBundle = context.getBundle(0);
+ return sysBundle.getSymbolicName() + "-" + sysBundle.getVersion();
+ }
+ };
+ return call.call();
+ } catch (Throwable t) {
+ // We're not in OSGi, just safely return null
+ return null;
+ }
+ }
+}
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/YangFileProvider.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/YangFileProvider.java
new file mode 100644
index 0000000..5e0c470
--- /dev/null
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/YangFileProvider.java
@@ -0,0 +1,206 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
+ * =================================================================================================
+ * 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.
+ * ============LICENSE_END==========================================================================
+ ******************************************************************************/
+package org.onap.ccsdk.features.sdnr.wt.dataprovider.data;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FilenameFilter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.nio.file.Path;
+import java.text.ParseException;
+import java.util.ArrayList;
+import java.util.Comparator;
+import java.util.Date;
+import java.util.List;
+
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class YangFileProvider {
+
+ private static final Logger LOG = LoggerFactory.getLogger(YangFileProvider.class);
+
+ private static final FilenameFilter yangFilenameFilter = new FilenameFilter() {
+
+ @Override
+ public boolean accept(File dir, String name) {
+ return name.toLowerCase().endsWith(".yang");
+ }
+ };
+
+ private static final int BUFFER_SIZE = 1024;
+
+ private final Path mainSourcePath;
+ private final List<Path> additionalSources;
+
+ public YangFileProvider(String path) {
+ this.mainSourcePath = new File(path).toPath();
+ this.additionalSources = new ArrayList<>();
+ }
+
+ public boolean hasFileForModule(String module, String version) {
+ return this.mainSourcePath.resolve(YangFilename.createFilename(module, version)).toFile().exists();
+ }
+
+ public boolean hasFileForModule(String module) {
+ return this.findYangFiles(module).size() > 0;
+ }
+
+ private List<YangFilename> findYangFiles(String module) {
+ List<YangFilename> list = new ArrayList<>();
+ String[] files = this.mainSourcePath.toFile().list(yangFilenameFilter);
+ YangFilename yangfile;
+ for (String file : files) {
+ files = this.mainSourcePath.toFile().list(yangFilenameFilter);
+ for (String fn : files) {
+ try {
+ yangfile = new YangFilename(this.mainSourcePath.resolve(fn).toString());
+ if (yangfile.getModule().equals(module)) {
+ list.add(yangfile);
+ }
+ } catch (ParseException e) {
+ LOG.warn("unable to handle yangfile {}: {}", file, e);
+ }
+ }
+ }
+ for (Path addPath : this.additionalSources) {
+ files = addPath.toFile().list(yangFilenameFilter);
+ for (String file : files) {
+ try {
+ yangfile = new YangFilename(addPath.resolve(file).toString());
+ if (yangfile.getModule().equals(module)) {
+ list.add(yangfile);
+ }
+ } catch (ParseException e) {
+ LOG.warn("unable to handle yangfile {}: {}", file, e);
+ }
+ }
+ }
+ return list;
+ }
+
+ /**
+ * get yang file from source with specified version or least newer one if
+ * version is null then the latest one
+ *
+ * @param module
+ * @param version
+ * @return
+ * @throws ParseException
+ */
+ private @Nullable YangFilename getYangFile(@Nonnull String module, @Nullable String version) throws ParseException {
+ YangFilename f = null;
+ List<YangFilename> list = this.findYangFiles(module);
+
+ list.sort(SortByDateAscComparator.getInstance());
+
+ // find specific version or nearest oldest
+ if (version != null) {
+ Date rev = YangFilename.parseRevision(version);
+ for (YangFilename item : list) {
+ if (rev.equals(item.getRevision())) {
+ f = item;
+ break;
+ }
+ if (item.getRevision().after(rev)) {
+ f = item;
+ break;
+ }
+ }
+ }
+ // get latest
+ else {
+ f = list.get(list.size() - 1);
+ }
+ return f;
+ }
+
+ /**
+ * write filestream directly to output stream easier for http handling
+ *
+ * @param module
+ * @param version
+ * @param outputStream
+ * @return
+ * @throws IOException
+ * @throws ParseException
+ */
+ public int writeOutput(@Nonnull String module, @Nullable String version, @Nonnull OutputStream outputStream)
+ throws IOException, ParseException {
+ YangFilename fn = this.getYangFile(module, version);
+ if(fn==null) {
+ return 0;
+ }
+ byte[] buffer = new byte[BUFFER_SIZE];
+ int bytesRead = -1;
+ int sumlen = 0;
+ InputStream inputStream = null ;
+ try {
+ inputStream= new FileInputStream(fn.getFilename());
+
+ while ((bytesRead = inputStream.read(buffer)) != -1) {
+ outputStream.write(buffer, 0, bytesRead);
+ sumlen += bytesRead;
+ }}
+ catch(IOException e) {
+ LOG.warn("problem sending {}: {}",fn.getFilename(),e);
+ }
+ finally {
+ if(inputStream!=null) {
+ inputStream.close();
+ }
+ }
+ return sumlen;
+ }
+
+ private static class SortByDateAscComparator implements Comparator<YangFilename> {
+
+ private static SortByDateAscComparator instance;
+
+ @Override
+ public int compare(YangFilename o1, YangFilename o2) {
+ return o1.getRevision().compareTo(o2.getRevision());
+ }
+
+ public static Comparator<YangFilename> getInstance() {
+ if (instance == null) {
+ instance = new SortByDateAscComparator();
+ }
+ return instance;
+ }
+
+ }
+
+ public YangFilename getFileForModule(String module, String rev) throws ParseException {
+ return this.getYangFile(module, rev);
+ }
+
+ public YangFilename getFileForModule(String module) throws ParseException {
+ return this.getFileForModule(module, null);
+ }
+
+ public boolean hasFileOrNewerForModule(String module, String version) throws ParseException {
+ return this.getYangFile(module, version) != null;
+ }
+
+}
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/YangFilename.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/YangFilename.java
new file mode 100644
index 0000000..d46f5d5
--- /dev/null
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/YangFilename.java
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
+ * =================================================================================================
+ * 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.
+ * ============LICENSE_END==========================================================================
+ ******************************************************************************/
+package org.onap.ccsdk.features.sdnr.wt.dataprovider.data;
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class YangFilename {
+
+ private static final String REGEX = "([^\\/]*)@([0-9]{4}-[0-9]{2}-[0-9]{2}).yang";
+ private static final Pattern pattern = Pattern.compile(REGEX, Pattern.MULTILINE);
+ private final String filename;
+ private final Matcher matcher;
+ private Date revision;
+ private String module;
+ public static Date parseRevision(String sRevision) throws ParseException {
+ final SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd");
+ return fmt.parse(sRevision);
+ }
+ public YangFilename(String fn) throws ParseException {
+ this.filename = fn;
+ matcher = pattern.matcher(this.filename);
+ if(!matcher.find()) {
+ throw new ParseException("unknown filename format", 0);
+ }
+ this.module= matcher.group(1);
+ this.revision=parseRevision(matcher.group(2));
+
+ }
+ public static String createFilename(String module, String rev) {
+ return String.format("%s@%s.yang", module,rev);
+ }
+ public YangFilename(String module, String rev) throws ParseException {
+ this(createFilename(module, rev));
+ }
+ public String getFilename() {
+ return this.filename;
+ }
+ public Date getRevision() {
+ return this.revision;
+ }
+ public String getModule() {
+ return this.module;
+ }
+}
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/EsDataObjectReaderWriter.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/EsDataObjectReaderWriter.java
new file mode 100644
index 0000000..b119b80
--- /dev/null
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/EsDataObjectReaderWriter.java
@@ -0,0 +1,339 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
+ * =================================================================================================
+ * 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.
+ * ============LICENSE_END==========================================================================
+ ******************************************************************************/
+package org.onap.ccsdk.features.sdnr.wt.dataprovider.database;
+
+import java.io.IOException;
+import java.lang.reflect.Field;
+import java.util.List;
+
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
+import org.onap.ccsdk.features.sdnr.wt.common.database.DatabaseClient;
+import org.onap.ccsdk.features.sdnr.wt.common.database.SearchHit;
+import org.onap.ccsdk.features.sdnr.wt.common.database.SearchResult;
+import org.onap.ccsdk.features.sdnr.wt.common.database.queries.QueryBuilder;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.yangtools.YangToolsMapper;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.Entity;
+import org.opendaylight.yangtools.concepts.Builder;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+
+/**
+ * Class to rw yang-tool generated objects into elasticsearch database. For "ES _id" exchange the esIdAddAtributteName is used.
+ * This attribute mast be of type String and contains for read and write operations the object id.
+ * The function can be used without id handling.
+ * If id handling is required the parameter needs to be specified by class definition in yang and setting the name by using setAttributeName()
+ *
+ * @param <T> Yang tools generated class object.
+ */
+public class EsDataObjectReaderWriter<T extends DataObject> {
+
+ private final Logger LOG = LoggerFactory.getLogger(EsDataObjectReaderWriter.class);
+
+ /** Typename for elastic search data schema **/
+ private String dataTypeName;
+
+ /** Elasticsearch Database client to be used **/
+ private DatabaseClient db;
+
+ /** Mapper with configuration to use opendaylight yang-tools builder pattern for object creation **/
+ private YangToolsMapper yangtoolsMapper;
+
+ /** Class of T as attribute to allow JSON to Class object mapping **/
+ private Class<T> clazz;
+
+ /** Field is used to write id. If null no id handling **/
+ private @Nullable Field field;
+
+ /** Attribute that is used as id field for the database object **/
+ private @Nullable String esIdAddAtributteName;
+
+ /** Interface to be used for write operations. Rule for write: T extends S and **/
+ private Class<? extends DataObject> writeInterfaceClazz; // == "S"
+
+ /**
+ * Elasticsearch database read and write for specific class, defined by opendaylight yang-tools.
+ *
+ * @param db Database access client
+ * @param dataTypeName typename in database schema
+ * @param clazz class of type to be handled
+ * @throws ClassNotFoundException
+ */
+ public EsDataObjectReaderWriter(DatabaseClient db, Entity dataTypeName, Class<T> clazz) throws ClassNotFoundException {
+ this(db, dataTypeName.getName(), clazz);
+ }
+ public EsDataObjectReaderWriter(DatabaseClient db, String dataTypeName, Class<T> clazz) throws ClassNotFoundException {
+ LOG.info("Create {} for datatype {} class {}", this.getClass().getName(), dataTypeName, clazz.getName());
+
+ this.esIdAddAtributteName = null;
+ this.field = null;
+ this.writeInterfaceClazz = clazz;
+ this.db = db;
+ this.dataTypeName = dataTypeName;
+ this.yangtoolsMapper = new YangToolsMapper();
+ //this.yangtoolsMapper.assertBuilderClass(clazz);
+ this.clazz = clazz;
+//
+// if (! db.isExistsIndex(dataTypeName)) {
+// throw new IllegalArgumentException("Index "+dataTypeName+" not existing.");
+// }
+ }
+
+ public String getDataTypeName() {
+ return dataTypeName;
+ }
+ public Class<T> getClazz() {
+ return clazz;
+ }
+ /**
+ * Simlar to {@link #setEsIdAttributeName()}, but adapts the parameter to yangtools attribute naming schema
+ * @param esIdAttributeName is converted to UnderscoreCamelCase
+ * @return this for further operations.
+ */
+ public EsDataObjectReaderWriter<T> setEsIdAttributeNameCamelized(String esIdAttributeName) {
+ return setEsIdAttributeName(YangToolsMapper.toCamelCaseAttributeName(esIdAttributeName));
+ }
+
+ /**
+ * Attribute name of class that is containing the object id
+ * @param esIdAttributeName of the implementation class for the yangtools interface.
+ * Expected attribute name format is CamelCase with leading underline. @
+ * @return this for further operations.
+ * @throws SecurityException if no access or IllegalArgumentException if wrong type or no attribute with this name.
+ */
+ public EsDataObjectReaderWriter<T> setEsIdAttributeName(String esIdAttributeName) {
+ LOG.debug("Set attribute '{}'", esIdAttributeName);
+ this.esIdAddAtributteName = null; // Reset status
+ this.field = null;
+
+ Field attributeField;
+ try {
+ Builder<T> builder = yangtoolsMapper.getBuilder(clazz);
+ T object = builder.build();
+ attributeField = object.getClass().getDeclaredField(esIdAttributeName);
+ if (attributeField.getType().equals(String.class)) {
+ attributeField.setAccessible(true);
+ this.esIdAddAtributteName = esIdAttributeName; //Set new status if everything OK
+ this.field = attributeField;
+ } else {
+ String msg = "Wrong field type " + attributeField.getType().getName() + " of " + esIdAttributeName;
+ LOG.debug(msg);
+ throw new IllegalArgumentException(msg);
+ }
+ } catch (NoSuchFieldException e) {
+ // Convert to run-time exception
+ String msg = "NoSuchFieldException for '" + esIdAttributeName + "' in class " + clazz.getName();
+ LOG.debug(msg);
+ throw new IllegalArgumentException(msg);
+ } catch (SecurityException e) {
+ LOG.debug("Access problem "+esIdAttributeName,e);
+ throw e;
+ }
+ return this;
+ }
+
+ /**
+ * Specify subclass of T for write operations.
+ * @param writeInterfaceClazz
+ */
+ public EsDataObjectReaderWriter<T> setWriteInterface( @Nonnull Class<? extends DataObject> writeInterfaceClazz ) {
+ LOG.debug("Set write interface to {}", writeInterfaceClazz);
+ if (writeInterfaceClazz == null)
+ throw new IllegalArgumentException("Null not allowed here.");
+
+ this.writeInterfaceClazz = writeInterfaceClazz;
+ return this;
+ }
+
+ /**
+ * Write child object to database with specific id
+ * @param object
+ * @param @Nullable esId use the id or if null generate unique id
+ * @return String with id or null
+ */
+ public @Nullable <S extends DataObject> String write(S object, @Nullable String esId) {
+ if (writeInterfaceClazz.isInstance(object)) {
+ try {
+ String json = yangtoolsMapper.writeValueAsString(object);
+ return db.doWriteRaw(dataTypeName, esId, json);
+ } catch (JsonProcessingException e) {
+ LOG.error("Write problem: ", e);
+ }
+ } else {
+ LOG.error("Type {} does not provide interface {}", object!=null?object.getClass().getName():"null",
+ writeInterfaceClazz.getName());
+ }
+ return null;
+ }
+ /**
+ * Update partial child object to database with match/term query
+ * @param object
+ * @param esId
+ * @return String with esId or null
+ */
+ public @Nullable <S extends DataObject> String update(S object, QueryBuilder query) {
+ if (writeInterfaceClazz.isInstance(object)) {
+ try {
+ String json = yangtoolsMapper.writeValueAsString(object);
+ return db.doUpdate(this.dataTypeName,json,query);
+ } catch (JsonProcessingException e) {
+ LOG.error("Update problem: ", e);
+ }
+ } else {
+ LOG.error("Type {} does not provide interface {}", object!=null?object.getClass().getName():"null",
+ writeInterfaceClazz.getName());
+ }
+ return null;
+ }
+ /**
+ * Write/ update partial child object to database with specific id Write if not
+ * exists, else update
+ * @param object
+ * @param esId
+ * @return String with esId or null
+ */
+ public @Nullable <S extends DataObject> String update(S object, String esId) {
+ return this.update(object, esId,null);
+ }
+ public @Nullable <S extends DataObject> String update(S object, String esId,List<String> onylForInsert) {
+ if (writeInterfaceClazz.isInstance(object)) {
+ try {
+ String json = yangtoolsMapper.writeValueAsString(object);
+ return db.doUpdateOrCreate(dataTypeName, esId, json,onylForInsert);
+ } catch (JsonProcessingException e) {
+ LOG.error("Update problem: ", e);
+ }
+ } else {
+ LOG.error("Type {} does not provide interface {}", object!=null?object.getClass().getName():"null",
+ writeInterfaceClazz.getName());
+ }
+ return null;
+ }
+
+ /**
+ * Read object from database, by using the id field
+ * @param object
+ * @return
+ */
+ public @Nullable T read(String esId) {
+ @Nullable T res = (T)null;
+ if (esId != null) {
+ String json = db.doReadJsonData(dataTypeName, esId);
+ try {
+ res = yangtoolsMapper.readValue(json.getBytes(), clazz);
+ } catch (IOException e) {
+ LOG.error("Problem: ", e);
+ }
+ }
+ return res;
+ }
+
+ /**
+ * Remove object
+ * @param esId to identify the object.
+ * @return success
+ */
+ public boolean remove(String esId) {
+ return db.doRemove(this.dataTypeName, esId);
+ }
+
+ public int remove(QueryBuilder query) {
+ return this.db.doRemove(this.dataTypeName, query);
+ }
+ /**
+ * Get all elements of related type
+ * @return all Elements
+ */
+ public SearchResult<T> doReadAll() {
+ return doReadAll(null);
+ }
+ public SearchResult<T> doReadAll(QueryBuilder query) {
+ return this.doReadAll(query,false);
+ }
+ /**
+ * Read all existing objects of a type
+ * @param query for the elements
+ * @return the list of all objects
+ */
+
+ public SearchResult<T> doReadAll(QueryBuilder query, boolean ignoreException) {
+
+ SearchResult<T> res = new SearchResult<T>();
+ int idx = 0; //Idx for getAll
+ int iterateLength = 100; //Step width for iterate
+
+ SearchResult<SearchHit> result;
+ List<SearchHit> hits;
+ do {
+ if(query!=null) {
+ LOG.debug("read data in {} with query {}",dataTypeName,query.toJSON());
+ result=db.doReadByQueryJsonData( dataTypeName, query,ignoreException);
+ }
+ else {
+ result = db.doReadAllJsonData(dataTypeName,ignoreException);
+ }
+ hits=result.getHits();
+ LOG.debug("Read: {} elements: {} Failures: {}",dataTypeName,hits.size(), yangtoolsMapper.getMappingFailures());
+
+ T object;
+ idx += result.getHits().size();
+ for (SearchHit hit : hits) {
+ object = getT(hit.getSourceAsString());
+ LOG.debug("Mapp Object: {}\nSource: '{}'\nResult: '{}'\n Failures: {}", hit.getId(),
+ hit.getSourceAsString(), object, yangtoolsMapper.getMappingFailures());
+ if (object != null) {
+ setEsId(object, hit.getId());
+ res.add(object);
+ } else {
+ LOG.warn("Mapp result null Object: {}\n Source: '{}'\n : '", hit.getId(), hit.getSourceAsString());
+ }
+ }
+
+ } while (hits.size() == iterateLength); // Do it until end indicated, because less hits than iterateLength
+ // allows.
+ res.setTotal(result.getTotal());
+ return res;
+ }
+
+ /* ---------------------------------------------
+ * Private functions
+ */
+
+ private void setEsId(T object, String esId) {
+ if (field != null) {
+ try {
+ field.set(object, esId);
+ } catch (IllegalArgumentException | IllegalAccessException e) {
+ LOG.debug("Field set problem.", e); }
+ }
+ }
+
+ private @Nullable T getT(String jsonString) {
+ try {
+ return yangtoolsMapper.readValue( jsonString, clazz );
+ } catch (IOException e) {
+ LOG.info("Mapping problem", e);
+ return (T)null;
+ }
+ }
+
+}
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/EsDataObjectReaderWriter2.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/EsDataObjectReaderWriter2.java
new file mode 100644
index 0000000..d097d82
--- /dev/null
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/EsDataObjectReaderWriter2.java
@@ -0,0 +1,361 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
+ * =================================================================================================
+ * 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.
+ * ============LICENSE_END==========================================================================
+ ******************************************************************************/
+package org.onap.ccsdk.features.sdnr.wt.dataprovider.database;
+
+import java.io.IOException;
+import java.lang.reflect.Field;
+import java.util.List;
+
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
+import org.eclipse.jdt.annotation.NonNull;
+import org.onap.ccsdk.features.sdnr.wt.common.database.DatabaseClient;
+import org.onap.ccsdk.features.sdnr.wt.common.database.SearchHit;
+import org.onap.ccsdk.features.sdnr.wt.common.database.SearchResult;
+import org.onap.ccsdk.features.sdnr.wt.common.database.queries.QueryBuilder;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.yangtools.YangToolsMapper;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.yangtools.YangToolsMapper2;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.Entity;
+import org.opendaylight.yangtools.concepts.Builder;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+
+/**
+ * Class to rw yang-tool generated objects into elasticsearch database. For "ES _id" exchange the esIdAddAtributteName is used.
+ * This attribute mast be of type String and contains for read and write operations the object id.
+ * The function can be used without id handling.
+ * If id handling is required the parameter needs to be specified by class definition in yang and setting the name by using setAttributeName()
+ *
+ * Due to using Jackson base interfaces the org.eclipse.jdt.annotation.NonNull needs to be used here to get rid of warnings
+ *
+ * @param <T> Yang tools generated class object.
+ */
+public class EsDataObjectReaderWriter2<T extends DataObject> {
+
+ private final Logger LOG = LoggerFactory.getLogger(EsDataObjectReaderWriter2.class);
+
+ /** Typename for elastic search data schema **/
+ private String dataTypeName;
+
+ /** Elasticsearch Database client to be used **/
+ private DatabaseClient db;
+
+ /** Mapper with configuration to use opendaylight yang-tools builder pattern for object creation **/
+ private YangToolsMapper2<T> yangtoolsMapper;
+
+ /** Class of T as attribute to allow JSON to Class object mapping **/
+ private Class<T> clazz;
+
+ /** Field is used to write id. If null no id handling **/
+ private @Nullable Field field;
+
+ /** Attribute that is used as id field for the database object **/
+ private @Nullable String esIdAddAtributteName;
+
+ /** Interface to be used for write operations. Rule for write: T extends S and **/
+ private Class<? extends DataObject> writeInterfaceClazz; // == "S"
+
+ /**
+ * Elasticsearch database read and write for specific class, defined by opendaylight yang-tools.
+ *
+ * @param db Database access client
+ * @param dataTypeName typename in database schema
+ * @param clazz class of type to be handled
+ * @throws ClassNotFoundException
+ */
+ public <X extends T, @NonNull B extends Builder<X>> EsDataObjectReaderWriter2(DatabaseClient db, Entity dataTypeName, @Nonnull Class<T> clazz, @Nullable Class<B> builderClazz) throws ClassNotFoundException {
+ this(db, dataTypeName.getName(), clazz, builderClazz);
+ }
+ public <X extends T, @NonNull B extends Builder<X>> EsDataObjectReaderWriter2(DatabaseClient db, Entity dataTypeName, @Nonnull Class<T> clazz) throws ClassNotFoundException {
+ this(db, dataTypeName.getName(), clazz, null);
+ }
+ public <X extends T, @NonNull B extends Builder<X>> EsDataObjectReaderWriter2(DatabaseClient db, String dataTypeName, @Nonnull Class<T> clazz, @Nullable Class<B> builderClazz) throws ClassNotFoundException {
+ LOG.info("Create {} for datatype {} class {}", this.getClass().getName(), dataTypeName, clazz.getName());
+
+ this.esIdAddAtributteName = null;
+ this.field = null;
+ this.writeInterfaceClazz = clazz;
+ this.db = db;
+ this.dataTypeName = dataTypeName;
+ this.yangtoolsMapper = new YangToolsMapper2<>(clazz, builderClazz);
+ this.clazz = clazz;
+ }
+
+ /**
+ * Simlar to {@link #setEsIdAttributeName()}, but adapts the parameter to yangtools attribute naming schema
+ * @param esIdAttributeName is converted to UnderscoreCamelCase
+ * @return this for further operations.
+ */
+ public EsDataObjectReaderWriter2<T> setEsIdAttributeNameCamelized(String esIdAttributeName) {
+ return setEsIdAttributeName(YangToolsMapper.toCamelCaseAttributeName(esIdAttributeName));
+ }
+
+ /**
+ * Attribute name of class that is containing the object id
+ * @param esIdAttributeName of the implementation class for the yangtools interface.
+ * Expected attribute name format is CamelCase with leading underline. @
+ * @return this for further operations.
+ * @throws SecurityException if no access or IllegalArgumentException if wrong type or no attribute with this name.
+ */
+ public EsDataObjectReaderWriter2<T> setEsIdAttributeName(String esIdAttributeName) {
+ LOG.debug("Set attribute '{}'", esIdAttributeName);
+ this.esIdAddAtributteName = null; // Reset status
+ this.field = null;
+
+ Field attributeField;
+ try {
+ Builder<T> builder = yangtoolsMapper.getBuilder(clazz);
+ if (builder == null) {
+ String msg = "No builder for " + clazz;
+ LOG.debug(msg);
+ throw new IllegalArgumentException(msg);
+ } else {
+ T object = builder.build();
+ attributeField = object.getClass().getDeclaredField(esIdAttributeName);
+ if (attributeField.getType().equals(String.class)) {
+ attributeField.setAccessible(true);
+ this.esIdAddAtributteName = esIdAttributeName; // Set new status if everything OK
+ this.field = attributeField;
+ } else {
+ String msg = "Wrong field type " + attributeField.getType().getName() + " of " + esIdAttributeName;
+ LOG.debug(msg);
+ throw new IllegalArgumentException(msg);
+ }
+ }
+ } catch (NoSuchFieldException e) {
+ // Convert to run-time exception
+ String msg = "NoSuchFieldException for '" + esIdAttributeName + "' in class " + clazz.getName();
+ LOG.debug(msg);
+ throw new IllegalArgumentException(msg);
+ } catch (SecurityException e) {
+ LOG.debug("Access problem "+esIdAttributeName,e);
+ throw e;
+ }
+ return this;
+ }
+
+ /**
+ * Specify subclass of T for write operations.
+ * @param writeInterfaceClazz
+ */
+ public EsDataObjectReaderWriter2<T> setWriteInterface( @Nonnull Class<? extends DataObject> writeInterfaceClazz ) {
+ LOG.debug("Set write interface to {}", writeInterfaceClazz);
+ if (writeInterfaceClazz == null) {
+ throw new IllegalArgumentException("Null not allowed here.");
+ }
+
+ this.writeInterfaceClazz = writeInterfaceClazz;
+ return this;
+ }
+
+ public interface IdGetter<S extends DataObject> {
+ String getId(S object);
+ }
+
+ public <S extends DataObject> void write(List<S> objectList, IdGetter<S> idGetter) {
+ for (S object : objectList) {
+ write(object, idGetter.getId(object));
+ }
+ }
+
+ /**
+ * Write child object to database with specific id
+ * @param object to be written
+ * @param esId use the id or if null generate unique id
+ * @return String with id or null
+ */
+ public @Nullable <S extends DataObject> String write( S object, @Nullable String esId) {
+ if (object != null && writeInterfaceClazz.isInstance(object)) {
+ try {
+ String json = yangtoolsMapper.writeValueAsString(object);
+ return db.doWriteRaw(dataTypeName, esId, json);
+ } catch (JsonProcessingException e) {
+ LOG.error("Write problem: ", e);
+ }
+ } else {
+ LOG.error("Type {} does not provide interface {}", object!=null?object.getClass().getName():"null",
+ writeInterfaceClazz.getName());
+ }
+ return null;
+ }
+ /**
+ * Update partial child object to database with match/term query
+ * @param <S> of object
+ * @param object to write
+ * @param query for write of specific attributes
+ * @return json string with new Object
+ */
+ public @Nullable <S extends DataObject> String update(S object, QueryBuilder query) {
+ if (object != null && writeInterfaceClazz.isInstance(object)) {
+ try {
+ String json = yangtoolsMapper.writeValueAsString(object);
+ return db.doUpdate(this.dataTypeName,json,query);
+ } catch (JsonProcessingException e) {
+ LOG.error("Update problem: ", e);
+ }
+ } else {
+ LOG.error("Type {} does not provide interface {}", object!=null?object.getClass().getName():"null",
+ writeInterfaceClazz.getName());
+ }
+ return null;
+ }
+ /**
+ * Write/ update partial child object to database with specific id Write if not
+ * exists, else update
+ * @param object
+ * @param esId
+ * @return String with esId or null
+ */
+ public @Nullable <S extends DataObject> String update(S object, String esId) {
+ return this.updateOrCreate(object, esId,null);
+ }
+ /**
+ * See {@link doUpdateOrCreate(String dataTypeName, String esId, String json, List<String> doNotUpdateField) }
+ */
+ public @Nullable <S extends DataObject> String updateOrCreate(S object, String esId,List<String> onlyForInsert) {
+ if (object != null && writeInterfaceClazz.isInstance(object)) {
+ try {
+ String json = yangtoolsMapper.writeValueAsString(object);
+ return db.doUpdateOrCreate(dataTypeName, esId, json,onlyForInsert);
+ } catch (JsonProcessingException e) {
+ LOG.error("Update problem: ", e);
+ }
+ } else {
+ LOG.error("Type {} does not provide interface {}", object!=null?object.getClass().getName():"null",
+ writeInterfaceClazz.getName());
+ }
+ return null;
+ }
+
+ /**
+ * Read object from database, by using the id field
+ * @param object
+ * @return
+ */
+ public @Nullable T read(String esId) {
+ @Nullable
+ T res = null;
+ if (esId != null) {
+ String json = db.doReadJsonData(dataTypeName, esId);
+ if (json != null) {
+ try {
+ res = yangtoolsMapper.readValue(json.getBytes(), clazz);
+ } catch (IOException e) {
+ LOG.error("Problem: ", e);
+ }
+ } else {
+ LOG.debug("Can not read from DB id {} type {}", esId, dataTypeName);
+ }
+ }
+ return res;
+ }
+
+ /**
+ * Remove object
+ * @param esId to identify the object.
+ * @return success
+ */
+ public boolean remove(String esId) {
+ return db.doRemove(this.dataTypeName, esId);
+ }
+
+ public int remove(QueryBuilder query) {
+ return this.db.doRemove(this.dataTypeName, query);
+ }
+ /**
+ * Get all elements of related type
+ * @return all Elements
+ */
+ public SearchResult<T> doReadAll() {
+ return doReadAll(null);
+ }
+ public SearchResult<T> doReadAll(QueryBuilder query) {
+ return this.doReadAll(query,false);
+ }
+ /**
+ * Read all existing objects of a type
+ * @param query for the elements
+ * @return the list of all objects
+ */
+
+ public SearchResult<T> doReadAll(QueryBuilder query, boolean ignoreException) {
+
+ SearchResult<T> res = new SearchResult<>();
+ int idx = 0; //Idx for getAll
+ int iterateLength = 100; //Step width for iterate
+
+ SearchResult<SearchHit> result;
+ List<SearchHit> hits;
+ do {
+ if(query!=null) {
+ LOG.debug("read data in {} with query {}",dataTypeName,query.toJSON());
+ result=db.doReadByQueryJsonData( dataTypeName, query,ignoreException);
+ }
+ else {
+ result = db.doReadAllJsonData(dataTypeName,ignoreException);
+ }
+ hits=result.getHits();
+ LOG.debug("Read: {} elements: {} Failures: {}",dataTypeName,hits.size(), yangtoolsMapper.getMappingFailures());
+
+ T object;
+ idx += result.getHits().size();
+ for (SearchHit hit : hits) {
+ object = getT(hit.getSourceAsString());
+ LOG.debug("Mapp Object: {}\nSource: '{}'\nResult: '{}'\n Failures: {}", hit.getId(),
+ hit.getSourceAsString(), object, yangtoolsMapper.getMappingFailures());
+ if (object != null) {
+ setEsId(object, hit.getId());
+ res.add(object);
+ } else {
+ LOG.warn("Mapp result null Object: {}\n Source: '{}'\n : '", hit.getId(), hit.getSourceAsString());
+ }
+ }
+
+ } while (hits.size() == iterateLength); // Do it until end indicated, because less hits than iterateLength
+ // allows.
+ res.setTotal(result.getTotal());
+ return res;
+ }
+
+ /* ---------------------------------------------
+ * Private functions
+ */
+
+ private void setEsId(T object, String esId) {
+ if (field != null) {
+ try {
+ field.set(object, esId);
+ } catch (IllegalArgumentException | IllegalAccessException e) {
+ LOG.debug("Field set problem.", e); }
+ }
+ }
+
+ private @Nullable T getT(String jsonString) {
+ try {
+ return yangtoolsMapper.readValue( jsonString, clazz );
+ } catch (IOException e) {
+ LOG.info("Mapping problem", e);
+ return null;
+ }
+ }
+
+}
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/AboutHttpServlet.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/AboutHttpServlet.java
new file mode 100644
index 0000000..6c5ed0d
--- /dev/null
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/AboutHttpServlet.java
@@ -0,0 +1,344 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
+ * =================================================================================================
+ * 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.
+ * ============LICENSE_END==========================================================================
+ ******************************************************************************/
+package org.onap.ccsdk.features.sdnr.wt.dataprovider.http;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.jar.Attributes;
+import java.util.jar.Manifest;
+
+import javax.servlet.ServletException;
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.onap.ccsdk.features.sdnr.wt.common.Resources;
+import org.onap.ccsdk.features.sdnr.wt.common.file.PomFile;
+import org.onap.ccsdk.features.sdnr.wt.common.file.PomPropertiesFile;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.data.ODLVersionLUT;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.data.SystemInfo;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class AboutHttpServlet extends HttpServlet {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ private static final Logger LOG = LoggerFactory.getLogger(AboutHttpServlet.class);
+ private static final String UNKNOWN = "unknown";
+ private static final String METAINF_MAVEN = "/META-INF/maven/";
+ private static final String EXCEPTION_FORMAT_UNABLE_TO_READ_INNER_POMFILE = "unable to read inner pom file: {}";
+
+ private static final String URI_PRE = "/about";
+ private static final String RES_BASEPATH = "about/";
+
+ private static final String PLACEHOLDER_ONAP_RELEASENAME = "{release-name}";
+ private static final String PLACEHOLDER_ONAP_RELEASEVERSION = "{release-version}";
+ private static final String PLACEHOLDER_ODL_RELEASENAME = "{odl-version}";
+ private static final String PLACEHOLDER_BUILD_TIMESTAMP = "{build-time}";
+ private static final String PLACEHOLDER_ODLUX_REVISION = "{odlux-revision}";
+ private static final String PLACEHOLDER_PACKAGE_GITHASH = "{package-githash}";
+ private static final String PLACEHOLDER_PACAKGE_VERSION = "{package-version}";
+ private static final String PLACEHOLDER_CCSDK_VERSION = "{ccsdk-version}";
+ private static final String PLACEHOLDER_CLUSTER_SIZE = "{cluster-size}";
+ private static final String PLACEHOLDER_MDSAL_VERSION = "{mdsal-version}";
+ private static final String PLACEHOLDER_YANGTOOLS_VERSION = "{yangtools-version}";
+ private static final String PLACEHOLDER_KARAF_INFO = "{karaf-info}";
+ private static final String README_FILE = "README.md";
+
+ private final String groupId = "org.onap.ccsdk.features.sdnr.wt";
+ private final String artifactId = "sdnr-wt-data-provider-provider";
+
+ private final Map<String, String> data;
+ private final String readmeContent;
+
+ public AboutHttpServlet() {
+
+ this.data = new HashMap<>();
+ this.collectStaticData();
+ this.readmeContent = this.render(this.getResourceFileContent(README_FILE));
+ }
+
+ /**
+ * collect static versioning data
+ */
+ private void collectStaticData() {
+ PomPropertiesFile props = this.getPomProperties();
+ final String ccsdkVersion = this.getPomParentVersion();
+ this.data.put(PLACEHOLDER_ONAP_RELEASENAME, ODLVersionLUT.getONAPReleaseName(ccsdkVersion, UNKNOWN));
+ this.data.put(PLACEHOLDER_ODL_RELEASENAME, ODLVersionLUT.getOdlVersion(ccsdkVersion, UNKNOWN));
+ this.data.put(PLACEHOLDER_BUILD_TIMESTAMP, props != null ? props.getBuildDate().toString() : "");
+ this.data.put(PLACEHOLDER_ODLUX_REVISION, this.getPomProperty("odlux.buildno"));
+ this.data.put(PLACEHOLDER_PACAKGE_VERSION, this.getManifestValue("Bundle-Version"));
+ this.data.put(PLACEHOLDER_CCSDK_VERSION, ccsdkVersion);
+ this.data.put(PLACEHOLDER_ONAP_RELEASEVERSION, "1.8.1-SNAPSHOT");
+ this.data.put(PLACEHOLDER_MDSAL_VERSION, SystemInfo.getMdSalVersion(UNKNOWN));
+ this.data.put(PLACEHOLDER_YANGTOOLS_VERSION, SystemInfo.getYangToolsVersion(UNKNOWN));
+ this.data.put(PLACEHOLDER_PACKAGE_GITHASH, this.getGitHash(UNKNOWN));
+ }
+
+ @Override
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+
+ String uri = req.getRequestURI().substring(URI_PRE.length());
+ LOG.debug("request for {}", uri);
+ if (uri.length() <= 0 || uri.equals("/")) {
+ // collect data
+ this.collectData();
+ // render readme
+ String content = this.render();
+ byte[] output = content != null ? content.getBytes() : new byte[0];
+ // output
+ resp.setStatus(HttpServletResponse.SC_OK);
+ resp.setContentLength(output.length);
+ resp.setContentType("text/plain");
+ ServletOutputStream os = null;
+ try{
+ os = resp.getOutputStream();
+ os.write(output);
+ }
+ catch(IOException e) {
+ LOG.warn("problem writing response for {}: {}",uri,e);
+ }
+ finally {
+ if(os!=null) {
+ try{
+ os.close();
+ }
+ catch(IOException e) {
+ LOG.warn("problem closing response stream: {}",e);
+ }
+ }
+ }
+
+ } else {
+ this.doGetFile(uri, resp);
+ }
+ }
+
+ /**
+ * load git.commit.id from jar /META-INF/git.properties
+ *
+ * @param def
+ */
+ private String getGitHash(String def) {
+ String content = Resources.getFileContent(AboutHttpServlet.class, "/META-INF/git.properties");
+ if (content == null) {
+ return def;
+ }
+ String lines[] = content.split("\n");
+ for (String line : lines) {
+ if (line.startsWith("git.commit.id")) {
+ def = line.substring("git.commit.id=".length());
+ break;
+ }
+ }
+ return def;
+ }
+
+ private String getResourceFileContent(String filename) {
+ LOG.debug("try ti get content of {}", filename);
+ return Resources.getFileContent(AboutHttpServlet.class, RES_BASEPATH + filename);
+ }
+
+ /**
+ * collect dynamic data for about.md
+ */
+ private void collectData() {
+ LOG.info("collecting dynamic data");
+ try {
+ this.data.put(PLACEHOLDER_KARAF_INFO, SystemInfo.get());
+ } catch (Exception e) {
+ LOG.warn("problem collecting system data: {}", e);
+ }
+ }
+
+ /**
+ * get value for key out of /META-INF/MANIFEST.MF
+ * @param key
+ * @return
+ */
+ private String getManifestValue(String key) {
+ URL url = Resources.getUrlForRessource(AboutHttpServlet.class, "/META-INF/MANIFEST.MF");
+ if (url == null) {
+ return null;
+ }
+ Manifest manifest;
+ try {
+ manifest = new Manifest(url.openStream());
+ Attributes attr = manifest.getMainAttributes();
+ return attr.getValue(key);
+ } catch (IOException e) {
+ LOG.warn("problem reading manifest: {}", e);
+ }
+ return null;
+
+ }
+ /**
+ * get object representation of /META-INF/maven/groupId/artifactId/pom.properties
+ * @return
+ */
+ private PomPropertiesFile getPomProperties() {
+ URL url = Resources.getUrlForRessource(AboutHttpServlet.class,
+ METAINF_MAVEN + groupId + "/" + artifactId + "/pom.properties");
+ PomPropertiesFile propfile;
+ if (url == null) {
+ return null;
+ }
+ try {
+ propfile = new PomPropertiesFile(url.openStream());
+ return propfile;
+ } catch (Exception e) {
+ LOG.warn(EXCEPTION_FORMAT_UNABLE_TO_READ_INNER_POMFILE, e);
+ }
+ return null;
+ }
+ /**
+ * get value for key out of /META-INF/maven/groupId/artifactId/pom.xml in properties section
+ * @param key
+ * @return
+ */
+ private String getPomProperty(String key) {
+ LOG.info("try to get pom property for {}", key);
+ URL url = Resources.getUrlForRessource(AboutHttpServlet.class,
+ METAINF_MAVEN + groupId + "/" + artifactId + "/pom.xml");
+ if (url == null) {
+ return null;
+ }
+ PomFile pomfile;
+ try {
+ pomfile = new PomFile(url.openStream());
+ return pomfile.getProperty(key);
+ } catch (Exception e) {
+ LOG.warn(EXCEPTION_FORMAT_UNABLE_TO_READ_INNER_POMFILE, e);
+ }
+ return null;
+ }
+ /**
+ * get parent pom version out of /META-INF/maven/groupId/artifactId/pom.xml
+ * @return
+ */
+ private String getPomParentVersion() {
+ LOG.info("try to get pom parent version");
+ URL url = Resources.getUrlForRessource(AboutHttpServlet.class,
+ METAINF_MAVEN + groupId + "/" + artifactId + "/pom.xml");
+ if (url == null) {
+ return null;
+ }
+ PomFile pomfile;
+ try {
+ pomfile = new PomFile(url.openStream());
+ return pomfile.getParentVersion();
+ } catch (Exception e) {
+ LOG.warn(EXCEPTION_FORMAT_UNABLE_TO_READ_INNER_POMFILE, e);
+ }
+ return null;
+ }
+
+ /**
+ * get file by uri from resources and write out to response stream
+ * @param uri
+ * @param resp
+ */
+ private void doGetFile(String uri, HttpServletResponse resp) {
+ String content = this.getResourceFileContent(uri);
+ if (content == null) {
+ try {
+ resp.sendError(HttpServletResponse.SC_NOT_FOUND);
+ } catch (IOException e) {
+ LOG.debug("unable to send error response : {}", e);
+ }
+ } else {
+ byte[] data = content.getBytes();
+ resp.setStatus(HttpServletResponse.SC_OK);
+ resp.setContentType(this.getContentType(uri));
+ try {
+ resp.getOutputStream().write(data);
+ } catch (IOException e) {
+ LOG.debug("unable to send data : {}", e);
+ }
+ }
+
+ }
+
+ /**
+ * create http response contentType by filename
+ * @param filename
+ * @return
+ */
+ private String getContentType(String filename) {
+ String ext = filename.substring(filename.lastIndexOf(".") + 1).toLowerCase();
+ switch (ext) {
+ case "jpg":
+ case "jpeg":
+ case "svg":
+ case "png":
+ case "gif":
+ case "bmp":
+ return "image/" + ext;
+ case "json":
+ return "application/json";
+ case "html":
+ case "htm":
+ return "text/html";
+ case "txt":
+ case "md":
+ default:
+ return "text/plain";
+ }
+ }
+
+ /**
+ * render this.readmeContent with this.data
+ * @return
+ */
+ private String render() {
+ return this.render(null);
+ }
+
+ /**
+ * render content with this.data
+ * @param content
+ * @return
+ */
+ private String render(String content) {
+ if (content == null) {
+ content = this.readmeContent;
+ }
+ if (content == null) {
+ return null;
+ }
+ for (Entry<String, String> entry : this.data.entrySet()) {
+ if (entry.getValue() != null && content.contains(entry.getKey())) {
+ content = content.replace(entry.getKey(), entry.getValue());
+ }
+ }
+
+ return content;
+ }
+
+ public void setClusterSize(String value) {
+ this.data.put(PLACEHOLDER_CLUSTER_SIZE, value);
+ }
+}
\ No newline at end of file
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/GetYangSchemaRequest.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/GetYangSchemaRequest.java
new file mode 100644
index 0000000..db4faed
--- /dev/null
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/GetYangSchemaRequest.java
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
+ * =================================================================================================
+ * 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.
+ * ============LICENSE_END==========================================================================
+ ******************************************************************************/
+package org.onap.ccsdk.features.sdnr.wt.dataprovider.http;
+
+import javax.servlet.http.HttpServletRequest;
+
+public class GetYangSchemaRequest {
+
+ private static final String URI_PREFIX = "/yang-schema/";
+ private final String module;
+ private final String version;
+
+ public String getModule() {
+ return this.module;
+ }
+
+ public String getVersion() {
+ return this.version;
+ }
+
+ public boolean hasVersion() {
+ return this.version != null;
+ }
+
+ public GetYangSchemaRequest(HttpServletRequest req) throws Exception {
+ String uri = req.getRequestURI().substring(URI_PREFIX.length());
+
+ String[] hlp = uri.split("/");
+ if (hlp.length < 1) {
+ throw new Exception("no module request found");
+
+ } else if (hlp.length == 1) {
+ this.module = hlp[0];
+ this.version = null;
+ } else {
+ this.module = hlp[0];
+ this.version = hlp[1];
+ }
+
+ }
+
+}
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/MsServlet.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/MsServlet.java
new file mode 100644
index 0000000..cdcbb49
--- /dev/null
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/MsServlet.java
@@ -0,0 +1,102 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP : CCSDK.apps.sdnr.wt.apigateway
+ * ================================================================================
+ * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property.
+ * All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.ccsdk.features.sdnr.wt.dataprovider.http;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.onap.ccsdk.features.sdnr.wt.common.http.BaseServlet;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.data.MediatorServerDataProvider;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class MsServlet extends BaseServlet {
+
+ /**
+ *
+ */
+ private static Logger LOG = LoggerFactory.getLogger(MsServlet.class);
+ private static final long serialVersionUID = -5361461082028405171L;
+ private static final String OFFLINE_RESPONSE_MESSAGE = "MediatorServer interface is offline";
+ private static boolean trustAll = false;
+ private MediatorServerDataProvider entryProvider;
+ public MsServlet() {
+ super(false);
+ }
+
+ @Override
+ protected void doOptions(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+ resp.setStatus(200);
+ }
+ @Override
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+ super.doGet(req, resp);
+ }
+ @Override
+ protected String getOfflineResponse() {
+ return OFFLINE_RESPONSE_MESSAGE;
+ }
+
+ public void triggerReloadDatabaseEntries() {
+ LOG.debug("external reload triggered");
+ this.entryProvider.triggerReloadSync();
+ }
+
+ @Override
+ protected boolean isOff() {
+ return false;
+ }
+
+ @Override
+ protected String getRemoteUrl(String uri) {
+ String dbServerId = "0";
+ if (uri == null)
+ uri = "";
+ if (uri.length() > 0) {
+ uri = uri.substring("/ms/".length());
+ int idx= uri.indexOf("/");
+ dbServerId = uri.substring(0,idx);
+ uri=uri.substring(idx);
+ }
+ LOG.debug("request for ms server with id={}",dbServerId);
+ String url= this.getBaseUrl(dbServerId) + uri;
+ LOG.debug("dest-url: {}",url);
+ return url;
+ }
+
+ protected String getBaseUrl(String dbServerId) {
+ return this.entryProvider.getHostUrl(dbServerId);
+ }
+ @Override
+ protected boolean doTrustAll() {
+ return trustAll;
+ }
+ @Override
+ protected void trustAll(boolean trust) {
+ trustAll = trust;
+ }
+
+ public void setDataProvider(MediatorServerDataProvider mediatorServerDataProvider) {
+ this.entryProvider = mediatorServerDataProvider;
+ }
+}
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/ReadyHttpServlet.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/ReadyHttpServlet.java
new file mode 100644
index 0000000..96a6fc1
--- /dev/null
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/ReadyHttpServlet.java
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
+ * =================================================================================================
+ * 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.
+ * ============LICENSE_END==========================================================================
+ ******************************************************************************/
+package org.onap.ccsdk.features.sdnr.wt.dataprovider.http;
+
+import java.io.IOException;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class ReadyHttpServlet extends HttpServlet {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ private static final Logger LOG = LoggerFactory.getLogger(ReadyHttpServlet.class);
+ private static boolean status;
+
+ @Override
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+
+ if(isReady()) {
+ resp.setStatus(HttpServletResponse.SC_OK);
+ }
+ else {
+
+ try {
+ resp.sendError(HttpServletResponse.SC_NOT_FOUND);
+ }catch(IOException | IllegalStateException e) {
+ LOG.warn("unable to write out 404 res not found: {}",e);
+ }
+ }
+ }
+
+ private static boolean isReady() {
+ return status;
+ }
+
+ public static void setStatus(boolean s) {
+ status = s;
+ LOG.info("status is set to ready: {}",status);
+ }
+}
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/YangSchemaHttpServlet.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/YangSchemaHttpServlet.java
new file mode 100644
index 0000000..1cb3865
--- /dev/null
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/YangSchemaHttpServlet.java
@@ -0,0 +1,119 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
+ * =================================================================================================
+ * 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.
+ * ============LICENSE_END==========================================================================
+ ******************************************************************************/
+package org.onap.ccsdk.features.sdnr.wt.dataprovider.http;
+
+import java.io.IOException;
+import java.text.ParseException;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.data.YangFileProvider;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class YangSchemaHttpServlet extends HttpServlet {
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ private static final Logger LOG = LoggerFactory.getLogger(YangSchemaHttpServlet.class);
+
+ private static final String schemaCachePath = "cache/schema/";
+
+ private final YangFileProvider fileProvider;
+
+ public YangSchemaHttpServlet() {
+ this.fileProvider = new YangFileProvider(schemaCachePath);
+ }
+
+ @Override
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+
+ GetYangSchemaRequest request = null;
+ try {
+ request = new GetYangSchemaRequest(req);
+ } catch (Exception e) {
+ LOG.warn("bad request for yang-schema: {}", e);
+ }
+ if (request != null) {
+ int len;
+ LOG.debug("request for yang-schema for module {} with version {}", request.getModule(),
+ request.getVersion());
+ if (request.hasVersion()) {
+ boolean has=false;
+ try {
+ has = this.fileProvider.hasFileOrNewerForModule(request.getModule(), request.getVersion());
+ } catch (ParseException e1) {
+ LOG.warn("unable to parse revision: {}" ,e1);
+ }
+ if(has) {
+
+ try {
+ resp.setStatus(HttpServletResponse.SC_OK);
+ resp.setContentType("text/plain");
+ len = this.fileProvider.writeOutput(request.getModule(), request.getVersion(),
+ resp.getOutputStream());
+ resp.setContentLength(len);
+
+ } catch (ParseException e) {
+ LOG.warn("unable to parse revision: {}", e);
+ }catch (IOException | IllegalStateException e) {
+ LOG.warn("unable to write out module {}@{}: {}",request.getModule(), request.getVersion(), e);
+ }
+ } else {
+ try {
+ resp.sendError(HttpServletResponse.SC_NOT_FOUND);
+ }catch(IOException | IllegalStateException e) {
+ LOG.warn("unable to write out 404 res not found: {}",e);
+ }
+ }
+
+ } else if (this.fileProvider.hasFileForModule(request.getModule())) {
+
+ try {
+ resp.setStatus(HttpServletResponse.SC_OK);
+ resp.setContentType("text/plain");
+ len = this.fileProvider.writeOutput(request.getModule(), null, resp.getOutputStream());
+ resp.setContentLength(len);
+ } catch (ParseException e) {
+ LOG.warn(e.getMessage());
+ }catch(IOException | IllegalStateException e) {
+ LOG.warn("unable to write out module {}: {}",request.getModule(), e);
+ }
+
+ } else {
+ try {
+ resp.sendError(HttpServletResponse.SC_NOT_FOUND);
+ }catch(IOException | IllegalStateException e) {
+ LOG.warn("unable to write out 404 res not found: {}",e);
+ }
+ }
+ } else {
+ try {
+ resp.sendError(HttpServletResponse.SC_BAD_REQUEST);
+ }catch(IOException | IllegalStateException e) {
+ LOG.warn("unable to write out 400 bad request: {}",e);
+ }
+ }
+
+ }
+
+}
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/impl/DataProviderImpl.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/impl/DataProviderImpl.java
new file mode 100644
index 0000000..e29e7f4
--- /dev/null
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/impl/DataProviderImpl.java
@@ -0,0 +1,130 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
+ * =================================================================================================
+ * 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.
+ * ============LICENSE_END==========================================================================
+ ******************************************************************************/
+package org.onap.ccsdk.features.sdnr.wt.dataprovider.impl;
+
+import org.onap.ccsdk.features.sdnr.wt.common.database.HtDatabaseClient;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.http.AboutHttpServlet;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.http.MsServlet;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.http.ReadyHttpServlet;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.HtDatabaseMaintenance;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.IEntityDataProvider;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.IEsConfig;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.NetconfTimeStamp;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.StatusChangedHandler.StatusKey;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.types.NetconfTimeStampImpl;
+import org.opendaylight.mdsal.binding.api.RpcProviderService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class DataProviderImpl implements IEntityDataProvider, AutoCloseable {
+
+ private static final Logger LOG = LoggerFactory.getLogger(DataProviderImpl.class);
+
+ private static final String APPLICATION_NAME = "data-provider";
+ private RpcProviderService rpcProviderService = null;
+ private MsServlet mediatorServerServlet;
+ private DataProviderServiceImpl rpcApiService;
+ private AboutHttpServlet aboutServlet;
+ private HtDatabaseClient dbClient;
+
+
+ // Blueprint 1
+ public DataProviderImpl() {
+ super();
+ LOG.info("Creating provider for {}", APPLICATION_NAME);
+ }
+
+ public void setRpcProviderService(RpcProviderService rpcProviderService) {
+ this.rpcProviderService = rpcProviderService;
+ }
+ public void setMediatorServerServlet(MsServlet servlet) {
+ this.mediatorServerServlet = servlet;
+ }
+ public void setAboutServlet(AboutHttpServlet aboutServlet) {
+ this.aboutServlet = aboutServlet;
+ }
+ public void init() throws Exception {
+
+ LOG.info("Session Initiated start {}", APPLICATION_NAME);
+
+ // Start RPC Service
+ this.rpcApiService = new DataProviderServiceImpl(rpcProviderService,this.mediatorServerServlet);
+ // Get configuration
+
+ LOG.info("Session Initiated end. Initialization done");
+ }
+
+ @Override
+ public void close() throws Exception {
+ LOG.info("DeviceManagerImpl closing ...");
+
+ close(dbClient);
+ close(rpcApiService);
+ LOG.info("DeviceManagerImpl closing done");
+ }
+
+ /**
+ * Used to close all Services, that should support AutoCloseable Pattern
+ *
+ * @param toClose
+ * @throws Exception
+ */
+ private void close(AutoCloseable... toCloseList) throws Exception {
+ for (AutoCloseable element : toCloseList) {
+ if (element != null) {
+ element.close();
+ }
+ }
+ }
+
+ @Override
+ public DataProvider getDataProvider() {
+ return rpcApiService.getDataProvider();
+ }
+
+ @Override
+ public HtDatabaseMaintenance getHtDatabaseMaintenance() {
+ return rpcApiService.getHtDatabaseMaintenance();
+ }
+
+ @Override
+ public IEsConfig getEsConfig() {
+ return rpcApiService.getEsConfig();
+ }
+
+ @Override
+ public NetconfTimeStamp getConverter() {
+ return NetconfTimeStampImpl.getConverter();
+ }
+
+ @Override
+ public void setReadyStatus(boolean status) {
+ ReadyHttpServlet.setStatus(status);
+ }
+
+ @Override
+ public void setStatus(StatusKey key, String value) {
+ if(this.aboutServlet!=null) {
+ if(key==StatusKey.CLUSTER_SIZE) {
+ this.aboutServlet.setClusterSize(value);
+ }
+ }
+ }
+
+}
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/impl/DataProviderServiceImpl.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/impl/DataProviderServiceImpl.java
new file mode 100644
index 0000000..c20263c
--- /dev/null
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/impl/DataProviderServiceImpl.java
@@ -0,0 +1,360 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
+ * =================================================================================================
+ * 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.
+ * ============LICENSE_END==========================================================================
+ ******************************************************************************/
+package org.onap.ccsdk.features.sdnr.wt.dataprovider.impl;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.concurrent.TimeUnit;
+
+import org.eclipse.jdt.annotation.NonNull;
+import org.onap.ccsdk.features.sdnr.wt.common.configuration.ConfigurationFileRepresentation;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.data.ElasticSearchDataProvider;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.data.MediatorServerDataProvider;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.http.MsServlet;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.HtDatabaseMaintenance;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.IEsConfig;
+import org.opendaylight.mdsal.binding.api.RpcProviderService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.CreateMaintenanceInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.CreateMaintenanceOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.CreateMediatorServerInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.CreateMediatorServerOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.CreateNetworkElementConnectionInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.CreateNetworkElementConnectionOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.DataProviderService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.DeleteMaintenanceInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.DeleteMaintenanceOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.DeleteMediatorServerInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.DeleteMediatorServerOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.DeleteNetworkElementConnectionInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.DeleteNetworkElementConnectionOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ReadConnectionlogListInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ReadConnectionlogListOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ReadEventlogListInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ReadEventlogListOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ReadFaultcurrentListInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ReadFaultcurrentListOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ReadFaultlogListInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ReadFaultlogListOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ReadInventoryListInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ReadInventoryListOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ReadMaintenanceListInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ReadMaintenanceListOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ReadMediatorServerListInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ReadMediatorServerListOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ReadNetworkElementConnectionListInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ReadNetworkElementConnectionListOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ReadPmdata15mDeviceListInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ReadPmdata15mDeviceListOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ReadPmdata15mListInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ReadPmdata15mListOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ReadPmdata15mLtpListInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ReadPmdata15mLtpListOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ReadPmdata24hDeviceListInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ReadPmdata24hDeviceListOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ReadPmdata24hListInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ReadPmdata24hListOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ReadPmdata24hLtpListInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ReadPmdata24hLtpListOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ReadStatusInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ReadStatusOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.UpdateMaintenanceInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.UpdateMaintenanceOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.UpdateMediatorServerInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.UpdateMediatorServerOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.UpdateNetworkElementConnectionInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.UpdateNetworkElementConnectionOutput;
+import org.opendaylight.yangtools.concepts.Builder;
+import org.opendaylight.yangtools.concepts.ObjectRegistration;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.common.RpcError.ErrorType;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.util.concurrent.ListenableFuture;
+
+public class DataProviderServiceImpl implements DataProviderService, AutoCloseable {
+
+ private static final Logger LOG = LoggerFactory.getLogger(DataProviderServiceImpl.class);
+ public static final String CONFIGURATIONFILE = "etc/dataprovider.properties";
+ private static final long DATABASE_TIMEOUT_MS = 120*1000L;
+
+ private final ObjectRegistration<@NonNull DataProviderServiceImpl> rpcReg;
+ private final ElasticSearchDataProvider dataProvider;
+ private final ConfigurationFileRepresentation configuration;
+ private final EsConfig esConfig;
+ private final MediatorServerDataProvider mediatorServerDataProvider;
+
+ DataProviderServiceImpl(final RpcProviderService rpcProviderService,MsServlet mediatorServerServlet) throws Exception {
+ this.configuration = new ConfigurationFileRepresentation(CONFIGURATIONFILE);
+ this.esConfig = new EsConfig(configuration);
+ this.dataProvider = new ElasticSearchDataProvider(esConfig.getHosts(),esConfig.getBasicAuthUsername(),esConfig.getBasicAuthPassword());
+ this.dataProvider.waitForYellowDatabaseStatus(DATABASE_TIMEOUT_MS,TimeUnit.MILLISECONDS);
+ this.mediatorServerDataProvider = new MediatorServerDataProvider(esConfig.getHosts(),esConfig.getBasicAuthUsername(),esConfig.getBasicAuthPassword());
+ mediatorServerServlet.setDataProvider(this.mediatorServerDataProvider);
+ // Register ourselves as the REST API RPC implementation
+ LOG.info("Register RPC Service " + DataProviderServiceImpl.class.getSimpleName());
+ this.rpcReg = rpcProviderService.registerRpcImplementation(DataProviderService.class, this);
+ }
+ private void sendResyncCallbackToApiGateway() {
+ mediatorServerDataProvider.triggerReloadSync();
+ }
+ /**
+ * @return dataProvider
+ */
+ public DataProvider getDataProvider() {
+ return dataProvider.getDataProvider();
+ }
+
+ /**
+ * @return data provider for Maintenance()
+ */
+ public HtDatabaseMaintenance getHtDatabaseMaintenance() {
+ return dataProvider.getHtDatabaseMaintenance();
+ }
+
+ /**
+ * @return configuration object
+ */
+ public IEsConfig getEsConfig() {
+ return esConfig;
+ }
+
+
+ @Override
+ public void close() throws Exception {
+ LOG.info("Close RPC Service");
+ if (rpcReg != null) {
+ rpcReg.close();
+ }
+ }
+
+ @Override
+ public ListenableFuture<RpcResult<ReadFaultcurrentListOutput>> readFaultcurrentList(ReadFaultcurrentListInput input) {
+ LOG.debug("RPC Request: getFaultCurrentEntityList with input {}", input);
+ RpcResultBuilder<ReadFaultcurrentListOutput> result = read(()-> DataProviderServiceImpl.this.dataProvider.readFaultCurrentList(input));
+ return result.buildFuture();
+ }
+ @Override
+ public ListenableFuture<RpcResult<ReadFaultlogListOutput>> readFaultlogList(ReadFaultlogListInput input) {
+ LOG.debug("RPC Request: getFaultCurrentEntityList with input {}", input);
+ RpcResultBuilder<ReadFaultlogListOutput> result = read(()-> DataProviderServiceImpl.this.dataProvider.readFaultLogList(input));
+ return result.buildFuture();
+ }
+
+ @Override
+ public ListenableFuture<RpcResult<ReadMaintenanceListOutput>> readMaintenanceList(ReadMaintenanceListInput input) {
+ LOG.debug("RPC Request: getMaintenanceEntityList with input {}", input);
+ RpcResultBuilder<ReadMaintenanceListOutput> result = read(()-> DataProviderServiceImpl.this.dataProvider.readMaintenanceList(input));
+ return result.buildFuture();
+ }
+
+ @Override
+ public ListenableFuture<RpcResult<ReadMediatorServerListOutput>> readMediatorServerList(
+ ReadMediatorServerListInput input) {
+ LOG.debug("RPC Request: getMediatorServerEntityList with input {}", input);
+ RpcResultBuilder<ReadMediatorServerListOutput> result = read(()-> DataProviderServiceImpl.this.dataProvider.readMediatorServerList(input));
+ return result.buildFuture();
+ }
+
+ @Override
+ public ListenableFuture<RpcResult<ReadNetworkElementConnectionListOutput>> readNetworkElementConnectionList(
+ ReadNetworkElementConnectionListInput input) {
+ LOG.debug("RPC Request: getNetworkElementConnectionEntityList with input {}", input);
+ RpcResultBuilder<ReadNetworkElementConnectionListOutput> result = read(()-> DataProviderServiceImpl.this.dataProvider.readNetworkElementConnectionList(input));
+ return result.buildFuture();
+
+ }
+
+ @Override
+ public ListenableFuture<RpcResult<ReadPmdata15mListOutput>> readPmdata15mList(ReadPmdata15mListInput input) {
+ LOG.debug("RPC Request: getNetworkElementConnectionEntityList with input {}", input);
+ RpcResultBuilder<ReadPmdata15mListOutput> result = read(()-> DataProviderServiceImpl.this.dataProvider.readPmdata15mList(input));
+ return result.buildFuture();
+
+ }
+ @Override
+ public ListenableFuture<RpcResult<ReadPmdata24hListOutput>> readPmdata24hList(ReadPmdata24hListInput input) {
+ LOG.debug("RPC Request: getNetworkElementConnectionEntityList with input {}", input);
+ RpcResultBuilder<ReadPmdata24hListOutput> result = read(()-> DataProviderServiceImpl.this.dataProvider.readPmdata24hList(input));
+ return result.buildFuture();
+
+ }
+ @Override
+ public ListenableFuture<RpcResult<ReadStatusOutput>> readStatus(ReadStatusInput input) {
+ LOG.debug("RPC Request: getStatusEntityList with input {}", input);
+ RpcResultBuilder<ReadStatusOutput> result = read(()-> DataProviderServiceImpl.this.dataProvider.readStatus());
+ return result.buildFuture();
+
+ }
+
+ @Override
+ public ListenableFuture<RpcResult<ReadInventoryListOutput>> readInventoryList(ReadInventoryListInput input) {
+ LOG.debug("RPC Request: getInventoryEntityList with input {}", input);
+ RpcResultBuilder<ReadInventoryListOutput> result = read(()-> DataProviderServiceImpl.this.dataProvider.readInventoryList(input));
+ return result.buildFuture();
+ }
+
+ @Override
+ public ListenableFuture<RpcResult<ReadPmdata15mLtpListOutput>> readPmdata15mLtpList(ReadPmdata15mLtpListInput input) {
+ LOG.debug("RPC Request: readPmdataLtpList with input {}", input);
+ RpcResultBuilder<ReadPmdata15mLtpListOutput> result = read(()-> DataProviderServiceImpl.this.dataProvider.readPmdata15mLtpList(input));
+ return result.buildFuture();
+ }
+
+ @Override
+ public ListenableFuture<RpcResult<ReadPmdata15mDeviceListOutput>> readPmdata15mDeviceList(ReadPmdata15mDeviceListInput input) {
+ LOG.debug("RPC Request: readPmdataDeviceList with input {}", input);
+ RpcResultBuilder<ReadPmdata15mDeviceListOutput> result = read(()-> DataProviderServiceImpl.this.dataProvider.readPmdata15mDeviceList(input));
+ return result.buildFuture();
+ }
+
+ @Override
+ public ListenableFuture<RpcResult<ReadPmdata24hLtpListOutput>> readPmdata24hLtpList(ReadPmdata24hLtpListInput input) {
+ LOG.debug("RPC Request: readPmdataLtpList with input {}", input);
+ RpcResultBuilder<ReadPmdata24hLtpListOutput> result = read(()-> DataProviderServiceImpl.this.dataProvider.readPmdata24hLtpList(input));
+ return result.buildFuture();
+ }
+
+ @Override
+ public ListenableFuture<RpcResult<ReadPmdata24hDeviceListOutput>> readPmdata24hDeviceList(ReadPmdata24hDeviceListInput input) {
+ LOG.debug("RPC Request: readPmdataDeviceList with input {}", input);
+ RpcResultBuilder<ReadPmdata24hDeviceListOutput> result = read(()-> DataProviderServiceImpl.this.dataProvider.readPmdata24hDeviceList(input));
+ return result.buildFuture();
+ }
+
+ @Override
+ public ListenableFuture<RpcResult<ReadConnectionlogListOutput>> readConnectionlogList(
+ ReadConnectionlogListInput input) {
+ LOG.debug("RPC Request: readConnectionlogList with input {}", input);
+ RpcResultBuilder<ReadConnectionlogListOutput> result = read(() -> DataProviderServiceImpl.this.dataProvider.readConnectionlogList(input));
+ return result.buildFuture();
+ }
+
+ @Override
+ public ListenableFuture<RpcResult<CreateNetworkElementConnectionOutput>> createNetworkElementConnection(
+ CreateNetworkElementConnectionInput input) {
+ LOG.debug("RPC Request: createNetworkElementConnection with input {}", input);
+ RpcResultBuilder<CreateNetworkElementConnectionOutput> result = read(() -> DataProviderServiceImpl.this.dataProvider.createNetworkElementConnection(input));
+ return result.buildFuture();
+ }
+
+ @Override
+ public ListenableFuture<RpcResult<UpdateNetworkElementConnectionOutput>> updateNetworkElementConnection(
+ UpdateNetworkElementConnectionInput input) {
+ LOG.debug("RPC Request: updateNetworkElementConnection with input {}", input);
+ RpcResultBuilder<UpdateNetworkElementConnectionOutput> result = read(() -> DataProviderServiceImpl.this.dataProvider.updateNetworkElementConnection(input));
+ return result.buildFuture();
+ }
+
+ @Override
+ public ListenableFuture<RpcResult<DeleteNetworkElementConnectionOutput>> deleteNetworkElementConnection(
+ DeleteNetworkElementConnectionInput input) {
+ RpcResultBuilder<DeleteNetworkElementConnectionOutput> result = read(() -> DataProviderServiceImpl.this.dataProvider.deleteNetworkElementConnection(input));
+ return result.buildFuture();
+ }
+
+ @Override
+ public ListenableFuture<RpcResult<DeleteMediatorServerOutput>> deleteMediatorServer(
+ DeleteMediatorServerInput input) {
+ LOG.debug("RPC Request: deleteMediatorServer with input {}", input);
+ RpcResultBuilder<DeleteMediatorServerOutput> result = read(() -> DataProviderServiceImpl.this.dataProvider.deleteMediatorServer(input));
+ this.sendResyncCallbackToApiGateway();
+ return result.buildFuture();
+ }
+
+ @Override
+ public ListenableFuture<RpcResult<CreateMediatorServerOutput>> createMediatorServer(
+ CreateMediatorServerInput input) {
+ LOG.debug("RPC Request: createMediatorServer with input {}", input);
+ RpcResultBuilder<CreateMediatorServerOutput> result = read(() -> DataProviderServiceImpl.this.dataProvider.createMediatorServer(input));
+ this.sendResyncCallbackToApiGateway();
+ return result.buildFuture();
+ }
+
+ @Override
+ public ListenableFuture<RpcResult<CreateMaintenanceOutput>> createMaintenance(CreateMaintenanceInput input) {
+ LOG.debug("RPC Request: createMaintenance with input {}", input);
+ RpcResultBuilder<CreateMaintenanceOutput> result = read(() -> DataProviderServiceImpl.this.dataProvider.createMaintenance(input));
+ return result.buildFuture();
+ }
+
+ @Override
+ public ListenableFuture<RpcResult<DeleteMaintenanceOutput>> deleteMaintenance(DeleteMaintenanceInput input) {
+ LOG.debug("RPC Request: deleteMaintenance with input {}", input);
+ RpcResultBuilder<DeleteMaintenanceOutput> result = read(() -> DataProviderServiceImpl.this.dataProvider.deleteMaintenance(input));
+ return result.buildFuture();
+ }
+
+ @Override
+ public ListenableFuture<RpcResult<UpdateMediatorServerOutput>> updateMediatorServer(
+ UpdateMediatorServerInput input) {
+ LOG.debug("RPC Request: updateMediatorServer with input {}", input);
+ RpcResultBuilder<UpdateMediatorServerOutput> result = read(() -> DataProviderServiceImpl.this.dataProvider.updateMediatorServer(input));
+ this.sendResyncCallbackToApiGateway();
+ return result.buildFuture();
+ }
+
+ @Override
+ public ListenableFuture<RpcResult<UpdateMaintenanceOutput>> updateMaintenance(UpdateMaintenanceInput input) {
+ LOG.debug("RPC Request: updateMaintenance with input {}", input);
+ RpcResultBuilder<UpdateMaintenanceOutput> result = read(() -> DataProviderServiceImpl.this.dataProvider.updateMaintenance(input));
+ return result.buildFuture();
+ }
+
+ @Override
+ public ListenableFuture<RpcResult<ReadEventlogListOutput>> readEventlogList(ReadEventlogListInput input) {
+ LOG.debug("RPC Request: readEventlogList with input {}", input);
+ RpcResultBuilder<ReadEventlogListOutput> result = read(() -> DataProviderServiceImpl.this.dataProvider.readEventlogList(input));
+ return result.buildFuture();
+ }
+
+ // -- private classes and functions
+
+ private static String assembleExceptionMessage(Exception e) {
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw);
+ e.printStackTrace(pw);
+
+ StringBuffer buf = new StringBuffer();
+ buf.append("Exception: ");
+ buf.append(sw.toString());
+ return buf.toString();
+ }
+
+ private interface GetEntityInput<O extends DataObject> {
+ Builder<O> get() throws IOException;
+ }
+
+ private static <O extends DataObject,I extends DataObject> RpcResultBuilder<O> read(GetEntityInput<O> inputgetter ) {
+ RpcResultBuilder<O> result;
+ try {
+ Builder<O> outputBuilder = inputgetter.get();
+ result = RpcResultBuilder.success(outputBuilder);
+ } catch (Exception e) {
+ LOG.info("Exception", e);
+ result = RpcResultBuilder.failed();
+ result.withError(ErrorType.APPLICATION, assembleExceptionMessage(e));
+ }
+ return result;
+ }
+
+}
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/impl/EsConfig.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/impl/EsConfig.java
new file mode 100644
index 0000000..fc9ae50
--- /dev/null
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/impl/EsConfig.java
@@ -0,0 +1,194 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
+ * =================================================================================================
+ * 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.
+ * ============LICENSE_END==========================================================================
+ ******************************************************************************/
+package org.onap.ccsdk.features.sdnr.wt.dataprovider.impl;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.onap.ccsdk.features.sdnr.wt.common.configuration.Configuration;
+import org.onap.ccsdk.features.sdnr.wt.common.configuration.ConfigurationFileRepresentation;
+import org.onap.ccsdk.features.sdnr.wt.common.configuration.filechange.IConfigChangedListener;
+import org.onap.ccsdk.features.sdnr.wt.common.database.config.HostInfo;
+import org.onap.ccsdk.features.sdnr.wt.common.database.config.HostInfo.Protocol;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.IEsConfig;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class EsConfig implements Configuration, IEsConfig {
+
+ private static final Logger LOG = LoggerFactory.getLogger(EsConfig.class);
+
+ public static final String SECTION_MARKER_ES = "es";
+
+ private static final String PROPERTY_KEY_DBHOSTS = "esHosts";
+ private static final String PROPERTY_KEY_ARCHIVE_LIMIT = "esArchiveLifetimeSeconds";
+ private static final String PROPERTY_KEY_CLUSTER = "esCluster";
+ private static final String PROPERTY_KEY_ARCHIVE_INTERVAL = "esArchiveCheckIntervalSeconds";
+ private static final String PROPERTY_KEY_NODE = "esNode";
+ private static final String PROPERTY_KEY_AUTH_USERNAME = "esAuthUsername";
+ private static final String PROPERTY_KEY_AUTH_PASSWORD = "esAuthPassword";
+
+
+ private static String defaultHostinfo = printHosts(new HostInfo[] { new HostInfo("sdnrdb", 9200, Protocol.HTTP) });
+ private static final String DEFAULT_VALUE_CLUSTER = "";
+ /** check db data in this interval [in seconds] 0 deactivated */
+ private static final String DEFAULT_ARCHIVE_INTERVAL_SEC = "0";
+ /** keep data for this time [in seconds] 30 days */
+ private static final String DEFAULT_ARCHIVE_LIMIT_SEC = String.valueOf(60L * 60L * 24L * 30L);
+ private static final String DEFAULT_KEY_NODE = "elasticsearchnode";
+
+ private final ConfigurationFileRepresentation configuration;
+
+ public EsConfig(ConfigurationFileRepresentation configuration) {
+
+ this.configuration = configuration;
+ this.configuration.addSection(SECTION_MARKER_ES);
+ defaults();
+ }
+
+ /*
+ * Setter
+ */
+
+ public void setNode(String nodeName) {
+ configuration.setProperty(SECTION_MARKER_ES, PROPERTY_KEY_NODE, nodeName);
+ }
+
+ /*
+ * Getter
+ */
+
+ public String getNode() {
+ return configuration.getProperty(SECTION_MARKER_ES, PROPERTY_KEY_NODE);
+ }
+
+ public HostInfo[] getHosts() {
+ String dbHosts = configuration.getProperty(SECTION_MARKER_ES, PROPERTY_KEY_DBHOSTS);
+ return parseHosts(dbHosts);
+ }
+ public void setHosts(HostInfo[] hosts) {
+ this.configuration.setProperty(SECTION_MARKER_ES, PROPERTY_KEY_DBHOSTS, printHosts(hosts));
+ }
+ @Override
+ public String getCluster() {
+ return configuration.getProperty(SECTION_MARKER_ES, PROPERTY_KEY_ARCHIVE_INTERVAL);
+ }
+
+ public void setCluster(String cluster) {
+ configuration.setProperty(SECTION_MARKER_ES, PROPERTY_KEY_CLUSTER, cluster);
+ }
+
+ public boolean hasBasicAuthCredentials() {
+ return this.getBasicAuthUsername()!=null && this.getBasicAuthPassword()!=null &&
+ this.getBasicAuthUsername()!="" && this.getBasicAuthPassword()!="" ;
+ }
+ public String getBasicAuthUsername() {
+ return this.configuration.getProperty(SECTION_MARKER_ES, PROPERTY_KEY_AUTH_USERNAME);
+ }
+ public String getBasicAuthPassword() {
+ return this.configuration.getProperty(SECTION_MARKER_ES, PROPERTY_KEY_AUTH_PASSWORD);
+ }
+ @Override
+ public long getArchiveCheckIntervalSeconds() {
+ return configuration.getPropertyLong(SECTION_MARKER_ES, PROPERTY_KEY_ARCHIVE_INTERVAL).orElse(0L);
+ }
+
+ public void setArchiveCheckIntervalSeconds(long seconds) {
+ configuration.setProperty(SECTION_MARKER_ES, PROPERTY_KEY_ARCHIVE_INTERVAL, seconds);
+ }
+
+ @Override
+ public long getArchiveLifetimeSeconds() {
+ return configuration.getPropertyLong(SECTION_MARKER_ES, PROPERTY_KEY_ARCHIVE_LIMIT).orElse(0L);
+ }
+
+ public void setArchiveLimit(long seconds) {
+ configuration.setProperty(SECTION_MARKER_ES, PROPERTY_KEY_ARCHIVE_LIMIT, seconds);
+ }
+
+ @Override
+ public String getSectionName() {
+ return SECTION_MARKER_ES;
+ }
+
+ @Override
+ public void defaults() {
+ // Add default if not available
+ configuration.setPropertyIfNotAvailable(SECTION_MARKER_ES, PROPERTY_KEY_DBHOSTS, defaultHostinfo);
+ configuration.setPropertyIfNotAvailable(SECTION_MARKER_ES, PROPERTY_KEY_ARCHIVE_LIMIT,
+ DEFAULT_ARCHIVE_LIMIT_SEC);
+ configuration.setPropertyIfNotAvailable(SECTION_MARKER_ES, PROPERTY_KEY_CLUSTER, DEFAULT_VALUE_CLUSTER);
+ configuration.setPropertyIfNotAvailable(SECTION_MARKER_ES, PROPERTY_KEY_ARCHIVE_INTERVAL,
+ DEFAULT_ARCHIVE_INTERVAL_SEC);
+ configuration.setPropertyIfNotAvailable(SECTION_MARKER_ES, PROPERTY_KEY_NODE, DEFAULT_KEY_NODE);
+ configuration.setPropertyIfNotAvailable(SECTION_MARKER_ES, PROPERTY_KEY_AUTH_USERNAME, "");
+ configuration.setPropertyIfNotAvailable(SECTION_MARKER_ES, PROPERTY_KEY_AUTH_PASSWORD, "");
+ }
+
+ @Override
+ public void unregisterConfigChangedListener(IConfigChangedListener archiveCleanService) {
+ configuration.unregisterConfigChangedListener(archiveCleanService);
+ }
+
+ @Override
+ public void registerConfigChangedListener(IConfigChangedListener archiveCleanService) {
+ configuration.registerConfigChangedListener(archiveCleanService);
+ }
+
+ /** @TODO Shift to own class **/
+ private static String printHosts(HostInfo[] h) {
+ StringBuilder sb = new StringBuilder();
+ for (int i = 0; i < h.length; i++) {
+ sb.append(h[i].toUrl());
+ if (i != h.length - 1) {
+ sb.append(",");
+ }
+ }
+ return sb.toString();
+ }
+
+ /** @TODO Shift to own class **/
+ private static HostInfo[] parseHosts(String string) {
+ List<HostInfo> infos = new ArrayList<>();
+ String[] list = string.split(",");
+ if (list.length > 0) {
+ for (String item : list) {
+ try {
+ URL url = new URL(item);
+ infos.add(new HostInfo(url.getHost(), url.getPort(), Protocol.getValueOf(url.getProtocol())));
+ } catch (MalformedURLException e) {
+ LOG.warn("problem parsing url {} : {}", item, e.getMessage());
+ }
+ }
+ }
+ HostInfo[] a = new HostInfo[infos.size()];
+ return infos.toArray(a);
+ }
+
+ @Override
+ public String toString() {
+ return "EsConfig [getNode()=" + getNode() + ", getHosts()=" + Arrays.toString(getHosts()) + ", getCluster()="
+ + getCluster() + ", getArchiveCheckIntervalSeconds()=" + getArchiveCheckIntervalSeconds()
+ + ", getArchiveLifetimeSeconds()=" + getArchiveLifetimeSeconds() + ", getSectionName()="
+ + getSectionName() + "]";
+ }
+
+}
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/yangtools/YangToolsCloner.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/yangtools/YangToolsCloner.java
new file mode 100644
index 0000000..013a638
--- /dev/null
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/yangtools/YangToolsCloner.java
@@ -0,0 +1,216 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
+ * =================================================================================================
+ * 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.
+ * ============LICENSE_END==========================================================================
+ ******************************************************************************/
+package org.onap.ccsdk.features.sdnr.wt.dataprovider.yangtools;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.annotation.Nullable;
+import org.opendaylight.yangtools.concepts.Builder;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class YangToolsCloner {
+
+ private static YangToolsMapper yangtoolsMapper = new YangToolsMapper();
+ private static final Logger LOG = LoggerFactory.getLogger(YangToolsCloner.class);
+ public static final int ACCESSOR_FIELD = 0;
+ public static final int ACCESSOR_METHOD = 1;
+
+
+ private final int accessor;
+
+ private YangToolsCloner(int ac) {
+ this.accessor = ac;
+ }
+ public static YangToolsCloner instance() {
+ return instance(ACCESSOR_METHOD);
+ }
+ public static YangToolsCloner instance(int ac) {
+ return new YangToolsCloner(ac);
+ }
+ /**
+ *
+ * @param source source object
+ * @param clazz Class of return object
+ * @return list of cloned object
+ * @return
+ */
+ public <S extends DataObject, T extends DataObject> List<T> cloneList(List<S> source, Class<T> clazz) {
+ return cloneList(source, clazz, null);
+ }
+
+ /**
+ *
+ * @param source source object
+ * @param clazz Class of return object
+ * @attrList filter for attribute Names to clone
+ * @return list of cloned object
+ */
+ public <S extends DataObject, T extends DataObject> List<T> cloneList(List<S> source, Class<T> clazz,
+ @Nullable List<String> attrList) {
+ if (source == null) {
+ return null;
+ }
+ List<T> list = new ArrayList<>();
+ for (S s : source) {
+ list.add(clone(s, clazz, attrList));
+ }
+ return list;
+ }
+
+ /**
+ *
+ * @param source source object
+ * @param clazz Class of return object
+ * @return cloned object
+ */
+ public <S , T extends DataObject> T clone(S source, Class<T> clazz) {
+ return clone(source, clazz, null);
+ }
+ /**
+ *
+ * @param source source object
+ * @param clazz Class of return object
+ * @attrList if empty copy all else list of attribute Names to clone
+ * @return cloned object
+ */
+ public <S, T extends DataObject> T clone(S source, Class<T> clazz,
+ @Nullable List<String> attrList) {
+ if (source == null) {
+ return (T)null;
+ }
+ Field[] attributeFields;
+ Field sourceField;
+ Method m;
+ Builder<T> builder = yangtoolsMapper.getBuilder(clazz);
+ T object = builder.build();
+ attributeFields = object.getClass().getDeclaredFields();
+ for (Field attributeField : attributeFields) {
+ // check if attr is in inclusion list
+ if (attrList != null && !attrList.contains(attributeField.getName())) {
+ continue;
+ }
+ // ignore QNAME
+ if (attributeField.getName().equals("QNAME")) {
+ continue;
+ }
+
+ attributeField.setAccessible(true);
+ try {
+ if(accessor==ACCESSOR_FIELD) {
+ sourceField = source.getClass().getDeclaredField(attributeField.getName());
+ sourceField.setAccessible(true);
+ if (attributeField.getType().equals(String.class) && !sourceField.getType().equals(String.class)) {
+ attributeField.set(object, String.valueOf(sourceField.get(source)));
+ } else {
+ attributeField.set(object, sourceField.get(source));
+ }
+ }
+ else if(accessor==ACCESSOR_METHOD) {
+ String getter = getter(attributeField.getName());
+ System.out.println("getter="+getter);
+ m = source.getClass().getDeclaredMethod(getter);
+ m.setAccessible(true);
+ if (attributeField.getType().equals(String.class) && !m.getReturnType().equals(String.class)) {
+ attributeField.set(object, String.valueOf(m.invoke(source)));
+ } else {
+ attributeField.set(object, m.invoke(source));
+ }
+ }
+
+ } catch (NoSuchMethodException | NoSuchFieldException e) {
+ // Convert to run-time exception
+ String msg = "no such field " + attributeField.getName() + " in class " + source.getClass().getName();
+ LOG.debug(msg);
+ // throw new IllegalArgumentException(msg);
+ } catch (IllegalAccessException|SecurityException e) {
+ LOG.debug("Access problem " + attributeField.getName(), e);
+ } catch (IllegalArgumentException e) {
+ LOG.debug("argument problem " + attributeField.getName(), e);
+ } catch (InvocationTargetException e) {
+ LOG.debug("invocation problem " + attributeField.getName(), e);
+ }
+ }
+
+ return object;
+ }
+
+ private static String getter(String name) {
+ return String.format("%s%s%s","get",name.substring(1, 2).toUpperCase(),name.substring(2));
+ }
+ public <S extends DataObject, T extends DataObject,B extends Builder<T>> B cloneToBuilder(S source, B builder){
+ return cloneToBuilder(source, builder,null);
+ }
+ public <S extends DataObject, T extends DataObject,B extends Builder<T>> B cloneToBuilder(S source, B builder,
+ @Nullable List<String> attrList) {
+ Field[] attributeFields;
+ Field sourceField;
+ Method m;
+ attributeFields = builder.getClass().getDeclaredFields();
+ for (Field attributeField : attributeFields) {
+ // check if attr is in inclusion list
+ if (attrList != null && !attrList.contains(attributeField.getName())) {
+ continue;
+ }
+ // ignore QNAME
+ if (attributeField.getName().equals("QNAME")) {
+ continue;
+ }
+
+ attributeField.setAccessible(true);
+ try {
+ if(accessor==ACCESSOR_FIELD) {
+ sourceField = source.getClass().getDeclaredField(attributeField.getName());
+ sourceField.setAccessible(true);
+ if (attributeField.getType().equals(String.class) && !sourceField.getType().equals(String.class)) {
+ attributeField.set(builder, String.valueOf(sourceField.get(source)));
+ } else {
+ attributeField.set(builder, sourceField.get(source));
+ }
+ }
+ else if(accessor==ACCESSOR_METHOD) {
+ m = source.getClass().getDeclaredMethod(getter(attributeField.getName()));
+ m.setAccessible(true);
+ if (attributeField.getType().equals(String.class) && !m.getReturnType().equals(String.class)) {
+ attributeField.set(builder, String.valueOf(m.invoke(source)));
+ } else {
+ attributeField.set(builder, m.invoke(source));
+ }
+ }
+
+ } catch (NoSuchMethodException | NoSuchFieldException e) {
+ // Convert to run-time exception
+ String msg = "no such field " + attributeField.getName() + " in class " + source.getClass().getName();
+ LOG.debug(msg);
+ // throw new IllegalArgumentException(msg);
+ } catch (IllegalAccessException|SecurityException e) {
+ LOG.debug("Access problem " + attributeField.getName(), e);
+ } catch (IllegalArgumentException e) {
+ LOG.debug("argument problem " + attributeField.getName(), e);
+ } catch (InvocationTargetException e) {
+ LOG.debug("invocation problem " + attributeField.getName(), e);
+ }
+ }
+ return builder;
+ }
+}
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/yangtools/YangToolsMapper.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/yangtools/YangToolsMapper.java
new file mode 100644
index 0000000..3d74a12
--- /dev/null
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/yangtools/YangToolsMapper.java
@@ -0,0 +1,226 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
+ * =================================================================================================
+ * 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.
+ * ============LICENSE_END==========================================================================
+ ******************************************************************************/
+package org.onap.ccsdk.features.sdnr.wt.dataprovider.yangtools;
+
+import java.io.IOException;
+import javax.annotation.Nullable;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.credentials.Credentials;
+import org.opendaylight.yangtools.concepts.Builder;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.FrameworkUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.PropertyNamingStrategy;
+import com.fasterxml.jackson.databind.SerializerProvider;
+import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder;
+import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder.Value;
+import com.fasterxml.jackson.databind.introspect.AnnotatedClass;
+import com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector;
+import com.fasterxml.jackson.databind.module.SimpleModule;
+import com.fasterxml.jackson.databind.ser.std.StdSerializer;
+
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime;
+/**
+ * YangToolsMapper is a specific Jackson mapper configuration for opendaylight yangtools serialization or deserialization of DataObject to/from JSON
+ * TODO ChoiceIn and Credentials deserialization only for LoginPasswordBuilder
+ */
+public class YangToolsMapper extends ObjectMapper {
+
+ private final Logger LOG = LoggerFactory.getLogger(YangToolsMapper.class);
+ private static final long serialVersionUID = 1L;
+ private static BundleContext context;
+
+ public YangToolsMapper() {
+ super();
+ configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+ setPropertyNamingStrategy(PropertyNamingStrategy.KEBAB_CASE);
+ setSerializationInclusion(Include.NON_NULL);
+ setAnnotationIntrospector(new YangToolsBuilderAnnotationIntrospector());
+ SimpleModule dateAndTimeSerializerModule = new SimpleModule();
+ dateAndTimeSerializerModule.addSerializer(DateAndTime.class,new CustomDateAndTimeSerializer());
+ registerModule(dateAndTimeSerializerModule );
+ Bundle bundle = FrameworkUtil.getBundle(YangToolsMapper.class);
+ context = bundle != null ? bundle.getBundleContext() : null;
+ }
+
+ @Override
+ public String writeValueAsString(Object value) throws JsonProcessingException {
+ // TODO Auto-generated method stub
+ return super.writeValueAsString(value);
+ }
+ /**
+ * Get Builder object for yang tools interface.
+ * @param <T> yang-tools base datatype
+ * @param clazz class with interface.
+ * @return builder for interface or null if not existing
+ */
+ @SuppressWarnings("unchecked")
+ public @Nullable <T extends DataObject> Builder<T> getBuilder(Class<T> clazz) {
+ String builder = clazz.getName() + "Builder";
+ try {
+ Class<?> clazzBuilder = findClass(builder);
+ return (Builder<T>) clazzBuilder.newInstance();
+ } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
+ LOG.debug("Problem ", e);
+ return null;
+ }
+ }
+
+ /**
+ * Callback for handling mapping failures.
+ * @return
+ */
+ public int getMappingFailures() {
+ return 0;
+ }
+
+ /**
+ * Provide mapping of string to attribute names, generated by yang-tools.
+ * "netconf-id" converted to "_netconfId"
+ * @param name with attribute name, not null or empty
+ * @return converted string or null if name was empty or null
+ */
+ public @Nullable static String toCamelCaseAttributeName(final String name) {
+ if (name == null || name.isEmpty())
+ return null;
+
+ final StringBuilder ret = new StringBuilder(name.length());
+ if (!name.startsWith("_"))
+ ret.append('_');
+ int start = 0;
+ for (final String word : name.split("-")) {
+ if (!word.isEmpty()) {
+ if (start++ == 0) {
+ ret.append(Character.toLowerCase(word.charAt(0)));
+ } else {
+ ret.append(Character.toUpperCase(word.charAt(0)));
+ }
+ ret.append(word.substring(1));
+ }
+ }
+ return ret.toString();
+ }
+
+ /**
+ * Adapted Builder callbacks
+ */
+ private static class YangToolsBuilderAnnotationIntrospector extends JacksonAnnotationIntrospector {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Class<?> findPOJOBuilder(AnnotatedClass ac) {
+ try {
+ String builder = null;
+ if (ac.getRawType().equals(Credentials.class)) {
+ builder = "org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.credentials.credentials.LoginPasswordBuilder";
+ //System.out.println(DataContainer.class.isAssignableFrom(ac.getRawType()));
+ //System.out.println(ChoiceIn.class.isAssignableFrom(ac.getRawType()));
+
+ }
+ else if(ac.getRawType().equals(DateAndTime.class)) {
+ builder = DateAndTimeBuilder.class.getName();
+ }
+
+ else {
+ if (ac.getRawType().isInterface()) {
+ builder = ac.getName()+"Builder";
+ }
+ }
+ if (builder != null) {
+ //System.out.println("XX1: "+ac.getRawType());
+ //System.out.println("XX2: "+builder);
+ //Class<?> innerBuilder = Class.forName(builder);
+ Class<?> innerBuilder = findClass(builder);
+ //System.out.println("Builder found: "+ innerBuilder);
+ return innerBuilder;
+ }
+ } catch( ClassNotFoundException e ) {
+ // No problem .. try next
+ }
+ return super.findPOJOBuilder(ac);
+ }
+
+ @Override
+ public Value findPOJOBuilderConfig(AnnotatedClass ac) {
+ if (ac.hasAnnotation(JsonPOJOBuilder.class)) {
+ return super.findPOJOBuilderConfig(ac);
+ }
+ return new JsonPOJOBuilder.Value("build", "set");
+ }
+ }
+
+ private static Class<?> findClass(String name) throws ClassNotFoundException {
+ // Try to find in other bundles
+ if (context != null) {
+ //OSGi environment
+ for (Bundle b : context.getBundles()) {
+ try {
+ return b.loadClass(name);
+ } catch (ClassNotFoundException e) {
+ // No problem, this bundle doesn't have the class
+ }
+ }
+ throw new ClassNotFoundException("Can not find Class in OSGi context.");
+ } else {
+ return Class.forName(name);
+ }
+ // not found in any bundle
+ }
+ public static class DateAndTimeBuilder{
+
+ private final String _value;
+
+ public DateAndTimeBuilder(String v) {
+ this._value= v;
+ }
+
+ public DateAndTime build() {
+ return new DateAndTime(_value);
+ }
+
+ }
+ public static class CustomDateAndTimeSerializer extends StdSerializer<DateAndTime>{
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ public CustomDateAndTimeSerializer() {
+ this(null);
+ }
+ protected CustomDateAndTimeSerializer(Class<DateAndTime> t) {
+ super(t);
+ }
+
+ @Override
+ public void serialize(DateAndTime value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
+ gen.writeString(value.getValue());
+ }
+
+ }
+}
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/yangtools/YangToolsMapper2.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/yangtools/YangToolsMapper2.java
new file mode 100644
index 0000000..c492691
--- /dev/null
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/yangtools/YangToolsMapper2.java
@@ -0,0 +1,263 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
+ * =================================================================================================
+ * 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.
+ * ============LICENSE_END==========================================================================
+ ******************************************************************************/
+package org.onap.ccsdk.features.sdnr.wt.dataprovider.yangtools;
+
+import java.io.IOException;
+import javax.annotation.Nullable;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.credentials.Credentials;
+import org.opendaylight.yangtools.concepts.Builder;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.FrameworkUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.PropertyNamingStrategy;
+import com.fasterxml.jackson.databind.SerializerProvider;
+import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder;
+import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder.Value;
+import com.fasterxml.jackson.databind.introspect.AnnotatedClass;
+import com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector;
+import com.fasterxml.jackson.databind.module.SimpleModule;
+import com.fasterxml.jackson.databind.ser.std.StdSerializer;
+
+import org.eclipse.jdt.annotation.NonNull;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime;
+/**
+ * YangToolsMapper is a specific Jackson mapper configuration for opendaylight yangtools serialization or deserialization of DataObject to/from JSON
+ * TODO ChoiceIn and Credentials deserialization only for LoginPasswordBuilder
+ */
+public class YangToolsMapper2<T extends DataObject> extends ObjectMapper {
+
+ private final Logger LOG = LoggerFactory.getLogger(YangToolsMapper2.class);
+ private static final long serialVersionUID = 1L;
+ private static String ENTITY = "Entity";
+ private static String BUILDER = "Builder";
+
+ private @Nullable Class<T> clazz;
+ private @Nullable Class<? extends Builder<? extends T>> builderClazz;
+
+ private BundleContext context;
+
+ public <X extends T, B extends Builder<X>> YangToolsMapper2(Class<T> clazz, Class<B> builderClazz) throws ClassNotFoundException {
+ super();
+ configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+ setPropertyNamingStrategy(PropertyNamingStrategy.KEBAB_CASE);
+ setSerializationInclusion(Include.NON_NULL);
+ setAnnotationIntrospector(new YangToolsBuilderAnnotationIntrospector());
+ SimpleModule dateAndTimeSerializerModule = new SimpleModule();
+ dateAndTimeSerializerModule.addSerializer(DateAndTime.class, new CustomDateAndTimeSerializer());
+ registerModule(dateAndTimeSerializerModule );
+ Bundle bundle = FrameworkUtil.getBundle(YangToolsMapper2.class);
+
+ this.clazz = clazz;
+ this.builderClazz = builderClazz != null ? builderClazz : getBuilderClass(getBuilderClassName(clazz)) ;
+ context = bundle != null ? bundle.getBundleContext() : null;
+ }
+
+ public YangToolsMapper2() throws ClassNotFoundException {
+ this(null, null);
+ }
+
+
+ @Override
+ public String writeValueAsString(Object value) throws JsonProcessingException {
+ return super.writeValueAsString(value);
+ }
+ /**
+ * Get Builder object for yang tools interface.
+ * @param <T> yang-tools base datatype
+ * @param clazz class with interface.
+ * @return builder for interface or null if not existing
+ */
+ @SuppressWarnings("unchecked")
+ public @Nullable <T extends DataObject> Builder<T> getBuilder(Class<T> clazz) {
+ try {
+ //Class<?> clazzBuilder = getBuilderClass(getBuilderClassName(clazz));
+ return (Builder<T>) builderClazz.newInstance();
+ } catch (InstantiationException | IllegalAccessException e) {
+ LOG.debug("Problem ", e);
+ return null;
+ }
+ }
+
+ /**
+ * Callback for handling mapping failures.
+ * @return
+ */
+ public int getMappingFailures() {
+ return 0;
+ }
+
+ /**
+ * Provide mapping of string to attribute names, generated by yang-tools.
+ * "netconf-id" converted to "_netconfId"
+ * @param name with attribute name, not null or empty
+ * @return converted string or null if name was empty or null
+ */
+ public @Nullable static String toCamelCaseAttributeName(final String name) {
+ if (name == null || name.isEmpty())
+ return null;
+
+ final StringBuilder ret = new StringBuilder(name.length());
+ if (!name.startsWith("_"))
+ ret.append('_');
+ int start = 0;
+ for (final String word : name.split("-")) {
+ if (!word.isEmpty()) {
+ if (start++ == 0) {
+ ret.append(Character.toLowerCase(word.charAt(0)));
+ } else {
+ ret.append(Character.toUpperCase(word.charAt(0)));
+ }
+ ret.append(word.substring(1));
+ }
+ }
+ return ret.toString();
+ }
+
+ /** Verify if builder is available
+ * @throws ClassNotFoundException **/
+ public Class<?> assertBuilderClass(Class<?> clazz) throws ClassNotFoundException {
+ return getBuilderClass(getBuilderClassName(clazz));
+ }
+
+ // --- Private functions
+
+ /**
+ * Create name of builder class
+ * @param <T>
+ * @param clazz
+ * @return builders class name
+ * @throws ClassNotFoundException
+ */
+ private static String getBuilderClassName(Class<?> clazz) {
+ return clazz.getName() + BUILDER;
+// String clazzName = clazz.getName();
+// if (clazzName.endsWith(ENTITY)) {
+// return clazzName.replace(ENTITY, BUILDER);
+// } else {
+// return clazzName + BUILDER;
+// }
+ }
+
+ /**
+ * Search builder in context
+ * @param name
+ * @return
+ * @throws ClassNotFoundException
+ */
+ @SuppressWarnings("unchecked")
+ private <X extends T, B extends Builder<X>> Class<B> getBuilderClass(String name) throws ClassNotFoundException {
+ // Try to find in other bundles
+ if (context != null) {
+ //OSGi environment
+ for (Bundle b : context.getBundles()) {
+ try {
+ return (Class<B>) b.loadClass(name);
+ } catch (ClassNotFoundException e) {
+ // No problem, this bundle doesn't have the class
+ }
+ }
+ throw new ClassNotFoundException("Can not find Class in OSGi context.");
+ } else {
+ return (Class<B>) Class.forName(name);
+ }
+ // not found in any bundle
+ }
+
+ // --- Classes
+
+ /**
+ * Adapted Builder callbacks
+ */
+ private class YangToolsBuilderAnnotationIntrospector extends JacksonAnnotationIntrospector {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Class<?> findPOJOBuilder(AnnotatedClass ac) {
+
+ if (ac.getRawType().equals(Credentials.class)) {
+ return org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.credentials.credentials.LoginPasswordBuilder.class;
+
+ } else if (ac.getRawType().equals(DateAndTime.class)) {
+ return DateAndTimeBuilder.class;
+
+ } else if (ac.getRawType().equals(clazz)) {
+ return builderClazz;
+ }
+
+ if (ac.getRawType().isInterface()) {
+ String builder = getBuilderClassName(ac.getRawType());
+ try {
+ Class<?> innerBuilder = getBuilderClass(builder);
+ return innerBuilder;
+ } catch (ClassNotFoundException e) {
+ // No problem .. try next
+ }
+ }
+ return super.findPOJOBuilder(ac);
+ }
+
+ @Override
+ public Value findPOJOBuilderConfig(AnnotatedClass ac) {
+ if (ac.hasAnnotation(JsonPOJOBuilder.class)) {
+ return super.findPOJOBuilderConfig(ac);
+ }
+ return new JsonPOJOBuilder.Value("build", "set");
+ }
+ }
+
+ public static class DateAndTimeBuilder{
+
+ private final String _value;
+
+ public DateAndTimeBuilder(String v) {
+ this._value= v;
+ }
+
+ public DateAndTime build() {
+ return new DateAndTime(_value);
+ }
+
+ }
+ public static class CustomDateAndTimeSerializer extends StdSerializer<@NonNull DateAndTime>{
+
+ private static final long serialVersionUID = 1L;
+
+ public CustomDateAndTimeSerializer() {
+ this(null);
+ }
+ protected CustomDateAndTimeSerializer(Class<DateAndTime> t) {
+ super(t);
+ }
+
+ @Override
+ public void serialize(DateAndTime value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
+ gen.writeString(value.getValue());
+ }
+
+ }
+}
diff --git a/sdnr/wt/data-provider/provider/src/main/resources/about/README.md b/sdnr/wt/data-provider/provider/src/main/resources/about/README.md
new file mode 100644
index 0000000..81c8c6c
--- /dev/null
+++ b/sdnr/wt/data-provider/provider/src/main/resources/about/README.md
@@ -0,0 +1,17 @@
+
+| | |
+| --- | ----- |
+| ONAP release | {release-name} |
+| ONAP release version | {release-version} |
+| Opendaylight release | {odl-version} |
+| ONAP CCSDK version | {ccsdk-version} |
+| Build timestamp | {build-time} |
+| Yangtools version | {yangtools-version} |
+| MD-SAL version | {mdsal-version} |
+| SDN-R packages version | {package-version} ({package-githash}) |
+| ODLUX version | {odlux-revision} |
+| Cluster size | {cluster-size} |
+
+```
+{karaf-info}
+```
\ No newline at end of file
diff --git a/sdnr/wt/data-provider/provider/src/main/resources/about/test.bmp b/sdnr/wt/data-provider/provider/src/main/resources/about/test.bmp
new file mode 100644
index 0000000..d049ea5
--- /dev/null
+++ b/sdnr/wt/data-provider/provider/src/main/resources/about/test.bmp
Binary files differ
diff --git a/sdnr/wt/data-provider/provider/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml b/sdnr/wt/data-provider/provider/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml
new file mode 100644
index 0000000..54575ad
--- /dev/null
+++ b/sdnr/wt/data-provider/provider/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml
@@ -0,0 +1,80 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+============LICENSE_START=======================================================
+ONAP : ccsdk feature sdnr wt data-provider
+ ================================================================================
+Copyright (C) 2019 highstreet technologies GmbH Intellectual Property.
+All rights reserved.
+================================================================================
+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.
+============LICENSE_END=========================================================
+ -->
+
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+ xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0" odl:use-default-for-reference-types="true">
+
+ <reference id="rpcProviderService"
+ interface="org.opendaylight.mdsal.binding.api.RpcProviderService"
+ odl:type="default" />
+
+ <bean id="readyServlet"
+ class="org.onap.ccsdk.features.sdnr.wt.dataprovider.http.ReadyHttpServlet">
+ </bean>
+ <service interface="javax.servlet.http.HttpServlet"
+ ref="readyServlet">
+ <service-properties>
+ <entry key="alias" value="/ready" />
+ </service-properties>
+ </service>
+
+ <bean id="aboutServlet"
+ class="org.onap.ccsdk.features.sdnr.wt.dataprovider.http.AboutHttpServlet">
+ </bean>
+ <service interface="javax.servlet.http.HttpServlet"
+ ref="aboutServlet">
+ <service-properties>
+ <entry key="alias" value="/about" />
+ </service-properties>
+ </service>
+
+ <bean id="msServlet"
+ class="org.onap.ccsdk.features.sdnr.wt.dataprovider.http.MsServlet">
+ </bean>
+ <service interface="javax.servlet.http.HttpServlet" ref="msServlet">
+ <service-properties>
+ <entry key="alias" value="/ms" />
+ </service-properties>
+ </service>
+
+ <bean id="provider"
+ class="org.onap.ccsdk.features.sdnr.wt.dataprovider.impl.DataProviderImpl"
+ init-method="init" destroy-method="close">
+ <property name="rpcProviderService" ref="rpcProviderService" />
+ <property name="aboutServlet" ref="aboutServlet" />
+ <property name="mediatorServerServlet" ref="msServlet" />
+ </bean>
+
+ <bean id="yangServlet"
+ class="org.onap.ccsdk.features.sdnr.wt.dataprovider.http.YangSchemaHttpServlet">
+ </bean>
+ <service interface="javax.servlet.http.HttpServlet"
+ ref="yangServlet">
+ <service-properties>
+ <entry key="alias" value="/yang-schema" />
+ </service-properties>
+ </service>
+
+ <service ref="provider"
+ interface="org.onap.ccsdk.features.sdnr.wt.dataprovider.model.IEntityDataProvider" />
+
+</blueprint>
diff --git a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestAbout.java b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestAbout.java
new file mode 100644
index 0000000..01dc8fc
--- /dev/null
+++ b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestAbout.java
@@ -0,0 +1,131 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
+ * =================================================================================================
+ * 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.
+ * ============LICENSE_END==========================================================================
+ ******************************************************************************/
+
+package org.onap.ccsdk.features.sdnr.wt.dataprovider.test;
+
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.http.AboutHttpServlet;
+
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.StringWriter;
+import java.nio.file.Files;
+import javax.servlet.ServletException;
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+public class TestAbout {
+
+ private static final String REPO_MDSAL_DIR = "system/org/opendaylight/mdsal/mdsal-binding-api/3.0.9/";
+ private static final String REPO_YANGTOOLS_DIR = "system/org/opendaylight/yangtools/odl-yangtools-common/2.1.11";
+ @BeforeClass
+ public static void before() throws IOException {
+ //create temporary odl folder structure in tmp
+ Files.createDirectories(new File(REPO_MDSAL_DIR).toPath() );
+ Files.createDirectories(new File(REPO_YANGTOOLS_DIR).toPath() );
+ }
+ @AfterClass
+ public static void after() throws IOException {
+ //delete created dirs
+ delete(new File("system/"));
+ }
+ private static void delete(File file) throws IOException {
+
+ for (File childFile : file.listFiles()) {
+
+ if (childFile.isDirectory()) {
+ delete(childFile);
+ } else {
+ if (!childFile.delete()) {
+ throw new IOException();
+ }
+ }
+ }
+
+ if (!file.delete()) {
+ throw new IOException();
+ }
+ }
+ @Test
+ public void testReadmeRequest() throws IOException, ServletException {
+ AboutHelperServlet servlet =new AboutHelperServlet();
+ HttpServletRequest request = mock(HttpServletRequest.class);
+ HttpServletResponse response = mock(HttpServletResponse.class);
+ when(request.getRequestURI()).thenReturn("/about");
+ StringWriter out = new StringWriter();
+ ServletOutputStream printOut = new ServletOutputStream() {
+
+ @Override
+ public void write(int arg0) throws IOException {
+ out.write(arg0);
+ }
+ };
+ when(response.getOutputStream()).thenReturn(printOut);
+ servlet.doGet(request,response);
+ verify(response).setStatus(200);
+ verify(response).setContentType("text/plain");
+ System.out.println(out.getBuffer().toString());
+ assertTrue(out.getBuffer().length()>0);
+ }
+
+ @Test
+ public void testReadmeResourceRequest() throws IOException, ServletException {
+ AboutHelperServlet servlet =new AboutHelperServlet();
+ HttpServletRequest request = mock(HttpServletRequest.class);
+ HttpServletResponse response = mock(HttpServletResponse.class);
+ when(request.getRequestURI()).thenReturn("/about/test.bmp");
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ ServletOutputStream printOut = new ServletOutputStream() {
+
+ @Override
+ public void write(int arg0) throws IOException {
+ out.write(arg0);
+ }
+ };
+ when(response.getOutputStream()).thenReturn(printOut);
+ servlet.doGet(request,response);
+ verify(response).setStatus(200);
+ verify(response).setContentType("image/bmp");
+ assertTrue(out.size()>0);
+ }
+
+
+
+ private class AboutHelperServlet extends AboutHttpServlet{
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+ super.doGet(req, resp);
+ }
+
+ }
+}
diff --git a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestCRUDforDatabase.java b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestCRUDforDatabase.java
new file mode 100644
index 0000000..748ad51
--- /dev/null
+++ b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestCRUDforDatabase.java
@@ -0,0 +1,1450 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
+ * =================================================================================================
+ * 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.
+ * ============LICENSE_END==========================================================================
+ ******************************************************************************/
+
+package org.onap.ccsdk.features.sdnr.wt.dataprovider.test;
+
+import static org.junit.Assert.*;
+
+import java.io.IOException;
+import java.math.BigInteger;
+import java.util.Arrays;
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.onap.ccsdk.features.sdnr.wt.common.database.HtDatabaseClient;
+import org.onap.ccsdk.features.sdnr.wt.common.database.SearchHit;
+import org.onap.ccsdk.features.sdnr.wt.common.database.SearchResult;
+import org.onap.ccsdk.features.sdnr.wt.common.database.config.HostInfo;
+import org.onap.ccsdk.features.sdnr.wt.common.database.queries.QueryBuilders;
+import org.onap.ccsdk.features.sdnr.wt.common.database.requests.BaseRequest;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.data.ElasticSearchDataProvider;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.CreateMaintenanceInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.CreateMaintenanceInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.CreateMaintenanceOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.CreateMediatorServerInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.CreateMediatorServerInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.CreateMediatorServerOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.CreateNetworkElementConnectionInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.CreateNetworkElementConnectionInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.CreateNetworkElementConnectionOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.DeleteMaintenanceInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.DeleteMaintenanceInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.DeleteMediatorServerInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.DeleteMediatorServerInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.DeleteNetworkElementConnectionInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.DeleteNetworkElementConnectionInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.Entity;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.GranularityPeriodType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ReadConnectionlogListInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ReadConnectionlogListInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ReadConnectionlogListOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ReadEventlogListInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ReadEventlogListInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ReadEventlogListOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ReadFaultcurrentListInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ReadFaultcurrentListInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ReadFaultcurrentListOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ReadFaultlogListInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ReadFaultlogListInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ReadFaultlogListOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ReadInventoryListInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ReadInventoryListInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ReadInventoryListOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ReadMaintenanceListInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ReadMaintenanceListInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ReadMaintenanceListOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ReadMediatorServerListInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ReadMediatorServerListInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ReadMediatorServerListOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ReadNetworkElementConnectionListInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ReadNetworkElementConnectionListInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ReadNetworkElementConnectionListOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ReadPmdata15mDeviceListInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ReadPmdata15mDeviceListInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ReadPmdata15mDeviceListOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ReadPmdata15mListInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ReadPmdata15mListInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ReadPmdata15mListOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ReadPmdata15mLtpListInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ReadPmdata15mLtpListInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ReadPmdata15mLtpListOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ReadPmdata24hDeviceListInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ReadPmdata24hDeviceListInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ReadPmdata24hDeviceListOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ReadPmdata24hListInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ReadPmdata24hListInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ReadPmdata24hListOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ReadPmdata24hLtpListInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ReadPmdata24hLtpListInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ReadPmdata24hLtpListOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.SeverityType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.UpdateMaintenanceInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.UpdateMaintenanceInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.UpdateMaintenanceOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.UpdateMediatorServerInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.UpdateMediatorServerInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.UpdateMediatorServerOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.UpdateNetworkElementConnectionInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.UpdateNetworkElementConnectionInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.UpdateNetworkElementConnectionOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.entity.input.FilterBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.entity.input.Pagination;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.entity.input.PaginationBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.mediator.server.list.output.Data;
+
+public class TestCRUDforDatabase {
+
+ private static ElasticSearchDataProvider dbProvider;
+ private static HtDatabaseClient dbRawProvider;
+ private static HostInfo[] hosts = new HostInfo[] { new HostInfo("localhost", Integer
+ .valueOf(System.getProperty("databaseport") != null ? System.getProperty("databaseport") : "49200")) };
+
+ @BeforeClass
+ public static void init() throws Exception {
+
+ dbProvider = new ElasticSearchDataProvider(hosts);
+ dbProvider.waitForYellowDatabaseStatus(30, TimeUnit.SECONDS);
+ dbRawProvider = new HtDatabaseClient(hosts);
+ }
+
+ private static void trySleep(long ms) {
+ try {
+ Thread.sleep(ms);
+ } catch (Exception e) {
+ Thread.currentThread().interrupt();
+ }
+ }
+
+ private static void trySleep() {
+ trySleep(0);
+ }
+
+ @Test
+ public void testStatus() throws IOException {
+
+ //== CLEAR AND CREATE ================================
+ clearAndCreatefaultEntity("1", Entity.Faultcurrent.getName(), "org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.CreateFaultcurrentInput", SeverityType.Critical);
+ createFaultEntity("Lorem Ipsum", Entity.Faultcurrent.getName(), "org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.CreateFaultcurrentInput", SeverityType.Major);
+ createFaultEntity("3", Entity.Faultcurrent.getName(), "org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.CreateFaultcurrentInput", SeverityType.Minor);
+ createFaultEntity("4", Entity.Faultcurrent.getName(), "org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.CreateFaultcurrentInput", SeverityType.Warning);
+
+ //== READ ================================
+
+ List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.status.output.Data> readOutput = dbProvider.readStatus().getData();
+ System.out.println(readOutput);
+
+ assertEquals(1,readOutput.get(0).getFaults().getMajors().intValue());
+ assertEquals(1,readOutput.get(0).getFaults().getMinors().intValue());
+ assertEquals(1,readOutput.get(0).getFaults().getWarnings().intValue());
+ assertEquals(1,readOutput.get(0).getFaults().getCriticals().intValue());
+
+ //== DELETE ================================
+
+ System.out.println("try to delete entries");
+ try {
+ dbRawProvider.doRemove(Entity.Faultcurrent.getName(), QueryBuilders.matchAllQuery());
+ } catch (Exception e) {
+ fail("problem deleting entry: " + e.getMessage());
+ }
+
+ //== VERIFY DELETE ===========================
+ System.out.println("verify entries were deleted");
+ readOutput = dbProvider.readStatus().getData();
+ assertEquals(0,readOutput.get(0).getFaults().getMajors().intValue());
+ assertEquals(0,readOutput.get(0).getFaults().getMinors().intValue());
+ assertEquals(0,readOutput.get(0).getFaults().getWarnings().intValue());
+ assertEquals(0,readOutput.get(0).getFaults().getCriticals().intValue());
+ }
+
+ @Test
+ public void testMediatorServer() {
+ final String NAME = "ms1";
+ final String URL = "http://11.23.45.55:4599";
+ final String NAME2 = "ms1-nu";
+ final String URL2 = "http://11.23.45.56:4599";
+
+ // ==CLEAR BEFORE TEST============================
+ System.out.println("try to clear entry");
+ try {
+ dbRawProvider.doRemove(Entity.MediatorServer.getName(), QueryBuilders.matchAllQuery());
+ } catch (Exception e) {
+ fail("problem deleting entry: " + e.getMessage());
+ }
+ trySleep();
+ // ==CREATE============================
+ System.out.println("try to create entry");
+ CreateMediatorServerOutputBuilder createOutput = null;
+ CreateMediatorServerInput input = new CreateMediatorServerInputBuilder().setName(NAME).setUrl(URL).build();
+ String dbId = null;
+
+ try {
+ createOutput = dbProvider.createMediatorServer(input);
+ dbId = createOutput.getId();
+ System.out.println(createOutput);
+ } catch (Exception e) {
+ fail("failed to create " + input.toString() + ":" + e.getMessage());
+ }
+ assertNotNull(createOutput);
+ assertNotNull(dbId);
+ trySleep();
+ // ==READ===========================
+ System.out.println("try to read entry");
+ ReadMediatorServerListInput readinput = new ReadMediatorServerListInputBuilder()
+ .setFilter(Arrays.asList(new FilterBuilder().setProperty("id").setFiltervalue(dbId).build()))
+ .setPagination(getPagination(20, 1)).build();
+ ReadMediatorServerListOutputBuilder readoutput = dbProvider.readMediatorServerList(readinput);
+ List<Data> data = readoutput.getData();
+ assertNotNull(data);
+ assertEquals("no entry found", 1, data.size());
+ assertEquals(NAME, data.get(0).getName());
+ assertEquals(URL, data.get(0).getUrl());
+ String dbId2 = data.get(0).getId();
+ assertEquals(dbId, dbId2);
+ System.out.println(data);
+ // ==UPDATE============================
+ System.out.println("try to update entry");
+ UpdateMediatorServerInput updateInput = new UpdateMediatorServerInputBuilder().setId(dbId2).setName(NAME2)
+ .setUrl(URL2).build();
+ UpdateMediatorServerOutputBuilder updateOutput = null;
+ try {
+ updateOutput = dbProvider.updateMediatorServer(updateInput);
+ System.out.println(updateOutput);
+ } catch (Exception e) {
+ fail("problem updating entry:" + e.getMessage());
+ }
+ assertNotNull(updateOutput);
+ trySleep();
+ // ==READ============================
+ System.out.println("try to read entry");
+ readinput = new ReadMediatorServerListInputBuilder()
+ .setFilter(Arrays.asList(new FilterBuilder().setProperty("name").setFiltervalue(NAME2).build()))
+ .setPagination(getPagination(20, 1)).build();
+ readoutput = dbProvider.readMediatorServerList(readinput);
+ data = readoutput.getData();
+ System.out.println(data);
+ assertNotNull("no update response", data);
+ assertEquals("update not verifiied", 1, data.size());
+ assertEquals("update not verifiied", NAME2, data.get(0).getName());
+ assertEquals("update not verifiied", URL2, data.get(0).getUrl());
+ assertEquals("update not verifiied", dbId, data.get(0).getId());
+ // ==DELETE============================
+ System.out.println("try to delete entry");
+ DeleteMediatorServerInput deleteInput = new DeleteMediatorServerInputBuilder().setId(dbId).build();
+ try {
+ dbProvider.deleteMediatorServer(deleteInput);
+ } catch (Exception e) {
+ fail("problem deleting entry: " + e.getMessage());
+ }
+
+ trySleep();
+ // ==READ/VERIFY DELETE============================
+ System.out.println("try to read entry");
+ readinput = new ReadMediatorServerListInputBuilder()
+ .setFilter(Arrays.asList(new FilterBuilder().setProperty("name").setFiltervalue(NAME2).build()))
+ .setPagination(getPagination(20, 1)).build();
+ readoutput = dbProvider.readMediatorServerList(readinput);
+ data = readoutput.getData();
+ assertNotNull("delete not verifiied", data);
+ assertEquals("delete not verifiied", 0, data.size());
+ }
+
+ @Test
+ public void testNetworkElementConnectionCurrent() {
+
+ System.out.println("networkElementConnection test start");
+
+ // ==CLEAR BEFORE TEST============================
+ System.out.println("try to clear entry");
+ try {
+ dbRawProvider.doRemove(Entity.NetworkelementConnection.getName(), QueryBuilders.matchAllQuery());
+ } catch (Exception e) {
+ fail("problem deleting entry: " + e.getMessage());
+ }
+
+ // ==CREATE============================
+ System.out.println("try to create");
+ final String name = "sim87";
+ final String url = "10.5.10.1";
+ final long port = 5959;
+
+ CreateNetworkElementConnectionOutputBuilder create = null;
+ CreateNetworkElementConnectionInput input = new CreateNetworkElementConnectionInputBuilder().setNodeId(name)
+ .setIsRequired(true).setHost(url).setPort(port).build();
+ String dbId = null;
+
+ try {
+ create = dbProvider.createNetworkElementConnection(input);
+ dbId = create.getId();
+ } catch (Exception e) {
+ fail("networkElementConnection create failed" + e.getMessage());
+ }
+
+ assertNotNull(dbId);
+ assertNotNull(create);
+
+ // ==READ===========================
+
+ ReadNetworkElementConnectionListInput readInput = new ReadNetworkElementConnectionListInputBuilder()
+ .setFilter(Arrays.asList(new FilterBuilder().setProperty("id").setFiltervalue(dbId).build()))
+ .setPagination(getPagination(20, 1)).build();
+
+ ReadNetworkElementConnectionListOutputBuilder readOperation = dbProvider
+ .readNetworkElementConnectionList(readInput);
+ List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.network.element.connection.list.output.Data> data = readOperation
+ .getData();
+
+ assertNotNull(data);
+ assertEquals(dbId, data.get(0).getId());
+ assertEquals(name, data.get(0).getNodeId());
+ assertEquals(url, data.get(0).getHost());
+ assertEquals(port, data.get(0).getPort().longValue());
+
+ // ==UPDATE============================
+ System.out.println("Trying to update...");
+ final String name2 = "sim88";
+ final String url2 = "10.5.10.2";
+ final long port2 = 5960;
+
+ UpdateNetworkElementConnectionInput updateInput = new UpdateNetworkElementConnectionInputBuilder().setId(dbId).setHost(url2).setPort(port2).setIsRequired(false).build();
+ UpdateNetworkElementConnectionOutputBuilder updateOutput = null;
+ try {
+ updateOutput = dbProvider.updateNetworkElementConnection(updateInput);
+ } catch (Exception e) {
+ fail("update failed: " + e.getMessage());
+ }
+
+ assertNotNull(updateOutput);
+
+ // == Verify UPDATE============================
+ System.out.println("Verfiying update...");
+
+ readOperation = dbProvider.readNetworkElementConnectionList(readInput);
+ data = readOperation.getData();
+
+ assertNotNull(data);
+ assertEquals(url2, data.get(0).getHost());
+ assertEquals(port2, data.get(0).getPort().longValue());
+
+ // ==PARTIAL UPDATE============================
+ System.out.println("Try partial update...");
+ assertEquals(false, data.get(0).isIsRequired());
+ updateInput = new UpdateNetworkElementConnectionInputBuilder().setId(dbId).setIsRequired(true).build();
+ try {
+ updateOutput = dbProvider.updateNetworkElementConnection(updateInput);
+ } catch (Exception e) {
+ fail("update failed: " + e.getMessage());
+ }
+
+ assertNotNull(updateOutput);
+
+ readOperation = dbProvider.readNetworkElementConnectionList(readInput);
+ data = readOperation.getData();
+
+ assertEquals(true, data.get(0).isIsRequired());
+ assertEquals(url2, data.get(0).getHost());
+ assertEquals(port2, data.get(0).getPort().longValue());
+
+ // ==DELETE============================
+ System.out.println("Try delete...");
+
+ DeleteNetworkElementConnectionInput deleteInput = new DeleteNetworkElementConnectionInputBuilder().setId(dbId)
+ .build();
+ try {
+ dbProvider.deleteNetworkElementConnection(deleteInput);
+ } catch (Exception e) {
+ fail("problem deleting "+e.getMessage());
+ }
+
+ readInput = new ReadNetworkElementConnectionListInputBuilder()
+ .setFilter(Arrays.asList(new FilterBuilder().setProperty("id").setFiltervalue(dbId).build()))
+ .setPagination(getPagination(20, 1)).build();
+ readOperation = dbProvider.readNetworkElementConnectionList(readInput);
+ data = readOperation.getData();
+ assertEquals(0, data.size());
+
+ }
+
+ @Test
+ public void testMaintenance() {
+ System.out.println("Starting Maintenance tests...");
+
+ // ==CLEAR BEFORE TEST============================
+ System.out.println("try to clear entry");
+ try {
+ dbRawProvider.doRemove(Entity.Maintenancemode.getName(), QueryBuilders.matchAllQuery());
+ } catch (Exception e) {
+ fail("problem deleting entry: " + e.getMessage());
+ }
+
+ // ==CREATE============================
+
+ final String nodeId = "Lorem Ipsum";
+ final boolean isActive = true;
+
+ CreateMaintenanceOutputBuilder create = null;
+ CreateMaintenanceInput input = new CreateMaintenanceInputBuilder().setNodeId(nodeId).setActive(isActive)
+ .build();
+ String dbId = null;
+ try {
+ create = dbProvider.createMaintenance(input);
+ dbId = create.getId();
+ } catch (Exception e) {
+ fail("Failed to create:" + e.getMessage());
+ }
+
+ System.out.println(dbId);
+ assertNotNull(create);
+ assertNotNull(dbId);
+
+ // ==READ===========================
+ System.out.println("Try read...");
+
+ ReadMaintenanceListInput readinput = new ReadMaintenanceListInputBuilder()
+ .setFilter(Arrays.asList(new FilterBuilder().setProperty("id").setFiltervalue(dbId).build()))
+ .setPagination(getPagination(20, 1)).build();
+ ReadMaintenanceListOutputBuilder readResult = dbProvider.readMaintenanceList(readinput);
+ List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.maintenance.list.output.Data> data = readResult
+ .getData();
+
+ assertNotEquals(0, data.size());
+ assertNotNull(data);
+ assertEquals(nodeId, data.get(0).getNodeId());
+ assertEquals(isActive, data.get(0).isActive());
+
+ // ==UPDATE============================
+
+ System.out.println("Trying to update...");
+ final String nodeId2 = "Name2";
+ final boolean isActive2 = false;
+
+ UpdateMaintenanceInput updateInput = new UpdateMaintenanceInputBuilder().setId(dbId).setNodeId(nodeId2)
+ .setActive(isActive2).build();
+ UpdateMaintenanceOutputBuilder updateResult = null;
+ try {
+ updateResult = dbProvider.updateMaintenance(updateInput);
+ } catch (Exception e) {
+ fail("maintenance update failed..." + e.getMessage());
+ }
+
+ assertNotNull(updateResult);
+
+ // == VERIFY UPDATE============================
+ System.out.println("Verfify update...");
+ readResult = dbProvider.readMaintenanceList(readinput);
+ data = readResult.getData();
+
+ assertNotNull(data);
+ assertEquals(nodeId2, data.get(0).getNodeId());
+ assertEquals(isActive2, data.get(0).isActive());
+
+ // ==DELETE================================
+ System.out.println("Trying to delete...");
+
+ DeleteMaintenanceInput deleteInput = new DeleteMaintenanceInputBuilder().setId(dbId).build();
+ try {
+ dbProvider.deleteMaintenance(deleteInput);
+ } catch (Exception e) {
+ fail("Maintenance entry couldn't be deleted" + e.getMessage());
+ }
+
+ readResult = dbProvider.readMaintenanceList(readinput);
+ data = readResult.getData();
+
+ assertEquals(0, data.size());
+ }
+
+ @Test
+ public void testFaultLog() {
+
+ System.out.println("Starting fault log tests...");
+ String dbId = clearAndCreatefaultEntity("1", Entity.Faultlog.getName(), "org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.CreateFaultlogInput", SeverityType.Critical);
+
+ // ==READ===========================
+ System.out.println("try to read entry");
+
+ ReadFaultlogListInput readinput = new ReadFaultlogListInputBuilder()
+ .setFilter(Arrays.asList(new FilterBuilder().setProperty("id").setFiltervalue(dbId).build()))
+ .setPagination(getPagination(20, 1)).build();
+
+ ReadFaultlogListOutputBuilder readResult = null;
+ try {
+ readResult = dbProvider.readFaultLogList(readinput);
+
+ } catch (Exception e) {
+ fail("Fault log not read: " + e.getMessage());
+ }
+
+ List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.faultlog.list.output.Data> data = readResult
+ .getData();
+
+ assertNotNull(data);
+ assertEquals(1, data.size());
+ assertEquals("signalIsLost", data.get(0).getProblem());
+ assertEquals("Critical", data.get(0).getSeverity().toString());
+ assertEquals("s1", data.get(0).getNodeId());
+
+ //== UPDATE ================================
+ System.out.println("try to update entry");
+
+ dbRawProvider.doUpdateOrCreate(Entity.Faultlog.getName(), "1", "{'problem': 'CableLOS', 'severity': 'Major', 'node-id': 'test4657-78'}");
+
+ System.out.println("try to search entry 1");
+ readinput = new ReadFaultlogListInputBuilder()
+ .setFilter(Arrays.asList(new FilterBuilder().setProperty("node-id").setFiltervalue("test").build()))
+ .setPagination(getPagination(20, 1)).build();
+
+ //== VERIFY UPDATE ================================
+ readResult = dbProvider.readFaultLogList(readinput);
+ data = readResult.getData();
+
+
+ assertNotNull(data);
+ System.out.println(data);
+ assertEquals(0, data.size());
+
+ System.out.println("try to search entry 2");
+
+ readinput = new ReadFaultlogListInputBuilder()
+ .setFilter(Arrays.asList(new FilterBuilder().setProperty("node-id").setFiltervalue("test*").build()))
+ .setPagination(getPagination(20, 1)).build();
+
+ readResult = dbProvider.readFaultLogList(readinput);
+ data = readResult.getData();
+
+
+ assertNotNull(data);
+ assertEquals(1, data.size());
+ assertEquals("CableLOS", data.get(0).getProblem());
+ assertEquals("Major", data.get(0).getSeverity().toString());
+ assertEquals("test4657-78", data.get(0).getNodeId());
+
+ //== DELETE ================================
+
+ System.out.println("try to clear entry");
+ try {
+ dbRawProvider.doRemove(Entity.Faultlog.getName(), dbId);
+ } catch (Exception e) {
+ fail("problem deleting entry: " + e.getMessage());
+ }
+
+ //== VERIFY DELETE ===========================
+ System.out.println("verify entries deleted");
+ readResult = dbProvider.readFaultLogList(new ReadFaultlogListInputBuilder().setPagination(getPagination(20, 1)).build());
+ data = readResult.getData();
+ assertEquals(0, data.size());
+ }
+
+ @Test
+ public void testFaultCurrent() {
+ System.out.println("Starting faultCurrent test...");
+ String dbId = null;
+ dbId = clearAndCreatefaultEntity("1", Entity.Faultcurrent.getName(), "org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.CreateFaultcurrentInput", SeverityType.NonAlarmed);
+ assertEquals("1", dbId);
+
+ // ==READ===========================
+ System.out.println("Trying to read...");
+
+
+ ReadFaultcurrentListInput readinput = new ReadFaultcurrentListInputBuilder()
+ .setFilter(Arrays.asList(new FilterBuilder().setProperty("id").setFiltervalue(dbId).build()))
+ .setPagination(getPagination(20, 1)).build();
+
+ ReadFaultcurrentListOutputBuilder readResult = null;
+ try {
+ readResult = dbProvider.readFaultCurrentList(readinput);
+
+ } catch (Exception e) {
+ fail("Fault log not read: " + e.getMessage());
+ }
+
+ List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.faultcurrent.list.output.Data> data = readResult
+ .getData();
+
+
+ assertNotNull(data);
+ assertEquals(1, data.size());
+ assertEquals("signalIsLost", data.get(0).getProblem());
+ assertEquals("NonAlarmed", data.get(0).getSeverity().toString());
+ assertEquals("s1", data.get(0).getNodeId());
+ assertEquals(4340, data.get(0).getCounter().intValue());
+ assertEquals(new DateAndTime("2019-10-28T11:55:58.3Z"), data.get(0).getTimestamp());
+ assertEquals(4340, data.get(0).getCounter().intValue());
+ assertEquals("LP-MWPS-RADIO", data.get(0).getObjectId());
+
+
+ // ==UPDATE============================
+ System.out.println("Trying to update...");
+
+ String json = "{\n" +
+ "\"timestamp\": \"2019-12-28T11:55:58.3Z\",\n" +
+ "\"node-id\": \"SDN-Controller-0\",\n" +
+ "\"counter\": 75,\n" +
+ "\"problem\": \"connectionLossNeOAM\",\n" +
+ "}";
+
+ String updatedDbId = dbRawProvider.doUpdateOrCreate(Entity.Faultcurrent.getName(), dbId, json);
+ assertEquals(dbId, updatedDbId);
+
+ // ==READ============================
+
+ try {
+ readResult = dbProvider.readFaultCurrentList(readinput);
+
+ } catch (Exception e) {
+ fail("Fault log not read: " + e.getMessage());
+ }
+
+ data = readResult.getData();
+
+ assertNotNull(data);
+ assertEquals(1, data.size());
+ assertEquals("connectionLossNeOAM", data.get(0).getProblem());
+ assertEquals("SDN-Controller-0", data.get(0).getNodeId());
+ assertEquals(75, data.get(0).getCounter().intValue());
+ assertEquals("LP-MWPS-RADIO", data.get(0).getObjectId());
+
+ // ==DELETE============================
+ try {
+ dbRawProvider.doRemove(Entity.Faultcurrent.getName(), QueryBuilders.matchAllQuery());
+ } catch (Exception e) {
+ fail("problem deleting: " + e.getMessage());
+ }
+
+ // ==READ/VERIFY DELETE============================
+
+ try {
+ readResult = dbProvider.readFaultCurrentList(readinput);
+
+ } catch (Exception e) {
+ fail("Fault log not read: " + e.getMessage());
+ }
+
+ data = readResult.getData();
+
+ assertNotNull(data);
+ assertEquals(0, data.size());
+ }
+
+ @Test
+ public void testConnectionLog() {
+
+ // ==CLEAR================================
+ System.out.println("Clear before test");
+ try {
+ dbRawProvider.doRemove(Entity.Connectionlog.getName(), QueryBuilders.matchAllQuery());
+ } catch (Exception e) {
+ fail("problem deleting: " + e.getMessage());
+ }
+
+ // ==CREATE================================
+
+ System.out.println("Try create entry");
+ final String initialDbId = "1";
+ String dbId = null;
+ String json ="{\n" +
+ "\"timestamp\": \"2019-11-01T11:28:34.7Z\",\n" +
+ "\"status\": \"Connecting\",\n" +
+ "\"node-id\": \"sim2230\",\n" +
+ "\"implemented-interface\": \"org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.CreateConnectionlogInput\"\n" +
+ "}";
+
+ dbId = dbRawProvider.doUpdateOrCreate(Entity.Connectionlog.getName(), initialDbId, json);
+
+ assertEquals(initialDbId, dbId);
+
+ // ==READ================================
+ System.out.println("Try read entry");
+
+ ReadConnectionlogListInput readinput = new ReadConnectionlogListInputBuilder()
+ .setFilter(Arrays.asList(new FilterBuilder().setProperty("id").setFiltervalue(dbId).build()))
+ .setPagination(getPagination(20, 1)).build();
+
+ ReadConnectionlogListOutputBuilder readResult = null;
+ try {
+ readResult = dbProvider.readConnectionlogList(readinput);
+
+ } catch (Exception e) {
+ fail("Connection log not read: " + e.getMessage());
+ }
+
+ List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.connectionlog.list.output.Data> data = readResult
+ .getData();
+
+ assertNotNull(data);
+ assertEquals(1, data.size());
+ assertEquals("Connecting", data.get(0).getStatus().toString());
+ assertEquals("sim2230", data.get(0).getNodeId());
+
+
+ // ==UPDATE================================
+ System.out.println("Try update entry");
+
+ dbRawProvider.doUpdateOrCreate(Entity.Connectionlog.getName(), dbId, "{'status' : 'Connected'}");
+
+ // ==READ 2================================
+ System.out.println("Try read updated entry");
+
+ readinput = new ReadConnectionlogListInputBuilder()
+ .setFilter(Arrays.asList(new FilterBuilder().setProperty("status").setFiltervalue("Connected").build()))
+ .setPagination(getPagination(20, 1)).build();
+
+ try {
+ readResult = dbProvider.readConnectionlogList(readinput);
+
+ } catch (Exception e) {
+ fail("Connection log not read: " + e.getMessage());
+ }
+
+ data = readResult.getData();
+
+ assertNotNull(data);
+ assertEquals(1, data.size());
+ assertEquals("Connected", data.get(0).getStatus().toString());
+ assertEquals("sim2230", data.get(0).getNodeId());
+
+ //== DELETE ================================
+
+ System.out.println("try to clear entry");
+ try {
+ dbRawProvider.doRemove(Entity.Connectionlog.getName(), dbId);
+ } catch (Exception e) {
+ fail("problem deleting entry: " + e.getMessage());
+ }
+
+ //== VERIFY DELETE ===========================
+ System.out.println("verify entries deleted");
+ readResult = dbProvider.readConnectionlogList(new ReadConnectionlogListInputBuilder().setPagination(getPagination(20, 1)).build());
+ data = readResult.getData();
+ assertEquals(0, data.size());
+
+ }
+
+ @Test
+ public void testEventLog() {
+ System.out.println("Test event log starting...");
+
+ // ==CLEAR================================
+ System.out.println("Clear before test");
+ try {
+ dbRawProvider.doRemove(Entity.Eventlog.getName(), QueryBuilders.matchAllQuery());
+ } catch (Exception e) {
+ fail("problem deleting: " + e.getMessage());
+ }
+ // ==CREATE============================
+
+ String dbId = null;
+ String json = " {\n" +
+ "\"timestamp\": \"2019-11-08T16:39:23.0Z\",\n" +
+ "\"new-value\": \"done\",\n" +
+ "\"object-id\": \"SDN-Controller-0\",\n" +
+ "\"attribute-name\": \"startup\",\n" +
+ "\"counter\": 0,\n" +
+ "\"implemented-interface\": \"org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.Eventlog\",\n" +
+ "\"node-id\": \"SDN-Controller-0\"\n" +
+ "}";
+
+ dbId = dbRawProvider.doUpdateOrCreate(Entity.Eventlog.getName(), "1", json);
+ assertNotNull(dbId);
+
+ // ==READ===========================
+
+ ReadEventlogListInput readinput = new ReadEventlogListInputBuilder()
+ .setFilter(Arrays.asList(new FilterBuilder().setProperty("id").setFiltervalue(dbId).build()))
+ .setPagination(getPagination(20, 1)).build();
+ ReadEventlogListOutputBuilder readResult = null;
+ try {
+ readResult = dbProvider.readEventlogList(readinput);
+
+ } catch (Exception e) {
+ fail("problem reading eventlog");
+ }
+
+ List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.eventlog.list.output.Data> data = readResult.getData();
+ assertEquals(1,data.size());
+
+ //== DELETE ================================
+
+ System.out.println("try to clear entry");
+ try {
+ dbRawProvider.doRemove(Entity.Eventlog.getName(), dbId);
+ } catch (Exception e) {
+ fail("problem deleting entry: " + e.getMessage());
+ }
+
+ //== VERIFY DELETE ===========================
+ System.out.println("verify entries deleted");
+ try {
+ readResult = dbProvider.readEventlogList(new ReadEventlogListInputBuilder().setPagination(getPagination(20, 1)).build());
+ } catch (IOException e) {
+ fail("problem reading eventlog");
+ }
+ data = readResult.getData();
+ assertEquals(0, data.size());
+
+ }
+
+ @Test
+ public void testInventory() {
+
+ System.out.println("Test inventory starting...");
+
+ // ==CLEAR================================
+ System.out.println("Clear before test");
+ try {
+ dbRawProvider.doRemove(Entity.Inventoryequipment.getName(), QueryBuilders.matchAllQuery());
+ } catch (Exception e) {
+ fail("problem deleting: " + e.getMessage());
+ }
+
+
+ // ==CREATE============================
+
+ String dbId = null;
+ String json = " {\"tree-level\": 1,\n" +
+ " \"parent-uuid\": \"SHELF-1.1.0.0\",\n" +
+ " \"node-id\": \"sim2\",\n" +
+ " \"uuid\": \"CARD-1.1.8.0\",\n" +
+ " \"contained-holder\": [ ],\n" +
+ " \"manufacturer-name\": \"Lorem Ipsum\",\n" +
+ " \"manufacturer-identifier\": \"ONF-Wireless-Transport\",\n" +
+ " \"serial\": \"sd-dsa-eqw\",\n" +
+ " \"date\": \"2008-10-21T00:00:00.0Z\",\n" +
+ "\"implemented-interface\": \"org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.Inventory\",\n" +
+ " \"version\": \"unknown\",\n" +
+ " \"description\": \"WS/DS3\",\n" +
+ " \"part-type-id\": \"unknown\",\n" +
+ " \"model-identifier\": \"model-id-s3s\",\n" +
+ " \"type-name\": \"p4.module\"}";
+
+ dbId = dbRawProvider.doUpdateOrCreate(Entity.Inventoryequipment.getName(), "1 1", json);
+ assertNotNull(dbId);
+
+ // ==READ===========================
+ ReadInventoryListInput readinput = new ReadInventoryListInputBuilder()
+ .setFilter(Arrays.asList(new FilterBuilder().setProperty("id").setFiltervalue(dbId).build()))
+ .setPagination(getPagination(20, 1)).build();
+ ReadInventoryListOutputBuilder readResult = null;
+ try {
+ readResult = dbProvider.readInventoryList(readinput);
+
+ } catch (Exception e) {
+ fail("Problem reading inventory list"+e.getMessage());
+ }
+
+ List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.inventory.list.output.Data> data = readResult.getData();
+ assertEquals(1,data.size());
+ assertEquals("Lorem Ipsum", data.get(0).getManufacturerName());
+ assertEquals("ONF-Wireless-Transport", data.get(0).getManufacturerIdentifier());
+ assertEquals("sim2", data.get(0).getNodeId());
+ assertEquals("unknown", data.get(0).getVersion());
+ assertEquals("WS/DS3", data.get(0).getDescription());
+ assertEquals("2008-10-21T00:00:00.0Z", data.get(0).getDate());
+ assertEquals("sd-dsa-eqw", data.get(0).getSerial());
+ System.out.println(data.get(0).getDate());
+
+ // ==UPDATE============================
+ String updatedDbId=null;
+ final String[] holderArray = {"Lorem Ipsum 1", "Lorem Ipsum 2", "Lorem Ipsum &%/$_2"};
+ String updatejson = " {" +
+ " \"node-id\": \"sim5\",\n" +
+ " \"contained-holder\": [ \"Lorem Ipsum 1\", \"Lorem Ipsum 2\", \"Lorem Ipsum &%/$_2\" ],\n" +
+ " \"serial\": \"sd-dsa-eww\",\n" +
+ " \"date\": \"2008-11-21T00:00:00.0Z\",\n" +
+ " \"part-type-id\": \"not unknown\",\n" +
+ "}";
+
+ updatedDbId = dbRawProvider.doUpdateOrCreate(Entity.Inventoryequipment.getName(), dbId, updatejson);
+ assertEquals(dbId, updatedDbId);
+
+ try {
+ readResult = dbProvider.readInventoryList(readinput);
+
+ } catch (Exception e) {
+ fail("Problem reading inventory list"+e.getMessage());
+ }
+
+ data = readResult.getData();
+
+ assertEquals(1,data.size());
+ assertEquals("Lorem Ipsum", data.get(0).getManufacturerName());
+ assertEquals("ONF-Wireless-Transport", data.get(0).getManufacturerIdentifier());
+ assertEquals("sim5", data.get(0).getNodeId());
+ assertEquals("not unknown", data.get(0).getPartTypeId());
+ assertEquals("WS/DS3", data.get(0).getDescription());
+ assertEquals("2008-11-21T00:00:00.0Z", data.get(0).getDate());
+ assertEquals("sd-dsa-eww", data.get(0).getSerial());
+ assertEquals(holderArray.length,data.get(0).getContainedHolder().size());
+ assertEquals(holderArray[0],data.get(0).getContainedHolder().get(0));
+ assertEquals(holderArray[1],data.get(0).getContainedHolder().get(1));
+ assertEquals(holderArray[2],data.get(0).getContainedHolder().get(2));
+
+ // ==DELETE============================
+
+ System.out.println("delete after test");
+ try {
+ dbRawProvider.doRemove(Entity.Inventoryequipment.getName(), QueryBuilders.matchAllQuery());
+ } catch (Exception e) {
+ fail("problem deleting: " + e.getMessage());
+ }
+
+ // ==VERIFY DELETE ============================
+
+ try {
+ readResult = dbProvider.readInventoryList(readinput);
+
+ } catch (Exception e) {
+ fail("Problem reading inventory list"+e.getMessage());
+ }
+
+ data = readResult.getData();
+ assertEquals(0,data.size());
+
+ }
+
+ @Test
+ public void test15MinPerformanceReadLtpListWithoutNodeIdSetThrowsException() {
+
+ System.out.println("Reading 15m ltp list without node id filter set throws an exception test start...");
+
+ try {
+ dbRawProvider.doRemove(Entity.Historicalperformance15min.getName(), QueryBuilders.matchAllQuery());
+ } catch (Exception e) {
+ fail("problem deleting: " + e.getMessage());
+ }
+
+ System.out.println("create entries...");
+
+ createPerformanceData("1", GranularityPeriodType.Period15Min, "PM_RADIO_15M_6", "LP-MWPS-TTP-02", "a2");
+ createPerformanceData("2", GranularityPeriodType.Period15Min, "PM_RADIO_15M_4", "LP-MWPS-TTP-01", "a2");
+
+ createPerformanceData("4", GranularityPeriodType.Period15Min, "PM_RADIO_15M_6", "LP-MWPS-TTP-02", "a3");
+ createPerformanceData("5", GranularityPeriodType.Period15Min, "PM_RADIO_15M_4", "LP-MWPS-TTP-01", "a3");
+ createPerformanceData("6", GranularityPeriodType.Period15Min, "PM_RADIO_15M_7", "LP-MWPS-TTP-03", "a3");
+ createPerformanceData("3", GranularityPeriodType.Period15Min, "PM_RADIO_15M_7", "LP-MWPS-TTP-05", "a3");
+
+ System.out.println("trying to read, should throw exception...");
+
+
+ ReadPmdata15mLtpListInput readLtp = new ReadPmdata15mLtpListInputBuilder()
+ .setPagination(getPagination(20, 1)).build();
+
+ ReadPmdata15mLtpListOutputBuilder readltpResult = null;
+
+ try {
+ readltpResult = dbProvider.readPmdata15mLtpList(readLtp);
+ fail("No exception thrown!");
+ } catch (Exception e) {
+ System.out.println(e);
+ assertTrue(e instanceof IllegalArgumentException);
+ assertEquals("no nodename in filter found ", e.getMessage());
+ }
+
+ assertNull(readltpResult);
+
+ //== DELETE ================================
+
+ System.out.println("try to clear entry");
+ try {
+ dbRawProvider.doRemove(Entity.Historicalperformance15min.getName(), QueryBuilders.matchAllQuery());
+ } catch (Exception e) {
+ fail("problem deleting entry: " + e.getMessage());
+ }
+
+ //== VERIFY DELETE ===========================
+ System.out.println("verify entries deleted");
+ List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.pmdata._15m.list.output.Data> data = dbProvider.readPmdata15mList(new ReadPmdata15mListInputBuilder()
+ .setPagination(getPagination(20, 1)).build()).getData();
+
+ assertEquals(0, data.size());
+ }
+
+ @Test
+ public void test15MinPerformanceData() {
+ // == CLEAR BEFORE TESTS ============================
+ System.out.println("Test 15 min performance...");
+
+ try {
+ dbRawProvider.doRemove(Entity.Historicalperformance15min.getName(), QueryBuilders.matchAllQuery());
+ } catch (Exception e) {
+ fail("problem deleting: " + e.getMessage());
+ }
+
+ // == CREATE ============================
+
+ System.out.println("create entries...");
+
+ createPerformanceData("1", GranularityPeriodType.Period15Min, "PM_RADIO_15M_6", "LP-MWPS-TTP-02", "a2");
+ createPerformanceData("2", GranularityPeriodType.Period15Min, "PM_RADIO_15M_4", "LP-MWPS-TTP-01", "a2");
+
+ createPerformanceData("4", GranularityPeriodType.Period15Min, "PM_RADIO_15M_6", "LP-MWPS-TTP-02", "a3");
+ createPerformanceData("5", GranularityPeriodType.Period15Min, "PM_RADIO_15M_4", "LP-MWPS-TTP-01", "a3");
+ createPerformanceData("6", GranularityPeriodType.Period15Min, "PM_RADIO_15M_7", "LP-MWPS-TTP-03", "a3");
+ createPerformanceData("3", GranularityPeriodType.Period15Min, "PM_RADIO_15M_7", "LP-MWPS-TTP-05", "a3");
+
+ // == READ ============================
+ System.out.println("read list entries...");
+
+ ReadPmdata15mListInput read = new ReadPmdata15mListInputBuilder()
+ .setFilter(Arrays.asList(new FilterBuilder().setProperty("node-name").setFiltervalue("a2").build()))
+ .setPagination(getPagination(20, 1)).build();
+
+ ReadPmdata15mListOutputBuilder readResult = null;
+
+ try {
+ readResult = dbProvider.readPmdata15mList(read);
+ } catch (Exception e) {
+ fail("Problem reading 15m data");
+ }
+
+ List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.pmdata._15m.list.output.Data> data = readResult
+ .getData();
+
+ assertNotNull(data);
+ assertEquals(2, data.size());
+
+ System.out.println("read ltp entries with node name set...");
+
+ ReadPmdata15mLtpListInput readLtp = new ReadPmdata15mLtpListInputBuilder()
+ .setFilter(Arrays.asList(new FilterBuilder().setProperty("node-name").setFiltervalue("a2").build()))
+ .setPagination(getPagination(20, 1)).build();
+
+ ReadPmdata15mLtpListOutputBuilder readltpResult = null;
+
+ try {
+ readltpResult = dbProvider.readPmdata15mLtpList(readLtp);
+ } catch (Exception e) {
+ fail("Problem reading 15m ltp data");
+ }
+
+ List<String> dataLtp = readltpResult.getData();
+
+ assertNotNull(dataLtp);
+ assertEquals(2, dataLtp.size());
+ assertTrue(dataLtp.contains("LP-MWPS-TTP-02"));
+ assertTrue(dataLtp.contains("LP-MWPS-TTP-01"));
+
+ System.out.println("read device entries...");
+
+ ReadPmdata15mDeviceListInput readDevices = new ReadPmdata15mDeviceListInputBuilder()
+ .setPagination(getPagination(20, 1)).build();
+
+ ReadPmdata15mDeviceListOutputBuilder readDeviceResult = null;
+
+ try {
+ readDeviceResult = dbProvider.readPmdata15mDeviceList(readDevices);
+ } catch (Exception e) {
+ fail("Problem reading 15m device data");
+ }
+
+ List<String> dataDevice = readDeviceResult.getData();
+
+ assertNotNull(dataDevice);
+ assertEquals(2, dataDevice.size());
+ assertTrue(dataDevice.contains("a2"));
+ assertTrue(dataDevice.contains("a3"));
+
+ //== DELETE ================================
+
+ System.out.println("try to clear entry");
+ try {
+ dbRawProvider.doRemove(Entity.Historicalperformance15min.getName(), QueryBuilders.matchAllQuery());
+ } catch (Exception e) {
+ fail("problem deleting entry: " + e.getMessage());
+ }
+
+ //== VERIFY DELETE ===========================
+ System.out.println("verify entries deleted");
+ readResult = dbProvider.readPmdata15mList(new ReadPmdata15mListInputBuilder()
+ .setPagination(getPagination(20, 1)).build());
+ data = readResult.getData();
+ assertEquals(0, data.size());
+
+ }
+
+ @Test
+ public void test24hPerformanceData() {
+ System.out.println("Test 24h performance...");
+
+ try {
+ dbRawProvider.doRemove(Entity.Historicalperformance24h.getName(), QueryBuilders.matchAllQuery());
+ } catch (Exception e) {
+ fail("problem deleting: " + e.getMessage());
+ }
+
+ System.out.println("create entries...");
+ GranularityPeriodType timeInterval = GranularityPeriodType.Period24Hours;
+ createPerformanceData("1", timeInterval, "PM_RADIO_15M_6", "LP-MWPS-TTP-02", "a2");
+ createPerformanceData("2", timeInterval, "PM_RADIO_15M_4", "LP-MWPS-TTP-01", "a2");
+ String aDbId = createPerformanceData("4", timeInterval, "PM_RADIO_15M_6", "LP-MWPS-TTP-06", "a2");
+
+ createPerformanceData("5", timeInterval, "PM_RADIO_15M_4", "LP-MWPS-TTP-01", "a3");
+ createPerformanceData("6", timeInterval, "PM_RADIO_15M_7", "LP-MWPS-TTP-03", "a3");
+ createPerformanceData("3", timeInterval, "PM_RADIO_15M_7", "LP-MWPS-TTP-05", "a3");
+
+ System.out.println("read all list entries...");
+
+ ReadPmdata24hListInput read = new ReadPmdata24hListInputBuilder()
+ .setPagination(getPagination(20, 1)).build();
+
+ ReadPmdata24hListOutputBuilder readResult = null;
+
+ try {
+ readResult = dbProvider.readPmdata24hList(read);
+ } catch (Exception e) {
+ fail("Problem reading 24h data");
+ }
+
+ List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.pmdata._24h.list.output.Data> data = readResult
+ .getData();
+
+ assertNotNull(data);
+ assertEquals(6, data.size());
+
+
+ System.out.println("filter list entries...");
+
+ read = new ReadPmdata24hListInputBuilder()
+ .setFilter(Arrays.asList(new FilterBuilder().setProperty("node-name").setFiltervalue("a2").build()))
+ .setPagination(getPagination(20, 1)).build();
+
+ readResult = null;
+
+ try {
+ readResult = dbProvider.readPmdata24hList(read);
+ } catch (Exception e) {
+ fail("Problem reading 24h data");
+ }
+
+ data = readResult.getData();
+
+ assertNotNull(data);
+ assertEquals(3, data.size());
+
+ System.out.println("read ltp entries with node name set...");
+
+ ReadPmdata24hLtpListInput readLtp = new ReadPmdata24hLtpListInputBuilder()
+ .setFilter(Arrays.asList(new FilterBuilder().setProperty("node-name").setFiltervalue("a2").build()))
+ .setPagination(getPagination(20, 1)).build();
+
+ ReadPmdata24hLtpListOutputBuilder readltpResult = null;
+
+ try {
+ readltpResult = dbProvider.readPmdata24hLtpList(readLtp);
+ } catch (Exception e) {
+ fail("Problem reading 24h ltp data");
+ }
+
+ List<String> dataLtp = readltpResult.getData();
+
+ assertNotNull(dataLtp);
+ assertEquals(3, dataLtp.size());
+ assertTrue(dataLtp.contains("LP-MWPS-TTP-02"));
+ assertTrue(dataLtp.contains("LP-MWPS-TTP-01"));
+ assertTrue(dataLtp.contains("LP-MWPS-TTP-06"));
+
+
+ System.out.println("read device entries...");
+
+ ReadPmdata24hDeviceListInput readDevices = new ReadPmdata24hDeviceListInputBuilder()
+ .setPagination(getPagination(20, 1)).build();
+
+ ReadPmdata24hDeviceListOutputBuilder readDeviceResult = null;
+
+ try {
+ readDeviceResult = dbProvider.readPmdata24hDeviceList(readDevices);
+ } catch (Exception e) {
+ fail("Problem reading 24h device data");
+ }
+
+ List<String> dataDevice = readDeviceResult.getData();
+
+ assertNotNull(dataDevice);
+ assertEquals(2, dataDevice.size());
+ assertTrue(dataDevice.contains("a2"));
+ assertTrue(dataDevice.contains("a3"));
+
+ // == UPDATE ==============================
+
+ String shouldbeEmpty = dbRawProvider.doUpdate(Entity.Historicalperformance24h.getName(), "{'uuid-interface':'LTP-TEST-MWP-097'}", QueryBuilders.termQuery("_id", aDbId));
+ assertEquals("",shouldbeEmpty);
+ try {
+ readltpResult = dbProvider.readPmdata24hLtpList(readLtp);
+ } catch (Exception e) {
+ fail("Problem reading 24h ltp data");
+ }
+
+ // == VERIFY UPDATE ==============================
+
+ dataLtp = readltpResult.getData();
+
+ assertNotNull(dataLtp);
+ assertEquals(3, dataLtp.size());
+ assertTrue(dataLtp.contains("LP-MWPS-TTP-02"));
+ assertTrue(dataLtp.contains("LP-MWPS-TTP-01"));
+ assertTrue(dataLtp.contains("LTP-TEST-MWP-097"));
+
+
+
+ //== DELETE ===========================
+
+ System.out.println("try to clear entries");
+ try {
+ dbRawProvider.doRemove(Entity.Historicalperformance24h.getName(), QueryBuilders.matchAllQuery());
+ } catch (Exception e) {
+ fail("problem deleting entry: " + e.getMessage());
+ }
+
+ //== VERIFY DELETE ===========================
+ System.out.println("verify entries deleted");
+ readResult = dbProvider.readPmdata24hList(new ReadPmdata24hListInputBuilder()
+ .setPagination(getPagination(20, 1)).build());
+ data = readResult.getData();
+ assertEquals(0, data.size());
+ }
+
+ @Test
+ public void test24hPerformanceDataReadLtpListWithoutNodeIdSetThrowsException() {
+ System.out.println("Test 24 hour tp list without node id filter set throws an exception test start...\"...");
+
+ try {
+ dbRawProvider.doRemove(Entity.Historicalperformance24h.getName(), QueryBuilders.matchAllQuery());
+ } catch (Exception e) {
+ fail("problem deleting: " + e.getMessage());
+ }
+
+ System.out.println("create entries...");
+
+ GranularityPeriodType timeInterval = GranularityPeriodType.Period24Hours;
+ createPerformanceData("1", timeInterval, "PM_RADIO_15M_6", "LP-MWPS-TTP-02", "a2");
+ createPerformanceData("2", timeInterval, "PM_RADIO_15M_4", "LP-MWPS-TTP-01", "a2");
+
+ createPerformanceData("4", timeInterval, "PM_RADIO_15M_6", "LP-MWPS-TTP-02", "a3");
+ createPerformanceData("5", timeInterval, "PM_RADIO_15M_4", "LP-MWPS-TTP-01", "a3");
+ createPerformanceData("6", timeInterval, "PM_RADIO_15M_7", "LP-MWPS-TTP-03", "a3");
+ createPerformanceData("3", timeInterval, "PM_RADIO_15M_7", "LP-MWPS-TTP-05", "a3");
+
+ System.out.println("trying to read, should throw exception...");
+
+
+ ReadPmdata24hLtpListInput readLtp = new ReadPmdata24hLtpListInputBuilder()
+ .setPagination(getPagination(20, 1)).build();
+
+ ReadPmdata24hLtpListOutputBuilder readltpResult = null;
+
+ try {
+ readltpResult = dbProvider.readPmdata24hLtpList(readLtp);
+ fail("No exception thrown!");
+ } catch (Exception e) {
+ System.out.println(e);
+ assertTrue(e instanceof IllegalArgumentException);
+ assertEquals("no nodename in filter found ", e.getMessage());
+ }
+
+ assertNull(readltpResult);
+
+ try {
+ dbRawProvider.doRemove(Entity.Historicalperformance24h.getName(), QueryBuilders.matchAllQuery());
+ } catch (Exception e) {
+ fail("problem deleting: " + e.getMessage());
+ }
+ }
+
+ @Test
+ public void testUrlEncoding() {
+ System.out.println("Testing url encding");
+
+ final String test = "Lorem Ipsum";
+ final String test1 = "Lorem/Ipsum";
+ final String test2 = "Lorem_Ipsum";
+ final String test3 = "Lorem%Ipsum";
+
+ assertEquals("Lorem%20Ipsum", BaseRequest.urlEncodeValue(test));
+ assertEquals("Lorem%2FIpsum", BaseRequest.urlEncodeValue(test1));
+ assertEquals("Lorem_Ipsum", BaseRequest.urlEncodeValue(test2));
+ assertEquals("Lorem%25Ipsum", BaseRequest.urlEncodeValue(test3));
+ }
+
+ @Test
+ public void testDoUpdateOrCreateWithNullId() {
+ System.out.println("Test DoUpdateOrCreate doesn't create new database entry if null is passed");
+
+ String dbId = clearAndCreatefaultEntity(null, Entity.Faultlog.getName(), "org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.CreateFaultlogInput", SeverityType.Critical);
+ assertNull(dbId);
+ }
+
+ @Test
+ public void readTestFaultCurrentViaRawDbProvider() {
+ System.out.println("Starting faultCurrent test...");
+ String dbId = null;
+ dbId = clearAndCreatefaultEntity("1", Entity.Faultcurrent.getName(), "org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.CreateFaultcurrentInput", SeverityType.Critical);
+ assertEquals("1", dbId);
+
+ // ==READ===========================
+ System.out.println("Trying to read...");
+
+ String readResult = null;
+ try {
+ readResult = dbRawProvider.doReadJsonData(Entity.Faultcurrent.getName(), dbId);
+
+ } catch (Exception e) {
+ fail("Fault log not read: " + e.getMessage());
+ }
+
+
+ String expectedDbResult ="{\"severity\":\"Critical\",\"node-id\":\"s1\",\"problem\":\"signalIsLost\",\"counter\":4340,\"object-id\":\"LP-MWPS-RADIO\",\"implemented-interface\":\"org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.CreateFaultcurrentInput\",\"type\":\"ProblemNotificationXml\",\"timestamp\":\"2019-10-28T11:55:58.3Z\"}";
+
+ System.out.println(readResult);
+ assertNotNull(readResult);
+ assertEquals(expectedDbResult, readResult);
+
+ SearchResult<SearchHit> searchResult = dbRawProvider.doReadAllJsonData(Entity.Faultcurrent.getName());
+ assertNotNull(searchResult);
+
+ List<SearchHit> hits = searchResult.getHits();
+
+ assertNotNull(hits);
+ assertEquals(1, searchResult.getTotal());
+ assertEquals(expectedDbResult, hits.get(0).getSourceAsString());
+
+ //== DELETE ==============================
+ try {
+ dbRawProvider.doRemove(Entity.Faultcurrent.getName(), QueryBuilders.matchAllQuery());
+ } catch (Exception e) {
+ fail("problem deleting: " + e.getMessage());
+ }
+ //== VERIFY DELETE ========================
+ searchResult = dbRawProvider.doReadAllJsonData(Entity.Faultcurrent.getName());
+ hits = searchResult.getHits();
+ assertNotNull(hits);
+ assertEquals(0, searchResult.getTotal());
+
+ }
+
+
+ private Pagination getPagination(long pageSize, int page) {
+ return new PaginationBuilder().setPage(BigInteger.valueOf(page)).setSize(pageSize).build();
+ }
+
+
+ private String clearAndCreatefaultEntity(String initialDbId, String entityType, String implementedInterface, SeverityType severity) {
+ // ==CLEAR BEFORE TEST============================
+ System.out.println("try to clear entry");
+ try {
+ dbRawProvider.doRemove(entityType, QueryBuilders.matchAllQuery());
+ } catch (Exception e) {
+ fail("problem deleting: " + e.getMessage());
+ }
+
+
+ return createFaultEntity(initialDbId, entityType, implementedInterface, severity);
+ }
+
+ private String createFaultEntity(String initialDbId, String entityType, String implementedInterface, SeverityType severity) {
+ // ==CREATE============================
+ System.out.println("try to create entry");
+ String dbId = null;
+
+ try {
+
+ dbId = dbRawProvider.doUpdateOrCreate(entityType, initialDbId,"{\n" +
+ "\"timestamp\": \"2019-10-28T11:55:58.3Z\",\n" +
+ "\"object-id\": \"LP-MWPS-RADIO\",\n" +
+ "\"severity\": \""+severity.toString()+"\",\n" +
+ "\"node-id\": \"s1\",\n" +
+ "\"implemented-interface\": \""+implementedInterface+"\",\n" +
+ "\"counter\": 4340,\n" +
+ "\"problem\": \"signalIsLost\",\n" +
+ "\"type\": \"ProblemNotificationXml\"\n" +
+ "}");
+
+
+
+ } catch (Exception e) {
+ fail("Problem creating fault log entry" + e.getMessage());
+ }
+
+ return dbId;
+ }
+
+ private String createPerformanceData(String initialDbId, GranularityPeriodType timeInterval, String scannerId, String uuidInterface, String nodename) {
+
+ String json = "{\n" +
+ "\"node-name\": \""+nodename+"\",\n" +
+ "\"uuid-interface\": \""+uuidInterface+"\",\n" +
+ "\"layer-protocol-name\": \"MWPS\",\n" +
+ "\"radio-signal-id\": \"Test8\",\n" +
+ "\"time-stamp\": \"2017-03-01T06:15:00.0Z\",\n" +
+ "\"granularity-period\": \""+timeInterval.toString()+"\",\n" +
+ "\"scanner-id\": \""+scannerId+"\",\n" +
+ "\"performance-data\": {\n" +
+ "\"cses\": 0,\n" +
+ "\"ses\": 0,\n" +
+ "\"es\": 0,\n" +
+ "\"tx-level-max\": 3,\n" +
+ "\"tx-level-avg\": 3,\n" +
+ "\"rx-level-min\": -44,\n" +
+ "\"rx-level-max\": -45,\n" +
+ "\"rx-level-avg\": -44,\n" +
+ "\"time2-states\": 0,\n" +
+ "\"time4-states-s\": 0,\n" +
+ "\"time4-states\": 0,\n" +
+ "\"time8-states\": -1,\n" +
+ "\"time16-states-s\": -1,\n" +
+ "\"time16-states\": 0,\n" +
+ "\"time32-states\": -1,\n" +
+ "\"time64-states\": 900,\n" +
+ "\"time128-states\": -1,\n" +
+ "\"time256-states\": -1,\n" +
+ "\"time512-states\": -1,\n" +
+ "\"time512-states-l\": -1,\n" +
+ "\"unavailability\": 0,\n" +
+ "\"tx-level-min\": 3,\n" +
+ "\"time1024-states\": -1,\n" +
+ "\"time1024-states-l\": -1,\n" +
+ "\"time2048-states\": -1,\n" +
+ "\"time2048-states-l\": -1,\n" +
+ "\"time4096-states\": -1,\n" +
+ "\"time4096-states-l\": -1,\n" +
+ "\"time8192-states\": -1,\n" +
+ "\"time8192-states-l\": -1,\n" +
+ "\"snir-min\": -99,\n" +
+ "\"snir-max\": -99,\n" +
+ "\"snir-avg\": -99,\n" +
+ "\"xpd-min\": -99,\n" +
+ "\"xpd-max\": -99,\n" +
+ "\"xpd-avg\": -99,\n" +
+ "\"rf-temp-min\": -99,\n" +
+ "\"rf-temp-max\": -99,\n" +
+ "\"rf-temp-avg\": -99,\n" +
+ "\"defect-blocks-sum\": -1,\n" +
+ "\"time-period\": 900\n" +
+ "},\n" +
+ "\"suspect-interval-flag\": false\n" +
+ "}";
+
+ if(timeInterval.equals(GranularityPeriodType.Period15Min)) {
+ return dbRawProvider.doUpdateOrCreate(Entity.Historicalperformance15min.getName(), initialDbId, json);
+ }else {
+ return dbRawProvider.doUpdateOrCreate(Entity.Historicalperformance24h.getName(), initialDbId, json);
+ }
+ }
+
+}
diff --git a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestConfig.java b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestConfig.java
new file mode 100644
index 0000000..7ff547f
--- /dev/null
+++ b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestConfig.java
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
+ * =================================================================================================
+ * 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.
+ * ============LICENSE_END==========================================================================
+ ******************************************************************************/
+package org.onap.ccsdk.features.sdnr.wt.dataprovider.test;
+
+import static org.junit.Assert.*;
+
+import java.io.File;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.ccsdk.features.sdnr.wt.common.configuration.ConfigurationFileRepresentation;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.impl.EsConfig;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class TestConfig {
+
+ private static final Logger LOG = LoggerFactory.getLogger(TestConfig.class);
+
+ private static final String TESTFILENAME = "testconfig.properties";
+
+ @After
+ @Before
+ public void afterAndBefore() {
+ File f=new File(TESTFILENAME);
+ if(f.exists()) {
+ LOG.info("Remove {}", f.getAbsolutePath());
+ f.delete();
+ }
+ }
+ @Test
+ public void test() {
+ ConfigurationFileRepresentation configuration=new ConfigurationFileRepresentation(TESTFILENAME);
+
+ EsConfig esConfig = new EsConfig(configuration);
+ LOG.info("Defaultconfiguration: {}", esConfig.toString());
+ assertEquals("http", esConfig.getHosts()[0].protocol.getValue());
+ assertEquals(9200, esConfig.getHosts()[0].port);
+ assertEquals("sdnrdb", esConfig.getHosts()[0].hostname);
+
+ }
+
+}
diff --git a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestConfiguration.java b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestConfiguration.java
new file mode 100644
index 0000000..62d2bb5
--- /dev/null
+++ b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestConfiguration.java
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * ============LICENSE_START======================================================= ONAP : ccsdk
+ * feature sdnr wt ================================================================================
+ * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
+ * ================================================================================ 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. ============LICENSE_END=========================================================
+ ******************************************************************************/
+package org.onap.ccsdk.features.sdnr.wt.dataprovider.test;
+
+import java.io.File;
+
+import org.junit.Test;
+import org.onap.ccsdk.features.sdnr.wt.common.configuration.ConfigurationFileRepresentation;
+import org.onap.ccsdk.features.sdnr.wt.common.configuration.exception.ConfigurationException;
+import org.onap.ccsdk.features.sdnr.wt.common.util.ResourceFileLoader;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.impl.EsConfig;
+
+public class TestConfiguration {
+
+ private static final String CONFIGURATIONTESTFILE = "test.properties"; // for
+
+ @Test
+ public void test1() throws ConfigurationException {
+
+ System.out.println("Configuration file " + CONFIGURATIONTESTFILE);
+
+ File testConfigurationFile = ResourceFileLoader.getFile(this, CONFIGURATIONTESTFILE);
+ System.out.println("Located at: "+testConfigurationFile.getAbsolutePath());
+
+ ConfigurationFileRepresentation configuration = new ConfigurationFileRepresentation(testConfigurationFile);
+
+ System.out.println("Configuration: " + configuration.getSection(EsConfig.SECTION_MARKER_ES));
+ EsConfig esConfig1 = new EsConfig(configuration);
+
+ System.out.println("ES config getArchiveLifetimeSeconds: "+esConfig1.getArchiveLifetimeSeconds());
+
+
+ // fail("Not yet implemented");
+ }
+
+ @Test
+ public void test2() {
+
+ }
+
+
+}
diff --git a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestDataMappings.java b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestDataMappings.java
new file mode 100644
index 0000000..5171aed
--- /dev/null
+++ b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestDataMappings.java
@@ -0,0 +1,206 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
+ * =================================================================================================
+ * 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.
+ * ============LICENSE_END==========================================================================
+ ******************************************************************************/
+package org.onap.ccsdk.features.sdnr.wt.dataprovider.test;
+
+import java.io.IOException;
+import java.util.List;
+import org.junit.Test;
+import org.onap.ccsdk.features.sdnr.wt.common.database.DatabaseClient;
+import org.onap.ccsdk.features.sdnr.wt.common.database.HtDatabaseClient;
+import org.onap.ccsdk.features.sdnr.wt.common.database.SearchHit;
+import org.onap.ccsdk.features.sdnr.wt.common.database.SearchResult;
+import org.onap.ccsdk.features.sdnr.wt.common.database.config.HostInfo;
+import org.onap.ccsdk.features.sdnr.wt.common.database.queries.QueryBuilder;
+import org.onap.ccsdk.features.sdnr.wt.common.database.responses.SearchResponse;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.EsDataObjectReaderWriter;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.yangtools.YangToolsMapper;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.pmdata._15m.list.output.Data;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+
+public class TestDataMappings {
+
+ private static final HostInfo[] HOSTINFOS = new HostInfo[] {HostInfo.getDefault()};
+ //public static final String ESDATATYPENAME = "faultcurrent";
+
+ private static class HtDatabaseClientHelper extends HtDatabaseClient {
+
+ private final String json;
+
+ public HtDatabaseClientHelper(String jsonResponse, HostInfo[] hosts) {
+ super(hosts);
+ this.json = jsonResponse;
+
+ }
+
+ @Override
+ public SearchResult<SearchHit> doReadByQueryJsonData(String dataTypeName, QueryBuilder qb) {
+ return new SearchResult<>(new SearchResponse(this.json).getHits());
+ }
+ }
+
+ private static class MapResult<T extends DataObject> {
+ public final List<T> mappedData;
+ public MapResult(String dataType, Class<T> cls, String dbJson) throws ClassNotFoundException {
+ System.out.println(dbJson);
+ DatabaseClient db = new HtDatabaseClientHelper(dbJson,HOSTINFOS);
+ EsDataObjectReaderWriter<T> dbrw=new EsDataObjectReaderWriter<>(db,dataType,cls);
+ this.mappedData=dbrw.doReadAll().getHits();
+ }
+ }
+
+ private static final String SEARCHJSON_FORMAT = "{\n" +
+ "\"took\": 0,\n" +
+ "\"timed_out\": false,\n" +
+ "\"_shards\": {\n" +
+ "\"total\": 5,\n" +
+ "\"successful\": 5,\n" +
+ "\"skipped\": 0,\n" +
+ "\"failed\": 0\n" +
+ "},\n" +
+ "\"hits\": {\n" +
+ "\"total\": 1,\n" +
+ "\"max_score\": 1,\n" +
+ "\"hits\": [\n" +
+ "{\n" +
+ "\"_index\": \"%s\",\n" +
+ "\"_type\": \"%s\",\n" +
+ "\"_id\": \"%s\",\n" +
+ "\"_score\": 1,\n" +
+ "\"_source\": %s}\n" +
+ "]\n" +
+ "}\n" +
+ "}";
+
+ private static final String MEDIATORSERVER_DB_ID="LumwSG0BFvcE3yf8MBM5";
+ private static final String MEDIATOR_SERVERDB_JSON = "{\"url\":\"https://10.45.44.223:7590\",\"name\":\"test mediator server\"}";
+
+ private static final String FAULTCURRENT_DB_ID="LumwSG0BFvcE3yf8MBM5";
+ private static final String FAULTCURRENT_DB_NODEID = "sim1";
+ private static final int FAULTCURRENT_DB_COUNTER = 3;
+ private static final String FAULTCURRENT_DB_OBJECTID = "LPS-MWT-01";
+ private static final String FAULTCURRENT_DB_PROBLEM = "rlsExceeded";
+ private static final String FAULTCURRENT_DB_SEVERITY = "critical";
+ private static final DateAndTime FAULTCURRENT_DB_TIMESTAMP = DateAndTime.getDefaultInstance("2019-09-18T13:07:05.8Z");
+
+ private static final String FAULTCURRENT_SERVERDB_JSON = "{\"node-id\":\""+FAULTCURRENT_DB_NODEID+"\","+
+ "\"counter\":"+FAULTCURRENT_DB_COUNTER+","+
+ "\"object-id\":\""+FAULTCURRENT_DB_OBJECTID+"\","+
+ "\"problem\":\""+FAULTCURRENT_DB_PROBLEM+"\","+
+ "\"timestamp\":\""+FAULTCURRENT_DB_TIMESTAMP.getValue()+"\","+
+ "\"severity\":\""+FAULTCURRENT_DB_SEVERITY+"\""+
+ "}";
+
+
+ private static final String PMDATA15M_SERVERDB_JSON="{\n" +
+ "\"node-name\": \"sim2\",\n" +
+ "\"uuid-interface\": \"LP-MWPS-TTP-01\",\n" +
+ "\"layer-protocol-name\": \"MWPS\",\n" +
+ "\"radio-signal-id\": \"Test11\",\n" +
+ "\"time-stamp\": \"2017-07-04T14:00:00.0Z\",\n" +
+ "\"granularity-period\": \"PERIOD_15MIN\",\n" +
+ "\"scanner-id\": \"PM_RADIO_15M_9\",\n" +
+ "\"performance-data\": {\n" +
+ "\"es\": 0,\n" +
+ "\"rx-level-avg\": -41,\n" +
+ "\"time2-states\": -1,\n" +
+ "\"time4-states-s\": 0,\n" +
+ "\"time4-states\": 0,\n" +
+ "\"time8-states\": 0,\n" +
+ "\"time16-states-s\": -1,\n" +
+ "\"time16-states\": 0,\n" +
+ "\"time32-states\": 0,\n" +
+ "\"time64-states\": 0,\n" +
+ "\"time128-states\": 0,\n" +
+ "\"time256-states\": 900,\n" +
+ "\"time512-states\": -1,\n" +
+ "\"time512-states-l\": -1,\n" +
+ "\"time1024-states\": -1,\n" +
+ "\"time1024-states-l\": -1,\n" +
+ "\"time2048-states\": -1,\n" +
+ "\"time2048-states-l\": -1,\n" +
+ "\"time4096-states\": -1,\n" +
+ "\"time4096-states-l\": -1,\n" +
+ "\"time8192-states\": -1,\n" +
+ "\"time8192-states-l\": -1,\n" +
+ "\"snir-min\": -99,\n" +
+ "\"snir-max\": -99,\n" +
+ "\"snir-avg\": -99,\n" +
+ "\"xpd-min\": -99,\n" +
+ "\"xpd-max\": -99,\n" +
+ "\"xpd-avg\": -99,\n" +
+ "\"rf-temp-min\": -99,\n" +
+ "\"rf-temp-max\": -99,\n" +
+ "\"rf-temp-avg\": -99,\n" +
+ "\"defect-blocks-sum\": -1,\n" +
+ "\"time-period\": 900,\n" +
+ "\"tx-level-min\": 25,\n" +
+ "\"tx-level-max\": 25,\n" +
+ "\"tx-level-avg\": 25,\n" +
+ "\"rx-level-min\": -41,\n" +
+ "\"rx-level-max\": -41,\n" +
+ "\"unavailability\": 0,\n" +
+ "\"ses\": 0,\n" +
+ "\"cses\": 0\n" +
+ "},\n" +
+ "\"suspect-interval-flag\": false\n" +
+ "}";
+
+ //@Test
+// public void testMediatorServer() throws ClassNotFoundException {
+//
+// MapResult<EsMediatorServer> result = new MapResult<EsMediatorServer>(EsMediatorServer.ESDATATYPENAME,
+// EsMediatorServer.class,
+// getSearchJson(EsMediatorServer.ESDATATYPENAME,MEDIATORSERVER_DB_ID,MEDIATOR_SERVERDB_JSON));
+// assertEquals("test mediator server", result.mappedData.get(0).getName());
+// assertEquals("https://10.45.44.223:7590", result.mappedData.get(0).getUrl());
+// assertEquals(MEDIATORSERVER_DB_ID, result.mappedData.get(0).getId());
+//
+// }
+ //@Test
+// public void testFaultCurrent() {
+//
+// MapResult<FaultcurrentEntity> result = new MapResult<FaultcurrentEntity>(ESDATATYPENAME, EsFaultCurrent.class,
+// getSearchJson(ESDATATYPENAME, FAULTCURRENT_DB_ID, FAULTCURRENT_SERVERDB_JSON));
+// assertEquals(FAULTCURRENT_DB_ID, result.mappedData.get(0).getId());
+// assertEquals(FAULTCURRENT_DB_NODEID, result.mappedData.get(0).getNodeId());
+// assertEquals(FAULTCURRENT_DB_COUNTER, result.mappedData.get(0).getCounter().intValue());
+// assertEquals(FAULTCURRENT_DB_OBJECTID, result.mappedData.get(0).getObjectId());
+// assertEquals(FAULTCURRENT_DB_PROBLEM, result.mappedData.get(0).getProblem());
+// assertEquals(FAULTCURRENT_DB_SEVERITY, result.mappedData.get(0).getSeverity());
+// assertEquals(FAULTCURRENT_DB_TIMESTAMP, result.mappedData.get(0).getTimestamp());
+// }
+//
+ @Test
+ public void testPmData15m() {
+
+ YangToolsMapper mapper = new YangToolsMapper();
+ try {
+ Data data =mapper.readValue(PMDATA15M_SERVERDB_JSON.getBytes(), Data.class);
+ System.out.println(data);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+
+ }
+ private String getSearchJson(String dataType,String dbId, String source) {
+ return String.format(SEARCHJSON_FORMAT,dataType,dataType, dbId,source);
+ }
+
+}
diff --git a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestFilterConversion.java b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestFilterConversion.java
new file mode 100644
index 0000000..94381b6
--- /dev/null
+++ b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestFilterConversion.java
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
+ * =================================================================================================
+ * 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.
+ * ============LICENSE_END==========================================================================
+ ******************************************************************************/
+package org.onap.ccsdk.features.sdnr.wt.dataprovider.test;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.junit.Test;
+import org.onap.ccsdk.features.sdnr.wt.common.database.queries.QueryBuilder;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.data.QueryByFilter;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.entity.input.Filter;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.entity.input.FilterBuilder;
+
+public class TestFilterConversion {
+
+ private static final String PROPERTY = "node-id";
+
+ @Test
+ public void testQuestionMark() {
+ List<Filter> filters = Arrays.asList(new FilterBuilder().setProperty(PROPERTY).setFiltervalue("si?ba").build());
+ QueryBuilder query = QueryByFilter.fromFilter(filters );
+ System.out.println(query.toJSON());
+ }
+}
diff --git a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestInitalMaintenanceObjectInDatabase.java b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestInitalMaintenanceObjectInDatabase.java
new file mode 100644
index 0000000..6339125
--- /dev/null
+++ b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestInitalMaintenanceObjectInDatabase.java
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
+ * =================================================================================================
+ * 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.
+ * ============LICENSE_END==========================================================================
+ ******************************************************************************/
+package org.onap.ccsdk.features.sdnr.wt.dataprovider.test;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+/**
+ * - Handling of inital values for Maintenance mode.
+ */
+public class TestInitalMaintenanceObjectInDatabase {
+
+ //@Test
+ public void test() {
+ fail("Not yet implemented");
+ }
+
+}
diff --git a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestNetconfNodeBuilder.java b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestNetconfNodeBuilder.java
new file mode 100644
index 0000000..0f502f8
--- /dev/null
+++ b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestNetconfNodeBuilder.java
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
+ * =================================================================================================
+ * 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.
+ * ============LICENSE_END==========================================================================
+ ******************************************************************************/
+package org.onap.ccsdk.features.sdnr.wt.dataprovider.test;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNode;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNodeBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.credentials.Credentials;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.credentials.credentials.LoginPassword;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.credentials.credentials.LoginPasswordBuilder;
+
+public class TestNetconfNodeBuilder {
+
+ @SuppressWarnings("deprecation")
+ //@Test
+ public void test() {
+
+ NetconfNodeBuilder netconfNodeBuilder = new NetconfNodeBuilder();
+
+ LoginPasswordBuilder loginPasswordBuilder = new LoginPasswordBuilder();
+ loginPasswordBuilder.setUsername("myTestUsername");
+ loginPasswordBuilder.setPassword("myTestPassword");
+ netconfNodeBuilder.setCredentials(loginPasswordBuilder.build());
+
+ NetconfNode netconfNode = netconfNodeBuilder.build();
+ System.out.println(netconfNode);
+
+ Credentials credentials = netconfNode.getCredentials();
+ System.out.println("Class: "+credentials.getClass()+"\nContent: "+credentials);
+
+ if (credentials instanceof LoginPassword) {
+ LoginPassword loginPassword = (LoginPassword)credentials;
+ System.out.println("User: "+loginPassword.getUsername()+" Password"+loginPassword.getPassword());
+ } else {
+ System.out.println("Not expected class");
+ }
+ }
+
+}
diff --git a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestNetconfTimestamp.java b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestNetconfTimestamp.java
new file mode 100644
index 0000000..d125af1
--- /dev/null
+++ b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestNetconfTimestamp.java
@@ -0,0 +1,88 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
+ * =================================================================================================
+ * 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.
+ * ============LICENSE_END==========================================================================
+ ******************************************************************************/
+package org.onap.ccsdk.features.sdnr.wt.dataprovider.test;
+
+import static org.junit.Assert.*;
+
+import java.util.Calendar;
+import java.util.Date;
+import java.util.TimeZone;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.junit.Test;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.NetconfTimeStamp;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.types.NetconfTimeStampImpl;
+
+public class TestNetconfTimestamp {
+
+
+ private static final String regex = "[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\\.?[0-9]?Z";
+ private static final String NETCONF_DEF_MILLIS_STRING = "2020-01-09T05:40:41.1Z";
+ private static final String NETCONF_DEF_MILLIS_STRING_MALFORMAED = "2020-01-09T05:40:41:0Z";
+ private static final String NETCONF_DEF2_MILLIS_STRING = "2020-01-09T05:40:41.111Z";
+ private static final String NETCONF_DEF3_MILLIS_STRING = "2020-01-09T05:40:41Z";
+ private static final String NETCONF_DEF3_MILLIS_STRING_CORRECTED = "2020-01-09T05:40:41.0Z";
+ private static final String NETCONF_DEF4_MILLIS_STRING_MALFORMAED = "2020-01-09T05:40:41.0000Z";
+ private static final long NETCONF_DEF_MILLIS_LONG = 1578548441100L;
+
+ private static NetconfTimeStamp converter =NetconfTimeStampImpl.getConverter();
+
+ @Test
+ public void test() {
+ String ts = converter.getTimeStampAsNetconfString();
+ final Pattern pattern = Pattern.compile(regex, Pattern.MULTILINE);
+ final Matcher matcher = pattern.matcher(ts);
+ assertTrue(matcher.find());
+ }
+ @Test
+ public void testMillis() {
+ long millis=converter.getTimeStampFromNetconfAsMilliseconds(NETCONF_DEF_MILLIS_STRING);
+ assertEquals(NETCONF_DEF_MILLIS_LONG,millis);
+
+ }
+ @Test(expected = IllegalArgumentException.class)
+ public void testMillisMalformed() {
+ long millis=converter.getTimeStampFromNetconfAsMilliseconds(NETCONF_DEF_MILLIS_STRING_MALFORMAED);
+
+ }
+
+ @Test
+ public void test2() {
+ assertEquals(NETCONF_DEF_MILLIS_STRING,converter.getTimeStampFromNetconf(NETCONF_DEF2_MILLIS_STRING));
+ assertEquals(NETCONF_DEF3_MILLIS_STRING_CORRECTED,converter.getTimeStampFromNetconf(NETCONF_DEF3_MILLIS_STRING));
+ assertTrue(converter.getTimeStampFromNetconf(NETCONF_DEF4_MILLIS_STRING_MALFORMAED).startsWith("Malformed"));
+ }
+
+ @Test
+ public void test3() {
+ Date dt = converter.getDateFromNetconf(NETCONF_DEF_MILLIS_STRING);
+ final Calendar c = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
+ c.setTime(dt);
+ assertEquals(2020,c.get(Calendar.YEAR));
+ assertEquals(0,c.get(Calendar.MONTH));
+ assertEquals(9,c.get(Calendar.DAY_OF_MONTH));
+ assertEquals(5,c.get(Calendar.HOUR_OF_DAY));
+ assertEquals(40,c.get(Calendar.MINUTE));
+ assertEquals(41,c.get(Calendar.SECOND));
+ assertEquals(100,c.get(Calendar.MILLISECOND));
+
+
+ assertEquals(NETCONF_DEF_MILLIS_STRING,converter.getTimeStampAsNetconfString(dt));
+ }
+}
diff --git a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestNuMappings.java b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestNuMappings.java
new file mode 100644
index 0000000..7f7c971
--- /dev/null
+++ b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestNuMappings.java
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
+ * =================================================================================================
+ * 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.
+ * ============LICENSE_END==========================================================================
+ ******************************************************************************/
+package org.onap.ccsdk.features.sdnr.wt.dataprovider.test;
+
+import com.fasterxml.jackson.core.JsonParseException;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.JsonMappingException;
+import java.io.IOException;
+import org.junit.Test;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.yangtools.YangToolsMapper;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.Faultcurrent;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.FaultcurrentBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.SeverityType;
+
+public class TestNuMappings {
+
+ @Test
+ public void test33() {
+ Faultcurrent c = new FaultcurrentBuilder().setSeverity(SeverityType.Critical).build();
+ YangToolsMapper mapper = new YangToolsMapper();
+ try {
+ System.out.println(mapper.writeValueAsString(c)+"<=>"+SeverityType.Critical.getName());
+ } catch (JsonProcessingException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ try {
+ Faultcurrent f=mapper.readValue( "{\"severity\":\"Critical\"}", Faultcurrent.class);
+ System.out.println(f);
+ System.out.println(mapper.writeValueAsString(f));
+ } catch (JsonParseException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (JsonMappingException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestTimestampFilter.java b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestTimestampFilter.java
new file mode 100644
index 0000000..c32149b
--- /dev/null
+++ b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestTimestampFilter.java
@@ -0,0 +1,137 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
+ * =================================================================================================
+ * 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.
+ * ============LICENSE_END==========================================================================
+ ******************************************************************************/
+package org.onap.ccsdk.features.sdnr.wt.dataprovider.test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.json.JSONObject;
+import org.junit.Test;
+import org.onap.ccsdk.features.sdnr.wt.common.database.queries.QueryBuilder;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.data.QueryByFilter;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.entity.input.Filter;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.entity.input.FilterBuilder;
+
+public class TestTimestampFilter {
+
+
+
+ @Test
+ public void testTimestampRange() {
+ final String PROPERTY_TIMESTAMP = "timestamp";
+ List<Filter> filters = Arrays.asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2017*").build());
+ QueryBuilder query= QueryByFilter.fromFilter(filters );
+ assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2017-01-01T00:00:00.0Z", "2018-01-01T00:00:00.0Z");
+
+ filters = Arrays.asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2*").build());
+ query= QueryByFilter.fromFilter(filters );
+ assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2000-01-01T00:00:00.0Z", "3000-01-01T00:00:00.0Z");
+
+ filters = Arrays.asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("20*").build());
+ query= QueryByFilter.fromFilter(filters );
+ assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2000-01-01T00:00:00.0Z", "2100-01-01T00:00:00.0Z");
+
+ filters = Arrays.asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("205*").build());
+ query= QueryByFilter.fromFilter(filters );
+ assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2050-01-01T00:00:00.0Z", "2060-01-01T00:00:00.0Z");
+
+ filters = Arrays.asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2050*").build());
+ query= QueryByFilter.fromFilter(filters );
+ assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2050-01-01T00:00:00.0Z", "2051-01-01T00:00:00.0Z");
+
+ filters = Arrays.asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2050-*").build());
+ query= QueryByFilter.fromFilter(filters );
+ assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2050-01-01T00:00:00.0Z", "2051-01-01T00:00:00.0Z");
+
+ filters = Arrays.asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2050-1*").build());
+ query= QueryByFilter.fromFilter(filters );
+ assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2050-10-01T00:00:00.0Z", "2051-01-01T00:00:00.0Z");
+
+ filters = Arrays.asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2050-10*").build());
+ query= QueryByFilter.fromFilter(filters );
+ assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2050-10-01T00:00:00.0Z", "2050-11-01T00:00:00.0Z");
+
+ filters = Arrays.asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2050-10-*").build());
+ query= QueryByFilter.fromFilter(filters );
+ assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2050-10-01T00:00:00.0Z", "2050-11-01T00:00:00.0Z");
+
+ filters = Arrays.asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2050-10-0*").build());
+ query= QueryByFilter.fromFilter(filters );
+ assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2050-10-01T00:00:00.0Z", "2050-10-10T00:00:00.0Z");
+
+ filters = Arrays.asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2050-10-02*").build());
+ query= QueryByFilter.fromFilter(filters );
+ assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2050-10-02T00:00:00.0Z", "2050-10-03T00:00:00.0Z");
+
+ filters = Arrays.asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2050-10-14*").build());
+ query= QueryByFilter.fromFilter(filters );
+ assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2050-10-14T00:00:00.0Z", "2050-10-15T00:00:00.0Z");
+
+ filters = Arrays.asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2050-10-14T*").build());
+ query= QueryByFilter.fromFilter(filters );
+ assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2050-10-14T00:00:00.0Z", "2050-10-15T00:00:00.0Z");
+
+ filters = Arrays.asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2050-10-14T1*").build());
+ query= QueryByFilter.fromFilter(filters );
+ assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2050-10-14T10:00:00.0Z", "2050-10-14T20:00:00.0Z");
+
+ filters = Arrays.asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2050-10-14T12*").build());
+ query= QueryByFilter.fromFilter(filters );
+ assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2050-10-14T12:00:00.0Z", "2050-10-14T13:00:00.0Z");
+
+ filters = Arrays.asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2050-10-14T12:*").build());
+ query= QueryByFilter.fromFilter(filters );
+ assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2050-10-14T12:00:00.0Z", "2050-10-14T13:00:00.0Z");
+
+ filters = Arrays.asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2050-10-14T12:4*").build());
+ query= QueryByFilter.fromFilter(filters );
+ assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2050-10-14T12:40:00.0Z", "2050-10-14T12:50:00.0Z");
+
+ filters = Arrays.asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2050-10-14T12:42*").build());
+ query= QueryByFilter.fromFilter(filters );
+ assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2050-10-14T12:42:00.0Z", "2050-10-14T12:43:00.0Z");
+
+ filters = Arrays.asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2050-10-14T12:42:*").build());
+ query= QueryByFilter.fromFilter(filters );
+ assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2050-10-14T12:42:00.0Z", "2050-10-14T12:43:00.0Z");
+
+ filters = Arrays.asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2050-10-14T12:42:5*").build());
+ query= QueryByFilter.fromFilter(filters );
+ assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2050-10-14T12:42:50.0Z", "2050-10-14T12:43:00.0Z");
+
+ filters = Arrays.asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2050-10-14T12:42:56*").build());
+ query= QueryByFilter.fromFilter(filters );
+ assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2050-10-14T12:42:56.0Z", "2050-10-14T12:42:57.0Z");
+ }
+ private void assertRange(JSONObject rangeQuery,String property,String lower,String upper) {
+ System.out.println("==test for "+rangeQuery.toString());
+ assertTrue(rangeQuery.has("range"));
+ assertTrue(rangeQuery.getJSONObject("range").has(property));
+ JSONObject o=rangeQuery.getJSONObject("range").getJSONObject(property);
+ assertNotNull(o);
+ assertTrue(o.has("lt"));
+ assertEquals(upper, o.getString("lt"));
+ assertTrue(o.has("gte"));
+ assertEquals(lower, o.getString("gte"));
+ System.out.println("succeeded");
+ }
+}
diff --git a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestYangCloning.java b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestYangCloning.java
new file mode 100644
index 0000000..95e9c0b
--- /dev/null
+++ b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestYangCloning.java
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
+ * =================================================================================================
+ * 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.
+ * ============LICENSE_END==========================================================================
+ ******************************************************************************/
+
+package org.onap.ccsdk.features.sdnr.wt.dataprovider.test;
+
+import java.util.Arrays;
+
+import org.junit.Test;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.Faultcurrent;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.FaultcurrentEntity;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.InventoryBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.InventoryEntity;
+
+public class TestYangCloning {
+/*
+ @Test
+ public void testEquipment() {
+ EquipmentBuilder equipmentBuilder = new EquipmentBuilder();
+ equipmentBuilder.setUuid( new UniversalId("EquipmentId"));
+ equipmentBuilder.setContainedHolder(Arrays.asList(new ContainedHolderBuilder()
+ .setUuid(new UniversalId("HolderId"))
+ .setAdministrativeState(AdministrativeState.Locked)
+ .setSupportedEquipment(Arrays.asList("eq1"))
+ .build()));
+ Equipment equipment = equipmentBuilder.build();
+ InventoryEntity output = YangToolsCloner.instance().cloneToBuilder(equipment, new InventoryBuilder())
+ .setNodeId("node1").setUuid("a.a.a").setId("node1"+"/"+"a.a.a").build();
+
+
+ System.out.println("source:");
+ System.out.println(equipment);
+ System.out.println("result:");
+ System.out.println(output);
+
+
+ }
+ @Test
+ public void testFaultCurrent() {
+ ProblemNotificationXml source = new ProblemNotificationXml("node", "uuid", "problem", InternalSeverity.Critical,54,InternalDateAndTime.getTestpattern());
+ FaultcurrentEntity output = YangToolsCloner.instance().clone(source,Faultcurrent.class);
+
+ System.out.println("source:");
+ System.out.println(source);
+ System.out.println("result:");
+ System.out.println(output);
+ }
+ */
+}
diff --git a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestYangGenSalMapping.java b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestYangGenSalMapping.java
new file mode 100644
index 0000000..271b268
--- /dev/null
+++ b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestYangGenSalMapping.java
@@ -0,0 +1,406 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
+ * =================================================================================================
+ * 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.
+ * ============LICENSE_END==========================================================================
+ ******************************************************************************/
+package org.onap.ccsdk.features.sdnr.wt.dataprovider.test;
+
+import java.io.IOException;
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
+import org.json.JSONObject;
+import org.junit.Test;
+import org.onap.ccsdk.features.sdnr.wt.common.database.DatabaseClient;
+import org.onap.ccsdk.features.sdnr.wt.common.database.HtDatabaseClient;
+import org.onap.ccsdk.features.sdnr.wt.common.database.SearchResult;
+import org.onap.ccsdk.features.sdnr.wt.common.database.config.HostInfo;
+import org.onap.ccsdk.features.sdnr.wt.common.database.config.HostInfo.Protocol;
+import org.onap.ccsdk.features.sdnr.wt.common.database.queries.BoolQueryBuilder;
+import org.onap.ccsdk.features.sdnr.wt.common.database.queries.QueryBuilder;
+import org.onap.ccsdk.features.sdnr.wt.common.database.queries.QueryBuilders;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.EsDataObjectReaderWriter;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.yangtools.YangToolsMapper;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNode;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNodeBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.parameters.OdlHelloMessageCapabilitiesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.credentials.credentials.LoginPasswordBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.CreateMediatorServerInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.Entity;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.EntityInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ReadPmdata15mListInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ReadPmdata15mListInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ReadPmdata15mListOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.SortOrder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.entity.input.Filter;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.entity.input.PaginationBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.entity.input.Sortorder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.pmdata15m.entity.PerformanceDataBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.pmdata._15m.list.output.Data;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.pmdata._15m.list.output.DataBuilder;
+import org.opendaylight.yangtools.concepts.Builder;
+import org.opendaylight.yangtools.yang.binding.DataContainer;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+
+public class TestYangGenSalMapping {
+
+ // Create mapper for serialization and deserialization
+ YangToolsMapper mapper = new YangToolsMapper();
+
+ @Test
+ public void test1() throws IOException {
+
+ // Create test object
+ NetconfNodeBuilder netconfNodeBuilder = new NetconfNodeBuilder();
+ netconfNodeBuilder.setConnectedMessage("ConnMessage");
+
+ LoginPasswordBuilder loginPasswordBuilder = new LoginPasswordBuilder();
+ loginPasswordBuilder.setUsername("myTestUsername");
+ loginPasswordBuilder.setPassword("myTestPassword");
+ netconfNodeBuilder.setCredentials(loginPasswordBuilder.build());
+
+ OdlHelloMessageCapabilitiesBuilder odlHelloMessageCapabilitiesBuilder = new OdlHelloMessageCapabilitiesBuilder();
+ List<Uri> uriList = new ArrayList<>();
+ uriList.add( new Uri("test.uri") );
+ odlHelloMessageCapabilitiesBuilder.setCapability(uriList);
+ netconfNodeBuilder.setOdlHelloMessageCapabilities(odlHelloMessageCapabilitiesBuilder.build());
+
+ NetconfNode netconfNode = netconfNodeBuilder.build();
+ out(netconfNode.toString());
+
+ // Map Object to JSON String
+ String res = mapper.writeValueAsString(netconfNode);
+ JSONObject json = new JSONObject(res); // Convert text to object
+ out(json.toString(4)); // Print it with specified indentation
+
+ // Map to JSON String to Object
+ NetconfNode generatedNode = mapper.readValue(res.getBytes(), NetconfNode.class);
+ out(generatedNode.toString()); // Print it with specified indentation
+ // Compare result
+ out("Equal? "+netconfNode.equals(generatedNode));
+ }
+
+ static class TestDataObjectBuilder implements Builder<TestDataObject> {
+ @Override
+ public @NonNull TestDataObject build() throws IllegalArgumentException {
+ return new TestDataObject();
+ }
+ }
+
+ static class TestDataObject implements DataObject {
+ String test;
+
+ @Override
+ public Class<? extends DataContainer> getImplementedInterface() {
+ return null;
+ }
+ }
+
+ @Test
+ public void test2() throws ClassNotFoundException {
+
+ int databasePort = Integer.valueOf(System.getProperty("databaseport")!=null?System.getProperty("databaseport"):"49200");
+ System.out.println("DB Port: "+databasePort);
+
+ HostInfo[] HOSTINFOS = new HostInfo[] { new HostInfo("localhost", databasePort ,Protocol.HTTP)};
+ DatabaseClient db = new HtDatabaseClient(HOSTINFOS);
+
+ EsDataObjectReaderWriter<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.inventory.list.output.Data> dataRW =
+ new EsDataObjectReaderWriter<>(db, "inventorytest", org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.inventory.list.output.Data.class);
+
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.inventory.list.output.Data d1;
+ d1 = getInventoryDataBuilder("MyDescription", 23L).build();
+ String id = dataRW.write(d1,null);
+
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.inventory.list.output.Data d2;
+ d2 = dataRW.read(id);
+
+ out(d2.toString());
+
+ }
+
+ @Test
+ public void test3() throws IOException {
+
+ PerformanceDataBuilder performanceBuilder = new PerformanceDataBuilder();
+ performanceBuilder.setEs(99);
+ DataBuilder pmData15MinutesBuilder = new DataBuilder();
+ pmData15MinutesBuilder.setLayerProtocolName("fdsaf");
+ pmData15MinutesBuilder.setTimeStamp(new DateAndTime("2017-03-01T09:15:00.0Z"));
+ pmData15MinutesBuilder.setPerformanceData(performanceBuilder.build());
+
+ // Map Object to JSON String
+ String res = mapper.writeValueAsString(pmData15MinutesBuilder.build());
+ JSONObject json = new JSONObject(res); // Convert text to object
+ out(json.toString(4)); // Print it with specified indentation
+
+ // Map to JSON String to Object
+ Data generatedNode = mapper.readValue(res.getBytes(), Data.class);
+ out(generatedNode.toString()); // Print it with specified indentation
+ }
+
+ @Test
+ public void test4() throws IOException {
+
+ String jsonString = "{\n" + "\"node-name\": \"Sim2230\",\n" + "\"uuid-interface\": \"LP-MWPS-TTP-RADIO\",\n"
+ + "\"layer-protocol-name\": \"MWPS\",\n" + "\"radio-signal-id\": \"Test8\",\n"
+ + "\"time-stamp\": \"2017-03-01T09:15:00.0Z\",\n" + "\"granularity-period\": \"Period15Min\",\n"
+ + "\"scanner-id\": \"PM_RADIO_15M_4\",\n" + "\"performance-data\": {\n" + "\"unavailability\": 0,\n"
+ + "\"tx-level-max\": 3,\n" + "\"tx-level-avg\": 3,\n" + "\"rx-level-min\": -44,\n"
+ + "\"rx-level-max\": -45,\n" + "\"rx-level-avg\": -44,\n" + "\"time2-states\": 0,\n"
+ + "\"time4-states-s\": 0,\n" + "\"time4-states\": 0,\n" + "\"time8-states\": -1,\n"
+ + "\"time16-states-s\": -1,\n" + "\"time16-states\": 0,\n" + "\"time32-states\": -1,\n"
+ + "\"time64-states\": 900,\n" + "\"time128-states\": -1,\n" + "\"time256-states\": -1,\n"
+ + "\"time512-states\": -1,\n" + "\"time512-states-l\": -1,\n" + "\"time1024-states\": -1,\n"
+ + "\"time1024-states-l\": -1,\n" + "\"time8192-states-l\": -1,\n" + "\"time8192-states\": -1,\n"
+ + "\"time2048-states\": -1,\n" + "\"snir-min\": -99,\n" + "\"snir-max\": -99,\n"
+ + "\"snir-avg\": -99,\n" + "\"xpd-min\": -99,\n" + "\"xpd-max\": -99,\n" + "\"xpd-avg\": -99,\n"
+ + "\"rf-temp-min\": -99,\n" + "\"rf-temp-max\": -99,\n" + "\"rf-temp-avg\": -99,\n"
+ + "\"defect-blocks-sum\": -1,\n" + "\"time-period\": 900,\n" + "\"cses\": 0,\n"
+ + "\"time4096-states-l\": -1,\n" + "\"tx-level-min\": 3,\n" + "\"es\": 0,\n"
+ + "\"time2048-states-l\": -1,\n" + "\"time4096-states\": -1,\n" + "\"ses\": 0\n" + "},\n"
+ + "\"suspect-interval-flag\": false\n" + "}\n" + "}";
+ // Map to JSON String to Object
+ Data generatedNode = mapper.readValue(jsonString.getBytes(), Data.class);
+ out(generatedNode.toString()); // Print it with specified indentation
+
+ }
+
+
+ @Test
+ public void test5() throws IOException {
+ String jsonString = "{\n" +
+ " \"time-stamp\": \"2017-03-01T06:45:00.0Z\",\n" +
+ " \"node-name\": \"Sim2230\",\n" +
+ " \"uuid-interface\": \"LP-MWPS-TTP-RADIO\",\n" +
+ " \"scanner-id\": \"PM_RADIO_15M_14\",\n" +
+ " \"layer-protocol-name\": \"MWPS\",\n" +
+ " \"granularity-period\": \"Period15Min\",\n" +
+ " \"radio-signal-id\": \"Test8\",\n" +
+ " \"suspect-interval-flag\": false,\n" +
+ " \"performance-data\": {\n" +
+ " \"time4096-states-l\": -1,\n" +
+ " \"time16-states-s\": -1,\n" +
+ " \"tx-level-max\": 3,\n" +
+ " \"snir-max\": -99,\n" +
+ " \"time16-states\": 0,\n" +
+ " \"time64-states\": 900,\n" +
+ " \"unavailability\": 0,\n" +
+ " \"time8192-states-l\": -1,\n" +
+ " \"time512-states\": -1,\n" +
+ " \"xpd-min\": -99,\n" +
+ " \"xpd-avg\": -99,\n" +
+ " \"tx-level-avg\": 3,\n" +
+ " \"tx-level-min\": 3,\n" +
+ " \"rf-temp-min\": -99,\n" +
+ " \"rf-temp-avg\": -99,\n" +
+ " \"snir-avg\": -99,\n" +
+ " \"snir-min\": -99,\n" +
+ " \"time-period\": 900,\n" +
+ " \"time2-states\": 0,\n" +
+ " \"time4-states\": 0,\n" +
+ " \"time8-states\": -1,\n" +
+ " \"ses\": 0,\n" +
+ " \"time2048-states-l\": -1,\n" +
+ " \"time2048-states\": -1,\n" +
+ " \"xpd-max\": -99,\n" +
+ " \"rf-temp-max\": -99,\n" +
+ " \"time8192-states\": -1,\n" +
+ " \"time128-states\": -1,\n" +
+ " \"time256-states\": -1,\n" +
+ " \"rx-level-min\": -44,\n" +
+ " \"rx-level-avg\": -44,\n" +
+ " \"time1024-states-l\": -1,\n" +
+ " \"es\": 0,\n" +
+ " \"cses\": 0,\n" +
+ " \"time4-states-s\": 0,\n" +
+ " \"time1024-states\": -1,\n" +
+ " \"time512-states-l\": -1,\n" +
+ " \"time4096-states\": -1,\n" +
+ " \"rx-level-max\": -45,\n" +
+ " \"defect-blocks-sum\": -1,\n" +
+ " \"time32-states\": -1\n" +
+ " }\n" +
+ "}";
+
+ // Map to JSON String to Object
+ Data generatedNode = mapper.readValue(jsonString.getBytes(), Data.class);
+ out(generatedNode.toString()); // Print it with specified indentation
+
+ }
+
+
+ @Test
+ public void test6() throws IOException, ClassNotFoundException {
+ out(method());
+ HtDatabaseClient dbClient = new HtDatabaseClient(new HostInfo[] { new HostInfo("sdnrdb", 9200, Protocol.HTTP) });
+ String PMDATA15M_TYPE = "historicalperformance15min";
+
+ EsDataObjectReaderWriter<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.pmdata._15m.list.output.Data> pm15mRW =
+ new EsDataObjectReaderWriter<>(dbClient, PMDATA15M_TYPE, org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.pmdata._15m.list.output.Data.class);
+ pm15mRW.setEsIdAttributeName("_nodeName");
+
+ ReadPmdata15mListInputBuilder inputBuilder = new ReadPmdata15mListInputBuilder();
+ PaginationBuilder paginationBuilder = new PaginationBuilder();
+ paginationBuilder.setPage(new BigInteger("1"));
+ paginationBuilder.setSize(20L);
+ inputBuilder.setPagination(paginationBuilder.build());
+
+ ReadPmdata15mListInput input = inputBuilder.build();
+
+
+ ReadPmdata15mListOutputBuilder outputBuilder = new ReadPmdata15mListOutputBuilder();
+ long page = getPage(input);
+ long pageSize = getPageSize(input);
+
+ QueryBuilder query = fromFilter(input.getFilter()).from((page - 1) * pageSize).size(pageSize);
+ setSortOrder(query, input.getSortorder());
+
+ SearchResult<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.pmdata._15m.list.output.Data> result=pm15mRW.doReadAll(query);
+
+ out("Found: "+result.getHits().size());
+ int t=0;
+ for (Data hit : result.getHits()) {
+ out("Hit "+t+++":"+hit);
+ }
+ setPagination(outputBuilder, page, pageSize, result.getTotal());
+ outputBuilder.setData(result.getHits());
+ }
+
+ @Test
+ public void test7() throws IOException, ClassNotFoundException {
+ out(method());
+ String ESDATATYPE_MEDIATORSERVER = Entity.MediatorServer.getName();
+ HtDatabaseClient dbClient = new HtDatabaseClient(new HostInfo[] { new HostInfo("sdnrdb", 9200, Protocol.HTTP) });
+ EsDataObjectReaderWriter<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.mediator.server.list.output.Data> mediatorserverRW;
+
+ mediatorserverRW = new EsDataObjectReaderWriter<>(dbClient, ESDATATYPE_MEDIATORSERVER,
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.mediator.server.list.output.Data.class)
+ .setWriteInterface(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.MediatorServerEntity.class)
+ .setEsIdAttributeName("_id");
+
+ CreateMediatorServerInputBuilder inputBuilder = new CreateMediatorServerInputBuilder();
+ inputBuilder.setName("Hans");
+ inputBuilder.setUrl("MyGreatUrl");
+
+ String id = mediatorserverRW.write(inputBuilder.build(),"testid");
+ System.out.println(id);
+
+ }
+
+ @Test
+ public void test8() throws IOException {
+ out(method());
+ String input;
+ input = "id-dd-dd";
+ System.out.println("Map " + input + " to "+YangToolsMapper.toCamelCaseAttributeName(input));
+ input = "idDdGg";
+ System.out.println("Map " + input + " to "+YangToolsMapper.toCamelCaseAttributeName(input));
+ input = "_idDdGg";
+ System.out.println("Map " + input + " to "+YangToolsMapper.toCamelCaseAttributeName(input));
+ input = "--ff--gfg";
+ System.out.println("Map " + input + " to "+YangToolsMapper.toCamelCaseAttributeName(input));
+ input = "";
+ System.out.println("Map " + input + " to "+YangToolsMapper.toCamelCaseAttributeName(input));
+ }
+
+ /* ---------------------------------
+ * Private
+ */
+ private static String method() {
+ String nameofCurrMethod = new Throwable().getStackTrace()[1].getMethodName();
+ return nameofCurrMethod;
+ }
+
+ private org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.inventory.list.output.DataBuilder getInventoryDataBuilder(String description, long treeLevel) {
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.inventory.list.output.DataBuilder dataBuilder =
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.inventory.list.output.DataBuilder();
+ dataBuilder.setDescription(description);
+ dataBuilder.setTreeLevel(treeLevel);
+ return dataBuilder;
+ }
+
+
+ private static void out(String text) {
+ System.out.println("----------------------");
+ System.out.println(text);
+ }
+
+ private static long getPage(EntityInput input) {
+ return getPage(input, 1);
+ }
+
+ private static long getPage(EntityInput input, long defaultValue) {
+ return input.getPagination() != null ? input.getPagination().getPage().longValue() : defaultValue;
+ }
+
+ private static long getPageSize(EntityInput input) {
+ return getPageSize(input, 1);
+ }
+
+ private static long getPageSize(EntityInput input, long defaultValue) {
+ return input.getPagination() != null ? input.getPagination().getSize().longValue() : defaultValue;
+ }
+
+ private static QueryBuilder fromFilter(@Nullable List<Filter> filters) {
+ return fromFilter(filters, "");
+ }
+
+ private static QueryBuilder fromFilter(@Nullable List<Filter> filters, String prefix) {
+ if (filters == null || filters.size() == 0) {
+ return QueryBuilders.matchAllQuery();
+
+ } else if(filters.size()==1){
+ return QueryBuilders.matchQuery(filters.get(0).getProperty(), filters.get(0).getFiltervalue());
+ }
+ else {
+ BoolQueryBuilder query = new BoolQueryBuilder();
+ for (Filter fi : filters) {
+ query.must(QueryBuilders.matchQuery((prefix != null ? prefix : "") + fi.getProperty(),
+ fi.getFiltervalue()));
+ }
+ return query;
+ }
+
+ }
+ private static QueryBuilder setSortOrder(QueryBuilder query, @Nullable List<Sortorder> sortorder) {
+ return setSortOrder(query, sortorder, "");
+ }
+
+ private static QueryBuilder setSortOrder(QueryBuilder query, @Nullable List<Sortorder> sortorder, String prefix) {
+ if (sortorder != null && sortorder.size() > 0) {
+ for (Sortorder so : sortorder) {
+ query.sort((prefix != null ? prefix : "") + so.getProperty(),
+ so.getSortorder() == SortOrder.Ascending
+ ? org.onap.ccsdk.features.sdnr.wt.common.database.queries.SortOrder.ASCENDING
+ : org.onap.ccsdk.features.sdnr.wt.common.database.queries.SortOrder.DESCENDING);
+ }
+ }
+ return query;
+
+ }
+
+ private static void setPagination(ReadPmdata15mListOutputBuilder outputBuilder, long page, long pageSize, long totalSize) {
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.pmdata._15m.list.output.Pagination value = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.pmdata._15m.list.output.PaginationBuilder()
+ .setPage(BigInteger.valueOf(page)).setSize(pageSize).setTotal(BigInteger.valueOf(totalSize)).build();
+ outputBuilder.setPagination(value);
+ }
+
+}
diff --git a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestYangProvider.java b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestYangProvider.java
new file mode 100644
index 0000000..c911100
--- /dev/null
+++ b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestYangProvider.java
@@ -0,0 +1,195 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
+ * =================================================================================================
+ * 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.
+ * ============LICENSE_END==========================================================================
+ ******************************************************************************/
+package org.onap.ccsdk.features.sdnr.wt.dataprovider.test;
+
+import static org.junit.Assert.*;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.StringWriter;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.attribute.FileAttribute;
+import java.nio.file.attribute.PosixFilePermission;
+import java.nio.file.attribute.PosixFilePermissions;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Comparator;
+import java.util.EnumSet;
+import java.util.Set;
+
+import javax.servlet.ServletException;
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.data.YangFileProvider;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.data.YangFilename;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.http.YangSchemaHttpServlet;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+public class TestYangProvider {
+
+ private static final String TESTPATH = "cache/schema/";
+
+
+ @BeforeClass
+ public static void init() {
+ Set<PosixFilePermission> perms;
+ FileAttribute<?> attr;
+ perms = EnumSet.noneOf(PosixFilePermission.class);
+
+ perms.add(PosixFilePermission.OWNER_READ);
+ perms.add(PosixFilePermission.OWNER_WRITE);
+ perms.add(PosixFilePermission.OWNER_EXECUTE);
+
+ attr = PosixFilePermissions.asFileAttribute(perms);
+ try {
+ Files.createDirectories(new File(TESTPATH).toPath(),attr);
+ new File(TESTPATH+new YangFilename("module1","2010-01-01").getFilename()).createNewFile();
+ new File(TESTPATH+new YangFilename("module2","2010-01-01").getFilename()).createNewFile();
+ new File(TESTPATH+new YangFilename("module2","2010-04-01").getFilename()).createNewFile();
+ new File(TESTPATH+new YangFilename("module3","2010-01-01").getFilename()).createNewFile();
+ new File(TESTPATH+new YangFilename("module4","2010-05-01").getFilename()).createNewFile();
+ new File(TESTPATH+new YangFilename("module5","2010-01-11").getFilename()).createNewFile();
+ new File(TESTPATH+new YangFilename("module6","2010-01-01").getFilename()).createNewFile();
+ } catch (IOException | ParseException e) {
+
+ }
+ }
+ @AfterClass
+ public static void deinit() {
+ try {
+ Files.walk(new File("cache").toPath())
+ .sorted(Comparator.reverseOrder())
+ .map(Path::toFile)
+ .forEach(File::delete);
+ } catch (IOException e) {
+ System.err.println(e);
+ }
+ }
+ @Test
+ public void testExisting() {
+ YangFileProvider provider= new YangFileProvider(TESTPATH);
+ assertTrue(provider.hasFileForModule("module1","2010-01-01"));
+ assertTrue(provider.hasFileForModule("module2"));
+ assertTrue(provider.hasFileForModule("module3"));
+ assertFalse(provider.hasFileForModule("module5","2010-01-01"));
+ }
+ @Test
+ public void testRevision() throws ParseException {
+ SimpleDateFormat sdf =new SimpleDateFormat("yyyy-MM-dd");
+ YangFileProvider provider= new YangFileProvider(TESTPATH);
+ YangFilename f1 = provider.getFileForModule("module1","2010-01-01");
+ assertEquals("module1",f1.getModule());
+ assertEquals(sdf.parse("2010-01-01"),f1.getRevision());
+ YangFilename f2 = provider.getFileForModule("module2");
+ assertEquals("module2",f2.getModule());
+ assertEquals(sdf.parse("2010-04-01"),f2.getRevision());
+ f2 = provider.getFileForModule("module2","2010-02-01");
+ assertEquals("module2",f2.getModule());
+ assertEquals(sdf.parse("2010-04-01"),f2.getRevision());
+ YangFilename f3 = provider.getFileForModule("module3");
+ assertEquals("module3",f3.getModule());
+ assertEquals(sdf.parse("2010-01-01"),f3.getRevision());
+ f3 = provider.getFileForModule("module3","2010-04-01");
+ assertNull(f3);
+ }
+ @Test
+ public void testServlet() throws IOException, ServletException {
+ HelpYangSchemaHttpServlet servlet = new HelpYangSchemaHttpServlet();
+ HttpServletRequest req = mock(HttpServletRequest.class);
+ HttpServletResponse resp = mock(HttpServletResponse.class);
+
+ when(req.getRequestURI()).thenReturn("/yang-schema/module1");
+ StringWriter out = new StringWriter();
+ ServletOutputStream printOut = new ServletOutputStream() {
+
+ @Override
+ public void write(int arg0) throws IOException {
+ out.write(arg0);
+ }
+ };
+ when(resp.getOutputStream()).thenReturn(printOut);
+ servlet.doGet(req,resp);
+ verify(resp).setStatus(200);
+ verify(resp).setContentType("text/plain");
+
+ }
+ @Test
+ public void testServletBad() throws IOException, ServletException {
+ HelpYangSchemaHttpServlet servlet = new HelpYangSchemaHttpServlet();
+ HttpServletRequest req = mock(HttpServletRequest.class);
+ HttpServletResponse resp = mock(HttpServletResponse.class);
+
+ when(req.getRequestURI()).thenReturn("/yang-schema/module1/2020-01-01");
+ StringWriter out = new StringWriter();
+ ServletOutputStream printOut = new ServletOutputStream() {
+
+ @Override
+ public void write(int arg0) throws IOException {
+ out.write(arg0);
+ }
+ };
+ when(resp.getOutputStream()).thenReturn(printOut);
+ servlet.doGet(req,resp);
+ verify(resp).sendError(HttpServletResponse.SC_NOT_FOUND);
+
+ }
+ @Test
+ public void testServletNear() throws IOException, ServletException {
+ HelpYangSchemaHttpServlet servlet = new HelpYangSchemaHttpServlet();
+ HttpServletRequest req = mock(HttpServletRequest.class);
+ HttpServletResponse resp = mock(HttpServletResponse.class);
+
+ when(req.getRequestURI()).thenReturn("/yang-schema/module2/2010-03-01");
+ StringWriter out = new StringWriter();
+ ServletOutputStream printOut = new ServletOutputStream() {
+
+ @Override
+ public void write(int arg0) throws IOException {
+ out.write(arg0);
+ }
+ };
+ when(resp.getOutputStream()).thenReturn(printOut);
+ servlet.doGet(req,resp);
+ verify(resp).setStatus(200);
+ verify(resp).setContentType("text/plain");
+
+ }
+ private static class HelpYangSchemaHttpServlet extends YangSchemaHttpServlet{
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+ super.doGet(req, resp);
+ }
+ }
+
+
+}
diff --git a/sdnr/wt/data-provider/provider/src/test/resources/log4j.properties b/sdnr/wt/data-provider/provider/src/test/resources/log4j.properties
new file mode 100644
index 0000000..142663b
--- /dev/null
+++ b/sdnr/wt/data-provider/provider/src/test/resources/log4j.properties
@@ -0,0 +1,12 @@
+log4j.rootLogger=INFO, out
+
+log4j.logger.org.apache.camel.impl.converter=WARN
+log4j.logger.org.apache.camel.management=WARN
+log4j.logger.org.apache.camel.impl.DefaultPackageScanClassResolver=WARN
+log4j.logger.org.springframework=ERROR
+
+# CONSOLE appender not used by default
+log4j.appender.out=org.apache.log4j.ConsoleAppender
+log4j.appender.out.layout=org.apache.log4j.PatternLayout
+log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
+
diff --git a/sdnr/wt/data-provider/provider/src/test/resources/log4j2.xml b/sdnr/wt/data-provider/provider/src/test/resources/log4j2.xml
new file mode 100644
index 0000000..164e93f
--- /dev/null
+++ b/sdnr/wt/data-provider/provider/src/test/resources/log4j2.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Configuration package="log4j.test"
+ status="WARN">
+ <Appenders>
+ <Console name="Console" target="SYSTEM_OUT">
+ <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
+ </Console>
+ </Appenders>
+ <Loggers>
+ <Logger name="log4j.test.Log4jTest" level="debug">
+ <AppenderRef ref="Console"/>
+ </Logger>
+ <Root level="trace">
+ <AppenderRef ref="Console"/>
+ </Root>
+ </Loggers>
+</Configuration>
\ No newline at end of file
diff --git a/sdnr/wt/data-provider/provider/src/test/resources/simplelogger.properties b/sdnr/wt/data-provider/provider/src/test/resources/simplelogger.properties
new file mode 100644
index 0000000..a2f1e7e
--- /dev/null
+++ b/sdnr/wt/data-provider/provider/src/test/resources/simplelogger.properties
@@ -0,0 +1,6 @@
+org.slf4j.simpleLogger.defaultLogLevel=debug
+org.slf4j.simpleLogger.showDateTime=true
+#org.slf4j.simpleLogger.dateTimeFormat=yyyy-MM-dd HH:mm:ss:SSS Z
+#org.slf4j.simpleLogger.showThreadName=true
+org.slf4j.simpleLogger.showLogName=true
+org.slf4j.simpleLogger.showShortLogName=false
\ No newline at end of file
diff --git a/sdnr/wt/data-provider/provider/src/test/resources/test.properties b/sdnr/wt/data-provider/provider/src/test/resources/test.properties
new file mode 100644
index 0000000..de49c58
--- /dev/null
+++ b/sdnr/wt/data-provider/provider/src/test/resources/test.properties
@@ -0,0 +1,55 @@
+[dcae]
+dcaeUserCredentials=admin:admin
+dcaeUrl=off
+dcaeHeartbeatPeriodSeconds=120
+dcaeTestCollector=no
+
+[aots]
+userPassword=passwd
+soapurladd=off
+soapaddtimeout=10
+soapinqtimeout=20
+userName=user
+inqtemplate=inqreq.tmpl.xml
+assignedto=userid
+addtemplate=addreq.tmpl.xml
+severitypassthrough=critical,major,minor,warning
+systemuser=user
+prt-offset=1200
+soapurlinq=off
+#smtpHost=
+#smtpPort=
+#smtpUsername=
+#smtpPassword=
+#smtpSender=
+#smtpReceivers=
+
+[es]
+esCluster=sendateodl5
+#time limit to keep increasing data in database [in seconds]
+#60*60*24*30 (30days)
+esArchiveLimit=2592000
+#folder where removed data will be stored
+esArchiveFolder=./backup
+#interval to archive database [in seconds]
+#60*60*24 (1day)
+esArchiveInterval=86400
+
+[aai]
+#keep comment
+aaiHeaders=["X-TransactionId: 9999"]
+aaiUrl=http://localhost:81
+aaiUserCredentials=AAI:AAI
+aaiDeleteOnMountpointRemove=false
+aaiTrustAllCerts=false
+aaiApiVersion=aai/v13
+aaiPropertiesFile=aaiclient.properties
+aaiApplicationId=SDNR
+aaiPcks12ClientCertFile=/opt/logs/externals/data/stores/keystore.client.p12
+aaiPcks12ClientCertPassphrase=adminadmin
+aaiClientConnectionTimeout=30000
+
+[pm]
+pmCluster=sendateodl5
+pmEnabled=true
+
diff --git a/sdnr/wt/pom.xml b/sdnr/wt/pom.xml
index b10d77a..fee3c4e 100644
--- a/sdnr/wt/pom.xml
+++ b/sdnr/wt/pom.xml
@@ -41,8 +41,8 @@
<module>apigateway</module>
<module>websocketmanager2</module>
<module>helpserver</module>
- <!--<module>data-provider</module>
- <module>netconfnode-state-service</module>
+ <module>data-provider</module>
+ <!--<module>netconfnode-state-service</module>
<module>devicemanager</module>
<module>devicemanager-onf</module>
<module>devicemanager-oran</module>