use of datawave.query.language.tree.ServerHeadNode in project datawave by NationalSecurityAgency.
the class JexlControlledQueryParser method parse.
@Override
public QueryNode parse(String query) throws ParseException {
checkIfQueryAllowed(query);
StringBuilder sb = new StringBuilder();
if (!includedValues.isEmpty()) {
sb.append("(");
}
boolean addedFirstInclude = false;
for (Map.Entry<String, Set<String>> entry : includedValues.entrySet()) {
String field = entry.getKey();
for (String value : entry.getValue()) {
if (addedFirstInclude) {
sb.append(" || ");
}
addedFirstInclude = true;
sb.append("filter:includeRegex(").append(field).append(", '").append(value).append("')");
}
}
if (!includedValues.isEmpty()) {
sb.append(")");
}
if (!excludedValues.isEmpty()) {
if (!includedValues.isEmpty()) {
sb.append(" && ");
}
sb.append("(");
}
boolean addedFirstExclude = false;
for (Map.Entry<String, Set<String>> entry : excludedValues.entrySet()) {
String field = entry.getKey();
for (String value : entry.getValue()) {
if (addedFirstExclude) {
sb.append(" && ");
}
addedFirstExclude = true;
sb.append("not(filter:includeRegex(").append(field).append(", '").append(value).append("'))");
}
}
if (!excludedValues.isEmpty()) {
sb.append(")");
}
if (sb.length() > 0) {
query = "(" + query + ")" + " && (" + sb + ")";
}
QueryNode node = new ServerHeadNode();
node.setOriginalQuery(query);
return node;
}
use of datawave.query.language.tree.ServerHeadNode in project datawave by NationalSecurityAgency.
the class LuceneToJexlQueryParser method parse.
@Override
public QueryNode parse(String query) throws ParseException {
JexlNode parsedQuery = convertToJexlNode(query);
QueryNode node = new ServerHeadNode();
node.setOriginalQuery(parsedQuery.toString());
return node;
}