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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations