001/** 002 * Copyright 2015 Tampere University of Technology, Pori Department 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package core.tut.pori.dao.filter; 017 018/** 019 * Interface for creating SOLR Query filters 020 * 021 */ 022public interface AbstractQueryFilter { 023 /** Solr AND operator definition */ 024 public static final String SOLR_AND = " AND "; 025 /** Solr OR operator definition */ 026 public static final String SOLR_OR = " OR "; 027 028 /** 029 * Type of the query 030 * 031 * <a href="https://wiki.apache.org/solr/SolrQuerySyntax">Solr Query Syntax</a> 032 */ 033 public enum QueryType{ 034 /** solr AND query */ 035 AND(SOLR_AND), 036 /** solr OR query */ 037 OR(SOLR_OR); 038 039 private String _type; 040 041 /** 042 * 043 * @param type 044 */ 045 private QueryType(String type){ 046 _type = type; 047 } 048 049 /** 050 * 051 * @return type as a string 052 */ 053 public String toTypeString(){ 054 return _type; 055 } 056 } // enum QueryType 057 058 /** 059 * The appended contents should NOT contain the fq= parameter, and should contain ( ) when necessary to contain the query contents. 060 * 061 * @param fq append this query's contents to the given filter query 062 */ 063 public void toFilterString(StringBuilder fq); 064 065 /** 066 * 067 * @return type of the query 068 */ 069 public QueryType getQueryType(); 070}