aboutsummaryrefslogtreecommitdiffstats
path: root/sdnr/wt/data-provider/dblib/src/main/java
diff options
context:
space:
mode:
authorMichael Dürre <michael.duerre@highstreet-technologies.com>2022-07-20 09:32:50 +0200
committerMichael Dürre <michael.duerre@highstreet-technologies.com>2022-07-21 12:38:52 +0200
commit25423c50e504676f15c7a57c03aad40bfc35c7e6 (patch)
tree811649e2ec44e0332e601c6563e00e914d355b9a /sdnr/wt/data-provider/dblib/src/main/java
parentcea47224b7b6afdd7b3d3ead8d08baf46eadc575 (diff)
migrate sdnr features to sulfur
fix sdnr code for sulfur Issue-ID: CCSDK-3692 Signed-off-by: Michael Dürre <michael.duerre@highstreet-technologies.com> Change-Id: I0a62ade424bb978222e7ce6450215fb327f957b7 Signed-off-by: Michael Dürre <michael.duerre@highstreet-technologies.com>
Diffstat (limited to 'sdnr/wt/data-provider/dblib/src/main/java')
-rw-r--r--sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/DatabaseDataProvider.java3
-rw-r--r--sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/data/SqlDBDataProvider.java14
-rw-r--r--sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/data/rpctypehelper/QueryResult.java8
-rw-r--r--sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/database/SqlDBMapper.java23
-rw-r--r--sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/database/SqlDBStatusReader.java16
-rw-r--r--sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/query/SelectQuery.java5
-rw-r--r--sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/query/SqlQuery.java31
-rw-r--r--sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/query/filters/RegexSqlDBFilter.java9
8 files changed, 74 insertions, 35 deletions
diff --git a/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/DatabaseDataProvider.java b/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/DatabaseDataProvider.java
index 20b86e661..fbd105aa1 100644
--- a/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/DatabaseDataProvider.java
+++ b/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/DatabaseDataProvider.java
@@ -48,6 +48,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.ReadEventlogListOutputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadFaultcurrentListOutputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadFaultlogListOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadGuiCutThroughEntryOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadGuiCutThroughEntryOutputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadInventoryListOutputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadMaintenanceListOutputBuilder;
@@ -102,7 +103,7 @@ public interface DatabaseDataProvider {
ReadPmdata24hDeviceListOutputBuilder readPmdata24hDeviceList(EntityInput input) throws IOException;
- ReadStatusOutputBuilder readStatus() throws IOException;
+ ReadStatusOutputBuilder readStatus(EntityInput input) throws IOException;
boolean waitForYellowDatabaseStatus(long timeout, TimeUnit unit);
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 1bb30dc69..cabe6bed0 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
@@ -297,7 +297,7 @@ public class SqlDBDataProvider extends HtDatabaseEventsService implements Databa
outputBuilder.setPagination(
new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.pmdata._15m.ltp.list.output.PaginationBuilder(
result.getPagination()).build());
- outputBuilder.setData(result.getResult());
+ outputBuilder.setData(result.getResultSet());
return outputBuilder;
}
@@ -308,7 +308,7 @@ public class SqlDBDataProvider extends HtDatabaseEventsService implements Databa
outputBuilder.setPagination(
new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.pmdata._15m.device.list.output.PaginationBuilder(
result.getPagination()).build());
- outputBuilder.setData(result.getResult());
+ outputBuilder.setData(result.getResultSet());
return outputBuilder;
}
@@ -322,7 +322,7 @@ public class SqlDBDataProvider extends HtDatabaseEventsService implements Databa
outputBuilder.setPagination(
new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.pmdata._24h.ltp.list.output.PaginationBuilder(
result.getPagination()).build());
- outputBuilder.setData(result.getResult());
+ outputBuilder.setData(result.getResultSet());
return outputBuilder;
}
@@ -335,14 +335,14 @@ public class SqlDBDataProvider extends HtDatabaseEventsService implements Databa
outputBuilder.setPagination(
new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.pmdata._24h.device.list.output.PaginationBuilder(
result.getPagination()).build());
- outputBuilder.setData(result.getResult());
+ outputBuilder.setData(result.getResultSet());
return outputBuilder;
}
@Override
- public ReadStatusOutputBuilder readStatus() throws IOException {
+ public ReadStatusOutputBuilder readStatus(EntityInput input) throws IOException {
QueryResult<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.status.output.Data> result =
- readStatus.getDataStatus();
+ readStatus.getDataStatus(input);
ReadStatusOutputBuilder outputBuilder = new ReadStatusOutputBuilder();
outputBuilder.setData(result.getResult());
@@ -352,7 +352,7 @@ public class SqlDBDataProvider extends HtDatabaseEventsService implements Databa
@Override
public CreateNetworkElementConnectionOutputBuilder createNetworkElementConnection(
NetworkElementConnectionEntity input) throws IOException {
- String id = this.networkelementConnectionRW.write(input, input.getNodeId());
+ String id = this.networkelementConnectionRW.updateOrInsert(input, input.getNodeId());
if (id == null) {
throw new IOException(EXCEPTION_UNABLE_TO_WRITE_IN_DATABASE);
}
diff --git a/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/data/rpctypehelper/QueryResult.java b/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/data/rpctypehelper/QueryResult.java
index c81725073..db4e980af 100644
--- a/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/data/rpctypehelper/QueryResult.java
+++ b/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/data/rpctypehelper/QueryResult.java
@@ -22,7 +22,10 @@
package org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.data.rpctypehelper;
import java.util.ArrayList;
+import java.util.HashSet;
import java.util.List;
+import java.util.Set;
+
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.PaginationOutputG;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.connectionlog.list.output.PaginationBuilder;
import org.opendaylight.yangtools.yang.common.Uint32;
@@ -43,8 +46,11 @@ public class QueryResult<T> {
pagination = x.build();
}
+ public Set<T> getResultSet() {
+ return new HashSet<>(this.result);
+ }
public List<T> getResult() {
- return result;
+ return this.result;
}
public PaginationOutputG getPagination() {
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 19323b9f7..1c24636db 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
@@ -33,6 +33,8 @@ import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Set;
+
import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.query.filters.DBKeyValuePair;
import org.onap.ccsdk.features.sdnr.wt.yang.mapper.YangToolsMapper;
import org.onap.ccsdk.features.sdnr.wt.yang.mapper.YangToolsMapperHelper;
@@ -40,7 +42,6 @@ import org.onap.ccsdk.features.sdnr.wt.yang.mapper.mapperextensions.YangToolsBui
import org.onap.ccsdk.features.sdnr.wt.yang.mapper.mapperextensions.YangToolsDeserializerModifier;
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.concepts.Builder;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.Enumeration;
import org.opendaylight.yangtools.yang.common.Uint16;
@@ -223,7 +224,7 @@ public class SqlDBMapper {
String type = mariaDBTypeMap.getOrDefault(valueType, null);
if (type == null) {
if (implementsInterface(valueType, DataObject.class) || implementsInterface(valueType, List.class)
- || implementsInterface(valueType, Map.class)) {
+ || implementsInterface(valueType, Map.class) || implementsInterface(valueType, Set.class)) {
return "JSON";
}
if (implementsInterface(valueType, Enumeration.class)) {
@@ -352,13 +353,13 @@ public class SqlDBMapper {
}
@SuppressWarnings("unchecked")
- public static <T> List<T> read(ResultSet data, Class<T> clazz, String column)
+ public static <S,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);
+ S builder = findPOJOBuilder(clazz);
if(builder==null && column==null) {
throw new InstantiationException("unable to find builder for class "+clazz.getName());
}
@@ -374,7 +375,7 @@ public class SqlDBMapper {
m.setAccessible(true);
m.invoke(builder, getValueOrDefault(data, col, argType, null));
}
- list.add(builder.build());
+ list.add(callBuild(builder));
} else {
Object value = getValueOrDefault(data, column, clazz, null);
if (value != null) {
@@ -386,7 +387,13 @@ public class SqlDBMapper {
}
@SuppressWarnings("unchecked")
- private static <T> Builder<T> findPOJOBuilder(Class<T> ac) throws InstantiationException, IllegalAccessException,
+ private static <S,T> T callBuild(S builder) throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
+ Method method = builder.getClass().getMethod("build");
+ return (T) method.invoke(builder);
+ }
+
+ @SuppressWarnings("unchecked")
+ private static <S,T> S findPOJOBuilder(Class<T> ac) throws InstantiationException, IllegalAccessException,
IllegalArgumentException, InvocationTargetException, SecurityException, NoSuchMethodException {
try {
String builder = null;
@@ -400,8 +407,8 @@ public class SqlDBMapper {
}
if (builder != null) {
Class<?> innerBuilder = YangToolsMapperHelper.findClass(builder);
- Class<Builder<T>> builderClass = (Class<Builder<T>>) innerBuilder;
- return builderClass.getDeclaredConstructor().newInstance();
+ //Class<Builder<T>> builderClass = (Class<Builder<T>>) innerBuilder;
+ return (S) innerBuilder.getDeclaredConstructor().newInstance();
}
} catch (ClassNotFoundException e) {
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 b0b169d18..75d8c9ad2 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
@@ -24,11 +24,16 @@ package org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.database;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Arrays;
+import java.util.Map;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.SqlDBClient;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.data.rpctypehelper.QueryResult;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.query.SqlQuery;
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.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.SeverityType;
+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.FilterKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.status.output.Data;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.status.output.DataBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.status.entity.FaultsBuilder;
@@ -49,8 +54,8 @@ public class SqlDBStatusReader {
this.controllerId = controllerId;
}
- public QueryResult<Data> getDataStatus() {
- String selectQuery = createCountQuery("severity", Entity.Faultcurrent, this.controllerId);
+ public QueryResult<Data> getDataStatus(EntityInput input) {
+ String selectQuery = createCountQuery("severity", Entity.Faultcurrent, this.controllerId, input);
long criticalCount = 0;
long majorCount = 0;
long minorCount = 0;
@@ -81,7 +86,7 @@ public class SqlDBStatusReader {
DataBuilder builder = new DataBuilder().setFaults(
new FaultsBuilder().setCriticals(Uint32.valueOf(criticalCount)).setMajors(Uint32.valueOf(majorCount))
.setMinors(Uint32.valueOf(minorCount)).setWarnings(Uint32.valueOf(warningCount)).build());
- selectQuery = createCountQuery("status", Entity.NetworkelementConnection, this.controllerId);
+ selectQuery = createCountQuery("status", Entity.NetworkelementConnection, this.controllerId, input);
NetworkElementConnectionsBuilder neBuilder = new NetworkElementConnectionsBuilder();
String state;
long connectedCount = 0, connectingCount = 0, disconnectedCount = 0, mountedCount = 0, unableToConnectCount = 0,
@@ -123,10 +128,11 @@ public class SqlDBStatusReader {
return new QueryResult<Data>(Arrays.asList(builder.build()), 1, 1, 1);
}
- private static String createCountQuery(String key, Entity e, String controllerId) {
+ private static String createCountQuery(String key, Entity e, String controllerId, EntityInput input) {
+ Map<FilterKey, Filter> filter = input != null ? input.getFilter() : null;
return String.format("SELECT `%s`, COUNT(`%s`) " + "FROM `%s` " + "%s " + "GROUP BY `%s`;", key, key,
e.getName(),
- controllerId != null ? String.format("WHERE `%s`='%s'", SqlDBMapper.ODLID_DBCOL, controllerId) : "",
+ SqlQuery.getWhereExpression(filter!=null?filter.values():null, controllerId),
key);
}
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 6403a5c1d..a4df26bae 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
@@ -25,6 +25,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import java.util.stream.Collectors;
import org.eclipse.jdt.annotation.Nullable;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.database.SqlDBMapper;
@@ -114,7 +115,7 @@ public class SelectQuery implements SqlQuery {
private static Filter cleanFilter(Filter filter) {
final String sFilter = filter.getFiltervalue();
- final List<String> sFilters = filter.getFiltervalues();
+ final Set<String> sFilters = filter.getFiltervalues();
//if only single filter value is set
if (sFilter != null && (sFilters == null || sFilter.isEmpty())) {
return "*".equals(filter.getFiltervalue()) ? null : filter;
@@ -128,7 +129,7 @@ public class SelectQuery implements SqlQuery {
} ;
return new FilterBuilder().setProperty(filter.getProperty()).setFiltervalue(filter.getFiltervalue())
.setFiltervalues(
- filter.getFiltervalues().stream().filter(e -> !"*".equals(e)).collect(Collectors.toList()))
+ filter.getFiltervalues().stream().filter(e -> !"*".equals(e)).collect(Collectors.toSet()))
.build();
}
}
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 3e26d0935..c954faadb 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
@@ -24,18 +24,22 @@ package org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.query;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
+import java.util.Collection;
import java.util.Date;
import java.util.List;
+import java.util.Set;
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.database.SqlDBMapper;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.query.filters.DBFilterKeyValuePair;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.query.filters.RangeSqlDBFilter;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.query.filters.RegexSqlDBFilter;
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.entity.input.Filter;
+import io.netty.util.internal.StringUtil;
public interface SqlQuery {
@@ -50,18 +54,25 @@ public interface SqlQuery {
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) {
+ public static String getWhereExpression(Collection<Filter> filters) {
+ return getWhereExpression(filters, null);
+ }
+ public static String getWhereExpression(Collection<Filter> filters, String controllerId) {
+ if (filters == null && controllerId == 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)) + ")");
- for (int i = 1; i < filters.size(); i++) {
- sb.append(" AND (" + getFilterExpression(filters.get(i)) + ")");
- }
+ List<String> filters2 =
+ filters != null
+ ? filters.stream().filter(e -> !"*".equals(e.getFiltervalue())).map(e -> getFilterExpression(e))
+ .collect(Collectors.toList())
+ : new ArrayList<>();
+ if(controllerId!=null) {
+ filters2.add(getFilterExpression(SqlDBMapper.ODLID_DBCOL, controllerId));
+ }
+ if (!filters2.isEmpty() ) {
+ sb.append(" WHERE ");
+ sb.append(StringUtil.join(" AND ", filters2));
}
return sb.toString();
}
@@ -107,7 +118,7 @@ public interface SqlQuery {
return new DBFilterKeyValuePair(property, value).getFilterExpression();
}
- static List<String> collectValues(String filtervalue, List<String> filtervalues) {
+ static List<String> collectValues(String filtervalue, Set<String> filtervalues) {
if (filtervalues == null) {
return Arrays.asList(filtervalue);
}
diff --git a/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/query/filters/RegexSqlDBFilter.java b/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/query/filters/RegexSqlDBFilter.java
index 4ef1b9a55..65e0c54e4 100644
--- a/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/query/filters/RegexSqlDBFilter.java
+++ b/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/query/filters/RegexSqlDBFilter.java
@@ -21,7 +21,7 @@
*/
package org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.query.filters;
-public class RegexSqlDBFilter extends DBKeyValuePair<String> implements SqlDBFilter{
+public class RegexSqlDBFilter extends DBKeyValuePair<String> implements SqlDBFilter {
public RegexSqlDBFilter(String key, String value) {
@@ -32,4 +32,11 @@ public class RegexSqlDBFilter extends DBKeyValuePair<String> implements SqlDBFil
public String getFilterExpression() {
return String.format("`%s` RLIKE '%s'", this.getKey(), this.getValue());
}
+
+ @Override
+ public String getValue() {
+ String value = super.getValue();
+ return value != null ? value.replace("*", ".*") : null;
+ }
}
+