summaryrefslogtreecommitdiffstats
path: root/components/datalake-handler/feeder/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'components/datalake-handler/feeder/src/main')
-rw-r--r--components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/controller/DbController.java22
-rw-r--r--components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/domain/Topic.java8
-rw-r--r--components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/dto/TopicConfig.java4
-rw-r--r--components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/service/TopicService.java8
4 files changed, 19 insertions, 23 deletions
diff --git a/components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/controller/DbController.java b/components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/controller/DbController.java
index 54f46e6f..49439e60 100644
--- a/components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/controller/DbController.java
+++ b/components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/controller/DbController.java
@@ -71,14 +71,13 @@ public class DbController {
//list all dbs
@GetMapping("")
@ResponseBody
- @ApiOperation(value="Get all databases name")
- public List<String> list() {
+ @ApiOperation(value="Get all database id")
+ public List<Integer> list() {
Iterable<Db> ret = dbRepository.findAll();
- List<String> retString = new ArrayList<>();
+ List<Integer> retString = new ArrayList<>();
for(Db db : ret)
{
- log.info(db.getName());
- retString.add(db.getName());
+ retString.add(db.getId());
}
return retString;
@@ -165,16 +164,13 @@ public class DbController {
//Show a db
//the topics are missing in the return, since in we use @JsonBackReference on Db's topics
//need to the the following method to retrieve the topic list
- @GetMapping("/{dbName}")
+ @GetMapping("/{dbId}")
@ResponseBody
@ApiOperation(value="Get a database's details.")
- public Db getDb(@PathVariable("dbName") String dbName, HttpServletResponse response) throws IOException {
- Db db = dbRepository.findByName(dbName);
- if (db == null) {
- sendError(response, 404, DB_NOT_FOUND + dbName);
- }
- return db;
- }
+ public DbConfig getDb(@PathVariable("dbId") int dbId, HttpServletResponse response) throws IOException {
+ Optional<Db> db = dbRepository.findById(dbId);
+ return db.isPresent() ? db.get().getDbConfig() : null;
+ }
//Delete a db
diff --git a/components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/domain/Topic.java b/components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/domain/Topic.java
index 5d0c7625..0de004d4 100644
--- a/components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/domain/Topic.java
+++ b/components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/domain/Topic.java
@@ -199,13 +199,13 @@ public class Topic {
tConfig.setTtl(getTtl());
Set<Db> topicDb = getDbs();
- List<String> dbList = new ArrayList<>();
- List<String> enabledDbList = new ArrayList<>();
+ List<Integer> dbList = new ArrayList<>();
+ List<Integer> enabledDbList = new ArrayList<>();
if (topicDb != null) {
for (Db item : topicDb) {
- dbList.add(item.getName());
+ dbList.add(item.getId());
if(item.isEnabled()) {
- enabledDbList.add(item.getName());
+ enabledDbList.add(item.getId());
}
}
}
diff --git a/components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/dto/TopicConfig.java b/components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/dto/TopicConfig.java
index 6a262ca8..1bdad2ec 100644
--- a/components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/dto/TopicConfig.java
+++ b/components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/dto/TopicConfig.java
@@ -41,8 +41,8 @@ public class TopicConfig {
private String name;
private String login;
private String password;
- private List<String> sinkdbs;
- private List<String> enabledSinkdbs;//only include enabled db
+ private List<Integer> sinkdbs;
+ private List<Integer> enabledSinkdbs;//only include enabled db
private boolean enabled;
private boolean saveRaw;
private String dataFormat;
diff --git a/components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/service/TopicService.java b/components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/service/TopicService.java
index e13a5d60..2f0761ab 100644
--- a/components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/service/TopicService.java
+++ b/components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/service/TopicService.java
@@ -160,10 +160,10 @@ public class TopicService {
topic.setFlattenArrayPath(tConfig.getFlattenArrayPath());
if (tConfig.getSinkdbs() != null) {
- for (String item : tConfig.getSinkdbs()) {
- Db sinkdb = dbRepository.findByName(item);
- if (sinkdb != null) {
- relateDb.add(sinkdb);
+ for (int item : tConfig.getSinkdbs()) {
+ Optional<Db> sinkdb = dbRepository.findById(item);
+ if (sinkdb.isPresent()) {
+ relateDb.add(sinkdb.get());
}
}
if (!relateDb.isEmpty())