List of usage examples for com.fasterxml.jackson.databind.node ObjectNode put
public ObjectNode put(String paramString1, String paramString2)
From source file:controllers.Rules.java
@Security.Authenticated(Secured.class) public static Promise<Result> details(String name) { ObjectNode properties = Json.newObject(); properties.put("name", name); Promise<Rule> requestedRule = Rule.nodes.full(properties); return requestedRule.map(new Function<Rule, Result>() { public Result apply(Rule requestedRule) { return ok(details.render(requestedRule)); }//from ww w . ja va2 s . c om }); }
From source file:controllers.Rules.java
@Security.Authenticated(Secured.class) public static Promise<Result> similar(String name) { ObjectNode properties = Json.newObject(); properties.put("name", name); Promise<List<Rule>> ruleList = Rule.nodes.similar(properties); return ruleList.map(new Function<List<Rule>, Result>() { public Result apply(List<Rule> ruleList) { return ok(browse.render(ruleList)); }/*from w w w . ja v a 2 s . co m*/ }); }
From source file:controllers.Rules.java
@Security.Authenticated(Secured.class) @BodyParser.Of(BodyParser.Json.class) public static Promise<Result> addString(String name, String groupID) { JsonNode json = request().body().asJson(); ObjectNode group = Json.newObject(); group.put("uuid", groupID); ObjectNode string = Json.newObject(); String uuid = UUIDGenerator.from(json.get("content").asText()); string.put("uuid", uuid); string.put("content", json.get("content").asText()); Promise<Boolean> connected = CombinationGroup.nodes.connect(group, string); ObjectNode result = Json.newObject(); result.put("id", uuid); return connected.map(new ResultFunction("String successfully added.", "String not added.", result)); }
From source file:controllers.Rules.java
@Security.Authenticated(Secured.class) public static Promise<Result> output(final String name) { Promise<List<Part>> globalPartsList = Part.nodes.all(); ObjectNode properties = Json.newObject(); properties.put("name", name); Promise<Rule> rule = Rule.nodes.full(properties); Promise<Tuple<List<Part>, Rule>> results = globalPartsList.zip(rule); return results.map(new Function<Tuple<List<Part>, Rule>, Result>() { public Result apply(Tuple<List<Part>, Rule> results) { return ok(output.render(results._1, results._2)); }/*from w w w .j ava2s. co m*/ }); }
From source file:controllers.Rules.java
@Security.Authenticated(Secured.class) @BodyParser.Of(BodyParser.Json.class) public static Promise<Result> removeGroup(String name, final String groupID) { ObjectNode properties = Json.newObject(); properties.put("name", name); Promise<Rule> rule = Rule.nodes.get(properties); Promise<Boolean> removed = rule.flatMap(new Function<Rule, Promise<Boolean>>() { public Promise<Boolean> apply(Rule rule) { String uuid = UUIDGenerator.from(rule.uuid); ObjectNode rhs = Json.newObject(); rhs.put("uuid", uuid); ObjectNode group = Json.newObject(); group.put("uuid", groupID); return RHS.nodes.disconnect(rhs, group); }//from w ww. ja v a 2 s .com }); return removed.map(new ResultFunction("Group successfully removed.", "Group not removed.")); }
From source file:controllers.Rules.java
@Security.Authenticated(Secured.class) @BodyParser.Of(BodyParser.Json.class) public static Promise<Result> updatePart(String name, String groupID, String slotID, String partID) { JsonNode json = request().body().asJson(); final ObjectNode slot = Json.newObject(); slot.put("uuid", slotID); final ObjectNode oldPart = Json.newObject(); oldPart.put("uuid", partID); ObjectNode newPart = Json.newObject(); String content = json.findValue("content").asText(); String uuid = UUIDGenerator.from(content); newPart.put("content", content); newPart.put("uuid", uuid); final ObjectNode result = Json.newObject(); result.put("id", uuid); Promise<Boolean> updated = Slot.nodes.update(slot, oldPart, newPart); return updated.map(new ResultFunction("Part successfully updated.", "Part not updated.", result)); }
From source file:controllers.Rules.java
@Security.Authenticated(Secured.class) @BodyParser.Of(BodyParser.Json.class) public static Promise<Result> updateString(String name, String groupID, String stringID) { JsonNode json = request().body().asJson(); final ObjectNode group = Json.newObject(); group.put("uuid", groupID); final ObjectNode oldString = Json.newObject(); oldString.put("uuid", stringID); ObjectNode newString = Json.newObject(); String content = json.findValue("content").asText(); String uuid = UUIDGenerator.from(content); newString.put("content", content); newString.put("uuid", uuid); final ObjectNode result = Json.newObject(); result.put("id", uuid); Promise<Boolean> updated = CombinationGroup.nodes.update(group, oldString, newString); return updated.map(new ResultFunction("String successfully updated.", "String not updated.", result)); }
From source file:controllers.Rules.java
@Security.Authenticated(Secured.class) @BodyParser.Of(BodyParser.Json.class) public static Promise<Result> removeFeature(String name) { JsonNode json = request().body().asJson(); ObjectNode avm = (ObjectNode) json.deepCopy(); avm.retain("ruleUUID", "uuid"); ObjectNode feature = Json.newObject(); feature.put("name", json.findValue("name").asText()); feature.put("type", json.findValue("type").asText()); Promise<Boolean> removed = Substructure.nodes.disconnect(avm, feature); return removed.map(new Function<Boolean, Result>() { ObjectNode result = Json.newObject(); public Result apply(Boolean removed) { if (removed) { result.put("message", "Feature successfully removed."); return ok(result); }//from ww w. ja v a2s .com result.put("message", "Feature not removed."); return badRequest(result); } }); }
From source file:controllers.Rules.java
@Security.Authenticated(Secured.class) @BodyParser.Of(BodyParser.Json.class) public static Promise<Result> addRef(String name, String groupID, String slotID) { JsonNode json = request().body().asJson(); String ruleName = json.findValue("ruleName").asText(); Promise<Boolean> added; if (name.equals(ruleName)) { added = Promise.pure(false);/* w ww.j a va2 s . c o m*/ return added.map( new ResultFunction("Cross-reference successfully added.", "Can't add circular dependency.")); } else { ObjectNode result = Json.newObject(); result.put("id", ruleName); ObjectNode slot = Json.newObject(); slot.put("uuid", slotID); ObjectNode rule = Json.newObject(); rule.put("name", ruleName); added = Slot.nodes.connect(slot, rule); return added.map(new ResultFunction("Cross-reference successfully added.", "Cross-reference not added.", result)); } }
From source file:com.github.fge.jsonschema.process.Index.java
private static JsonNode buildResult(final String rawSchema, final String rawData) throws IOException { final ObjectNode ret = JsonNodeFactory.instance.objectNode(); final boolean invalidSchema = fillWithData(ret, INPUT, INVALID_INPUT, rawSchema); final boolean invalidData = fillWithData(ret, INPUT2, INVALID_INPUT2, rawData); final JsonNode schemaNode = ret.remove(INPUT); final JsonNode data = ret.remove(INPUT2); if (invalidSchema || invalidData) return ret; final ProcessingReport report = VALIDATOR.validateUnchecked(schemaNode, data); final boolean success = report.isSuccess(); ret.put(VALID, success); final JsonNode node = ((AsJson) report).asJson(); ret.put(RESULTS, JacksonUtils.prettyPrint(node)); return ret;/* w w w.j a va 2 s . com*/ }