add search by meta data in cds-ui server and blueprint processor 39/98039/2
authorShaaban Ebrahim <shaaban.eltanany.ext@orange.com>
Wed, 6 Nov 2019 11:23:28 +0000 (13:23 +0200)
committerShaaban Ebrahim <shaaban.eltanany.ext@orange.com>
Wed, 6 Nov 2019 19:35:57 +0000 (21:35 +0200)
Issue-ID: CCSDK-1770

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

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 1eef6fb..b529528 100644 (file)
@@ -69,6 +69,20 @@ export class BlueprintRestController {
     return await this.bpservice.getAllblueprints();
   }
 
+ @get('/controllerblueprint/meta-data/{keyword}', {
+    responses: {
+      '200': {
+        description: 'Blueprint model instance',
+        content: { 'application/json': { schema: { 'x-ts-type': Blueprint } } },
+      },
+    },
+  })
+  async getAllPacakgesByKeword(@param.path.string('keyword') keyword: string) {
+    return await this.bpservice.getBlueprintsByKeyword(keyword);
+  }
+
+
+
   @get('/controllerblueprint/searchByTags/{tags}', {
     responses: {
       '200': {
@@ -344,4 +358,4 @@ export class BlueprintRestController {
         });
     });
   }
-}
\ No newline at end of file
+}
index 85e0aa3..b0aaf01 100644 (file)
@@ -38,5 +38,21 @@ export default {
 
         }
     },
+  {
+            "template": {
+                "method": "GET",
+                "url": processorApiConfig.http.url + "/blueprint-model/meta-data/{keyword}",
+                "headers": {
+                    "accepts": "application/json",
+                    "content-type": "application/json",
+                    "authorization": processorApiConfig.http.authToken
+                },
+                "responsePath": "$.*"
+            },
+            "functions": {
+                "getBlueprintsByKeyword": ["keyword"]
+
+            }
+        },
 ]
-};
\ No newline at end of file
+};
index 0545fac..7952859 100644 (file)
@@ -4,6 +4,7 @@ import {BlueprintDataSource} from '../datasources';
 
 export interface BlueprintService {
    getAllblueprints(): Promise<any>;
+   getBlueprintsByKeyword(keyword: string): Promise<any>;
    getByTags(tags: string): Promise<JSON>;
 }
 
@@ -17,4 +18,4 @@ export class BlueprintServiceProvider implements Provider<BlueprintService> {
   value(): Promise<BlueprintService> {
     return getService(this.dataSource);
   }
-}
\ No newline at end of file
+}
index f5ef074..60ca1fe 100644 (file)
@@ -1,5 +1,6 @@
 /*
  *  Copyright © 2019 IBM.
+ *  Modifications Copyright © 2019 Orange.
  *
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -59,4 +60,20 @@ interface BlueprintModelSearchRepository : JpaRepository<BlueprintModelSearch, L
      * @return Optional<BlueprintModelSearch>
     </BlueprintModelSearch> */
     fun findByTagsContainingIgnoreCase(tags: String): List<BlueprintModelSearch>
-}
\ No newline at end of file
+
+    /**
+     * This is a findby some attributes method
+     *
+     * @author Shaaban Ebrahim
+     *
+     * @param updatedBy
+     * @param tags
+     * @param artifactName
+     * @param artifactVersion
+     * @param artifactType
+     * @return Optional<BlueprintModelSearch>
+    </BlueprintModelSearch>
+     */
+    fun findByUpdatedByOrTagsOrOrArtifactNameOrOrArtifactVersionOrArtifactType(updatedBy: String, tags: String, artifactName: String, artifactVersion: String,
+                                                                               artifactType: String): List<BlueprintModelSearch>
+}
index 10cc0a4..ea5023c 100644 (file)
@@ -1,6 +1,7 @@
 /*
  * Copyright © 2019 Bell Canada Intellectual Property.
  * Modifications Copyright © 2019 IBM.
+ * Modifications Copyright © 2019 Orange.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -19,6 +20,7 @@ package org.onap.ccsdk.cds.blueprintsprocessor.designer.api
 
 import io.swagger.annotations.ApiOperation
 import io.swagger.annotations.ApiParam
+import org.jetbrains.annotations.NotNull
 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
@@ -70,6 +72,14 @@ open class BlueprintModelController(private val bluePrintModelHandler: BluePrint
         return this.bluePrintModelHandler.allBlueprintModel(pageRequest)
     }
 
+    @GetMapping("meta-data/{keyword}", produces = [MediaType.APPLICATION_JSON_VALUE])
+    @ResponseBody
+    @PreAuthorize("hasRole('USER')")
+    fun allBlueprintModelMetaData(@NotNull @PathVariable(value = "keyword") keyWord: String): List<BlueprintModelSearch> {
+        return this.bluePrintModelHandler.searchBluePrintModelsByKeyWord(keyWord)
+    }
+
+
     @DeleteMapping("/{id}")
     @Throws(BluePrintException::class)
     @PreAuthorize("hasRole('USER')")
index f4b0068..19076c6 100644 (file)
@@ -2,6 +2,7 @@
  * Copyright © 2017-2018 AT&T Intellectual Property.
  * Modifications Copyright © 2019 Bell Canada.
  * Modifications Copyright © 2019 IBM.
+ * Modifications Copyright © 2019 Orange.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -231,6 +232,20 @@ open class BluePrintModelHandler(private val blueprintsProcessorCatalogService:
                         String.format(BLUEPRINT_MODEL_ID_FAILURE_MSG, id))
     }
 
+    /**
+     * This is a searchBluePrintModelsByKeyWord method to retrieve specific  BlueprintModel in Database
+     * where keyword equals updatedBy or tags or artifcat name or artifcat version or artifact type
+     * @author Shaaban Ebrahim
+     * @param keyWord
+     *
+     * @return List<BlueprintModelSearch> list of the controller blueprint
+    </BlueprintModelSearch> */
+    open fun searchBluePrintModelsByKeyWord(keyWord: String): List<BlueprintModelSearch> {
+        return blueprintModelSearchRepository.
+                findByUpdatedByOrTagsOrOrArtifactNameOrOrArtifactVersionOrArtifactType(
+                        keyWord,keyWord,keyWord,keyWord,keyWord)
+    }
+    
     /**
      * This is a deleteBlueprintModel method
      *