summaryrefslogtreecommitdiffstats
path: root/aai-queries/src/main/java
diff options
context:
space:
mode:
authorFiete Ostkamp <Fiete.Ostkamp@telekom.de>2022-09-17 20:42:06 +0200
committerFiete Ostkamp <Fiete.Ostkamp@telekom.de>2022-09-17 20:42:06 +0200
commite0ad4f2890f9f933199bc6f1b3f0e988da471aa9 (patch)
tree0c42f25d258aeb0327cdafab0012ddbba13e040d /aai-queries/src/main/java
parent1b2c97dbc18bc0db5610fc18e9ae690b7a40d06d (diff)
Replace all tab characters in java files with two spaces to remove linter warning
Issue-ID: AAI-3525 Signed-off-by: Fiete Ostkamp <Fiete.Ostkamp@telekom.de> Change-Id: I36cf7b83dd33c3b69de51e56e00bbd93a79c5ec4
Diffstat (limited to 'aai-queries/src/main/java')
-rw-r--r--aai-queries/src/main/java/org/onap/aai/queries/CustomQueryConfig.java48
-rw-r--r--aai-queries/src/main/java/org/onap/aai/queries/GetCustomQueryConfig.java230
-rw-r--r--aai-queries/src/main/java/org/onap/aai/queries/GremlinServerSingleton.java44
3 files changed, 161 insertions, 161 deletions
diff --git a/aai-queries/src/main/java/org/onap/aai/queries/CustomQueryConfig.java b/aai-queries/src/main/java/org/onap/aai/queries/CustomQueryConfig.java
index 5a58923..664c9ca 100644
--- a/aai-queries/src/main/java/org/onap/aai/queries/CustomQueryConfig.java
+++ b/aai-queries/src/main/java/org/onap/aai/queries/CustomQueryConfig.java
@@ -22,32 +22,32 @@ package org.onap.aai.queries;
import java.util.List;
public class CustomQueryConfig {
- public CustomQueryConfig() {
- // used by GetCustomQueryConfig
- }
+ public CustomQueryConfig() {
+ // used by GetCustomQueryConfig
+ }
- private String query;
- private List<String> queryOptionalProperties;
- private List<String> queryRequiredProperties;
+ private String query;
+ private List<String> queryOptionalProperties;
+ private List<String> queryRequiredProperties;
- public void setQuery(String query) {
- this.query = query;
- }
- public String getQuery() {
- return this.query;
- }
+ public void setQuery(String query) {
+ this.query = query;
+ }
+ public String getQuery() {
+ return this.query;
+ }
- public void setQueryOptionalProperties( List<String> queryOptionalProperties) {
- this.queryOptionalProperties = queryOptionalProperties;
- }
- public List<String> getQueryOptionalProperties( ) {
- return queryOptionalProperties;
- }
- public void setQueryRequiredProperties( List<String> queryRequiredProperties) {
- this.queryRequiredProperties = queryRequiredProperties;
- }
- public List<String> getQueryRequiredProperties( ) {
- return queryRequiredProperties;
- }
+ public void setQueryOptionalProperties( List<String> queryOptionalProperties) {
+ this.queryOptionalProperties = queryOptionalProperties;
+ }
+ public List<String> getQueryOptionalProperties( ) {
+ return queryOptionalProperties;
+ }
+ public void setQueryRequiredProperties( List<String> queryRequiredProperties) {
+ this.queryRequiredProperties = queryRequiredProperties;
+ }
+ public List<String> getQueryRequiredProperties( ) {
+ return queryRequiredProperties;
+ }
}
diff --git a/aai-queries/src/main/java/org/onap/aai/queries/GetCustomQueryConfig.java b/aai-queries/src/main/java/org/onap/aai/queries/GetCustomQueryConfig.java
index ed4ff99..c726c76 100644
--- a/aai-queries/src/main/java/org/onap/aai/queries/GetCustomQueryConfig.java
+++ b/aai-queries/src/main/java/org/onap/aai/queries/GetCustomQueryConfig.java
@@ -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;
+
+ }
diff --git a/aai-queries/src/main/java/org/onap/aai/queries/GremlinServerSingleton.java b/aai-queries/src/main/java/org/onap/aai/queries/GremlinServerSingleton.java
index 3b4a406..509aa88 100644
--- a/aai-queries/src/main/java/org/onap/aai/queries/GremlinServerSingleton.java
+++ b/aai-queries/src/main/java/org/onap/aai/queries/GremlinServerSingleton.java
@@ -62,29 +62,29 @@ public class GremlinServerSingleton {
@PostConstruct
public void init() {
- try {
- String filepath = storedQueriesLocation + AAIConstants.AAI_FILESEP + "stored-queries.json";
- Path path = Paths.get(filepath);
- String customQueryConfigJson = new String(Files.readAllBytes(path));
+ try {
+ String filepath = storedQueriesLocation + AAIConstants.AAI_FILESEP + "stored-queries.json";
+ Path path = Paths.get(filepath);
+ String customQueryConfigJson = new String(Files.readAllBytes(path));
- queryConfig = new GetCustomQueryConfig(customQueryConfigJson);
- } catch (IOException e) {
- logger.error("Error occurred during the processing of query json file: " + LogFormatTools.getStackTop(e));
- }
+ queryConfig = new GetCustomQueryConfig(customQueryConfigJson);
+ } catch (IOException e) {
+ logger.error("Error occurred during the processing of query json file: " + LogFormatTools.getStackTop(e));
+ }
TimerTask task = new FileWatcher(new File(storedQueriesLocation)) {
@Override
protected void onChange(File file) {
- try {
- String filepath = storedQueriesLocation;
- Path path = Paths.get(filepath);
- String customQueryConfigJson = new String(Files.readAllBytes(path));
- queryConfig = new GetCustomQueryConfig(customQueryConfigJson);
- } catch (IOException e) {
- logger.error("Error occurred during the processing of query json file: " + LogFormatTools.getStackTop(e));
- }
+ try {
+ String filepath = storedQueriesLocation;
+ Path path = Paths.get(filepath);
+ String customQueryConfigJson = new String(Files.readAllBytes(path));
+ queryConfig = new GetCustomQueryConfig(customQueryConfigJson);
+ } catch (IOException e) {
+ logger.error("Error occurred during the processing of query json file: " + LogFormatTools.getStackTop(e));
+ }
}
};
@@ -102,15 +102,15 @@ public class GremlinServerSingleton {
* @return
*/
public String getStoredQueryFromConfig(String key){
- CustomQueryConfig customQueryConfig = queryConfig.getStoredQuery(key);
- if ( customQueryConfig == null ) {
- return null;
- }
- return customQueryConfig.getQuery();
+ CustomQueryConfig customQueryConfig = queryConfig.getStoredQuery(key);
+ if ( customQueryConfig == null ) {
+ return null;
+ }
+ return customQueryConfig.getQuery();
}
public CustomQueryConfig getCustomQueryConfig(String key) {
- return queryConfig.getStoredQuery(key);
+ return queryConfig.getStoredQuery(key);
}