use of water.util.RString in project h2o-2 by h2oai.
the class SetColumnNames2 method link.
public static String link(Key k, String content) {
RString rs = new RString("<a href='SetColumnNames2.query?source=%$key'>" + content + "</a>");
rs.replace("key", k.toString());
return rs.toString();
}
use of water.util.RString in project h2o-2 by h2oai.
the class RequestBuilders method buildResponseHeader.
protected String buildResponseHeader(Response response) {
RString result = new RString(_responseHeader);
JsonObject obj = response.responseToJson();
result.replace("CLOUD_NAME", obj.get(JSON_H2O).getAsString());
result.replace("NODE_NAME", obj.get(NODE).getAsString());
result.replace("TIME", PrettyPrint.msecs(obj.get(REQUEST_TIME).getAsLong(), true));
switch(response._status) {
case error:
result.replace("BUTTON", "<button class='btn btn-danger disabled'>" + response._status.toString() + "</button>");
result.replace("TEXT", "An error has occurred during the creation of the response. Details follow:");
break;
case done:
//result.replace("BUTTON","<button class='btn btn-success disabled'>"+response._status.toString()+"</button>");
//result.replace("TEXT","The result was a success and no further action is needed. JSON results are prettyprinted below.");
result = new RString("");
break;
case redirect:
result.replace("BUTTON", "<button class='btn btn-primary' onclick='redirect()'>" + response._status.toString() + "</button>");
result.replace("TEXT", "Request was successful and the process was started. You will be redirected to the new page in 1 seconds, or when you click on the redirect" + " button on the left. If you want to keep this page for longer you can <a href='#' onclick='countdown_stop()'>stop the countdown</a>.");
RString redirect = new RString(_redirectJs);
redirect.replace("REDIRECT_URL", response._redirectName + ".html" + encodeRedirectArgs(response._redirectArgs, response._redirArgs));
result.replace("JSSTUFF", redirect.toString());
break;
case poll:
if (response._redirectArgs != null) {
RString poll = new RString(_redirectJs);
poll.replace("REDIRECT_URL", requestName() + ".html" + encodeRedirectArgs(response._redirectArgs, response._redirArgs));
result.replace("JSSTUFF", poll.toString());
} else {
RString poll = new RString(_pollJs);
poll.replace("TIMEOUT", response._pollProgress == 0 ? 4500 : 5000);
result.replace("JSSTUFF", poll.toString());
}
int pct = (int) ((double) response._pollProgress / response._pollProgressElements * 100);
result.replace("BUTTON", "<button class='btn btn-primary' onclick='redirect()'>" + response._status.toString() + "</button>");
result.replace("TEXT", "<div style='margin-bottom:0px;padding-bottom:0xp;height:5px;' class='progress progress-stripped'><div class='bar' style='width:" + pct + "%;'></div></div>" + "Request was successful, but the process has not yet finished. The page will refresh every 5 seconds, or you can click the button" + " on the left. If you want you can <a href='#' onclick='countdown_stop()'>disable the automatic refresh</a>.");
break;
default:
result.replace("BUTTON", "<button class='btn btn-inverse disabled'>" + response._status.toString() + "</button>");
result.replace("TEXT", "This is an unknown response state not recognized by the automatic formatter. The rest of the response is displayed below.");
break;
}
return result.toString();
}
use of water.util.RString in project h2o-2 by h2oai.
the class GLMPredict method link.
public static String link(Key k, double lambda, String content) {
RString rs = new RString("<a href='GLMPredict.query?model=%$key&lambda=%lambda'>%content</a>");
rs.replace("key", k.toString());
rs.replace("lambda", lambda);
rs.replace("content", content);
return rs.toString();
}
use of water.util.RString in project h2o-2 by h2oai.
the class HTTP404 method build.
@Override
protected String build(Response response) {
StringBuilder sb = new StringBuilder();
sb.append("<div class='container'>");
sb.append("<div class='row-fluid'>");
sb.append("<div class='span12'>");
sb.append(buildResponseHeader(response));
RString str = new RString(_html);
str.replace("ERROR", response.error());
sb.append(str.toString());
sb.append("</div></div></div>");
return sb.toString();
}
use of water.util.RString in project h2o-2 by h2oai.
the class HTTP500 method build.
@Override
protected String build(Response response) {
StringBuilder sb = new StringBuilder();
sb.append("<div class='container'>");
sb.append("<div class='row-fluid'>");
sb.append("<div class='span12'>");
sb.append(buildResponseHeader(response));
RString str = new RString(_html);
str.replace("ERROR", response.error());
sb.append(str.toString());
sb.append("</div></div></div>");
return sb.toString();
}
Aggregations