diff options
author | Justyna Czestochowska <justyna.czestochowska@nokia.com> | 2018-07-31 12:40:32 +0200 |
---|---|---|
committer | jczestochowska <justyna.czestochowska@nokia.com> | 2018-07-31 12:40:32 +0200 |
commit | b4534bd90b0298e88d6bccd8b6d4dd5313c8a057 (patch) | |
tree | a0dd3fddf3a24e05323237fb58a1b8348d7be961 /aai-core/src | |
parent | f71dfcd688d0d912ce445cb2965d9c157a49c533 (diff) |
Removing minor sonar issues
replaced usage of print by logger,
removed duplication,
removed commented out code
Change-Id: Ib8b8cf9e6769ecc235ec080f26526cf7d790513c
Issue-ID: AAI-1434
Signed-off-by: jczestochowska <justyna.czestochowska@nokia.com>
Diffstat (limited to 'aai-core/src')
-rw-r--r-- | aai-core/src/main/java/org/onap/aai/db/schema/ManageJanusGraphSchema.java | 79 |
1 files changed, 13 insertions, 66 deletions
diff --git a/aai-core/src/main/java/org/onap/aai/db/schema/ManageJanusGraphSchema.java b/aai-core/src/main/java/org/onap/aai/db/schema/ManageJanusGraphSchema.java index bf2d4107..c4061b3f 100644 --- a/aai-core/src/main/java/org/onap/aai/db/schema/ManageJanusGraphSchema.java +++ b/aai-core/src/main/java/org/onap/aai/db/schema/ManageJanusGraphSchema.java @@ -46,7 +46,7 @@ public class ManageJanusGraphSchema { private List<EdgeProperty> aaiEdgeProperties; private Auditor oxmInfo = null; private Auditor graphInfo = null; - + /** * Instantiates a new manage JanusGraph schema. * @@ -86,28 +86,9 @@ public class ManageJanusGraphSchema { * Creates the property keys. */ private void createPropertyKeys() { - - + for (DBProperty prop : aaiProperties) { - - if (graphMgmt.containsPropertyKey(prop.getName())) { - PropertyKey key = graphMgmt.getPropertyKey(prop.getName()); - boolean isChanged = false; - if (!prop.getCardinality().equals(key.cardinality())) { - isChanged = true; - } - if (!prop.getTypeClass().equals(key.dataType())) { - isChanged = true; - } - if (isChanged) { - //must modify! - this.replaceProperty(prop); - } - } else { - //create a new property key - System.out.println("Key: " + prop.getName() + " not found - adding"); - graphMgmt.makePropertyKey(prop.getName()).dataType(prop.getTypeClass()).cardinality(prop.getCardinality()).make(); - } + this.createProperty(graphMgmt, prop); } } @@ -126,8 +107,8 @@ public class ManageJanusGraphSchema { keyList.add(graphMgmt.getPropertyKey(prop.getName())); } if (graphMgmt.containsGraphIndex(index.getName())) { - JanusGraphIndex JanusGraphIndex = graphMgmt.getGraphIndex(index.getName()); - PropertyKey[] dbKeys = JanusGraphIndex.getFieldKeys(); + JanusGraphIndex janusGraphIndex = graphMgmt.getGraphIndex(index.getName()); + PropertyKey[] dbKeys = janusGraphIndex.getFieldKeys(); if (dbKeys.length != keyList.size()) { isChanged = true; } else { @@ -143,7 +124,7 @@ public class ManageJanusGraphSchema { } else { isNew = true; } - if (keyList.size() > 0) { + if (!keyList.isEmpty()) { this.createIndex(graphMgmt, index.getName(), keyList, index.isUnique(), isNew, isChanged); } } @@ -194,7 +175,7 @@ public class ManageJanusGraphSchema { } } else { //create a new property key - System.out.println("Key: " + prop.getName() + " not found - adding"); + logger.info("Key: " + prop.getName() + " not found - adding"); mgmt.makePropertyKey(prop.getName()).dataType(prop.getTypeClass()).cardinality(prop.getCardinality()).make(); } } @@ -210,15 +191,7 @@ public class ManageJanusGraphSchema { * @param isChanged the is changed */ private void createIndex(JanusGraphManagement mgmt, String indexName, List<PropertyKey> keys, boolean isUnique, boolean isNew, boolean isChanged) { - - /*if (isChanged) { - System.out.println("Changing index: " + indexName); - JanusGraphIndex oldIndex = mgmt.getGraphIndex(indexName); - mgmt.updateIndex(oldIndex, SchemaAction.DISABLE_INDEX); - mgmt.commit(); - //cannot remove indexes - //graphMgmt.updateIndex(oldIndex, SchemaAction.REMOVE_INDEX); - }*/ + if (isNew || isChanged) { if (isNew) { @@ -230,31 +203,8 @@ public class ManageJanusGraphSchema { builder.unique(); } builder.buildCompositeIndex(); - System.out.println("Built index for " + indexName + " with keys: " + keys); - - //mgmt.commit(); - } - - //mgmt = graph.asAdmin().getManagementSystem(); - //mgmt.updateIndex(mgmt.getGraphIndex(indexName), SchemaAction.REGISTER_INDEX); - //mgmt.commit(); - - try { - //waitForCompletion(indexName); - //JanusGraphIndexRepair.hbaseRepair(AAIConstants.AAI_CONFIG_FILENAME, indexName, ""); - } catch (Exception e) { - graph.tx().rollback(); - graph.close(); - logger.error(e.getMessage(),e); + logger.info("Built index for " + indexName + " with keys: " + keys); } - - //mgmt = graph.asAdmin().getManagementSystem(); - //mgmt.updateIndex(mgmt.getGraphIndex(indexName), SchemaAction.REINDEX); - - //mgmt.updateIndex(mgmt.getGraphIndex(indexName), SchemaAction.ENABLE_INDEX); - - //mgmt.commit(); - } } @@ -279,19 +229,16 @@ public class ManageJanusGraphSchema { } mgmt.rollback(); } - System.out.println("Index REGISTERED in " + (System.currentTimeMillis() - before) + " ms"); + logger.info("Index REGISTERED in " + (System.currentTimeMillis() - before) + " ms"); } - + /** * Replace property. * * @param key the key */ private void replaceProperty(DBProperty key) { - - - - + } /** @@ -310,7 +257,7 @@ public class ManageJanusGraphSchema { keys.add(mgmt.getPropertyKey(prop.getName())); } if (mgmt.containsGraphIndex(index.getName())) { - System.out.println("index already exists"); + logger.info("index already exists"); isNew = false; isChanged = true; } else { |