diff options
author | ZhangZihao <zhangzihao@chinamobile.com> | 2019-08-08 09:45:36 +0800 |
---|---|---|
committer | ZhangZihao <zhangzihao@chinamobile.com> | 2019-08-08 09:46:13 +0800 |
commit | 4d026ddb33a8922bf29029e470a1be13d9668a02 (patch) | |
tree | 6784d5d5b0fb5f5ff76bd24e30d3652094de1b59 /components/datalake-handler/feeder | |
parent | fdc2d73a151965696157718d04b1b0f57c4a747a (diff) |
Get all databases id and name by designTypeId
Change-Id: I9127ad0f5aa3b77e7e3847f9fe8240ab4c1482f7
Issue-ID: DCAEGEN2-1658
Signed-off-by: ZhangZihao <zhangzihao@chinamobile.com>
Diffstat (limited to 'components/datalake-handler/feeder')
-rw-r--r-- | components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/controller/DbController.java | 26 |
1 files changed, 16 insertions, 10 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 f177a9ac..7f35662d 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 @@ -25,10 +25,12 @@ import java.util.*; import javax.servlet.http.HttpServletResponse; import org.onap.datalake.feeder.domain.Db; +import org.onap.datalake.feeder.domain.DesignType; import org.onap.datalake.feeder.domain.Topic; import org.onap.datalake.feeder.repository.DbRepository; import org.onap.datalake.feeder.dto.DbConfig; import org.onap.datalake.feeder.controller.domain.PostReturnBody; +import org.onap.datalake.feeder.repository.DesignTypeRepository; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -41,7 +43,7 @@ import io.swagger.annotations.ApiOperation; /** * This controller manages the big data storage settings. All the settings are * saved in database. - * + * * @author Guobiao Mo * */ @@ -57,7 +59,10 @@ public class DbController { @Autowired private DbRepository dbRepository; - //list all dbs + @Autowired + private DesignTypeRepository designTypeRepository; + + //list all dbs @GetMapping("") @ResponseBody @ApiOperation(value="Gat all databases name") @@ -74,16 +79,17 @@ public class DbController { return retString; } - @GetMapping("/idAndName") + @GetMapping("/idAndName/{id}") @ResponseBody - @ApiOperation(value="Gat all databases id and name") - public Map<Integer, String> listIdAndName() { - Iterable<Db> ret = dbRepository.findAll(); + @ApiOperation(value="Get all databases id and name by designTypeId") + public Map<Integer, String> listIdAndName(@PathVariable String id) { + Optional<DesignType> designType = designTypeRepository.findById(id); Map<Integer, String> map = new HashMap<>(); - for(Db db : ret) - { - log.info(db.getId() + "\t"+ db.getName()); - map.put(db.getId(), db.getName()); + if (designType.isPresent()) { + Set<Db> dbs = designType.get().getDbType().getDbs(); + for (Db item : dbs) { + map.put(item.getId(), item.getName()); + } } return map; } |