/** * Method for adding all properties of the given Object, overriding * any existing values for those properties. * * @param other Object of which properties to add to this object * * @return This node (to allow chaining) * * @since 1.3 */ public JsonNode putAll(ObjectNode other) { int len = other.size(); if (len > 0) { if (_children == null) { _children = new LinkedHashMap<String, JsonNode>(len); } other.putContentsTo(_children); } return this; }
@Override public boolean equals(Object o) { if (o == this) return true; if (o == null) return false; if (o.getClass() != getClass()) { return false; } ObjectNode other = (ObjectNode) o; if (other.size() != size()) { return false; } if (_children != null) { for (Map.Entry<String, JsonNode> en : _children.entrySet()) { String key = en.getKey(); JsonNode value = en.getValue(); JsonNode otherValue = other.get(key); if (otherValue == null || !otherValue.equals(value)) { return false; } } } return true; }
@Override public String toString() { StringBuilder sb = new StringBuilder(32 + (size() << 4)); sb.append("{"); if (_children != null) { int count = 0; for (Map.Entry<String, JsonNode> en : _children.entrySet()) { if (count > 0) { sb.append(","); } ++count; TextNode.appendQuoted(sb, en.getKey()); sb.append(':'); sb.append(en.getValue().toString()); } } sb.append("}"); return sb.toString(); }
/** * Method for adding all properties of the given Object, overriding * any existing values for those properties. * * @param other Object of which properties to add to this object * * @return This node (to allow chaining) * * @since 1.3 */ public JsonNode putAll(ObjectNode other) { int len = other.size(); if (len > 0) { if (_children == null) { _children = new LinkedHashMap<String, JsonNode>(len); } other.putContentsTo(_children); } return this; }
@Override public String toString() { StringBuilder sb = new StringBuilder(32 + (size() << 4)); sb.append("{"); if (_children != null) { int count = 0; for (Map.Entry<String, JsonNode> en : _children.entrySet()) { if (count > 0) { sb.append(","); } ++count; TextNode.appendQuoted(sb, en.getKey()); sb.append(':'); sb.append(en.getValue().toString()); } } sb.append("}"); return sb.toString(); }
@Override public boolean equals(Object o) { if (o == this) return true; if (o == null) return false; if (o.getClass() != getClass()) { return false; } ObjectNode other = (ObjectNode) o; if (other.size() != size()) { return false; } if (_children != null) { for (Map.Entry<String, JsonNode> en : _children.entrySet()) { String key = en.getKey(); JsonNode value = en.getValue(); JsonNode otherValue = other.get(key); if (otherValue == null || !otherValue.equals(value)) { return false; } } } return true; }
/** * Method for adding all properties of the given Object, overriding * any existing values for those properties. * * @param other Object of which properties to add to this object * * @return This node (to allow chaining) * * @since 1.3 */ public JsonNode putAll(ObjectNode other) { int len = other.size(); if (len > 0) { if (_children == null) { _children = new LinkedHashMap<String, JsonNode>(len); } other.putContentsTo(_children); } return this; }
/** * Method for adding all properties of the given Object, overriding * any existing values for those properties. * * @param other Object of which properties to add to this object * * @return This node (to allow chaining) * * @since 1.3 */ public JsonNode putAll(ObjectNode other) { int len = other.size(); if (len > 0) { if (_children == null) { _children = new LinkedHashMap<String, JsonNode>(len); } other.putContentsTo(_children); } return this; }
/** * Method for adding all properties of the given Object, overriding * any existing values for those properties. * * @param other Object of which properties to add to this object * * @return This node (to allow chaining) * * @since 1.3 */ public JsonNode putAll(ObjectNode other) { int len = other.size(); if (len > 0) { if (_children == null) { _children = new LinkedHashMap<String, JsonNode>(len); } other.putContentsTo(_children); } return this; }
@Override public boolean equals(Object o) { if (o == this) return true; if (o == null) return false; if (o.getClass() != getClass()) { return false; } ObjectNode other = (ObjectNode) o; if (other.size() != size()) { return false; } if (_children != null) { for (Map.Entry<String, JsonNode> en : _children.entrySet()) { String key = en.getKey(); JsonNode value = en.getValue(); JsonNode otherValue = other.get(key); if (otherValue == null || !otherValue.equals(value)) { return false; } } } return true; }
@Override public boolean equals(Object o) { if (o == this) return true; if (o == null) return false; if (o.getClass() != getClass()) { return false; } ObjectNode other = (ObjectNode) o; if (other.size() != size()) { return false; } if (_children != null) { for (Map.Entry<String, JsonNode> en : _children.entrySet()) { String key = en.getKey(); JsonNode value = en.getValue(); JsonNode otherValue = other.get(key); if (otherValue == null || !otherValue.equals(value)) { return false; } } } return true; }
@Override public String toString() { StringBuilder sb = new StringBuilder(32 + (size() << 4)); sb.append("{"); if (_children != null) { int count = 0; for (Map.Entry<String, JsonNode> en : _children.entrySet()) { if (count > 0) { sb.append(","); } ++count; TextNode.appendQuoted(sb, en.getKey()); sb.append(':'); sb.append(en.getValue().toString()); } } sb.append("}"); return sb.toString(); }
@Override public String toString() { StringBuilder sb = new StringBuilder(32 + (size() << 4)); sb.append("{"); if (_children != null) { int count = 0; for (Map.Entry<String, JsonNode> en : _children.entrySet()) { if (count > 0) { sb.append(","); } ++count; TextNode.appendQuoted(sb, en.getKey()); sb.append(':'); sb.append(en.getValue().toString()); } } sb.append("}"); return sb.toString(); }
/** * @param keyValues The map to turn into the string. * @return A string of format {"key":"value",...} */ String getMessagesFromMap(final Map<String, String> keyValues) { ObjectNode node = objectMapper.createObjectNode(); for (Map.Entry<String, String> entry : keyValues.entrySet()) { node.put(entry.getKey(), entry.getValue()); } return node.size() > 0 ? node.toString() : null; }
@Override public String toString() { StringBuilder sb = new StringBuilder(32 + (size() << 4)); sb.append("{"); if (_children != null) { int count = 0; for (Map.Entry<String, JsonNode> en : _children.entrySet()) { if (count > 0) { sb.append(","); } ++count; TextNode.appendQuoted(sb, en.getKey()); sb.append(':'); sb.append(en.getValue().toString()); } } sb.append("}"); return sb.toString(); }
public UpdateIndexerInput fromJsonBytes(byte [] jsonBytes) { ObjectNode node = null; try { node = (ObjectNode) new ObjectMapper().readTree(new ByteArrayInputStream(jsonBytes)); } catch (IOException e) { throw new JsonFormatException("Error parsing indexer definition JSON.", e); } if (node.size() != 2) { new JsonFormatException("Expected object field of size 2, got size " + node.size()); } IndexerDefinition baseIndexer = getDefinitionFromNode(node,"baseIndexer").build(); IndexerDefinition newIndexer = getDefinitionFromNode(node, "newIndexer").build(); return new UpdateIndexerInput(newIndexer, baseIndexer); }
@Test public void testProjection09() { String query = "ApplicationService[@resourceId=~\"srp-app.*\"]{*}.accessPoints{*}"; cmsdbContext.setShowDisplayMeta(true); cmsdbContext.setAllowFullTableScan(true); IQueryResult result = queryService.query(query, cmsdbContext); Assert.assertNotNull(result.getDisplayMeta()); ObjectNode apDisplay = (ObjectNode) result.getDisplayMeta().get(0).get("fields").get("accessPoints") .get("refDataType").get("AccessPoint").get("fields"); MetaClass meta = cmsdbMetaService.getMetaClass("AccessPoint"); Assert.assertEquals(meta.getFieldNames().size(), apDisplay.size()); }
@Test public void testProject08() { String query = "Rack{@location}.assets.asset!AssetServer{@resourceId,@faultDomain}"; cmsdbContext.setAllowFullTableScan(true); cmsdbContext.setShowDisplayMeta(true); IQueryResult result = queryService.query(query, cmsdbContext); Assert.assertNotNull(result.getDisplayMeta()); Assert.assertEquals(1, result.getDisplayMeta().size()); // reverse ObjectNode rackDisplay = (ObjectNode) result.getDisplayMeta().get(0).get("fields"); Assert.assertEquals(4, rackDisplay.size()); ObjectNode assetDisplay = (ObjectNode) rackDisplay.get("assets").get("refDataType").get("Asset").get("fields"); Assert.assertEquals(3, assetDisplay.size()); ObjectNode assetServerDisplay = (ObjectNode) assetDisplay.get("asset!AssetServer").get("refDataType") .get("AssetServer").get("fields"); Assert.assertEquals(4, assetServerDisplay.size()); }
/** * Set query */ @Test public void testProject07() { raptorContext.setAllowFullTableScan(true); raptorContext.setShowDisplayMeta(true); String query = "ApplicationService.(services{@_oid}&&updateStrategies{@_type})"; IQueryResult result = queryService.query(query, raptorContext); ArrayNode display = result.getDisplayMeta(); Assert.assertEquals(2, display.size()); ObjectNode servDisplay = (ObjectNode) display.get(0).get("fields"); Assert.assertEquals(2, servDisplay.size()); ObjectNode usDisplay = (ObjectNode) display.get(1).get("fields"); Assert.assertEquals(2, usDisplay.size()); }
@Test public void testProject06() { // case 0 : aggregation String query = "NetworkAddress<@healthState>{@healthState, $max(@address), $count()}"; cmsdbContext.setAllowFullTableScan(true); cmsdbContext.setShowDisplayMeta(true); IQueryResult result = queryService.query(query, cmsdbContext); ArrayNode display = result.getDisplayMeta(); ObjectNode na = (ObjectNode) display.get(0).get("fields"); Assert.assertEquals(5, na.size()); Assert.assertTrue(na.has("healthState")); Assert.assertTrue(na.has("$count")); Assert.assertTrue(na.has("$max_address")); }