List of usage examples for com.fasterxml.jackson.databind.node ObjectNode put
public ObjectNode put(String paramString1, String paramString2)
From source file:controllers.bank.Banks.java
public static Result investigation(Integer id) { Result hasProblem = AuthManager.hasProblem(RIGHT_SCOPE, RightLevel.Enable); if (hasProblem != null) return hasProblem; Bank bank = Bank.findById(id);/*from ww w. j av a2 s . c om*/ ObjectNode result = Json.newObject(); result.put("title", bank.name); result.put("body", investigation_form.render(QueryUtils.inspectXTrans(Module.bank, bank.id), QueryUtils.inspectXSummary(Module.bank, bank.id), null, null).body()); return ok(result); }
From source file:com.msopentech.odatajclient.testservice.utils.Commons.java
public static InputStream getLinksAsJSON(final String entitySetName, final Map.Entry<String, Collection<String>> link) throws IOException { final ObjectNode links = new ObjectNode(JsonNodeFactory.instance); links.put(JSON_ODATAMETADATA_NAME, ODATA_METADATA_PREFIX + entitySetName + "/$links/" + link.getKey()); final ArrayNode uris = new ArrayNode(JsonNodeFactory.instance); for (String uri : link.getValue()) { final String absoluteURI; if (URI.create(uri).isAbsolute()) { absoluteURI = uri;/* w w w .ja v a2 s. c om*/ } else { absoluteURI = DEFAULT_SERVICE_URL + uri; } uris.add(new ObjectNode(JsonNodeFactory.instance).put("url", absoluteURI)); } if (uris.size() == 1) { links.setAll((ObjectNode) uris.get(0)); } else { links.set("value", uris); } return IOUtils.toInputStream(links.toString()); }
From source file:com.nirmata.workflow.details.JsonSerializer.java
public static JsonNode newTask(Task task) { RunnableTaskDagBuilder builder = new RunnableTaskDagBuilder(task); ArrayNode tasks = newArrayNode();/*from w w w. jav a 2 s . c o m*/ builder.getTasks().values().forEach(thisTask -> { ObjectNode node = newNode(); node.put("taskId", thisTask.getTaskId().getId()); node.set("taskType", thisTask.isExecutable() ? newTaskType(thisTask.getTaskType()) : null); node.putPOJO("metaData", thisTask.getMetaData()); node.put("isExecutable", thisTask.isExecutable()); List<String> childrenTaskIds = thisTask.getChildrenTasks().stream().map(t -> t.getTaskId().getId()) .collect(Collectors.toList()); node.putPOJO("childrenTaskIds", childrenTaskIds); tasks.add(node); }); ObjectNode node = newNode(); node.put("rootTaskId", task.getTaskId().getId()); node.set("tasks", tasks); return node; }
From source file:mobile.service.UserService.java
/** * ?/*from w w w . ja va2 s.c o m*/ * * @return */ public static List<CommonVO> getIndustryTagList() { List<SkillTag> skillTags = SkillTag.getCategoryTag(true); List<CommonVO> list = new ArrayList<CommonVO>(); if (skillTags.size() > 0) { for (SkillTag tags : skillTags) { CommonVO commonVO = CommonVO.create(); commonVO.set("id", tags.id); commonVO.set("tagName", tags.tagName); List<Attach> attachList = new AttachOfIndustry().queryByAttachId(tags.getId()); ArrayNode arrayNode = Json.newObject().arrayNode(); for (Attach attach : attachList) { ObjectNode attachNode = Json.newObject(); attachNode.put("filename", attach.fileName); attachNode.put("url", Assets.at(attach.path)); arrayNode.add(attachNode); } commonVO.set("attachs", arrayNode); list.add(commonVO); } } return list; }
From source file:controllers.api.v1.User.java
public static Result updateSettings() { Map<String, String[]> params = request().body().asFormUrlEncoded(); ObjectNode result = Json.newObject(); String username = session("user"); if (StringUtils.isNotBlank(username)) { String message = UserDAO.updateUserSettings(params, username); if (StringUtils.isBlank(message)) { result.put("status", "success"); } else {//from w w w .j ava 2 s . c om result.put("status", "failed"); result.put("message", message); } } else { result.put("status", "failed"); result.put("message", "User is not authenticated"); } return ok(result); }
From source file:org.apache.taverna.activities.wsdl.xmlsplitter.XMLSplitterConfigurationBeanBuilder.java
public static JsonNode buildBeanForInput(Element element) throws JDOMException, IOException { ObjectNode bean = JSON_NODE_FACTORY.objectNode(); ArrayNode inputDefinitions = bean.arrayNode(); bean.put("inputPorts", inputDefinitions); ArrayNode outputDefinitions = bean.arrayNode(); bean.put("outputPorts", outputDefinitions); TypeDescriptor descriptor = XMLSplitterSerialisationHelper.extensionXMLToTypeDescriptor(element); ObjectNode outBean = outputDefinitions.addObject(); outBean.put("name", "output"); outBean.put("mimeType", "'text/xml'"); outBean.put("depth", 0); outBean.put("granularDepth", 0); if (descriptor instanceof ComplexTypeDescriptor) { List<TypeDescriptor> elements = ((ComplexTypeDescriptor) descriptor).getElements(); String[] names = new String[elements.size()]; Class<?>[] types = new Class<?>[elements.size()]; TypeDescriptor.retrieveSignature(elements, names, types); for (int i = 0; i < names.length; i++) { ObjectNode portBean = inputDefinitions.addObject(); portBean.put("name", names[i]); portBean.put("mimeType", TypeDescriptor.translateJavaType(types[i])); portBean.put("depth", depthForDescriptor(elements.get(i))); }//w w w . j a v a 2 s. c o m List<TypeDescriptor> attributes = ((ComplexTypeDescriptor) descriptor).getAttributes(); String[] elementNames = Arrays.copyOf(names, names.length); Arrays.sort(elementNames); String[] attributeNames = new String[attributes.size()]; Class<?>[] attributeTypes = new Class<?>[attributes.size()]; TypeDescriptor.retrieveSignature(attributes, attributeNames, attributeTypes); for (int i = 0; i < attributeNames.length; i++) { ObjectNode portBean = inputDefinitions.addObject(); if (Arrays.binarySearch(elementNames, attributeNames[i]) < 0) { portBean.put("name", attributeNames[i]); } else { portBean.put("name", "1" + attributeNames[i]); } portBean.put("mimeType", TypeDescriptor.translateJavaType(attributeTypes[i])); portBean.put("depth", depthForDescriptor(attributes.get(i))); } } else if (descriptor instanceof ArrayTypeDescriptor) { ObjectNode portBean = inputDefinitions.addObject(); portBean.put("name", descriptor.getName()); if (((ArrayTypeDescriptor) descriptor).getElementType() instanceof BaseTypeDescriptor) { portBean.put("mimeType", "l('text/plain')"); } else { portBean.put("mimeType", "l('text/xml')"); } portBean.put("depth", 1); } String wrappedType = new XMLOutputter().outputString(element); bean.put("wrappedType", wrappedType); return bean; }
From source file:org.inaetics.pubsub.demo.config.EtcdWrapper.java
private static JsonNode AddEtcdIndex(JsonNode node, long index) { ObjectNode objectNode = (ObjectNode) node; objectNode.put("EtcdIndex", index); return objectNode; }
From source file:org.jetbrains.webdemo.ResponseUtils.java
public static ObjectNode getErrorAsJsonNode(String error) { ObjectNode result = new ObjectNode(JsonNodeFactory.instance); result.put("type", "err"); result.put("exception", error); return result; }
From source file:com.github.fge.jsonschema.core.keyword.syntax.checkers.SyntaxCheckersTest.java
private static SchemaTree treeFromValue(final String keyword, final JsonNode node) { final ObjectNode schema = JacksonUtils.nodeFactory().objectNode(); schema.put(keyword, node); return new CanonicalSchemaTree(SchemaKey.anonymousKey(), schema); }
From source file:org.jetbrains.webdemo.ResponseUtils.java
public static ObjectNode getErrorWithStackTraceAsJsonNode(String error, String stackTrace) { ObjectNode result = new ObjectNode(JsonNodeFactory.instance); result.put("type", "err"); result.put("exception", error); result.put("stackTrace", stackTrace); return result; }