2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
20 package org.onap.aai.setup;
22 import org.springframework.beans.factory.annotation.Value;
23 import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
24 import org.springframework.context.annotation.PropertySource;
25 import org.springframework.stereotype.Component;
27 import javax.annotation.PostConstruct;
28 import java.util.List;
29 import java.util.stream.Collectors;
31 @Component("schemaConfigVersions")
32 @ConditionalOnExpression("'${schema.translator.list:config}'.contains('config') || '${schema.service.versions.override:false}'.equals('true')")
33 @PropertySource(value = "classpath:schema-ingest.properties", ignoreResourceNotFound = true)
34 @PropertySource(value = "file:${schema.ingest.file}", ignoreResourceNotFound = true)
35 public class SchemaConfigVersions extends SchemaVersions {
37 @Value("#{'${schema.version.list:''}'.split(',')}")
38 private List<String> apiVersions;
39 @Value("${schema.version.api.default}")
40 private String defaultApiVersion;
41 @Value("${schema.version.edge.label.start:''}")
42 private String edgeLabelStartVersion;
43 @Value("${schema.version.depth.start:''}")
44 private String depthStartVersion;
45 @Value("${schema.version.app.root.start:''}")
46 private String appRootStartVersion;
47 @Value("${schema.version.related.link.start:''}")
48 private String relatedLinkStartVersion;
49 @Value("${schema.version.namespace.change.start:''}")
50 protected String namespaceChangeStartVersion;
52 public List<String> getApiVersions() {
56 public String getDefaultApiVersion() {
57 return defaultApiVersion;
60 public String getEdgeLabelStartVersion() {
61 return edgeLabelStartVersion;
64 public String getDepthStartVersion() {
65 return depthStartVersion;
68 public String getAppRootStartVersion() {
69 return appRootStartVersion;
72 public String getRelatedLinkStartVersion() {
73 return relatedLinkStartVersion;
76 public String getNamespaceChangeStartVersion() {
77 return namespaceChangeStartVersion;
81 public void initialize() {
82 versionsValue = apiVersions.stream().map(SchemaVersion::new).collect(Collectors.toList());
83 edgeLabelVersionValue = new SchemaVersion(edgeLabelStartVersion);
84 defaultVersionValue = new SchemaVersion(defaultApiVersion);
85 depthVersionValue = new SchemaVersion(depthStartVersion);
86 appRootVersionValue = new SchemaVersion(appRootStartVersion);
87 relatedLinkVersionValue = new SchemaVersion(relatedLinkStartVersion);
88 namespaceChangeVersionValue = new SchemaVersion(namespaceChangeStartVersion);