Refine search
protected ObjectNode createSchemaNode(String type) { ObjectNode schema = JsonNodeFactory.instance.objectNode(); schema.put("type", type); return schema; }
private Response jsonSuccessResponse(Object result, float took) { ObjectNode json = JsonNodeFactory.instance.objectNode(); json.putPOJO("polygons", result); // If you replace GraphHopper with your own brand name, this is fine. // Still it would be highly appreciated if you mention us in your about page! final ObjectNode info = json.putObject("info"); info.putArray("copyrights") .add("GraphHopper") .add("OpenStreetMap contributors"); info.put("took", Math.round(took * 1000)); return Response.ok(json).build(); } }
@Override public void serialize(MultiException e, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException { List<Throwable> errors = e.getErrors(); ObjectNode json = JsonNodeFactory.instance.objectNode(); json.put("message", getMessage(errors.get(0))); ArrayNode errorHintList = json.putArray("hints"); for (Throwable t : errors) { ObjectNode error = errorHintList.addObject(); error.put("message", getMessage(t)); error.put("details", t.getClass().getName()); if (t instanceof GHException) { ((GHException) t).getDetails().forEach(error::putPOJO); } } jsonGenerator.writeObject(json); }
/** * Get the default schema node. * * @return The default schema node. */ public static JsonNode getDefaultSchemaNode() { ObjectNode objectNode = JsonNodeFactory.instance.objectNode(); objectNode.put("type", "any"); // "required" is false by default, no need to include //objectNode.put("required", false); return objectNode; }
@Override public JsonNode digest(final JsonNode schema) { final ObjectNode ret = FACTORY.objectNode(); ret.put(keyword, schema.get(keyword)); return ret; } }
JsonNodeFactory nodeFactory = new JsonNodeFactory(); ObjectNode node = nodeFactory.objectNode(); ObjectNode child = nodeFactory.objectNode(); // the child child.put("message", "test"); // etc etc // and then: node.put("notification", child);
protected ObjectNode link(String appUrl, Type type) { ObjectNode result = nodeFactory.objectNode(); result.put("href", generateTemplatedUri(appUrl, type)); result.put("templated", true); return result; }
public static String groupName( IMetaStoreElementType elementType ) { ObjectNode objectNode = JsonNodeFactory.instance.objectNode(); objectNode.put( "_", "Embedded MetaStore Elements" ); objectNode.put( "namespace", Preconditions.checkNotNull( elementType.getNamespace() ) ); objectNode.put( "type", Preconditions.checkNotNull( elementType.getId() ) ); return objectNode.toString(); }
@Override public JsonNode digest(final JsonNode schema) { // TODO: return an array directly (same for "required" in v4) final ObjectNode ret = FACTORY.objectNode(); final ArrayNode required = FACTORY.arrayNode(); ret.put("required", required); final JsonNode node = schema.get(keyword); final List<String> list = Lists.newArrayList(node.fieldNames()); Collections.sort(list); for (final String field: list) if (node.get(field).path("required").asBoolean(false)) required.add(field); return ret; } }
protected ObjectNode mapType(Type type) { ObjectNode result = mapValue(type); result.put("action", type.getAction()); ObjectNode tags = nodeFactory.objectNode(); type.getTags().forEach(tags::put); result.set("tags", tags); return result; }
@Override protected JsonNode generateSchema() { final ObjectNode value = FACTORY.objectNode(); value.put("a", sub1); value.put("b", sub2); final ObjectNode ret = FACTORY.objectNode(); ret.put(keyword, value); return ret; }
protected void type(ObjectNode parent, TypeCapability capability) { ObjectNode type = nodeFactory.objectNode(); type.put("type", "action"); Type defaultType = capability.getDefault(); if (defaultType != null) { type.put("default", defaultType.getId()); } ArrayNode values = nodeFactory.arrayNode(); values.addAll(capability.getContent().stream().map(this::mapType) .collect(Collectors.toList())); type.set("values", values); parent.set("type", type); }
private static JsonNode mapRepository(Repository repo) { ObjectNode node = nodeFactory.objectNode(); node.put("name", repo.getName()) .put("url", (repo.getUrl() != null) ? repo.getUrl().toString() : null) .put("snapshotEnabled", repo.isSnapshotsEnabled()); return node; }
public SchemaDigesterTest() { schema = FACTORY.objectNode(); schema.put(K1, K1); schema.put(K2, K2); }
private ObjectNode dependenciesLink(String appUrl) { String uri = (appUrl != null) ? appUrl + "/dependencies" : "/dependencies"; UriTemplate uriTemplate = new UriTemplate(uri, this.dependenciesVariables); ObjectNode result = nodeFactory().objectNode(); result.put("href", uriTemplate.toString()); result.put("templated", true); return result; }
protected void text(ObjectNode parent, TextCapability capability) { ObjectNode text = nodeFactory.objectNode(); text.put("type", capability.getType().getName()); String defaultValue = capability.getContent(); if (StringUtils.hasText(defaultValue)) { text.put("default", defaultValue); } parent.set(capability.getId(), text); }
@Override protected JsonNode generateInstance() { final ObjectNode ret = FACTORY.objectNode(); ret.put("a", "a"); ret.put("b", "b"); return ret; }
protected void dependencies(ObjectNode parent, DependenciesCapability capability) { ObjectNode dependencies = nodeFactory.objectNode(); dependencies.put("type", capability.getType().getName()); ArrayNode values = nodeFactory.arrayNode(); values.addAll(capability.getContent().stream().map(this::mapDependencyGroup) .collect(Collectors.toList())); dependencies.set("values", values); parent.set(capability.getId(), dependencies); }
protected ObjectNode mapValue(MetadataElement value) { ObjectNode result = nodeFactory.objectNode(); result.put("id", value.getId()); result.put("name", value.getName()); if ((value instanceof Describable) && ((Describable) value).getDescription() != null) { result.put("description", ((Describable) value).getDescription()); } return result; }
private ObjectNode readSchema(URL schemaUrl) { switch (ruleFactory.getGenerationConfig().getSourceType()) { case JSONSCHEMA: case YAMLSCHEMA: ObjectNode schemaNode = NODE_FACTORY.objectNode(); schemaNode.put("$ref", schemaUrl.toString()); return schemaNode; case JSON: case YAML: return schemaGenerator.schemaFromExample(schemaUrl); default: throw new IllegalArgumentException("Unrecognised source type: " + ruleFactory.getGenerationConfig().getSourceType()); } }