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=97e6e9ef6fe951c3299e774b5f5c27d103df5621;hp=0a3f46c78b2e1f69a7d37017b058c1eac27e3c06;hb=1e61676b77dd09659027b8984f050df7e8538526;hpb=f18fbfc026de9cf02126f57844c37abfee607394 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..97e6e9ef6 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 @@ -1154,4 +1154,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.setOnapName(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; + } }