From bb91b6eedec5d15ec4d9e473f27dd63592762cf9 Mon Sep 17 00:00:00 2001 From: Ahmedeldeeb50 Date: Tue, 12 Jan 2021 13:07:45 +0200 Subject: Add icon beside the selected templates in Function attributes tab update create_resource_dictionary API Issue-ID: CCSDK-3082 Issue-ID: CCSDK-3078 Signed-off-by: Ahmedeldeeb50 Change-Id: Ic5038dfba0c7b59c5e51096b9864aa0baff56c2b --- .../src/controllers/data-dictionary.controller.ts | 21 +- .../resource-dictionary.datasource-template.ts | 241 +++++++++++---------- .../src/services/resource-dictionary.service.ts | 9 +- 3 files changed, 152 insertions(+), 119 deletions(-) (limited to 'cds-ui/server') diff --git a/cds-ui/server/src/controllers/data-dictionary.controller.ts b/cds-ui/server/src/controllers/data-dictionary.controller.ts index 076d714c6..8dbb7eb3c 100644 --- a/cds-ui/server/src/controllers/data-dictionary.controller.ts +++ b/cds-ui/server/src/controllers/data-dictionary.controller.ts @@ -64,13 +64,28 @@ export class DataDictionaryController { } }, }) + async saveDefinition(@requestBody({ + content: { 'application/json': { schema: { 'x-ts-type': JSON } } }, + accepts: { 'application/json': { schema: { 'x-ts-type': JSON } } } + }) resourceDictionary: JSON): Promise { + return await this.rdservice.saveDefinition(resourceDictionary); + } + + @post('/resourcedictionary/definition', { + responses: { + '200': { + content: { 'application/json': {} } + } + }, + }) async save(@requestBody({ content: { 'application/json': { schema: { 'x-ts-type': JSON } } }, accepts: { 'application/json': { schema: { 'x-ts-type': JSON } } } }) resourceDictionary: JSON): Promise { - return await this.rdservice.save(resourceDictionary); + return await this.rdservice.saveDefinition(resourceDictionary); } - + + @post('/resourcedictionary/search/by-names', { responses: { '200': { @@ -114,7 +129,7 @@ export class DataDictionaryController { @get('/resourcedictionary/model-type/by-definition/{type}', { responses: { '200': { - content: {'application/json': {}}, + content: { 'application/json': {} }, }, }, }) diff --git a/cds-ui/server/src/datasources/resource-dictionary.datasource-template.ts b/cds-ui/server/src/datasources/resource-dictionary.datasource-template.ts index 7373d069e..07faa9a1a 100644 --- a/cds-ui/server/src/datasources/resource-dictionary.datasource-template.ts +++ b/cds-ui/server/src/datasources/resource-dictionary.datasource-template.ts @@ -1,4 +1,4 @@ -import {processorApiConfig} from '../config/app-config'; +import { processorApiConfig } from '../config/app-config'; export default { "name": "resourceDictionary", @@ -7,134 +7,151 @@ export default { "crud": false, "debug": true, "operations": [{ - "template": { - "method": "GET", - "url": processorApiConfig.http.url + "/dictionary/{name}", - "headers": { - "accepts": "application/json", - "content-type": "application/json", - "authorization": processorApiConfig.http.authToken - }, - "responsePath": "$.*" + "template": { + "method": "GET", + "url": processorApiConfig.http.url + "/dictionary/{name}", + "headers": { + "accepts": "application/json", + "content-type": "application/json", + "authorization": processorApiConfig.http.authToken }, - "functions": { - "getByName": ["name"] - - } + "responsePath": "$.*" }, - { - "template": { - "method": "GET", - "url": processorApiConfig.http.url + "/dictionary/source-mapping", - "headers": { - "accepts": "application/json", - "content-type": "application/json", - "authorization": processorApiConfig.http.authToken - }, - "responsePath": "$.*" - }, - "functions": { - "getSourceMapping": [] + "functions": { + "getByName": ["name"] - } - }, - { - "template": { - "method": "GET", - "url": processorApiConfig.http.url + "/dictionary/search/{tags}", - "headers": { - "accepts": "application/json", - "content-type": "application/json", - "authorization": processorApiConfig.http.authToken - }, - "responsePath": "$.*" + } + }, + { + "template": { + "method": "GET", + "url": processorApiConfig.http.url + "/dictionary/source-mapping", + "headers": { + "accepts": "application/json", + "content-type": "application/json", + "authorization": processorApiConfig.http.authToken }, - "functions": { - "getByTags": ["tags"] - - } + "responsePath": "$.*" }, - { - "template": { - "method": "POST", - "url": processorApiConfig.http.url + "/dictionary", - "headers": { - "accepts": "application/json", - "content-type": "application/json", - "authorization": processorApiConfig.http.authToken - }, - "body": "{resourceDictionary}", - "responsePath": "$.*" - }, - "functions": { - "save": ["resourceDictionary"] + "functions": { + "getSourceMapping": [] - } - }, - { - "template": { - "method": "POST", - "url": processorApiConfig.http.url + "/dictionary/by-names", - "headers": { - "accepts": "application/json", - "content-type": "application/json", - "authorization": processorApiConfig.http.authToken - }, - "body": "{resourceDictionaryList}", - "responsePath": "$.*" + } + }, + { + "template": { + "method": "GET", + "url": processorApiConfig.http.url + "/dictionary/search/{tags}", + "headers": { + "accepts": "application/json", + "content-type": "application/json", + "authorization": processorApiConfig.http.authToken }, - "functions": { - "searchbyNames": ["resourceDictionaryList"] + "responsePath": "$.*" + }, + "functions": { + "getByTags": ["tags"] - } + } + }, + { + "template": { + "method": "POST", + "url": processorApiConfig.http.url + "/dictionary", + "headers": { + "accepts": "application/json", + "content-type": "application/json", + "authorization": processorApiConfig.http.authToken + }, + "body": "{resourceDictionary}", + "responsePath": "$.*" }, - { - "template": { - "method": "GET", - "url": processorApiConfig.http.url + "/model-type/{source}", - "headers": { - "accepts": "application/json", - "content-type": "application/json", - "authorization": processorApiConfig.http.authToken - }, - "responsePath": "$.*" + "functions": { + "save": ["resourceDictionary"] + + } + }, + { + "template": { + "method": "POST", + "url": processorApiConfig.http.url + "/dictionary/definition", + "headers": { + "accepts": "application/json", + "content-type": "application/json", + "authorization": processorApiConfig.http.authToken }, - "functions": { - "getModelType": ["source"] + "body": "{resourceDictionary}", + "responsePath": "$.*" + }, + "functions": { + "saveDefinition": ["resourceDictionary"] - } + } + }, + { + "template": { + "method": "POST", + "url": processorApiConfig.http.url + "/dictionary/by-names", + "headers": { + "accepts": "application/json", + "content-type": "application/json", + "authorization": processorApiConfig.http.authToken + }, + "body": "{resourceDictionaryList}", + "responsePath": "$.*" }, - { - "template": { - "method": "GET", - "url": processorApiConfig.http.url + "/model-type/by-definition/data_type", - "headers": { - "accepts": "application/json", - "content-type": "application/json", - "authorization": processorApiConfig.http.authToken - }, - "responsePath": "$.*" + "functions": { + "searchbyNames": ["resourceDictionaryList"] + + } + }, + { + "template": { + "method": "GET", + "url": processorApiConfig.http.url + "/model-type/{source}", + "headers": { + "accepts": "application/json", + "content-type": "application/json", + "authorization": processorApiConfig.http.authToken }, - "functions": { - "getDataTypes": [] + "responsePath": "$.*" + }, + "functions": { + "getModelType": ["source"] - } + } + }, + { + "template": { + "method": "GET", + "url": processorApiConfig.http.url + "/model-type/by-definition/data_type", + "headers": { + "accepts": "application/json", + "content-type": "application/json", + "authorization": processorApiConfig.http.authToken + }, + "responsePath": "$.*" }, - { - "template": { - "method": "GET", - "url": processorApiConfig.http.url + "/model-type/by-definition/{type}", - "headers": { - "accepts": "application/json", - "content-type": "application/json", - "authorization": processorApiConfig.http.authToken - }, - "responsePath": "$.*" + "functions": { + "getDataTypes": [] + + } + }, + { + "template": { + "method": "GET", + "url": processorApiConfig.http.url + "/model-type/by-definition/{type}", + "headers": { + "accepts": "application/json", + "content-type": "application/json", + "authorization": processorApiConfig.http.authToken }, - "functions": { - "getResourceDictionaryByType": ["type"] + "responsePath": "$.*" + }, + "functions": { + "getResourceDictionaryByType": ["type"] - } } + } ] }; diff --git a/cds-ui/server/src/services/resource-dictionary.service.ts b/cds-ui/server/src/services/resource-dictionary.service.ts index a36c7fe75..6bf3f06ae 100644 --- a/cds-ui/server/src/services/resource-dictionary.service.ts +++ b/cds-ui/server/src/services/resource-dictionary.service.ts @@ -1,12 +1,13 @@ -import {getService} from '@loopback/service-proxy'; -import {inject, Provider} from '@loopback/core'; -import {ResourceDictionaryDataSource} from '../datasources'; +import { getService } from '@loopback/service-proxy'; +import { inject, Provider } from '@loopback/core'; +import { ResourceDictionaryDataSource } from '../datasources'; export interface ResourceDictionaryService { getByName(name: string): Promise; getSourceMapping(): Promise; getByTags(tags: string): Promise; save(resourceDictionary: JSON): Promise; + saveDefinition(resourceDictionary: JSON): Promise; searchbyNames(resourceDictionaryList: JSON): Promise; getModelType(source: string): Promise; getDataTypes(): Promise; @@ -18,7 +19,7 @@ export class ResourceDictionaryServiceProvider implements Provider { return getService(this.dataSource); -- cgit 1.2.3-korg