Adding integration to backend in Controller catalog 02/100202/4
authorswapnalipode <sp00501638@techmahindra.com>
Fri, 10 Jan 2020 16:58:48 +0000 (22:28 +0530)
committerKAPIL SINGAL <ks220y@att.com>
Mon, 13 Jan 2020 19:40:39 +0000 (19:40 +0000)
Adding integration to backend in controller catalog

Change-Id: Ia423d05ee5b089af6df70296a40d36d84892d488
Issue-ID: CCSDK-814
Signed-off-by: swapnalipode <sp00501638@techmahindra.com>
cds-ui/server/src/controllers/controller-catalog.controller.ts [new file with mode: 0644]
cds-ui/server/src/controllers/index.ts
cds-ui/server/src/datasources/controller-catalog.datasource-template.ts [new file with mode: 0644]
cds-ui/server/src/datasources/controller-catalog.datasource.ts [new file with mode: 0644]
cds-ui/server/src/datasources/index.ts
cds-ui/server/src/services/controller-catalog.service.ts [new file with mode: 0644]
cds-ui/server/src/services/index.ts

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 (file)
index 0000000..20e1cde
--- /dev/null
@@ -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);
+    }
+}
index fd4d9c8..28327ab 100644 (file)
@@ -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 (file)
index 0000000..e457415
--- /dev/null
@@ -0,0 +1,76 @@
+import {processorApiConfig} from '../config/app-config';\r
+\r
+export default {\r
+    "name": "controllerCatalog",\r
+    "connector": "rest",\r
+    "baseURL": processorApiConfig.http.url + "/model-type",\r
+    "crud": false,\r
+    "debug": true,\r
+    "operations": [\r
+\r
+          {\r
+            "template": {\r
+                "method": "GET",\r
+                "url": processorApiConfig.http.url + "/model-type/search/{tags}",\r
+                "headers": {\r
+                    "accepts": "application/json",\r
+                    "content-type": "application/json",\r
+                    "authorization": processorApiConfig.http.authToken\r
+                },\r
+                "responsePath": "$.*"\r
+            },\r
+            "functions": {\r
+                "getByTags": ["tags"]\r
+\r
+          }\r
+        },\r
+          {\r
+            "template": {\r
+                "method": "POST",\r
+                "url": processorApiConfig.http.url + "/model-type",\r
+                "headers": {\r
+                    "accepts": "application/json",\r
+                    "content-type": "application/json",\r
+                    "authorization": processorApiConfig.http.authToken\r
+                },\r
+                "body": "{controllerCatalog}",\r
+                "responsePath": "$.*"\r
+            },\r
+            "functions": {\r
+                "save": ["controllerCatalog"]\r
+\r
+          }\r
+        },\r
+          {\r
+            "template": {\r
+                "method": "GET",\r
+                "url": processorApiConfig.http.url + "/model-type/by-definition/{definitionType}",\r
+                "headers": {\r
+                    "accepts": "application/json",\r
+                    "content-type": "application/json",\r
+                    "authorization": processorApiConfig.http.authToken\r
+                },\r
+                "responsePath": "$.*"\r
+            },\r
+            "functions": {\r
+                "getDefinitionTypes": ["definitionType"]\r
+\r
+           }\r
+        },\r
+           {\r
+             "template": {\r
+                   "method": "DEL",\r
+                   "url": processorApiConfig.http.url + "/model-type/{name}",\r
+                   "headers": {\r
+                       "accepts": "application/json",\r
+                       "content-type": "application/json",\r
+                       "authorization": processorApiConfig.http.authToken\r
+                   },\r
+                   "responsePath": "$.*"\r
+             },\r
+             "functions": {\r
+                  "delete": ["name"]\r
+             }\r
+           }\r
+    ]\r
+};
\ 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 (file)
index 0000000..d711d46
--- /dev/null
@@ -0,0 +1,14 @@
+import {inject} from '@loopback/core';\r
+import {juggler} from '@loopback/repository';\r
+import config from './controller-catalog.datasource-template';\r
+\r
+export class ControllerCatalogDataSource extends juggler.DataSource {\r
+  static dataSourceName = 'controllerCatalog';\r
+\r
+  constructor(\r
+    @inject('datasources.config.controllerCatalog', {optional: true})\r
+    dsConfig: object = config,\r
+  ) {\r
+    super(dsConfig);\r
+  }\r
+}\r
index 7ed2c91..2734411 100644 (file)
@@ -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 (file)
index 0000000..9b48805
--- /dev/null
@@ -0,0 +1,22 @@
+import {getService} from '@loopback/service-proxy';\r
+import {inject, Provider} from '@loopback/core';\r
+import {ControllerCatalogDataSource} from '../datasources';\r
+\r
+export interface ControllerCatalogService {\r
+  getByTags(tags: string): Promise<JSON>;\r
+  save(controllerCatalog: JSON): Promise<JSON>;\r
+  getDefinitionTypes(definitionType: string): Promise<JSON>;\r
+  deleteCatalog(name: string): Promise<JSON>;\r
+}\r
+\r
+export class ControllerCatalogServiceProvider implements Provider<ControllerCatalogService> {\r
+  constructor(\r
+    // controllerCatalog must match the name property in the datasource json file\r
+    @inject('datasources.controllerCatalog')\r
+    protected dataSource: ControllerCatalogDataSource = new ControllerCatalogDataSource(),\r
+  ) {}\r
+\r
+  value(): Promise<ControllerCatalogService> {\r
+    return getService(this.dataSource);\r
+  }\r
+}\r
index 8a82e32..be987b1 100644 (file)
@@ -1,2 +1,3 @@
 export * from './blueprint.service';
 export * from './resource-dictionary.service';
+export * from './controller-catalog.service';