+ private String constructLuceneQuery(ReadGraph graph, Resource type, String filter) throws DatabaseException {
+ Layer0 L0 = Layer0.getInstance(graph);
+ StringBuilder sb = new StringBuilder();
+ boolean emptyFilter = filter.isEmpty();
+ if (emptyFilter || !type.equals(L0.Entity)) {
+ String typeName = graph.getPossibleRelatedValue(type, L0.HasName, Bindings.STRING);
+ if (typeName == null || typeName.isEmpty())
+ return null;
+ sb.append("Types:").append( IndexQueries.quoteTerm(typeName) );
+ }
+ if (!emptyFilter) {
+ if (sb.length() > 0)
+ sb.append(" AND ");
+ sb.append(filter);
+ }
+ if (sb.length() == 0) {
+ sb.append("*:*");
+ }
+ return sb.toString();