Skip to content

Commit

Permalink
OAK-6295 : Move constants from oak.query.QueryImpl to oak.spi.query.Q…
Browse files Browse the repository at this point in the history
…ueryConstants

git-svn-id: https://svn.apache.org/repos/asf/jackrabbit/oak/trunk@1797786 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
anchela committed Jun 6, 2017
1 parent 6680856 commit 9d5edb7
Show file tree
Hide file tree
Showing 18 changed files with 116 additions and 116 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
import org.apache.jackrabbit.oak.query.plan.SelectorExecutionPlan;
import org.apache.jackrabbit.oak.spi.query.Filter;
import org.apache.jackrabbit.oak.spi.query.PropertyValues;
import org.apache.jackrabbit.oak.spi.query.QueryConstants;
import org.apache.jackrabbit.oak.spi.query.QueryIndex;
import org.apache.jackrabbit.oak.spi.query.QueryIndex.AdvancedQueryIndex;
import org.apache.jackrabbit.oak.spi.query.QueryIndex.IndexPlan;
Expand All @@ -102,42 +103,6 @@
* Represents a parsed query.
*/
public class QueryImpl implements Query {

/**
* The "jcr:path" pseudo-property.
*/
// TODO jcr:path isn't an official feature, support it?
public static final String JCR_PATH = "jcr:path";

/**
* The "jcr:score" pseudo-property.
*/
public static final String JCR_SCORE = "jcr:score";

/**
* The "rep:excerpt" pseudo-property.
*/
public static final String REP_EXCERPT = "rep:excerpt";

/**
* The "rep:facet" pseudo-property.
*/
public static final String REP_FACET = "rep:facet";

/**
* The "oak:explainScore" pseudo-property.
*/
public static final String OAK_SCORE_EXPLANATION = "oak:scoreExplanation";

/**
* The "rep:spellcheck" pseudo-property.
*/
public static final String REP_SPELLCHECK = "rep:spellcheck()";

/**
* The "rep:suggest" pseudo-property.
*/
public static final String REP_SUGGEST = "rep:suggest()";

private static final Logger LOG = LoggerFactory.getLogger(QueryImpl.class);

Expand Down Expand Up @@ -443,7 +408,7 @@ public boolean visit(NotImpl node) {
for (int i = 0; i < columns.length; i++) {
ColumnImpl c = columns[i];
boolean distinct = true;
if (JCR_SCORE.equals(c.getPropertyName())) {
if (QueryConstants.JCR_SCORE.equals(c.getPropertyName())) {
distinct = false;
}
distinctColumns[i] = distinct;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.apache.jackrabbit.oak.query.ast.OrderingImpl;
import org.apache.jackrabbit.oak.query.fulltext.SimpleExcerptProvider;
import org.apache.jackrabbit.oak.spi.query.PropertyValues;
import org.apache.jackrabbit.oak.spi.query.QueryConstants;

/**
* A query result row that keeps all data (for this row only) in memory.
Expand Down Expand Up @@ -108,13 +109,13 @@ public PropertyValue getValue(String columnName) {
// OAK-318:
// somebody might call rep:excerpt(text)
// even though the query doesn't contain that column
if (columnName.startsWith(QueryImpl.REP_EXCERPT)) {
int columnIndex = query.getColumnIndex(QueryImpl.REP_EXCERPT);
if (columnName.startsWith(QueryConstants.REP_EXCERPT)) {
int columnIndex = query.getColumnIndex(QueryConstants.REP_EXCERPT);
PropertyValue indexExcerptValue = null;
if (columnIndex >= 0) {
indexExcerptValue = values[columnIndex];
if (indexExcerptValue != null) {
if (QueryImpl.REP_EXCERPT.equals(columnName) || SimpleExcerptProvider.REP_EXCERPT_FN.equals(columnName)) {
if (QueryConstants.REP_EXCERPT.equals(columnName) || SimpleExcerptProvider.REP_EXCERPT_FN.equals(columnName)) {
return SimpleExcerptProvider.getExcerpt(indexExcerptValue);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
import org.apache.jackrabbit.oak.query.ast.SourceImpl;
import org.apache.jackrabbit.oak.query.ast.StaticOperandImpl;
import org.apache.jackrabbit.oak.spi.query.PropertyValues;
import org.apache.jackrabbit.oak.spi.query.QueryConstants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -210,8 +211,8 @@ private QueryImpl parseSelect() throws ParseException {
boolean distinct = readIf("DISTINCT");
ArrayList<ColumnOrWildcard> list = parseColumns();
if (supportSQL1) {
addColumnIfNecessary(list, QueryImpl.JCR_PATH, QueryImpl.JCR_PATH);
addColumnIfNecessary(list, QueryImpl.JCR_SCORE, QueryImpl.JCR_SCORE);
addColumnIfNecessary(list, QueryConstants.JCR_PATH, QueryConstants.JCR_PATH);
addColumnIfNecessary(list, QueryConstants.JCR_SCORE, QueryConstants.JCR_SCORE);
}
read("FROM");
SourceImpl source = parseSource();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import javax.annotation.Nonnull;

import org.apache.jackrabbit.oak.api.PropertyValue;
import org.apache.jackrabbit.oak.query.QueryImpl;
import org.apache.jackrabbit.oak.spi.query.QueryConstants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -52,7 +52,7 @@ public ChildNodeJoinConditionImpl childNodeJoinCondition(String childSelectorNam
}

public ColumnImpl column(String selectorName, String propertyName, String columnName) {
if (propertyName.startsWith(QueryImpl.REP_FACET)) {
if (propertyName.startsWith(QueryConstants.REP_FACET)) {
return new FacetColumnImpl(selectorName, propertyName, columnName);
} else {
return new ColumnImpl(selectorName, propertyName, columnName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
import javax.jcr.PropertyType;

import org.apache.jackrabbit.oak.api.PropertyValue;
import org.apache.jackrabbit.oak.query.QueryImpl;
import org.apache.jackrabbit.oak.query.index.FilterImpl;
import org.apache.jackrabbit.oak.spi.query.PropertyValues;
import org.apache.jackrabbit.oak.spi.query.QueryConstants;
import org.apache.jackrabbit.oak.spi.query.QueryIndex.OrderEntry;

/**
Expand Down Expand Up @@ -64,7 +64,7 @@ public Set<SelectorImpl> getSelectors() {

@Override
public PropertyValue currentProperty() {
PropertyValue p = selector.currentOakProperty(QueryImpl.JCR_SCORE);
PropertyValue p = selector.currentOakProperty(QueryConstants.JCR_SCORE);
if (p == null) {
// TODO if score() is not supported by the index, use the value 0.0?
return PropertyValues.newDouble(0.0);
Expand All @@ -83,7 +83,7 @@ public void restrict(FilterImpl f, Operator operator, PropertyValue v) {
// not supported
return;
}
f.restrictProperty(QueryImpl.JCR_SCORE, operator, v);
f.restrictProperty(QueryConstants.JCR_SCORE, operator, v);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@

import org.apache.jackrabbit.oak.api.PropertyValue;
import org.apache.jackrabbit.oak.api.Type;
import org.apache.jackrabbit.oak.query.QueryImpl;
import org.apache.jackrabbit.oak.query.SQL2Parser;
import org.apache.jackrabbit.oak.query.index.FilterImpl;
import org.apache.jackrabbit.oak.spi.query.Filter.PathRestriction;
import org.apache.jackrabbit.oak.spi.query.QueryConstants;
import org.apache.jackrabbit.oak.spi.query.QueryIndex.OrderEntry;

/**
Expand Down Expand Up @@ -84,7 +84,7 @@ public boolean supportsRangeConditions() {
// the jcr:path pseudo-property doesn't support LIKE conditions,
// because the path doesn't might be escaped, and possibly contain
// expressions that would result in incorrect results (/test[1] for example)
return !propertyName.equals(QueryImpl.JCR_PATH);
return !propertyName.equals(QueryConstants.JCR_PATH);
}

@Override
Expand Down Expand Up @@ -119,7 +119,7 @@ public void bindSelector(SourceImpl source) {
public void restrict(FilterImpl f, Operator operator, PropertyValue v) {
if (f.getSelector().equals(selector)) {
String pn = normalizePropertyName(propertyName);
if (pn.equals(QueryImpl.JCR_PATH)) {
if (pn.equals(QueryConstants.JCR_PATH)) {
if (operator == Operator.EQUAL) {
f.restrictPath(v.getValue(Type.STRING), PathRestriction.EXACT);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import org.apache.jackrabbit.oak.spi.query.Cursors;
import org.apache.jackrabbit.oak.spi.query.IndexRow;
import org.apache.jackrabbit.oak.spi.query.PropertyValues;
import org.apache.jackrabbit.oak.spi.query.QueryConstants;
import org.apache.jackrabbit.oak.spi.query.QueryIndex;
import org.apache.jackrabbit.oak.spi.query.QueryIndex.AdvancedQueryIndex;
import org.apache.jackrabbit.oak.spi.query.QueryIndex.IndexPlan;
Expand Down Expand Up @@ -386,10 +387,10 @@ public FilterImpl createFilter(boolean preparing) {
for (ColumnImpl c : query.getColumns()) {
if (c.getSelector().equals(this)) {
String columnName = c.getColumnName();
if (columnName.equals(QueryImpl.REP_EXCERPT) || columnName.equals(QueryImpl.OAK_SCORE_EXPLANATION)) {
if (columnName.equals(QueryConstants.REP_EXCERPT) || columnName.equals(QueryConstants.OAK_SCORE_EXPLANATION)) {
f.restrictProperty(columnName, Operator.NOT_EQUAL, null);
} else if (columnName.startsWith(QueryImpl.REP_FACET)) {
f.restrictProperty(QueryImpl.REP_FACET, Operator.EQUAL, PropertyValues.newString(columnName));
} else if (columnName.startsWith(QueryConstants.REP_FACET)) {
f.restrictProperty(QueryConstants.REP_FACET, Operator.EQUAL, PropertyValues.newString(columnName));
}
}
}
Expand Down Expand Up @@ -648,25 +649,25 @@ private PropertyValue currentOakProperty(Tree t, String oakPropertyName, Integer
if ((t == null || !t.exists()) && (currentRow == null || !currentRow.isVirtualRow())) {
return null;
}
if (oakPropertyName.equals(QueryImpl.JCR_PATH)) {
if (oakPropertyName.equals(QueryConstants.JCR_PATH)) {
String path = currentPath();
String local = getLocalPath(path);
if (local == null) {
// not a local path
return null;
}
result = PropertyValues.newString(local);
} else if (oakPropertyName.equals(QueryImpl.JCR_SCORE)) {
result = currentRow.getValue(QueryImpl.JCR_SCORE);
} else if (oakPropertyName.equals(QueryImpl.REP_EXCERPT)) {
result = currentRow.getValue(QueryImpl.REP_EXCERPT);
} else if (oakPropertyName.equals(QueryImpl.OAK_SCORE_EXPLANATION)) {
result = currentRow.getValue(QueryImpl.OAK_SCORE_EXPLANATION);
} else if (oakPropertyName.equals(QueryImpl.REP_SPELLCHECK)) {
result = currentRow.getValue(QueryImpl.REP_SPELLCHECK);
} else if (oakPropertyName.equals(QueryImpl.REP_SUGGEST)) {
result = currentRow.getValue(QueryImpl.REP_SUGGEST);
} else if (oakPropertyName.startsWith(QueryImpl.REP_FACET)) {
} else if (oakPropertyName.equals(QueryConstants.JCR_SCORE)) {
result = currentRow.getValue(QueryConstants.JCR_SCORE);
} else if (oakPropertyName.equals(QueryConstants.REP_EXCERPT)) {
result = currentRow.getValue(QueryConstants.REP_EXCERPT);
} else if (oakPropertyName.equals(QueryConstants.OAK_SCORE_EXPLANATION)) {
result = currentRow.getValue(QueryConstants.OAK_SCORE_EXPLANATION);
} else if (oakPropertyName.equals(QueryConstants.REP_SPELLCHECK)) {
result = currentRow.getValue(QueryConstants.REP_SPELLCHECK);
} else if (oakPropertyName.equals(QueryConstants.REP_SUGGEST)) {
result = currentRow.getValue(QueryConstants.REP_SUGGEST);
} else if (oakPropertyName.startsWith(QueryConstants.REP_FACET)) {
result = currentRow.getValue(oakPropertyName);
} else {
result = PropertyValues.create(t.getProperty(oakPropertyName));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

import org.apache.jackrabbit.oak.commons.json.JsopReader;
import org.apache.jackrabbit.oak.commons.json.JsopTokenizer;
import org.apache.jackrabbit.oak.query.QueryImpl;
import org.apache.jackrabbit.oak.spi.query.QueryConstants;

/**
* A facet result is a wrapper for {@link javax.jcr.query.QueryResult} capable of returning information about facets
Expand All @@ -49,8 +49,8 @@ public FacetResult(QueryResult queryResult) {
if (rows.hasNext()) {
Row row = rows.nextRow();
for (String column : queryResult.getColumnNames()) {
if (column.startsWith(QueryImpl.REP_FACET)) {
String dimension = column.substring(QueryImpl.REP_FACET.length() + 1, column.length() - 1);
if (column.startsWith(QueryConstants.REP_FACET)) {
String dimension = column.substring(QueryConstants.REP_FACET.length() + 1, column.length() - 1);
Value value = row.getValue(column);
if (value != null) {
String jsonFacetString = value.getString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@

import java.util.ArrayList;

import org.apache.jackrabbit.oak.query.QueryImpl;
import org.apache.jackrabbit.oak.query.QueryOptions;
import org.apache.jackrabbit.oak.query.QueryOptions.Traversal;
import org.apache.jackrabbit.oak.query.xpath.Expression.AndCondition;
import org.apache.jackrabbit.oak.query.xpath.Expression.OrCondition;
import org.apache.jackrabbit.oak.query.xpath.Expression.Property;
import org.apache.jackrabbit.oak.spi.query.QueryConstants;

/**
* An xpath statement.
Expand Down Expand Up @@ -158,14 +158,14 @@ public String toString() {

// select ...
buff.append("select ");
buff.append(new Expression.Property(columnSelector, QueryImpl.JCR_PATH, false).toString());
buff.append(new Expression.Property(columnSelector, QueryConstants.JCR_PATH, false).toString());
if (selectors.size() > 1) {
buff.append(" as ").append('[').append(QueryImpl.JCR_PATH).append(']');
buff.append(" as ").append('[').append(QueryConstants.JCR_PATH).append(']');
}
buff.append(", ");
buff.append(new Expression.Property(columnSelector, QueryImpl.JCR_SCORE, false).toString());
buff.append(new Expression.Property(columnSelector, QueryConstants.JCR_SCORE, false).toString());
if (selectors.size() > 1) {
buff.append(" as ").append('[').append(QueryImpl.JCR_SCORE).append(']');
buff.append(" as ").append('[').append(QueryConstants.JCR_SCORE).append(']');
}
if (columnList.isEmpty()) {
buff.append(", ");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
import org.apache.jackrabbit.oak.api.Root;
import org.apache.jackrabbit.oak.api.Tree;
import org.apache.jackrabbit.oak.api.Type;
import org.apache.jackrabbit.oak.query.QueryImpl;
import org.apache.jackrabbit.oak.security.user.UserManagerImpl;
import org.apache.jackrabbit.oak.spi.query.QueryConstants;
import org.apache.jackrabbit.oak.spi.security.user.AuthorizableType;
import org.apache.jackrabbit.oak.spi.security.user.util.UserUtil;
import org.slf4j.Logger;
Expand Down Expand Up @@ -64,7 +64,7 @@ public Authorizable apply(@Nullable ResultRow row) {
private Authorizable getAuthorizable(@CheckForNull ResultRow row) {
Authorizable authorizable = null;
if (row != null) {
String resultPath = row.getValue(QueryImpl.JCR_PATH).getValue(Type.STRING);
String resultPath = row.getValue(QueryConstants.JCR_PATH).getValue(Type.STRING);
try {
Tree tree = root.getTree(resultPath);
AuthorizableType type = UserUtil.getType(tree);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,39 @@ public abstract class QueryConstants {
public static final String FUNCTION_RESTRICTION_PREFIX = "function*";

public static final String SEARCH_ROOT_PATH = "/jcr:root";
/**
* The "jcr:path" pseudo-property.
*/
// TODO jcr:path isn't an official feature, support it?
public static final String JCR_PATH = "jcr:path";

/**
* The "jcr:score" pseudo-property.
*/
public static final String JCR_SCORE = "jcr:score";

/**
* The "rep:excerpt" pseudo-property.
*/
public static final String REP_EXCERPT = "rep:excerpt";

/**
* The "rep:facet" pseudo-property.
*/
public static final String REP_FACET = "rep:facet";

/**
* The "oak:explainScore" pseudo-property.
*/
public static final String OAK_SCORE_EXPLANATION = "oak:scoreExplanation";

/**
* The "rep:spellcheck" pseudo-property.
*/
public static final String REP_SPELLCHECK = "rep:spellcheck()";

/**
* The "rep:suggest" pseudo-property.
*/
public static final String REP_SUGGEST = "rep:suggest()";
}
Loading

0 comments on commit 9d5edb7

Please sign in to comment.