use of org.apache.jena.atlas.json.JsonArray in project jena by apache.
the class StatsServlet method statsJSON.
private void statsJSON(JsonObject datasets, String ds) {
DatasetRef desc = DatasetRegistry.get().get(ds);
JsonObject stats = new JsonObject();
datasets.put(ds, stats);
stats.put(CounterName.Requests.name(), desc.getCounters().value(CounterName.Requests));
stats.put(CounterName.RequestsGood.name(), desc.getCounters().value(CounterName.RequestsGood));
stats.put(CounterName.RequestsBad.name(), desc.getCounters().value(CounterName.RequestsBad));
JsonObject services = new JsonObject();
// There can be several endpoints for one service.
for (ServiceRef srvRef : desc.getServiceRefs()) {
JsonObject epStats = new JsonObject();
statsJSON(epStats, srvRef);
services.put(srvRef.name, epStats);
JsonArray endpoints = new JsonArray();
epStats.put("endpoints", endpoints);
for (String ep : srvRef.endpoints) {
endpoints.add(ep);
}
}
stats.put("services", services);
}
use of org.apache.jena.atlas.json.JsonArray in project jena by apache.
the class StoreParamsCodec method getStringArray.
private static String[] getStringArray(JsonObject json, String key) {
if (!json.hasKey(key))
throw new TDBException("StoreParamsCodec.getStringArray: no such key: " + key);
JsonArray a = json.get(key).getAsArray();
String[] x = new String[a.size()];
for (int i = 0; i < a.size(); i++) {
x[i] = a.get(i).getAsString().value();
}
return x;
}
use of org.apache.jena.atlas.json.JsonArray in project jena by apache.
the class TestAdmin method checkJsonDatasetsAll.
private static void checkJsonDatasetsAll(JsonValue v) {
assertNotNull(v.getAsObject().get("datasets"));
JsonArray a = v.getAsObject().get("datasets").getAsArray();
for (JsonValue v2 : a) checkJsonDatasetsOne(v2);
}
use of org.apache.jena.atlas.json.JsonArray in project jena by apache.
the class TestAdmin method checkInTasks.
private static void checkInTasks(String x) {
String url = ServerCtl.urlRoot() + "$/tasks";
JsonValue v = httpGetJson(url);
assertTrue(v.isArray());
JsonArray array = v.getAsArray();
int found = 0;
for (int i = 0; i < array.size(); i++) {
JsonValue jv = array.get(i);
assertTrue(jv.isObject());
JsonObject obj = jv.getAsObject();
checkTask(obj);
if (obj.get("taskId").getAsString().value().equals(x)) {
found++;
}
}
assertEquals("Occurence of taskId count", 1, found);
}
use of org.apache.jena.atlas.json.JsonArray in project jena by apache.
the class JSONInput method parseVars.
private List<Var> parseVars(JsonObject obj) {
if (!obj.get(kVars).isArray())
throw new ResultSetException("Key 'vars' must be a JSON array");
JsonArray a = obj.get(kVars).getAsArray();
Iterator<JsonValue> iter = a.iterator();
List<Var> vars = new ArrayList<>();
for (; iter.hasNext(); ) {
JsonValue v = iter.next();
if (!v.isString())
throw new ResultSetException("Entries in vars array must be strings");
Var var = Var.alloc(v.getAsString().value());
vars.add(var);
}
return vars;
}
Aggregations