Search in sources :

Example 26 with ArrayNode

use of com.fasterxml.jackson.databind.node.ArrayNode in project Activiti by Activiti.

the class BpmnJsonConverterUtil method convertSignalDefinitionsToJson.

public static void convertSignalDefinitionsToJson(BpmnModel bpmnModel, ObjectNode propertiesNode) {
    if (bpmnModel.getSignals() != null) {
        ArrayNode signalDefinitions = objectMapper.createArrayNode();
        for (Signal signal : bpmnModel.getSignals()) {
            ObjectNode signalNode = signalDefinitions.addObject();
            signalNode.put(PROPERTY_SIGNAL_DEFINITION_ID, signal.getId());
            signalNode.put(PROPERTY_SIGNAL_DEFINITION_NAME, signal.getName());
            signalNode.put(PROPERTY_SIGNAL_DEFINITION_SCOPE, signal.getScope());
        }
        propertiesNode.put(PROPERTY_SIGNAL_DEFINITIONS, signalDefinitions);
    }
}
Also used : Signal(org.activiti.bpmn.model.Signal) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode)

Example 27 with ArrayNode

use of com.fasterxml.jackson.databind.node.ArrayNode in project Activiti by Activiti.

the class BpmnJsonConverterUtil method convertMessagesToJson.

public static void convertMessagesToJson(Collection<Message> messages, ObjectNode propertiesNode) {
    String propertyName = "messages";
    ArrayNode messagesNode = objectMapper.createArrayNode();
    for (Message message : messages) {
        ObjectNode propertyItemNode = objectMapper.createObjectNode();
        propertyItemNode.put(PROPERTY_MESSAGE_ID, message.getId());
        propertyItemNode.put(PROPERTY_MESSAGE_NAME, message.getName());
        propertyItemNode.put(PROPERTY_MESSAGE_ITEM_REF, message.getItemRef());
        messagesNode.add(propertyItemNode);
    }
    propertiesNode.put(propertyName, messagesNode);
}
Also used : Message(org.activiti.bpmn.model.Message) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode)

Example 28 with ArrayNode

use of com.fasterxml.jackson.databind.node.ArrayNode in project Activiti by Activiti.

the class BaseBpmnJsonConverter method createDataAssociation.

protected void createDataAssociation(DataAssociation dataAssociation, boolean incoming, Activity activity) {
    String sourceRef = null;
    String targetRef = null;
    if (incoming) {
        sourceRef = dataAssociation.getSourceRef();
        targetRef = activity.getId();
    } else {
        sourceRef = activity.getId();
        targetRef = dataAssociation.getTargetRef();
    }
    ObjectNode flowNode = BpmnJsonConverterUtil.createChildShape(dataAssociation.getId(), STENCIL_DATA_ASSOCIATION, 172, 212, 128, 212);
    ArrayNode dockersArrayNode = objectMapper.createArrayNode();
    ObjectNode dockNode = objectMapper.createObjectNode();
    dockNode.put(EDITOR_BOUNDS_X, model.getGraphicInfo(sourceRef).getWidth() / 2.0);
    dockNode.put(EDITOR_BOUNDS_Y, model.getGraphicInfo(sourceRef).getHeight() / 2.0);
    dockersArrayNode.add(dockNode);
    if (model.getFlowLocationGraphicInfo(dataAssociation.getId()).size() > 2) {
        for (int i = 1; i < model.getFlowLocationGraphicInfo(dataAssociation.getId()).size() - 1; i++) {
            GraphicInfo graphicInfo = model.getFlowLocationGraphicInfo(dataAssociation.getId()).get(i);
            dockNode = objectMapper.createObjectNode();
            dockNode.put(EDITOR_BOUNDS_X, graphicInfo.getX());
            dockNode.put(EDITOR_BOUNDS_Y, graphicInfo.getY());
            dockersArrayNode.add(dockNode);
        }
    }
    dockNode = objectMapper.createObjectNode();
    dockNode.put(EDITOR_BOUNDS_X, model.getGraphicInfo(targetRef).getWidth() / 2.0);
    dockNode.put(EDITOR_BOUNDS_Y, model.getGraphicInfo(targetRef).getHeight() / 2.0);
    dockersArrayNode.add(dockNode);
    flowNode.put("dockers", dockersArrayNode);
    ArrayNode outgoingArrayNode = objectMapper.createArrayNode();
    outgoingArrayNode.add(BpmnJsonConverterUtil.createResourceNode(targetRef));
    flowNode.put("outgoing", outgoingArrayNode);
    flowNode.put("target", BpmnJsonConverterUtil.createResourceNode(targetRef));
    ObjectNode propertiesNode = objectMapper.createObjectNode();
    propertiesNode.put(PROPERTY_OVERRIDE_ID, dataAssociation.getId());
    flowNode.put(EDITOR_SHAPE_PROPERTIES, propertiesNode);
    shapesArrayNode.add(flowNode);
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) GraphicInfo(org.activiti.bpmn.model.GraphicInfo) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode)

Example 29 with ArrayNode

use of com.fasterxml.jackson.databind.node.ArrayNode in project Activiti by Activiti.

the class BoundaryEventJsonConverter method convertElementToJson.

protected void convertElementToJson(ObjectNode propertiesNode, BaseElement baseElement) {
    BoundaryEvent boundaryEvent = (BoundaryEvent) baseElement;
    ArrayNode dockersArrayNode = objectMapper.createArrayNode();
    ObjectNode dockNode = objectMapper.createObjectNode();
    GraphicInfo graphicInfo = model.getGraphicInfo(boundaryEvent.getId());
    GraphicInfo parentGraphicInfo = model.getGraphicInfo(boundaryEvent.getAttachedToRef().getId());
    dockNode.put(EDITOR_BOUNDS_X, graphicInfo.getX() - parentGraphicInfo.getX());
    dockNode.put(EDITOR_BOUNDS_Y, graphicInfo.getY() - parentGraphicInfo.getY());
    dockersArrayNode.add(dockNode);
    flowElementNode.put("dockers", dockersArrayNode);
    propertiesNode.put(PROPERTY_CANCEL_ACTIVITY, boundaryEvent.isCancelActivity());
    addEventProperties(boundaryEvent, propertiesNode);
}
Also used : BoundaryEvent(org.activiti.bpmn.model.BoundaryEvent) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) GraphicInfo(org.activiti.bpmn.model.GraphicInfo) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode)

Example 30 with ArrayNode

use of com.fasterxml.jackson.databind.node.ArrayNode in project Activiti by Activiti.

the class UserTaskJsonConverter method convertElementToJson.

@Override
protected void convertElementToJson(ObjectNode propertiesNode, BaseElement baseElement) {
    UserTask userTask = (UserTask) baseElement;
    String assignee = userTask.getAssignee();
    String owner = userTask.getOwner();
    if (StringUtils.isNotEmpty(assignee) || StringUtils.isNotEmpty(owner) || CollectionUtils.isNotEmpty(userTask.getCandidateUsers()) || CollectionUtils.isNotEmpty(userTask.getCandidateGroups())) {
        ObjectNode assignmentNode = objectMapper.createObjectNode();
        ObjectNode assignmentValuesNode = objectMapper.createObjectNode();
        if (StringUtils.isNotEmpty(assignee)) {
            assignmentValuesNode.put(PROPERTY_USERTASK_ASSIGNEE, assignee);
        }
        if (StringUtils.isNotEmpty(owner)) {
            assignmentValuesNode.put(PROPERTY_USERTASK_OWNER, owner);
        }
        if (CollectionUtils.isNotEmpty(userTask.getCandidateUsers())) {
            ArrayNode candidateArrayNode = objectMapper.createArrayNode();
            for (String candidateUser : userTask.getCandidateUsers()) {
                ObjectNode candidateNode = objectMapper.createObjectNode();
                candidateNode.put("value", candidateUser);
                candidateArrayNode.add(candidateNode);
            }
            assignmentValuesNode.put(PROPERTY_USERTASK_CANDIDATE_USERS, candidateArrayNode);
        }
        if (CollectionUtils.isNotEmpty(userTask.getCandidateGroups())) {
            ArrayNode candidateArrayNode = objectMapper.createArrayNode();
            for (String candidateGroup : userTask.getCandidateGroups()) {
                ObjectNode candidateNode = objectMapper.createObjectNode();
                candidateNode.put("value", candidateGroup);
                candidateArrayNode.add(candidateNode);
            }
            assignmentValuesNode.put(PROPERTY_USERTASK_CANDIDATE_GROUPS, candidateArrayNode);
        }
        assignmentNode.put("assignment", assignmentValuesNode);
        propertiesNode.put(PROPERTY_USERTASK_ASSIGNMENT, assignmentNode);
    }
    if (userTask.getPriority() != null) {
        setPropertyValue(PROPERTY_USERTASK_PRIORITY, userTask.getPriority().toString(), propertiesNode);
    }
    if (StringUtils.isNotEmpty(userTask.getFormKey())) {
        setPropertyValue(PROPERTY_FORMKEY, userTask.getFormKey(), propertiesNode);
    }
    setPropertyValue(PROPERTY_USERTASK_DUEDATE, userTask.getDueDate(), propertiesNode);
    setPropertyValue(PROPERTY_USERTASK_CATEGORY, userTask.getCategory(), propertiesNode);
    addFormProperties(userTask.getFormProperties(), propertiesNode);
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) UserTask(org.activiti.bpmn.model.UserTask) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode)

Aggregations

ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)711 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)383 JsonNode (com.fasterxml.jackson.databind.JsonNode)296 Test (org.junit.Test)113 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)90 ArrayList (java.util.ArrayList)67 IOException (java.io.IOException)62 HashMap (java.util.HashMap)50 Map (java.util.Map)50 TextNode (com.fasterxml.jackson.databind.node.TextNode)30 DefaultSerializerProvider (com.fasterxml.jackson.databind.ser.DefaultSerializerProvider)30 Deployment (org.activiti.engine.test.Deployment)23 List (java.util.List)22 HashSet (java.util.HashSet)21 ArrayNode (org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.ArrayNode)20 StringEntity (org.apache.http.entity.StringEntity)20 JsonNodeFactory (com.fasterxml.jackson.databind.node.JsonNodeFactory)19 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)19 Cluster (org.apache.geode.tools.pulse.internal.data.Cluster)18 HttpPost (org.apache.http.client.methods.HttpPost)16