From 7cfca9c44b6465d7eb88d64e3fa38c7f1a09c096 Mon Sep 17 00:00:00 2001 From: Shaaban Ebrahim Date: Wed, 6 Nov 2019 13:23:28 +0200 Subject: add search by meta data in cds-ui server and blueprint processor Issue-ID: CCSDK-1770 Signed-off-by: Shaaban Ebrahim Change-Id: I8ac77ab4903e3141d065a61bf28404f3d16077cd --- .../src/controllers/blueprint-rest.controller.ts | 16 +++++++++++++++- .../src/datasources/blueprint.datasource-template.ts | 18 +++++++++++++++++- cds-ui/server/src/services/blueprint.service.ts | 3 ++- .../repository/BlueprintModelSearchRepository.kt | 19 ++++++++++++++++++- .../designer/api/BlueprintModelController.kt | 10 ++++++++++ .../designer/api/handler/BluePrintModelHandler.kt | 15 +++++++++++++++ 6 files changed, 77 insertions(+), 4 deletions(-) diff --git a/cds-ui/server/src/controllers/blueprint-rest.controller.ts b/cds-ui/server/src/controllers/blueprint-rest.controller.ts index 1eef6fbcb..b52952826 100644 --- a/cds-ui/server/src/controllers/blueprint-rest.controller.ts +++ b/cds-ui/server/src/controllers/blueprint-rest.controller.ts @@ -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 +} diff --git a/cds-ui/server/src/datasources/blueprint.datasource-template.ts b/cds-ui/server/src/datasources/blueprint.datasource-template.ts index 85e0aa342..b0aaf01eb 100644 --- a/cds-ui/server/src/datasources/blueprint.datasource-template.ts +++ b/cds-ui/server/src/datasources/blueprint.datasource-template.ts @@ -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 +}; diff --git a/cds-ui/server/src/services/blueprint.service.ts b/cds-ui/server/src/services/blueprint.service.ts index 0545faca8..7952859d1 100644 --- a/cds-ui/server/src/services/blueprint.service.ts +++ b/cds-ui/server/src/services/blueprint.service.ts @@ -4,6 +4,7 @@ import {BlueprintDataSource} from '../datasources'; export interface BlueprintService { getAllblueprints(): Promise; + getBlueprintsByKeyword(keyword: string): Promise; getByTags(tags: string): Promise; } @@ -17,4 +18,4 @@ export class BlueprintServiceProvider implements Provider { value(): Promise { return getService(this.dataSource); } -} \ No newline at end of file +} diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/repository/BlueprintModelSearchRepository.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/repository/BlueprintModelSearchRepository.kt index f5ef0740e..60ca1fec1 100644 --- a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/repository/BlueprintModelSearchRepository.kt +++ b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/repository/BlueprintModelSearchRepository.kt @@ -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 */ fun findByTagsContainingIgnoreCase(tags: String): List -} \ 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 + + */ + fun findByUpdatedByOrTagsOrOrArtifactNameOrOrArtifactVersionOrArtifactType(updatedBy: String, tags: String, artifactName: String, artifactVersion: String, + artifactType: String): List +} 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 10cc0a44a..ea5023cd5 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 @@ -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 { + return this.bluePrintModelHandler.searchBluePrintModelsByKeyWord(keyWord) + } + + @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 f4b006867..19076c681 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 @@ -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 list of the controller blueprint + */ + open fun searchBluePrintModelsByKeyWord(keyWord: String): List { + return blueprintModelSearchRepository. + findByUpdatedByOrTagsOrOrArtifactNameOrOrArtifactVersionOrArtifactType( + keyWord,keyWord,keyWord,keyWord,keyWord) + } + /** * This is a deleteBlueprintModel method * -- cgit 1.2.3-korg