blob: b0d22d7f91631d9bc1cb52c762a5a2350edaf827 [file] [log] [blame]
Michael Landodd603392017-07-12 00:54:52 +03001/*-
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 Landoed64b5e2017-06-09 03:19:04 +030021/**
22 * Created by osonsino on 16/05/2016.
23 */
24'use strict';
ys969316a9fce2020-01-19 13:50:02 +020025import { PROPERTY_DATA } from 'app/utils/constants';
Michael Landoed64b5e2017-06-09 03:19:04 +030026
27export class SchemaPropertyGroupModel {
ys969316a9fce2020-01-19 13:50:02 +020028 property: SchemaProperty;
Michael Landoed64b5e2017-06-09 03:19:04 +030029
ys969316a9fce2020-01-19 13:50:02 +020030 constructor(schemaProperty?: SchemaProperty) {
Michael Landoed64b5e2017-06-09 03:19:04 +030031 this.property = schemaProperty;
32 }
33}
34
35export class SchemaProperty {
36
ys969316a9fce2020-01-19 13:50:02 +020037 type: string;
38 required: boolean;
39 definition: boolean;
40 description: string;
41 password: boolean;
42 // custom properties
43 simpleType: string;
Michael Landoed64b5e2017-06-09 03:19:04 +030044 isSimpleType: boolean;
45 isDataType: boolean;
ys969316a9fce2020-01-19 13:50:02 +020046 private _derivedFromSimpleTypeName: string;
47 get derivedFromSimpleTypeName(): string {
Michael Landoed64b5e2017-06-09 03:19:04 +030048 return this._derivedFromSimpleTypeName;
49 }
ys969316a9fce2020-01-19 13:50:02 +020050 set derivedFromSimpleTypeName(derivedFromSimpleTypeName: string) {
Michael Landoed64b5e2017-06-09 03:19:04 +030051 this._derivedFromSimpleTypeName = derivedFromSimpleTypeName;
52 }
53
ys969316a9fce2020-01-19 13:50:02 +020054 constructor(schemaProperty?: SchemaProperty) {
Michael Landoed64b5e2017-06-09 03:19:04 +030055 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));
ys969316a9fce2020-01-19 13:50:02 +020063 this.isDataType = PROPERTY_DATA.TYPES.indexOf(this.type) === -1;
Michael Landoed64b5e2017-06-09 03:19:04 +030064 }
65 }
66
ys969316a9fce2020-01-19 13:50:02 +020067 public toJSON = (): any => {
Michael Landoed64b5e2017-06-09 03:19:04 +030068 this.simpleType = undefined;
69 this.isSimpleType = undefined;
70 this.isDataType = undefined;
71 this._derivedFromSimpleTypeName = undefined;
72 return this;
ys969316a9fce2020-01-19 13:50:02 +020073 }
Michael Landoed64b5e2017-06-09 03:19:04 +030074}