aboutsummaryrefslogtreecommitdiffstats
path: root/sdnr/wt/data-provider/dblib
diff options
context:
space:
mode:
authorDan Timoney <dtimoney@att.com>2023-08-10 20:46:56 +0000
committerGerrit Code Review <gerrit@onap.org>2023-08-10 20:46:56 +0000
commit8f708e94e2798d42f1b107828c910304bc5cac6b (patch)
treeb82972b8fe8087a0c5e6c6c0b91c84d46e108ed4 /sdnr/wt/data-provider/dblib
parentfad3167f42d585e3144547db4c6dd7d00ea7b18a (diff)
parentc35ad79f3939eebf531f477d62755221789bca12 (diff)
Merge "Update features for Argon release"
Diffstat (limited to 'sdnr/wt/data-provider/dblib')
-rw-r--r--sdnr/wt/data-provider/dblib/pom.xml17
-rw-r--r--sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/data/SqlDBDataProvider.java62
-rw-r--r--sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/database/SqlDBMapper.java6
-rw-r--r--sdnr/wt/data-provider/dblib/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/dblib/test/util/MariaDBTestBase.java8
-rw-r--r--sdnr/wt/data-provider/dblib/test2.properties7
5 files changed, 72 insertions, 28 deletions
diff --git a/sdnr/wt/data-provider/dblib/pom.xml b/sdnr/wt/data-provider/dblib/pom.xml
index 2897e4ede..39b878bd9 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.5.4</version>
+ <version>2.6.0</version>
<relativePath/>
</parent>
@@ -123,4 +123,19 @@
<!-- MariaDB end -->
</dependencies>
+ <!-- Tests require MariaDB4j , which does not currently support ARM64 -->
+ <profiles>
+ <profile>
+ <id>disable-test-on-ARM64</id>
+ <activation>
+ <os>
+ <arch>aarch64</arch>
+ </os>
+ </activation>
+ <properties>
+ <skipTests>true</skipTests>
+ </properties>
+ </profile>
+ </profiles>
+
</project>
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 d00941d86..e04e109cd 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
@@ -26,6 +26,7 @@ package org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.data;
import java.io.IOException;
import java.sql.ResultSet;
import java.sql.SQLException;
+import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.SqlDBClient;
@@ -56,6 +57,8 @@ 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.DeleteNetworkElementConnectionOutputBuilder;
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.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.MaintenanceEntity;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.MediatorServerEntity;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.NetworkElementConnectionEntity;
@@ -88,7 +91,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.pro
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
public class SqlDBDataProvider extends HtDatabaseEventsService implements DatabaseDataProvider {
private static final Logger LOG = LoggerFactory.getLogger(SqlDBDataProvider.class);
@@ -104,7 +106,7 @@ public class SqlDBDataProvider extends HtDatabaseEventsService implements Databa
private final SqlDBStatusReader readStatus;
private final HtUserdataManager usermanager;
private final InventoryTreeProvider inventoryTreeProvider;
-
+ private final String guicutthroughOverride;
public SqlDBReaderWriter<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.maintenance.list.output.Data> getMaintenanceReaderWriter() {
return this.maintenanceRW;
@@ -114,12 +116,13 @@ public class SqlDBDataProvider extends HtDatabaseEventsService implements Databa
return this.mediatorserverRW;
}
- public SqlDBDataProvider(SqlDBConfig config) {
- this(config, true);
+ public SqlDBDataProvider(SqlDBConfig config, String guicutthroughOverride) {
+ this(config, true, guicutthroughOverride);
}
- public SqlDBDataProvider(SqlDBConfig config, boolean initControllerId) {
+ public SqlDBDataProvider(SqlDBConfig config, boolean initControllerId, String guicutthroughOverride) {
super(config);
+ this.guicutthroughOverride = guicutthroughOverride;
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,
@@ -139,8 +142,8 @@ 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.usermanager = new HtUserdataManagerImpl(
+ new SqlDBReaderWriterUserdata(this.dbClient, Entity.Userdata, config.getDbSuffix()));
if (initControllerId) {
try {
this.setControllerId();
@@ -150,7 +153,6 @@ public class SqlDBDataProvider extends HtDatabaseEventsService implements Databa
}
this.inventoryTreeProvider = new SqlDbInventoryTreeProvider(this.dbClient, this.getControllerId());
-
}
/*-------------------------
@@ -186,13 +188,12 @@ public class SqlDBDataProvider extends HtDatabaseEventsService implements Databa
@Override
public ReadCmlogListOutputBuilder readCMLogList(EntityInput input) {
ReadCmlogListOutputBuilder outputBuilder = new ReadCmlogListOutputBuilder();
- QueryResult<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.cmlog.list.output.Data>
- result =
- this.eventRWCMLog.getData(input);
+ QueryResult<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.cmlog.list.output.Data> result =
+ this.eventRWCMLog.getData(input);
outputBuilder.setData(result.getResult());
outputBuilder.setPagination(
- new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.cmlog.list.output.PaginationBuilder(
- result.getPagination()).build());
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.cmlog.list.output.PaginationBuilder(
+ result.getPagination()).build());
return outputBuilder;
}
@@ -475,15 +476,33 @@ public class SqlDBDataProvider extends HtDatabaseEventsService implements Databa
ReadGuiCutThroughEntryOutputBuilder outputBuilder = new ReadGuiCutThroughEntryOutputBuilder();
QueryResult<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.gui.cut.through.entry.output.Data> result =
this.guicutthroughRW.getData(input);
- outputBuilder.setData(result.getResult());
+
+ if (!guicutthroughOverride.isEmpty()) {
+ List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.gui.cut.through.entry.output.Data> gcData =
+ result.getResult();
+ List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.gui.cut.through.entry.output.Data> updatedGcData =
+ new ArrayList<>();
+ for (int i = 0; i < gcData.size(); i++) {
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.gui.cut.through.entry.output.Data gcDataItem =
+ gcData.get(i);
+ Guicutthrough gcItem =
+ new GuicutthroughBuilder().setId(gcDataItem.getId()).setName(gcDataItem.getName())
+ .setWeburi(guicutthroughOverride + "/" + gcDataItem.getId()).build();
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.gui.cut.through.entry.output.DataBuilder gcDataBuilder =
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.gui.cut.through.entry.output.DataBuilder(
+ gcItem);
+ updatedGcData.add(gcDataBuilder.build());
+ }
+ outputBuilder.setData(updatedGcData);
+ } else {
+ outputBuilder.setData(result.getResult());
+ }
outputBuilder.setPagination(
new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.gui.cut.through.entry.output.PaginationBuilder()
.build());
return outputBuilder;
}
-
-
@Override
public boolean waitForYellowDatabaseStatus(long timeout, TimeUnit unit) {
return true;
@@ -519,8 +538,7 @@ public class SqlDBDataProvider extends HtDatabaseEventsService implements Databa
return true;
}
LOG.info("set controllerId {}", this.controllerId);
- String query =
- String.format("SELECT * FROM `%s` WHERE `id`='%s'", this.controllerTableName, this.controllerId);
+ String query = String.format("SELECT * FROM `%s` WHERE `id`='%s'", this.controllerTableName, this.controllerId);
LOG.trace(query);
ResultSet data = this.dbClient.read(query);
@@ -528,7 +546,12 @@ 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 { if(data!=null){data.close();} } catch (SQLException ignore) { }
+ try {
+ if (data != null) {
+ data.close();
+ }
+ } catch (SQLException ignore) {
+ }
return this.dbClient.write(query);
} else {
this.controllerId = data.getString(0);
@@ -555,5 +578,4 @@ public class SqlDBDataProvider extends HtDatabaseEventsService implements Databa
return this.inventoryTreeProvider;
}
-
}
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 8167c7bbf..5755023e1 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
@@ -44,7 +44,7 @@ import org.onap.ccsdk.features.sdnr.wt.yang.mapper.mapperextensions.YangToolsDes
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.Entity;
import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.Enumeration;
+import org.opendaylight.yangtools.yang.binding.EnumTypeObject;
import org.opendaylight.yangtools.yang.common.Uint16;
import org.opendaylight.yangtools.yang.common.Uint32;
import org.opendaylight.yangtools.yang.common.Uint64;
@@ -233,7 +233,7 @@ public class SqlDBMapper {
|| implementsInterface(valueType, Map.class) || implementsInterface(valueType, Set.class)) {
return "JSON";
}
- if (implementsInterface(valueType, Enumeration.class)) {
+ if (implementsInterface(valueType, EnumTypeObject.class)) {
return ENUM_DBTYPE;
}
throw new UnableToMapClassException("no mapping for " + valueType.getName() + " found");
@@ -360,7 +360,7 @@ public class SqlDBMapper {
}
private static boolean isYangEnum(Class<?> valueType) {
- return YangToolsMapperHelper.implementsInterface(valueType, Enumeration.class);
+ return YangToolsMapperHelper.implementsInterface(valueType, EnumTypeObject.class);
}
public static <T extends DataObject> List<T> read(ResultSet data, Class<T> clazz)
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 3123d25a6..1da6e6a86 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
@@ -96,12 +96,12 @@ public class MariaDBTestBase {
this.config.setDbSuffix("");
this.config.setControllerId("test123");
this.db = null;
- this.dbProvider = new SqlDBDataProvider(config, false);
+ this.dbProvider = new SqlDBDataProvider(config, false, "");
SqlDBConfig config2 = new SqlDBConfig(new ConfigurationFileRepresentation("test2.properties"));
config2.setDbSuffix("");
config2.setControllerId(null);
- this.dbProviderOverall = new SqlDBDataProvider(config2, false);
+ this.dbProviderOverall = new SqlDBDataProvider(config2, false, "");
}
public MariaDBTestBase(int port) throws ManagedProcessException {
@@ -116,11 +116,11 @@ public class MariaDBTestBase {
//start db server
this.db = startDatabase(port);
//create db with name sdnrdb
- this.dbProvider = new SqlDBDataProvider(config, false);
+ this.dbProvider = new SqlDBDataProvider(config, false, "");
SqlDBConfig config2 = new SqlDBConfig(new ConfigurationFileRepresentation("test2.properties"));
config2.setDbSuffix("");
config2.setControllerId(null);
- this.dbProviderOverall = new SqlDBDataProvider(config2, false);
+ this.dbProviderOverall = new SqlDBDataProvider(config2, false, "");
}
public void close() throws ManagedProcessException {
diff --git a/sdnr/wt/data-provider/dblib/test2.properties b/sdnr/wt/data-provider/dblib/test2.properties
new file mode 100644
index 000000000..e3485ea95
--- /dev/null
+++ b/sdnr/wt/data-provider/dblib/test2.properties
@@ -0,0 +1,7 @@
+[mariadb]
+url=${SDNRDBURL}
+username=${SDNRDBUSERNAME}
+password=${SDNRDBPASSWORD}
+controllerId=null
+suffix=
+