diff options
Diffstat (limited to 'sdnr/wt/data-provider/dblib/src/main/java/org')
2 files changed, 45 insertions, 23 deletions
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) |