AAI-1523 Batch reformat aai-schema-ingest
[aai/aai-common.git] / aai-schema-ingest / src / main / java / org / onap / aai / setup / SchemaConfigVersions.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 import java.util.stream.Collectors;
25
26 import javax.annotation.PostConstruct;
27
28 import org.springframework.beans.factory.annotation.Value;
29 import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
30 import org.springframework.context.annotation.PropertySource;
31 import org.springframework.stereotype.Component;
32
33 @Component("schemaConfigVersions")
34 @ConditionalOnExpression("'${schema.translator.list:config}'.contains('config') || '${schema.service.versions.override:false}'.equals('true')")
35 @PropertySource(value = "classpath:schema-ingest.properties", ignoreResourceNotFound = true)
36 @PropertySource(value = "file:${schema.ingest.file}", ignoreResourceNotFound = true)
37 public class SchemaConfigVersions extends SchemaVersions {
38
39     @Value("#{'${schema.version.list:''}'.split(',')}")
40     private List<String> apiVersions;
41     @Value("${schema.version.api.default}")
42     private String defaultApiVersion;
43     @Value("${schema.version.edge.label.start:''}")
44     private String edgeLabelStartVersion;
45     @Value("${schema.version.depth.start:''}")
46     private String depthStartVersion;
47     @Value("${schema.version.app.root.start:''}")
48     private String appRootStartVersion;
49     @Value("${schema.version.related.link.start:''}")
50     private String relatedLinkStartVersion;
51     @Value("${schema.version.namespace.change.start:''}")
52     protected String namespaceChangeStartVersion;
53
54     public List<String> getApiVersions() {
55         return apiVersions;
56     }
57
58     public String getDefaultApiVersion() {
59         return defaultApiVersion;
60     }
61
62     public String getEdgeLabelStartVersion() {
63         return edgeLabelStartVersion;
64     }
65
66     public String getDepthStartVersion() {
67         return depthStartVersion;
68     }
69
70     public String getAppRootStartVersion() {
71         return appRootStartVersion;
72     }
73
74     public String getRelatedLinkStartVersion() {
75         return relatedLinkStartVersion;
76     }
77
78     public String getNamespaceChangeStartVersion() {
79         return namespaceChangeStartVersion;
80     }
81
82     @PostConstruct
83     public void initialize() {
84         versionsValue = apiVersions.stream().map(SchemaVersion::new).collect(Collectors.toList());
85         edgeLabelVersionValue = new SchemaVersion(edgeLabelStartVersion);
86         defaultVersionValue = new SchemaVersion(defaultApiVersion);
87         depthVersionValue = new SchemaVersion(depthStartVersion);
88         appRootVersionValue = new SchemaVersion(appRootStartVersion);
89         relatedLinkVersionValue = new SchemaVersion(relatedLinkStartVersion);
90         namespaceChangeVersionValue = new SchemaVersion(namespaceChangeStartVersion);
91         this.validate();
92     }
93
94 }