X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Forg%2Fonap%2Fdmaap%2Fdbcapi%2Futil%2FGraph.java;fp=src%2Fmain%2Fjava%2Forg%2Fonap%2Fdmaap%2Fdbcapi%2Futil%2FGraph.java;h=a7700a11320bdad644dc0a439c7bec28db4c5c1e;hb=1611944a45491e2b8f00606b0aac2cdb0de8dde8;hp=f86569decce2a0515696e07541f429b9131d493a;hpb=f595e173fdb3921cb6c6855f5389871ee3c3ada3;p=dmaap%2Fdbcapi.git diff --git a/src/main/java/org/onap/dmaap/dbcapi/util/Graph.java b/src/main/java/org/onap/dmaap/dbcapi/util/Graph.java index f86569d..a7700a1 100644 --- a/src/main/java/org/onap/dmaap/dbcapi/util/Graph.java +++ b/src/main/java/org/onap/dmaap/dbcapi/util/Graph.java @@ -29,6 +29,8 @@ import java.util.Map; import org.onap.dmaap.dbcapi.database.DatabaseClass; import org.onap.dmaap.dbcapi.model.DcaeLocation; import org.onap.dmaap.dbcapi.model.MR_Client; +import org.onap.dmaap.dbcapi.model.MR_Cluster; +import org.onap.dmaap.dbcapi.service.MR_ClusterService; public class Graph { @@ -49,21 +51,38 @@ public class Graph { public Graph( List clients, boolean strict ) { if ( clients == null ) return; + initGraph( clients, strict, "" ); + return; + + } + public Graph( List clients, boolean strict, String group ) { + if ( clients == null ) + return; + initGraph( clients, strict, group ); + return; + } + + private void initGraph(List clients, boolean strict, String group ) { + MR_ClusterService clusters = new MR_ClusterService(); this.graph = new HashMap(); this.hasCentral = false; for( MR_Client client: clients ) { if ( ! strict || client.isStatusValid()) { String loc = client.getDcaeLocationName(); - for( String action : client.getAction() ){ - DcaeLocation dcaeLoc = locations.get(loc); + DcaeLocation dcaeLoc = locations.get(loc); + if ( dcaeLoc == null ) continue; + MR_Cluster c = clusters.getMr_ClusterByLoc(loc); + if ( group != null && ! group.isEmpty() && ! group.equals(c.getReplicationGroup())) continue; + + for( String action : client.getAction() ){ if ( ! action.equals("view") && dcaeLoc != null ) { - graph.put(loc, dcaeLoc.getDcaeLayer()); + String layer = dcaeLoc.getDcaeLayer(); + if ( layer != null && layer.contains(centralDcaeLayerName) ) { + this.hasCentral = true; + } + graph.put(loc, layer); } } - String layer = graph.get(loc); - if ( layer != null && layer.contains(centralDcaeLayerName) ) { - this.hasCentral = true; - } } } @@ -88,7 +107,7 @@ public class Graph { public Collection getKeys() { return graph.keySet(); } - public boolean isHasCentral() { + public boolean hasCentral() { return hasCentral; } public void setHasCentral(boolean hasCentral) { @@ -106,6 +125,9 @@ public class Graph { } return null; } + public boolean isEmpty() { + return graph.isEmpty(); + } }