Replace all tab characters in java files with two spaces to remove linter warning
[aai/schema-service.git] / aai-queries / src / main / java / org / onap / aai / queries / GetCustomQueryConfig.java
index ed4ff99..c726c76 100644 (file)
@@ -28,121 +28,121 @@ import java.util.List;
 
 public class GetCustomQueryConfig {
 
-       private JsonArray storedQueries = null;
-       private CustomQueryConfig customQueryConfig;
-
-
-       private final static String QUERY_CONFIG = "query";
-       private final static String REQUIRED_CONFIG = "required-properties";
-       private final static String OPTIONAL_CONFIG = "optional-properties";
-       private final static String STORED_QUERIES_CONFIG = "stored-queries";
-       private final static String STORED_QUERY_CONFIG = "stored-query";
-
-//     public static final String AAI_HOME_ETC_QUERY_JSON = AAIConstants.AAI_HOME_ETC + "query" + AAIConstants.AAI_FILESEP + "stored-queries.json";
-
-       public GetCustomQueryConfig(String customQueryJson ) {
-               init(customQueryJson);
-       }
-
-       private void init( String customQueryJson) {
-               JsonParser parser = new JsonParser();
-               JsonObject queriesObject = parser.parse(customQueryJson).getAsJsonObject();
-               if (queriesObject.has(STORED_QUERIES_CONFIG)) {
-
-                       storedQueries = queriesObject.getAsJsonArray(STORED_QUERIES_CONFIG);
-               }
-       }
-
-       private List<String> toStringList(JsonArray array) {
-          Gson converter = new Gson();
-          Type listType = new TypeToken<List<String>>() {}.getType();
-          return converter.fromJson(array, listType);
-       }
-
-       private List<String> getPropertyList(JsonObject configObject, String config ) {
-               JsonElement subqueryConfig;
-               JsonArray props;
-
-               if ( configObject.has(config)) {
-                       subqueryConfig = configObject.get(config);
-                       if ( subqueryConfig != null && !subqueryConfig.isJsonNull() ) {
-                               props = subqueryConfig.getAsJsonArray();
-                               if ( props != null ) {
-                                       return toStringList(props);
-                               }
-                       }
-               }
-               return toStringList(null);
-       }
-
-       private String getPropertyString(JsonObject configObject, String config) {
-               JsonElement subqueryConfig;
-
-               if ( configObject.has(config)) {
-                       subqueryConfig = configObject.get(config);
-                       if ( subqueryConfig != null && !subqueryConfig.isJsonNull() ) {
-                               return subqueryConfig.getAsString();
-                       }
-               }
-               return null;
-       }
-
-       private void getStoredQueryBlock( JsonObject configObject, String config ) {
-               if ( !configObject.has(config)) {
-                       customQueryConfig.setQueryRequiredProperties( new ArrayList<String>() );
-                       customQueryConfig.setQueryOptionalProperties( new ArrayList<String>()  );
-                       return;
-               }
-
-               JsonElement queryConfig;
-               JsonObject subObject;
-               String multipleStartNodes;
-               List<String> propertyList;
-
-               queryConfig = configObject.get(config);
-               subObject = queryConfig.getAsJsonObject();
-               propertyList = getPropertyList(subObject, REQUIRED_CONFIG);
-               if ( propertyList == null ) {
-                       propertyList = new ArrayList<String>();
-               }
-               customQueryConfig.setQueryRequiredProperties( propertyList );
-               propertyList = getPropertyList(subObject, OPTIONAL_CONFIG);
-               if ( propertyList == null ) {
-                       propertyList = new ArrayList<String>();
-               }
-               customQueryConfig.setQueryOptionalProperties( propertyList );
-
-       }
-
-
-       public CustomQueryConfig getStoredQuery(String queryName ) {
-
-               customQueryConfig = null;
-               JsonObject configObject;
-               JsonElement query;
-               JsonElement queryConfig;
-               String queryString;
-
-               for (JsonElement storedQuery : storedQueries) {
-                       if (storedQuery.isJsonObject()) {
-                               JsonObject queryObject = storedQuery.getAsJsonObject();
-                               query = queryObject.get(queryName);
-                               if ( query != null ) {
-                                       customQueryConfig = new CustomQueryConfig();
-                                       configObject = query.getAsJsonObject();
-                                       getStoredQueryBlock(configObject, QUERY_CONFIG);
-                                       if ( configObject.has(STORED_QUERY_CONFIG)) {
-                                               queryConfig = configObject.get(STORED_QUERY_CONFIG);
-                                               customQueryConfig.setQuery(queryConfig.getAsString());
-                                       }
-                                       break;
-                               }
-                       }
-               }
-
-               return customQueryConfig;
-
-       }
+  private JsonArray storedQueries = null;
+  private CustomQueryConfig customQueryConfig;
+
+
+  private final static String QUERY_CONFIG = "query";
+  private final static String REQUIRED_CONFIG = "required-properties";
+  private final static String OPTIONAL_CONFIG = "optional-properties";
+  private final static String STORED_QUERIES_CONFIG = "stored-queries";
+  private final static String STORED_QUERY_CONFIG = "stored-query";
+
+//  public static final String AAI_HOME_ETC_QUERY_JSON = AAIConstants.AAI_HOME_ETC + "query" + AAIConstants.AAI_FILESEP + "stored-queries.json";
+
+  public GetCustomQueryConfig(String customQueryJson ) {
+    init(customQueryJson);
+  }
+
+  private void init( String customQueryJson) {
+    JsonParser parser = new JsonParser();
+    JsonObject queriesObject = parser.parse(customQueryJson).getAsJsonObject();
+    if (queriesObject.has(STORED_QUERIES_CONFIG)) {
+
+      storedQueries = queriesObject.getAsJsonArray(STORED_QUERIES_CONFIG);
+    }
+  }
+
+  private List<String> toStringList(JsonArray array) {
+     Gson converter = new Gson();
+     Type listType = new TypeToken<List<String>>() {}.getType();
+     return converter.fromJson(array, listType);
+  }
+
+  private List<String> getPropertyList(JsonObject configObject, String config ) {
+    JsonElement subqueryConfig;
+    JsonArray props;
+
+    if ( configObject.has(config)) {
+      subqueryConfig = configObject.get(config);
+      if ( subqueryConfig != null && !subqueryConfig.isJsonNull() ) {
+        props = subqueryConfig.getAsJsonArray();
+        if ( props != null ) {
+          return toStringList(props);
+        }
+      }
+    }
+    return toStringList(null);
+  }
+
+  private String getPropertyString(JsonObject configObject, String config) {
+    JsonElement subqueryConfig;
+
+    if ( configObject.has(config)) {
+      subqueryConfig = configObject.get(config);
+      if ( subqueryConfig != null && !subqueryConfig.isJsonNull() ) {
+        return subqueryConfig.getAsString();
+      }
+    }
+    return null;
+  }
+
+  private void getStoredQueryBlock( JsonObject configObject, String config ) {
+    if ( !configObject.has(config)) {
+      customQueryConfig.setQueryRequiredProperties( new ArrayList<String>() );
+      customQueryConfig.setQueryOptionalProperties( new ArrayList<String>()  );
+      return;
+    }
+
+    JsonElement queryConfig;
+    JsonObject subObject;
+    String multipleStartNodes;
+    List<String> propertyList;
+
+    queryConfig = configObject.get(config);
+    subObject = queryConfig.getAsJsonObject();
+    propertyList = getPropertyList(subObject, REQUIRED_CONFIG);
+    if ( propertyList == null ) {
+      propertyList = new ArrayList<String>();
+    }
+    customQueryConfig.setQueryRequiredProperties( propertyList );
+    propertyList = getPropertyList(subObject, OPTIONAL_CONFIG);
+    if ( propertyList == null ) {
+      propertyList = new ArrayList<String>();
+    }
+    customQueryConfig.setQueryOptionalProperties( propertyList );
+
+  }
+
+
+  public CustomQueryConfig getStoredQuery(String queryName ) {
+
+    customQueryConfig = null;
+    JsonObject configObject;
+    JsonElement query;
+    JsonElement queryConfig;
+    String queryString;
+
+    for (JsonElement storedQuery : storedQueries) {
+      if (storedQuery.isJsonObject()) {
+        JsonObject queryObject = storedQuery.getAsJsonObject();
+        query = queryObject.get(queryName);
+        if ( query != null ) {
+          customQueryConfig = new CustomQueryConfig();
+          configObject = query.getAsJsonObject();
+          getStoredQueryBlock(configObject, QUERY_CONFIG);
+          if ( configObject.has(STORED_QUERY_CONFIG)) {
+            queryConfig = configObject.get(STORED_QUERY_CONFIG);
+            customQueryConfig.setQuery(queryConfig.getAsString());
+          }
+          break;
+        }
+      }
+    }
+
+    return customQueryConfig;
+
+  }