X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=aai-schema-ingest%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Faai%2Fsetup%2FSchemaServiceVersions.java;h=f39042d44dad64b1ba8a1e0484e07804a98f23c8;hb=b7ad55e5d91527b259cb9189237b3f01915c31f8;hp=6594f23226a810db413c059f068675aa3673f663;hpb=5948f878fa0ee735e81f1cf648d5d3bdb35048cd;p=aai%2Faai-common.git diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaServiceVersions.java b/aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaServiceVersions.java index 6594f232..f39042d4 100644 --- a/aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaServiceVersions.java +++ b/aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaServiceVersions.java @@ -17,12 +17,22 @@ * limitations under the License. * ============LICENSE_END========================================================= */ + package org.onap.aai.setup; -import javax.annotation.PostConstruct; import java.util.List; import java.util.stream.Collectors; +import javax.annotation.PostConstruct; + +import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; +import org.springframework.context.annotation.PropertySource; +import org.springframework.stereotype.Component; + +@Component("schemaServiceVersions") +@ConditionalOnExpression("'${schema.translator.list}'.contains('schema-service')") +@PropertySource(value = "classpath:schema-ingest.properties", ignoreResourceNotFound = true) +@PropertySource(value = "file:${schema.ingest.file}", ignoreResourceNotFound = true) public class SchemaServiceVersions extends SchemaVersions { private List versions; private String edgeVersion; @@ -32,9 +42,17 @@ public class SchemaServiceVersions extends SchemaVersions { private String relatedLinkVersion; private String namespaceChangeVersion; + public List getVersionsAll() { + return versions; + } + + public void setVersions(List versions) { + this.versions = versions; + } @PostConstruct - public void initializeFromSchemaService() { + public void initializeFromSchemaService() throws ExceptionInInitializerError { + versionsValue = versions.stream().map(SchemaVersion::new).collect(Collectors.toList()); edgeLabelVersionValue = new SchemaVersion(edgeVersion); defaultVersionValue = new SchemaVersion(defaultVersion); @@ -42,7 +60,24 @@ public class SchemaServiceVersions extends SchemaVersions { appRootVersionValue = new SchemaVersion(appRootVersion); relatedLinkVersionValue = new SchemaVersion(relatedLinkVersion); namespaceChangeVersionValue = new SchemaVersion(namespaceChangeVersion); + this.validate(); } + /* + * TODO Change Method names + */ + public void initializeFromSchemaConfig(SchemaConfigVersions schemaConfigVersion) + throws ExceptionInInitializerError { + + versions = schemaConfigVersion.getApiVersions(); + appRootVersion = schemaConfigVersion.getAppRootStartVersion(); + defaultVersion = schemaConfigVersion.getDefaultApiVersion(); + depthVersion = schemaConfigVersion.getDepthStartVersion(); + edgeVersion = schemaConfigVersion.getEdgeLabelStartVersion(); + namespaceChangeVersion = schemaConfigVersion.getNamespaceChangeStartVersion(); + relatedLinkVersion = schemaConfigVersion.getRelatedLinkStartVersion(); + this.initializeFromSchemaService(); + } + }