Resource Dictionary: fecthing data-type list
[ccsdk/cds.git] / cds-ui / server / src / controllers / data-dictionary.controller.ts
1 // Uncomment these imports to begin using these cool features!
2
3 // import {inject} from '@loopback/context';
4 import {
5   post,
6   param,
7   get,
8   getFilterSchemaFor,
9   getWhereSchemaFor,
10   patch,
11   put,
12   del,
13   requestBody,
14   Request,
15   Response,
16   RestBindings,
17 } from '@loopback/rest';
18 import { inject } from '@loopback/core';
19 import { ResourceDictionaryService } from '../services';
20
21 export class DataDictionaryController {
22   constructor(
23     @inject('services.ResourceDictionaryService')
24     public rdservice: ResourceDictionaryService,
25   ) { }
26
27   @get('/resourcedictionary/{name}', {
28     responses: {
29       '200': {
30         content: { 'application/json': {} },
31       },
32     },
33   })
34   async getByName(@param.path.string('name') name: string) {
35     return await this.rdservice.getByName(name);
36   }
37
38   @get('/resourcedictionary/search/{tags}', {
39     responses: {
40       '200': {
41         content: { 'application/json': {} },
42       },
43     },
44   })
45   async getByTags(@param.path.string('tags') tags: string) {
46     return await this.rdservice.getByTags(tags);
47   }
48
49   @get('/resourcedictionary/source-mapping', {
50     responses: {
51       '200': {
52         content: { 'application/json': {} },
53       },
54     },
55   })
56   async getSourceMapping() {
57     return await this.rdservice.getSourceMapping();
58   }
59
60   @post('/resourcedictionary/save', {
61     responses: {
62       '200': {
63         content: { 'application/json': {} }
64       }
65     },
66   })
67   async save(@requestBody({
68     content: { 'application/json': { schema: { 'x-ts-type': JSON } } },
69     accepts: { 'application/json': { schema: { 'x-ts-type': JSON } } }
70   }) resourceDictionary: JSON): Promise<any> {
71     return await this.rdservice.save(resourceDictionary);
72   }
73   
74   @post('/resourcedictionary/search/by-names', {
75     responses: {
76       '200': {
77         content: { 'application/json': {} }
78       }
79     },
80   })
81   async searchByNames(@requestBody({
82     content: { 'application/json': { schema: { 'x-ts-type': JSON } } },
83     accepts: { 'application/json': { schema: { 'x-ts-type': JSON } } }
84   }) resourceDictionaryList: JSON): Promise<any> {
85     return await this.rdservice.searchbyNames(resourceDictionaryList);
86   }
87
88   @get('/resourcedictionary/model-type/{source}', {
89     responses: {
90       '200': {
91         content: { 'application/json': {} },
92       },
93     },
94   })
95   async getmodelType(@param.path.string('source') source: string) {
96     return await this.rdservice.getModelType(source);
97   }
98
99   @get('/resourcedictionary/model-type/by-definition/data_type', {
100     responses: {
101       '200': {
102         content: { 'application/json': {} },
103       },
104     },
105   })
106   async getDataTypes() {
107     return await this.rdservice.getDataTypes();
108   }
109 }