diff options
7 files changed, 188 insertions, 0 deletions
diff --git a/cds-ui/server/src/controllers/controller-catalog.controller.ts b/cds-ui/server/src/controllers/controller-catalog.controller.ts new file mode 100644 index 000000000..20e1cded6 --- /dev/null +++ b/cds-ui/server/src/controllers/controller-catalog.controller.ts @@ -0,0 +1,73 @@ +// Uncomment these imports to begin using these cool features! + +// import {inject} from '@loopback/context'; +import { + post, + param, + get, + getFilterSchemaFor, + getWhereSchemaFor, + patch, + put, + del, + requestBody, + Request, + Response, + RestBindings, +} from '@loopback/rest'; +import { inject } from '@loopback/core'; +import { ControllerCatalogService } from '../services'; + +export class ControllerCatalogController { + constructor( + @inject('services.ControllerCatalogService') + public Ccservice: ControllerCatalogService, + ){ } + + @get('/controllercatalog/search/{tags}', { + responses: { + '200': { + content: { 'application/json': {} }, + }, + }, + }) + async getByTags(@param.path.string('tags') tags: string) { + return await this.Ccservice.getByTags(tags); + } + + @post('/controllercatalog/save', { + responses: { + '200': { + content: { 'application/json': {} } + } + }, + }) + async save(@requestBody({ + content: { 'application/json': { schema: { 'x-ts-type': JSON } } }, + accepts: { 'application/json': { schema: { 'x-ts-type': JSON } } } + }) controllerCatalog: JSON): Promise<any> { + return await this.Ccservice.save(controllerCatalog); + } + + @get('/controllercatalog/model-type/by-definition/{definitionType}', { + responses: { + '200': { + content: { 'application/json': {} }, + }, + }, + }) + async getDataTypes(@param.path.string('definitionType') definitionType: string) { + return await this.Ccservice.getDefinitionTypes(definitionType); + } + + @del('/controllercatalog/model-type/{name}', { + responses: { + '200': { + content: { 'application/json': {} } + } + }, + }) + async delete(@param.path.string('name') name: string): Promise<JSON> { + return await this.Ccservice.deleteCatalog(name); + } +} diff --git a/cds-ui/server/src/controllers/index.ts b/cds-ui/server/src/controllers/index.ts index fd4d9c8ac..28327ab9d 100644 --- a/cds-ui/server/src/controllers/index.ts +++ b/cds-ui/server/src/controllers/index.ts @@ -22,3 +22,4 @@ limitations under the License. export * from './ping.controller'; export * from './blueprint-rest.controller'; export * from './data-dictionary.controller'; +export * from './controller-catalog.controller'; diff --git a/cds-ui/server/src/datasources/controller-catalog.datasource-template.ts b/cds-ui/server/src/datasources/controller-catalog.datasource-template.ts new file mode 100644 index 000000000..e45741576 --- /dev/null +++ b/cds-ui/server/src/datasources/controller-catalog.datasource-template.ts @@ -0,0 +1,76 @@ +import {processorApiConfig} from '../config/app-config';
+
+export default {
+ "name": "controllerCatalog",
+ "connector": "rest",
+ "baseURL": processorApiConfig.http.url + "/model-type",
+ "crud": false,
+ "debug": true,
+ "operations": [
+
+ {
+ "template": {
+ "method": "GET",
+ "url": processorApiConfig.http.url + "/model-type/search/{tags}",
+ "headers": {
+ "accepts": "application/json",
+ "content-type": "application/json",
+ "authorization": processorApiConfig.http.authToken
+ },
+ "responsePath": "$.*"
+ },
+ "functions": {
+ "getByTags": ["tags"]
+
+ }
+ },
+ {
+ "template": {
+ "method": "POST",
+ "url": processorApiConfig.http.url + "/model-type",
+ "headers": {
+ "accepts": "application/json",
+ "content-type": "application/json",
+ "authorization": processorApiConfig.http.authToken
+ },
+ "body": "{controllerCatalog}",
+ "responsePath": "$.*"
+ },
+ "functions": {
+ "save": ["controllerCatalog"]
+
+ }
+ },
+ {
+ "template": {
+ "method": "GET",
+ "url": processorApiConfig.http.url + "/model-type/by-definition/{definitionType}",
+ "headers": {
+ "accepts": "application/json",
+ "content-type": "application/json",
+ "authorization": processorApiConfig.http.authToken
+ },
+ "responsePath": "$.*"
+ },
+ "functions": {
+ "getDefinitionTypes": ["definitionType"]
+
+ }
+ },
+ {
+ "template": {
+ "method": "DEL",
+ "url": processorApiConfig.http.url + "/model-type/{name}",
+ "headers": {
+ "accepts": "application/json",
+ "content-type": "application/json",
+ "authorization": processorApiConfig.http.authToken
+ },
+ "responsePath": "$.*"
+ },
+ "functions": {
+ "delete": ["name"]
+ }
+ }
+ ]
+};
\ No newline at end of file diff --git a/cds-ui/server/src/datasources/controller-catalog.datasource.ts b/cds-ui/server/src/datasources/controller-catalog.datasource.ts new file mode 100644 index 000000000..d711d4693 --- /dev/null +++ b/cds-ui/server/src/datasources/controller-catalog.datasource.ts @@ -0,0 +1,14 @@ +import {inject} from '@loopback/core';
+import {juggler} from '@loopback/repository';
+import config from './controller-catalog.datasource-template';
+
+export class ControllerCatalogDataSource extends juggler.DataSource {
+ static dataSourceName = 'controllerCatalog';
+
+ constructor(
+ @inject('datasources.config.controllerCatalog', {optional: true})
+ dsConfig: object = config,
+ ) {
+ super(dsConfig);
+ }
+}
diff --git a/cds-ui/server/src/datasources/index.ts b/cds-ui/server/src/datasources/index.ts index 7ed2c9121..273441131 100644 --- a/cds-ui/server/src/datasources/index.ts +++ b/cds-ui/server/src/datasources/index.ts @@ -23,3 +23,4 @@ limitations under the License. export * from './db.datasource'; export * from './blueprint.datasource'; export * from './resource-dictionary.datasource'; +export * from './controller-catalog.datasource'; diff --git a/cds-ui/server/src/services/controller-catalog.service.ts b/cds-ui/server/src/services/controller-catalog.service.ts new file mode 100644 index 000000000..9b4880543 --- /dev/null +++ b/cds-ui/server/src/services/controller-catalog.service.ts @@ -0,0 +1,22 @@ +import {getService} from '@loopback/service-proxy';
+import {inject, Provider} from '@loopback/core';
+import {ControllerCatalogDataSource} from '../datasources';
+
+export interface ControllerCatalogService {
+ getByTags(tags: string): Promise<JSON>;
+ save(controllerCatalog: JSON): Promise<JSON>;
+ getDefinitionTypes(definitionType: string): Promise<JSON>;
+ deleteCatalog(name: string): Promise<JSON>;
+}
+
+export class ControllerCatalogServiceProvider implements Provider<ControllerCatalogService> {
+ constructor(
+ // controllerCatalog must match the name property in the datasource json file
+ @inject('datasources.controllerCatalog')
+ protected dataSource: ControllerCatalogDataSource = new ControllerCatalogDataSource(),
+ ) {}
+
+ value(): Promise<ControllerCatalogService> {
+ return getService(this.dataSource);
+ }
+}
diff --git a/cds-ui/server/src/services/index.ts b/cds-ui/server/src/services/index.ts index 8a82e3231..be987b1c9 100644 --- a/cds-ui/server/src/services/index.ts +++ b/cds-ui/server/src/services/index.ts @@ -1,2 +1,3 @@ export * from './blueprint.service'; export * from './resource-dictionary.service'; +export * from './controller-catalog.service'; |