X-Git-Url: https://gerrit.onap.org/r/gitweb?p=policy%2Fengine.git;a=blobdiff_plain;f=ONAP-REST%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fpolicy%2Frest%2Fadapter%2FPolicyRestAdapter.java;h=e7879a855ea2da6bdbfdd3837e1156ff0eecc41b;hp=0a3f46c78b2e1f69a7d37017b058c1eac27e3c06;hb=2f3ca9fc5edc5a52659b3486605e0db508143318;hpb=9beb01fafe35a819d85bc66668b499f25aa0857a diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/PolicyRestAdapter.java b/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/PolicyRestAdapter.java index 0a3f46c78..e7879a855 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/PolicyRestAdapter.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/PolicyRestAdapter.java @@ -23,7 +23,9 @@ package org.onap.policy.rest.adapter; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; + import javax.persistence.EntityManagerFactory; + import org.onap.policy.rest.jpa.OnapName; public class PolicyRestAdapter { @@ -1154,4 +1156,55 @@ public class PolicyRestAdapter { public void setUiJsonBody(String uiJsonBody) { this.uiJsonBody = uiJsonBody; } + + public boolean setupUsingAttribute(String attributeId, String value) { + switch (attributeId) { + case "ONAPName": + this.setOnapName(value); + OnapName tempOnapName = new OnapName(); + tempOnapName.setName(value); + this.setOnapNameField(tempOnapName); + return true; + case "RiskType": + this.setRiskType(value); + return true; + case "RiskLevel": + this.setRiskLevel(value); + return true; + case "guard": + this.setGuard(value); + return true; + case "ConfigName": + this.setConfigName(value); + return true; + case "uuid": + this.setUuid(value); + return true; + case "location": + this.setLocation(value); + return true; + case "TTLDate": + if (!value.contains("NA")) { + this.setTtlDate(PolicyRestAdapter.convertDate(value)); + return true; + } + return false; + default: + return false; + } + } + + /** + * Function to convert date. + * + * @param dateTimeToLive input date value. + * @return + */ + private static String convertDate(String dateTimeToLive) { + String formatDate = null; + if (dateTimeToLive.contains("-")) { + formatDate = dateTimeToLive.replace("-", "/"); + } + return formatDate; + } }