Search in sources :

Example 36 with JsonObject

use of dontweave.gson.JsonObject in project h2o-2 by h2oai.

the class Remove method serve.

@Override
protected Response serve() {
    try {
        Lockable.delete(_key.value()._key);
    } catch (Throwable e) {
        return Response.error(e);
    }
    JsonObject response = new JsonObject();
    response.addProperty(KEY, _key.toString());
    return Response.redirect(response, StoreView.class, null);
}
Also used : JsonObject(dontweave.gson.JsonObject)

Example 37 with JsonObject

use of dontweave.gson.JsonObject in project h2o-2 by h2oai.

the class RemoveAck method serve.

@Override
protected Response serve() {
    Value v = _key.value();
    String key = v._key.toString();
    JsonObject response = new JsonObject();
    response.addProperty(RequestStatics.KEY, key);
    Response r = Response.done(new JsonObject());
    r.addHeader(//
    "" + "<div class='alert alert-error'>Are you sure you want to delete key <strong>" + key + //
    "</strong>?<br/>" + //
    "There is no way back!" + //
    "</div>" + //
    "<div style='text-align:center'>" + //
    "<a href='javascript:history.back()'><button class='btn btn-primary'>No, go back</button></a>" + //
    "&nbsp;&nbsp;&nbsp;" + "<a href='Remove.html?" + KEY + "=" + key + //
    "'><button class='btn btn-danger'>Yes!</button></a>" + "</div>");
    return r;
}
Also used : Value(water.Value) JsonObject(dontweave.gson.JsonObject)

Example 38 with JsonObject

use of dontweave.gson.JsonObject in project h2o-2 by h2oai.

the class ExportHdfs method serve.

@Override
protected Response serve() {
    Value value = _source.value();
    String path = _path.value();
    try {
        if (value == null)
            throw new IllegalArgumentException("Unknown key: " + _source.record()._originalValue);
        byte[] data = null;
        Model model = getAsModel(value);
        if (model != null) {
            // Add extension, used during import
            if (!path.endsWith(Extensions.JSON))
                path += Extensions.JSON;
            data = model.writeJSON(new AutoBuffer()).buf();
        }
        if (data != null)
            PersistHdfs.store(new Path(path), data);
        else
            throw new UnsupportedOperationException("Only models can be exported");
    } catch (Throwable e) {
        return Response.error(e);
    }
    JsonObject json = new JsonObject();
    Response r = Response.done(json);
    return r;
}
Also used : Path(org.apache.hadoop.fs.Path) JsonObject(dontweave.gson.JsonObject)

Example 39 with JsonObject

use of dontweave.gson.JsonObject in project h2o-2 by h2oai.

the class GetTimezone method serve.

@Override
protected Response serve() {
    String s = ParseTime.getTimezone().getID();
    JsonObject response = new JsonObject();
    response.addProperty("tz", s);
    return Response.done(response);
}
Also used : JsonObject(dontweave.gson.JsonObject)

Example 40 with JsonObject

use of dontweave.gson.JsonObject in project h2o-2 by h2oai.

the class Jobs method redirect.

public static Response redirect(JsonObject resp, Key dest) {
    JsonObject redir = new JsonObject();
    redir.addProperty(KEY, dest.toString());
    return Response.redirect(resp, Jobs.class, redir);
}
Also used : JsonObject(dontweave.gson.JsonObject)

Aggregations

JsonObject (dontweave.gson.JsonObject)41 JsonElement (dontweave.gson.JsonElement)5 JsonParser (dontweave.gson.JsonParser)4 JsonArray (dontweave.gson.JsonArray)3 Frame (water.fvec.Frame)3 Job (water.Job)2 Value (water.Value)2 JsonPrimitive (dontweave.gson.JsonPrimitive)1 JsonWriter (dontweave.gson.stream.JsonWriter)1 FileWriter (java.io.FileWriter)1 InputStreamReader (java.io.InputStreamReader)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 Date (java.util.Date)1 TimerTask (java.util.TimerTask)1 HttpClient (org.apache.commons.httpclient.HttpClient)1 GetMethod (org.apache.commons.httpclient.methods.GetMethod)1 Path (org.apache.hadoop.fs.Path)1 Key (water.Key)1 Timer (water.Timer)1 FrameSummary (water.api.Frames.FrameSummary)1