Java Code Examples for org.codehaus.jackson.node.ObjectNode#toString()
The following examples show how to use
org.codehaus.jackson.node.ObjectNode#toString() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BeamSqlLineIT.java From beam with Apache License 2.0 | 6 votes |
private String taxiRideJSON( String rideId, int pointIdex, double latitude, double longitude, int meterReading, int meterIncrement, String rideStatus, int passengerCount) { ObjectMapper mapper = new ObjectMapper(); ObjectNode objectNode = mapper.createObjectNode(); objectNode.put("ride_id", rideId); objectNode.put("point_idx", pointIdex); objectNode.put("latitude", latitude); objectNode.put("longitude", longitude); objectNode.put("meter_reading", meterReading); objectNode.put("meter_increment", meterIncrement); objectNode.put("ride_status", rideStatus); objectNode.put("passenger_count", passengerCount); return objectNode.toString(); }
Example 2
Source File: LineageHelper.java From Cubert with Apache License 2.0 | 6 votes |
public List<ObjectNode> findAllParentStores(ObjectNode jobNode, JsonNode phaseNode, ObjectNode opNode) { if (!isLoadOperator(jobNode, phaseNode, opNode)) throw new RuntimeException("Cannot find parent store for non-LOAD " + opNode.toString()); List<ObjectNode> result = new ArrayList<ObjectNode>(); List<String> loadPaths = operatorMapGet(loadPathsMap, opNode); for (String loadPath : loadPaths) { ObjectNode storeNode = findPrecedingStore(opNode, loadPath); if (storeNode != null) result.add(storeNode); } return result; }
Example 3
Source File: AggregateRewriter.java From Cubert with Apache License 2.0 | 6 votes |
protected ObjectNode getFactTimeSpecNode(ObjectNode factNode, ObjectNode cubeNode) throws AggregateRewriteException { List<String> paths = lineage.getPaths(factNode.get("path")); for (JsonNode timeSpecNode : (ArrayNode) (cubeNode.get("timeColumnSpec"))) { String elementPath = ((ObjectNode) timeSpecNode).get("factPath").getTextValue(); if (paths.indexOf(elementPath) != -1) { tNode = (ObjectNode) timeSpecNode; return tNode; } } throw new AggregateRewriteException("No matching time column specification found for FACT load at " + factNode.toString()); }
Example 4
Source File: MetricConfigResource.java From incubator-pinot with Apache License 2.0 | 6 votes |
@GET @Path("/list") @Produces(MediaType.APPLICATION_JSON) public String viewMetricConfig(@NotNull @QueryParam("dataset") String dataset, @DefaultValue("0") @QueryParam("jtStartIndex") int jtStartIndex, @DefaultValue("100") @QueryParam("jtPageSize") int jtPageSize) { Map<String, Object> filters = new HashMap<>(); filters.put("dataset", dataset); List<MetricConfigDTO> metricConfigDTOs = metricConfigDao.findByParams(filters); Collections.sort(metricConfigDTOs, new Comparator<MetricConfigDTO>() { @Override public int compare(MetricConfigDTO m1, MetricConfigDTO m2) { return m1.getName().compareTo(m2.getName()); } }); List<MetricConfigDTO> subList = Utils.sublist(metricConfigDTOs, jtStartIndex, jtPageSize); ObjectNode rootNode = JsonResponseUtil.buildResponseJSON(subList); return rootNode.toString(); }
Example 5
Source File: DatasetConfigResource.java From incubator-pinot with Apache License 2.0 | 6 votes |
@GET @Path("/list") @Produces(MediaType.APPLICATION_JSON) public String viewDatsetConfig(@DefaultValue("0") @QueryParam("jtStartIndex") int jtStartIndex, @DefaultValue("100") @QueryParam("jtPageSize") int jtPageSize) { List<DatasetConfigDTO> datasetConfigDTOs = datasetConfigDAO.findAll(); Collections.sort(datasetConfigDTOs, new Comparator<DatasetConfigDTO>() { @Override public int compare(DatasetConfigDTO d1, DatasetConfigDTO d2) { return d1.getDataset().compareTo(d2.getDataset()); } }); List<DatasetConfigDTO> subList = Utils.sublist(datasetConfigDTOs, jtStartIndex, jtPageSize); ObjectNode rootNode = JsonResponseUtil.buildResponseJSON(subList); return rootNode.toString(); }
Example 6
Source File: Directive.java From dcs-sdk-java with Apache License 2.0 | 5 votes |
@Override public Directive deserialize(JsonParser jp, DeserializationContext ctx) throws IOException { ObjectReader reader = ObjectMapperUtil.instance().getObjectReader(); ObjectNode obj = (ObjectNode) reader.readTree(jp); Iterator<Map.Entry<String, JsonNode>> elementsIterator = obj.getFields(); String rawMessage = obj.toString(); DialogRequestIdHeader header = null; JsonNode payloadNode = null; ObjectReader headerReader = ObjectMapperUtil.instance().getObjectReader(DialogRequestIdHeader.class); while (elementsIterator.hasNext()) { Map.Entry<String, JsonNode> element = elementsIterator.next(); if (element.getKey().equals("header")) { header = headerReader.readValue(element.getValue()); } if (element.getKey().equals("payload")) { payloadNode = element.getValue(); } } if (header == null) { throw ctx.mappingException("Missing header"); } if (payloadNode == null) { throw ctx.mappingException("Missing payload"); } return createDirective(header, payloadNode, rawMessage); }
Example 7
Source File: ExplorerResource.java From exhibitor with Apache License 2.0 | 5 votes |
@GET @Path("node-data") @Produces("application/json") public String getNodeData(@QueryParam("key") String key) throws Exception { ObjectNode node = JsonNodeFactory.instance.objectNode(); try { Stat stat = context.getExhibitor().getLocalConnection().checkExists().forPath(key); byte[] bytes = context.getExhibitor().getLocalConnection().getData().storingStatIn(stat).forPath(key); if (bytes != null) { node.put("bytes", bytesToString(bytes)); node.put("str", new String(bytes, "UTF-8")); } else { node.put("bytes", ""); node.put("str", ""); } node.put("stat", reflectToString(stat)); } catch ( KeeperException.NoNodeException dummy ) { node.put("bytes", ""); node.put("str", ""); node.put("stat", "* not found * "); } catch ( Throwable e ) { node.put("bytes", ""); node.put("str", "Exception"); node.put("stat", e.getMessage()); } return node.toString(); }
Example 8
Source File: LineageHelper.java From Cubert with Apache License 2.0 | 5 votes |
public ObjectNode findOperatorSource(ObjectNode opNode, String inputRelation) { int opSequence = this.getOpSequence(opNode); JsonNode phaseNode = this.getJobPhase(opNode).getSecond(); ObjectNode sourceOp = findOperatorSourcePrior(opSequence - 1, inputRelation); if (sourceOp == null) throw new RuntimeException("Cannot find source for opNode " + opNode.toString() + "for relation " + inputRelation); return sourceOp; }
Example 9
Source File: LineageHelper.java From Cubert with Apache License 2.0 | 5 votes |
public int getOpSequence(ObjectNode opNode) { int result = CommonUtils.indexOfByRef(this.operatorList, opNode); if (result == -1) throw new RuntimeException("No operatorList reference found \n opNode = " + opNode.toString()); return result; }
Example 10
Source File: Lineage.java From Cubert with Apache License 2.0 | 5 votes |
private String getNodeType(ObjectNode sourceNode) { Pair<ObjectNode, JsonNode> jobPhase = this.preLineageInfo.getJobPhase(sourceNode); if (jobPhase == null) { throw new RuntimeException("PhaseInformation missing for " + sourceNode.toString() + "\n*********"); } return getOperatorType(jobPhase.getFirst(), jobPhase.getSecond(), sourceNode); }
Example 11
Source File: IndexResource.java From exhibitor with Apache License 2.0 | 4 votes |
@Path("dataTable/{index-name}/{search-handle}") @GET @Produces(MediaType.APPLICATION_JSON) public String getDataTableData ( @PathParam("index-name") String indexName, @PathParam("search-handle") String searchHandle, @QueryParam("iDisplayStart") int iDisplayStart, @QueryParam("iDisplayLength") int iDisplayLength, @QueryParam("sEcho") String sEcho ) throws Exception { LogSearch logSearch = getLogSearch(indexName); if ( logSearch == null ) { return "{}"; } ObjectNode node; try { CachedSearch cachedSearch = logSearch.getCachedSearch(searchHandle); DateFormat dateFormatter = new SimpleDateFormat(DATE_FORMAT_STR); ArrayNode dataTab = JsonNodeFactory.instance.arrayNode(); for ( int i = iDisplayStart; i < (iDisplayStart + iDisplayLength); ++i ) { if ( i < cachedSearch.getTotalHits() ) { ObjectNode data = JsonNodeFactory.instance.objectNode(); int docId = cachedSearch.getNthDocId(i); SearchItem item = logSearch.toResult(docId); data.put("DT_RowId", "index-query-result-" + docId); data.put("0", getTypeName(EntryTypes.getFromId(item.getType()))); data.put("1", dateFormatter.format(item.getDate())); data.put("2", trimPath(item.getPath())); dataTab.add(data); } } node = JsonNodeFactory.instance.objectNode(); node.put("sEcho", sEcho); node.put("iTotalRecords", logSearch.getDocQty()); node.put("iTotalDisplayRecords", cachedSearch.getTotalHits()); node.put("aaData", dataTab); } finally { context.getExhibitor().getIndexCache().releaseLogSearch(logSearch.getFile()); } return node.toString(); }
Example 12
Source File: Lineage.java From Cubert with Apache License 2.0 | 4 votes |
public boolean inspect(ObjectNode jobNode, JsonNode phaseNode, ObjectNode operatorNode) { ArrayList<ObjectNode> sourceOperators = preLineageInfo.findAllOperatorSources(jobNode, phaseNode, operatorNode); if (sourceOperators != null) { for (ObjectNode sourceNode : sourceOperators) addOperatorLineage(sourceNode, operatorNode); } Pair<ObjectNode, JsonNode> jobPhase = preLineageInfo.getJobPhase(operatorNode); if (jobPhase.getSecond() != phaseNode) throw new RuntimeException("mis-matched phaseNode stored in phaseMap for \nopNode= " + operatorNode.toString() + "\nphaseNode = " + jobPhase.getSecond().toString() + "\noriginal phaseNode = " + phaseNode.toString()); LineageHelper.trace("Lineage Visitor visiting " + operatorNode.toString()); // Now capture columnLineage for all output columns at this node BlockSchema outSchema = new BlockSchema(operatorNode.get("schema")); for (String colName : outSchema.getColumnNames()) { OutputColumn destColumn = new OutputColumn(operatorNode, colName); List<OutputColumn> sourceColumns = getSourceColumns(operatorNode, colName); if (sourceColumns != null) { for (OutputColumn sourceColumn : sourceColumns) addColumnLineage(sourceColumn, destColumn); } } return true; }