Java Code Examples for com.fasterxml.jackson.databind.node.ArrayNode#isNull()

The following examples show how to use com.fasterxml.jackson.databind.node.ArrayNode#isNull() . 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: LargeTextNodeRemover.java    From foxtrot with Apache License 2.0 6 votes vote down vote up
private void handleArrayNode(final String table,
                             final String documentId,
                             final String parentKey,
                             ArrayNode arrayNode) {
    if (arrayNode == null || arrayNode.isNull()) {
        return;
    }
    ArrayNode copy = objectMapper.createArrayNode();
    arrayNode.elements()
            .forEachRemaining(node -> {
                boolean copyNode = true;
                if (node.isObject()) {
                    handleObjectNode(table, documentId, (ObjectNode) node);
                } else if (node.isArray()) {
                    handleArrayNode(table, documentId, parentKey, (ArrayNode) node);
                } else if (node.isTextual()) {
                    copyNode = !evaluateForRemoval(table, documentId, parentKey, node);
                }
                if (copyNode) {
                    copy.add(node);
                }
            });
    arrayNode.removeAll();
    arrayNode.addAll(copy);
}
 
Example 2
Source File: PceWebTopovMessageHandler.java    From onos with Apache License 2.0 5 votes vote down vote up
@Override
public void process(ObjectNode payload) {
    ObjectNode result = objectNode();
    ArrayNode arrayNode = arrayNode();
    Collection<Tunnel> tunnelSet = null;

    tunnelSet = tunnelService.queryTunnel(MPLS);
    for (Tunnel tunnel : tunnelSet) {
        if (tunnel.state().equals(ACTIVE)) {
            //TODO: if it is load balancing need to check whether to send tunnel ID as null or some negative
            //TODO;value
            if (tunnel.annotations().value("loadBalancingPathName") != null) {
                boolean present = false;
                if (!arrayNode.isNull()) {
                    for (JsonNode node : arrayNode) {
                        if (node.asText().equals(tunnel.annotations().value("loadBalancingPathName"))) {
                            present = true;
                            break;
                        }
                    }
                    if (!present) {
                        arrayNode.add("");
                        arrayNode.add(tunnel.annotations().value("loadBalancingPathName"));
                    }
                }

            } else {
                arrayNode.add(tunnel.tunnelId().toString());
                arrayNode.add(tunnel.tunnelName().toString());
            }
        }
    }

    result.putArray(BUFFER_ARRAY).addAll(arrayNode);
    sendMessage(PCEWEB_TUNNEL_QUERY_INFO, result);
}
 
Example 3
Source File: CaseInstanceMigrationDocumentConverter.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
public static JsonNode convertToJson(CaseInstanceMigrationDocument caseInstanceMigrationDocument) {

        ObjectNode documentNode = objectMapper.createObjectNode();

        if (caseInstanceMigrationDocument.getMigrateToCaseDefinitionId() != null) {
            documentNode.put(TO_CASE_DEFINITION_ID_JSON_PROPERTY, caseInstanceMigrationDocument.getMigrateToCaseDefinitionId());
        }

        if (caseInstanceMigrationDocument.getMigrateToCaseDefinitionKey() != null) {
            documentNode.put(TO_CASE_DEFINITION_KEY_JSON_PROPERTY, caseInstanceMigrationDocument.getMigrateToCaseDefinitionKey());
        }

        if (caseInstanceMigrationDocument.getMigrateToCaseDefinitionVersion() != null) {
            documentNode.put(TO_CASE_DEFINITION_VERSION_JSON_PROPERTY, caseInstanceMigrationDocument.getMigrateToCaseDefinitionVersion());
        }

        if (caseInstanceMigrationDocument.getMigrateToCaseDefinitionTenantId() != null) {
            documentNode.put(TO_CASE_DEFINITION_TENANT_ID_JSON_PROPERTY, caseInstanceMigrationDocument.getMigrateToCaseDefinitionTenantId());
        }

        ArrayNode activateMappingNodes = convertToJsonActivatePlanItemDefinitionMappings(caseInstanceMigrationDocument.getActivatePlanItemDefinitionMappings());
        if (activateMappingNodes != null && !activateMappingNodes.isNull()) {
            documentNode.set(ACTIVATE_PLAN_ITEM_DEFINITIONS_JSON_SECTION, activateMappingNodes);
        }
        
        ArrayNode terminateMappingNodes = convertToJsonTerminatePlanItemDefinitionMappings(caseInstanceMigrationDocument.getTerminatePlanItemDefinitionMappings());
        if (terminateMappingNodes != null && !terminateMappingNodes.isNull()) {
            documentNode.set(TERMINATE_PLAN_ITEM_DEFINITIONS_JSON_SECTION, terminateMappingNodes);
        }
        
        ArrayNode moveToAvailableMappingNodes = convertToJsonMoveToAvailablePlanItemDefinitionMappings(caseInstanceMigrationDocument.getMoveToAvailablePlanItemDefinitionMappings());
        if (moveToAvailableMappingNodes != null && !moveToAvailableMappingNodes.isNull()) {
            documentNode.set(TERMINATE_PLAN_ITEM_DEFINITIONS_JSON_SECTION, moveToAvailableMappingNodes);
        }

        JsonNode caseInstanceVariablesNode = convertToJsonCaseInstanceVariables(caseInstanceMigrationDocument, objectMapper);
        if (caseInstanceVariablesNode != null && !caseInstanceVariablesNode.isNull()) {
            documentNode.set(CASE_INSTANCE_VARIABLES_JSON_SECTION, caseInstanceVariablesNode);
        }

        return documentNode;
    }
 
Example 4
Source File: ProcessInstanceMigrationDocumentConverter.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
public static JsonNode convertToJson(ProcessInstanceMigrationDocument processInstanceMigrationDocument) {

        ObjectNode documentNode = objectMapper.createObjectNode();

        if (processInstanceMigrationDocument.getMigrateToProcessDefinitionId() != null) {
            documentNode.put(TO_PROCESS_DEFINITION_ID_JSON_PROPERTY, processInstanceMigrationDocument.getMigrateToProcessDefinitionId());
        }

        if (processInstanceMigrationDocument.getMigrateToProcessDefinitionKey() != null) {
            documentNode.put(TO_PROCESS_DEFINITION_KEY_JSON_PROPERTY, processInstanceMigrationDocument.getMigrateToProcessDefinitionKey());
        }

        if (processInstanceMigrationDocument.getMigrateToProcessDefinitionVersion() != null) {
            documentNode.put(TO_PROCESS_DEFINITION_VERSION_JSON_PROPERTY, processInstanceMigrationDocument.getMigrateToProcessDefinitionVersion());
        }

        if (processInstanceMigrationDocument.getMigrateToProcessDefinitionTenantId() != null) {
            documentNode.put(TO_PROCESS_DEFINITION_TENANT_ID_JSON_PROPERTY, processInstanceMigrationDocument.getMigrateToProcessDefinitionTenantId());
        }

        JsonNode preUpgradeScriptNode = convertToJsonUpgradeScript(processInstanceMigrationDocument.getPreUpgradeScript(), objectMapper);
        if (preUpgradeScriptNode != null && !preUpgradeScriptNode.isNull()) {
            documentNode.set(PRE_UPGRADE_SCRIPT, preUpgradeScriptNode);
        }

        if (processInstanceMigrationDocument.getPreUpgradeJavaDelegate() != null) {
            documentNode.put(PRE_UPGRADE_JAVA_DELEGATE, processInstanceMigrationDocument.getPreUpgradeJavaDelegate());
        }

        if (processInstanceMigrationDocument.getPreUpgradeJavaDelegateExpression() != null) {
            documentNode.put(PRE_UPGRADE_JAVA_DELEGATE_EXPRESSION, processInstanceMigrationDocument.getPreUpgradeJavaDelegateExpression());
        }

        JsonNode postUpgradeScriptNode = convertToJsonUpgradeScript(processInstanceMigrationDocument.getPostUpgradeScript(), objectMapper);
        if (postUpgradeScriptNode != null && !postUpgradeScriptNode.isNull()) {
            documentNode.set(POST_UPGRADE_SCRIPT, postUpgradeScriptNode);
        }

        if (processInstanceMigrationDocument.getPostUpgradeJavaDelegate() != null) {
            documentNode.put(POST_UPGRADE_JAVA_DELEGATE, processInstanceMigrationDocument.getPostUpgradeJavaDelegate());
        }

        if (processInstanceMigrationDocument.getPostUpgradeJavaDelegateExpression() != null) {
            documentNode.put(POST_UPGRADE_JAVA_DELEGATE_EXPRESSION, processInstanceMigrationDocument.getPostUpgradeJavaDelegateExpression());
        }

        ArrayNode mappingNodes = convertToJsonActivityMigrationMappings(processInstanceMigrationDocument.getActivityMigrationMappings());
        if (mappingNodes != null && !mappingNodes.isNull()) {
            documentNode.set(ACTIVITY_MAPPINGS_JSON_SECTION, mappingNodes);
        }

        JsonNode processInstanceVariablesNode = convertToJsonProcessInstanceVariables(processInstanceMigrationDocument, objectMapper);
        if (processInstanceVariablesNode != null && !processInstanceVariablesNode.isNull()) {
            documentNode.set(PROCESS_INSTANCE_VARIABLES_JSON_SECTION, processInstanceVariablesNode);
        }

        return documentNode;
    }
 
Example 5
Source File: PceWebTopovMessageHandler.java    From onos with Apache License 2.0 4 votes vote down vote up
@Override
public void process(ObjectNode payload) {
    String srcId = string(payload, SRCID);
    ElementId src = elementId(srcId);
    String dstId = string(payload, DSTID);
    ElementId dst = elementId(dstId);

    Device srcDevice = deviceService.getDevice((DeviceId) src);
    Device dstDevice = deviceService.getDevice((DeviceId) dst);

    TunnelEndPoint tunSrc = IpTunnelEndPoint.ipTunnelPoint(IpAddress
            .valueOf(srcDevice.annotations().value("lsrId")));
    TunnelEndPoint tunDst = IpTunnelEndPoint.ipTunnelPoint(IpAddress
            .valueOf(dstDevice.annotations().value("lsrId")));

    Collection<Tunnel> tunnelSet = tunnelService.queryTunnel(tunSrc, tunDst);
    ObjectNode result = objectNode();
    ArrayNode arrayNode = arrayNode();

    for (Tunnel tunnel : tunnelSet) {
        if (tunnel.type() == MPLS) {
            if (tunnel.state().equals(ACTIVE)) {

                if (tunnel.annotations().value("loadBalancingPathName") != null) {
                    boolean present = false;
                    if (!arrayNode.isNull()) {
                        for (JsonNode node : arrayNode) {
                            if (node.asText().equals(tunnel.annotations().value("loadBalancingPathName"))) {
                                present = true;
                                break;
                            }
                        }
                        if (!present) {
                            arrayNode.add("");
                            arrayNode.add(tunnel.annotations().value("loadBalancingPathName"));
                        }
                    }

                } else {
                    arrayNode.add(tunnel.tunnelId().toString());
                    arrayNode.add(tunnel.tunnelName().toString());
                }
            }
        }
    }

    result.putArray(BUFFER_ARRAY).addAll(arrayNode);
    sendMessage(PCEWEB_SHOW_TUNNEL_REMOVE, result);
}