Merge "Architecture documentation updates"
[policy/engine.git] / POLICY-SDK-APP / src / main / java / org / onap / policy / controller / CreateClosedLoopPMController.java
index a4d6014..392adf0 100644 (file)
@@ -98,23 +98,24 @@ public class CreateClosedLoopPMController{
                                                                                String attributeId = designator.getAttributeId();
 
                                                                                // First match in the target is OnapName, so set that value.
-                                                                               if (attributeId.equals("ONAPName")) {
+                                                                               if ("ONAPName".equals(attributeId)) {
                                                                                        policyAdapter.setOnapName(value);
                                                                                }
-                                                                               if (attributeId.equals("RiskType")){
+                                                                               if ("RiskType".equals(attributeId)){
                                                                                        policyAdapter.setRiskType(value);
                                                                                }
-                                                                               if (attributeId.equals("RiskLevel")){
+                                                                               if ("RiskLevel".equals(attributeId)){
                                                                                        policyAdapter.setRiskLevel(value);
                                                                                }
-                                                                               if (attributeId.equals("guard")){
+                                                                               if ("guard".equals(attributeId)){
                                                                                        policyAdapter.setGuard(value);
                                                                                }
-                                                                               if (attributeId.equals("TTLDate") && !value.contains("NA")){
-                                                                                       String newDate = convertDate(value, true);
+                                                                               if ("TTLDate".equals(attributeId) && !value.contains("NA")){
+                                                                                       PolicyController controller = new PolicyController();
+                                                                                       String newDate = controller.convertDate(value);
                                                                                        policyAdapter.setTtlDate(newDate);
                                                                                }
-                                                                               if (attributeId.equals("ServiceType")){
+                                                                               if ("ServiceType".equals(attributeId)){
                                                                                        LinkedHashMap<String, String> serviceTypePolicyName1 = new LinkedHashMap<>();
                                                                                        String key = "serviceTypePolicyName";
                                                                                        serviceTypePolicyName1.put(key, value);
@@ -140,22 +141,6 @@ public class CreateClosedLoopPMController{
                }               
        }
 
-       private String convertDate(String dateTTL, boolean portalType) {
-               String formateDate = null;
-               String[] date;
-               String[] parts;
-
-               if (portalType){
-                       parts = dateTTL.split("-");
-                       formateDate = parts[2] + "-" + parts[1] + "-" + parts[0] + "T05:00:00.000Z";
-               } else {
-                       date  = dateTTL.split("T");
-                       parts = date[0].split("-");
-                       formateDate = parts[2] + "-" + parts[1] + "-" + parts[0];
-               }
-               return formateDate;
-       }
-
        protected void readClosedLoopJSONFile(PolicyRestAdapter policyAdapter, PolicyEntity entity) {
                ObjectMapper mapper = new ObjectMapper();
                try {