Reduce the number of problems in aai-common by removing unused imports
[aai/aai-common.git] / aai-schema-ingest / src / main / java / org / onap / aai / setup / SchemaVersions.java
1 /**
2  * ============LICENSE_START=======================================================
3  * org.onap.aai
4  * ================================================================================
5  * Copyright © 2017-18 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
21 package org.onap.aai.setup;
22
23 import java.util.List;
24
25 import org.onap.aai.validation.AAISchemaValidationException;
26 import org.springframework.context.annotation.PropertySource;
27
28 @PropertySource(value = "classpath:schema-ingest.properties", ignoreResourceNotFound = true)
29 @PropertySource(value = "file:${schema.ingest.file}", ignoreResourceNotFound = true)
30 public class SchemaVersions {
31
32     protected List<SchemaVersion> versionsValue;
33     protected SchemaVersion edgeLabelVersionValue;
34     protected SchemaVersion defaultVersionValue;
35     protected SchemaVersion depthVersionValue;
36     protected SchemaVersion appRootVersionValue;
37     protected SchemaVersion relatedLinkVersionValue;
38     protected SchemaVersion namespaceChangeVersionValue;
39
40     protected void validate() {
41         String errorMessage = "Invalid, edge label version is not in the api versions list"
42                 + ", please check schema.version.list and ensure that the"
43                 + " schema.version.edge.label.start is in that list";
44         if (!versionsValue.contains(edgeLabelVersionValue)) {
45             throw new AAISchemaValidationException(errorMessage);
46         }
47
48         if (!versionsValue.contains(defaultVersionValue)) {
49             throw new AAISchemaValidationException(errorMessage);
50         }
51
52         if (!versionsValue.contains(depthVersionValue)) {
53             throw new AAISchemaValidationException(errorMessage);
54         }
55
56         if (!versionsValue.contains(appRootVersionValue)) {
57             throw new AAISchemaValidationException(errorMessage);
58         }
59
60         if (!versionsValue.contains(relatedLinkVersionValue)) {
61             throw new AAISchemaValidationException(errorMessage);
62         }
63
64         if (!versionsValue.contains(namespaceChangeVersionValue)) {
65             throw new AAISchemaValidationException(errorMessage);
66         }
67     }
68
69     public List<SchemaVersion> getVersions() {
70         return versionsValue;
71     }
72
73     public SchemaVersion getEdgeLabelVersion() {
74         return edgeLabelVersionValue;
75     }
76
77     public SchemaVersion getDefaultVersion() {
78         return defaultVersionValue;
79     }
80
81     public SchemaVersion getDepthVersion() {
82         return depthVersionValue;
83     }
84
85     public SchemaVersion getAppRootVersion() {
86         return appRootVersionValue;
87     }
88
89     public SchemaVersion getRelatedLinkVersion() {
90         return relatedLinkVersionValue;
91     }
92
93     public SchemaVersion getNamespaceChangeVersion() {
94         return namespaceChangeVersionValue;
95     }
96
97     public void setNamespaceChangeVersion(SchemaVersion namespaceChangeVersion) {
98         this.namespaceChangeVersionValue = namespaceChangeVersion;
99     }
100
101 }