Remove useless code 33/17433/1
authorDeterme, Sebastien (sd378r) <sd378r@intl.att.com>
Fri, 6 Oct 2017 12:07:37 +0000 (14:07 +0200)
committerDeterme, Sebastien (sd378r) <sd378r@intl.att.com>
Fri, 6 Oct 2017 12:07:37 +0000 (14:07 +0200)
This code was always returning an empty map so it has been removed

Change-Id: I7691d2a52b2ea50d4cb8586b2e66b6ecfdd6fe13
Issue-ID: CLAMP-54
Signed-off-by: Determe, Sebastien (sd378r) <sd378r@intl.att.com>
src/main/java/org/onap/clamp/clds/service/CldsTemplateService.java

index e29b188..73b593c 100644 (file)
@@ -26,18 +26,10 @@ package org.onap.clamp.clds.service;
 import com.att.ajsc.common.AjscService;
 import com.fasterxml.jackson.core.JsonParseException;
 import com.fasterxml.jackson.databind.JsonMappingException;
 import com.att.ajsc.common.AjscService;
 import com.fasterxml.jackson.core.JsonParseException;
 import com.fasterxml.jackson.databind.JsonMappingException;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
 
 import java.io.IOException;
 import java.util.Date;
 
 import java.io.IOException;
 import java.util.Date;
-import java.util.HashMap;
-import java.util.Iterator;
 import java.util.List;
 import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
 
 import javax.annotation.PostConstruct;
 import javax.ws.rs.Consumes;
 
 import javax.annotation.PostConstruct;
 import javax.ws.rs.Consumes;
@@ -52,7 +44,6 @@ import javax.xml.transform.TransformerException;
 import org.onap.clamp.clds.dao.CldsDao;
 import org.onap.clamp.clds.model.CldsTemplate;
 import org.onap.clamp.clds.model.ValueItem;
 import org.onap.clamp.clds.dao.CldsDao;
 import org.onap.clamp.clds.model.CldsTemplate;
 import org.onap.clamp.clds.model.ValueItem;
-import org.onap.clamp.clds.model.prop.ModelBpmn;
 import org.onap.clamp.clds.transform.XslTransformer;
 import org.onap.clamp.clds.util.LoggingUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.onap.clamp.clds.transform.XslTransformer;
 import org.onap.clamp.clds.util.LoggingUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -65,8 +56,6 @@ import org.springframework.beans.factory.annotation.Value;
 @Path("/cldsTempate")
 public class CldsTemplateService extends SecureServiceBase {
 
 @Path("/cldsTempate")
 public class CldsTemplateService extends SecureServiceBase {
 
-    private static final String     POLICY_KEY       = "Policy";
-
     @Value("${CLDS_PERMISSION_TYPE_TEMPLATE:permission-type-template}")
     private String                  cldsPermissionTypeTemplate;
 
     @Value("${CLDS_PERMISSION_TYPE_TEMPLATE:permission-type-template}")
     private String                  cldsPermissionTypeTemplate;
 
@@ -244,14 +233,6 @@ public class CldsTemplateService extends SecureServiceBase {
         String bpmnText = cldsTemplate.getBpmnText();
         String imageText = cldsTemplate.getImageText();
         String propText = cldsTemplate.getPropText();
         String bpmnText = cldsTemplate.getBpmnText();
         String imageText = cldsTemplate.getImageText();
         String propText = cldsTemplate.getPropText();
-        Map<String, String> newBpmnIdsMap = getNewBpmnIdsMap(bpmnText, cldsTemplate.getPropText());
-        for (String currBpmnId : newBpmnIdsMap.keySet()) {
-            if (currBpmnId != null && newBpmnIdsMap.get(currBpmnId) != null) {
-                bpmnText = bpmnText.replace(currBpmnId, newBpmnIdsMap.get(currBpmnId));
-                imageText = imageText.replace(currBpmnId, newBpmnIdsMap.get(currBpmnId));
-                propText = propText.replace(currBpmnId, newBpmnIdsMap.get(currBpmnId));
-            }
-        }
         cldsTemplate.setBpmnText(bpmnText);
         cldsTemplate.setImageText(imageText);
         cldsTemplate.setPropText(propText);
         cldsTemplate.setBpmnText(bpmnText);
         cldsTemplate.setImageText(imageText);
         cldsTemplate.setPropText(propText);
@@ -288,49 +269,4 @@ public class CldsTemplateService extends SecureServiceBase {
         auditLogger.info("GET template names completed");
         return names;
     }
         auditLogger.info("GET template names completed");
         return names;
     }
-
-    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;
-    }
 }
 }