add service for searching in meta data pageable 32/98532/1
authorShaaban Ebrahim <shaaban.eltanany.ext@orange.com>
Mon, 18 Nov 2019 17:39:26 +0000 (19:39 +0200)
committerShaaban Ebrahim <shaaban.eltanany.ext@orange.com>
Mon, 18 Nov 2019 17:41:17 +0000 (19:41 +0200)
Issue-ID: CCSDK-1770

Signed-off-by: Shaaban Ebrahim <shaaban.eltanany.ext@orange.com>
Change-Id: Ibf718314f2f818108af3133641ab7be48c334dce

cds-ui/server/src/controllers/blueprint-rest.controller.ts
cds-ui/server/src/datasources/blueprint.datasource-template.ts
cds-ui/server/src/services/blueprint.service.ts
ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/repository/BlueprintModelSearchRepository.kt
ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/BlueprintModelController.kt
ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/handler/BluePrintModelHandler.kt

index 49ecb9d..1a8de6b 100644 (file)
@@ -84,6 +84,22 @@ export class BlueprintRestController {
     return await this.bpservice.getPagedBueprints(limit, offset, sort);
   }
 
+    @get('/controllerblueprint/metadata/paged/{keyword}', {
+        responses: {
+            '200': {
+                description: 'Blueprint model instance with pagination',
+                content: { 'application/json': { schema: { 'x-ts-type': Blueprint } } },
+            },
+        },
+    })
+    async getMetaDataPagedBlueprints(
+        @param.path.string('keyword') keyword: string,
+        @param.query.number('limit') limit: number,
+        @param.query.number('offset') offset: number,
+        @param.query.string('sort') sort: string) {
+        return await this.bpservice.getMetaDataPagedBlueprints(limit, offset, sort,keyword);
+    }
+
  @get('/controllerblueprint/meta-data/{keyword}', {
     responses: {
       '200': {
index 9140218..a7cea1d 100644 (file)
@@ -69,5 +69,20 @@ export default {
             "getPagedBueprints": ["limit","offset", "sort"],
         }
     },
+        {
+            "template": {
+                "method": "GET",
+                "url": processorApiConfig.http.url + "/blueprint-model/paged/meta-data/{keyword}?limit={limit}&offset={offset}&sort={sort}",
+                "headers": {
+                    "accepts": "application/json",
+                    "content-type": "application/json",
+                    "authorization": processorApiConfig.http.authToken
+                },
+                "responsePath": "$",
+            },
+            "functions": {
+                "getMetaDataPagedBlueprints": ["limit","offset", "sort","keyword"],
+            }
+        },
 ]
 };
index bc93fa1..b6474a3 100644 (file)
@@ -7,6 +7,9 @@ export interface BlueprintService {
    getBlueprintsByKeyword(keyword: string): Promise<any>;
    getByTags(tags: string): Promise<JSON>;
    getPagedBueprints(limit: number, offset: number , sort: string): Promise<any>;
+   getMetaDataPagedBlueprints(limit: number, offset: number, sort: string, keyword: string): Promise<any>;
+
+
 }
 
 export class BlueprintServiceProvider implements Provider<BlueprintService> {
index 60ca1fe..5c7a940 100644 (file)
@@ -18,6 +18,9 @@
 package org.onap.ccsdk.cds.blueprintsprocessor.db.primary.repository
 
 import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.domain.BlueprintModelSearch
+import org.springframework.data.domain.Page
+import org.springframework.data.domain.PageRequest
+import org.springframework.data.domain.Pageable
 import org.springframework.data.jpa.repository.JpaRepository
 import org.springframework.stereotype.Repository
 
@@ -76,4 +79,25 @@ interface BlueprintModelSearchRepository : JpaRepository<BlueprintModelSearch, L
      */
     fun findByUpdatedByOrTagsOrOrArtifactNameOrOrArtifactVersionOrArtifactType(updatedBy: String, tags: String, artifactName: String, artifactVersion: String,
                                                                                artifactType: String): List<BlueprintModelSearch>
+
+
+    /**
+     * This is a findby some attributes method
+     *
+     * @author Shaaban Ebrahim
+     *
+     * @param updatedBy
+     * @param tags
+     * @param artifactName
+     * @param artifactVersion
+     * @param artifactType
+     * @param pageRequest
+     * @return Page<BlueprintModelSearch>
+     */
+    fun findByUpdatedByOrTagsOrOrArtifactNameOrOrArtifactVersionOrArtifactType(updatedBy: String, tags: String, artifactName: String, artifactVersion: String,
+                                                                               artifactType: String,pageRequest: Pageable): Page<BlueprintModelSearch>
+
+
+
+
 }
index ea5023c..94c0950 100644 (file)
@@ -35,7 +35,9 @@ import org.springframework.http.ResponseEntity
 import org.springframework.http.codec.multipart.FilePart
 import org.springframework.security.access.prepost.PreAuthorize
 import org.springframework.web.bind.annotation.*
+import reactor.core.publisher.Flux
 import reactor.core.publisher.Mono
+import java.time.Duration
 
 /**
  * BlueprintModelController Purpose: Handle controllerBlueprint API request
@@ -76,10 +78,23 @@ open class BlueprintModelController(private val bluePrintModelHandler: BluePrint
     @ResponseBody
     @PreAuthorize("hasRole('USER')")
     fun allBlueprintModelMetaData(@NotNull @PathVariable(value = "keyword") keyWord: String): List<BlueprintModelSearch> {
-        return this.bluePrintModelHandler.searchBluePrintModelsByKeyWord(keyWord)
+      return this.bluePrintModelHandler.searchBluePrintModelsByKeyWord(keyWord)
     }
 
 
+    @GetMapping("/paged/meta-data/{keyword}", produces = [MediaType.APPLICATION_JSON_VALUE])
+    @ResponseBody
+    @PreAuthorize("hasRole('USER')")
+    fun allBlueprintModelMetaDataPaged(@NotNull @PathVariable(value = "keyword") keyWord: String,
+                                       @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.searchBluePrintModelsByKeyWordPaged(keyWord,pageRequest)
+
+    }
+
     @DeleteMapping("/{id}")
     @Throws(BluePrintException::class)
     @PreAuthorize("hasRole('USER')")
index 19076c6..2166483 100644 (file)
@@ -35,6 +35,7 @@ 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.data.domain.PageRequest
 import org.springframework.http.HttpHeaders
 import org.springframework.http.MediaType
 import org.springframework.http.ResponseEntity
@@ -245,7 +246,22 @@ open class BluePrintModelHandler(private val blueprintsProcessorCatalogService:
                 findByUpdatedByOrTagsOrOrArtifactNameOrOrArtifactVersionOrArtifactType(
                         keyWord,keyWord,keyWord,keyWord,keyWord)
     }
-    
+
+
+
+    /**
+     * This is a searchBluePrintModelsByKeyWordPagebale method to retrieve specific  BlueprintModel in Database
+     * where keyword equals updatedBy or tags or artifcat name or artifcat version or artifact type and pageable
+     * @author Shaaban Ebrahim
+     * @param keyWord
+     *
+     * @return List<BlueprintModelSearch> list of the controller blueprint
+    </BlueprintModelSearch> */
+    open fun searchBluePrintModelsByKeyWordPaged(keyWord: String, pageRequest: PageRequest): Page<BlueprintModelSearch>
+    {
+        return blueprintModelSearchRepository.
+                findByUpdatedByOrTagsOrOrArtifactNameOrOrArtifactVersionOrArtifactType(keyWord,keyWord,keyWord,keyWord,keyWord,pageRequest)
+    }
     /**
      * This is a deleteBlueprintModel method
      *