aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/org/onap/schema
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org/onap/schema')
-rw-r--r--src/main/java/org/onap/schema/EdgeRulesLoader.java22
-rw-r--r--src/main/java/org/onap/schema/OxmModelLoader.java30
2 files changed, 32 insertions, 20 deletions
diff --git a/src/main/java/org/onap/schema/EdgeRulesLoader.java b/src/main/java/org/onap/schema/EdgeRulesLoader.java
index 2c139a7..47be12b 100644
--- a/src/main/java/org/onap/schema/EdgeRulesLoader.java
+++ b/src/main/java/org/onap/schema/EdgeRulesLoader.java
@@ -32,6 +32,7 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
+import javax.annotation.PostConstruct;
import javax.ws.rs.core.Response.Status;
import org.apache.commons.io.IOUtils;
@@ -39,8 +40,8 @@ import org.onap.aai.cl.eelf.LoggerFactory;
import org.onap.aai.edges.EdgeIngestor;
import org.onap.aai.edges.EdgeRule;
import org.onap.aai.edges.exceptions.EdgeRuleNotFoundException;
-import org.onap.aai.setup.ConfigTranslator;
import org.onap.aai.setup.SchemaVersion;
+import org.onap.aai.setup.Translator;
import org.onap.crud.exception.CrudException;
import org.onap.crud.logging.CrudServiceMsgs;
import org.springframework.beans.factory.annotation.Autowired;
@@ -48,8 +49,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import com.google.common.collect.Multimap;
public class EdgeRulesLoader {
-
- private static ConfigTranslator configTranslator;
+
+ private static Translator translator;
private static EdgeIngestor edgeIngestor;
private static EdgePropsConfiguration edgePropsConfiguration;
@@ -67,14 +68,19 @@ public class EdgeRulesLoader {
LoggerFactory.getInstance ().getLogger ( EdgeRulesLoader.class.getName () );
private EdgeRulesLoader () { }
-
+
@Autowired
- public EdgeRulesLoader(ConfigTranslator configTranslator, EdgeIngestor edgeIngestor, EdgePropsConfiguration edgePropsConfiguration) {
- EdgeRulesLoader.configTranslator = configTranslator;
+ public EdgeRulesLoader(Translator translator, EdgeIngestor edgeIngestor, EdgePropsConfiguration edgePropsConfiguration) {
+ EdgeRulesLoader.translator = translator;
EdgeRulesLoader.edgeIngestor = edgeIngestor;
EdgeRulesLoader.edgePropsConfiguration = edgePropsConfiguration;
}
+ @PostConstruct
+ public void init() throws CrudException {
+ EdgeRulesLoader.loadModels();
+ }
+
/**
* Finds all DB Edge Rules and Edge Properties files for all OXM models.
*
@@ -89,7 +95,7 @@ public class EdgeRulesLoader {
for (String version : OxmModelLoader.getLoadedOXMVersions()) {
try {
- SchemaVersion schemaVersion = configTranslator.getSchemaVersions().getVersions().stream()
+ SchemaVersion schemaVersion = translator.getSchemaVersions().getVersions().stream()
.filter(s -> s.toString().equalsIgnoreCase(version)).findAny().orElse(null);
loadModel(schemaVersion, edgeIngestor, propFiles);
} catch (IOException | EdgeRuleNotFoundException e) {
@@ -112,7 +118,7 @@ public class EdgeRulesLoader {
}
try {
- SchemaVersion schemaVersion = configTranslator.getSchemaVersions().getVersions().stream()
+ SchemaVersion schemaVersion = translator.getSchemaVersions().getVersions().stream()
.filter(s -> s.toString().equalsIgnoreCase(v)).findAny().orElse(null);
loadModel(schemaVersion, edgeIngestor, propFiles);
diff --git a/src/main/java/org/onap/schema/OxmModelLoader.java b/src/main/java/org/onap/schema/OxmModelLoader.java
index 12f8f09..fb41fc9 100644
--- a/src/main/java/org/onap/schema/OxmModelLoader.java
+++ b/src/main/java/org/onap/schema/OxmModelLoader.java
@@ -29,14 +29,15 @@ import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import javax.annotation.PostConstruct;
import javax.ws.rs.core.Response.Status;
import org.eclipse.persistence.dynamic.DynamicType;
import org.eclipse.persistence.internal.oxm.mappings.Descriptor;
import org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext;
import org.onap.aai.cl.eelf.LoggerFactory;
import org.onap.aai.nodes.NodeIngestor;
-import org.onap.aai.setup.ConfigTranslator;
import org.onap.aai.setup.SchemaVersion;
+import org.onap.aai.setup.Translator;
import org.onap.crud.exception.CrudException;
import org.onap.crud.logging.CrudServiceMsgs;
import org.springframework.beans.factory.annotation.Autowired;
@@ -45,9 +46,9 @@ import org.springframework.stereotype.Component;
@Component
public class OxmModelLoader {
- private static ConfigTranslator configTranslator;
+ private static Translator translator;
private static NodeIngestor nodeIngestor;
-
+
private static Map<String, DynamicJAXBContext> versionContextMap = new ConcurrentHashMap<>();
private static Map<String, HashMap<String, DynamicType>> xmlElementLookup = new ConcurrentHashMap<>();
@@ -57,13 +58,18 @@ public class OxmModelLoader {
LoggerFactory.getInstance().getLogger(OxmModelLoader.class.getName());
private OxmModelLoader() { }
-
+
@Autowired
- public OxmModelLoader(ConfigTranslator configTranslator, NodeIngestor nodeIngestor) {
- OxmModelLoader.configTranslator = configTranslator;
+ public OxmModelLoader(Translator translator, NodeIngestor nodeIngestor) {
+ OxmModelLoader.translator = translator;
OxmModelLoader.nodeIngestor = nodeIngestor;
}
+ @PostConstruct
+ public void init() throws CrudException {
+ OxmModelLoader.loadModels();
+ }
+
/**
* Finds all OXM model files
*
@@ -77,7 +83,7 @@ public class OxmModelLoader {
logger.debug("Loading OXM Models");
}
- for (SchemaVersion oxmVersion : configTranslator.getSchemaVersions().getVersions()) {
+ for (SchemaVersion oxmVersion : translator.getSchemaVersions().getVersions()) {
DynamicJAXBContext jaxbContext = nodeIngestor.getContextForVersion(oxmVersion);
if (jaxbContext != null) {
loadModel(oxmVersion.toString(), jaxbContext);
@@ -166,8 +172,8 @@ public class OxmModelLoader {
public static void setVersionContextMap(Map<String, DynamicJAXBContext> versionContextMap) {
OxmModelLoader.versionContextMap = versionContextMap;
}
-
-
+
+
public static void loadXmlLookupMap(String version, DynamicJAXBContext jaxbContext ) {
@SuppressWarnings("rawtypes")
@@ -183,8 +189,8 @@ public class OxmModelLoader {
}
xmlElementLookup.put(version, types);
}
-
-
+
+
public static DynamicType getDynamicTypeForVersion(String version, String type) throws CrudException {
DynamicType dynamicType;
@@ -220,7 +226,7 @@ public class OxmModelLoader {
return dynamicType;
}
-
+
/**
* Retrieves the list of all Loaded OXM versions.
*