Add code for data format webtool
[dcaegen2/platform/cli.git] / dcaedftool / src / app / metaschema.service.ts
1 // org.onap.dcae\r
2 // ============LICENSE_START====================================================\r
3 // Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.\r
4 // =============================================================================\r
5 // Licensed under the Apache License, Version 2.0 (the "License");\r
6 // you may not use this file except in compliance with the License.\r
7 // You may obtain a copy of the License at\r
8 //\r
9 //     http://www.apache.org/licenses/LICENSE-2.0\r
10 //\r
11 // Unless required by applicable law or agreed to in writing, software\r
12 // distributed under the License is distributed on an "AS IS" BASIS,\r
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
14 // See the License for the specific language governing permissions and\r
15 // limitations under the License.\r
16 // ============LICENSE_END======================================================\r
17 //\r
18 // ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
19 import { Injectable } from '@angular/core';\r
20 \r
21 @Injectable()\r
22 export class MetaSchemaService {\r
23 \r
24   private metaschemaVersions: string [] = ['1.0','1.1 test only'];\r
25   private metaschemaVersion: string;\r
26 \r
27   //    Get it from a external URL?  Note version 6 now.\r
28   private metaschema1_obj: any ={'$schema': 'http://json-schema.org/draft-04/schema#','title':'Data format specification schema Version 1.0','type':'object','oneOf':[{'properties':{'self':{'$ref':'#/definitions/self'},'dataformatversion':{'$ref':'#/definitions/dataformatversion'},'reference':{'type':'object','description':'A reference to an external schema','properties':{'name':{'$ref':'#/definitions/name'},'version':{'$ref':'#/definitions/version'},'format':{'$ref':'#/definitions/format'}},'required':['name','version','format'],'additionalProperties':false}},'required':['self','dataformatversion','reference'],'additionalProperties':false},{'properties':{'self':{'$ref':'#/definitions/self'},'dataformatversion':{'$ref':'#/definitions/dataformatversion'},'jsonschema':{'$schema':'http://json-schema.org/draft-04/schema#','description':'The JSON schema for this data format'}},'required':['self','dataformatversion','jsonschema'],'additionalProperties':false},{'properties':{'self':{'$ref':'#/definitions/self'},'dataformatversion':{'$ref':'#/definitions/dataformatversion'},'delimitedschema':{'type':'object','description':'A JSON schema for delimited files','properties':{'delimiter':{'enum':[',','|','\t']},'fields':{'type':'array','description':'Array of field descriptions','items':{'$ref':'#/definitions/field'}}},'additionalProperties':false}},'required':['self','dataformatversion','delimitedschema'],'additionalProperties':false},{'properties':{'self':{'$ref':'#/definitions/self'},'dataformatversion':{'$ref':'#/definitions/dataformatversion'},'unstructured':{'type':'object','description':'A JSON schema for unstructured text','properties':{'encoding':{'type':'string','enum':['ASCII','UTF-8','UTF-16','UTF-32']}},'additionalProperties':false}},'required':['self','dataformatversion','unstructured'],'additionalProperties':false}],'definitions':{'name':{'type':'string'},'version':{'type':'string','pattern':'^(\\d+\\.)(\\d+\\.)(\\*|\\d+)$'},'self':{'description':'Identifying Information','type':'object','properties':{'name':{'$ref':'#/definitions/name'},'version':{'$ref':'#/definitions/version'},'description':{'type':'string'}},'required':['name','version'],'additionalProperties':false},'format':{'description':'Referenceschematype','type':'string','enum':['JSON','DelimitedFormat','XML','Unstructured']},'field':{'description':'Afielddefinitionforthedelimitedschema','type':'object','properties':{'name':{'type':'string'},'description':{'type':'string'},'fieldtype':{'description':'the field type; XML schema types','type':'string','enum':['string','boolean','decimal','float','double','duration','dateTime','time','date','gYearMonth','gYear','gMonthDay','gDay','gMonth','hexBinary','base64Binary','anyURI','QName','NOTATION','normalizedString','token','language','IDREFS','ENTITIES','NMTOKEN','NMTOKENS','Name','NCName','ID','IDREF','ENTITY','integer','nonPositiveInteger','negativeInteger','long','int','short','byte','nonNegativeInteger','unsignedLong','unsignedInt','unsignedShort','unsignedByte','positiveInteger']},'fieldPattern':{'description':'Regular expression','type':'integer'},'fieldMaxLength':{'description':'The maximum length','type':'integer'},'fieldMinLength':{'description':'The minimum length','type':'integer'},'fieldMinimum':{'description':'The minimum numeric value','type':'integer'},'fieldMaximum':{'description':'The maximum numeric value','type':'integer'}},'additionalProperties':false},'dataformatversion':{'type':'string','enum':['1.0.0']}}};\r
29 \r
30   private currentMetaSchemaVersion = '1.0';\r
31 \r
32   constructor() {\r
33   }\r
34 \r
35   currentMetaSchema(): any {\r
36       return this.metaschema1_obj;\r
37   }\r
38   currentMetaSchemaFormatted(): string {\r
39       return JSON.stringify(this.metaschema1_obj, undefined, '\t');\r
40   }\r
41 \r
42   metaSchemaVersion(): string {\r
43      return this.currentMetaSchemaVersion;\r
44   }\r
45 \r
46   setMetaSchemaVersion(newVersion: string): boolean {\r
47     this.currentMetaSchemaVersion = newVersion;\r
48     return true;\r
49   }\r
50 \r
51   metaSchemaVersions(): any {\r
52     return this.metaschemaVersions;\r
53   }\r
54 \r
55 }\r