fix waitforyellow in dbclient
[ccsdk/features.git] / sdnr / wt / data-provider / setup / src / main / java / org / onap / ccsdk / features / sdnr / wt / dataprovider / setup / ReleaseInformation.java
index f45d5e7..ccae07c 100644 (file)
@@ -37,13 +37,17 @@ import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.guilin.GuilinReleaseIn
 
 public abstract class ReleaseInformation {
 
+       // variables
        private final Release release;
        private final Map<ComponentName, DatabaseInfo> dbMap;
+       // end of variables
 
+       // constructors
        public ReleaseInformation(Release r, Map<ComponentName, DatabaseInfo> dbMap) {
                this.release = r;
                this.dbMap = dbMap;
        }
+       // end of constructors
 
        /**
         * get database alias for component
@@ -51,28 +55,37 @@ public abstract class ReleaseInformation {
         * @return alias or null if not exists
         */
        public String getAlias(ComponentName name) {
-               return this.getAlias(name,"");
+               return this.getAlias(name, "");
        }
-       public String getAlias(ComponentName name,String prefix) {
-               return dbMap.get(name) == null ? null : prefix+dbMap.get(name).alias;
+
+       public String getAlias(ComponentName name, String prefix) {
+               return dbMap.get(name) == null ? null : prefix + dbMap.get(name).alias;
        }
 
        /**
-        * @param c
-        * @return
+        * get index name for component
+        * @param comp
+        * @return null if component does not exists in this release, otherwise index name
         */
-       public String getIndex(ComponentName name) {
-               return this.getIndex(name,"");
+       public String getIndex(ComponentName comp) {
+               return this.getIndex(comp, "");
        }
-       public String getIndex(ComponentName name,String prefix) {
-               return dbMap.get(name) == null ? null : (prefix+dbMap.get(name).getIndex(this.release.getDBSuffix())); 
+
+       /**
+        * get index name for component with prefix 
+        * @param comp
+        * @param prefix
+        * @return null if component does not exists in this release, otherwise index name
+        */
+       public String getIndex(ComponentName comp, String prefix) {
+               return dbMap.get(comp) == null ? null : (prefix + dbMap.get(comp).getIndex(this.release.getDBSuffix()));
        }
 
        /**
-                * get database datatype (doctype) for component
-                * @param name
-                * @return datatype or null if not exists
-                */
+        * get database datatype (doctype) for component
+        * @param name
+        * @return datatype or null if not exists
+        */
        public String getDataType(ComponentName name) {
                return dbMap.get(name) == null ? null : dbMap.get(name).doctype;
        }
@@ -80,20 +93,22 @@ public abstract class ReleaseInformation {
        public String getDatabaseMapping(ComponentName name) {
                return dbMap.get(name) == null ? null : dbMap.get(name).getMapping();
        }
-               /**
+
+       /**
         * get database doctype definition for component
         * @param name
         * @return mappings or null if not exists
         */
-       public String getDatabaseMapping(ComponentName name,boolean useStrict) {
+       public String getDatabaseMapping(ComponentName name, boolean useStrict) {
                return dbMap.get(name) == null ? null : dbMap.get(name).getMapping(useStrict);
        }
+
        /**
         * get database settings definition for component
         * @param name
         * @return settings or null if not exists
         */
-       public String getDatabaseSettings(ComponentName name,int shards,int replicas) {
+       public String getDatabaseSettings(ComponentName name, int shards, int replicas) {
                return dbMap.get(name) == null ? null : dbMap.get(name).getSettings(shards, replicas);
        }
 
@@ -104,7 +119,7 @@ public abstract class ReleaseInformation {
         * @return
         */
        public SearchHitConverter getConverter(Release dst, ComponentName comp) {
-               if(dst==this.release && this.getComponents().contains(comp)) {
+               if (dst == this.release && this.getComponents().contains(comp)) {
                        return new KeepDataSearchHitConverter(comp);
                }
                return null;
@@ -135,7 +150,7 @@ public abstract class ReleaseInformation {
         * @return
         */
        public boolean hasOwnDbIndex(ComponentName component) {
-               return this.getDatabaseMapping(component)!=null;
+               return this.getDatabaseMapping(component) != null;
        }
 
        /**
@@ -143,18 +158,18 @@ public abstract class ReleaseInformation {
         * @return true if components of this release are covered by the given indices
         */
        protected boolean containsIndices(IndicesEntryList indices) {
-               
-               if(this.dbMap.size()<=0) {
+
+               if (this.dbMap.size() <= 0) {
                        return false;
                }
-               for(DatabaseInfo entry:this.dbMap.values()) {
+               for (DatabaseInfo entry : this.dbMap.values()) {
                        String dbIndexName = entry.getIndex(this.release.getDBSuffix());
-                       if(indices.findByIndex(dbIndexName)==null) {
+                       if (indices.findByIndex(dbIndexName) == null) {
                                return false;
                        }
                }
                return true;
-               
+
        }
 
        /**
@@ -163,13 +178,11 @@ public abstract class ReleaseInformation {
         */
        protected abstract boolean runPreInitCommands(HtDatabaseClient dbClient);
 
-
        /**
         * 
         * @param dbClient
         * @return if succeeded or not
         */
        protected abstract boolean runPostInitCommands(HtDatabaseClient dbClient);
-       
 
 }