<commit_before>/*
 *  Copyright (c) 2017 <NAME> and others
 *   All rights reserved. This program and the accompanying materials
 *   are made available under the terms of the Eclipse Public License v1.0
 *   and Apache License v2.0 which accompanies this distribution.
 *   The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
 *   and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php.
 *
 *   You may elect to redistribute this code under either of these licenses.
 *
 *   Contributors:
 *
 *   <NAME>
 */
package org.jnosql.diana.orientdb.document;


import com.orientechnologies.orient.core.command.OCommandResultListener;
import com.orientechnologies.orient.core.record.impl.ODocument;
import com.orientechnologies.orient.core.sql.query.OLiveQuery;
import com.orientechnologies.orient.core.sql.query.OSQLAsynchQuery;
import com.orientechnologies.orient.core.sql.query.OSQLQuery;
import com.orientechnologies.orient.core.sql.query.OSQLSynchQuery;
import org.jnosql.diana.api.Condition;
import org.jnosql.diana.api.TypeReference;
import org.jnosql.diana.api.document.Document;
import org.jnosql.diana.api.document.DocumentCondition;
import org.jnosql.diana.api.document.DocumentEntity;
import org.jnosql.diana.api.document.DocumentQuery;

import java.util.ArrayList;
import java.util.List;
import java.util.function.Consumer;

import static java.util.Arrays.asList;

final class OSQLQueryFactory {

    public static final String LIVE = "live ";

    private OSQLQueryFactory() {
    }

    static QueryResult to(DocumentQuery documentQuery) {
        Query query = getQuery(documentQuery);

        return new QueryResult(new OSQLSynchQuery<ODocument>(query.getQuery()) {
        }, query.getParams());
    }

    static OSQLSynchQuery<ODocument> parse(String query) {
        return new OSQLSynchQuery<ODocument>(query) {
        };
    }

    static OLiveQuery<ODocument> parseOlive(String query, Consumer<DocumentEntity> callBack) {
        return new OLiveQuery<>(query, new LiveQueryLIstener(callBack));
    }

    static QueryResult toDelete(DocumentQuery documentQuery) {
        Query query = getQuery(documentQuery);

        return new QueryResult(new OSQLSynchQuery<ODocument>(query.getQuery()) {
        }, query.getParams());
    }

    static QueryResult toAsync(DocumentQuery documentQuery, Consumer<List<ODocument>> callBack) {
        Query query = getQuery(documentQuery);
        return new QueryResult(new OSQLAsynchQuery<>(query.getQuery(), new OCommandResultListener() {<commit_msg>removes methods in orientdb<commit_after>/*
 *  Copyright (c) 2017 <NAME> and others
 *   All rights reserved. This program and the accompanying materials
 *   are made available under the terms of the Eclipse Public License v1.0
 *   and Apache License v2.0 which accompanies this distribution.
 *   The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
 *   and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php.
 *
 *   You may elect to redistribute this code under either of these licenses.
 *
 *   Contributors:
 *
 *   <NAME>
 */
package org.jnosql.diana.orientdb.document;


import com.orientechnologies.orient.core.command.OCommandResultListener;
import com.orientechnologies.orient.core.record.impl.ODocument;
import com.orientechnologies.orient.core.sql.query.OLiveQuery;
import com.orientechnologies.orient.core.sql.query.OSQLAsynchQuery;
import com.orientechnologies.orient.core.sql.query.OSQLQuery;
import com.orientechnologies.orient.core.sql.query.OSQLSynchQuery;
import org.jnosql.diana.api.Condition;
import org.jnosql.diana.api.TypeReference;
import org.jnosql.diana.api.document.Document;
import org.jnosql.diana.api.document.DocumentCondition;
import org.jnosql.diana.api.document.DocumentEntity;
import org.jnosql.diana.api.document.DocumentQuery;

import java.util.ArrayList;
import java.util.List;
import java.util.function.Consumer;

import static java.util.Arrays.asList;

final class OSQLQueryFactory {

    public static final String LIVE = "live ";

    private OSQLQueryFactory() {
    }

    static QueryResult to(DocumentQuery documentQuery) {
        Query query = getQuery(documentQuery);

        return new QueryResult(new OSQLSynchQuery<ODocument>(query.getQuery()) {
        }, query.getParams());
    }

    static OSQLSynchQuery<ODocument> parse(String query) {
        return new OSQLSynchQuery<ODocument>(query) {
        };
    }

    static QueryResult toAsync(DocumentQuery documentQuery, Consumer<List<ODocument>> callBack) {
        Query query = getQuery(documentQuery);
        return new QueryResult(new OSQLAsynchQuery<>(query.getQuery(), new OCommandResultListener() {
{'fraction_non_alphanumeric': 0.09834346823233382, 'fraction_numerical': 0.005871251834766198, 'mean_word_length': 4.25909592061742, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5034843', 'n_tokens_mistral': 1447, 'n_tokens_neox': 1406, 'n_words': 320}