List of usage examples for com.fasterxml.jackson.databind.node ObjectNode put
public ObjectNode put(String paramString1, String paramString2)
From source file:org.waarp.common.json.JsonHandler.java
/** * /*from w ww .j a v a2 s .c o m*/ * @param node * @param field * @param value */ public final static void setValue(ObjectNode node, Enum<?> field, int value) { node.put(field.name(), value); }
From source file:org.waarp.common.json.JsonHandler.java
/** * //www. j a v a 2 s . c o m * @param node * @param field * @param value */ public final static void setValue(ObjectNode node, Enum<?> field, long value) { node.put(field.name(), value); }
From source file:org.waarp.common.json.JsonHandler.java
/** * //ww w.j av a 2 s.c o m * @param node * @param field * @param value */ public final static void setValue(ObjectNode node, String field, double value) { node.put(field, value); }
From source file:org.waarp.common.json.JsonHandler.java
/** * // w w w .j ava 2 s .c o m * @param node * @param field * @param value */ public final static void setValue(ObjectNode node, String field, boolean value) { node.put(field, value); }
From source file:org.waarp.common.json.JsonHandler.java
/** * //from www. j av a 2 s . c om * @param node * @param field * @param value */ public final static void setValue(ObjectNode node, Enum<?> field, double value) { node.put(field.name(), value); }
From source file:org.waarp.common.json.JsonHandler.java
/** * // www. j a v a2s . co m * @param node * @param field * @param value */ public final static void setValue(ObjectNode node, Enum<?> field, boolean value) { node.put(field.name(), value); }
From source file:controllers.stock.Stocks.java
public static Result investigation(Integer id) { Result hasProblem = AuthManager.hasProblem(RIGHT_SCOPE, RightLevel.Enable); if (hasProblem != null) return hasProblem; Stock stock = Stock.findById(id);//from ww w . j av a 2 s . c o m List<Pair> properties = new ArrayList<Pair>(); properties.add(new Pair(Messages.get("stock.code"), stock.code)); properties.add(new Pair(Messages.get("name"), stock.name)); properties.add(new Pair(Messages.get("provider_code"), stock.providerCode)); properties.add(new Pair(Messages.get("units"), stock.unit1 + " / " + (stock.unit2 != null ? stock.unit2 + "( " + stock.unit2Ratio.toString() + " )" : "") + " / " + (stock.unit3 != null ? stock.unit3 + "( " + stock.unit3Ratio.toString() + " )" : ""))); properties.add(Pair.EMPTY); properties.add(new Pair(Messages.get("buy_price"), Format.asMoney(stock.buyPrice))); properties.add(new Pair(Messages.get("sell_price"), Format.asMoney(stock.sellPrice))); properties.add( new Pair(Messages.get("last_buy_price"), Format.asMoney(QueryUtils.findStockLastPrice(id, true)))); properties.add(new Pair(Messages.get("last_sell_price"), Format.asMoney(QueryUtils.findStockLastPrice(id, false)))); properties.add(Pair.EMPTY); properties.add( new Pair(Messages.get("prim_rate"), (stock.primRate != null ? stock.primRate.toString() : ""))); properties.add( new Pair(Messages.get("tax_both"), stock.buyTax.toString() + " / " + stock.sellTax.toString())); properties .add(new Pair(Messages.get("both.limit"), (stock.minLimit != null ? stock.minLimit.toString() : "") + " / " + (stock.minLimit != null ? stock.minLimit.toString() : ""))); ObjectNode result = Json.newObject(); result.put("title", stock.name); result.put("body", investigation_form .render(QueryUtils.inspectStockTrans(id), QueryUtils.inspectStockSummary(id), properties).body()); return ok(result); }
From source file:com.google.api.server.spi.tools.JacksonUtil.java
public static ObjectNode mergeObject(ObjectNode object1, ObjectNode object2, boolean throwOnConflict) { Iterator<String> fieldNames = object2.fieldNames(); while (fieldNames.hasNext()) { String fieldName = fieldNames.next(); JsonNode child2 = object2.get(fieldName); JsonNode child1 = object1.get(fieldName); JsonNode merged = (child1 == null) ? child2 : mergeNode(child1, child2, throwOnConflict); object1.put(fieldName, merged); }/*from ww w .j av a2 s .co m*/ return object1; }
From source file:com.github.fge.avro.translators.RecordTranslator.java
private static void injectDefault(final ObjectNode propertyNode, final Schema.Field field) { final JsonNode value = field.defaultValue(); if (value == null) return;//from w ww. ja va 2 s . com /* * Write the value to a string using a 1.8 writer, and read it from that * string using a 2.1 reader... Did you say "hack"? */ try { final String s = OLD_MAPPER.writeValueAsString(value); propertyNode.put("default", JsonLoader.fromString(s)); } catch (IOException ignored) { // cannot happen } }
From source file:dao.MetricsDAO.java
public static ObjectNode getPagedMetrics(String dashboardName, String group, Integer page, Integer size, String user) {//from ww w . j a v a2 s . c om Integer userId = UserDAO.getUserIDByUserName(user); final JdbcTemplate jdbcTemplate = getJdbcTemplate(); javax.sql.DataSource ds = jdbcTemplate.getDataSource(); DataSourceTransactionManager tm = new DataSourceTransactionManager(ds); TransactionTemplate txTemplate = new TransactionTemplate(tm); ObjectNode result; final Integer id = userId; result = txTemplate.execute(new TransactionCallback<ObjectNode>() { public ObjectNode doInTransaction(TransactionStatus status) { List<Map<String, Object>> rows; if (StringUtils.isBlank(dashboardName)) { rows = jdbcTemplate.queryForList(SELECT_PAGED_METRICS, id, (page - 1) * size, size); } else if (StringUtils.isBlank(group)) { String dbName; if (dashboardName.equals("[Other]")) { dbName = null; } else { dbName = dashboardName; } rows = jdbcTemplate.queryForList(SELECT_PAGED_METRICS_BY_DASHBOARD_NAME, id, dbName, dbName, (page - 1) * size, size); } else { String dbName; if (dashboardName.equals("[Other]")) { dbName = null; } else { dbName = dashboardName; } String grp; if (group.equals("[Other]")) { grp = null; } else { grp = group; } rows = jdbcTemplate.queryForList(SELECT_PAGED_METRICS_BY_DASHBOARD_AND_GROUP, id, dbName, dbName, grp, grp, (page - 1) * size, size); } List<Metric> pagedMetrics = new ArrayList<>(); for (Map row : rows) { Metric metric = new Metric(); metric.id = (int) row.get("metric_id"); metric.name = (String) row.get("metric_name"); metric.description = (String) row.get("metric_description"); metric.refID = (String) row.get("metric_ref_id"); metric.refIDType = (String) row.get("metric_ref_id_type"); metric.dashboardName = (String) row.get("dashboard_name"); metric.category = (String) row.get("metric_category"); metric.group = (String) row.get("metric_group"); metric.watchId = (Long) row.get("watch_id"); pagedMetrics.add(metric); } long count = 0; try { count = jdbcTemplate.queryForObject("SELECT FOUND_ROWS()", Long.class); } catch (EmptyResultDataAccessException e) { Logger.error("Exception = " + e.getMessage()); } ObjectNode resultNode = Json.newObject(); resultNode.put("count", count); resultNode.put("page", page); resultNode.put("itemsPerPage", size); resultNode.put("totalPages", (int) Math.ceil(count / ((double) size))); resultNode.set("metrics", Json.toJson(pagedMetrics)); return resultNode; } }); return result; }