diff options
author | Brinda Santh Muthuramalingam <brindasanth@in.ibm.com> | 2019-11-06 18:33:49 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2019-11-06 18:33:49 +0000 |
commit | 8ce7fa4bf8b410d28985ddb3d6490e84e76d9478 (patch) | |
tree | 95dc051a077dc7f3d2bf67296dbf25890693e5fa /ms | |
parent | 94f1bfcc93e46dc08f806e9a3b495abc9d9bf53d (diff) | |
parent | 3bae63fe818d7ff134b68534edc2abfbb99374ad (diff) |
Merge "add get blueprints API with pagination and sorting"
Diffstat (limited to 'ms')
3 files changed, 32 insertions, 0 deletions
diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/BlueprintModelController.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/BlueprintModelController.kt index bf251f6c3..10cc0a44a 100644 --- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/BlueprintModelController.kt +++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/BlueprintModelController.kt @@ -21,9 +21,13 @@ import io.swagger.annotations.ApiOperation import io.swagger.annotations.ApiParam import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.domain.BlueprintModelSearch import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.handler.BluePrintModelHandler +import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.utils.BlueprintSortByOption import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.monoMdc import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException import org.springframework.core.io.Resource +import org.springframework.data.domain.Page +import org.springframework.data.domain.PageRequest +import org.springframework.data.domain.Sort import org.springframework.http.MediaType import org.springframework.http.ResponseEntity import org.springframework.http.codec.multipart.FilePart @@ -56,6 +60,16 @@ open class BlueprintModelController(private val bluePrintModelHandler: BluePrint return this.bluePrintModelHandler.allBlueprintModel() } + @GetMapping("/paged", produces = [MediaType.APPLICATION_JSON_VALUE]) + @ResponseBody + @PreAuthorize("hasRole('USER')") + fun allBlueprintModel(@RequestParam(defaultValue = "20") limit: Int, + @RequestParam(defaultValue = "0") offset: Int, + @RequestParam(defaultValue = "DATE") sort: BlueprintSortByOption): Page<BlueprintModelSearch> { + val pageRequest = PageRequest.of(offset, limit, Sort.Direction.ASC, sort.columnName) + return this.bluePrintModelHandler.allBlueprintModel(pageRequest) + } + @DeleteMapping("/{id}") @Throws(BluePrintException::class) @PreAuthorize("hasRole('USER')") diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/handler/BluePrintModelHandler.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/handler/BluePrintModelHandler.kt index 526e92cea..f4b006867 100644 --- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/handler/BluePrintModelHandler.kt +++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/handler/BluePrintModelHandler.kt @@ -33,6 +33,7 @@ import org.onap.ccsdk.cds.controllerblueprints.core.scripts.BluePrintCompileCach import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintFileUtils import org.springframework.core.io.ByteArrayResource import org.springframework.core.io.Resource +import org.springframework.data.domain.Page import org.springframework.http.HttpHeaders import org.springframework.http.MediaType import org.springframework.http.ResponseEntity @@ -41,6 +42,8 @@ import org.springframework.stereotype.Service import org.springframework.transaction.annotation.Transactional import java.io.IOException import java.util.* +import org.springframework.data.domain.Pageable + /** * BlueprintModelHandler Purpose: Handler service to handle the request from BlurPrintModelRest @@ -69,6 +72,15 @@ open class BluePrintModelHandler(private val blueprintsProcessorCatalogService: } /** + * This is a getAllBlueprintModel method to retrieve all the BlueprintModel in Database + * + * @return List<BlueprintModelSearch> list of the controller blueprint archives + </BlueprintModelSearch> */ + open fun allBlueprintModel(pageRequest: Pageable): Page<BlueprintModelSearch> { + return blueprintModelSearchRepository.findAll(pageRequest) + } + + /** * This is a saveBlueprintModel method * * @param filePart filePart diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/utils/SortByOptionsEnum.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/utils/SortByOptionsEnum.kt new file mode 100644 index 000000000..6f5636516 --- /dev/null +++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/utils/SortByOptionsEnum.kt @@ -0,0 +1,6 @@ +package org.onap.ccsdk.cds.blueprintsprocessor.designer.api.utils + +enum class BlueprintSortByOption(val columnName: String) { + DATE("createdDate"), + NAME("artifactName") +}
\ No newline at end of file |