Search in sources :

Example 51 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 52 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 53 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 54 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)

Example 55 with ArrayNode

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

the class BpmnJsonConverterUtil method convertDataPropertiesToJson.

public static void convertDataPropertiesToJson(List<ValuedDataObject> dataObjects, ObjectNode propertiesNode) {
    ObjectNode dataPropertiesNode = objectMapper.createObjectNode();
    ArrayNode itemsNode = objectMapper.createArrayNode();
    for (ValuedDataObject dObj : dataObjects) {
        ObjectNode propertyItemNode = objectMapper.createObjectNode();
        propertyItemNode.put(PROPERTY_DATA_ID, dObj.getId());
        propertyItemNode.put(PROPERTY_DATA_NAME, dObj.getName());
        String itemSubjectRefQName = dObj.getItemSubjectRef().getStructureRef();
        // remove namespace prefix
        String dataType = itemSubjectRefQName.substring(itemSubjectRefQName.indexOf(':') + 1);
        propertyItemNode.put(PROPERTY_DATA_TYPE, dataType);
        Object dObjValue = dObj.getValue();
        String value = new String();
        if (null == dObjValue) {
            propertyItemNode.put(PROPERTY_DATA_VALUE, "");
        } else {
            if ("datetime".equals(dataType)) {
                value = new DateTime(dObjValue).toString("yyyy-MM-dd'T'hh:mm:ss");
            } else {
                value = new String(dObjValue.toString());
            }
            propertyItemNode.put(PROPERTY_DATA_VALUE, value.toString());
        }
        itemsNode.add(propertyItemNode);
    }
    dataPropertiesNode.put(EDITOR_PROPERTIES_GENERAL_ITEMS, itemsNode);
    propertiesNode.put("dataproperties", dataPropertiesNode);
}
Also used : ValuedDataObject(org.activiti.bpmn.model.ValuedDataObject) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) StringDataObject(org.activiti.bpmn.model.StringDataObject) DoubleDataObject(org.activiti.bpmn.model.DoubleDataObject) LongDataObject(org.activiti.bpmn.model.LongDataObject) BooleanDataObject(org.activiti.bpmn.model.BooleanDataObject) ValuedDataObject(org.activiti.bpmn.model.ValuedDataObject) IntegerDataObject(org.activiti.bpmn.model.IntegerDataObject) DateDataObject(org.activiti.bpmn.model.DateDataObject) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) DateTime(org.joda.time.DateTime)

Aggregations

ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)277 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)167 JsonNode (com.fasterxml.jackson.databind.JsonNode)97 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)57 ArrayList (java.util.ArrayList)32 HashMap (java.util.HashMap)27 Test (org.junit.Test)25 Deployment (org.activiti.engine.test.Deployment)23 StringEntity (org.apache.http.entity.StringEntity)20 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)19 Cluster (org.apache.geode.tools.pulse.internal.data.Cluster)18 IOException (java.io.IOException)16 Map (java.util.Map)16 HttpPost (org.apache.http.client.methods.HttpPost)16 CloseableHttpResponse (org.apache.http.client.methods.CloseableHttpResponse)14 Task (org.activiti.engine.task.Task)13 GraphicInfo (org.activiti.bpmn.model.GraphicInfo)10 TextNode (com.fasterxml.jackson.databind.node.TextNode)8 JsonNodeFactory (com.fasterxml.jackson.databind.node.JsonNodeFactory)7 MissingNode (com.fasterxml.jackson.databind.node.MissingNode)7