package org.onap.aai.query.builder;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import com.google.common.base.Joiner;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Multimap;
import org.onap.aai.restcore.search.GremlinGroovyShell;
import org.onap.aai.schema.enums.ObjectMetadata;
import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* The Class GremlinQueryBuilder.
list = new ArrayList<>();
}
-
@Override
public QueryBuilder<Vertex> exactMatchQuery(Introspector obj) {
// TODO not implemented because this is implementation is no longer used
String valueString = value.toString();
if (valueString.indexOf('\'') != -1) {
- value = valueString.replace(SINGLE_QUOTE, ESCAPE_SINGLE_QUOTE);
+ value = valueString.replace(SINGLE_QUOTE, ESCAPE_SINGLE_QUOTE);
}
LOGGER.trace("Inside getVerticesByProperty(): key = {}, value = {}", key, value);
term = value.toString();
String valueString = value.toString();
if (valueString.indexOf('\'') != -1) {
- value = valueString.replace(SINGLE_QUOTE, ESCAPE_SINGLE_QUOTE);
+ value = valueString.replace(SINGLE_QUOTE, ESCAPE_SINGLE_QUOTE);
}
LOGGER.trace("Inside getVerticesByProperty(): key = {}, value = {}", key, value);
term = "'" + value + "'";
stepIndex++;
return (QueryBuilder<Vertex>) this;
}
-
+
/**
* @{inheritDoc}
*/
@Override
public QueryBuilder<Vertex> getVerticesByCommaSeperatedValue(String key, String value) {
ArrayList<String> arguments = new ArrayList<>(Arrays.asList(value.split(",")));
- //add the single quotes
+ // add the single quotes
for (int i = 0; i < arguments.size(); i++) {
- if(arguments.get(i) != null && !arguments.get(i).startsWith("'")
- && !arguments.get(i).endsWith("'")) {
- arguments.set(i,"'" + arguments.get(i).trim() + "'");
- }
- else {
- arguments.set(i, arguments.get(i).trim());
- }
+ if (arguments.get(i) != null && !arguments.get(i).startsWith("'") && !arguments.get(i).endsWith("'")) {
+ arguments.set(i, "'" + arguments.get(i).trim() + "'");
+ } else {
+ arguments.set(i, arguments.get(i).trim());
+ }
}
String predicate = "P.within(#!#argument#!#)";
String argument = Joiner.on(",").join(arguments);
public QueryBuilder<Vertex> getTypedVerticesByMap(String type, Map<String, String> map) {
for (Map.Entry<String, String> es : map.entrySet()) {
- //TODO what is this and where is it used - need to check
+ // TODO what is this and where is it used - need to check
list.add(HAS + es.getKey() + "', '" + es.getValue() + "')");
stepIndex++;
}
list.add(".has('aai-node-type', '" + type + "')");
}
stepIndex++;
- this.markContainer();
+ this.markContainerIndex();
return (QueryBuilder<Vertex>) this;
}
return this;
}
-
+
@Override
public QueryBuilder<E> valueMap() {
this.list.add(".valueMap()");
return this;
}
-
+
@Override
public QueryBuilder<E> valueMap(String... names) {
- String stepString = ".valueMap('";
- for (int i = 0; i < names.length; i++) {
- stepString = stepString + names[i] + "'";
- if (i != (names.length - 1)) {
- stepString = stepString + ",'";
- }
- }
- stepString = stepString + ")";
- this.list.add(stepString);
- stepIndex++;
+ String stepString = ".valueMap('";
+ for (int i = 0; i < names.length; i++) {
+ stepString = stepString + names[i] + "'";
+ if (i != (names.length - 1)) {
+ stepString = stepString + ",'";
+ }
+ }
+ stepString = stepString + ")";
+ this.list.add(stepString);
+ stepIndex++;
- return this;
+ return this;
}
-
/**
* {@inheritDoc}
}
@Override
- public void markContainer() {
+ public void markContainerIndex() {
this.containerStepIndex = stepIndex;
}
* This is required for the subgraphstrategies to work
*/
-
}