<commit_before>package nl.maastrichtuniversity.networklibrary.cyneo4j.internal.serviceprovider;

import nl.maastrichtuniversity.networklibrary.cyneo4j.internal.ServiceLocator;
import nl.maastrichtuniversity.networklibrary.cyneo4j.internal.extensionlogic.neo4j.Neo4jCall;
import nl.maastrichtuniversity.networklibrary.cyneo4j.internal.serviceprovider.extension.PassThroughResponseHandler;
import nl.maastrichtuniversity.networklibrary.cyneo4j.internal.serviceprovider.general.Neo4jPingHandler;
import nl.maastrichtuniversity.networklibrary.cyneo4j.internal.serviceprovider.sync.SyncDownTask;
import nl.maastrichtuniversity.networklibrary.cyneo4j.internal.serviceprovider.sync.SyncUpTask;
import org.apache.http.client.fluent.Request;
import org.cytoscape.application.CyApplicationManager;
import org.cytoscape.model.CyNetwork;
import org.cytoscape.model.CyNetworkFactory;
import org.cytoscape.model.CyNetworkManager;
import org.cytoscape.view.layout.CyLayoutAlgorithmManager;
import org.cytoscape.view.model.CyNetworkViewFactory;
import org.cytoscape.view.model.CyNetworkViewManager;
import org.cytoscape.view.vizmap.VisualMappingManager;
import org.cytoscape.work.TaskIterator;
import org.cytoscape.work.swing.DialogTaskManager;

import java.io.IOException;

import static org.apache.http.entity.ContentType.APPLICATION_JSON;

public class Neo4jRESTServer {

    private static final String DATA_URL = "/db/data/";
    private static final String CYPHER_URL = DATA_URL + "cypher";

    private String instanceLocation = null;
    private CyNetworkManager cyNetworkManager;
    private CyNetworkFactory cyNetworkFactory;
    private CyNetworkViewManager cyNetViewMgr;
    private CyNetworkViewFactory cyNetworkViewFactory;
    private CyLayoutAlgorithmManager cyLayoutAlgorithmManager;
    private VisualMappingManager visualMappingManager;
    private CyApplicationManager cyApplicationManager;
    private DialogTaskManager dialogTaskManager;

    public static Neo4jRESTServer create(ServiceLocator serviceLocator) {
        Neo4jRESTServer neo4jRESTServer = new Neo4jRESTServer();
        neo4jRESTServer.cyApplicationManager = serviceLocator.getService(CyApplicationManager.class);
        neo4jRESTServer.cyNetworkFactory = serviceLocator.getService(CyNetworkFactory.class);
        neo4jRESTServer.cyNetViewMgr = serviceLocator.getService(CyNetworkViewManager.class);
        neo4jRESTServer.cyNetworkViewFactory = serviceLocator.getService(CyNetworkViewFactory.class);
        neo4jRESTServer.cyLayoutAlgorithmManager = serviceLocator.getService(CyLayoutAlgorithmManager.class);
        neo4jRESTServer.visualMappingManager = serviceLocator.getService(VisualMappingManager.class);
        neo4jRESTServer.cyApplicationManager = serviceLocator.getService(CyApplicationManager.class);
        neo4jRESTServer.dialogTaskManager = serviceLocator.getService(DialogTaskManager.class);
        return neo4jRESTServer;
    }

    private Neo4jRESTServer() {
    }

    public void connect(String instanceLocation) {
        if (isConnected()) {
            this.instanceLocation = null;
        }
        if (validateConnection(instanceLocation)) {
            this.instanceLocation = instanceLocation;
        }
    }

    public boolean isConnected() {
        return validateConnection(getInstanceLocation());
    }

    public String getInstanceLocation() {
        return instanceLocation;
    }

    public void syncDown() {
        TaskIterator it = new TaskIterator(new SyncDownTask(
            getCypherURL(),
            getInstanceLocation(),<commit_msg>Minor change<commit_after>package nl.maastrichtuniversity.networklibrary.cyneo4j.internal.serviceprovider;

import nl.maastrichtuniversity.networklibrary.cyneo4j.internal.ServiceLocator;
import nl.maastrichtuniversity.networklibrary.cyneo4j.internal.extensionlogic.neo4j.Neo4jCall;
import nl.maastrichtuniversity.networklibrary.cyneo4j.internal.serviceprovider.extension.PassThroughResponseHandler;
import nl.maastrichtuniversity.networklibrary.cyneo4j.internal.serviceprovider.general.Neo4jPingHandler;
import nl.maastrichtuniversity.networklibrary.cyneo4j.internal.serviceprovider.sync.SyncDownTask;
import nl.maastrichtuniversity.networklibrary.cyneo4j.internal.serviceprovider.sync.SyncUpTask;
import org.apache.http.client.fluent.Request;
import org.cytoscape.application.CyApplicationManager;
import org.cytoscape.model.CyNetwork;
import org.cytoscape.model.CyNetworkFactory;
import org.cytoscape.model.CyNetworkManager;
import org.cytoscape.view.layout.CyLayoutAlgorithmManager;
import org.cytoscape.view.model.CyNetworkViewFactory;
import org.cytoscape.view.model.CyNetworkViewManager;
import org.cytoscape.view.vizmap.VisualMappingManager;
import org.cytoscape.work.TaskIterator;
import org.cytoscape.work.swing.DialogTaskManager;

import java.io.IOException;

import static org.apache.http.entity.ContentType.APPLICATION_JSON;

public class Neo4jRESTServer {

    private static final String DATA_URL = "/db/data/";
    private static final String CYPHER_URL = DATA_URL + "cypher";

    private String instanceLocation = null;
    private CyNetworkManager cyNetworkManager;
    private CyNetworkFactory cyNetworkFactory;
    private CyNetworkViewManager cyNetViewMgr;
    private CyNetworkViewFactory cyNetworkViewFactory;
    private CyLayoutAlgorithmManager cyLayoutAlgorithmManager;
    private VisualMappingManager visualMappingManager;
    private CyApplicationManager cyApplicationManager;
    private DialogTaskManager dialogTaskManager;

    public static Neo4jRESTServer create(ServiceLocator serviceLocator) {
        Neo4jRESTServer neo4jRESTServer = new Neo4jRESTServer();
        neo4jRESTServer.cyApplicationManager = serviceLocator.getService(CyApplicationManager.class);
        neo4jRESTServer.cyNetworkFactory = serviceLocator.getService(CyNetworkFactory.class);
        neo4jRESTServer.cyNetViewMgr = serviceLocator.getService(CyNetworkViewManager.class);
        neo4jRESTServer.cyNetworkViewFactory = serviceLocator.getService(CyNetworkViewFactory.class);
        neo4jRESTServer.cyLayoutAlgorithmManager = serviceLocator.getService(CyLayoutAlgorithmManager.class);
        neo4jRESTServer.visualMappingManager = serviceLocator.getService(VisualMappingManager.class);
        neo4jRESTServer.cyApplicationManager = serviceLocator.getService(CyApplicationManager.class);
        neo4jRESTServer.dialogTaskManager = serviceLocator.getService(DialogTaskManager.class);
        return neo4jRESTServer;
    }

    private Neo4jRESTServer() {
    }

    public void connect(String instanceLocation) {
        if (validateConnection(this.instanceLocation)) {
            this.instanceLocation = null;
        }
        if (validateConnection(instanceLocation)) {
            this.instanceLocation = instanceLocation;
        }
    }

    public boolean isConnected() {
        return validateConnection(getInstanceLocation());
    }

    public String getInstanceLocation() {
        return instanceLocation;
    }

    public void syncDown() {
        TaskIterator it = new TaskIterator(new SyncDownTask(
            getCypherURL(),
            getInstanceLocation(),
{'fraction_non_alphanumeric': 0.07139863071119185, 'fraction_numerical': 0.00698616738857063, 'mean_word_length': 5.133676092544987, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '6822116', 'n_tokens_mistral': 2047, 'n_tokens_neox': 1930, 'n_words': 292}