// Path: src/main/java/de/ids_mannheim/korap/query/serialize/FCSQLQueryProcessor.java
// public class FCSQLQueryProcessor extends AbstractQueryProcessor {
// 
//     public static final class FCSSRUQuery extends SRUQueryBase<QueryNode> {
// 
//         private FCSSRUQuery (String rawQuery, QueryNode parsedQuery) {
//             super(rawQuery, parsedQuery);
//         }
// 
//         @Override
//         public String getQueryType() {
//             return Constants.FCS_QUERY_TYPE_FCS;
//         }
//     }
// 
//     private final QueryParser fcsParser = new QueryParser();
//     
//     /** Constructs FCSQLQueryProcessor for the given query and version.
//      * @param query an FCS query string
//      */
//     public FCSQLQueryProcessor (String query) {
//         super();
//         process(query);
//     }
// 
//     @Override
//     public Map<String, Object> getRequestMap() {
//         return this.requestMap;
//     }
// 
//     @Override
//     public void process(String query) {
//         FCSSRUQuery fcsSruQuery = parseQueryStringtoFCSQuery(query);
//         if (fcsSruQuery != null) {
//             QueryNode fcsQueryNode = fcsSruQuery.getParsedQuery();
//             try {
// 				parseFCSQueryToKoralQuery(fcsQueryNode);
// 			} catch (KoralException e) {
// 				addError(e.getStatusCode(), e.getMessage());
// 			}
//         }
//     }
// 
//     /** Translates the given FCS query string into an FCSSSRUQuery object.
//      * @param query an FCS query string
//      * @return an FCSSRUQuery
//      */
//     private FCSSRUQuery parseQueryStringtoFCSQuery(String query) {
//         if ((query == null) || query.isEmpty())
//             addError(StatusCodes.NO_QUERY,
//                     "No query has been passed.");
//         FCSSRUQuery fcsQuery = null;
//         try {
//             QueryNode parsedQuery = fcsParser.parse(query);
//             fcsQuery = new FCSSRUQuery(query, parsedQuery);
//             if (fcsQuery == null) {
//                 addError(StatusCodes.UNKNOWN_QUERY_ERROR,
//                         "Unexpected error while parsing query.");
//             }
//         }
//         catch (QueryParserException e) {
//             addError(
//                     StatusCodes.UNKNOWN_QUERY_ERROR,
//                     "Query cannot be parsed, "
//                             + e.getMessage());
//         }
//         catch (Exception e) {
//             addError(StatusCodes.UNKNOWN_QUERY_ERROR, "Unexpected error while parsing query.");
//         }
//         return fcsQuery;
//     }
// 
//     /** Generates a query map structure for the given FCS query node.
//      * 
//      * @param queryNode an FCS query node
//      * @throws KoralException
//      */
//     private void parseFCSQueryToKoralQuery(QueryNode queryNode) throws KoralException {
//         FCSSRUQueryParser parser = new FCSSRUQueryParser();
//         KoralObject o = parser.parseQueryNode(queryNode);
//         Map<String, Object> queryMap = MapBuilder.buildQueryMap(o);
//         if (queryMap != null) requestMap.put("query", queryMap);
//     }
// }


import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.io.IOException;
import java.util.List;
import org.junit.Test;
import com.fasterxml.jackson.core.JsonProcessingException;
import de.ids_mannheim.korap.query.serialize.FCSQLQueryProcessor;
                + "operation:operation:position,"
                + "operands:["
                + "{@type:koral:span,wrap:{@type:koral:term,key:s,foundry:base,layer:s}},"
                + "{@type:koral:token,wrap:{@type:koral:term,key:grün,foundry:opennlp,layer:orth,type:type:regex,match:match:eq}}"
                + "]}";
        FCSQLQueryProcessorTest.runAndValidate(query, jsonLd);
        
        query = "[corenlp:pos=\"VVFIN\"] within s";
        jsonLd = "{@type:koral:group,"
                + "operation:operation:position,"
                + "operands:["
                + "{@type:koral:span,wrap:{@type:koral:term,key:s,foundry:base,layer:s}},"
                + "{@type:koral:token,wrap:{@type:koral:term,key:VVFIN,foundry:corenlp,layer:p,type:type:regex,match:match:eq}}"
                + "]}";
        FCSQLQueryProcessorTest.runAndValidate(query, jsonLd);

        query = "[corenlp:pos=\"VVFIN\"] within sentence";
        FCSQLQueryProcessorTest.runAndValidate(query, jsonLd);

        query = "[corenlp:pos=\"VVFIN\"] within p";
        jsonLd = "{@type:koral:span,wrap:{@type:koral:term,key:p,foundry:base,layer:s}}";
        FCSQLQueryProcessorTest
                .validateNode(query, "/query/operands/0", jsonLd);

        query = "[corenlp:pos=\"VVFIN\"] within text";
        jsonLd = "{@type:koral:span,wrap:{@type:koral:term,key:t,foundry:base,layer:s}}";
        FCSQLQueryProcessorTest
                .validateNode(query, "/query/operands/0", jsonLd);

        query = "[corenlp:pos=\"VVFIN\"] within u";
// Path: src/main/java/de/ids_mannheim/korap/query/serialize/FCSQLQueryProcessor.java
// public class FCSQLQueryProcessor extends AbstractQueryProcessor {
// 
//     public static final class FCSSRUQuery extends SRUQueryBase<QueryNode> {
// 
//         private FCSSRUQuery (String rawQuery, QueryNode parsedQuery) {
//             super(rawQuery, parsedQuery);
//         }
// 
//         @Override
//         public String getQueryType() {
//             return Constants.FCS_QUERY_TYPE_FCS;
//         }
//     }
// 
//     private final QueryParser fcsParser = new QueryParser();
//     
//     /** Constructs FCSQLQueryProcessor for the given query and version.
//      * @param query an FCS query string
//      */
//     public FCSQLQueryProcessor (String query) {
//         super();
//         process(query);
//     }
// 
//     @Override
//     public Map<String, Object> getRequestMap() {
//         return this.requestMap;
//     }
// 
//     @Override
//     public void process(String query) {
//         FCSSRUQuery fcsSruQuery = parseQueryStringtoFCSQuery(query);
//         if (fcsSruQuery != null) {
//             QueryNode fcsQueryNode = fcsSruQuery.getParsedQuery();
//             try {
// 				parseFCSQueryToKoralQuery(fcsQueryNode);
// 			} catch (KoralException e) {
// 				addError(e.getStatusCode(), e.getMessage());
// 			}
//         }
//     }
// 
//     /** Translates the given FCS query string into an FCSSSRUQuery object.
//      * @param query an FCS query string
//      * @return an FCSSRUQuery
//      */
//     private FCSSRUQuery parseQueryStringtoFCSQuery(String query) {
//         if ((query == null) || query.isEmpty())
//             addError(StatusCodes.NO_QUERY,
//                     "No query has been passed.");
//         FCSSRUQuery fcsQuery = null;
//         try {
//             QueryNode parsedQuery = fcsParser.parse(query);
//             fcsQuery = new FCSSRUQuery(query, parsedQuery);
//             if (fcsQuery == null) {
//                 addError(StatusCodes.UNKNOWN_QUERY_ERROR,
//                         "Unexpected error while parsing query.");
//             }
//         }
//         catch (QueryParserException e) {
//             addError(
//                     StatusCodes.UNKNOWN_QUERY_ERROR,
//                     "Query cannot be parsed, "
//                             + e.getMessage());
//         }
//         catch (Exception e) {
//             addError(StatusCodes.UNKNOWN_QUERY_ERROR, "Unexpected error while parsing query.");
//         }
//         return fcsQuery;
//     }
// 
//     /** Generates a query map structure for the given FCS query node.
//      * 
//      * @param queryNode an FCS query node
//      * @throws KoralException
//      */
//     private void parseFCSQueryToKoralQuery(QueryNode queryNode) throws KoralException {
//         FCSSRUQueryParser parser = new FCSSRUQueryParser();
//         KoralObject o = parser.parseQueryNode(queryNode);
//         Map<String, Object> queryMap = MapBuilder.buildQueryMap(o);
//         if (queryMap != null) requestMap.put("query", queryMap);
//     }
// }


// Path: src/test/java/de/ids_mannheim/korap/query/test/fcsql/FCSQLComplexTest.java
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.io.IOException;
import java.util.List;
import org.junit.Test;
import com.fasterxml.jackson.core.JsonProcessingException;
import de.ids_mannheim.korap.query.serialize.FCSQLQueryProcessor;

                + "operation:operation:position,"
                + "operands:["
                + "{@type:koral:span,wrap:{@type:koral:term,key:s,foundry:base,layer:s}},"
                + "{@type:koral:token,wrap:{@type:koral:term,key:grün,foundry:opennlp,layer:orth,type:type:regex,match:match:eq}}"
                + "]}";
        FCSQLQueryProcessorTest.runAndValidate(query, jsonLd);
        
        query = "[corenlp:pos=\"VVFIN\"] within s";
        jsonLd = "{@type:koral:group,"
                + "operation:operation:position,"
                + "operands:["
                + "{@type:koral:span,wrap:{@type:koral:term,key:s,foundry:base,layer:s}},"
                + "{@type:koral:token,wrap:{@type:koral:term,key:VVFIN,foundry:corenlp,layer:p,type:type:regex,match:match:eq}}"
                + "]}";
        FCSQLQueryProcessorTest.runAndValidate(query, jsonLd);

        query = "[corenlp:pos=\"VVFIN\"] within sentence";
        FCSQLQueryProcessorTest.runAndValidate(query, jsonLd);

        query = "[corenlp:pos=\"VVFIN\"] within p";
        jsonLd = "{@type:koral:span,wrap:{@type:koral:term,key:p,foundry:base,layer:s}}";
        FCSQLQueryProcessorTest
                .validateNode(query, "/query/operands/0", jsonLd);

        query = "[corenlp:pos=\"VVFIN\"] within text";
        jsonLd = "{@type:koral:span,wrap:{@type:koral:term,key:t,foundry:base,layer:s}}";
        FCSQLQueryProcessorTest
                .validateNode(query, "/query/operands/0", jsonLd);

        query = "[corenlp:pos=\"VVFIN\"] within u";
        error = FCSQLQueryProcessorTest.getError(new FCSQLQueryProcessor(query));