aboutsummaryrefslogtreecommitdiffstats
path: root/sdnr/wt/data-provider/provider/src
diff options
context:
space:
mode:
Diffstat (limited to 'sdnr/wt/data-provider/provider/src')
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/DataObjectAcessor.java58
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/DataObjectAcessorPm.java161
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/DataObjectAcessorStatus.java72
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/ElasticSearchDataProvider.java439
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/FaultEntityManager.java91
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/HtDatabaseEventsService.java388
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/QueryByFilter.java342
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/QueryResult.java52
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/YangFileProvider.java206
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/YangFilename.java63
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/AboutHttpServlet.java224
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/GetYangSchemaRequest.java57
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/ReadyHttpServlet.java42
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/YangSchemaHttpServlet.java103
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/impl/DataProviderImpl.java95
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/impl/DataProviderServiceImpl.java335
-rw-r--r--sdnr/wt/data-provider/provider/src/main/resources/about/README.md2
-rw-r--r--sdnr/wt/data-provider/provider/src/main/resources/about/test.bmpbin14454 -> 0 bytes
-rwxr-xr-xsdnr/wt/data-provider/provider/src/main/resources/es-init.sh446
-rw-r--r--sdnr/wt/data-provider/provider/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml68
-rw-r--r--sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestAbout.java98
-rw-r--r--sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestCRUDforDatabase.java1453
-rw-r--r--sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestFilterConversion.java22
-rw-r--r--sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestInitalMaintenanceObjectInDatabase.java34
-rw-r--r--sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestTimestampFilter.java137
-rw-r--r--sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestYangProvider.java195
-rw-r--r--sdnr/wt/data-provider/provider/src/test/resources/log4j.properties12
-rw-r--r--sdnr/wt/data-provider/provider/src/test/resources/log4j2.xml17
-rw-r--r--sdnr/wt/data-provider/provider/src/test/resources/simplelogger.properties6
29 files changed, 446 insertions, 4772 deletions
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
deleted file mode 100644
index dc90ee9fa..000000000
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/DataObjectAcessor.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*******************************************************************************
- * ============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.database.EsDataObjectReaderWriter;
-import org.onap.ccsdk.features.sdnr.wt.dataprovider.impl.DataProviderServiceImpl;
-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.ReadFaultcurrentListInput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ReadFaultcurrentListOutputBuilder;
-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<T>(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
deleted file mode 100644
index a145a9f1b..000000000
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/DataObjectAcessorPm.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/*******************************************************************************
- * ============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
deleted file mode 100644
index 5970d5416..000000000
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/DataObjectAcessorStatus.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*******************************************************************************
- * ============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
deleted file mode 100644
index 306fe95f4..000000000
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/ElasticSearchDataProvider.java
+++ /dev/null
@@ -1,439 +0,0 @@
-/*******************************************************************************
- * ============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.IEntityDataProvider;
-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 implements IEntityDataProvider {
-
- private static final Logger LOG = LoggerFactory.getLogger(ElasticSearchDataProvider.class);
-
- 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;
-
- public ElasticSearchDataProvider(HostInfo[] hosts) throws Exception {
- LOG.info("Start {}", this.getClass().getName());
-
- this.dbClient = new HtDatabaseClient(hosts);
- 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);
- }
-
- //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("unable to write data to 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("unable to update data 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("unable to remove data from database");
- }
- return new DeleteNetworkElementConnectionOutputBuilder();
- }
-
- public DeleteMediatorServerOutputBuilder deleteMediatorServer(DeleteMediatorServerInput input) throws IOException {
- boolean removed = this.mediatorserverRW.remove(input.getId());
- if (!removed) {
- throw new IOException("unable to remove data from database");
- }
- return new DeleteMediatorServerOutputBuilder();
- }
-
- public DeleteMaintenanceOutputBuilder deleteMaintenance(DeleteMaintenanceInput input) throws IOException {
- boolean removed = this.maintenanceRW.remove(input.getId());
- if (!removed) {
- throw new IOException("unable to remove data 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("unable to update data 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("unable to update data 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("unable to write data to 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("unable to write data to database");
- }
- CreateMediatorServerOutputBuilder builder = new CreateMediatorServerOutputBuilder();
- builder.setId(id).setName(input.getName()).setUrl(input.getUrl());
- return builder;
- }
-
- @Override
- public DataProvider getDataProvider() {
- return this.databaseService;
- }
-
- /**
- * no need for implementation
- */
- @Override
- public void setReadyStatus(boolean status) {
-
- }
-
-
-
-}
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
deleted file mode 100644
index f26a30de8..000000000
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/FaultEntityManager.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*******************************************************************************
- * ============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
deleted file mode 100644
index b08466c8b..000000000
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/HtDatabaseEventsService.java
+++ /dev/null
@@ -1,388 +0,0 @@
-/*******************************************************************************
- * ============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.onap.ccsdk.features.sdnr.wt.base.netconf.util.NetconfTimeStamp;
-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.database.EsDataObjectReaderWriter2;
-import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.ArchiveCleanProvider;
-import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider;
-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.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.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 = NetconfTimeStamp.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 EsDataObjectReaderWriter2<NetworkElementConnectionEntity> networkelementConnectionDB;
- // --- Construct and initialize
-
- public HtDatabaseEventsService(HtDatabaseClient client) throws Exception {
-
- LOG.info("Create {} start", HtDatabaseEventsService.class);
-
- 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");
-
- } 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();
- }
-
-}
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
deleted file mode 100644
index f00ffb546..000000000
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/QueryByFilter.java
+++ /dev/null
@@ -1,342 +0,0 @@
-/*******************************************************************************
- * ============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.base.netconf.util.NetconfTimeStamp;
-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.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 = NetconfTimeStamp.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
deleted file mode 100644
index 9cbe9430c..000000000
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/QueryResult.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*******************************************************************************
- * ============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/YangFileProvider.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/YangFileProvider.java
deleted file mode 100644
index 44240b07f..000000000
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/YangFileProvider.java
+++ /dev/null
@@ -1,206 +0,0 @@
-/*******************************************************************************
- * ============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<? super 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
deleted file mode 100644
index b00eb203f..000000000
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/YangFilename.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*******************************************************************************
- * ============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/http/AboutHttpServlet.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/AboutHttpServlet.java
deleted file mode 100644
index 66d21041c..000000000
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/AboutHttpServlet.java
+++ /dev/null
@@ -1,224 +0,0 @@
-/*******************************************************************************
- * ============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.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.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 URI_PRE = "/about";
- private static final String RES_BASEPATH = "about/";
-
- private static final String PLACEHOLDER_ONAP_RELEASENAME = "{release-name}";
- 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_PACAKGE_VERSION = "{package-version}";
- 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 ConfigurationFileRepresentation configuration;
- //private final ExtRestClient dbClient;
- private final Map<String, String> data;
- private final String readmeContent;
-
-
-
- public AboutHttpServlet() {
-// this.configuration = new ConfigurationFileRepresentation(DataProviderServiceImpl.CONFIGURATIONFILE);
-// EsConfig esConfig = new EsConfig(configuration);
- //this.dbClient = ExtRestClient.createInstance(esConfig.getHosts());
- this.data = new HashMap<>();
- this.collectStaticData();
- this.readmeContent = this.render(this.getFileContent(README_FILE));
- }
-
- private void collectStaticData() {
- PomPropertiesFile props = this.getPomProperties();
- this.data.put(PLACEHOLDER_ONAP_RELEASENAME, this.getPomProperty("onap.distname"));
- this.data.put(PLACEHOLDER_ODL_RELEASENAME, this.getPomProperty("odl.distname") );
- 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"));
- }
-
- @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");
- resp.getOutputStream().write(output);
-
- } else {
- this.doGetFile(uri, resp);
- }
- }
-
- private String getFileContent(String filename) {
- LOG.debug("try ti get content of {}",filename);
- return Resources.getFileContent(AboutHttpServlet.class,RES_BASEPATH + filename);
- }
-
- private void collectData() {
- // TODO Auto-generated method stub
-
- }
-
- 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;
-
- }
- private PomPropertiesFile getPomProperties() {
- URL url = Resources.getUrlForRessource(AboutHttpServlet.class, "/META-INF/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("unable to read inner pom file: {}",e);
- }
- return null;
- }
- private String getPomProperty(String key) {
- LOG.info("try to get pom property for {}",key);
- URL url = Resources.getUrlForRessource(AboutHttpServlet.class,"/META-INF/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("unable to read inner pom file: {}",e);
- }
- return null;
- }
- private void doGetFile(String uri, HttpServletResponse resp) {
- String content = this.getFileContent(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);
- }
- }
-
- }
-
- 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";
- }
- }
-
- private String render() {
- return this.render(null);
- }
-
- 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;
- }
-} \ 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
deleted file mode 100644
index db4faedfc..000000000
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/GetYangSchemaRequest.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*******************************************************************************
- * ============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/ReadyHttpServlet.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/ReadyHttpServlet.java
deleted file mode 100644
index 607f552f6..000000000
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/ReadyHttpServlet.java
+++ /dev/null
@@ -1,42 +0,0 @@
-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 boolean status;
-
- @Override
- protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
-
- if(this.isReady()) {
- resp.setStatus(HttpServletResponse.SC_OK);
- }
- else {
-
- resp.sendError(HttpServletResponse.SC_NOT_FOUND);
- }
- }
-
- private boolean isReady() {
- return this.status;
- }
-
- public void setStatus(boolean status) {
- this.status = status;
- 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
deleted file mode 100644
index 94d2793ec..000000000
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/YangSchemaHttpServlet.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*******************************************************************************
- * ============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);
- }
- } else {
- resp.sendError(HttpServletResponse.SC_NOT_FOUND);
- }
-
- } 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());
- }
-
- } else {
- resp.sendError(HttpServletResponse.SC_NOT_FOUND);
- }
- } else {
- resp.sendError(HttpServletResponse.SC_BAD_REQUEST);
- }
-
- }
-
-}
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
deleted file mode 100644
index ba6e99975..000000000
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/impl/DataProviderImpl.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*******************************************************************************
- * ============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.ReadyHttpServlet;
-import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider;
-import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.IEntityDataProvider;
-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 = null;
- private RpcProviderService rpcProviderService = null;
- private DataProviderServiceImpl rpcApiService;
- private ReadyHttpServlet readyServlet;
- private HtDatabaseClient dbClient;
-
-
- // Blueprint 1
- public DataProviderImpl() {
- LOG.info("Creating provider for {}", APPLICATION_NAME);
- }
-
- public void setRpcProviderService(RpcProviderService rpcProviderService) {
- this.rpcProviderService = rpcProviderService;
- }
- public void setReadyServlet(ReadyHttpServlet readyServlet) {
- this.readyServlet = readyServlet;
- }
- public void init() throws Exception {
-
- LOG.info("Session Initiated start {}", APPLICATION_NAME);
-
- // Start RPC Service
- this.rpcApiService = new DataProviderServiceImpl(rpcProviderService);
- // 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 void setReadyStatus(boolean status) {
- if(this.readyServlet!=null) {
- this.readyServlet.setStatus(status);
- }
- }
-}
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
deleted file mode 100644
index 70b735357..000000000
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/impl/DataProviderServiceImpl.java
+++ /dev/null
@@ -1,335 +0,0 @@
-/*******************************************************************************
- * ============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.database.config.EsConfig;
-import org.onap.ccsdk.features.sdnr.wt.dataprovider.data.ElasticSearchDataProvider;
-import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider;
-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;
-
- DataProviderServiceImpl(final RpcProviderService rpcProviderService) throws Exception {
- this.configuration = new ConfigurationFileRepresentation(CONFIGURATIONFILE);
- EsConfig esConfig = new EsConfig(configuration);
- this.dataProvider = new ElasticSearchDataProvider(esConfig.getHosts());
- this.dataProvider.waitForYellowDatabaseStatus(DATABASE_TIMEOUT_MS,TimeUnit.MILLISECONDS);
- // Register ourselves as the REST API RPC implementation
- LOG.info("Register RPC Service " + DataProviderServiceImpl.class.getSimpleName());
- this.rpcReg = rpcProviderService.registerRpcImplementation(DataProviderService.class, this);
- }
-
- /**
- * @return the dataProvider
- */
- public DataProvider getDataProvider() {
- return dataProvider.getDataProvider();
- }
-
-
-
- @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));
- 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));
- 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));
- 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/resources/about/README.md b/sdnr/wt/data-provider/provider/src/main/resources/about/README.md
deleted file mode 100644
index 9c45d8354..000000000
--- a/sdnr/wt/data-provider/provider/src/main/resources/about/README.md
+++ /dev/null
@@ -1,2 +0,0 @@
-# About
-ONAP SDN-R | ONF Wireless for ONAP {release-name} ({odl-version}) - Build: {build-time} {odlux-revision} {package-version} \ 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
deleted file mode 100644
index d049ea5bc..000000000
--- a/sdnr/wt/data-provider/provider/src/main/resources/about/test.bmp
+++ /dev/null
Binary files differ
diff --git a/sdnr/wt/data-provider/provider/src/main/resources/es-init.sh b/sdnr/wt/data-provider/provider/src/main/resources/es-init.sh
new file mode 100755
index 000000000..8873b0b75
--- /dev/null
+++ b/sdnr/wt/data-provider/provider/src/main/resources/es-init.sh
@@ -0,0 +1,446 @@
+#!/bin/bash
+# ============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==========================================================================
+#
+# Version 2
+# Usage .. see help below
+
+SDNRNAME=sdnrdb
+REPLICAS=1
+SHARDS=5
+PREFIX=""
+VERSION="-v1"
+VERBOSE=0
+INITFILENAME="Init.script"
+
+#declare -a ALIAS
+#declare -a MAPPING
+
+# ------------------------------------------------------------
+# Function with definition of mappings
+# $1: alias name for index
+# $2: mapping properties and additonal parameter for this section
+
+set_definition() {
+ def "connectionlog" '{"node-id": {"type": "keyword"},"timestamp": {"type": "date"},"status": {"type": "keyword"}}'
+ def "maintenancemode" '{"node-id": {"type": "keyword"},"active": {"type": "boolean"}},"date_detection":false}}'
+ def "faultlog" '{"node-id": {"type": "keyword"},"severity": {"type": "keyword"},"timestamp": {"type": "date"},"problem": {"type": "keyword"},"counter": {"type": "keyword"},"object-id":{"type": "keyword"},"source-type":{"type": "keyword"}}'
+ def "faultcurrent" '{"node-id": {"type": "keyword"},"severity": {"type": "keyword"},"timestamp": {"type": "date"},"problem": {"type": "keyword"},"counter": {"type": "keyword"},"object-id":{"type": "keyword"}}'
+ def "eventlog" '{"node-id": {"type": "keyword"},"timestamp": {"type": "date"},"new-value": {"type": "keyword"},"attribute-name": {"type": "keyword"},"counter": {"type": "keyword"},"object-id": {"type": "keyword"}}'
+ def "inventoryequipment" '{"date": {"type": "keyword"},"model-identifier": {"type": "keyword"},"manufacturer-identifier": {"type": "keyword"},"type-name": {"type": "keyword"},"description": {"type": "keyword"},"uuid": {"type": "keyword"},"version": {"type": "keyword"},"parent-uuid": {"type": "keyword"},"contained-holder": {"type": "keyword"},"node-id": {"type": "keyword"},"tree-level": {"type": "long"},"part-type-id": {"type": "keyword"},"serial": {"type": "keyword"}}'
+ def "historicalperformance24h" '{"node-name":{"type": "keyword"},"timestamp":{"type": "date"},"suspect-interval-flag":{"type":"boolean"},"scanner-id":{"type": "keyword"},"uuid-interface":{"type": "keyword"},"layer-protocol-name":{"type": "keyword"},"granularity-period":{"type": "keyword"},"radio-signal-id":{"type": "keyword"}}'
+ def "historicalperformance15min" '{"node-name":{"type": "keyword"},"timestamp":{"type": "date"},"suspect-interval-flag":{"type":"boolean"},"scanner-id":{"type": "keyword"},"uuid-interface":{"type": "keyword"},"layer-protocol-name":{"type": "keyword"},"granularity-period":{"type": "keyword"},"radio-signal-id":{"type": "keyword"}}'
+ def "mediator-server" '{"url":{"type": "keyword"},"name":{"type": "keyword"}}'
+ def "networkelement-connection" '{"node-id": {"type": "keyword"},"host": {"type": "keyword"},"port": {"type": "long"},"username": {"type": "keyword"},"password": {"type": "keyword"},"core-model-capability": {"type": "keyword"},"device-type": {"type": "keyword"},"is-required": {"type": "boolean"},"status": {"type": "keyword"}},"date_detection":false'
+}
+
+# ------------------------------------------------------------
+# Functions
+
+# Get ip of container with database
+getsdnrurl() {
+ if [ ! -z "$DBURL" ]; then
+ return
+ fi
+ cmd=$(which docker)
+ if [ ! -z "$cmd" ]; then
+ SDNRIP=$($cmd inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' "$SDNRNAME")
+ if [ "$?" = "1" ] ; then
+ echo "WARN: Container $SDNRNAME not running. Start the sdnrdb container or enter a database url."
+ echo "continuing with localhost"
+ SDNRIP="localhost"
+ fi
+ else
+ # if no docker and no db url given
+ if [ -z "$DBURL" ]; then
+ echo "WARN: Please enter a database url."
+ echo "continuing with localhost"
+ SDNRIP="localhost"
+ fi
+ fi
+ DBURL="http://$SDNRIP:9200"
+}
+
+# Add elements to the array ALIAS and MAPPING
+# $1 alias
+# $2 mapping properties
+def() {
+ ALIAS=("${ALIAS[@]}" "$1")
+ MAPPING=("${MAPPING[@]}" "$2")
+}
+
+# $1 Response
+print_response() {
+ response="$1"
+ body=$(echo $response | sed -E 's/HTTPSTATUS\:[0-9]{3}$//')
+ code=$(echo $response | tr -d '\n' | sed -E 's/.*HTTPSTATUS:([0-9]{3})$/\1/')
+ if [ "$VERBOSE" = "0" -a "$code" -ne "200" ] ; then
+ echo "Error response $code $body"
+ fi
+ if [ "$VERBOSE" -ge 1 ] ; then
+ echo "response $code"
+ fi
+ if [ "$VERBOSE" -ge 2 ] ; then
+ echo "content: $body"
+ fi
+}
+
+#Write ini file for elasticsearch
+# $1 index
+# $1 data
+file_append() {
+ echo "PUT:"$1"/:"$2 >> $INITFILENAME
+}
+
+# Send get request to database
+# USes DBURL
+# $1 url path
+# $2 data
+http_get_request() {
+ url="$DBURL/$1"
+ if [ "$VERBOSE" -ge 2 ] ; then
+ echo "PUT to $url data $data"
+ fi
+ response=$(curl --silent --write-out "HTTPSTATUS:%{http_code}" -X GET -H "Content-Type: application/json" "$url")
+ print_response "$response"
+}
+
+# Send put request to database
+# USes DBURL
+# $1 url path
+# $2 data
+http_put_request() {
+ url="$DBURL/$1"
+ if [ "$VERBOSE" -ge 2 ] ; then
+ echo "PUT to $url data $data"
+ fi
+ response=$(curl --silent --write-out "HTTPSTATUS:%{http_code}" -X PUT -H "Content-Type: application/json" -d "$2" "$url")
+ print_response "$response"
+}
+
+# Send delete request to database
+# $1 url
+http_delete_request() {
+ url="$DBURL/$1"
+ if [ "$VERBOSE" -ge 2 ] ; then
+ echo "DELETE to $url"
+ fi
+ echo "DELETE to $url"
+ response=$(curl --silent --write-out "HTTPSTATUS:%{http_code}" -X DELETE -H "Content-Type: application/json" $url)
+ print_response "$response"
+}
+
+# Delete index and alias
+# $1 alias
+delete_index_alias() {
+
+ echo "deleting alias $alias"
+ # Delete alias
+ alias="$PREFIX$1"
+ index="$PREFIX$1$VERSION"
+
+ url="$index/_alias/$alias"
+ http_delete_request "$url"
+
+ # Delete index
+ echo "deleting index $index"
+ url="$index"
+ http_delete_request "$url"
+
+ # Delete alias that was falsely autocreated as index
+ echo "deleting index $index"
+ url="$alias"
+ http_delete_request "$url"
+}
+
+# Write mappings
+# Uses version, SHARDS and REPLICAS parameters
+# $1 alias and datatype "mydatatype"
+# $2 mapping properties
+# $3 filename or empty for WEB
+create_index_alias() {
+ # Create index
+ alias="$PREFIX$1"
+ index="$PREFIX$1$VERSION"
+ mappings='"mappings":{"'$1'":{"properties":'$2'}}'
+ settings='"settings":{"index":{"number_of_shards":'$SHARDS',"number_of_replicas":'$REPLICAS'},"analysis":{"analyzer":{"content":{"type":"custom","tokenizer":"whitespace"}}}}'
+
+ if [ -z "$mappings" ]; then
+ data="{$settings}"
+ else
+ data="{$settings,$mappings}"
+ fi
+
+ url=$index
+ echo "creating index $index"
+ if [ -z "$3" ] ; then
+ http_put_request "$url" "$data"
+ else
+ file_append "$url" "$data"
+ fi
+
+ #Create alias
+ url="$index/_alias/$alias"
+ echo "creating alias $alias for $index"
+ if [ -z "$3" ] ; then
+ http_put_request "$url"
+ else
+ file_append "$url" "{}"
+ fi
+}
+
+# Wait for status
+# $1 time to wait
+es_wait_yellow() {
+ ESSTATUS="yellow"
+ attempt_counter=0
+ max_attempts=5
+ echo "Wait up to $max_attempts attempts for $DBURL availability"
+ until $(curl --output /dev/null --silent --head --fail $DBURL); do
+ if [ ${attempt_counter} -eq ${max_attempts} ];then
+ echo "Error: Max attempts reached."
+ exit 3
+ fi
+ attempt_counter=$(($attempt_counter+1))
+ printf '.'
+ sleep 5
+ done
+ sleep 2
+ echo "Wait up to $1 for status $ESSTATUS"
+ RES=$(curl GET "$DBURL/_cluster/health?wait_for_status=$ESSTATUS&timeout=$1&pretty" 2>/dev/null)
+ if [ "$?" = "0" ] ; then
+ if [[ "$RES" =~ .*status.*:.*yellow.* || "$RES" =~ .*status.*:.*green.* ]] ; then
+ echo "Status $ESSTATUS reached: $RES"
+ else
+ echo "Error: DB Reachable, but status $ESSTATUS not reached"
+ exit 2
+ fi
+ else
+ echo "Error: $DBURL not reachable"
+ exit 2
+ fi
+}
+
+# Commands
+
+cmd_create() {
+ if [ -n "$WAITYELLOW" ] ; then
+ es_wait_yellow "$WAITYELLOW"
+ fi
+ for i in "${!ALIAS[@]}"; do
+ create_index_alias "${ALIAS[$i]}" "${MAPPING[$i]}"
+ done
+}
+
+cmd_delete() {
+ if [ -n "$WAITYELLOW" ] ; then
+ es_wait_yellow "$WAITYELLOW"
+ fi
+ for i in "${!ALIAS[@]}"; do
+ delete_index_alias "${ALIAS[$i]}"
+ done
+ for i in "${!ALIAS[@]}"; do
+ delete_index_alias "${ALIAS[$i]}"
+ done
+}
+cmd_purge() {
+# http_get_request '_cat/aliases'
+# body=$(echo $response | sed -E 's/HTTPSTATUS\:[0-9]{3}$//')
+# echo "$response" | awk '/^([^ ]*)[ ]*([^ ]*).*$/{ print $2"/_alias/"$1 }'
+# http_get_request '_cat/indices'
+# echo "indices"
+# echo "$response"
+# echo "$response" | awk '/^[^ ]*[ ]*[^ ]*[ ]*([^ ]*).*$/{ print $3 }'
+ echo "not yet implemented"
+}
+cmd_initfile() {
+ echo "Create script initfile: $INITFILENAME"
+ if [ -f "$INITFILENAME" ] ; then
+ rm $INITFILENAME
+ else
+ mkdir -p $(dirname $INITFILENAME )
+ fi
+ for i in "${!ALIAS[@]}"; do
+ create_index_alias "${ALIAS[$i]}" "${MAPPING[$i]}" file
+ done
+}
+
+# Prepare database startup
+cmd_startup() {
+ ESWAIT=30s
+ echo "Startup ElasticSearch DBURL=$DBURL CMD=$STARTUP_CMD CLUSTER=$CLUSTER_ENABLED INDEX=$NODE_INDEX"
+ if $CLUSTER_ENABLED ; then
+ if [ "$NODE_INDEX" = "0" ] ; then
+ echo "Cluster node 0 detected .. create"
+ es_wait_yellow $ESWAIT
+ cmd_create
+ else
+ echo "Cluster node > 0 detected .. do nothing"
+ fi
+ else
+ echo "No cluster"
+ es_wait_yellow $ESWAIT
+ cmd_create
+ fi
+}
+
+# Parse arguments
+parse_args() {
+ while [[ $# -gt 0 ]]
+ do
+ par=($(echo $1 | tr '=' '\n'))
+ echo ""
+ if [ ${#par[@]} == "2" ] ; then
+ # Equal sign found
+ key=${par[0]}
+ value=${par[1]}
+ else
+ # No equal sign
+ key="$1"
+ value="$2"
+ fi
+ shift
+ #Further shift if parameter is used
+ case $key in
+ -db|--dburl|--database)
+ DBURL="$value"
+ shift
+ ;;
+ -r|--replicas)
+ REPLICAS="$value"
+ shift
+ ;;
+ -s|--shards)
+ SHARDS="$value"
+ shift
+ ;;
+ -p|--prefix)
+ PREFIX="$value"
+ shift
+ ;;
+ -f|--file)
+ INITFILENAME="$value"
+ shift
+ ;;
+ -x|--verbose)
+ VERBOSE="${value:-0}"
+ shift
+ ;;
+ -v|--version)
+ VERSION="${value:--v1}"
+ shift
+ ;;
+ -vx|--versionx)
+ VERSION=""
+ ;;
+ -w|--wait)
+ WAITYELLOW="${value:-30s}"
+ shift
+ ;;
+ --cmd)
+ STARTUP_CMD="$value"
+ shift
+ ;;
+ --odlcluster)
+ CLUSTER_ENABLED="$value"
+ shift
+ ;;
+ --index)
+ NODE_INDEX="$value"
+ shift
+ ;;
+ *)
+ ;;
+ esac;
+ done
+}
+
+# -----------------------------------------
+# Main starts here
+
+TASK=$1
+shift
+parse_args "$@"
+
+set_definition
+
+
+echo "------------------------------"
+echo "Elasticsearch for SDN-R helper"
+echo "------------------------------"
+echo "Uses database container $SDNRNAME"
+echo "Database url $DBURL"
+echo " shards=$SHARDS replicas=$REPLICAS prefix=$PREFIX verbose=$VERBOSE version='$VERSION'"
+
+
+case "$TASK" in
+ "create")
+ getsdnrurl
+ if [ -z "$DBURL" ] ; then
+ echo "Error: unable to detect database url."
+ exit 1
+ fi
+ cmd_create
+ ;;
+ "delete")
+ getsdnrurl
+ if [ -z "$DBURL" ] ; then
+ echo "Error: unable to detect database url."
+ exit 1
+ fi
+ cmd_delete
+ ;;
+ "purge")
+ getsdnrurl
+ if [ -z "$DBURL" ] ; then
+ echo "Error: unable to detect database url."
+ exit 1
+ fi
+ cmd_purge
+ ;;
+ "initfile")
+ cmd_initfile
+ ;;
+ "startup")
+ cmd_startup
+ ;;
+ *)
+ echo "usage:"
+ echo " es-init.sh COMMAND [OPTIONS]"
+ echo " Commands:"
+ echo " create create SDN-R used indices and aliases"
+ echo " delete delete SDN-R used indices and aliases"
+ echo " initfile Create initfile for java unit tests"
+ echo " purge Clear complete database (indices and aliases)"
+ echo " startup Initial database write if node number 01"
+ echo " Options:"
+ echo -e " -db\--database DATABASEURL"
+ echo -e " -r\--replicas REPLICAS"
+ echo -e " -s\--shards SHARDS"
+ echo -e " -p\--prefix DATABASE-PREFIX"
+ echo -e " -f\--file init filename"
+ echo -e " -x\--verbose Verbose level less 0 .. 2 full"
+ echo -e " -v\--version Version prefix"
+ echo -e " -vx\--versionx Version prefix empty"
+ echo -e " -i\--ignore Ignore error responses"
+ echo -e " --odlcluster true/false if odl configured as cluster"
+ echo -e " --index Cluster node 0.."
+ echo -e " --cmd startup sub command"
+ echo " examples:"
+ echo " single node db:"
+ echo " es-init.sh create -db http://sdnrdb:9200 -r 0"
+ ;;
+esac
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
deleted file mode 100644
index bc2e3f9cf..000000000
--- a/sdnr/wt/data-provider/provider/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml
+++ /dev/null
@@ -1,68 +0,0 @@
-<?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="provider"
- class="org.onap.ccsdk.features.sdnr.wt.dataprovider.impl.DataProviderImpl"
- init-method="init" destroy-method="close">
- <property name="rpcProviderService" ref="rpcProviderService" />
- <property name="readyServlet" ref="readyServlet" />
-</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>
-
- <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>
-
- <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
deleted file mode 100644
index e87ef9d9b..000000000
--- a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestAbout.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*******************************************************************************
- * ============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.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.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.StringWriter;
-
-import javax.servlet.ServletException;
-import javax.servlet.ServletOutputStream;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-public class TestAbout {
-
- @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
deleted file mode 100644
index f1d512530..000000000
--- a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestCRUDforDatabase.java
+++ /dev/null
@@ -1,1453 +0,0 @@
-/*******************************************************************************
- * ============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.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.interrupted();
- }
- }
-
- 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", timeInterval.PERIOD_15MIN, "PM_RADIO_15M_6", "LP-MWPS-TTP-02", "a2");
- createPerformanceData("2", timeInterval.PERIOD_15MIN, "PM_RADIO_15M_4", "LP-MWPS-TTP-01", "a2");
-
- createPerformanceData("4", timeInterval.PERIOD_15MIN, "PM_RADIO_15M_6", "LP-MWPS-TTP-02", "a3");
- createPerformanceData("5", timeInterval.PERIOD_15MIN, "PM_RADIO_15M_4", "LP-MWPS-TTP-01", "a3");
- createPerformanceData("6", timeInterval.PERIOD_15MIN, "PM_RADIO_15M_7", "LP-MWPS-TTP-03", "a3");
- createPerformanceData("3", timeInterval.PERIOD_15MIN, "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", timeInterval.PERIOD_15MIN, "PM_RADIO_15M_6", "LP-MWPS-TTP-02", "a2");
- createPerformanceData("2", timeInterval.PERIOD_15MIN, "PM_RADIO_15M_4", "LP-MWPS-TTP-01", "a2");
-
- createPerformanceData("4", timeInterval.PERIOD_15MIN, "PM_RADIO_15M_6", "LP-MWPS-TTP-02", "a3");
- createPerformanceData("5", timeInterval.PERIOD_15MIN, "PM_RADIO_15M_4", "LP-MWPS-TTP-01", "a3");
- createPerformanceData("6", timeInterval.PERIOD_15MIN, "PM_RADIO_15M_7", "LP-MWPS-TTP-03", "a3");
- createPerformanceData("3", timeInterval.PERIOD_15MIN, "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...");
-
- createPerformanceData("1", timeInterval.PERIOD_24HOURS, "PM_RADIO_15M_6", "LP-MWPS-TTP-02", "a2");
- createPerformanceData("2", timeInterval.PERIOD_24HOURS, "PM_RADIO_15M_4", "LP-MWPS-TTP-01", "a2");
- String aDbId = createPerformanceData("4", timeInterval.PERIOD_24HOURS, "PM_RADIO_15M_6", "LP-MWPS-TTP-06", "a2");
-
- createPerformanceData("5", timeInterval.PERIOD_24HOURS, "PM_RADIO_15M_4", "LP-MWPS-TTP-01", "a3");
- createPerformanceData("6", timeInterval.PERIOD_24HOURS, "PM_RADIO_15M_7", "LP-MWPS-TTP-03", "a3");
- createPerformanceData("3", timeInterval.PERIOD_24HOURS, "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...");
-
- createPerformanceData("1", timeInterval.PERIOD_24HOURS, "PM_RADIO_15M_6", "LP-MWPS-TTP-02", "a2");
- createPerformanceData("2", timeInterval.PERIOD_24HOURS, "PM_RADIO_15M_4", "LP-MWPS-TTP-01", "a2");
-
- createPerformanceData("4", timeInterval.PERIOD_24HOURS, "PM_RADIO_15M_6", "LP-MWPS-TTP-02", "a3");
- createPerformanceData("5", timeInterval.PERIOD_24HOURS, "PM_RADIO_15M_4", "LP-MWPS-TTP-01", "a3");
- createPerformanceData("6", timeInterval.PERIOD_24HOURS, "PM_RADIO_15M_7", "LP-MWPS-TTP-03", "a3");
- createPerformanceData("3", timeInterval.PERIOD_24HOURS, "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 enum timeInterval{
- PERIOD_15MIN,
- PERIOD_24HOURS
- }
-
- private String createPerformanceData(String initialDbId, timeInterval 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.toString().equals("PERIOD_15MIN")) {
- 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/TestFilterConversion.java b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestFilterConversion.java
deleted file mode 100644
index 51fe76d92..000000000
--- a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestFilterConversion.java
+++ /dev/null
@@ -1,22 +0,0 @@
-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
deleted file mode 100644
index 633912579..000000000
--- a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestInitalMaintenanceObjectInDatabase.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*******************************************************************************
- * ============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/TestTimestampFilter.java b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestTimestampFilter.java
deleted file mode 100644
index c32149ba5..000000000
--- a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestTimestampFilter.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*******************************************************************************
- * ============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/TestYangProvider.java b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestYangProvider.java
deleted file mode 100644
index c911100ef..000000000
--- a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestYangProvider.java
+++ /dev/null
@@ -1,195 +0,0 @@
-/*******************************************************************************
- * ============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
deleted file mode 100644
index 142663bd2..000000000
--- a/sdnr/wt/data-provider/provider/src/test/resources/log4j.properties
+++ /dev/null
@@ -1,12 +0,0 @@
-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
deleted file mode 100644
index 164e93f54..000000000
--- a/sdnr/wt/data-provider/provider/src/test/resources/log4j2.xml
+++ /dev/null
@@ -1,17 +0,0 @@
-<?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
deleted file mode 100644
index a2f1e7e76..000000000
--- a/sdnr/wt/data-provider/provider/src/test/resources/simplelogger.properties
+++ /dev/null
@@ -1,6 +0,0 @@
-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