private void processMap(ObjectMapper mapper, ObjectNode root, Map<String, List<CacheItem<Exchange>>> map) throws IOException { for (Map.Entry<String, List<CacheItem<Exchange>>> entry : map.entrySet()) { ObjectNode rootList = root.putObject(entry.getKey()); List<CacheItem<Exchange>> cl = entry.getValue(); for (CacheItem<Exchange> item : cl) { processExchange(mapper, rootList, item); } } }
public String calculateStatistics(Exchange exchange) throws Exception { ObjectMapper objectMapper = new ObjectMapper(); ObjectNode objectNode = objectMapper.createObjectNode(); ObjectNode statsNode = objectNode.putObject("statistics"); if (this.expressionDefinitions != null && this.expressionDefinitions.length > 0) { for (ExpressionDefinition expressionDefinition : expressionDefinitions) { ObjectNode expressionNode = statsNode.putObject(expressionDefinition.getExpression()); process(expressionDefinition, exchange, expressionNode); } } else { Map<String, Number> map = getNumbersFromExchange(exchange); if (map != null) { for (Map.Entry<String, Number> entry : map.entrySet()) { ObjectNode valueNode = statsNode.putObject(entry.getKey()); try { process(entry.getValue(), valueNode); } catch (Throwable e) { LOG.error("Failed to process statistics on " + exchange + " for parameter " + entry.getKey() + " = " + entry.getValue(), e); } } } } return objectNode.toString(); }
private void processExchange(ObjectMapper mapper, ObjectNode root, CacheItem<Exchange> item) throws IOException { Exchange exchange = item.getItem(); long timeStamp = item.getTimestamp(); ObjectNode exchangeNode = root.putObject(exchange.getExchangeId()); exchangeNode.put("timestamp", timeStamp); Object payload = exchange.getIn().getBody(); String payloadString = mapper.writeValueAsString(payload); exchangeNode.put("payload", payloadString); }
protected String processList(List<CacheItem<Exchange>> list) throws IOException { String result = null; if (list != null && !list.isEmpty()) { ObjectMapper objectMapper = new ObjectMapper(); ObjectNode objectNode = objectMapper.createObjectNode(); ObjectNode rootNode = objectNode.putObject("eca{" + getPattern() + "}"); Map<String, List<CacheItem<Exchange>>> map = new LinkedHashMap<String, List<CacheItem<Exchange>>>(list.size()); for (CacheItem<Exchange> item : list) { Exchange exchange = item.getItem(); String routeId = exchange.getFromRouteId(); List<CacheItem<Exchange>> cl = map.get(routeId); if (cl == null) { cl = new ArrayList<CacheItem<Exchange>>(); map.put(routeId, cl); } cl.add(item); } processMap(objectMapper, rootNode, map); result = objectNode.toString(); } return result; }
private void setBatchBuildInfo(BatchBuildInfo buildInfo, ObjectNode batchNode) { batchNode.put("submitTime", buildInfo.getSubmitTime()); Boolean isFinishedSuccessful = buildInfo.isFinishedSuccessful(); if (isFinishedSuccessful == null) { batchNode.put("finishedSuccessful", batchNode.nullNode()); } else { batchNode.put("finishedSuccessful", isFinishedSuccessful); } ObjectNode jobs = batchNode.putObject("mapReduceJobTrackingUrls"); for (Map.Entry<String, String> entry : buildInfo.getMapReduceJobTrackingUrls().entrySet()) { jobs.put(entry.getKey(), entry.getValue()); } setStringArrayProperty(batchNode, "batchIndexCliArguments", buildInfo.getBatchIndexCliArguments()); } }
private void setBatchBuildInfo(BatchBuildInfo buildInfo, ObjectNode batchNode) { batchNode.put("submitTime", buildInfo.getSubmitTime()); Boolean isFinishedSuccessful = buildInfo.isFinishedSuccessful(); if (isFinishedSuccessful == null) { batchNode.put("finishedSuccessful", batchNode.nullNode()); } else { batchNode.put("finishedSuccessful", isFinishedSuccessful); } ObjectNode jobs = batchNode.putObject("mapReduceJobTrackingUrls"); for (Map.Entry<String, String> entry : buildInfo.getMapReduceJobTrackingUrls().entrySet()) { jobs.put(entry.getKey(), entry.getValue()); } setStringArrayProperty(batchNode, "batchIndexCliArguments", buildInfo.getBatchIndexCliArguments()); } }
ObjectNode fieldsNode = recordNode.putObject("fields"); schemaNode = recordNode.putObject("schema"); ObjectNode attributesNode = recordNode.putObject("attributes"); for (String key : attributes.keySet()) { attributesNode.put(key, attributes.get(key)); ObjectNode metadatasNode = recordNode.putObject("metadata"); ObjectNode metadataNode = metadatasNode.putObject(fieldName); metadataNode.put(metadata.getKey(), (Boolean)value); } else if (value instanceof ByteArray) { ObjectNode binaryNode = metadataNode.putObject(metadata.getKey()); binaryNode.put("type", "binary"); binaryNode.put("value", ((ByteArray)value).getBytes()); } else if (value instanceof DateTime){ ObjectNode dateTimeNode = metadataNode.putObject(metadata.getKey()); dateTimeNode.put("type", "datetime"); dateTimeNode.put("value", value.toString()); if (!fieldsToDelete.isEmpty()) { if (metadataToDeleteNode == null) { metadataToDeleteNode = recordNode.putObject("metadataToDelete");
public ObjectNode toJson() { JsonNodeFactory factory = JsonNodeFactory.instance; ObjectNode object = factory.objectNode(); ObjectNode fieldsJson = object.putObject("fields"); for (IndexFieldDefinition field : fields) { fieldsJson.put(field.getName(), field.toJson()); } object.put("identifierOrder", this.identifierIndexFieldDefinition.getOrder().toString()); return object; }
public static ViewQuery createAndFetchViewQuery() { if (!connector.contains(DESIGN_DOC_ID)) { //The design document doesn't exist in the database so we create it. JsonNode rootNode = mapper.createObjectNode(); ((ObjectNode)rootNode).put("language", "javascript"); ((ObjectNode)rootNode).putObject("views").putObject(TEST_VIEW).put("map", "function(doc) {\n emit(doc._id, doc);\n}"); connector.create(DESIGN_DOC_ID, rootNode); } return new ViewQuery().designDocId(DESIGN_DOC_ID).viewName(TEST_VIEW); }
ObjectNode paramsNode = node.putObject("connectionParams"); for (Map.Entry<String, String> entry : indexer.getConnectionParams().entrySet()) { paramsNode.put(entry.getKey(), entry.getValue()); ObjectNode batchNode = node.putObject("activeBatchBuild"); ObjectNode batchNode = node.putObject("lastBatchBuild");
ObjectNode paramsNode = node.putObject("connectionParams"); for (Map.Entry<String, String> entry : indexer.getConnectionParams().entrySet()) { paramsNode.put(entry.getKey(), entry.getValue()); ObjectNode batchNode = node.putObject("activeBatchBuild"); ObjectNode batchNode = node.putObject("lastBatchBuild");
@Override ObjectNode toJson() { final ObjectNode obj = mapper.createObjectNode(); final ObjectNode node = obj.putObject(NodePropertyParser.NODE_PROPERTY); node.put(QueryPropertyParser.QUERY_PROPERTY, booleanExpression); if (this.hasLevel()) { node.put(LevelPropertyParser.LEVEL_PROPERTY, this.getLevel()); } if (this.hasRange()) { final ArrayNode array = node.putArray(RangePropertyParser.RANGE_PROPERTY); array.add(this.getLowerBound()); array.add(this.getUpperBound()); } if (this.hasBoost()) { node.put(BoostPropertyParser.BOOST_PROPERTY, this.getBoost()); } return obj; }
@Override public ObjectNode toJson() { final ObjectNode obj = mapper.createObjectNode(); final ObjectNode node = obj.putObject(NodePropertyParser.NODE_PROPERTY); node.put(QueryPropertyParser.QUERY_PROPERTY, booleanExpression); if (this.hasLevel()) { node.put(LevelPropertyParser.LEVEL_PROPERTY, this.getLevel()); } if (this.hasRange()) { final ArrayNode array = node.putArray(RangePropertyParser.RANGE_PROPERTY); array.add(this.getLowerBound()); array.add(this.getUpperBound()); } if (this.hasBoost()) { node.put(BoostPropertyParser.BOOST_PROPERTY, this.getBoost()); } return obj; }
node.putObject("value");
@Override public ObjectNode toJson() { final ObjectNode obj = mapper.createObjectNode(); ObjectNode bool = obj.putObject(BooleanPropertyParser.BOOLEAN_PROPERTY); // add boost if (this.hasBoost()) { bool.put(BoostPropertyParser.BOOST_PROPERTY, this.getBoost()); } // add slop if (this.hasSlop()) { bool.put(SlopPropertyParser.SLOP_PROPERTY, this.getSlop()); } // add inOrder if (this.hasInOrder()) { bool.put(InOrderPropertyParser.IN_ORDER_PROPERTY, this.getInOrder()); } // add clauses ArrayNode array = bool.putArray(ClausePropertyParser.CLAUSE_PROPERTY); for (final QueryClause clause : clauses) { final ObjectNode e = array.addObject(); e.put(OccurPropertyParser.OCCUR_PROPERTY, clause.getOccur().toString()); e.putAll(clause.getQuery().toJson()); } return obj; }
ObjectNode returnFieldsNode = node.putObject("returnFields"); returnFieldsNode.put("type", scan.getReturnFields().getType().toString()); if (scan.getReturnFields().getFields() != null) {
@Override public ObjectNode toJson() { final ObjectNode obj = mapper.createObjectNode(); final ObjectNode twig = obj.putObject(TwigPropertyParser.TWIG_PROPERTY);
@Override ObjectNode toJson() { final ObjectNode obj = mapper.createObjectNode(); final ObjectNode twig = obj.putObject(TwigPropertyParser.TWIG_PROPERTY);