Michael Lando | dd60339 | 2017-07-12 00:54:52 +0300 | [diff] [blame] | 1 | /*- |
| 2 | * ============LICENSE_START======================================================= |
| 3 | * SDC |
| 4 | * ================================================================================ |
| 5 | * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. |
| 6 | * ================================================================================ |
| 7 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 8 | * you may not use this file except in compliance with the License. |
| 9 | * You may obtain a copy of the License at |
| 10 | * |
| 11 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | * |
| 13 | * Unless required by applicable law or agreed to in writing, software |
| 14 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 16 | * See the License for the specific language governing permissions and |
| 17 | * limitations under the License. |
| 18 | * ============LICENSE_END========================================================= |
| 19 | */ |
| 20 | |
Michael Lando | ed64b5e | 2017-06-09 03:19:04 +0300 | [diff] [blame] | 21 | /** |
| 22 | * Created by osonsino on 16/05/2016. |
| 23 | */ |
| 24 | 'use strict'; |
| 25 | import { PROPERTY_DATA } from "app/utils"; |
| 26 | |
| 27 | export class SchemaPropertyGroupModel { |
| 28 | property:SchemaProperty; |
| 29 | |
| 30 | constructor(schemaProperty?:SchemaProperty) { |
| 31 | this.property = schemaProperty; |
| 32 | } |
| 33 | } |
| 34 | |
| 35 | export class SchemaProperty { |
| 36 | |
| 37 | type:string; |
| 38 | required:boolean; |
| 39 | definition:boolean; |
| 40 | description:string; |
| 41 | password:boolean; |
| 42 | //custom properties |
| 43 | simpleType:string; |
| 44 | isSimpleType: boolean; |
| 45 | isDataType: boolean; |
| 46 | private _derivedFromSimpleTypeName:string; |
| 47 | get derivedFromSimpleTypeName():string { |
| 48 | return this._derivedFromSimpleTypeName; |
| 49 | } |
| 50 | set derivedFromSimpleTypeName(derivedFromSimpleTypeName:string) { |
| 51 | this._derivedFromSimpleTypeName = derivedFromSimpleTypeName; |
| 52 | } |
| 53 | |
| 54 | constructor(schemaProperty?:SchemaProperty) { |
| 55 | if (schemaProperty) { |
| 56 | this.type = schemaProperty.type; |
| 57 | this.required = schemaProperty.required; |
| 58 | this.definition = schemaProperty.definition; |
| 59 | this.description = schemaProperty.description; |
| 60 | this.password = schemaProperty.password; |
| 61 | this.simpleType = schemaProperty.simpleType; |
| 62 | this.isSimpleType = (-1 < PROPERTY_DATA.SIMPLE_TYPES.indexOf(this.type)); |
| 63 | this.isDataType = PROPERTY_DATA.TYPES.indexOf(this.type) == -1; |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | public toJSON = ():any => { |
| 68 | this.simpleType = undefined; |
| 69 | this.isSimpleType = undefined; |
| 70 | this.isDataType = undefined; |
| 71 | this._derivedFromSimpleTypeName = undefined; |
| 72 | return this; |
| 73 | }; |
| 74 | } |
| 75 | |
| 76 | |