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'; |
ys9693 | 16a9fce | 2020-01-19 13:50:02 +0200 | [diff] [blame^] | 25 | import { PROPERTY_DATA } from 'app/utils/constants'; |
Michael Lando | ed64b5e | 2017-06-09 03:19:04 +0300 | [diff] [blame] | 26 | |
| 27 | export class SchemaPropertyGroupModel { |
ys9693 | 16a9fce | 2020-01-19 13:50:02 +0200 | [diff] [blame^] | 28 | property: SchemaProperty; |
Michael Lando | ed64b5e | 2017-06-09 03:19:04 +0300 | [diff] [blame] | 29 | |
ys9693 | 16a9fce | 2020-01-19 13:50:02 +0200 | [diff] [blame^] | 30 | constructor(schemaProperty?: SchemaProperty) { |
Michael Lando | ed64b5e | 2017-06-09 03:19:04 +0300 | [diff] [blame] | 31 | this.property = schemaProperty; |
| 32 | } |
| 33 | } |
| 34 | |
| 35 | export class SchemaProperty { |
| 36 | |
ys9693 | 16a9fce | 2020-01-19 13:50:02 +0200 | [diff] [blame^] | 37 | type: string; |
| 38 | required: boolean; |
| 39 | definition: boolean; |
| 40 | description: string; |
| 41 | password: boolean; |
| 42 | // custom properties |
| 43 | simpleType: string; |
Michael Lando | ed64b5e | 2017-06-09 03:19:04 +0300 | [diff] [blame] | 44 | isSimpleType: boolean; |
| 45 | isDataType: boolean; |
ys9693 | 16a9fce | 2020-01-19 13:50:02 +0200 | [diff] [blame^] | 46 | private _derivedFromSimpleTypeName: string; |
| 47 | get derivedFromSimpleTypeName(): string { |
Michael Lando | ed64b5e | 2017-06-09 03:19:04 +0300 | [diff] [blame] | 48 | return this._derivedFromSimpleTypeName; |
| 49 | } |
ys9693 | 16a9fce | 2020-01-19 13:50:02 +0200 | [diff] [blame^] | 50 | set derivedFromSimpleTypeName(derivedFromSimpleTypeName: string) { |
Michael Lando | ed64b5e | 2017-06-09 03:19:04 +0300 | [diff] [blame] | 51 | this._derivedFromSimpleTypeName = derivedFromSimpleTypeName; |
| 52 | } |
| 53 | |
ys9693 | 16a9fce | 2020-01-19 13:50:02 +0200 | [diff] [blame^] | 54 | constructor(schemaProperty?: SchemaProperty) { |
Michael Lando | ed64b5e | 2017-06-09 03:19:04 +0300 | [diff] [blame] | 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)); |
ys9693 | 16a9fce | 2020-01-19 13:50:02 +0200 | [diff] [blame^] | 63 | this.isDataType = PROPERTY_DATA.TYPES.indexOf(this.type) === -1; |
Michael Lando | ed64b5e | 2017-06-09 03:19:04 +0300 | [diff] [blame] | 64 | } |
| 65 | } |
| 66 | |
ys9693 | 16a9fce | 2020-01-19 13:50:02 +0200 | [diff] [blame^] | 67 | public toJSON = (): any => { |
Michael Lando | ed64b5e | 2017-06-09 03:19:04 +0300 | [diff] [blame] | 68 | this.simpleType = undefined; |
| 69 | this.isSimpleType = undefined; |
| 70 | this.isDataType = undefined; |
| 71 | this._derivedFromSimpleTypeName = undefined; |
| 72 | return this; |
ys9693 | 16a9fce | 2020-01-19 13:50:02 +0200 | [diff] [blame^] | 73 | } |
Michael Lando | ed64b5e | 2017-06-09 03:19:04 +0300 | [diff] [blame] | 74 | } |