diff options
author | Pamela Dragosh <pdragosh@research.att.com> | 2019-10-22 07:53:44 -0400 |
---|---|---|
committer | Pamela Dragosh <pdragosh@research.att.com> | 2019-10-23 13:33:56 -0400 |
commit | 1e61676b77dd09659027b8984f050df7e8538526 (patch) | |
tree | 115053dba12b4b27a0f92de0e7648a672a66893a /ONAP-REST/src/main/java/org/onap/policy/rest/adapter/PolicyRestAdapter.java | |
parent | f18fbfc026de9cf02126f57844c37abfee607394 (diff) |
Consolidate PolicyRestAdapter setup
Put common code into PolicyEngineUtils that the controllers use to
populate the PolicyRestController.
Also some more sonar cleanup and formatting of XML files.
Shortened 120 line characters. Removed some trailing spaces
from comments.
Fixed up one JUnit.
Licenses.
Issue-ID: POLICY-2133
Change-Id: Id7d8ac3ab60331535f048ec0f26aeb17a099414e
Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
Diffstat (limited to 'ONAP-REST/src/main/java/org/onap/policy/rest/adapter/PolicyRestAdapter.java')
-rw-r--r-- | ONAP-REST/src/main/java/org/onap/policy/rest/adapter/PolicyRestAdapter.java | 51 |
1 files changed, 51 insertions, 0 deletions
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; + } } |