diff options
author | Fiete Ostkamp <Fiete.Ostkamp@telekom.de> | 2022-11-10 20:45:04 +0000 |
---|---|---|
committer | Fiete Ostkamp <Fiete.Ostkamp@telekom.de> | 2022-11-11 14:18:51 +0000 |
commit | fa2e088e613c35fbfd4a19ac0e0cb88ce9ef7448 (patch) | |
tree | ba9a44b4774ebf2c1faa40f4e51500142b03cda2 /aai-schema-gen/src/main/java | |
parent | f8c058b2be718ab825f88e10e43ed59d5ca75de2 (diff) |
Update aai-schema-ingest dependency in the schema-service
- SchemaVersions object is being renamed to SchemaConfigVersions in aai-schema-ingest > 1.4.0
- add logback config to set log level to INFO, since a test run would otherwise generate 6GB worth of logs (when piped into a file)
Issue-ID: AAI-3592
Signed-off-by: Fiete Ostkamp <Fiete.Ostkamp@telekom.de>
Change-Id: I7e0a6f4577d2254d8f58956f4ad3ea39bd74dc8d
Diffstat (limited to 'aai-schema-gen/src/main/java')
10 files changed, 96 insertions, 81 deletions
diff --git a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/AutoGenerateHtml.java b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/AutoGenerateHtml.java index 9460175..f279aef 100644 --- a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/AutoGenerateHtml.java +++ b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/AutoGenerateHtml.java @@ -22,8 +22,6 @@ package org.onap.aai.schemagen; -import freemarker.template.TemplateException; - import java.io.File; import java.io.IOException; import java.util.Collections; @@ -31,13 +29,15 @@ import java.util.List; import java.util.ListIterator; import org.onap.aai.schemagen.swagger.GenerateSwagger; +import org.onap.aai.setup.SchemaConfigVersions; import org.onap.aai.setup.SchemaVersion; -import org.onap.aai.setup.SchemaVersions; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.BeansException; import org.springframework.context.annotation.AnnotationConfigApplicationContext; +import freemarker.template.TemplateException; + public class AutoGenerateHtml { private static Logger logger = LoggerFactory.getLogger(AutoGenerateHtml.class); @@ -53,31 +53,32 @@ public class AutoGenerateHtml { try (AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext( "org.onap.aai.setup", "org.onap.aai.schemagen")) { - SchemaVersions schemaVersions = ctx.getBean(SchemaVersions.class); - List<SchemaVersion> versionsToGen = schemaVersions.getVersions(); - Collections.sort(versionsToGen); - Collections.reverse(versionsToGen); - ListIterator<SchemaVersion> versionIterator = versionsToGen.listIterator(); - String schemaDir; - if (System.getProperty("user.dir") != null - && !System.getProperty("user.dir").contains(DEFAULT_RUN_DIR)) { - schemaDir = ALT_SCHEMA_DIR; - } else { - schemaDir = DEFAULT_SCHEMA_DIR; - } - String release = System.getProperty("aai.release", "onap"); - while (versionIterator.hasNext()) { - System.setProperty(AAI_GENERATE_VERSION, versionIterator.next().toString()); - String yamlFile = - schemaDir + "/src/main/resources/" + release + "/aai_swagger_yaml/aai_swagger_" - + System.getProperty(AAI_GENERATE_VERSION) + ".yaml"; - File swaggerYamlFile = new File(yamlFile); - if (swaggerYamlFile.exists()) { - GenerateSwagger.schemaVersions = schemaVersions; - GenerateSwagger.main(args); - } + SchemaConfigVersions schemaConfigVersions = ctx.getBean(SchemaConfigVersions.class); + + List<SchemaVersion> versionsToGen = schemaConfigVersions.getVersions(); + Collections.sort(versionsToGen); + Collections.reverse(versionsToGen); + ListIterator<SchemaVersion> versionIterator = versionsToGen.listIterator(); + String schemaDir; + if (System.getProperty("user.dir") != null + && !System.getProperty("user.dir").contains(DEFAULT_RUN_DIR)) { + schemaDir = ALT_SCHEMA_DIR; + } else { + schemaDir = DEFAULT_SCHEMA_DIR; + } + String release = System.getProperty("aai.release", "onap"); + while (versionIterator.hasNext()) { + System.setProperty(AAI_GENERATE_VERSION, versionIterator.next().toString()); + String yamlFile = + schemaDir + "/src/main/resources/" + release + "/aai_swagger_yaml/aai_swagger_" + + System.getProperty(AAI_GENERATE_VERSION) + ".yaml"; + File swaggerYamlFile = new File(yamlFile); + if (swaggerYamlFile.exists()) { + GenerateSwagger.schemaConfigVersions = schemaConfigVersions; + GenerateSwagger.main(args); } + } } catch (BeansException e) { logger.warn("Unable to initialize AnnotationConfigApplicationContext ", e); } diff --git a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/GenerateXsd.java b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/GenerateXsd.java index 2655e3c..f9e7b4d 100644 --- a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/GenerateXsd.java +++ b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/GenerateXsd.java @@ -37,8 +37,8 @@ import java.util.Map; import org.onap.aai.schemagen.genxsd.HTMLfromOXM; import org.onap.aai.schemagen.genxsd.NodesYAMLfromOXM; import org.onap.aai.schemagen.genxsd.YAMLfromOXM; +import org.onap.aai.setup.SchemaConfigVersions; import org.onap.aai.setup.SchemaVersion; -import org.onap.aai.setup.SchemaVersions; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.BeansException; @@ -109,11 +109,12 @@ public class GenerateXsd { return true; } - SchemaVersions schemaVersions = SpringContextAware.getBean(SchemaVersions.class); - if (schemaVersions == null) { + SchemaConfigVersions schemaConfigVersions = + SpringContextAware.getBean(SchemaConfigVersions.class); + if (schemaConfigVersions == null) { return false; } - for (SchemaVersion v : schemaVersions.getVersions()) { + for (SchemaVersion v : schemaConfigVersions.getVersions()) { if (v.toString().equals(versionToGen)) { return true; } @@ -156,7 +157,7 @@ public class GenerateXsd { try (AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext( "org.onap.aai.setup", "org.onap.aai.schemagen")) { - SchemaVersions schemaVersions = ctx.getBean(SchemaVersions.class); + SchemaConfigVersions schemaConfigVersions = ctx.getBean(SchemaConfigVersions.class); if (!fileTypeToGen.equals(GENERATE_TYPE_XSD) && !fileTypeToGen.equals(GENERATE_TYPE_YAML)) { @@ -173,7 +174,7 @@ public class GenerateXsd { System.err.println("Invalid version passed. " + versionToGen); System.exit(1); } else if ("ALL".equalsIgnoreCase(versionToGen)) { - versionsToGen = schemaVersions.getVersions(); + versionsToGen = schemaConfigVersions.getVersions(); Collections.sort(versionsToGen); Collections.reverse(versionsToGen); } else { diff --git a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/SchemaConfiguration.java b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/SchemaConfiguration.java index 4657862..12afcaf 100644 --- a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/SchemaConfiguration.java +++ b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/SchemaConfiguration.java @@ -22,12 +22,15 @@ package org.onap.aai.schemagen; +import java.util.HashSet; +import java.util.Set; + import org.onap.aai.edges.EdgeIngestor; import org.onap.aai.nodes.NodeIngestor; import org.onap.aai.setup.AAIConfigTranslator; -import org.onap.aai.setup.ConfigTranslator; +import org.onap.aai.setup.SchemaConfigVersions; import org.onap.aai.setup.SchemaLocationsBean; -import org.onap.aai.setup.SchemaVersions; +import org.onap.aai.setup.Translator; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -36,19 +39,23 @@ public class SchemaConfiguration { @Bean public EdgeIngestor edgeIngestor(SchemaLocationsBean schemaLocationsBean, - SchemaVersions schemaVersions) { - return new EdgeIngestor(configTranslator(schemaLocationsBean, schemaVersions), - schemaVersions); + SchemaConfigVersions schemaConfigVersions) { + return new EdgeIngestor(configTranslators(schemaLocationsBean, schemaConfigVersions)); } @Bean(name = "nodeIngestor") - public NodeIngestor nodeIngestor(ConfigTranslator configTranslator) { - return new NodeIngestor(configTranslator); + public NodeIngestor nodeIngestor(SchemaLocationsBean schemaLocationsBean, + SchemaConfigVersions schemaConfigVersions) { + return new NodeIngestor(configTranslators(schemaLocationsBean, schemaConfigVersions)); } @Bean(name = "configTranslator") - public ConfigTranslator configTranslator(SchemaLocationsBean schemaLocationsBean, - SchemaVersions schemaVersions) { - return new AAIConfigTranslator(schemaLocationsBean, schemaVersions); + public Set<Translator> configTranslators(SchemaLocationsBean schemaLocationsBean, + SchemaConfigVersions schemaConfigVersions) { + Set<Translator> translators = new HashSet<>(); + AAIConfigTranslator translator = + new AAIConfigTranslator(schemaLocationsBean, schemaConfigVersions); + translators.add(translator); + return translators; } } diff --git a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/SwaggerGenerationConfiguration.java b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/SwaggerGenerationConfiguration.java index 0370e8b..aa8b508 100644 --- a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/SwaggerGenerationConfiguration.java +++ b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/SwaggerGenerationConfiguration.java @@ -27,7 +27,7 @@ import org.onap.aai.nodes.NodeIngestor; import org.onap.aai.schemagen.genxsd.HTMLfromOXM; import org.onap.aai.schemagen.genxsd.NodesYAMLfromOXM; import org.onap.aai.schemagen.genxsd.YAMLfromOXM; -import org.onap.aai.setup.SchemaVersions; +import org.onap.aai.setup.SchemaConfigVersions; import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.context.annotation.Bean; @@ -45,23 +45,23 @@ public class SwaggerGenerationConfiguration { @Bean @Scope(scopeName = ConfigurableBeanFactory.SCOPE_PROTOTYPE) - public NodesYAMLfromOXM nodesYamlFromOXM(SchemaVersions schemaVersions, + public NodesYAMLfromOXM nodesYamlFromOXM(SchemaConfigVersions schemaConfigVersions, NodeIngestor nodeIngestor, EdgeIngestor edgeIngestor) { - return new NodesYAMLfromOXM(basePath, schemaVersions, nodeIngestor, edgeIngestor); + return new NodesYAMLfromOXM(basePath, schemaConfigVersions, nodeIngestor, edgeIngestor); } @Bean @Scope(scopeName = ConfigurableBeanFactory.SCOPE_PROTOTYPE) - public HTMLfromOXM htmlFromOXM(SchemaVersions schemaVersions, NodeIngestor nodeIngestor, - EdgeIngestor edgeIngestor) { - return new HTMLfromOXM(maxOccurs, schemaVersions, nodeIngestor, edgeIngestor); + public HTMLfromOXM htmlFromOXM(SchemaConfigVersions schemaConfigVersions, + NodeIngestor nodeIngestor, EdgeIngestor edgeIngestor) { + return new HTMLfromOXM(maxOccurs, schemaConfigVersions, nodeIngestor, edgeIngestor); } @Bean @Scope(scopeName = ConfigurableBeanFactory.SCOPE_PROTOTYPE) - public YAMLfromOXM yamlFromOXM(SchemaVersions schemaVersions, NodeIngestor nodeIngestor, - EdgeIngestor edgeIngestor) { - return new YAMLfromOXM(basePath, schemaVersions, nodeIngestor, edgeIngestor); + public YAMLfromOXM yamlFromOXM(SchemaConfigVersions schemaConfigVersions, + NodeIngestor nodeIngestor, EdgeIngestor edgeIngestor) { + return new YAMLfromOXM(basePath, schemaConfigVersions, nodeIngestor, edgeIngestor); } } diff --git a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/ConfigTranslatorForDocs.java b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/ConfigTranslatorForDocs.java index 87ba528..ca1c71e 100644 --- a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/ConfigTranslatorForDocs.java +++ b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/ConfigTranslatorForDocs.java @@ -22,17 +22,22 @@ package org.onap.aai.schemagen.genxsd; import java.io.File; import java.io.FilenameFilter; -import java.util.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.TreeMap; -import org.onap.aai.setup.ConfigTranslator; +import org.onap.aai.setup.AAIConfigTranslator; +import org.onap.aai.setup.SchemaConfigVersions; import org.onap.aai.setup.SchemaLocationsBean; import org.onap.aai.setup.SchemaVersion; -import org.onap.aai.setup.SchemaVersions; -public class ConfigTranslatorForDocs extends ConfigTranslator { +public class ConfigTranslatorForDocs extends AAIConfigTranslator { - public ConfigTranslatorForDocs(SchemaLocationsBean bean, SchemaVersions schemaVersions) { - super(bean, schemaVersions); + public ConfigTranslatorForDocs(SchemaLocationsBean bean, + SchemaConfigVersions schemaConfigVersions) { + super(bean, schemaConfigVersions); } @Override diff --git a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/HTMLfromOXM.java b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/HTMLfromOXM.java index c1cf5ac..5779e6d 100644 --- a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/HTMLfromOXM.java +++ b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/HTMLfromOXM.java @@ -32,8 +32,8 @@ import javax.xml.parsers.ParserConfigurationException; import org.onap.aai.edges.EdgeIngestor; import org.onap.aai.edges.exceptions.EdgeRuleNotFoundException; import org.onap.aai.nodes.NodeIngestor; +import org.onap.aai.setup.SchemaConfigVersions; import org.onap.aai.setup.SchemaVersion; -import org.onap.aai.setup.SchemaVersions; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.w3c.dom.Attr; @@ -48,9 +48,9 @@ public class HTMLfromOXM extends OxmFileProcessor { private String maxOccurs; - public HTMLfromOXM(String maxOccurs, SchemaVersions schemaVersions, NodeIngestor ni, + public HTMLfromOXM(String maxOccurs, SchemaConfigVersions schemaConfigVersions, NodeIngestor ni, EdgeIngestor ei) { - super(schemaVersions, ni, ei); + super(schemaConfigVersions, ni, ei); this.maxOccurs = maxOccurs; } @@ -76,7 +76,7 @@ public class HTMLfromOXM extends OxmFileProcessor { sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>") .append(LINE_SEPARATOR); String namespace = "org.onap"; - if (v.compareTo(getSchemaVersions().getNamespaceChangeVersion()) < 0) { + if (v.compareTo(getSchemaConfigVersions().getNamespaceChangeVersion()) < 0) { namespace = "org.openecomp"; } sb.append( diff --git a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/NodesYAMLfromOXM.java b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/NodesYAMLfromOXM.java index 77c76cb..92cc4a0 100644 --- a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/NodesYAMLfromOXM.java +++ b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/NodesYAMLfromOXM.java @@ -49,8 +49,8 @@ import org.onap.aai.edges.EdgeRule; import org.onap.aai.edges.EdgeRuleQuery; import org.onap.aai.edges.exceptions.EdgeRuleNotFoundException; import org.onap.aai.nodes.NodeIngestor; +import org.onap.aai.setup.SchemaConfigVersions; import org.onap.aai.setup.SchemaVersion; -import org.onap.aai.setup.SchemaVersions; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.w3c.dom.Element; @@ -71,9 +71,9 @@ public class NodesYAMLfromOXM extends OxmFileProcessor { private final String basePath; - public NodesYAMLfromOXM(String basePath, SchemaVersions schemaVersions, NodeIngestor ni, - EdgeIngestor ei) { - super(schemaVersions, ni, ei); + public NodesYAMLfromOXM(String basePath, SchemaConfigVersions schemaConfigVersions, + NodeIngestor ni, EdgeIngestor ei) { + super(schemaConfigVersions, ni, ei); this.basePath = basePath; } diff --git a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/OxmFileProcessor.java b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/OxmFileProcessor.java index 150bab7..684c2e8 100644 --- a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/OxmFileProcessor.java +++ b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/OxmFileProcessor.java @@ -40,8 +40,8 @@ import javax.xml.parsers.ParserConfigurationException; import org.onap.aai.edges.EdgeIngestor; import org.onap.aai.edges.exceptions.EdgeRuleNotFoundException; import org.onap.aai.nodes.NodeIngestor; +import org.onap.aai.setup.SchemaConfigVersions; import org.onap.aai.setup.SchemaVersion; -import org.onap.aai.setup.SchemaVersions; import org.w3c.dom.Attr; import org.w3c.dom.Document; import org.w3c.dom.Element; @@ -70,7 +70,7 @@ public abstract class OxmFileProcessor { protected SchemaVersion v; protected Document doc = null; protected String apiVersion = null; - protected SchemaVersions schemaVersions; + protected SchemaConfigVersions schemaConfigVersions; protected Map<String, Integer> combinedJavaTypes; protected String apiVersionFmt = null; protected List<String> topLevelPaths = new ArrayList<String>(); @@ -81,8 +81,9 @@ public abstract class OxmFileProcessor { EdgeIngestor ei; NodeIngestor ni; - public OxmFileProcessor(SchemaVersions schemaVersions, NodeIngestor ni, EdgeIngestor ei) { - this.schemaVersions = schemaVersions; + public OxmFileProcessor(SchemaConfigVersions schemaConfigVersions, NodeIngestor ni, + EdgeIngestor ei) { + this.schemaConfigVersions = schemaConfigVersions; this.ni = ni; this.ei = ei; } @@ -137,12 +138,12 @@ public abstract class OxmFileProcessor { this.ei = ei; } - public SchemaVersions getSchemaVersions() { - return schemaVersions; + public SchemaConfigVersions getSchemaConfigVersions() { + return schemaConfigVersions; } - public void setSchemaVersions(SchemaVersions schemaVersions) { - this.schemaVersions = schemaVersions; + public void setSchemaConfigVersions(SchemaConfigVersions schemaConfigVersions) { + this.schemaConfigVersions = schemaConfigVersions; } protected void getTopLevelPaths(XSDElement elem) { diff --git a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/YAMLfromOXM.java b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/YAMLfromOXM.java index 3b8fa4d..0ded250 100644 --- a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/YAMLfromOXM.java +++ b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/YAMLfromOXM.java @@ -49,8 +49,8 @@ import org.onap.aai.edges.EdgeRule; import org.onap.aai.edges.EdgeRuleQuery; import org.onap.aai.edges.exceptions.EdgeRuleNotFoundException; import org.onap.aai.nodes.NodeIngestor; +import org.onap.aai.setup.SchemaConfigVersions; import org.onap.aai.setup.SchemaVersion; -import org.onap.aai.setup.SchemaVersions; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.w3c.dom.Element; @@ -72,9 +72,9 @@ public class YAMLfromOXM extends OxmFileProcessor { private String basePath; - public YAMLfromOXM(String basePath, SchemaVersions schemaVersions, NodeIngestor ni, + public YAMLfromOXM(String basePath, SchemaConfigVersions schemaConfigVersions, NodeIngestor ni, EdgeIngestor ei) { - super(schemaVersions, ni, ei); + super(schemaConfigVersions, ni, ei); this.basePath = basePath; } diff --git a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/swagger/GenerateSwagger.java b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/swagger/GenerateSwagger.java index b467e33..c050063 100644 --- a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/swagger/GenerateSwagger.java +++ b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/swagger/GenerateSwagger.java @@ -45,7 +45,7 @@ import java.util.Set; import java.util.TreeMap; import java.util.stream.Collectors; -import org.onap.aai.setup.SchemaVersions; +import org.onap.aai.setup.SchemaConfigVersions; public class GenerateSwagger { @@ -58,16 +58,16 @@ public class GenerateSwagger { // used to check to see if program is run from aai-schema-gen public static final String DEFAULT_RUN_DIR = "aai-schema-gen"; - public static SchemaVersions schemaVersions; + public static SchemaConfigVersions schemaConfigVersions; - public SchemaVersions getSchemaVersions() { - return schemaVersions; + public SchemaConfigVersions getSchemaConfigVersions() { + return schemaConfigVersions; } public static void main(String[] args) throws IOException, TemplateException { // SchemaVersions schemaVersions = SpringContextAware.getBean(SchemaVersions.class); - String CURRENT_VERSION = schemaVersions.getDefaultVersion().toString(); + String CURRENT_VERSION = schemaConfigVersions.getDefaultVersion().toString(); String schemaDir = System.getProperty("aai.schema.dir"); String versionToGenerate = System.getProperty("aai.generate.version"); String wikiLink = System.getProperty("aai.wiki.link"); |