[SDC-29] catalog 1707 rebase commit.
[sdc.git] / catalog-ui / src / app / models / aschema-property.ts
1 /**
2  * Created by osonsino on 16/05/2016.
3  */
4 'use strict';
5 import { PROPERTY_DATA } from "app/utils";
6
7 export class SchemaPropertyGroupModel {
8     property:SchemaProperty;
9
10     constructor(schemaProperty?:SchemaProperty) {
11         this.property = schemaProperty;
12     }
13 }
14
15 export class SchemaProperty {
16
17     type:string;
18     required:boolean;
19     definition:boolean;
20     description:string;
21     password:boolean;
22     //custom properties
23     simpleType:string;
24     isSimpleType: boolean;
25     isDataType: boolean;
26     private _derivedFromSimpleTypeName:string;
27     get derivedFromSimpleTypeName():string {
28         return this._derivedFromSimpleTypeName;
29     }
30     set derivedFromSimpleTypeName(derivedFromSimpleTypeName:string) {
31         this._derivedFromSimpleTypeName = derivedFromSimpleTypeName;
32     }
33
34     constructor(schemaProperty?:SchemaProperty) {
35         if (schemaProperty) {
36             this.type = schemaProperty.type;
37             this.required = schemaProperty.required;
38             this.definition = schemaProperty.definition;
39             this.description = schemaProperty.description;
40             this.password = schemaProperty.password;
41             this.simpleType = schemaProperty.simpleType;
42             this.isSimpleType = (-1 < PROPERTY_DATA.SIMPLE_TYPES.indexOf(this.type));
43             this.isDataType = PROPERTY_DATA.TYPES.indexOf(this.type) == -1;
44         }
45     }
46
47     public toJSON = ():any => {
48         this.simpleType = undefined;
49         this.isSimpleType = undefined;
50         this.isDataType = undefined;
51         this._derivedFromSimpleTypeName = undefined;
52         return this;
53     };
54 }
55
56