aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/org
diff options
context:
space:
mode:
authorIgor Dysko <igor1.dysko@orange.com>2021-06-15 17:13:36 +0200
committerIgor Dysko <igor1.dysko@orange.com>2021-06-15 17:13:36 +0200
commit3646ed953013eab56b29abdc57a9bf29a8a8753c (patch)
treeb533597d0789f26fda7984fc1f1b739488458dc9 /src/main/java/org
parent7966c096b1857006ce93a8304fae82826d82f203 (diff)
Make ModelExporter thread safe
Refactoring of ModelExporter class. Issue-ID: AAI-3349 Signed-off-by: Igor Dysko <igor1.dysko@orange.com> Change-Id: Iaec66bafc5555630ff1e8a055624f28e66329349
Diffstat (limited to 'src/main/java/org')
-rw-r--r--src/main/java/org/onap/aai/graphgraph/ModelExporter.java14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/main/java/org/onap/aai/graphgraph/ModelExporter.java b/src/main/java/org/onap/aai/graphgraph/ModelExporter.java
index 1c433fe..24d0829 100644
--- a/src/main/java/org/onap/aai/graphgraph/ModelExporter.java
+++ b/src/main/java/org/onap/aai/graphgraph/ModelExporter.java
@@ -41,6 +41,8 @@ import org.onap.aai.introspection.Introspector;
import org.onap.aai.schema.enums.ObjectMetadata;
import org.onap.aai.schema.enums.PropertyMetadata;
import org.onap.aai.setup.SchemaVersion;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -61,7 +63,8 @@ public class ModelExporter {
private static final String VELOCITY_TEMPLATE_FILENAME = "model_export.vm";
private static final boolean OXM_ENABLED = false;
private static final String camelCaseRegex = "(?=[A-Z][a-z])";
- private Map<String, Introspector> allEntities;
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(ModelExporter.class);
@Autowired
private MoxyLoaderRepository moxyLoaderRepository;
@@ -72,13 +75,14 @@ public class ModelExporter {
private Multimap<String, EdgeRule> getEdgeRules(String schemaVersion) {
try {
Multimap<String, EdgeRule> allRules = edgeIngestor.getAllRules(new SchemaVersion(schemaVersion));
- allEntities = moxyLoaderRepository.getMoxyLoaders().get(schemaVersion).getAllObjects();
if (OXM_ENABLED) {
+ Map<String, Introspector> allEntities = moxyLoaderRepository.getMoxyLoaders().get(schemaVersion).getAllObjects();
addOxmRelationships(allRules, allEntities);
}
return allRules;
+
} catch (EdgeRuleNotFoundException e) {
- e.printStackTrace();
+ LOGGER.error("Getting edge rules failed", e);
}
return null;
@@ -132,7 +136,7 @@ public class ModelExporter {
fw.write(result);
fw.close();
} catch (IOException e) {
- e.printStackTrace();
+ LOGGER.error("Writing exported model failed", e);
}
}
@@ -170,7 +174,7 @@ public class ModelExporter {
.filter(a -> a.getFromEntityId().equals(e.getId())).collect(
Collectors.toList());
updateNeighbour(entityList, associations);
- String description = allEntities.get(e.getName()).getMetadata(ObjectMetadata.DESCRIPTION);
+ String description = allObjects.get(e.getName()).getMetadata(ObjectMetadata.DESCRIPTION);
e.setDescription(StringUtil.isBlank(description) ? "no description is available" : description);
});