aboutsummaryrefslogtreecommitdiffstats
path: root/sdnr/wt/data-provider
diff options
context:
space:
mode:
Diffstat (limited to 'sdnr/wt/data-provider')
-rw-r--r--sdnr/wt/data-provider/dblib/pom.xml2
-rw-r--r--sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/SqlDBClient.java74
-rw-r--r--sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/data/HtUserdataManagerBase.java2
-rw-r--r--sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/data/HtUserdataManagerImpl.java26
-rw-r--r--sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/data/SqlDBDataProvider.java7
-rw-r--r--sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/data/entity/DatabaseIdGenerator.java1
-rw-r--r--sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/data/entity/HtDatabaseEventsService.java56
-rw-r--r--sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/data/entity/HtDatabaseMaintenanceService.java9
-rw-r--r--sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/database/SqlDBMapper.java26
-rw-r--r--sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/database/SqlDBReaderWriter.java93
-rw-r--r--sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/database/SqlDBReaderWriterFault.java4
-rw-r--r--sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/database/SqlDBReaderWriterPm.java6
-rw-r--r--sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/database/SqlDBReaderWriterUserdata.java6
-rw-r--r--sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/database/SqlDBStatusReader.java1
-rw-r--r--sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/query/CountQuery.java2
-rw-r--r--sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/query/InsertQuery.java46
-rw-r--r--sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/query/SelectQuery.java19
-rw-r--r--sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/query/SqlQuery.java9
-rw-r--r--sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/query/UpdateQuery.java4
-rw-r--r--sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/query/UpsertQuery.java4
-rw-r--r--sdnr/wt/data-provider/dblib/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/dblib/test/TestCRUDMariaDB.java4
-rw-r--r--sdnr/wt/data-provider/dblib/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/dblib/test/TestMariaDataProvider.java203
-rw-r--r--sdnr/wt/data-provider/dblib/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/dblib/test/TestQuerySyntax.java42
-rw-r--r--sdnr/wt/data-provider/dblib/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/dblib/test/util/MariaDBTestBase.java10
-rw-r--r--sdnr/wt/data-provider/dblib/src/test/resources/pmdata24h.json55
-rw-r--r--sdnr/wt/data-provider/feature/pom.xml2
-rwxr-xr-xsdnr/wt/data-provider/installer/pom.xml2
-rw-r--r--sdnr/wt/data-provider/model/pom.xml2
-rwxr-xr-xsdnr/wt/data-provider/pom.xml2
-rw-r--r--sdnr/wt/data-provider/provider/pom.xml15
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/data/entity/HtDatabaseEventsService.java6
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/data/entity/HtDatabaseMaintenanceService.java4
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/about/ODLVersionLUT.java2
-rw-r--r--sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestCRUDforDatabase.java8
-rw-r--r--sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestMapper.java93
-rw-r--r--sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestYangGenSalMappingOpenRoadm.java6
-rw-r--r--sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/util/MariaDBTestBase.java15
-rw-r--r--sdnr/wt/data-provider/setup/pom.xml2
-rw-r--r--sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/istanbul/IstanbulReleaseInformation.java146
-rw-r--r--sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/jakarta/JakartaReleaseInformation.java23
-rw-r--r--sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/MariaDBTestBase.java15
-rw-r--r--sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestMariaDBMapper.java56
42 files changed, 750 insertions, 360 deletions
diff --git a/sdnr/wt/data-provider/dblib/pom.xml b/sdnr/wt/data-provider/dblib/pom.xml
index e4bc57519..b1dd4ff04 100644
--- a/sdnr/wt/data-provider/dblib/pom.xml
+++ b/sdnr/wt/data-provider/dblib/pom.xml
@@ -28,7 +28,7 @@
<parent>
<groupId>org.onap.ccsdk.parent</groupId>
<artifactId>binding-parent</artifactId>
- <version>2.3.2</version>
+ <version>2.3.3-SNAPSHOT</version>
<relativePath/>
</parent>
diff --git a/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/SqlDBClient.java b/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/SqlDBClient.java
index ce9d4dcd1..1ed0b5f17 100644
--- a/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/SqlDBClient.java
+++ b/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/SqlDBClient.java
@@ -56,7 +56,6 @@ public class SqlDBClient {
private static final String DBVERSION_REGEX = "^([\\d]+\\.[\\d]+\\.[\\d]+)";
private static final Pattern DBVERSION_PATTERN = Pattern.compile(DBVERSION_REGEX);
private static final String SELECT_VERSION_QUERY = "SELECT @@version as version";
- private static final String LOG_PROBLEM_CLOSING_CONNECTION = "problem closing connection: ";
private static final String DBNAME_DEFAULT = "sdnrdb";
private final String dbConnectionString;
@@ -100,6 +99,7 @@ public class SqlDBClient {
} catch (SQLException e) {
LOG.warn("problem reading views: ", e);
}
+ try { data.close(); } catch (SQLException ignore) { }
return list;
}
@@ -114,6 +114,7 @@ public class SqlDBClient {
} catch (SQLException e) {
LOG.warn("problem reading tables: ", e);
}
+ try { data.close(); } catch (SQLException ignore) { }
return list;
}
@@ -155,22 +156,18 @@ public class SqlDBClient {
public boolean createTable(String query) {
boolean result = false;
PreparedStatement stmt = null;
+ Connection connection = null;
try {
- Connection connection = this.getConnection();
+ connection = this.getConnection();
stmt = connection.prepareStatement(query, Statement.RETURN_GENERATED_KEYS);
stmt.execute();
- connection.close();
+
result = true;
} catch (SQLException e) {
LOG.warn("problem creating table:", e);
} finally {
- if (stmt != null) {
- try {
- stmt.close();
- } catch (SQLException e) {
- LOG.warn("problem closing stmt:", e);
- }
- }
+ if (stmt != null) try { stmt.close(); } catch (SQLException logOrIgnore) {}
+ if (connection != null) try { connection.close(); } catch (SQLException logOrIgnore) {}
}
return result;
}
@@ -199,20 +196,17 @@ public class SqlDBClient {
boolean result = false;
SQLException innerE = null;
Statement stmt = null;
- try (Connection connection = this.getConnection()) {
+ Connection connection = null;
+ try {
+ connection= this.getConnection();
stmt = connection.createStatement();
result = stmt.execute(query);
result = stmt.getUpdateCount() > 0 ? stmt.getUpdateCount() > 0 : result;
} catch (SQLException e) {
innerE = e;
} finally {
- try {
- if (stmt != null) {
- stmt.close();
- }
- } catch (SQLException e) {
- LOG.warn(LOG_PROBLEM_CLOSING_CONNECTION, e);
- }
+ if (stmt != null) try { stmt.close(); } catch (SQLException ignore) {}
+ if (connection != null) try { connection.close(); } catch (SQLException ignore) {}
}
if (innerE != null) {
throw innerE;
@@ -224,20 +218,17 @@ public class SqlDBClient {
boolean result = false;
SQLException innerE = null;
PreparedStatement stmt = null;
- try (Connection connection = this.getConnection()) {
+ Connection connection = null;
+ try {
+ connection = this.getConnection();
stmt = connection.prepareStatement(query, Statement.RETURN_GENERATED_KEYS);
result = stmt.execute();
result = stmt.getUpdateCount() > 0 ? stmt.getUpdateCount() > 0 : result;
} catch (SQLException e) {
innerE = e;
} finally {
- try {
- if (stmt != null) {
- stmt.close();
- }
- } catch (SQLException e) {
- LOG.warn(LOG_PROBLEM_CLOSING_CONNECTION, e);
- }
+ if (stmt != null) try { stmt.close(); } catch (SQLException ignore) {}
+ if (connection != null) try { connection.close(); } catch (SQLException ignore) {}
}
if (innerE != null) {
throw innerE;
@@ -249,24 +240,22 @@ public class SqlDBClient {
String result = null;
SQLException innerE = null;
PreparedStatement stmt = null;
- try (Connection connection = this.getConnection()) {
+ ResultSet generatedKeys = null;
+ Connection connection = null;
+ try {
+ connection = this.getConnection();
stmt = connection.prepareStatement(query, Statement.RETURN_GENERATED_KEYS);
stmt.execute();
- ResultSet generatedKeys = stmt.getGeneratedKeys();
+ generatedKeys = stmt.getGeneratedKeys();
if (generatedKeys.next()) {
result = String.valueOf(generatedKeys.getLong(1));
}
} catch (SQLException e) {
innerE = e;
} finally {
- try {
- if (stmt != null) {
- stmt.close();
- }
-
- } catch (SQLException e) {
- LOG.warn(LOG_PROBLEM_CLOSING_CONNECTION, e);
- }
+ if (generatedKeys != null) try { generatedKeys.close(); } catch (SQLException ignore) {}
+ if (stmt != null) try { stmt.close(); } catch (SQLException ignore) {}
+ if (connection != null) try { connection.close(); } catch (SQLException ignore) {}
}
if (innerE != null) {
throw innerE;
@@ -291,19 +280,16 @@ public class SqlDBClient {
public ResultSet read(String query) {
ResultSet data = null;
Statement stmt = null;
- try (Connection connection = this.getConnection()) {
+ Connection connection = null;
+ try{
+ connection = this.getConnection();
stmt = connection.createStatement();
data = stmt.executeQuery(query);
} catch (SQLException e) {
LOG.warn("problem reading db for query '{}': ", query, e);
} finally {
- try {
- if (stmt != null) {
- stmt.close();
- }
- } catch (SQLException e) {
- LOG.warn(LOG_PROBLEM_CLOSING_CONNECTION, e);
- }
+ if (stmt != null) try { stmt.close(); } catch (SQLException ignore) {}
+ if (connection != null) try { connection.close(); } catch (SQLException ignore) {}
}
return data;
}
diff --git a/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/data/HtUserdataManagerBase.java b/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/data/HtUserdataManagerBase.java
index 60f28d95c..e015dd29f 100644
--- a/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/data/HtUserdataManagerBase.java
+++ b/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/data/HtUserdataManagerBase.java
@@ -74,7 +74,7 @@ public abstract class HtUserdataManagerBase implements HtUserdataManager {
@Override
public boolean setUserdata(String username, String key, String data) {
- JSONObject o = new JSONObject();
+ JSONObject o = new JSONObject(this.getUserdata(username));
o.put(key, new JSONObject(data));
return this.setUserdata(username, o.toString());
}
diff --git a/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/data/HtUserdataManagerImpl.java b/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/data/HtUserdataManagerImpl.java
index 79d963751..832d473c2 100644
--- a/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/data/HtUserdataManagerImpl.java
+++ b/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/data/HtUserdataManagerImpl.java
@@ -21,16 +21,7 @@
*/
package org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.data;
-import java.util.Arrays;
-import java.util.List;
-import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.data.rpctypehelper.QueryResult;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.database.SqlDBReaderWriterUserdata;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.EntityInput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadFaultcurrentListInputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.entity.input.FilterBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.entity.input.PaginationBuilder;
-import org.opendaylight.yangtools.yang.common.Uint32;
-import org.opendaylight.yangtools.yang.common.Uint64;
public class HtUserdataManagerImpl extends HtUserdataManagerBase {
@@ -42,7 +33,9 @@ public class HtUserdataManagerImpl extends HtUserdataManagerBase {
@Override
public boolean setUserdata(String username, String data) {
- return this.rw.write(new UserdataBuilder().setId(username).setValue(data).build(), username) != null;
+ Userdata o = new UserdataBuilder().setId(username).setValue(data).build();
+ String x = this.rw.updateOrInsert(o, username);
+ return x!=null;
}
@Override
@@ -52,17 +45,8 @@ public class HtUserdataManagerImpl extends HtUserdataManagerBase {
@Override
protected String readUserdata(String username, String defaultValue) {
- EntityInput input = new ReadFaultcurrentListInputBuilder()
- .setFilter(Arrays.asList(new FilterBuilder().setProperty("id").setFiltervalue(username).build()))
- .setPagination(new PaginationBuilder().setPage(Uint64.valueOf(1)).setSize(Uint32.valueOf(1)).build())
- .build();
- QueryResult<Userdata> result = this.rw.getData(input);
- if (result != null) {
- List<Userdata> data = result.getResult();
- Userdata user = (data != null && !data.isEmpty()) ? data.get(0) : null;
- return user == null ? defaultValue : user.getValue();
- }
- return defaultValue;
+ Userdata user = this.rw.read(username);
+ return user!=null? user.getValue():defaultValue;
}
}
diff --git a/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/data/SqlDBDataProvider.java b/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/data/SqlDBDataProvider.java
index b6df73b89..1bb30dc69 100644
--- a/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/data/SqlDBDataProvider.java
+++ b/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/data/SqlDBDataProvider.java
@@ -120,11 +120,11 @@ public class SqlDBDataProvider extends HtDatabaseEventsService implements Databa
this.mediatorserverRW = new SqlDBReaderWriter<>(this.dbClient, Entity.MediatorServer, config.getDbSuffix(),
org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.mediator.server.list.output.Data.class,
- this.dbClient.getDatabaseName(), this.controllerId).setWriteInterface(MediatorServerEntity.class);
+ this.controllerId).setWriteInterface(MediatorServerEntity.class);
this.maintenanceRW = new SqlDBReaderWriter<>(this.dbClient, Entity.Maintenancemode, config.getDbSuffix(),
org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.maintenance.list.output.Data.class,
- this.dbClient.getDatabaseName(), this.controllerId).setWriteInterface(MaintenanceEntity.class);
+ this.controllerId).setWriteInterface(MaintenanceEntity.class);
this.readStatus = new SqlDBStatusReader(this.dbClient, this.controllerId);
@@ -137,7 +137,7 @@ public class SqlDBDataProvider extends HtDatabaseEventsService implements Databa
};
this.dbMaintenanceService = new HtDatabaseMaintenanceService(this);
this.usermanager = new HtUserdataManagerImpl(new SqlDBReaderWriterUserdata(this.dbClient,
- Entity.Userdata, config.getDbSuffix(), this.dbClient.getDatabaseName(), this.controllerId));
+ Entity.Userdata, config.getDbSuffix()));
if (initControllerId) {
try {
this.setControllerId();
@@ -512,6 +512,7 @@ public class SqlDBDataProvider extends HtDatabaseEventsService implements Databa
query = String.format("INSERT INTO `%s` (`id`,`desc`) VALUES ('%s','%s')", this.controllerTableName,
this.controllerId, "");
LOG.trace(query);
+ try { data.close(); } catch (SQLException ignore) { }
return this.dbClient.write(query);
} else {
LOG.trace("controllerId already set");
diff --git a/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/data/entity/DatabaseIdGenerator.java b/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/data/entity/DatabaseIdGenerator.java
index 6244894e5..9d09a11c8 100644
--- a/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/data/entity/DatabaseIdGenerator.java
+++ b/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/data/entity/DatabaseIdGenerator.java
@@ -74,7 +74,6 @@ public class DatabaseIdGenerator {
public static String getFaultcurrentId(String nodeId, String objectId, String problemName) {
String uuId = extractUuid(objectId);
-
return String.format(FORMAT_FAULTDATA_ID, nodeId, uuId, problemName);
}
diff --git a/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/data/entity/HtDatabaseEventsService.java b/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/data/entity/HtDatabaseEventsService.java
index 88aaa583d..776c91fe5 100644
--- a/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/data/entity/HtDatabaseEventsService.java
+++ b/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/data/entity/HtDatabaseEventsService.java
@@ -40,6 +40,7 @@ import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.NetconfTimeStamp;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.types.NetconfTimeStampImpl;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.CmlogEntity;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ConnectionLogStatus;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ConnectionlogEntity;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.Entity;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.EventlogEntity;
@@ -50,6 +51,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.pro
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.Inventory;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.NetworkElementConnectionEntity;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.PmdataEntity;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.UpdateNetworkElementConnectionInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.entity.input.Filter;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.entity.input.FilterBuilder;
import org.slf4j.Logger;
@@ -89,68 +91,68 @@ public class HtDatabaseEventsService implements DataProvider {
this.dbClient = new SqlDBClient(config.getUrl(), config.getUsername(), config.getPassword());
this.connectionlogRW = new SqlDBReaderWriter<>(dbClient, Entity.Connectionlog, config.getDbSuffix(),
org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.connectionlog.list.output.Data.class,
- this.dbClient.getDatabaseName(), this.controllerId);
+ this.controllerId);
this.eventlogRW = new SqlDBReaderWriter<>(dbClient, Entity.Eventlog, config.getDbSuffix(),
org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.eventlog.list.output.Data.class,
- this.dbClient.getDatabaseName(), this.controllerId);
+ this.controllerId);
this.eventRWFaultLog = new SqlDBReaderWriter<>(dbClient, Entity.Faultlog, config.getDbSuffix(),
org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.faultlog.list.output.Data.class,
- this.dbClient.getDatabaseName(), this.controllerId);
+ this.controllerId);
this.eventRWFaultCurrent = new SqlDBReaderWriterFault<>(dbClient, Entity.Faultcurrent, config.getDbSuffix(),
org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.faultcurrent.list.output.Data.class,
- this.dbClient.getDatabaseName(), this.controllerId);
+ this.controllerId);
this.equipmentRW = new SqlDBReaderWriter<>(dbClient, Entity.Inventoryequipment, config.getDbSuffix(),
org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.inventory.list.output.Data.class,
- this.dbClient.getDatabaseName(), this.controllerId);
+ this.controllerId);
this.guicutthroughRW = new SqlDBReaderWriter<>(dbClient,
org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.Entity.Guicutthrough,
config.getDbSuffix(),
org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.gui.cut.through.entry.output.Data.class,
- this.dbClient.getDatabaseName(), this.controllerId).setWriteInterface(Guicutthrough.class);
+ this.controllerId).setWriteInterface(Guicutthrough.class);
this.networkelementConnectionRW = new SqlDBReaderWriter<>(dbClient, Entity.NetworkelementConnection,
config.getDbSuffix(),
org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.network.element.connection.list.output.Data.class,
- this.dbClient.getDatabaseName(), this.controllerId);
+ this.controllerId);
this.networkelementConnectionRW.setWriteInterface(NetworkElementConnectionEntity.class);
this.pm15mRW = new SqlDBReaderWriterPm<>(dbClient, Entity.Historicalperformance15min, config.getDbSuffix(),
org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.pmdata._15m.list.output.Data.class,
- this.dbClient.getDatabaseName(), this.controllerId);
+ this.controllerId);
this.pm24hRW = new SqlDBReaderWriterPm<>(dbClient, Entity.Historicalperformance24h, config.getDbSuffix(),
org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.pmdata._24h.list.output.Data.class,
- this.dbClient.getDatabaseName(), this.controllerId);
+ this.controllerId);
this.eventRWCMLog = new SqlDBReaderWriter<>(dbClient, Entity.Cmlog, config.getDbSuffix(),
org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.cmlog.list.output.Data.class,
- this.dbClient.getDatabaseName(), this.controllerId);
+ this.controllerId);
}
@Override
public void writeConnectionLog(ConnectionlogEntity event) {
- this.connectionlogRW.write(event, event.getId());
+ this.connectionlogRW.write(event, null);
}
@Override
public void writeEventLog(EventlogEntity event) {
- this.eventlogRW.write(event, event.getId());
+ this.eventlogRW.write(event, null);
}
@Override
public void writeFaultLog(FaultlogEntity fault) {
- this.eventRWFaultLog.write(fault, fault.getId());
+ this.eventRWFaultLog.write(fault, null);
}
@Override
public void writeCMLog(CmlogEntity cm) {
- this.eventRWCMLog.write(cm, cm.getId());
+ this.eventRWCMLog.write(cm, null);
}
@Override
public void updateFaultCurrent(FaultcurrentEntity fault) {
- final String id = fault.getId() != null ? fault.getId() : DatabaseIdGenerator.getFaultcurrentId(fault);
+ final String id = DatabaseIdGenerator.getFaultcurrentId(fault);
if (FaultEntityManager.isManagedAsCurrentProblem(fault)) {
if (FaultEntityManager.isNoAlarmIndication(fault)) {
LOG.debug("Remove from currentFaults: {}", fault.toString());
@@ -198,8 +200,7 @@ public class HtDatabaseEventsService implements DataProvider {
@Override
public int clearGuiCutThroughEntriesOfNode(String nodeName) {
- this.guicutthroughRW.remove(nodeName);
- return 0;
+ return this.guicutthroughRW.remove(nodeName);
}
@Override
@@ -213,9 +214,28 @@ public class HtDatabaseEventsService implements DataProvider {
return this.networkelementConnectionRW.updateOrInsert(ne, nodeId) != null;
}
+ /**
+ * Remove network element connection if not required
+ * This function is called onDisconnect event for netconf node
+ */
@Override
public void removeNetworkConnection(String nodeId) {
- this.networkelementConnectionRW.remove(nodeId);
+ NetworkElementConnectionEntity e = this.networkelementConnectionRW.read(nodeId);
+ Boolean isRequired = e!=null? e.getIsRequired():null;
+ if (e != null && isRequired != null) {
+ if (isRequired) {
+ LOG.debug("updating connection status for {} of required ne to disconnected", nodeId);
+ this.networkelementConnectionRW.update(new UpdateNetworkElementConnectionInputBuilder()
+ .setStatus(ConnectionLogStatus.Disconnected).build(), nodeId);
+ } else {
+ LOG.debug("remove networkelement-connection for {} entry because of non-required", nodeId);
+ this.networkelementConnectionRW.remove(nodeId);
+ }
+ } else {
+ LOG.warn("Unable to update connection-status. dbentry for {} not found in networkelement-connection",
+ nodeId);
+ }
+
}
diff --git a/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/data/entity/HtDatabaseMaintenanceService.java b/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/data/entity/HtDatabaseMaintenanceService.java
index a17c6ae48..8c549ded8 100644
--- a/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/data/entity/HtDatabaseMaintenanceService.java
+++ b/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/data/entity/HtDatabaseMaintenanceService.java
@@ -33,8 +33,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.pro
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.CreateMaintenanceOutputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.DeleteMaintenanceInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.MaintenanceEntity;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadMaintenanceListInputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadMaintenanceListOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadNetworkElementConnectionListInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadNetworkElementConnectionListOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.entity.input.Filter;
@@ -109,12 +107,7 @@ public class HtDatabaseMaintenanceService implements HtDatabaseMaintenance {
@Override
public MaintenanceEntity getMaintenance(@Nullable String nodeId) {
- ReadMaintenanceListOutput result = this.dbProvider
- .readMaintenanceList(
- new ReadMaintenanceListInputBuilder().setFilter(getFilterInput("node-id", nodeId)).build())
- .build();
- final List<Data> data = result.getData();
- return data != null ? !data.isEmpty() ? data.get(0) : null : null;
+ return this.maintenanceRw.read(DatabaseIdGenerator.getMaintenanceId(nodeId));
}
@Override
diff --git a/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/database/SqlDBMapper.java b/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/database/SqlDBMapper.java
index c63d2f16b..19323b9f7 100644
--- a/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/database/SqlDBMapper.java
+++ b/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/database/SqlDBMapper.java
@@ -60,7 +60,7 @@ public class SqlDBMapper {
private static final String ENUM_DBTYPE = "VARCHAR(100)";
private static final String BIGINT_DBTYPE = "BIGINT";
public static final String ODLID_DBCOL = "controller-id";
- private static final String ID_DBCOL = "id";
+ public static final String ID_DBCOL = "id";
private static List<Class<?>> numericClasses = Arrays.asList(Byte.class, Integer.class, Long.class,
BigInteger.class, Uint8.class, Uint16.class, Uint32.class, Uint64.class);
private static final YangToolsMapper mapper = new YangToolsMapper();
@@ -78,18 +78,19 @@ public class SqlDBMapper {
}
public static <T> String createTable(Class<T> clazz, Entity e) throws UnableToMapClassException {
- return createTable(clazz, e, "", false);
+ return createTable(clazz, e, "", false, true);
}
public static <T> String createTable(Class<T> clazz, Entity e, String suffix) throws UnableToMapClassException {
- return createTable(clazz, e, suffix, false);
+ return createTable(clazz, e, suffix, false, true);
}
public static <T> String createTable(Class<T> clazz, Entity e, boolean autoIndex) throws UnableToMapClassException {
- return createTable(clazz, e, "", false);
+ return createTable(clazz, e, "", false, true);
}
- public static <T> String createTable(Class<T> clazz, Entity e, String suffix, boolean autoIndex)
+ public static <T> String createTable(Class<T> clazz, Entity e, String suffix, boolean autoIndex,
+ boolean withControllerId)
throws UnableToMapClassException {
StringBuilder sb = new StringBuilder();
sb.append("CREATE TABLE IF NOT EXISTS `" + e.getName() + suffix + "` (\n");
@@ -99,7 +100,9 @@ public class SqlDBMapper {
} else {
sb.append("`" + ID_DBCOL + "` " + STRING_DBTYPE + " " + getColumnOptions(ID_DBCOL, STRING_DBTYPE) + ",\n");
}
- sb.append("`" + ODLID_DBCOL + "` " + ODLID_DBTYPE + " " + getColumnOptions(ODLID_DBCOL, ODLID_DBTYPE) + ",\n");
+ if(withControllerId) {
+ sb.append("`" + ODLID_DBCOL + "` " + ODLID_DBTYPE + " " + getColumnOptions(ODLID_DBCOL, ODLID_DBTYPE) + ",\n");
+ }
for (Method method : getFilteredMethods(clazz, true)) {
Class<?> valueType = method.getReturnType();
String colName = getColumnName(method);
@@ -110,8 +113,10 @@ public class SqlDBMapper {
String options = getColumnOptions(colName, dbType);
sb.append("`" + colName + "` " + dbType + " " + options + ",\n");
}
- sb.append("primary key(" + ID_DBCOL + "),");
- sb.append("foreign key(`" + ODLID_DBCOL + "`) references " + TABLENAME_CONTROLLER + "(" + ID_DBCOL + ")");
+ sb.append("primary key(" + ID_DBCOL + ")");
+ if(withControllerId) {
+ sb.append(",foreign key(`" + ODLID_DBCOL + "`) references " + TABLENAME_CONTROLLER + "(" + ID_DBCOL + ")");
+ }
sb.append(");");
return sb.toString();
@@ -350,11 +355,14 @@ public class SqlDBMapper {
public static <T> List<T> read(ResultSet data, Class<T> clazz, String column)
throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, SQLException,
InstantiationException, SecurityException, NoSuchMethodException, JsonProcessingException {
-
+ if(data==null) {
+ return Arrays.asList();
+ }
Builder<T> builder = findPOJOBuilder(clazz);
if(builder==null && column==null) {
throw new InstantiationException("unable to find builder for class "+clazz.getName());
}
+
List<T> list = new ArrayList<>();
while (data.next()) {
if (column == null) {
diff --git a/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/database/SqlDBReaderWriter.java b/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/database/SqlDBReaderWriter.java
index b5322d6ff..56e965c9f 100644
--- a/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/database/SqlDBReaderWriter.java
+++ b/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/database/SqlDBReaderWriter.java
@@ -57,34 +57,47 @@ public class SqlDBReaderWriter<T extends DataObject> {
protected final Entity entity;
private final Class<T> clazz;
protected final SqlDBClient dbService;
- private final String dbName;
protected final String controllerId;
protected final String tableName;
+ private final boolean ignoreControllerId;
- public SqlDBReaderWriter(SqlDBClient dbService, Entity e, String dbSuffix, Class<T> clazz, String dbName,
+ public SqlDBReaderWriter(SqlDBClient dbService, Entity e, String dbSuffix, Class<T> clazz,
String controllerId) {
+ this(dbService, e, dbSuffix, clazz, controllerId, false);
+ }
+
+ public SqlDBReaderWriter(SqlDBClient dbService, Entity e, String dbSuffix, Class<T> clazz,
+ String controllerId, boolean ignoreControllerId) {
this.dbService = dbService;
this.entity = e;
this.clazz = clazz;
- this.dbName = dbName;
this.tableName = this.entity.getName() + dbSuffix;
this.controllerId = controllerId;
+ this.ignoreControllerId = ignoreControllerId;
}
public long count(List<Filter> filter) throws SQLException {
String query;
if (filter == null || filter.isEmpty()) {
- query = String.format("SELECT table_rows FROM `information_schema`.`tables` "
- + "WHERE `table_schema` = '%s' AND `table_name` = '%s'", this.dbName, this.tableName);
+ // query = String.format("SELECT table_rows FROM `information_schema`.`tables` "
+ // + "WHERE `table_schema` = '%s' AND `table_name` = '%s'", this.dbName, this.tableName);
+ query = String.format("SELECT COUNT(`id`) FROM `%s`", this.tableName);
} else {
query = String.format("SELECT COUNT(`id`) FROM `%s` %s", this.tableName,
SqlQuery.getWhereExpression(filter));
}
ResultSet data = this.dbService.read(query);
+ if(data==null) {
+ return 0;
+ }
long cnt = 0;
if (data.next()) {
cnt = data.getLong(1);
}
+ try {
+ data.close();
+ } catch (SQLException ignore) {
+ }
return cnt;
}
@@ -106,11 +119,19 @@ public class SqlDBReaderWriter<T extends DataObject> {
public QueryResult<T> getData(EntityInput input) {
SelectQuery query = new SelectQuery(this.tableName, input, this.controllerId);
- LOG.trace("query={}", query.toSql());
+ if (LOG.isTraceEnabled()) {
+ LOG.trace("query={}", query.toSql());
+ }
try {
ResultSet data = this.dbService.read(query.toSql());
List<T> mappedData = SqlDBMapper.read(data, clazz);
final Map<FilterKey, Filter> filter = input.getFilter();
+ try {
+ if(data!=null) {
+ data.close();
+ }
+ } catch (SQLException ignore) {
+ }
long total = this.count(filter != null ? new ArrayList<>(filter.values()) : null, this.controllerId);
return new QueryResult<T>(mappedData, query.getPage(), query.getPageSize(), total);
} catch (SQLException | IllegalAccessException | IllegalArgumentException | InvocationTargetException
@@ -126,8 +147,11 @@ public class SqlDBReaderWriter<T extends DataObject> {
if (id == null) {
return this.writeWithoutId(object);
}
- InsertQuery<S> query = new InsertQuery<S>(this.entity, object, this.controllerId);
+ InsertQuery<S> query = new InsertQuery<S>(this.entity, object, this.controllerId, this.ignoreControllerId);
query.setId(id);
+ if (LOG.isTraceEnabled()) {
+ LOG.trace("query={}", query.toSql());
+ }
boolean success = false;
try {
success = this.dbService.write(query.toSql());
@@ -140,7 +164,11 @@ public class SqlDBReaderWriter<T extends DataObject> {
private <S extends DataObject> String writeWithoutId(S object) {
- InsertQuery<S> query = new InsertQuery<S>(this.entity, object, this.controllerId);
+ InsertQuery<S> query =
+ new InsertQuery<S>(this.entity, object, this.controllerId, this.ignoreControllerId, true);
+ if (LOG.isTraceEnabled()) {
+ LOG.trace("query={}", query.toSql());
+ }
try {
return this.dbService.writeAndReturnId(query.toSql());
} catch (SQLException e) {
@@ -150,8 +178,11 @@ public class SqlDBReaderWriter<T extends DataObject> {
}
public <S extends DataObject> String update(S object, String id) {
- UpdateQuery<S> query = new UpdateQuery<S>(this.entity, object, this.controllerId);
+ UpdateQuery<S> query = new UpdateQuery<S>(this.entity, object, this.controllerId, this.ignoreControllerId, true);
query.setId(id);
+ if (LOG.isTraceEnabled()) {
+ LOG.trace("query={}", query.toSql());
+ }
String insertedId = null;
PreparedStatement stmt = null;
try {
@@ -164,6 +195,9 @@ public class SqlDBReaderWriter<T extends DataObject> {
if (affectedRows > 0) {
insertedId = id;
}
+ if (LOG.isTraceEnabled()) {
+ LOG.trace("insertedid={}", insertedId);
+ }
} catch (SQLException e) {
LOG.warn("problem writing data into db: ", e);
} finally {
@@ -180,10 +214,12 @@ public class SqlDBReaderWriter<T extends DataObject> {
}
public <S extends DataObject> String updateOrInsert(S object, String id) {
- UpsertQuery<S> query = new UpsertQuery<S>(this.entity, object, this.controllerId);
+ UpsertQuery<S> query = new UpsertQuery<S>(this.entity, object, this.controllerId, this.ignoreControllerId, true);
query.setId(id);
String insertedId = null;
- LOG.trace("query={}", query.toSql());
+ if (LOG.isTraceEnabled()) {
+ LOG.trace("query={}", query.toSql());
+ }
PreparedStatement stmt = null;
try {
Connection connection = this.dbService.getConnection();
@@ -221,6 +257,9 @@ public class SqlDBReaderWriter<T extends DataObject> {
public int remove(List<Filter> filters) {
DeleteQuery query = new DeleteQuery(this.entity, filters);
+ if (LOG.isTraceEnabled()) {
+ LOG.trace("query={}", query.toSql());
+ }
int affectedRows = 0;
PreparedStatement stmt = null;
try {
@@ -249,9 +288,16 @@ public class SqlDBReaderWriter<T extends DataObject> {
public <S extends DataObject> List<S> readAll(Class<S> clazz) {
SelectQuery query = new SelectQuery(this.tableName);
+ if (LOG.isTraceEnabled()) {
+ LOG.trace("query={}", query.toSql());
+ }
try {
ResultSet data = this.dbService.read(query.toSql());
List<S> mappedData = SqlDBMapper.read(data, clazz);
+ try {
+ data.close();
+ } catch (SQLException ignore) {
+ }
return mappedData;
} catch (SQLException | IllegalAccessException | IllegalArgumentException | InvocationTargetException
| InstantiationException | SecurityException | NoSuchMethodException | JsonProcessingException e) {
@@ -262,9 +308,16 @@ public class SqlDBReaderWriter<T extends DataObject> {
public List<String> readAll(String key) {
SelectQuery query = new SelectQuery(this.tableName, key, this.controllerId).groupBy(key);
+ if (LOG.isTraceEnabled()) {
+ LOG.trace("query={}", query.toSql());
+ }
try {
ResultSet data = this.dbService.read(query.toSql());
List<String> mappedData = SqlDBMapper.read(data, String.class, key);
+ try {
+ data.close();
+ } catch (SQLException ignore) {
+ }
return mappedData;
} catch (SQLException | IllegalAccessException | IllegalArgumentException | InvocationTargetException
| InstantiationException | SecurityException | NoSuchMethodException | JsonProcessingException e) {
@@ -272,4 +325,22 @@ public class SqlDBReaderWriter<T extends DataObject> {
}
return null;
}
+
+ public T read(String id) {
+ SelectQuery query =
+ new SelectQuery(this.tableName, this.controllerId).addFilter(SqlDBMapper.ID_DBCOL, id);
+ if (LOG.isTraceEnabled()) {
+ LOG.trace("query={}", query.toSql());
+ }
+ T item = null;
+ try {
+ ResultSet data = this.dbService.read(query.toSql());
+ List<T> mappedData = SqlDBMapper.read(data, clazz);
+ item = mappedData.size()>0? mappedData.get(0): null;
+ } catch (SQLException | IllegalAccessException | IllegalArgumentException | InvocationTargetException
+ | InstantiationException | SecurityException | NoSuchMethodException | JsonProcessingException e) {
+ LOG.warn("problem reading data {}: ", this.entity, e);
+ }
+ return item;
+ }
}
diff --git a/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/database/SqlDBReaderWriterFault.java b/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/database/SqlDBReaderWriterFault.java
index 2d4e26eea..86d888a16 100644
--- a/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/database/SqlDBReaderWriterFault.java
+++ b/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/database/SqlDBReaderWriterFault.java
@@ -30,9 +30,9 @@ public class SqlDBReaderWriterFault<T extends DataObject> extends SqlDBReaderWri
private static final String NODE_KEY = "node-id";
- public SqlDBReaderWriterFault(SqlDBClient dbService, Entity e, String dbSuffix, Class<T> clazz, String dbName,
+ public SqlDBReaderWriterFault(SqlDBClient dbService, Entity e, String dbSuffix, Class<T> clazz,
String controllerId) {
- super(dbService, e, dbSuffix, clazz, dbName, controllerId);
+ super(dbService, e, dbSuffix, clazz, controllerId);
}
public List<String> getAllNodes() {
diff --git a/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/database/SqlDBReaderWriterPm.java b/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/database/SqlDBReaderWriterPm.java
index 021741bd8..22aabc429 100644
--- a/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/database/SqlDBReaderWriterPm.java
+++ b/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/database/SqlDBReaderWriterPm.java
@@ -53,9 +53,9 @@ public class SqlDBReaderWriterPm<T extends DataObject> extends SqlDBReaderWriter
private static final FilterKey FILTERKEY = new FilterKey(KEY);
- public SqlDBReaderWriterPm(SqlDBClient dbService, Entity e, String dbSuffix, Class<T> clazz, String dbName,
+ public SqlDBReaderWriterPm(SqlDBClient dbService, Entity e, String dbSuffix, Class<T> clazz,
String controllerId) {
- super(dbService, e, dbSuffix, clazz, dbName, controllerId);
+ super(dbService, e, dbSuffix, clazz, controllerId);
}
/**
@@ -83,6 +83,7 @@ public class SqlDBReaderWriterPm<T extends DataObject> extends SqlDBReaderWriter
try {
ResultSet data = this.dbService.read(query.toSql());
List<String> mappedData = SqlDBMapper.read(data, String.class, UUID_KEY);
+ try { data.close(); } catch (SQLException ignore) { }
Map<FilterKey, Filter> inpFilter = input.getFilter();
long total = this.count(inpFilter != null ? new ArrayList<>(inpFilter.values()) : null, this.controllerId);
return new QueryResult<>(mappedData, query.getPage(), query.getPageSize(), total);
@@ -114,6 +115,7 @@ public class SqlDBReaderWriterPm<T extends DataObject> extends SqlDBReaderWriter
try {
ResultSet data = this.dbService.read(query.toSql());
List<String> mappedData = SqlDBMapper.read(data, String.class, NODE_KEY);
+ try { data.close(); } catch (SQLException ignore) { }
Map<FilterKey, Filter> inpFilter = input.getFilter();
long total = this.count(inpFilter != null ? new ArrayList<>(inpFilter.values()) : null, this.controllerId);
return new QueryResult<>(mappedData, query.getPage(), query.getPageSize(), total);
diff --git a/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/database/SqlDBReaderWriterUserdata.java b/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/database/SqlDBReaderWriterUserdata.java
index 2c849ac67..258cd160f 100644
--- a/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/database/SqlDBReaderWriterUserdata.java
+++ b/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/database/SqlDBReaderWriterUserdata.java
@@ -27,11 +27,11 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.pro
public class SqlDBReaderWriterUserdata extends SqlDBReaderWriter<Userdata> {
- public SqlDBReaderWriterUserdata(SqlDBClient dbService, Entity e, String dbSuffix, String dbName,
- String controllerId) {
- super(dbService, e, dbSuffix, Userdata.class, dbName, controllerId);
+ public SqlDBReaderWriterUserdata(SqlDBClient dbService, Entity e, String dbSuffix) {
+ super(dbService, e, dbSuffix, Userdata.class, null, true);
}
+
}
diff --git a/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/database/SqlDBStatusReader.java b/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/database/SqlDBStatusReader.java
index c98ba388d..b0b169d18 100644
--- a/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/database/SqlDBStatusReader.java
+++ b/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/database/SqlDBStatusReader.java
@@ -74,6 +74,7 @@ public class SqlDBStatusReader {
}
}
+ try { data.close(); } catch (SQLException ignore) { }
} catch (SQLException e) {
LOG.warn("problem reading status:", e);
}
diff --git a/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/query/CountQuery.java b/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/query/CountQuery.java
index c499fefb8..1c1ec622b 100644
--- a/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/query/CountQuery.java
+++ b/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/query/CountQuery.java
@@ -59,7 +59,7 @@ public class CountQuery implements SqlQuery {
this(e);
Map<FilterKey, Filter> filter = input != null ? input.getFilter() : null;
if (filter != null && filter.size() > 0) {
- this.filters.addAll(filters);
+ this.filters.addAll(filter.values());
}
if (controllerId != null) {
this.addFilter(SqlDBMapper.ODLID_DBCOL, controllerId);
diff --git a/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/query/InsertQuery.java b/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/query/InsertQuery.java
index 108888ad0..f52fbd55a 100644
--- a/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/query/InsertQuery.java
+++ b/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/query/InsertQuery.java
@@ -39,17 +39,28 @@ public class InsertQuery<T extends DataObject> implements SqlQuery {
protected final Entity entity;
private final String controllerId;
+ private final boolean ignoreControllerId;
private final T object;
private final boolean ignoreNull;
private String id;
+ private final boolean ignoreIdField;
public InsertQuery(Entity e, T object, String controllerId) {
+ this(e, object, controllerId, SqlQuery.DEFAULT_IGNORE_CONTROLLERID);
+ }
+
+ public InsertQuery(Entity e, T object, String controllerId, boolean ignoreControllerId) {
+ this(e, object, controllerId, ignoreControllerId, SqlQuery.DEFAULT_IGNORE_ID_FIELD);
+ }
+
+ public InsertQuery(Entity e, T object, String controllerId, boolean ignoreControllerId, boolean ignoreIdField) {
this.entity = e;
this.controllerId = controllerId;
this.object = object;
this.ignoreNull = true;
this.id = null;
-
+ this.ignoreControllerId = ignoreControllerId;
+ this.ignoreIdField = ignoreIdField;
}
@Override
@@ -63,8 +74,8 @@ public class InsertQuery<T extends DataObject> implements SqlQuery {
return null;
}
- protected String toSqlWithError() throws IllegalAccessException, IllegalArgumentException, InvocationTargetException,
- JsonProcessingException {
+ protected String toSqlWithError() throws IllegalAccessException, IllegalArgumentException,
+ InvocationTargetException, JsonProcessingException {
Class<?> cls = this.object.getClass();
List<DBKeyValuePair<String>> kvps = new ArrayList<>();
List<String> cols = new ArrayList<>();
@@ -78,26 +89,37 @@ public class InsertQuery<T extends DataObject> implements SqlQuery {
m.setAccessible(true);
value = m.invoke(this.object);
col = SqlDBMapper.getColumnName(m);
- if (col.equals("id") && this.id != null) {
- value = this.id;
+ if (col.equals("id")) {
+ if (this.ignoreIdField) {
+ continue;
+ }
+ if (this.id != null) {
+ value = this.id;
+ }
}
if (ignoreNull && value == null) {
continue;
}
- DBKeyValuePair<String> kvp = SqlDBMapper.getEscapedKeyValue(m,col, value);
+ DBKeyValuePair<String> kvp = SqlDBMapper.getEscapedKeyValue(m, col, value);
cols.add(kvp.getKey());
args.add(kvp.getValue());
kvps.add(kvp);
}
if (this.id != null && !cols.contains("`id`")) {
cols.add("`id`");
- args.add("'"+this.id+"'");
+ args.add("'" + this.id + "'");
+ }
+ if (!this.ignoreControllerId) {
+ args.add("'" + this.controllerId + "'");
+ }
+ sb.append(String.join(",", cols));
+ if (!this.ignoreControllerId) {
+ sb.append(",`" + SqlDBMapper.ODLID_DBCOL + "`) VALUES (");
+ } else {
+ sb.append(") VALUES (");
}
- args.add("'"+this.controllerId+"'");
- sb.append( String.join(",", cols));
- sb.append(",`" + SqlDBMapper.ODLID_DBCOL + "`) VALUES (");
- sb.append( String.join(",", args)+" )");
- this.appendAdditionalToQuery(sb,kvps);
+ sb.append(String.join(",", args) + " )");
+ this.appendAdditionalToQuery(sb, kvps);
return sb.toString();
}
diff --git a/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/query/SelectQuery.java b/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/query/SelectQuery.java
index 2b3f9f3fa..6403a5c1d 100644
--- a/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/query/SelectQuery.java
+++ b/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/query/SelectQuery.java
@@ -54,9 +54,11 @@ public class SelectQuery implements SqlQuery {
private final List<String> groups;
public SelectQuery(String tableName) {
- this(tableName, Arrays.asList("*"), null);
+ this(tableName, (String)null);
+ }
+ public SelectQuery(String tableName, String controllerId) {
+ this(tableName, Arrays.asList("*"), controllerId);
}
-
public SelectQuery(String tableName, List<String> fields, String controllerId) {
this.tableName = tableName;
this.fields = fields;
@@ -105,18 +107,21 @@ public class SelectQuery implements SqlQuery {
}
- public void addFilter(String property, String filtervalue) {
+ public SelectQuery addFilter(String property, String filtervalue) {
this.addFilter(new FilterBuilder().setProperty(property).setFiltervalue(filtervalue).build());
+ return this;
}
private static Filter cleanFilter(Filter filter) {
- if (filter.getFiltervalue() != null
- && (filter.getFiltervalues() == null || filter.getFiltervalues().isEmpty())) {
+ final String sFilter = filter.getFiltervalue();
+ final List<String> sFilters = filter.getFiltervalues();
+ //if only single filter value is set
+ if (sFilter != null && (sFilters == null || sFilter.isEmpty())) {
return "*".equals(filter.getFiltervalue()) ? null : filter;
} else {
List<String> list = new ArrayList<>(filter.getFiltervalues());
- if (filter.getFiltervalue() != null && !filter.getFiltervalue().isEmpty()) {
- list.add(filter.getFiltervalue());
+ if (sFilter != null && !sFilter.isEmpty()) {
+ list.add(sFilter);
}
if (list.size() == 1 && "*".equals(list.get(0))) {
return null;
diff --git a/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/query/SqlQuery.java b/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/query/SqlQuery.java
index 82f10b1e5..3e26d0935 100644
--- a/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/query/SqlQuery.java
+++ b/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/query/SqlQuery.java
@@ -27,6 +27,7 @@ import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.TimeZone;
+import java.util.stream.Collectors;
import org.eclipse.jdt.annotation.Nullable;
import org.onap.ccsdk.features.sdnr.wt.common.database.data.DbFilter;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.query.filters.DBFilterKeyValuePair;
@@ -46,12 +47,15 @@ public interface SqlQuery {
static final String MARIADB_TIMESTAMP_REPLACER_MIN = "0000-00-00 00:00:00";
static final int MARIADB_TIMESTAMP_REPLACER_MIN_LENGTH = MARIADB_TIMESTAMP_REPLACER_MIN.length();
static final int MARIADB_TIMESTAMP_REPLACER_MAX_LENGTH = MARIADB_TIMESTAMP_REPLACER.length();
+ static final boolean DEFAULT_IGNORE_CONTROLLERID = false;
+ static final boolean DEFAULT_IGNORE_ID_FIELD = false;
public static String getWhereExpression(List<Filter> filters) {
if (filters == null) {
return "";
}
StringBuilder sb = new StringBuilder();
+ filters = filters.stream().filter(e -> !"*".equals(e.getFiltervalue())).collect(Collectors.toList());
if (!filters.isEmpty()) {
sb.append(" WHERE (" + getFilterExpression(filters.get(0)) + ")");
@@ -64,7 +68,8 @@ public interface SqlQuery {
public static String getFilterExpression(Filter filter) {
String property = filter.getProperty();
- List<String> values = collectValues(filter.getFiltervalue(), filter.getFiltervalues());
+ List<String> values = collectValues(filter.getFiltervalue(), filter.getFiltervalues()).stream()
+ .filter(e -> !"*".equals(e)).collect(Collectors.toList());
if (values.size() == 1) {
return getFilterExpression(property, values.get(0));
} else if (values.size() > 1) {
@@ -225,7 +230,7 @@ public interface SqlQuery {
}
private static String netconfToMariaDBTimestamp(String ts) {
- if(ts==null) {
+ if (ts == null) {
return null;
}
String v = ts.replace("T", " ").replace("Z", "");
diff --git a/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/query/UpdateQuery.java b/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/query/UpdateQuery.java
index b47b03042..dc81161ee 100644
--- a/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/query/UpdateQuery.java
+++ b/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/query/UpdateQuery.java
@@ -44,10 +44,10 @@ public class UpdateQuery<T extends DataObject> implements SqlQuery {
private String id;
public UpdateQuery(Entity e, T object) {
- this(e, object, null);
+ this(e, object, null, SqlQuery.DEFAULT_IGNORE_CONTROLLERID, SqlQuery.DEFAULT_IGNORE_ID_FIELD);
}
- public UpdateQuery(Entity e, T object, String controllerId) {
+ public UpdateQuery(Entity e, T object, String controllerId, boolean ignoreControllerId, boolean ignoreIdField) {
this.entity = e;
this.controllerId = controllerId;
this.object = object;
diff --git a/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/query/UpsertQuery.java b/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/query/UpsertQuery.java
index e6f1e13cb..39c505454 100644
--- a/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/query/UpsertQuery.java
+++ b/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/query/UpsertQuery.java
@@ -32,6 +32,10 @@ public class UpsertQuery<T extends DataObject> extends InsertQuery<T> {
super(e, object, controllerId);
}
+ public UpsertQuery(Entity e, T object, String controllerId, boolean ignoreControllerId, boolean ignoreIdField) {
+ super(e, object, controllerId, ignoreControllerId, ignoreIdField);
+
+ }
@Override
protected void appendAdditionalToQuery(StringBuilder sb, List<DBKeyValuePair<String>> keyValues) {
diff --git a/sdnr/wt/data-provider/dblib/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/dblib/test/TestCRUDMariaDB.java b/sdnr/wt/data-provider/dblib/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/dblib/test/TestCRUDMariaDB.java
index ad4ab6789..1dd9f725e 100644
--- a/sdnr/wt/data-provider/dblib/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/dblib/test/TestCRUDMariaDB.java
+++ b/sdnr/wt/data-provider/dblib/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/dblib/test/TestCRUDMariaDB.java
@@ -105,6 +105,7 @@ public class TestCRUDMariaDB {
e.printStackTrace();
fail("unable to read size");
}
+ try { data.close(); } catch (SQLException ignore) { }
//create entry
success = false;
try {
@@ -125,6 +126,7 @@ public class TestCRUDMariaDB {
e.printStackTrace();
fail("unable to verify write");
}
+ try { data.close(); } catch (SQLException ignore) { }
//update entry
success = false;
try {
@@ -145,6 +147,7 @@ public class TestCRUDMariaDB {
e.printStackTrace();
fail("unable to verify write");
}
+ try { data.close(); } catch (SQLException ignore) { }
//delete entry
success = false;
try {
@@ -161,6 +164,7 @@ public class TestCRUDMariaDB {
e.printStackTrace();
fail("unable to verify delete. size>0");
}
+ try { data.close(); } catch (SQLException ignore) { }
}
@Test
diff --git a/sdnr/wt/data-provider/dblib/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/dblib/test/TestMariaDataProvider.java b/sdnr/wt/data-provider/dblib/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/dblib/test/TestMariaDataProvider.java
index b4e0584b0..c9cf27c68 100644
--- a/sdnr/wt/data-provider/dblib/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/dblib/test/TestMariaDataProvider.java
+++ b/sdnr/wt/data-provider/dblib/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/dblib/test/TestMariaDataProvider.java
@@ -24,6 +24,8 @@
package org.onap.ccsdk.features.sdnr.wt.dataprovider.dblib.test;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.io.IOException;
import java.sql.SQLException;
@@ -34,14 +36,17 @@ import java.util.Map;
import java.util.concurrent.TimeUnit;
import org.json.JSONArray;
import org.json.JSONException;
+import org.json.JSONObject;
import org.junit.AfterClass;
import org.junit.BeforeClass;
-import org.junit.Ignore;
import org.junit.Test;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.SqlDBClient;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.data.SqlDBDataProvider;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.database.SqlDBReaderWriter;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.query.DeleteQuery;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.dblib.test.util.MariaDBTestBase;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.HtDatabaseMaintenance;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.HtUserdataManager;
import org.onap.ccsdk.features.sdnr.wt.yang.mapper.YangToolsMapper;
import org.opendaylight.netconf.shaded.sshd.common.util.io.IoUtils;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime;
@@ -57,6 +62,9 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.pro
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.CreateMediatorServerInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.CreateMediatorServerInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.CreateMediatorServerOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.CreateNetworkElementConnectionOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.DeleteMaintenanceInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.DeleteMaintenanceInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.DeleteMediatorServerInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.DeleteMediatorServerInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.DeleteNetworkElementConnectionInput;
@@ -72,6 +80,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.pro
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.Guicutthrough;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.GuicutthroughBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.Inventory;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.MaintenanceEntity;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.NetworkElementConnectionBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.NetworkElementConnectionEntity;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.NetworkElementDeviceType;
@@ -90,10 +99,14 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.pro
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadPmdata15mDeviceListOutputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadPmdata15mListOutputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadPmdata15mLtpListOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadPmdata24hDeviceListOutputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadPmdata24hListOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadPmdata24hLtpListOutputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadStatusOutputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.SeverityType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.SourceType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.UpdateMaintenanceInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.UpdateMaintenanceInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.UpdateMediatorServerInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.UpdateMediatorServerInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.UpdateNetworkElementConnectionInput;
@@ -102,6 +115,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.pro
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.entity.input.FilterBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.entity.input.FilterKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.entity.input.PaginationBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.network.element.connection.list.output.Data;
import org.opendaylight.yangtools.yang.common.Uint32;
import org.opendaylight.yangtools.yang.common.Uint64;
import ch.vorburger.exec.ManagedProcessException;
@@ -112,6 +126,8 @@ public class TestMariaDataProvider {
private static final String NODEID1 = "node1";
private static final String NODEID2 = "node2";
private static final String NODEID3 = "node3";
+ private static final String NODEID4 = "node4";
+ private static final String NODEID5 = "node5";
private static final String PROBLEM1 = "problem1";
private static final String TIME1 = "2021-05-25T05:12:55.0Z";
private static final String TIME2 = "2021-05-25T05:12:56.0Z";
@@ -121,6 +137,7 @@ public class TestMariaDataProvider {
private static final String URI2 = "http://localhost:8181";
private static final String URI3 = "http://localhost:8181";
private static final String PATH = "https://samsung.com/3GPP/simulation/network-function/ves";
+ private static final String USERNAME = "admin";
private static MariaDBTestBase testBase;
private static SqlDBDataProvider dbProvider;
private static SqlDBClient dbClient;
@@ -176,12 +193,43 @@ public class TestMariaDataProvider {
assertEquals(1, status.getData().get(0).getFaults().getMinors().intValue());
assertEquals(0, status.getData().get(0).getFaults().getWarnings().intValue());
+ List<String> nodeList = dbProvider.getAllNodesWithCurrentAlarms();
+ assertTrue(nodeList.contains(NODEID1));
+ assertEquals(1,nodeList.size());
+
faultCurrent1 = new FaultcurrentBuilder().setNodeId(NODEID1).setCounter(1).setObjectId("obj")
.setProblem(PROBLEM1).setTimestamp(DateAndTime.getDefaultInstance(TIME1))
.setSeverity(SeverityType.NonAlarmed).setId(String.format("%s/%s", NODEID1, PROBLEM1)).build();
dbProvider.updateFaultCurrent(faultCurrent1);
faultCurrents = dbProvider.readFaultCurrentList(createInput("node-id", NODEID1, 1, 20));
assertEquals(1, faultCurrents.getData().size());
+
+
+ }
+
+ @Test
+ public void testSerializeDeserialize() {
+
+ try {
+ CreateNetworkElementConnectionOutputBuilder necon = dbProvider.createNetworkElementConnection(
+ new NetworkElementConnectionBuilder().setNodeId(NODEID1).setIsRequired(Boolean.TRUE).build());
+ List<Data> netestList =
+ dbProvider.readNetworkElementConnectionList(createInput("node-id", NODEID1, 1, 20)).getData();
+
+ assertNotNull(necon);
+ assertEquals(1, netestList.size());
+ assertTrue(netestList.get(0).getIsRequired());
+ SqlDBReaderWriter<Data> dbrw = new SqlDBReaderWriter<>(dbClient, Entity.NetworkelementConnection,
+ MariaDBTestBase.SUFFIX,
+ Data.class,
+ CONTROLLERID);
+ Data e = dbrw.read(NODEID1);
+ assertNotNull(e);
+
+ } catch (IOException e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
}
@Test
@@ -204,6 +252,7 @@ public class TestMariaDataProvider {
dbProvider.writeFaultLog(fault2);
faultlogs = dbProvider.readFaultLogList(createInput("node-id", NODEID1, 1, 20));
assertEquals(2, faultlogs.getData().size());
+
}
@Test
@@ -211,28 +260,16 @@ public class TestMariaDataProvider {
ReadCmlogListOutputBuilder cmlogs = dbProvider.readCMLogList(createInput(1, 20));
assertEquals(0, cmlogs.getData().size());
- CmlogEntity cm1 = new CmlogBuilder()
- .setNodeId(NODEID2)
- .setCounter(1)
- .setTimestamp(DateAndTime.getDefaultInstance(TIME1))
- .setObjectId("obj")
- .setNotificationType(CmNotificationType.NotifyMOIChanges)
- .setNotificationId("1")
- .setSourceIndicator(CmSourceIndicator.MANAGEMENTOPERATION)
- .setPath(PATH)
- .setValue("pnf-registration: true")
- .build();
- CmlogEntity cm2 = new CmlogBuilder()
- .setNodeId(NODEID2)
- .setCounter(2)
- .setTimestamp(DateAndTime.getDefaultInstance(TIME2))
- .setObjectId("obj")
- .setNotificationType(CmNotificationType.NotifyMOIChanges)
- .setNotificationId("2")
- .setSourceIndicator(CmSourceIndicator.UNKNOWN)
- .setPath(PATH)
- .setValue("pnf-registration: false")
- .build();
+ CmlogEntity cm1 =
+ new CmlogBuilder().setNodeId(NODEID2).setCounter(1).setTimestamp(DateAndTime.getDefaultInstance(TIME1))
+ .setObjectId("obj").setNotificationType(CmNotificationType.NotifyMOIChanges)
+ .setNotificationId("1").setSourceIndicator(CmSourceIndicator.MANAGEMENTOPERATION).setPath(PATH)
+ .setValue("pnf-registration: true").build();
+ CmlogEntity cm2 =
+ new CmlogBuilder().setNodeId(NODEID2).setCounter(2).setTimestamp(DateAndTime.getDefaultInstance(TIME2))
+ .setObjectId("obj").setNotificationType(CmNotificationType.NotifyMOIChanges)
+ .setNotificationId("2").setSourceIndicator(CmSourceIndicator.UNKNOWN).setPath(PATH)
+ .setValue("pnf-registration: false").build();
dbProvider.writeCMLog(cm1);
dbProvider.writeCMLog(cm2);
@@ -240,10 +277,10 @@ public class TestMariaDataProvider {
assertEquals(2, cmlogs.getData().size());
List<CmlogEntity> cmLogEntityList = List.of(cm1, cm2);
- assertEquals("node2",cmLogEntityList.get(0).getNodeId());
- assertEquals("obj",cmLogEntityList.get(0).getObjectId());
- assertEquals(CmNotificationType.NotifyMOIChanges,cmLogEntityList.get(0).getNotificationType());
- assertEquals("2",cmLogEntityList.get(1).getNotificationId());
+ assertEquals("node2", cmLogEntityList.get(0).getNodeId());
+ assertEquals("obj", cmLogEntityList.get(0).getObjectId());
+ assertEquals(CmNotificationType.NotifyMOIChanges, cmLogEntityList.get(0).getNotificationType());
+ assertEquals("2", cmLogEntityList.get(1).getNotificationId());
}
@@ -383,6 +420,45 @@ public class TestMariaDataProvider {
data = dbProvider.readMaintenanceList(createInput(1, 20));
assertEquals(3, data.getData().size());
+ UpdateMaintenanceInput update1 =
+ new UpdateMaintenanceInputBuilder().setId(NODEID1).setNodeId(NODEID1).setActive(false).build();
+ try {
+ dbProvider.updateMaintenance(update1);
+ } catch (IOException e) {
+ e.printStackTrace();
+ fail("unable to update maintenance data");
+ }
+ data = dbProvider.readMaintenanceList(createInput("active","false",1, 20));
+ assertEquals(1, data.getData().size());
+ DeleteMaintenanceInput delete1 = new DeleteMaintenanceInputBuilder().setId(NODEID1).build();
+ try {
+ dbProvider.deleteMaintenance(delete1);
+ } catch (IOException e) {
+ e.printStackTrace();
+ fail("unable to delete maintenance data");
+ }
+ data = dbProvider.readMaintenanceList(createInput(1, 20));
+ assertEquals(2, data.getData().size());
+ try {
+ dbClient.delete(new DeleteQuery(Entity.Maintenancemode, null).toSql());
+ } catch (SQLException e) {
+ e.printStackTrace();
+ fail("problem clearing faultlog");
+ }
+ final String nodeId = "maint_node1";
+ HtDatabaseMaintenance maintenanceService = dbProvider.getHtDatabaseMaintenance();
+ MaintenanceEntity e = maintenanceService.createIfNotExists(nodeId);
+ assertNotNull(e);
+ assertEquals(nodeId,e.getNodeId());
+ MaintenanceEntity e2 = new CreateMaintenanceInputBuilder(e).setActive(true).build();
+ e = maintenanceService.setMaintenance(e2);
+ assertNotNull(e);
+ assertEquals(nodeId,e.getNodeId());
+ assertTrue(e.getActive());
+ maintenanceService.deleteIfNotRequired(nodeId);
+ data = dbProvider.readMaintenanceList(createInput("node-id",nodeId,1, 20));
+ assertEquals(0, data.getData().size());
+
}
@Test
@@ -456,22 +532,26 @@ public class TestMariaDataProvider {
NetworkElementConnectionEntity ne2 = new NetworkElementConnectionBuilder().setNodeId(NODEID2)
.setHost("10.20.30.55").setPort(Uint32.valueOf(8300)).setIsRequired(false).setUsername("user")
.setPassword("passwd").setStatus(ConnectionLogStatus.Connecting).build();
+ NetworkElementConnectionEntity ne3 = new NetworkElementConnectionBuilder().setNodeId(NODEID3)
+ .setHost("10.20.30.55").setPort(Uint32.valueOf(8300)).setIsRequired(false).setUsername("user")
+ .setPassword("passwd").setStatus(ConnectionLogStatus.Connecting).build();
try {
dbProvider.createNetworkElementConnection(ne1);
dbProvider.createNetworkElementConnection(ne2);
+ dbProvider.updateNetworkConnection22(ne3, NODEID3);
} catch (IOException e) {
e.printStackTrace();
fail("problem creating neconnection");
}
data = dbProvider.readNetworkElementConnectionList(createInput(1, 20));
- assertEquals(2, data.getData().size());
+ assertEquals(3, data.getData().size());
NetworkElementConnectionEntity update1 = new NetworkElementConnectionBuilder()
.setStatus(ConnectionLogStatus.Connected).setDeviceType(NetworkElementDeviceType.ORAN).build();
dbProvider.updateNetworkConnectionDeviceType(update1, NODEID1);
data = dbProvider.readNetworkElementConnectionList(createInput("node-id", NODEID1, 1, 20));
assertEquals(1, data.getData().size());
assertEquals(NetworkElementDeviceType.ORAN, data.getData().get(0).getDeviceType());
- assertEquals(true, data.getData().get(0).isIsRequired());
+ assertEquals(true, data.getData().get(0).getIsRequired());
UpdateNetworkElementConnectionInput update2 = new UpdateNetworkElementConnectionInputBuilder().setId(NODEID2)
.setHost("10.20.55.44").setIsRequired(true).build();
try {
@@ -483,7 +563,7 @@ public class TestMariaDataProvider {
data = dbProvider.readNetworkElementConnectionList(createInput("node-id", NODEID2, 1, 20));
assertEquals(1, data.getData().size());
assertEquals("10.20.55.44", data.getData().get(0).getHost());
- assertEquals(true, data.getData().get(0).isIsRequired());
+ assertEquals(true, data.getData().get(0).getIsRequired());
ReadStatusOutputBuilder status = null;
try {
@@ -493,10 +573,10 @@ public class TestMariaDataProvider {
fail("failed to read status");
}
assertEquals(1, status.getData().get(0).getNetworkElementConnections().getConnected().intValue());
- assertEquals(1, status.getData().get(0).getNetworkElementConnections().getConnecting().intValue());
+ assertEquals(2, status.getData().get(0).getNetworkElementConnections().getConnecting().intValue());
assertEquals(0, status.getData().get(0).getNetworkElementConnections().getDisconnected().intValue());
assertEquals(0, status.getData().get(0).getNetworkElementConnections().getMounted().intValue());
- assertEquals(2, status.getData().get(0).getNetworkElementConnections().getTotal().intValue());
+ assertEquals(3, status.getData().get(0).getNetworkElementConnections().getTotal().intValue());
assertEquals(0, status.getData().get(0).getNetworkElementConnections().getUnableToConnect().intValue());
assertEquals(0, status.getData().get(0).getNetworkElementConnections().getUndefined().intValue());
assertEquals(0, status.getData().get(0).getNetworkElementConnections().getUnmounted().intValue());
@@ -513,10 +593,40 @@ public class TestMariaDataProvider {
data = dbProvider.readNetworkElementConnectionList(createInput("node-id", NODEID1, 1, 20));
assertEquals(0, data.getData().size());
data = dbProvider.readNetworkElementConnectionList(createInput(1, 20));
- assertEquals(1, data.getData().size());
+ assertEquals(2, data.getData().size());
+
}
@Test
+ public void testUserdata() {
+ HtUserdataManager mgr = dbProvider.getUserManager();
+ String userdata = mgr.getUserdata(USERNAME);
+ assertEquals("{}",userdata);
+ JSONObject o = new JSONObject();
+ o.put("key1", false);
+ o.put("key2","value2");
+ boolean result = mgr.setUserdata(USERNAME, o.toString());
+ assertTrue(result);
+ userdata = mgr.getUserdata(USERNAME);
+ o = new JSONObject(userdata);
+ assertEquals(false,o.getBoolean("key1"));
+ assertEquals("value2",o.getString("key2"));
+ o = new JSONObject();
+ o.put("enabled", true);
+ o.put("name","abcdef");
+ result = mgr.setUserdata(USERNAME,"app1",o.toString());
+ assertTrue(result);
+ userdata = mgr.getUserdata(USERNAME);
+ o = new JSONObject(userdata);
+ assertEquals(false,o.getBoolean("key1"));
+ assertEquals("value2",o.getString("key2"));
+ JSONObject app = o.getJSONObject("app1");
+ assertNotNull(app);
+ assertEquals(true, app.getBoolean("enabled"));
+ assertEquals("abcdef", app.getString("name"));
+
+ }
+ @Test
public void testpm15m() {
try {
dbClient.delete(new DeleteQuery(Entity.Historicalperformance15min, null).toSql());
@@ -538,7 +648,7 @@ public class TestMariaDataProvider {
assertEquals(10, data.getData().size());
ReadPmdata15mLtpListOutputBuilder ltpdata = null;
try {
- ltpdata = dbProvider.readPmdata15mLtpList(createInput("node-name","sim12600",1, 20));
+ ltpdata = dbProvider.readPmdata15mLtpList(createInput("node-name", "sim12600", 1, 20));
} catch (IOException e) {
e.printStackTrace();
fail("failed to read pmdata15m ltp list");
@@ -546,7 +656,7 @@ public class TestMariaDataProvider {
assertEquals(3, ltpdata.getData().size());
ReadPmdata15mDeviceListOutputBuilder devicedata = null;
try {
- devicedata = dbProvider.readPmdata15mDeviceList(createInput(1,20));
+ devicedata = dbProvider.readPmdata15mDeviceList(createInput(1, 20));
} catch (IOException e) {
e.printStackTrace();
fail("failed to read pmdata15m devices list");
@@ -554,7 +664,6 @@ public class TestMariaDataProvider {
assertEquals(1, devicedata.getData().size());
}
- @Ignore
@Test
public void testpm24h() {
try {
@@ -573,9 +682,27 @@ public class TestMariaDataProvider {
fail("failed to load pmdata24h");
}
dbProvider.doWritePerformanceData(list);
+ data = dbProvider.readPmdata24hList(createInput(1, 20));
+ assertEquals(1, data.getData().size());
+ ReadPmdata24hLtpListOutputBuilder ltpdata = null;
+ try {
+ ltpdata = dbProvider.readPmdata24hLtpList(createInput("node-name", "test", 1, 20));
+ } catch (IOException e) {
+ e.printStackTrace();
+ fail("failed to read pmdata15m ltp list");
+ }
+ assertEquals(1, ltpdata.getData().size());
+ ReadPmdata24hDeviceListOutputBuilder devicedata = null;
+ try {
+ devicedata = dbProvider.readPmdata24hDeviceList(createInput(1, 20));
+ } catch (IOException e) {
+ e.printStackTrace();
+ fail("failed to read pmdata15m devices list");
+ }
+ assertEquals(1, devicedata.getData().size());
}
- private static EntityInput createInput(int page, int size) {
+ static EntityInput createInput(int page, int size) {
return createInput(null, null, page, size);
}
@@ -597,7 +724,7 @@ public class TestMariaDataProvider {
return String.join("\n", IoUtils.readAllLines(TestMariaDataProvider.class.getResourceAsStream(filename)));
}
- private static EntityInput createInput(String filter, String filterValue, int page, int size) {
+ static EntityInput createInput(String filter, String filterValue, int page, int size) {
ReadFaultcurrentListInputBuilder builder = new ReadFaultcurrentListInputBuilder().setPagination(
new PaginationBuilder().setPage(Uint64.valueOf(page)).setSize(Uint32.valueOf(size)).build());
if (filter != null && filterValue != null) {
diff --git a/sdnr/wt/data-provider/dblib/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/dblib/test/TestQuerySyntax.java b/sdnr/wt/data-provider/dblib/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/dblib/test/TestQuerySyntax.java
index 24347c7db..576a3825c 100644
--- a/sdnr/wt/data-provider/dblib/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/dblib/test/TestQuerySyntax.java
+++ b/sdnr/wt/data-provider/dblib/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/dblib/test/TestQuerySyntax.java
@@ -22,12 +22,16 @@
package org.onap.ccsdk.features.sdnr.wt.dataprovider.dblib.test;
import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.junit.Test;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.query.CountQuery;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.query.SelectQuery;
+import org.onap.ccsdk.features.sdnr.wt.yang.mapper.YangToolsMapperHelper;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.Entity;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.EntityInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadEventlogListInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadGuiCutThroughEntryInputBuilder;
@@ -164,8 +168,8 @@ public class TestQuerySyntax {
@Test
public void testSelectForFilterValues() {
EntityInput input = new ReadGuiCutThroughEntryInputBuilder()
- .setFilter(Arrays.asList(
- new FilterBuilder().setProperty("id").setFiltervalues(Arrays.asList("das", "das2")).build()))
+ .setFilter(YangToolsMapperHelper.toMap(Arrays.asList(
+ new FilterBuilder().setProperty("id").setFiltervalues(Arrays.asList("das", "das2")).build())))
.setPagination(new PaginationBuilder().setSize(Uint32.valueOf(20)).setPage(Uint64.valueOf(1)).build())
.build();
SelectQuery query = new SelectQuery(TABLENAME1, input, CONTROLLERID);
@@ -174,8 +178,8 @@ public class TestQuerySyntax {
@Test
public void testSelectForFilterValues2() {
EntityInput input = new ReadGuiCutThroughEntryInputBuilder()
- .setFilter(Arrays.asList(
- new FilterBuilder().setProperty("id").setFiltervalue("*").build()))
+ .setFilter(YangToolsMapperHelper.toMap(Arrays.asList(
+ new FilterBuilder().setProperty("id").setFiltervalue("*").build())))
.setPagination(new PaginationBuilder().setSize(Uint32.valueOf(20)).setPage(Uint64.valueOf(1)).build())
.build();
SelectQuery query = new SelectQuery(TABLENAME1, input, CONTROLLERID);
@@ -185,12 +189,38 @@ public class TestQuerySyntax {
@Test
public void testSelectForFilterValues3() {
EntityInput input = new ReadGuiCutThroughEntryInputBuilder()
- .setFilter(Arrays.asList(
- new FilterBuilder().setProperty("id").setFiltervalues(Arrays.asList("*","abc")).build()))
+ .setFilter(YangToolsMapperHelper.toMap(Arrays.asList(
+ new FilterBuilder().setProperty("id").setFiltervalues(Arrays.asList("*","abc")).build())))
.setPagination(new PaginationBuilder().setSize(Uint32.valueOf(20)).setPage(Uint64.valueOf(1)).build())
.build();
SelectQuery query = new SelectQuery(TABLENAME1, input, CONTROLLERID);
System.out.println(query.toSql());
assertFalse(query.toSql().contains("RLIKE"));
}
+ @Test
+ public void testSelectForFilterValues4() {
+ EntityInput input = new ReadGuiCutThroughEntryInputBuilder()
+ .setFilter(YangToolsMapperHelper.toMap(Arrays.asList(
+ new FilterBuilder().setProperty("id").setFiltervalues(Arrays.asList("abc")).build(),
+ new FilterBuilder().setProperty("node-id").setFiltervalues(Arrays.asList("*")).build())))
+ .setPagination(new PaginationBuilder().setSize(Uint32.valueOf(20)).setPage(Uint64.valueOf(1)).build())
+ .build();
+ SelectQuery query = new SelectQuery(TABLENAME1, input, CONTROLLERID);
+ System.out.println(query.toSql());
+ assertFalse(query.toSql().contains("RLIKE"));
+ }
+ @Test
+ public void testCount() {
+ CountQuery query = new CountQuery(Entity.Eventlog, TestMariaDataProvider.createInput(1, 20));
+ String sQuery = query.toSql();
+ assertNotNull(sQuery);
+ assertTrue(sQuery.contains("*") && sQuery.contains("COUNT") && sQuery.contains(Entity.Eventlog.getName()));
+
+ query = new CountQuery(Entity.Eventlog, TestMariaDataProvider.createInput("node-id","abc",1, 20));
+ sQuery = query.toSql();
+ assertNotNull(sQuery);
+ assertTrue(sQuery.contains("node-id") && sQuery.contains("COUNT") && sQuery.contains(Entity.Eventlog.getName()));
+
+
+ }
}
diff --git a/sdnr/wt/data-provider/dblib/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/dblib/test/util/MariaDBTestBase.java b/sdnr/wt/data-provider/dblib/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/dblib/test/util/MariaDBTestBase.java
index 3360d3ed8..aebd3328e 100644
--- a/sdnr/wt/data-provider/dblib/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/dblib/test/util/MariaDBTestBase.java
+++ b/sdnr/wt/data-provider/dblib/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/dblib/test/util/MariaDBTestBase.java
@@ -34,6 +34,7 @@ import org.onap.ccsdk.features.sdnr.wt.common.configuration.subtypes.Section.Env
import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.SqlDBClient;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.SqlDBConfig;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.data.SqlDBDataProvider;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.data.Userdata;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.database.SqlDBMapper;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.database.SqlDBMapper.UnableToMapClassException;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.CmlogEntity;
@@ -60,6 +61,7 @@ public class MariaDBTestBase {
private SqlDBConfig config;
private static final Map<String, String> envDefaultValues = initEnvDefaultValues();
private static final String SDNRDBDATABASETEST = "test";
+ public static final String SUFFIX = "";
public MariaDBTestBase() throws ManagedProcessException {
this(new Random().nextInt(1000) + 50000);
@@ -173,6 +175,7 @@ public class MariaDBTestBase {
createTable(dbService, MaintenanceEntity.class, Entity.Maintenancemode, false);
createTable(dbService, MediatorServerEntity.class, Entity.MediatorServer, true);
createTable(dbService, NetworkElementConnectionEntity.class, Entity.NetworkelementConnection, false);
+ createTable(dbService, Userdata.class, Entity.Userdata, false, false);
}
public static boolean createTableOdl(SqlDBClient dbService) {
@@ -181,11 +184,14 @@ public class MariaDBTestBase {
System.out.println(createStatement);
return dbService.createTable(createStatement);
}
-
public static boolean createTable(SqlDBClient dbService, Class<?> cls, Entity entity, boolean autoIndex) {
+ return createTable(dbService, cls, entity, autoIndex, true);
+ }
+ public static boolean createTable(SqlDBClient dbService, Class<?> cls, Entity entity, boolean autoIndex,
+ boolean withControllerId) {
String createStatement = null;
try {
- createStatement = SqlDBMapper.createTable(cls, entity, "", autoIndex);
+ createStatement = SqlDBMapper.createTable(cls, entity, SUFFIX, autoIndex,withControllerId);
} catch (UnableToMapClassException e) {
fail(e.getMessage());
}
diff --git a/sdnr/wt/data-provider/dblib/src/test/resources/pmdata24h.json b/sdnr/wt/data-provider/dblib/src/test/resources/pmdata24h.json
new file mode 100644
index 000000000..6b1f6b543
--- /dev/null
+++ b/sdnr/wt/data-provider/dblib/src/test/resources/pmdata24h.json
@@ -0,0 +1,55 @@
+[
+ {
+ "uuid-interface": "LP-MWPS-TTP-RADIO",
+ "granularity-period": "period-24-hours",
+ "suspect-interval-flag": false,
+ "layer-protocol-name": "MWPS",
+ "performance-data": {
+ "time-period": 86400,
+ "es": 0,
+ "ses": 0,
+ "cses": 0,
+ "unavailability": 0,
+ "tx-level-min": 3,
+ "tx-level-max": 3,
+ "tx-level-avg": 3,
+ "rx-level-min": -44,
+ "rx-level-max": -45,
+ "rx-level-avg": -44,
+ "time2-states": 0,
+ "time4-states-s": 0,
+ "time4-states": 0,
+ "time8-states": -1,
+ "time16-states-s": -1,
+ "time16-states": 0,
+ "time32-states": -1,
+ "time64-states": 86400,
+ "time128-states": -1,
+ "time256-states": -1,
+ "time512-states": -1,
+ "time512-states-l": -1,
+ "time1024-states": -1,
+ "time1024-states-l": -1,
+ "time2048-states": -1,
+ "time2048-states-l": -1,
+ "time4096-states": -1,
+ "time4096-states-l": -1,
+ "time8192-states": -1,
+ "time8192-states-l": -1,
+ "snir-min": -99,
+ "snir-max": -99,
+ "snir-avg": -99,
+ "xpd-min": -99,
+ "xpd-max": -99,
+ "xpd-avg": -99,
+ "rf-temp-min": -99,
+ "rf-temp-max": -99,
+ "rf-temp-avg": -99,
+ "defect-blocks-sum": -1
+ },
+ "radio-signal-id": "Test8",
+ "scanner-id": "PM_RADIO_24H_1",
+ "time-stamp": "2017-03-01T00:00:00.0+00:00",
+ "node-name": "test"
+ }
+] \ No newline at end of file
diff --git a/sdnr/wt/data-provider/feature/pom.xml b/sdnr/wt/data-provider/feature/pom.xml
index d8885ffb5..7e05c15b0 100644
--- a/sdnr/wt/data-provider/feature/pom.xml
+++ b/sdnr/wt/data-provider/feature/pom.xml
@@ -28,7 +28,7 @@
<parent>
<groupId>org.onap.ccsdk.parent</groupId>
<artifactId>single-feature-parent</artifactId>
- <version>2.3.2</version>
+ <version>2.3.3-SNAPSHOT</version>
<relativePath/>
</parent>
diff --git a/sdnr/wt/data-provider/installer/pom.xml b/sdnr/wt/data-provider/installer/pom.xml
index 1d13432a8..b118cbdb1 100755
--- a/sdnr/wt/data-provider/installer/pom.xml
+++ b/sdnr/wt/data-provider/installer/pom.xml
@@ -28,7 +28,7 @@
<parent>
<groupId>org.onap.ccsdk.parent</groupId>
<artifactId>odlparent-lite</artifactId>
- <version>2.3.2</version>
+ <version>2.3.3-SNAPSHOT</version>
<relativePath/>
</parent>
diff --git a/sdnr/wt/data-provider/model/pom.xml b/sdnr/wt/data-provider/model/pom.xml
index 05d98fa2d..0a73be143 100644
--- a/sdnr/wt/data-provider/model/pom.xml
+++ b/sdnr/wt/data-provider/model/pom.xml
@@ -28,7 +28,7 @@
<parent>
<groupId>org.onap.ccsdk.parent</groupId>
<artifactId>binding-parent</artifactId>
- <version>2.3.2</version>
+ <version>2.3.3-SNAPSHOT</version>
<relativePath/>
</parent>
diff --git a/sdnr/wt/data-provider/pom.xml b/sdnr/wt/data-provider/pom.xml
index 70ac5655f..d24fb72c3 100755
--- a/sdnr/wt/data-provider/pom.xml
+++ b/sdnr/wt/data-provider/pom.xml
@@ -28,7 +28,7 @@
<parent>
<groupId>org.onap.ccsdk.parent</groupId>
<artifactId>odlparent-lite</artifactId>
- <version>2.3.2</version>
+ <version>2.3.3-SNAPSHOT</version>
<relativePath/>
</parent>
diff --git a/sdnr/wt/data-provider/provider/pom.xml b/sdnr/wt/data-provider/provider/pom.xml
index 8c546aebd..1d3753b48 100644
--- a/sdnr/wt/data-provider/provider/pom.xml
+++ b/sdnr/wt/data-provider/provider/pom.xml
@@ -28,7 +28,7 @@
<parent>
<groupId>org.onap.ccsdk.parent</groupId>
<artifactId>binding-parent</artifactId>
- <version>2.3.2</version>
+ <version>2.3.3-SNAPSHOT</version>
<relativePath/>
</parent>
@@ -210,18 +210,7 @@
</execution>
</executions>
</plugin>
-<!-- <plugin> -->
-<!-- <groupId>org.apache.felix</groupId> -->
-<!-- <artifactId>maven-bundle-plugin</artifactId> -->
-<!-- <extensions>true</extensions> -->
-<!-- <configuration> -->
-<!-- <instructions> -->
-<!-- <Export-Package>org.onap.ccsdk.features.sdnr.wt.dataprovider.*</Export-Package> -->
-<!-- <Import-Package>*</Import-Package> -->
-<!-- <Embed-Dependency>dblib-provider;scope=provided|;inline=false,utils-provider;scope=provided|;inline=false</Embed-Dependency> -->
-<!-- </instructions> -->
-<!-- </configuration> -->
-<!-- </plugin> -->
+
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/data/entity/HtDatabaseEventsService.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/data/entity/HtDatabaseEventsService.java
index 13438ef15..9cfe4e50d 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/data/entity/HtDatabaseEventsService.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/data/entity/HtDatabaseEventsService.java
@@ -405,8 +405,8 @@ public class HtDatabaseEventsService implements ArchiveCleanProvider, DataProvid
}
NetworkElementConnectionBuilder builder = new NetworkElementConnectionBuilder(base);
if (toJoin != null) {
- if (toJoin.isIsRequired() != null) {
- builder.setIsRequired(toJoin.isIsRequired());
+ if (toJoin.requireIsRequired() != null) {
+ builder.setIsRequired(toJoin.requireIsRequired());
}
if (toJoin.getCoreModelCapability() != null) {
builder.setCoreModelCapability(toJoin.getCoreModelCapability());
@@ -483,7 +483,7 @@ public class HtDatabaseEventsService implements ArchiveCleanProvider, DataProvid
public void removeNetworkConnection(String nodeId) {
Boolean isRequired;
NetworkElementConnectionEntity e = this.networkelementConnectionDB.read(nodeId);
- if (e != null && (isRequired = e.isIsRequired()) != null) {
+ if (e != null && (isRequired = e.requireIsRequired()) != null) {
if (isRequired) {
LOG.debug("updating connection status for {} of required ne to disconnected", nodeId);
this.networkelementConnectionDB.update(new UpdateNetworkElementConnectionInputBuilder()
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/data/entity/HtDatabaseMaintenanceService.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/data/entity/HtDatabaseMaintenanceService.java
index c6161b54c..9f4c0f399 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/data/entity/HtDatabaseMaintenanceService.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/data/entity/HtDatabaseMaintenanceService.java
@@ -166,8 +166,8 @@ public class HtDatabaseMaintenanceService implements HtDatabaseMaintenance {
} else {
LOG.warn("cannot read db. no db reader writer initialized");
}
- if (ne != null && ne.isIsRequired() != null) {
- return ne.isIsRequired();
+ if (ne != null && ne.requireIsRequired() != null) {
+ return ne.requireIsRequired();
} else {
return false;
}
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/about/ODLVersionLUT.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/about/ODLVersionLUT.java
index 5211030eb..29d9ee9db 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/about/ODLVersionLUT.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/about/ODLVersionLUT.java
@@ -66,6 +66,8 @@ public class ODLVersionLUT {
}
if(odlMdsalVersionLUT==null) {
odlMdsalVersionLUT = new HashMap<>();
+ odlMdsalVersionLUT.put("8.0.7","phosphorus-SR1 (0.15.1)");
+ odlMdsalVersionLUT.put("8.0.5","phosphorus-SR0 (0.15.0)");
odlMdsalVersionLUT.put("7.0.9","silicon-SR2 (0.14.2)");
odlMdsalVersionLUT.put("7.0.7","silicon-SR1 (0.14.1)");
odlMdsalVersionLUT.put("7.0.6","silicon-SR0 (0.14.0)");
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
index d59a0784f..00e8075f9 100644
--- 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
@@ -379,7 +379,7 @@ public class TestCRUDforDatabase {
// ==PARTIAL UPDATE============================
System.out.println("Try partial update...");
- assertEquals(false, data.get(0).isIsRequired());
+ assertEquals(false, data.get(0).requireIsRequired());
updateInput = new UpdateNetworkElementConnectionInputBuilder().setId(dbId).setIsRequired(true).build();
try {
updateOutput = dbProvider.updateNetworkElementConnection(updateInput);
@@ -392,7 +392,7 @@ public class TestCRUDforDatabase {
readOperation = dbProvider.readNetworkElementConnectionList(readInput);
data = readOperation.getData();
- assertEquals(true, data.get(0).isIsRequired());
+ assertEquals(true, data.get(0).requireIsRequired());
assertEquals(url2, data.get(0).getHost());
assertEquals(port2, data.get(0).getPort().longValue());
@@ -463,7 +463,7 @@ public class TestCRUDforDatabase {
assertNotEquals(0, data.size());
assertNotNull(data);
assertEquals(nodeId, data.get(0).getNodeId());
- assertEquals(isActive, data.get(0).isActive());
+ assertEquals(isActive, data.get(0).requireActive());
// ==UPDATE============================
@@ -489,7 +489,7 @@ public class TestCRUDforDatabase {
assertNotNull(data);
assertEquals(nodeId2, data.get(0).getNodeId());
- assertEquals(isActive2, data.get(0).isActive());
+ assertEquals(isActive2, data.get(0).getActive());
// ==DELETE================================
System.out.println("Trying to delete...");
diff --git a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestMapper.java b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestMapper.java
new file mode 100644
index 000000000..50c231015
--- /dev/null
+++ b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestMapper.java
@@ -0,0 +1,93 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP : ccsdk features
+ * ================================================================================
+ * Copyright (C) 2020 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.fail;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import org.json.JSONObject;
+import org.junit.Test;
+import org.onap.ccsdk.features.sdnr.wt.yang.mapper.YangToolsMapper;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.NetworkElementConnection;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.NetworkElementConnectionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.NetworkElementDeviceType;
+
+public class TestMapper {
+
+ private static final YangToolsMapper MAPPER = new YangToolsMapper();
+
+ @Test
+ public void testYangGenEnumMapperDeser() {
+ NetworkElementConnection con = null;
+ try {
+ con = MAPPER.readValue("{\"device-type\":\"O-RAN\"}", NetworkElementConnection.class);
+ } catch (JsonProcessingException e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ assertEquals(NetworkElementDeviceType.ORAN, con.getDeviceType());
+ try {
+ con = MAPPER.readValue("{\"device-type\":\"ORAN\"}", NetworkElementConnection.class);
+ } catch (JsonProcessingException e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ assertEquals(NetworkElementDeviceType.ORAN, con.getDeviceType());
+ try {
+ con = MAPPER.readValue("{\"device-type\":\"O-ROADM\"}", NetworkElementConnection.class);
+ } catch (JsonProcessingException e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ assertEquals(NetworkElementDeviceType.OROADM, con.getDeviceType());
+ try {
+ con = MAPPER.readValue("{\"device-type\":\"O-ROADM\"}", NetworkElementConnection.class);
+ } catch (JsonProcessingException e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ assertEquals(NetworkElementDeviceType.OROADM, con.getDeviceType());
+ }
+
+ @Test
+ public void testYangGenEnumMapperSer() {
+ NetworkElementConnection con =
+ new NetworkElementConnectionBuilder().setDeviceType(NetworkElementDeviceType.ORAN).build();
+ String str = null;
+ try {
+ str = MAPPER.writeValueAsString(con);
+ } catch (JsonProcessingException e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ assertEquals("O-RAN", new JSONObject(str).getString("device-type"));
+ con = new NetworkElementConnectionBuilder().setDeviceType(NetworkElementDeviceType.OROADM).build();
+ str = null;
+ try {
+ str = MAPPER.writeValueAsString(con);
+ } catch (JsonProcessingException e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ assertEquals("O-ROADM", new JSONObject(str).getString("device-type"));
+ }
+}
diff --git a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestYangGenSalMappingOpenRoadm.java b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestYangGenSalMappingOpenRoadm.java
index 1345d4edf..35ddaf2f3 100644
--- a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestYangGenSalMappingOpenRoadm.java
+++ b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestYangGenSalMappingOpenRoadm.java
@@ -35,6 +35,7 @@ import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.types.YangHelper2;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.yangtools.DataProviderYangToolsMapper;
import org.onap.ccsdk.features.sdnr.wt.yang.mapper.YangToolsMapper2;
import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.types.rev191129.PmDataType;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.types.rev191129.PmDataTypeBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.openroadm.pm.types.rev200413.BIPErrorCounter;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.openroadm.pm.types.rev200413.OpticalPowerInputOSCMin;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.GranularityPeriodType;
@@ -78,7 +79,7 @@ public class TestYangGenSalMappingOpenRoadm extends Mockito {
String jsonString = mapper2.writeValueAsString(pmDataType);
out("Result json after mapping: " + jsonString);
- PmdataEntity generatepmdNode = mapper2.readValue(jsonString.getBytes(), PmdataEntity.class);
+ PmdataEntity generatepmdNode = mapper2.readValue(jsonString, PmdataEntity.class);
out("Original: " + pmDataType.toString());
out("Mapped : " + generatepmdNode.toString());
assertTrue("Can mapping not working", generatepmdNode.equals(pmDataType));
@@ -104,9 +105,10 @@ public class TestYangGenSalMappingOpenRoadm extends Mockito {
@Test
public void testOpenroadmPMString2() throws IOException, ClassNotFoundException {
out("Test: " + method());
+ PmDataTypeBuilder.getDefaultInstance("11298624220985537708");
String jsonString2 = getFileContent("pmdata2.json");
DataProviderYangToolsMapper mapper2 = new DataProviderYangToolsMapper();
- PmdataEntity generatepmdNode = mapper2.readValue(jsonString2.getBytes(), PmdataEntity.class);
+ PmdataEntity generatepmdNode = mapper2.readValue(jsonString2, PmdataEntity.class);
out(generatepmdNode.toString()); // Print it with specified indentation
}
diff --git a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/util/MariaDBTestBase.java b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/util/MariaDBTestBase.java
index 18efde235..7d71571d4 100644
--- a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/util/MariaDBTestBase.java
+++ b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/util/MariaDBTestBase.java
@@ -154,20 +154,17 @@ public class MariaDBTestBase {
}
public static boolean createTable(SqlDBClient dbService, Class<?> cls, Entity entity, boolean autoIndex) {
+ return createTable(dbService, cls, entity, autoIndex, true);
+ }
+ public static boolean createTable(SqlDBClient dbService, Class<?> cls, Entity entity, boolean autoIndex,
+ boolean withControllerId) {
String createStatement = null;
try {
- createStatement = SqlDBMapper.createTable(cls, entity, "", autoIndex);
+ createStatement = SqlDBMapper.createTable(cls, entity, "", autoIndex,withControllerId);
} catch (UnableToMapClassException e) {
fail(e.getMessage());
}
System.out.println(createStatement);
- try {
- return dbService.write(createStatement);
- } catch (SQLException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
-
- }
- return false;
+ return dbService.createTable(createStatement);
}
}
diff --git a/sdnr/wt/data-provider/setup/pom.xml b/sdnr/wt/data-provider/setup/pom.xml
index 487aacd88..7d7a6ee16 100644
--- a/sdnr/wt/data-provider/setup/pom.xml
+++ b/sdnr/wt/data-provider/setup/pom.xml
@@ -28,7 +28,7 @@
<parent>
<groupId>org.onap.ccsdk.parent</groupId>
<artifactId>binding-parent</artifactId>
- <version>2.3.2</version>
+ <version>2.3.3-SNAPSHOT</version>
<relativePath/>
</parent>
diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/istanbul/IstanbulReleaseInformation.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/istanbul/IstanbulReleaseInformation.java
index 8a0aeb05e..6148e21d5 100644
--- a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/istanbul/IstanbulReleaseInformation.java
+++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/istanbul/IstanbulReleaseInformation.java
@@ -44,95 +44,98 @@ import org.slf4j.LoggerFactory;
public class IstanbulReleaseInformation extends ReleaseInformation {
private final Logger LOG = LoggerFactory.getLogger(IstanbulReleaseInformation.class);
-
+ private static String NORMAL_STRING_MAX_LEN = "1024";
public static final String TIMEZONE_TYPE_FORMAT =
"CHAR(6) DEFAULT NULL CHECK (`%s` regexp '^[+-]\\\\d\\\\d:\\\\d\\\\d$')";
public static final String TABLENAME_CONTROLLER_FORMAT = "controller%s";
public static final String TABLEMAPPING_CONTROLLER =
- "`id` VARCHAR(40) CHARACTER SET utf8 NOT NULL,`desc` VARCHAR(255) CHARACTER SET utf8 ,primary key(id)";
+ "`id` VARCHAR(40) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,`desc` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_bin ,primary key(id)";
private static final String TABLEMAPPING_CONNECTIONLOG_FORMAT = "`id` int(11) NOT NULL AUTO_INCREMENT,\n"
- + "`controller-id` VARCHAR(40) CHARACTER SET utf8 NOT NULL,\n" + "`timestamp` DATETIME(3) ,\n"
- + "`status` VARCHAR(100) CHARACTER SET utf8 ,\n" + "`node-id` VARCHAR(255) CHARACTER SET utf8 ,\n"
+ + "`controller-id` VARCHAR(40) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,\n" + "`timestamp` DATETIME(3) ,\n"
+ + "`status` VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_bin ,\n" + "`node-id` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_bin ,\n"
+ "primary key(id),foreign key(`controller-id`) references `controller%s`(id)";
private static final String TABLEMAPPING_EVENTLOG_FORMAT = "`id` int(11) NOT NULL AUTO_INCREMENT,\n"
- + "`controller-id` VARCHAR(40) CHARACTER SET utf8 NOT NULL,\n"
- + "`source-type` VARCHAR(100) CHARACTER SET utf8 ,\n" + "`object-id` VARCHAR(255) CHARACTER SET utf8 ,\n"
- + "`timestamp` DATETIME(3) ,\n" + "`timestamp-tz` " + String.format(TIMEZONE_TYPE_FORMAT, "timestamp-tz")
- + " ,\n" + "`node-id` VARCHAR(255) CHARACTER SET utf8 ,\n" + "`counter` INTEGER ,\n"
- + "`attribute-name` VARCHAR(255) CHARACTER SET utf8 ,\n" + "`new-value` VARCHAR(255) CHARACTER SET utf8 ,\n"
- + "primary key(id),foreign key(`controller-id`) references `controller%s`(id)";
- private static final String TABLEMAPPING_FAULTCURRENT_FORMAT = "`id` VARCHAR(255) CHARACTER SET utf8 NOT NULL,\n"
- + "`controller-id` VARCHAR(40) CHARACTER SET utf8 NOT NULL,\n"
- + "`object-id` VARCHAR(255) CHARACTER SET utf8 ,\n" + "`timestamp` DATETIME(3) ,\n" + "`timestamp-tz` "
+ + "`controller-id` VARCHAR(40) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,\n"
+ + "`source-type` VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_bin ,\n" + "`object-id` VARCHAR(" + NORMAL_STRING_MAX_LEN
+ + ") CHARACTER SET utf8 COLLATE utf8_bin ,\n" + "`timestamp` DATETIME(3) ,\n" + "`timestamp-tz` "
+ String.format(TIMEZONE_TYPE_FORMAT, "timestamp-tz") + " ,\n"
- + "`node-id` VARCHAR(255) CHARACTER SET utf8 ,\n" + "`counter` INTEGER ,\n"
- + "`severity` VARCHAR(100) CHARACTER SET utf8 ,\n" + "`problem` VARCHAR(255) CHARACTER SET utf8 ,\n"
- + "primary key(id),foreign key(`controller-id`) references `controller%s`(id)";
- private static final String TABLEMAPPING_FAULTLOG_FORMAT = "`id` int(11) NOT NULL AUTO_INCREMENT,\n"
- + "`controller-id` VARCHAR(40) CHARACTER SET utf8 NOT NULL,\n"
- + "`source-type` VARCHAR(100) CHARACTER SET utf8 ,\n" + "`object-id` VARCHAR(255) CHARACTER SET utf8 ,\n"
+ + "`node-id` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_bin ,\n" + "`counter` INTEGER ,\n" + "`attribute-name` VARCHAR("
+ + NORMAL_STRING_MAX_LEN + ") CHARACTER SET utf8 COLLATE utf8_bin ,\n" + "`new-value` VARCHAR(" + NORMAL_STRING_MAX_LEN
+ + ") CHARACTER SET utf8 COLLATE utf8_bin ,\n" + "primary key(id),foreign key(`controller-id`) references `controller%s`(id)";
+ private static final String TABLEMAPPING_FAULTCURRENT_FORMAT = "`id` VARCHAR(" + NORMAL_STRING_MAX_LEN
+ + ") CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,\n" + "`controller-id` VARCHAR(40) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,\n"
+ + "`object-id` VARCHAR(" + NORMAL_STRING_MAX_LEN + ") CHARACTER SET utf8 COLLATE utf8_bin ,\n"
+ "`timestamp` DATETIME(3) ,\n" + "`timestamp-tz` " + String.format(TIMEZONE_TYPE_FORMAT, "timestamp-tz")
- + " ,\n" + "`node-id` VARCHAR(255) CHARACTER SET utf8 ,\n" + "`counter` INTEGER ,\n"
- + "`severity` VARCHAR(100) CHARACTER SET utf8 ,\n" + "`problem` VARCHAR(255) CHARACTER SET utf8 ,\n"
+ + " ,\n" + "`node-id` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_bin ,\n" + "`counter` INTEGER ,\n"
+ + "`severity` VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_bin ,\n" + "`problem` VARCHAR(" + NORMAL_STRING_MAX_LEN
+ + ") CHARACTER SET utf8 COLLATE utf8_bin ,\n" + "primary key(id),foreign key(`controller-id`) references `controller%s`(id)";
+ private static final String TABLEMAPPING_FAULTLOG_FORMAT = "`id` int(11) NOT NULL AUTO_INCREMENT,\n"
+ + "`controller-id` VARCHAR(40) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,\n" + "`source-type` VARCHAR("
+ + NORMAL_STRING_MAX_LEN + ") CHARACTER SET utf8 COLLATE utf8_bin ,\n" + "`object-id` VARCHAR(" + NORMAL_STRING_MAX_LEN
+ + ") CHARACTER SET utf8 COLLATE utf8_bin ,\n" + "`timestamp` DATETIME(3) ,\n" + "`timestamp-tz` "
+ + String.format(TIMEZONE_TYPE_FORMAT, "timestamp-tz") + " ,\n"
+ + "`node-id` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_bin ,\n" + "`counter` INTEGER ,\n"
+ + "`severity` VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_bin ,\n" + "`problem` VARCHAR(" + NORMAL_STRING_MAX_LEN
+ + ") CHARACTER SET utf8 COLLATE utf8_bin ,\n" + "primary key(id),foreign key(`controller-id`) references `controller%s`(id)";
+ private static final String TABLEMAPPING_GUICUTTHROUGH_FORMAT = "`id` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,\n"
+ + "`controller-id` VARCHAR(40) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,\n"
+ + "`name` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_bin ,\n" + "`weburi` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_bin ,\n"
+ "primary key(id),foreign key(`controller-id`) references `controller%s`(id)";
- private static final String TABLEMAPPING_GUICUTTHROUGH_FORMAT = "`id` VARCHAR(255) CHARACTER SET utf8 NOT NULL,\n"
- + "`controller-id` VARCHAR(40) CHARACTER SET utf8 NOT NULL,\n"
- + "`name` VARCHAR(255) CHARACTER SET utf8 ,\n" + "`weburi` VARCHAR(255) CHARACTER SET utf8 ,\n"
+ private static final String TABLEMAPPING_HISTORICALPM15M_FORMAT = "`id` VARCHAR(" + NORMAL_STRING_MAX_LEN
+ + ") CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,\n" + "`controller-id` VARCHAR(40) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,\n"
+ + "`performance-data` JSON ,\n" + "`granularity-period` VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_bin ,\n"
+ + "`time-stamp` DATETIME(3) ,\n" + "`time-stamp-tz` " + String.format(TIMEZONE_TYPE_FORMAT, "time-stamp-tz")
+ + " ,\n" + "`node-name` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_bin ,\n"
+ + "`uuid-interface` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_bin ,\n"
+ + "`layer-protocol-name` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_bin ,\n" + "`radio-signal-id` VARCHAR("
+ + NORMAL_STRING_MAX_LEN + ") CHARACTER SET utf8 COLLATE utf8_bin ,\n" + "`suspect-interval-flag` BOOLEAN ,\n"
+ + "`scanner-id` VARCHAR(" + NORMAL_STRING_MAX_LEN + ") CHARACTER SET utf8 COLLATE utf8_bin ,\n"
+ "primary key(id),foreign key(`controller-id`) references `controller%s`(id)";
- private static final String TABLEMAPPING_HISTORICALPM15M_FORMAT = "`id` VARCHAR(255) CHARACTER SET utf8 NOT NULL,\n"
- + "`controller-id` VARCHAR(40) CHARACTER SET utf8 NOT NULL,\n" + "`performance-data` JSON ,\n"
- + "`granularity-period` VARCHAR(100) CHARACTER SET utf8 ,\n" + "`time-stamp` DATETIME(3) ,\n"
+ private static final String TABLEMAPPING_HISTORICALPM24H_FORMAT = "`id` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,\n"
+ + "`controller-id` VARCHAR(40) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,\n" + "`performance-data` JSON ,\n"
+ + "`granularity-period` VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_bin ,\n" + "`time-stamp` DATETIME(3) ,\n"
+ "`time-stamp-tz` " + String.format(TIMEZONE_TYPE_FORMAT, "time-stamp-tz") + " ,\n"
- + "`node-name` VARCHAR(255) CHARACTER SET utf8 ,\n" + "`uuid-interface` VARCHAR(255) CHARACTER SET utf8 ,\n"
- + "`layer-protocol-name` VARCHAR(255) CHARACTER SET utf8 ,\n"
- + "`radio-signal-id` VARCHAR(255) CHARACTER SET utf8 ,\n" + "`suspect-interval-flag` BOOLEAN ,\n"
- + "`scanner-id` VARCHAR(255) CHARACTER SET utf8 ,\n"
+ + "`node-name` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_bin ,\n" + "`uuid-interface` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_bin ,\n"
+ + "`layer-protocol-name` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_bin ,\n"
+ + "`radio-signal-id` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_bin ,\n" + "`suspect-interval-flag` BOOLEAN ,\n"
+ + "`scanner-id` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_bin ,\n"
+ "primary key(id),foreign key(`controller-id`) references `controller%s`(id)";
- private static final String TABLEMAPPING_HISTORICALPM24H_FORMAT = "`id` VARCHAR(255) CHARACTER SET utf8 NOT NULL,\n"
- + "`controller-id` VARCHAR(40) CHARACTER SET utf8 NOT NULL,\n" + "`performance-data` JSON ,\n"
- + "`granularity-period` VARCHAR(100) CHARACTER SET utf8 ,\n" + "`time-stamp` DATETIME(3) ,\n"
- + "`time-stamp-tz` " + String.format(TIMEZONE_TYPE_FORMAT, "time-stamp-tz") + " ,\n"
- + "`node-name` VARCHAR(255) CHARACTER SET utf8 ,\n" + "`uuid-interface` VARCHAR(255) CHARACTER SET utf8 ,\n"
- + "`layer-protocol-name` VARCHAR(255) CHARACTER SET utf8 ,\n"
- + "`radio-signal-id` VARCHAR(255) CHARACTER SET utf8 ,\n" + "`suspect-interval-flag` BOOLEAN ,\n"
- + "`scanner-id` VARCHAR(255) CHARACTER SET utf8 ,\n"
+ private static final String TABLEMAPPING_INVENTORY_FORMAT = "`id` VARCHAR(" + NORMAL_STRING_MAX_LEN
+ + ") CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,\n" + "`controller-id` VARCHAR(40) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,\n"
+ + "`version` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_bin ,\n" + "`type-name` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_bin ,\n"
+ + "`date` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_bin ,\n" + "`description` VARCHAR(1024) CHARACTER SET utf8 COLLATE utf8_bin ,\n"
+ + "`node-id` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_bin ,\n" + "`uuid` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_bin ,\n"
+ + "`part-type-id` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_bin ,\n"
+ + "`model-identifier` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_bin ,\n"
+ + "`manufacturer-identifier` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_bin ,\n" + "`tree-level` BIGINT ,\n"
+ + "`parent-uuid` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_bin ,\n" + "`contained-holder` JSON ,\n"
+ + "`serial` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_bin ,\n" + "`manufacturer-name` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_bin ,\n"
+ "primary key(id),foreign key(`controller-id`) references `controller%s`(id)";
- private static final String TABLEMAPPING_INVENTORY_FORMAT = "`id` VARCHAR(255) CHARACTER SET utf8 NOT NULL,\n"
- + "`controller-id` VARCHAR(40) CHARACTER SET utf8 NOT NULL,\n"
- + "`version` VARCHAR(255) CHARACTER SET utf8 ,\n" + "`type-name` VARCHAR(255) CHARACTER SET utf8 ,\n"
- + "`date` VARCHAR(255) CHARACTER SET utf8 ,\n" + "`description` VARCHAR(1024) CHARACTER SET utf8 ,\n"
- + "`node-id` VARCHAR(255) CHARACTER SET utf8 ,\n" + "`uuid` VARCHAR(255) CHARACTER SET utf8 ,\n"
- + "`part-type-id` VARCHAR(255) CHARACTER SET utf8 ,\n"
- + "`model-identifier` VARCHAR(255) CHARACTER SET utf8 ,\n"
- + "`manufacturer-identifier` VARCHAR(255) CHARACTER SET utf8 ,\n" + "`tree-level` BIGINT ,\n"
- + "`parent-uuid` VARCHAR(255) CHARACTER SET utf8 ,\n" + "`contained-holder` JSON ,\n"
- + "`serial` VARCHAR(255) CHARACTER SET utf8 ,\n" + "`manufacturer-name` VARCHAR(255) CHARACTER SET utf8 ,\n"
- + "primary key(id),foreign key(`controller-id`) references `controller%s`(id)";
- private static final String TABLEMAPPING_MAINTENANCE_FORMAT = "`id` VARCHAR(255) CHARACTER SET utf8 NOT NULL,\n"
- + "`controller-id` VARCHAR(40) CHARACTER SET utf8 NOT NULL,\n" + "`active` BOOLEAN ,\n"
- + "`node-id` VARCHAR(255) CHARACTER SET utf8 ,\n" + "`description` VARCHAR(1024) CHARACTER SET utf8 ,\n"
- + "`problem` VARCHAR(255) CHARACTER SET utf8 ,\n" + "`start` DATETIME(3) ,\n" + "`start-tz` "
+ private static final String TABLEMAPPING_MAINTENANCE_FORMAT = "`id` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,\n"
+ + "`controller-id` VARCHAR(40) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,\n" + "`active` BOOLEAN ,\n"
+ + "`node-id` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_bin ,\n" + "`description` VARCHAR(1024) CHARACTER SET utf8 COLLATE utf8_bin ,\n"
+ + "`problem` VARCHAR("+NORMAL_STRING_MAX_LEN+") CHARACTER SET utf8 COLLATE utf8_bin ,\n" + "`start` DATETIME(3) ,\n" + "`start-tz` "
+ String.format(TIMEZONE_TYPE_FORMAT, "start-tz") + " ,\n" + "`end` DATETIME(3) ,\n" + "`end-tz` "
+ String.format(TIMEZONE_TYPE_FORMAT, "end-tz") + " ,\n"
- + "`object-id-ref` VARCHAR(255) CHARACTER SET utf8 ,\n"
+ + "`object-id-ref` VARCHAR("+NORMAL_STRING_MAX_LEN+") CHARACTER SET utf8 COLLATE utf8_bin ,\n"
+ "primary key(id),foreign key(`controller-id`) references `controller%s`(id)";
private static final String TABLEMAPPING_MEDIATORSERVER_FORMAT =
- "`id` int(11) NOT NULL AUTO_INCREMENT,\n" + "`controller-id` VARCHAR(40) CHARACTER SET utf8 NOT NULL,\n"
- + "`name` VARCHAR(255) CHARACTER SET utf8 ,\n" + "`url` VARCHAR(255) CHARACTER SET utf8 ,\n"
+ "`id` int(11) NOT NULL AUTO_INCREMENT,\n" + "`controller-id` VARCHAR(40) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,\n"
+ + "`name` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_bin ,\n" + "`url` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_bin ,\n"
+ "primary key(id),foreign key(`controller-id`) references `controller%s`(id)";
- private static final String TABLEMAPPING_NETWORKELEMENT_FORMAT = "`id` VARCHAR(255) CHARACTER SET utf8 NOT NULL,\n"
- + "`controller-id` VARCHAR(40) CHARACTER SET utf8 NOT NULL,\n"
- + "`password` VARCHAR(255) CHARACTER SET utf8 ,\n" + "`host` VARCHAR(255) CHARACTER SET utf8 ,\n"
- + "`port` BIGINT ,\n" + "`status` VARCHAR(100) CHARACTER SET utf8 ,\n"
- + "`node-id` VARCHAR(255) CHARACTER SET utf8 ,\n" + "`username` VARCHAR(255) CHARACTER SET utf8 ,\n"
- + "`is-required` BOOLEAN ,\n" + "`core-model-capability` VARCHAR(255) CHARACTER SET utf8 ,\n"
- + "`device-type` VARCHAR(100) CHARACTER SET utf8 ,\n"
- + "`device-function` VARCHAR(512) CHARACTER SET utf8 ,\n" + "`node-details` JSON ,\n"
- + "`tls-key` VARCHAR(255) CHARACTER SET utf8 ,\n" + "`mount-method` VARCHAR(255) CHARACTER SET utf8 ,\n"
- + "primary key(id),foreign key(`controller-id`) references `controller%s`(id)";
- private static final String TABLEMAPPING_USERDATA_FORMAT = "`id` VARCHAR(255) CHARACTER SET utf8 NOT NULL,\n"
- + "`controller-id` VARCHAR(40) CHARACTER SET utf8 NOT NULL,\n" + "`value` JSON ,\n"
+ private static final String TABLEMAPPING_NETWORKELEMENT_FORMAT = "`id` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,\n"
+ + "`controller-id` VARCHAR(40) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,\n"
+ + "`password` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_bin ,\n" + "`host` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_bin ,\n"
+ + "`port` BIGINT ,\n" + "`status` VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_bin ,\n"
+ + "`node-id` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_bin ,\n" + "`username` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_bin ,\n"
+ + "`is-required` BOOLEAN ,\n" + "`core-model-capability` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_bin ,\n"
+ + "`device-type` VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_bin ,\n"
+ + "`device-function` VARCHAR(512) CHARACTER SET utf8 COLLATE utf8_bin ,\n" + "`node-details` JSON ,\n"
+ + "`tls-key` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_bin ,\n" + "`mount-method` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_bin ,\n"
+ "primary key(id),foreign key(`controller-id`) references `controller%s`(id)";
+ private static final String TABLEMAPPING_USERDATA_FORMAT = "`id` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,\n"
+ + "`value` JSON ,\n"
+ + "primary key(id)";
public IstanbulReleaseInformation() {
@@ -176,9 +179,8 @@ public class IstanbulReleaseInformation extends ReleaseInformation {
+ "\"device-function\": {\"type\": \"keyword\"},\"is-required\": {\"type\": \"boolean\"},"
+ "\"status\": {\"type\": \"keyword\"},\"tls-key\": {\"type\": \"keyword\"},"
+ "\"mount-method\": {\"type\":\"keyword\"}}",
- "{\"index\":{\"max_result_window\": 20000,\"number_of_shards\":%d,\"number_of_replicas\":%d},"
- +"\"analysis\":{\"analyzer\":{\"content\":{\"type\":\"custom\",\"tokenizer\":\"whitespace\"}}}}"
- ));
+ "{\"index\":{\"max_result_window\": 20000,\"number_of_shards\":%d,\"number_of_replicas\":%d},"
+ + "\"analysis\":{\"analyzer\":{\"content\":{\"type\":\"custom\",\"tokenizer\":\"whitespace\"}}}}"));
return map;
}
diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/jakarta/JakartaReleaseInformation.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/jakarta/JakartaReleaseInformation.java
index 03033edad..cf369925c 100644
--- a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/jakarta/JakartaReleaseInformation.java
+++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/jakarta/JakartaReleaseInformation.java
@@ -49,17 +49,18 @@ public class JakartaReleaseInformation extends ReleaseInformation {
private static final String TIMEZONE_TYPE_FORMAT = IstanbulReleaseInformation.TIMEZONE_TYPE_FORMAT;
private final Logger LOG = LoggerFactory.getLogger(JakartaReleaseInformation.class);
- private static final String TABLEMAPPING_CMLOG_FORMAT =
- "`id` int(11) NOT NULL AUTO_INCREMENT,\n" + "`controller-id` VARCHAR(40) CHARACTER SET utf8 NOT NULL,\n"
- + "`source-type` VARCHAR(100) CHARACTER SET utf8 ,\n"
- + "`object-id` VARCHAR(255) CHARACTER SET utf8 ,\n" + "`timestamp` DATETIME(3) ,\n"
- + "`timestamp-tz` " + String.format(TIMEZONE_TYPE_FORMAT, "timestamp-tz")
- + " ,\n" + "`node-id` VARCHAR(255) CHARACTER SET utf8 ,\n" + "`counter` INTEGER ,\n"
- + "`notification-type` VARCHAR(100) CHARACTER SET utf8 ,\n"
- + "`notification-id` VARCHAR(40) CHARACTER SET utf8 ,\n"
- + "`source-indicator` VARCHAR(100) CHARACTER SET utf8 ,\n"
- + "`path` VARCHAR(255) CHARACTER SET utf8 ,\n" + "`operation` VARCHAR(100) CHARACTER SET utf8 ,\n"
- + "`value` VARCHAR(255) CHARACTER SET utf8 ,\n" + "primary key(id)";
+ private static final String TABLEMAPPING_CMLOG_FORMAT = "`id` int(11) NOT NULL AUTO_INCREMENT,\n"
+ + "`controller-id` VARCHAR(40) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,\n"
+ + "`source-type` VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_bin ,\n"
+ + "`object-id` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_bin ,\n" + "`timestamp` DATETIME(3) ,\n" + "`timestamp-tz` "
+ + String.format(TIMEZONE_TYPE_FORMAT, "timestamp-tz") + " ,\n"
+ + "`node-id` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_bin ,\n" + "`counter` INTEGER ,\n"
+ + "`notification-type` VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_bin ,\n"
+ + "`notification-id` VARCHAR(40) CHARACTER SET utf8 COLLATE utf8_bin ,\n"
+ + "`source-indicator` VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_bin ,\n"
+ + "`path` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_bin ,\n" + "`operation` VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_bin ,\n"
+ + "`value` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_bin ,\n" + "primary key(id),foreign key(`controller-id`) "
+ + "references `controller%s`(id) ";
public JakartaReleaseInformation() {
super(Release.JAKARTA_R1, createDBMap(), createMariaDBMap());
diff --git a/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/MariaDBTestBase.java b/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/MariaDBTestBase.java
index 6fd4a40a4..a2a1fcdec 100644
--- a/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/MariaDBTestBase.java
+++ b/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/MariaDBTestBase.java
@@ -163,21 +163,18 @@ public class MariaDBTestBase {
}
public static boolean createTable(SqlDBClient dbService, Class<?> cls, Entity entity, boolean autoIndex) {
+ return createTable(dbService, cls, entity, autoIndex, true);
+ }
+ public static boolean createTable(SqlDBClient dbService, Class<?> cls, Entity entity, boolean autoIndex,
+ boolean withControllerId) {
String createStatement = null;
try {
- createStatement = SqlDBMapper.createTable(cls, entity, "", autoIndex);
+ createStatement = SqlDBMapper.createTable(cls, entity, "", autoIndex,withControllerId);
} catch (UnableToMapClassException e) {
fail(e.getMessage());
}
System.out.println(createStatement);
- try {
- return dbService.write(createStatement);
- } catch (SQLException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
-
- }
- return false;
+ return dbService.createTable(createStatement);
}
public String getDBUrl() {
return envDefaultValues.get("SDNRDBURL");
diff --git a/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestMariaDBMapper.java b/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestMariaDBMapper.java
index f39f9b088..ef8998875 100644
--- a/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestMariaDBMapper.java
+++ b/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestMariaDBMapper.java
@@ -24,10 +24,10 @@ package org.onap.ccsdk.features.sdnr.wt.dataprovider.setup;
import static org.junit.Assert.fail;
import com.fasterxml.jackson.core.JsonProcessingException;
import java.lang.reflect.InvocationTargetException;
+import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Arrays;
import java.util.List;
-import java.util.Properties;
import java.util.concurrent.TimeUnit;
import org.junit.AfterClass;
import org.junit.BeforeClass;
@@ -63,12 +63,12 @@ import ch.vorburger.exec.ManagedProcessException;
public class TestMariaDBMapper {
- private static final String MARIADB_USERNAME = "sdnrdb";
- private static final String MARIADB_PASSWORD = "sdnrdb";
- // private static final String MARIADB_HOST = "10.20.11.159";
- private static final String MARIADB_HOST = "sdnrdb";
- private static final int MARIADB_PORT = 3306;
- private static final String MARIADB_DATABASENAME = "sdnrdb";
+// private static final String MARIADB_USERNAME = "sdnrdb";
+// private static final String MARIADB_PASSWORD = "sdnrdb";
+// private static final String MARIADB_HOST = "10.20.11.159";
+// private static final String MARIADB_HOST = "sdnrdb";
+// private static final int MARIADB_PORT = 3306;
+// private static final String MARIADB_DATABASENAME = "sdnrdb";
// private static DbLibService dbService;
@@ -137,7 +137,6 @@ public class TestMariaDBMapper {
writeEntry(builder.build(), Entity.NetworkelementConnection);
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException
| JsonProcessingException e) {
- // TODO Auto-generated catch block
e.printStackTrace();
}
}
@@ -152,16 +151,19 @@ public class TestMariaDBMapper {
private <T extends DataObject> List<T> readEntry(Entity entity, Class<T> clazz, String id) {
final SelectQuery selectStatement = new SelectQuery(entity.getName());
System.out.println(selectStatement);
+ List<T> list = null;
try {
- return SqlDBMapper.read(dbProvider.getDBService().read(selectStatement.toSql()), clazz);
+ ResultSet data = dbProvider.getDBService().read(selectStatement.toSql());
+ list = SqlDBMapper.read(data, clazz);
+ try { data.close(); } catch (SQLException ignore) { }
+
} catch (SQLException | IllegalAccessException | IllegalArgumentException | InvocationTargetException
| InstantiationException | SecurityException | NoSuchMethodException | JsonProcessingException e) {
- // TODO Auto-generated catch block
e.printStackTrace();
}
- return null;
+ return list;
}
private <T extends DataObject> boolean writeEntry(T data, Entity entity) throws IllegalAccessException,
@@ -173,7 +175,6 @@ public class TestMariaDBMapper {
return dbProvider.getDBService().write(insertStatement.toSql());
} catch (SQLException e) {
- // TODO Auto-generated catch block
e.printStackTrace();
}
@@ -188,41 +189,24 @@ public class TestMariaDBMapper {
try {
return dbService.write(createStatement);
} catch (SQLException e) {
- // TODO Auto-generated catch block
e.printStackTrace();
}
return false;
}
- private static boolean createTable(SqlDBClient dbService, Class<?> cls, Entity entity, boolean autoIndex) {
+ public static boolean createTable(SqlDBClient dbService, Class<?> cls, Entity entity, boolean autoIndex) {
+ return createTable(dbService, cls, entity, autoIndex, true);
+ }
+ public static boolean createTable(SqlDBClient dbService, Class<?> cls, Entity entity, boolean autoIndex,
+ boolean withControllerId) {
String createStatement = null;
try {
- createStatement = SqlDBMapper.createTable(cls, entity, "", autoIndex);
+ createStatement = SqlDBMapper.createTable(cls, entity, "", autoIndex,withControllerId);
} catch (UnableToMapClassException e) {
fail(e.getMessage());
}
System.out.println(createStatement);
- try {
- return dbService.write(createStatement);
- } catch (SQLException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
-
- }
- return false;
- }
-
- private static Properties getConfig() {
- Properties config = new Properties();
- config.setProperty("org.onap.ccsdk.sli.dbtype", "jdbc");
- config.setProperty("org.onap.ccsdk.sli.jdbc.hosts", MARIADB_HOST);
- config.setProperty("org.onap.ccsdk.sli.jdbc.url",
- String.format("jdbc:mysql://dbhost:%d/%s", MARIADB_PORT, MARIADB_DATABASENAME));
- config.setProperty("org.onap.ccsdk.sli.jdbc.driver", "org.mariadb.jdbc.Driver");
- config.setProperty("org.onap.ccsdk.sli.jdbc.database", MARIADB_DATABASENAME);
- config.setProperty("org.onap.ccsdk.sli.jdbc.user", MARIADB_USERNAME);
- config.setProperty("org.onap.ccsdk.sli.jdbc.password", MARIADB_PASSWORD);
- return config;
+ return dbService.createTable(createStatement);
}
}