use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.TextNode in project drools by kiegroup.
the class DMNFeelExpressionEvaluatorTest method expressionMapTest.
@Test
public void expressionMapTest() {
String expressionCollectionJsonString = new TextNode("{ x : 5, y : 3 }").toString();
Map<String, BigDecimal> result = (Map<String, BigDecimal>) expressionEvaluator.convertResult(expressionCollectionJsonString, Map.class.getCanonicalName(), Collections.EMPTY_LIST);
assertEquals(2, result.size());
assertEquals(BigDecimal.valueOf(5), result.get("x"));
assertEquals(BigDecimal.valueOf(3), result.get("y"));
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.TextNode in project openremote by openremote.
the class JSONSchemaUtil method getSchemaType.
public static JsonNode getSchemaType(boolean wrapped, String... types) {
JsonNode typesNode;
if (types.length == 1) {
typesNode = new TextNode(types[0]);
} else {
ArrayNode arrNode = ValueUtil.JSON.createArrayNode();
Arrays.stream(types).forEach(arrNode::add);
typesNode = arrNode;
}
return wrapped ? ValueUtil.JSON.createObjectNode().set("type", typesNode) : typesNode;
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.TextNode in project autorest-clientruntime-for-java by Azure.
the class ValidatorTests method validateRecursive.
@Test
public void validateRecursive() throws Exception {
TextNode textNode = new TextNode("\"\"");
Validator.validate(textNode);
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.TextNode in project thingsboard by thingsboard.
the class EdgeBulkImportService method setEntityFields.
@Override
protected void setEntityFields(Edge entity, Map<BulkImportColumnType, String> fields) {
ObjectNode additionalInfo = (ObjectNode) Optional.ofNullable(entity.getAdditionalInfo()).orElseGet(JacksonUtil::newObjectNode);
fields.forEach((columnType, value) -> {
switch(columnType) {
case NAME:
entity.setName(value);
break;
case TYPE:
entity.setType(value);
break;
case LABEL:
entity.setLabel(value);
break;
case DESCRIPTION:
additionalInfo.set("description", new TextNode(value));
break;
case ROUTING_KEY:
entity.setRoutingKey(value);
break;
case SECRET:
entity.setSecret(value);
break;
}
});
entity.setAdditionalInfo(additionalInfo);
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.TextNode in project walkmod-core by walkmod.
the class AddTransformationYMLAction method doAction.
@Override
public void doAction(JsonNode chainsNode) throws Exception {
ArrayNode transformationsNode = null;
boolean isMultiModule = chainsNode.has("modules");
ObjectMapper mapper = provider.getObjectMapper();
if (!isMultiModule) {
boolean validChainName = chain != null && !"".equals(chain) && !"default".equals(chain);
if (!chainsNode.has("chains")) {
if (chainsNode.has("transformations")) {
JsonNode aux = chainsNode.get("transformations");
if (aux.isArray()) {
transformationsNode = (ArrayNode) aux;
}
if (!validChainName) {
ObjectNode auxRoot = (ObjectNode) chainsNode;
if (transformationsNode == null) {
transformationsNode = new ArrayNode(mapper.getNodeFactory());
}
auxRoot.set("transformations", transformationsNode);
} else {
// reset the root
chainsNode = new ObjectNode(mapper.getNodeFactory());
ObjectNode auxRoot = (ObjectNode) chainsNode;
// the default chain list added
ObjectNode chainObject = new ObjectNode(mapper.getNodeFactory());
chainObject.set("name", new TextNode("default"));
chainObject.set("transformations", transformationsNode);
ArrayNode chainsListNode = new ArrayNode(mapper.getNodeFactory());
// the requested chain added
ObjectNode newChain = new ObjectNode(mapper.getNodeFactory());
newChain.set("name", new TextNode(chain));
if (path != null && !"".equals(path.trim())) {
ObjectNode readerNode = new ObjectNode(mapper.getNodeFactory());
newChain.set("reader", readerNode);
populateWriterReader(readerNode, path, null, null, null, null);
ObjectNode writerNode = new ObjectNode(mapper.getNodeFactory());
newChain.set("writer", writerNode);
populateWriterReader(writerNode, path, null, null, null, null);
}
transformationsNode = new ArrayNode(mapper.getNodeFactory());
newChain.set("transformations", transformationsNode);
if (before == null || !"default".equals(before)) {
chainsListNode.add(chainObject);
}
chainsListNode.add(newChain);
if (before != null && "default".equals(before)) {
chainsListNode.add(chainObject);
}
auxRoot.set("chains", chainsListNode);
}
} else {
ObjectNode auxRoot = (ObjectNode) chainsNode;
transformationsNode = new ArrayNode(mapper.getNodeFactory());
boolean writeChainInfo = validChainName;
if (!writeChainInfo) {
writeChainInfo = path != null && !"".equals(path.trim());
chain = "default";
}
if (writeChainInfo) {
ArrayNode auxChainsList = new ArrayNode(mapper.getNodeFactory());
ObjectNode aux = new ObjectNode(mapper.getNodeFactory());
auxChainsList.add(aux);
aux.set("name", new TextNode(chain));
if (path != null && !"".equals(path.trim())) {
ObjectNode readerNode = new ObjectNode(mapper.getNodeFactory());
aux.set("reader", readerNode);
populateWriterReader(readerNode, path, null, null, null, null);
}
auxRoot.set("chains", auxChainsList);
if (path != null && !"".equals(path.trim())) {
ObjectNode writerNode = new ObjectNode(mapper.getNodeFactory());
aux.set("writer", writerNode);
populateWriterReader(writerNode, path, null, null, null, null);
}
auxRoot = aux;
}
auxRoot.set("transformations", transformationsNode);
}
} else {
if (validChainName) {
JsonNode aux = chainsNode.get("chains");
boolean found = false;
if (aux.isArray()) {
Iterator<JsonNode> it = aux.elements();
while (it.hasNext()) {
JsonNode next = it.next();
if (next.has("name")) {
String id = next.get("name").asText();
if (chain.equals(id)) {
found = true;
if (next.has("transformations")) {
JsonNode auxTrans = next.get("transformations");
if (auxTrans.isArray()) {
transformationsNode = (ArrayNode) auxTrans;
} else {
throw new Exception("The chain [" + chain + "] does not have a valid transformations node");
}
} else if (next.isObject()) {
ObjectNode auxNext = (ObjectNode) next;
transformationsNode = new ArrayNode(mapper.getNodeFactory());
auxNext.set("transformations", transformationsNode);
} else {
throw new Exception("The chain [" + chain + "] does not have a valid structure");
}
}
}
}
if (!found) {
ChainConfig chainCfg = new ChainConfigImpl();
chainCfg.setName(chain);
WalkerConfig walkerCfg = new WalkerConfigImpl();
List<TransformationConfig> transfs = new LinkedList<TransformationConfig>();
transfs.add(transformationCfg);
walkerCfg.setTransformations(transfs);
chainCfg.setWalkerConfig(walkerCfg);
provider.addChainConfig(chainCfg, false, before);
return;
}
}
} else {
ObjectNode node = new ObjectNode(mapper.getNodeFactory());
node.set("name", new TextNode(chain));
ArrayNode transNodes = new ArrayNode(mapper.getNodeFactory());
node.set("transformations", transNodes);
ArrayNode array = (ArrayNode) chainsNode.get("chains");
array.add(node);
ObjectNode transformationNode = new ObjectNode(mapper.getNodeFactory());
transNodes.add(transformationNode);
createTransformation(transformationNode, transformationCfg);
return;
}
}
if (transformationsNode != null) {
ObjectNode transformationNode = new ObjectNode(mapper.getNodeFactory());
if (order != null && order < transformationsNode.size()) {
transformationsNode.insert(order, transformationNode);
} else {
transformationsNode.add(transformationNode);
}
createTransformation(transformationNode, transformationCfg);
provider.write(chainsNode);
return;
} else if (chain != null) {
throw new Exception("The chain [" + chain + "] does not exists");
}
}
}
Aggregations