-
- private Map<String, String> getNewBpmnIdsMap(String bpmnText, String propText)
- throws TransformerException, IOException {
- /**
- * Test sample code start
- */
- String bpmnJson = cldsBpmnTransformer.doXslTransformToString(bpmnText);
- ModelBpmn templateBpmn = ModelBpmn.create(bpmnJson);
- List<String> bpmnElementIds = templateBpmn.getBpmnElementIds();
- logger.info("value of elementIds:" + bpmnElementIds);
- logger.info("value of prop text:" + propText);
- Map<String, String> bpmnIoIdsMap = new HashMap<>();
- if (bpmnElementIds != null && !bpmnElementIds.isEmpty()) {
- ObjectMapper objectMapper = new ObjectMapper();
- ObjectNode root = objectMapper.readValue(propText, ObjectNode.class);
- Iterator<Entry<String, JsonNode>> entryItr = root.fields();
- while (entryItr.hasNext()) {
- // process the entry
- Entry<String, JsonNode> entry = entryItr.next();
- String keyPropName = entry.getKey();
- for (String currElementId : bpmnElementIds) {
- if (keyPropName != null && keyPropName.equalsIgnoreCase(currElementId)) {
- ArrayNode arrayNode = (ArrayNode) entry.getValue();
- // process each id/from object, like:
- // {"id":"Policy_11r50j1", "from":"StartEvent_1"}
- for (JsonNode anArrayNode : arrayNode) {
- ObjectNode node = (ObjectNode) anArrayNode;
- String valueNode = node.get("value").asText();
- logger.info("value of node:" + valueNode);
- if (keyPropName.startsWith(POLICY_KEY)) {
- valueNode = POLICY_KEY + "_" + valueNode;
- }
- bpmnIoIdsMap.put(keyPropName, valueNode);
- }
- break;
- }
- }
- }
- }
- logger.info("value of hashmap:" + bpmnIoIdsMap);
- /**
- * Test sample code end
- */
- return bpmnIoIdsMap;
- }