package no.altran.kpro2014.database;

import com.jayway.jsonpath.Configuration;
import com.jayway.jsonpath.JsonPath;
import org.json.simple.JSONValue;

import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.Invocation;
import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Request;
import javax.ws.rs.core.Response;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by audun on 10/1/14.
 */
public class ObservationGetter {
    String domain;
    String path;
    WebTarget queryResource;
    Client client;

    public ObservationGetter(String domain, String path){
        this.path = path;
        this.domain = domain;
        client = ClientBuilder.newClient();
        queryResource = client.target(domain);
    }

    public static List<Observation> toObservationList(String jsondata) {
        List<Observation> result = new ArrayList<Observation>();
        Object jsonDocument = Configuration.defaultConfiguration().jsonProvider().parse(jsondata);
        List observationObjectList = (List) JsonPath.read(jsonDocument, "$.observations[*]");
        String observationJson;
        Observation observation;
        for(Object observationObject : observationObjectList) {
            observationJson = JSONValue.toJSONString(observationObject);
            observation = Observation.fromLucene(null, null, observationJson);
            result.add(observation);
        }
        return result;
    }

    public void getQueryResult(String luceneQuery){
        String result = queryResource.queryParam("query", luceneQuery)
                .request(MediaType.APPLICATION_JSON)
                .get(String.class);

    }
}

@@ -522,24 +522,32 @@
 etter %7B%0A    
+private 
 String domai
@@ -549,24 +549,32 @@
 domain;%0A    
+private 
 String path;
@@ -578,16 +578,51 @@
 th;%0A    
+private Client client;%0A    private 
 WebTarge
@@ -642,26 +642,8 @@
 ce;%0A
-    Client client;
 %0A%0A  
@@ -702,34 +702,8 @@
 h)%7B%0A
-        this.path = path;%0A
     
@@ -724,24 +724,50 @@
 n = domain;%0A
+        this.path = path;%0A
         clie
@@ -845,23 +845,25 @@
 omain);%0A
-
     %7D%0A%0A
+%0A%0A
     publ

Make fields private.