From: liamfallon Date: Thu, 7 Nov 2019 10:38:07 +0000 (+0000) Subject: JUnit/SONAR/Checkstyle in ONAP-REST X-Git-Tag: 1.6.0~44^2 X-Git-Url: https://gerrit.onap.org/r/gitweb?p=policy%2Fengine.git;a=commitdiff_plain;h=e4ac1ef3c51fc9afe44849ada5bea8c3d6057897 JUnit/SONAR/Checkstyle in ONAP-REST Second batch of JPA pojos (B-D), with JUnit added and SONAR/Checkstyle issues addressed. In cases where a class name change caused an update in another package, the license header on files for those knock on changes are not updated. Issue-ID: POLICY-2131 Change-Id: I9466f27ffa606001209ed978be592ae95d1b32c4 Signed-off-by: liamfallon --- diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/CreateBRMSRuleTemplate.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/CreateBRMSRuleTemplate.java index 8321505de..2151a1988 100644 --- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/CreateBRMSRuleTemplate.java +++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/CreateBRMSRuleTemplate.java @@ -27,7 +27,7 @@ import java.util.Map; import org.onap.policy.common.logging.flexlogger.FlexLogger; import org.onap.policy.common.logging.flexlogger.Logger; import org.onap.policy.rest.dao.CommonClassDao; -import org.onap.policy.rest.jpa.BRMSParamTemplate; +import org.onap.policy.rest.jpa.BrmsParamTemplate; import org.onap.policy.rest.jpa.UserInfo; import org.onap.policy.utils.PolicyUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -50,13 +50,13 @@ public class CreateBRMSRuleTemplate { Map responseMap = new HashMap<>(); if (rule != null && !PolicyUtils.brmsRawValidate(rule).contains("[ERR")) { List duplicateData = - commonClassDao.checkDuplicateEntry(ruleName, "ruleName", BRMSParamTemplate.class); + commonClassDao.checkDuplicateEntry(ruleName, "ruleName", BrmsParamTemplate.class); if (duplicateData != null && !duplicateData.isEmpty()) { LOGGER.error("Import new service failed. Service already exists"); responseMap.put("DBError", "EXISTS"); return responseMap; } else { - BRMSParamTemplate brmsParamTemplate = new BRMSParamTemplate(); + BrmsParamTemplate brmsParamTemplate = new BrmsParamTemplate(); brmsParamTemplate.setDescription(description); brmsParamTemplate.setRuleName(ruleName); brmsParamTemplate.setRule(rule); diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/CreateBrmsParamPolicy.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/CreateBrmsParamPolicy.java index 7be1d39b0..36ab893fe 100644 --- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/CreateBrmsParamPolicy.java +++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/CreateBrmsParamPolicy.java @@ -66,7 +66,7 @@ import org.onap.policy.common.logging.flexlogger.Logger; import org.onap.policy.pap.xacml.rest.controller.BRMSDictionaryController; import org.onap.policy.pap.xacml.rest.daoimpl.CommonClassDaoImpl; import org.onap.policy.rest.adapter.PolicyRestAdapter; -import org.onap.policy.rest.jpa.BRMSParamTemplate; +import org.onap.policy.rest.jpa.BrmsParamTemplate; public class CreateBrmsParamPolicy extends Policy { @@ -189,7 +189,7 @@ public class CreateBrmsParamPolicy extends Policy { params.put("templateName", templateName); List result = dbConnection.getDataByQuery(queryString, params); if (!result.isEmpty()) { - BRMSParamTemplate template = (BRMSParamTemplate) result.get(0); + BrmsParamTemplate template = (BrmsParamTemplate) result.get(0); ruleTemplate = template.getRule(); } return ruleTemplate; diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/BRMSDictionaryController.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/BRMSDictionaryController.java index a669d82a0..d9cde35bb 100644 --- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/BRMSDictionaryController.java +++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/BRMSDictionaryController.java @@ -40,9 +40,9 @@ import org.onap.policy.common.logging.flexlogger.Logger; import org.onap.policy.pap.xacml.rest.components.CreateBRMSRuleTemplate; import org.onap.policy.pap.xacml.rest.util.DictionaryUtils; import org.onap.policy.rest.dao.CommonClassDao; -import org.onap.policy.rest.jpa.BRMSController; -import org.onap.policy.rest.jpa.BRMSDependency; -import org.onap.policy.rest.jpa.BRMSParamTemplate; +import org.onap.policy.rest.jpa.BrmsController; +import org.onap.policy.rest.jpa.BrmsDependency; +import org.onap.policy.rest.jpa.BrmsParamTemplate; import org.onap.policy.rest.jpa.OnapName; import org.onap.policy.rest.jpa.UserInfo; import org.onap.policy.utils.PolicyUtils; @@ -99,7 +99,7 @@ public class BRMSDictionaryController { produces = MediaType.APPLICATION_JSON_VALUE) public void getBRMSParamDictionaryByNameEntityData(HttpServletResponse response) { DictionaryUtils utils = getDictionaryUtilsInstance(); - utils.getDataByEntity(response, brmsParamDatas, ruleName, BRMSParamTemplate.class); + utils.getDataByEntity(response, brmsParamDatas, ruleName, BrmsParamTemplate.class); } @RequestMapping( @@ -108,7 +108,7 @@ public class BRMSDictionaryController { produces = MediaType.APPLICATION_JSON_VALUE) public void getBRMSParamDictionaryEntityData(HttpServletResponse response) { DictionaryUtils utils = getDictionaryUtilsInstance(); - utils.getData(response, brmsParamDatas, BRMSParamTemplate.class); + utils.getData(response, brmsParamDatas, BrmsParamTemplate.class); } @RequestMapping(value = {"/brms_dictionary/set_BRMSParamData"}, method = {RequestMethod.POST}) @@ -129,24 +129,24 @@ public class BRMSDictionaryController { mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); JsonNode root = mapper.readTree(request.getReader()); - BRMSParamTemplate bRMSParamTemplateData; + BrmsParamTemplate bRMSParamTemplateData; String userId = null; if (fromAPI) { bRMSParamTemplateData = - mapper.readValue(root.get(dictionaryFields).toString(), BRMSParamTemplate.class); + mapper.readValue(root.get(dictionaryFields).toString(), BrmsParamTemplate.class); userId = "API"; } else { bRMSParamTemplateData = - mapper.readValue(root.get("brmsParamDictionaryData").toString(), BRMSParamTemplate.class); + mapper.readValue(root.get("brmsParamDictionaryData").toString(), BrmsParamTemplate.class); userId = root.get(userid).textValue(); } UserInfo userInfo = utils.getUserInfo(userId); List duplicateData = commonClassDao.checkDuplicateEntry(bRMSParamTemplateData.getRuleName(), - ruleName, BRMSParamTemplate.class); + ruleName, BrmsParamTemplate.class); boolean duplicateflag = false; if (!duplicateData.isEmpty()) { - BRMSParamTemplate data = (BRMSParamTemplate) duplicateData.get(0); + BrmsParamTemplate data = (BrmsParamTemplate) duplicateData.get(0); if (request.getParameter(operation) != null && "update".equals(request.getParameter(operation))) { bRMSParamTemplateData.setId(data.getId()); } else if ((request.getParameter(operation) != null @@ -168,7 +168,7 @@ public class BRMSDictionaryController { } else { commonClassDao.update(bRMSParamTemplateData); } - responseString = mapper.writeValueAsString(commonClassDao.getData(BRMSParamTemplate.class)); + responseString = mapper.writeValueAsString(commonClassDao.getData(BrmsParamTemplate.class)); } else { responseString = duplicateResponseString; } @@ -197,7 +197,7 @@ public class BRMSDictionaryController { @RequestMapping(value = {"/brms_dictionary/remove_brmsParam"}, method = {RequestMethod.POST}) public void removeBRMSParamDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException { DictionaryUtils utils = getDictionaryUtilsInstance(); - utils.removeData(request, response, brmsParamDatas, BRMSParamTemplate.class); + utils.removeData(request, response, brmsParamDatas, BrmsParamTemplate.class); } @RequestMapping( @@ -206,7 +206,7 @@ public class BRMSDictionaryController { produces = MediaType.APPLICATION_JSON_VALUE) public void getBRMSDependencyDictionaryByNameEntityData(HttpServletResponse response) { DictionaryUtils utils = getDictionaryUtilsInstance(); - utils.getDataByEntity(response, brmsDependencyDatas, dependencyName, BRMSDependency.class); + utils.getDataByEntity(response, brmsDependencyDatas, dependencyName, BrmsDependency.class); } @RequestMapping( @@ -215,7 +215,7 @@ public class BRMSDictionaryController { produces = MediaType.APPLICATION_JSON_VALUE) public void getBRMSDependencyDictionaryEntityData(HttpServletResponse response) { DictionaryUtils utils = getDictionaryUtilsInstance(); - utils.getData(response, brmsDependencyDatas, BRMSDependency.class); + utils.getData(response, brmsDependencyDatas, BrmsDependency.class); } @RequestMapping(value = {"/brms_dictionary/save_BRMSDependencyData"}, method = {RequestMethod.POST}) @@ -229,23 +229,23 @@ public class BRMSDictionaryController { mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); JsonNode root = mapper.readTree(request.getReader()); - BRMSDependency brmsDependency; + BrmsDependency brmsDependency; String userId = null; if (fromAPI) { - brmsDependency = mapper.readValue(root.get(dictionaryFields).toString(), BRMSDependency.class); + brmsDependency = mapper.readValue(root.get(dictionaryFields).toString(), BrmsDependency.class); userId = "API"; } else { brmsDependency = - mapper.readValue(root.get("brmsDependencyDictionaryData").toString(), BRMSDependency.class); + mapper.readValue(root.get("brmsDependencyDictionaryData").toString(), BrmsDependency.class); userId = root.get(userid).textValue(); } UserInfo userInfo = utils.getUserInfo(userId); List duplicateData = commonClassDao.checkDuplicateEntry(brmsDependency.getDependencyName(), - dependencyName, BRMSDependency.class); + dependencyName, BrmsDependency.class); boolean duplicateflag = false; if (!duplicateData.isEmpty()) { - BRMSDependency data = (BRMSDependency) duplicateData.get(0); + BrmsDependency data = (BrmsDependency) duplicateData.get(0); if (request.getParameter(operation) != null && "update".equals(request.getParameter(operation))) { brmsDependency.setId(data.getId()); } else if ((request.getParameter(operation) != null @@ -277,7 +277,7 @@ public class BRMSDictionaryController { brmsDependency.setModifiedDate(new Date()); commonClassDao.update(brmsDependency); } - responseString = mapper.writeValueAsString(commonClassDao.getData(BRMSDependency.class)); + responseString = mapper.writeValueAsString(commonClassDao.getData(BrmsDependency.class)); } else { responseString = duplicateResponseString; } @@ -305,7 +305,7 @@ public class BRMSDictionaryController { public void removeBRMSDependencyDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException { DictionaryUtils utils = getDictionaryUtilsInstance(); - utils.removeData(request, response, brmsDependencyDatas, BRMSDependency.class); + utils.removeData(request, response, brmsDependencyDatas, BrmsDependency.class); } @RequestMapping( @@ -314,7 +314,7 @@ public class BRMSDictionaryController { produces = MediaType.APPLICATION_JSON_VALUE) public void getBRMSControllerDictionaryByNameEntityData(HttpServletResponse response) { DictionaryUtils utils = getDictionaryUtilsInstance(); - utils.getDataByEntity(response, brmsControllerDatas, controllerName, BRMSController.class); + utils.getDataByEntity(response, brmsControllerDatas, controllerName, BrmsController.class); } @RequestMapping( @@ -323,7 +323,7 @@ public class BRMSDictionaryController { produces = MediaType.APPLICATION_JSON_VALUE) public void getBRMSControllerDictionaryEntityData(HttpServletResponse response) { DictionaryUtils utils = getDictionaryUtilsInstance(); - utils.getData(response, brmsControllerDatas, BRMSController.class); + utils.getData(response, brmsControllerDatas, BrmsController.class); } @RequestMapping(value = {"/brms_dictionary/save_BRMSControllerData"}, method = {RequestMethod.POST}) @@ -336,23 +336,23 @@ public class BRMSDictionaryController { ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); JsonNode root = mapper.readTree(request.getReader()); - BRMSController brmsController; + BrmsController brmsController; String userId = null; if (fromAPI) { - brmsController = mapper.readValue(root.get(dictionaryFields).toString(), BRMSController.class); + brmsController = mapper.readValue(root.get(dictionaryFields).toString(), BrmsController.class); userId = "API"; } else { brmsController = - mapper.readValue(root.get("brmsControllerDictionaryData").toString(), BRMSController.class); + mapper.readValue(root.get("brmsControllerDictionaryData").toString(), BrmsController.class); userId = root.get(userid).textValue(); } UserInfo userInfo = utils.getUserInfo(userId); List duplicateData = commonClassDao.checkDuplicateEntry(brmsController.getControllerName(), - controllerName, BRMSController.class); + controllerName, BrmsController.class); boolean duplicateflag = false; if (!duplicateData.isEmpty()) { - BRMSController data = (BRMSController) duplicateData.get(0); + BrmsController data = (BrmsController) duplicateData.get(0); if (request.getParameter(operation) != null && "update".equals(request.getParameter(operation))) { brmsController.setId(data.getId()); } else if ((request.getParameter(operation) != null @@ -409,16 +409,16 @@ public class BRMSDictionaryController { public void removeBRMSControllerDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException { DictionaryUtils utils = getDictionaryUtilsInstance(); - utils.removeData(request, response, brmsControllerDatas, BRMSController.class); + utils.removeData(request, response, brmsControllerDatas, BrmsController.class); } - public BRMSDependency getDependencyDataByID(String dependencyName) { - return (BRMSDependency) commonClassDao.getEntityItem(BRMSDependency.class, + public BrmsDependency getDependencyDataByID(String dependencyName) { + return (BrmsDependency) commonClassDao.getEntityItem(BrmsDependency.class, BRMSDictionaryController.dependencyName, dependencyName); } - public BRMSController getControllerDataByID(String controllerName) { - return (BRMSController) commonClassDao.getEntityItem(BRMSController.class, + public BrmsController getControllerDataByID(String controllerName) { + return (BrmsController) commonClassDao.getEntityItem(BrmsController.class, BRMSDictionaryController.controllerName, controllerName); } } diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/DictionaryImportController.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/DictionaryImportController.java index f56da990c..7400eb0c8 100644 --- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/DictionaryImportController.java +++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/DictionaryImportController.java @@ -44,9 +44,9 @@ import org.onap.policy.rest.jpa.ActionList; import org.onap.policy.rest.jpa.ActionPolicyDict; import org.onap.policy.rest.jpa.AddressGroup; import org.onap.policy.rest.jpa.Attribute; -import org.onap.policy.rest.jpa.BRMSController; -import org.onap.policy.rest.jpa.BRMSDependency; -import org.onap.policy.rest.jpa.BRMSParamTemplate; +import org.onap.policy.rest.jpa.BrmsController; +import org.onap.policy.rest.jpa.BrmsDependency; +import org.onap.policy.rest.jpa.BrmsParamTemplate; import org.onap.policy.rest.jpa.Category; import org.onap.policy.rest.jpa.ClosedLoopD2Services; import org.onap.policy.rest.jpa.ClosedLoopSite; @@ -439,7 +439,7 @@ public class DictionaryImportController { } if (dictionaryName.startsWith("BRMSParamDictionary")) { for (int i = 1; i < dictSheet.size(); i++) { - BRMSParamTemplate attribute = new BRMSParamTemplate(); + BrmsParamTemplate attribute = new BrmsParamTemplate(); UserInfo userinfo = new UserInfo(); userinfo.setUserLoginId(userId); attribute.setUserCreatedBy(userinfo); @@ -461,7 +461,7 @@ public class DictionaryImportController { } if (dictionaryName.startsWith("BRMSControllerDictionary")) { for (int i = 1; i < dictSheet.size(); i++) { - BRMSController attribute = new BRMSController(); + BrmsController attribute = new BrmsController(); UserInfo userinfo = new UserInfo(); userinfo.setUserLoginId(userId); attribute.setUserCreatedBy(userinfo); @@ -483,7 +483,7 @@ public class DictionaryImportController { } if (dictionaryName.startsWith("BRMSDependencyDictionary")) { for (int i = 1; i < dictSheet.size(); i++) { - BRMSDependency attribute = new BRMSDependency(); + BrmsDependency attribute = new BrmsDependency(); UserInfo userinfo = new UserInfo(); userinfo.setUserLoginId(userId); attribute.setUserCreatedBy(userinfo); diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/MicroServiceDictionaryController.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/MicroServiceDictionaryController.java index 1582dab19..dfd7af48d 100644 --- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/MicroServiceDictionaryController.java +++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/controller/MicroServiceDictionaryController.java @@ -45,7 +45,7 @@ import org.onap.policy.pap.xacml.rest.XACMLPapServlet; import org.onap.policy.pap.xacml.rest.util.DictionaryUtils; import org.onap.policy.pap.xacml.rest.util.JsonMessage; import org.onap.policy.rest.dao.CommonClassDao; -import org.onap.policy.rest.jpa.DCAEuuid; +import org.onap.policy.rest.jpa.DcaeUuid; import org.onap.policy.rest.jpa.DictionaryData; import org.onap.policy.rest.jpa.MicroServiceAttribute; import org.onap.policy.rest.jpa.MicroServiceConfigName; @@ -119,7 +119,7 @@ public class MicroServiceDictionaryController { produces = MediaType.APPLICATION_JSON_VALUE) public void getDCAEUUIDDictionaryByNameEntityData(HttpServletResponse response) { DictionaryUtils utils = getDictionaryUtilsInstance(); - utils.getDataByEntity(response, dcaeUUIDDatas, "name", DCAEuuid.class); + utils.getDataByEntity(response, dcaeUUIDDatas, "name", DcaeUuid.class); } @RequestMapping( @@ -128,7 +128,7 @@ public class MicroServiceDictionaryController { produces = MediaType.APPLICATION_JSON_VALUE) public void getDCAEUUIDDictionaryEntityData(HttpServletResponse response) { DictionaryUtils utils = getDictionaryUtilsInstance(); - utils.getData(response, dcaeUUIDDatas, DCAEuuid.class); + utils.getData(response, dcaeUUIDDatas, DcaeUuid.class); } @RequestMapping(value = {"/ms_dictionary/save_dcaeUUID"}, method = {RequestMethod.POST}) @@ -140,17 +140,17 @@ public class MicroServiceDictionaryController { ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); JsonNode root = mapper.readTree(request.getReader()); - DCAEuuid dCAEuuid; + DcaeUuid dCAEuuid; if (fromAPI) { - dCAEuuid = mapper.readValue(root.get(dictionaryFields).toString(), DCAEuuid.class); + dCAEuuid = mapper.readValue(root.get(dictionaryFields).toString(), DcaeUuid.class); } else { - dCAEuuid = mapper.readValue(root.get("dcaeUUIDDictionaryData").toString(), DCAEuuid.class); + dCAEuuid = mapper.readValue(root.get("dcaeUUIDDictionaryData").toString(), DcaeUuid.class); } - List duplicateData = commonClassDao.checkDuplicateEntry(dCAEuuid.getName(), "name", DCAEuuid.class); + List duplicateData = commonClassDao.checkDuplicateEntry(dCAEuuid.getName(), "name", DcaeUuid.class); boolean duplicateflag = false; if (duplicateData != null && !duplicateData.isEmpty()) { - DCAEuuid data = (DCAEuuid) duplicateData.get(0); + DcaeUuid data = (DcaeUuid) duplicateData.get(0); if (request.getParameter(operation) != null && "update".equals(request.getParameter(operation))) { dCAEuuid.setId(data.getId()); } else if ((request.getParameter(operation) != null @@ -166,7 +166,7 @@ public class MicroServiceDictionaryController { } else { commonClassDao.update(dCAEuuid); } - responseString = mapper.writeValueAsString(commonClassDao.getData(DCAEuuid.class)); + responseString = mapper.writeValueAsString(commonClassDao.getData(DcaeUuid.class)); } else { responseString = duplicateResponseString; } @@ -184,7 +184,7 @@ public class MicroServiceDictionaryController { @RequestMapping(value = {"/ms_dictionary/remove_dcaeuuid"}, method = {RequestMethod.POST}) public void removeDCAEUUIDDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException { DictionaryUtils utils = getDictionaryUtilsInstance(); - utils.removeData(request, response, dcaeUUIDDatas, DCAEuuid.class); + utils.removeData(request, response, dcaeUUIDDatas, DcaeUuid.class); } @RequestMapping( diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/elk/client/PolicyElasticSearchController.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/elk/client/PolicyElasticSearchController.java index 36ecf83b8..ad6b9cf8e 100644 --- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/elk/client/PolicyElasticSearchController.java +++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/elk/client/PolicyElasticSearchController.java @@ -48,10 +48,10 @@ import org.onap.policy.rest.adapter.PolicyRestAdapter; import org.onap.policy.rest.dao.CommonClassDao; import org.onap.policy.rest.jpa.ActionPolicyDict; import org.onap.policy.rest.jpa.Attribute; -import org.onap.policy.rest.jpa.BRMSParamTemplate; +import org.onap.policy.rest.jpa.BrmsParamTemplate; import org.onap.policy.rest.jpa.ClosedLoopD2Services; import org.onap.policy.rest.jpa.ClosedLoopSite; -import org.onap.policy.rest.jpa.DCAEuuid; +import org.onap.policy.rest.jpa.DcaeUuid; import org.onap.policy.rest.jpa.DecisionSettings; import org.onap.policy.rest.jpa.DescriptiveScope; import org.onap.policy.rest.jpa.GroupPolicyScopeList; @@ -350,8 +350,8 @@ public class PolicyElasticSearchController { policyList = searchElkDatabase(action, "actionAttributeValue", value); break; case brmsParam: - BRMSParamTemplate bRMSParamTemplate = - mapper.readValue(root.get("data").toString(), BRMSParamTemplate.class); + BrmsParamTemplate bRMSParamTemplate = + mapper.readValue(root.get("data").toString(), BrmsParamTemplate.class); value = bRMSParamTemplate.getRuleName(); policyList = searchElkDatabase(config, "ruleName", value); break; @@ -399,7 +399,7 @@ public class PolicyElasticSearchController { policyList = searchElkDatabase(config, pholder, value); break; case msDCAEUUID: - DCAEuuid dcaeUUID = mapper.readValue(root.get("data").toString(), DCAEuuid.class); + DcaeUuid dcaeUUID = mapper.readValue(root.get("data").toString(), DcaeUuid.class); value = dcaeUUID.getName(); policyList = searchElkDatabase(config, "uuid", value); break; diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/policycontroller/PolicyCreation.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/policycontroller/PolicyCreation.java index 34ea2c099..29b244046 100644 --- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/policycontroller/PolicyCreation.java +++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/policycontroller/PolicyCreation.java @@ -56,7 +56,7 @@ import org.onap.policy.pap.xacml.rest.util.AbstractPolicyCreation; import org.onap.policy.rest.adapter.PolicyRestAdapter; import org.onap.policy.rest.dao.CommonClassDao; import org.onap.policy.rest.jpa.ActionPolicyDict; -import org.onap.policy.rest.jpa.BRMSParamTemplate; +import org.onap.policy.rest.jpa.BrmsParamTemplate; import org.onap.policy.rest.jpa.PolicyEditorScopes; import org.onap.policy.rest.jpa.PolicyVersion; import org.onap.policy.rest.jpa.UserInfo; @@ -314,8 +314,8 @@ public class PolicyCreation extends AbstractPolicyCreation { String modelName = drlRuleAndUiParams.get("templateName"); PolicyLogger.info("Template name from API is: " + modelName); - BRMSParamTemplate template = (BRMSParamTemplate) commonClassDao - .getEntityItem(BRMSParamTemplate.class, "ruleName", modelName); + BrmsParamTemplate template = (BrmsParamTemplate) commonClassDao + .getEntityItem(BrmsParamTemplate.class, "ruleName", modelName); if (template == null) { String message = XACMLErrorConstants.ERROR_DATA_ISSUE + "Invalid Template. The template name, " diff --git a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/test/XACMLPAPTest.java b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/test/XACMLPAPTest.java index ebfbf551f..10fcd300d 100644 --- a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/test/XACMLPAPTest.java +++ b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/test/XACMLPAPTest.java @@ -71,7 +71,7 @@ import org.onap.policy.pap.xacml.rest.policycontroller.PolicyCreation; import org.onap.policy.pap.xacml.rest.util.DictionaryUtils; import org.onap.policy.rest.dao.CommonClassDao; import org.onap.policy.rest.jpa.ActionPolicyDict; -import org.onap.policy.rest.jpa.BRMSParamTemplate; +import org.onap.policy.rest.jpa.BrmsParamTemplate; import org.onap.policy.rest.jpa.Category; import org.onap.policy.rest.jpa.FunctionDefinition; import org.onap.policy.rest.jpa.PolicyEditorScopes; @@ -459,7 +459,7 @@ public class XACMLPAPTest { editorScope.setUserModifiedBy(userInfo); Mockito.when(commonClassDao.getEntityItem(PolicyEditorScopes.class, "scopeName", "test")) .thenReturn(editorScope); - BRMSParamTemplate template = new BRMSParamTemplate(); + BrmsParamTemplate template = new BrmsParamTemplate(); template.setRuleName("testPolicy"); template.setUserCreatedBy(userInfo); String rule = "package com.sample;\n" + "import com.sample.DroolsTest.Message;\n" + "declare Params\n" @@ -471,7 +471,7 @@ public class XACMLPAPTest { + "Params($param.samPoll > 50)\n" + "then\n" + "System.out.println(\"Firing rule 1\");\n" + "System.out.println($param);\n" + "end\n"; template.setRule(rule); - Mockito.when(commonClassDao.getEntityItem(BRMSParamTemplate.class, "ruleName", "testPolicy")) + Mockito.when(commonClassDao.getEntityItem(BrmsParamTemplate.class, "ruleName", "testPolicy")) .thenReturn(template); } diff --git a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/controller/BRMSDictionaryControllerTest.java b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/controller/BRMSDictionaryControllerTest.java index e68860e4d..7d260907b 100644 --- a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/controller/BRMSDictionaryControllerTest.java +++ b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/controller/BRMSDictionaryControllerTest.java @@ -41,7 +41,7 @@ import org.onap.policy.common.logging.flexlogger.FlexLogger; import org.onap.policy.common.logging.flexlogger.Logger; import org.onap.policy.pap.xacml.rest.util.DictionaryUtils; import org.onap.policy.rest.dao.CommonClassDao; -import org.onap.policy.rest.jpa.BRMSParamTemplate; +import org.onap.policy.rest.jpa.BrmsParamTemplate; import org.onap.policy.rest.jpa.UserInfo; import org.springframework.mock.web.MockHttpServletResponse; @@ -64,9 +64,9 @@ public class BRMSDictionaryControllerTest { when(commonClassDao.getEntityItem(UserInfo.class, "userLoginId", "testing")).thenReturn(userInfo); List brms = new ArrayList(); brms.add("BRMS-Model"); - when(commonClassDao.getDataByColumn(BRMSParamTemplate.class, "name")).thenReturn(brms); - doNothing().when(commonClassDao).delete(new BRMSParamTemplate()); - doNothing().when(commonClassDao).save(new BRMSParamTemplate()); + when(commonClassDao.getDataByColumn(BrmsParamTemplate.class, "name")).thenReturn(brms); + doNothing().when(commonClassDao).delete(new BrmsParamTemplate()); + doNothing().when(commonClassDao).save(new BrmsParamTemplate()); controller = new BRMSDictionaryController(); request = Mockito.mock(HttpServletRequest.class); response = new MockHttpServletResponse(); diff --git a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/controller/MicroServiceDictionaryControllerTest.java b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/controller/MicroServiceDictionaryControllerTest.java index 43cba2e61..115e30249 100644 --- a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/controller/MicroServiceDictionaryControllerTest.java +++ b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/controller/MicroServiceDictionaryControllerTest.java @@ -43,7 +43,7 @@ import org.onap.policy.common.logging.flexlogger.FlexLogger; import org.onap.policy.common.logging.flexlogger.Logger; import org.onap.policy.pap.xacml.rest.util.DictionaryUtils; import org.onap.policy.rest.dao.CommonClassDao; -import org.onap.policy.rest.jpa.DCAEuuid; +import org.onap.policy.rest.jpa.DcaeUuid; import org.onap.policy.rest.jpa.MicroServiceLocation; import org.onap.policy.rest.jpa.MicroServiceModels; import org.onap.policy.rest.jpa.UserInfo; @@ -77,7 +77,7 @@ public class MicroServiceDictionaryControllerTest { List listIds = new ArrayList(); listIds.add("Jack"); - when(commonClassDao.getDataByColumn(DCAEuuid.class, "name")).thenReturn(listIds); + when(commonClassDao.getDataByColumn(DcaeUuid.class, "name")).thenReturn(listIds); List microList = new ArrayList(); microList.add("MC-Model"); @@ -85,7 +85,7 @@ public class MicroServiceDictionaryControllerTest { List listId = new ArrayList(); listId.add("smith"); - when(commonClassDao.getData(DCAEuuid.class)).thenReturn(listId); + when(commonClassDao.getData(DcaeUuid.class)).thenReturn(listId); MicroServiceModels microServiceModels = new MicroServiceModels(); doNothing().when(commonClassDao).delete(microServiceModels); diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/BRMSController.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/BrmsController.java similarity index 62% rename from ONAP-REST/src/main/java/org/onap/policy/rest/jpa/BRMSController.java rename to ONAP-REST/src/main/java/org/onap/policy/rest/jpa/BrmsController.java index af2b11a20..a17d8b643 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/BRMSController.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/BrmsController.java @@ -3,13 +3,14 @@ * ONAP-REST * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -38,117 +39,206 @@ import javax.persistence.Table; import javax.persistence.Temporal; import javax.persistence.TemporalType; +/** + * The Class BRMSController. + */ @Entity -@Table(name="BRMSController") -@NamedQuery(name="BRMSController.findAll", query="SELECT b from BRMSController b ") -public class BRMSController implements Serializable{ +@Table(name = "BrmsController") +@NamedQuery(name = "BrmsController.findAll", query = "SELECT b from BrmsController b ") +public class BrmsController implements Serializable { private static final long serialVersionUID = -8666947569754164177L; @Id @GeneratedValue(strategy = GenerationType.AUTO) - @Column(name="id") + @Column(name = "id") private int id; - - @Column(name="controller_name", nullable=false, length=1024, unique=true) + + @Column(name = "controller_name", nullable = false, length = 1024, unique = true) @OrderBy("asc") private String controllerName; - - @Column(name="description", nullable=true, length=1024) + + @Column(name = "description", nullable = true, length = 1024) private String description; - + @Temporal(TemporalType.TIMESTAMP) - @Column(name="created_date", updatable=false) + @Column(name = "created_date", updatable = false) private Date createdDate; - + @ManyToOne(optional = false) - @JoinColumn(name="created_by") + @JoinColumn(name = "created_by") private UserInfo userCreatedBy; - + @Temporal(TemporalType.TIMESTAMP) - @Column(name="modified_date", nullable=false) + @Column(name = "modified_date", nullable = false) private Date modifiedDate; - + @ManyToOne(optional = false) - @JoinColumn(name="modified_by") + @JoinColumn(name = "modified_by") private UserInfo userModifiedBy; - - @Column(name="controller", nullable=false) + + @Column(name = "controller", nullable = false) private String controller; - + + /** + * Called before persisting an instance. + */ @PrePersist public void prePersist() { Date date = new Date(); this.createdDate = date; this.modifiedDate = date; } - + + /** + * Pre update. + */ @PreUpdate public void preUpdate() { this.modifiedDate = new Date(); } - + + /** + * Gets the description. + * + * @return the description + */ public String getDescription() { return description; } + /** + * Sets the description. + * + * @param description the new description + */ public void setDescription(String description) { this.description = description; } + /** + * Gets the created date. + * + * @return the created date + */ public Date getCreatedDate() { return createdDate; } + /** + * Sets the created date. + * + * @param createdDate the new created date + */ public void setCreatedDate(Date createdDate) { this.createdDate = createdDate; } + /** + * Gets the user created by. + * + * @return the user created by + */ public UserInfo getUserCreatedBy() { return userCreatedBy; } + /** + * Sets the user created by. + * + * @param userCreatedBy the new user created by + */ public void setUserCreatedBy(UserInfo userCreatedBy) { this.userCreatedBy = userCreatedBy; } + /** + * Gets the modified date. + * + * @return the modified date + */ public Date getModifiedDate() { return modifiedDate; } + /** + * Sets the modified date. + * + * @param modifiedDate the new modified date + */ public void setModifiedDate(Date modifiedDate) { this.modifiedDate = modifiedDate; } + /** + * Gets the user modified by. + * + * @return the user modified by + */ public UserInfo getUserModifiedBy() { return userModifiedBy; } + /** + * Sets the user modified by. + * + * @param userModifiedBy the new user modified by + */ public void setUserModifiedBy(UserInfo userModifiedBy) { this.userModifiedBy = userModifiedBy; } + /** + * Gets the controller. + * + * @return the controller + */ public String getController() { return controller; } + /** + * Sets the controller. + * + * @param controller the new controller + */ public void setController(String controller) { this.controller = controller; } + /** + * Gets the id. + * + * @return the id + */ public int getId() { return id; } + /** + * Sets the id. + * + * @param id the new id + */ public void setId(int id) { this.id = id; } + /** + * Gets the controller name. + * + * @return the controller name + */ public String getControllerName() { return controllerName; } + /** + * Sets the controller name. + * + * @param controllerName the new controller name + */ public void setControllerName(String controllerName) { this.controllerName = controllerName; } - + } diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/BRMSDependency.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/BrmsDependency.java similarity index 62% rename from ONAP-REST/src/main/java/org/onap/policy/rest/jpa/BRMSDependency.java rename to ONAP-REST/src/main/java/org/onap/policy/rest/jpa/BrmsDependency.java index d06ec5d92..c04957dda 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/BRMSDependency.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/BrmsDependency.java @@ -3,13 +3,14 @@ * ONAP-REST * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -38,115 +39,204 @@ import javax.persistence.Table; import javax.persistence.Temporal; import javax.persistence.TemporalType; +/** + * The Class BrmsDependency. + */ @Entity -@Table(name="BRMSDependency") -@NamedQuery(name="BRMSDependency.findAll", query="SELECT b from BRMSDependency b ") -public class BRMSDependency implements Serializable{ +@Table(name = "BrmsDependency") +@NamedQuery(name = "BrmsDependency.findAll", query = "SELECT b from BrmsDependency b ") +public class BrmsDependency implements Serializable { private static final long serialVersionUID = -7005622785653160761L; - + @Id @GeneratedValue(strategy = GenerationType.AUTO) - @Column(name="id") + @Column(name = "id") private int id; - - @Column(name="dependency_name", nullable=false, length=1024, unique=true) + + @Column(name = "dependency_name", nullable = false, length = 1024, unique = true) @OrderBy("asc") private String dependencyName; - @Column(name="description", nullable=true, length=1024) + @Column(name = "description", nullable = true, length = 1024) private String description; - + @Temporal(TemporalType.TIMESTAMP) - @Column(name="created_date", updatable=false) + @Column(name = "created_date", updatable = false) private Date createdDate; - + @ManyToOne(optional = false) - @JoinColumn(name="created_by") + @JoinColumn(name = "created_by") private UserInfo userCreatedBy; - + @Temporal(TemporalType.TIMESTAMP) - @Column(name="modified_date", nullable=false) + @Column(name = "modified_date", nullable = false) private Date modifiedDate; - + @ManyToOne(optional = false) - @JoinColumn(name="modified_by") + @JoinColumn(name = "modified_by") private UserInfo userModifiedBy; - - @Column(name="dependency", nullable=false) + + @Column(name = "dependency", nullable = false) private String dependency; - + + /** + * Pre persist. + */ @PrePersist public void prePersist() { Date date = new Date(); this.createdDate = date; this.modifiedDate = date; } - + + /** + * Pre update. + */ @PreUpdate public void preUpdate() { this.modifiedDate = new Date(); } - + + /** + * Gets the description. + * + * @return the description + */ public String getDescription() { return description; } + /** + * Sets the description. + * + * @param description the new description + */ public void setDescription(String description) { this.description = description; } + /** + * Gets the created date. + * + * @return the created date + */ public Date getCreatedDate() { return createdDate; } + /** + * Sets the created date. + * + * @param createdDate the new created date + */ public void setCreatedDate(Date createdDate) { this.createdDate = createdDate; } + /** + * Gets the user created by. + * + * @return the user created by + */ public UserInfo getUserCreatedBy() { return userCreatedBy; } + /** + * Sets the user created by. + * + * @param userCreatedBy the new user created by + */ public void setUserCreatedBy(UserInfo userCreatedBy) { this.userCreatedBy = userCreatedBy; } + /** + * Gets the modified date. + * + * @return the modified date + */ public Date getModifiedDate() { return modifiedDate; } + /** + * Sets the modified date. + * + * @param modifiedDate the new modified date + */ public void setModifiedDate(Date modifiedDate) { this.modifiedDate = modifiedDate; } + /** + * Gets the user modified by. + * + * @return the user modified by + */ public UserInfo getUserModifiedBy() { return userModifiedBy; } + /** + * Sets the user modified by. + * + * @param userModifiedBy the new user modified by + */ public void setUserModifiedBy(UserInfo userModifiedBy) { this.userModifiedBy = userModifiedBy; } + /** + * Gets the dependency. + * + * @return the dependency + */ public String getDependency() { return dependency; } + /** + * Sets the dependency. + * + * @param dependency the new dependency + */ public void setDependency(String dependency) { this.dependency = dependency; } + /** + * Gets the id. + * + * @return the id + */ public int getId() { return id; } + /** + * Sets the id. + * + * @param id the new id + */ public void setId(int id) { this.id = id; } - + + /** + * Gets the dependency name. + * + * @return the dependency name + */ public String getDependencyName() { return dependencyName; } + /** + * Sets the dependency name. + * + * @param dependencyName the new dependency name + */ public void setDependencyName(String dependencyName) { this.dependencyName = dependencyName; } diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/BRMSParamTemplate.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/BrmsParamTemplate.java similarity index 78% rename from ONAP-REST/src/main/java/org/onap/policy/rest/jpa/BRMSParamTemplate.java rename to ONAP-REST/src/main/java/org/onap/policy/rest/jpa/BrmsParamTemplate.java index 7e47c0fb3..ae4fedab8 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/BRMSParamTemplate.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/BrmsParamTemplate.java @@ -3,13 +3,14 @@ * ONAP-REST * ================================================================================ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -38,44 +39,40 @@ import javax.persistence.Table; import javax.persistence.Temporal; import javax.persistence.TemporalType; -import org.onap.policy.rest.jpa.UserInfo; - /* - * JPA for the BRMS Param Template. - * + * JPA for the BRMS Param Template. + * * @version: 0.1 */ - @Entity -@Table(name="BRMSParamTemplate") -@NamedQuery(name="BRMSParamTemplate.findAll", query="SELECT b FROM BRMSParamTemplate b ") -public class BRMSParamTemplate implements Serializable{ +@Table(name = "BrmsParamTemplate") +@NamedQuery(name = "BrmsParamTemplate.findAll", query = "SELECT b FROM BrmsParamTemplate b ") +public class BrmsParamTemplate implements Serializable { private static final long serialVersionUID = 1L; @Id @GeneratedValue(strategy = GenerationType.AUTO) - @Column(name="id") + @Column(name = "id") private int id; - @Column(name="param_template_name", nullable=false, unique=true) + @Column(name = "param_template_name", nullable = false, unique = true) @OrderBy("asc") private String ruleName; @Lob - @Column(name="rule",nullable=false) + @Column(name = "rule", nullable = false) private String rule; - @Column(name="description", nullable=true, length=2048) + @Column(name = "description", nullable = true, length = 2048) private String description; @Temporal(TemporalType.TIMESTAMP) - @Column(name="created_date", updatable=false) + @Column(name = "created_date", updatable = false) private Date createdDate; - @ManyToOne(optional = false) - @JoinColumn(name="created_by") + @JoinColumn(name = "created_by") private UserInfo userCreatedBy; public UserInfo getUserCreatedBy() { @@ -87,7 +84,7 @@ public class BRMSParamTemplate implements Serializable{ } @PrePersist - public void prePersist() { + public void prePersist() { Date date = new Date(); this.createdDate = date; } @@ -100,7 +97,6 @@ public class BRMSParamTemplate implements Serializable{ this.id = id; } - public Date getCreatedDate() { return this.createdDate; } @@ -117,19 +113,19 @@ public class BRMSParamTemplate implements Serializable{ this.description = description; } - public String getRule(){ + public String getRule() { return this.rule; } - public void setRule(String rule){ + public void setRule(String rule) { this.rule = rule; } - public String getRuleName(){ + public String getRuleName() { return this.ruleName; } - public void setRuleName(String ruleName){ + public void setRuleName(String ruleName) { this.ruleName = ruleName; } } diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/Category.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/Category.java index f3874a480..4b0670752 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/Category.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/Category.java @@ -4,13 +4,14 @@ * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * Modified Copyright (C) 2018 Samsung Electronics Co., Ltd. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -21,6 +22,11 @@ package org.onap.policy.rest.jpa; +import com.att.research.xacml.api.Identifier; +import com.att.research.xacml.api.XACML3; +import com.att.research.xacml.std.IdentifierImpl; +import com.fasterxml.jackson.annotation.JsonBackReference; + import java.io.Serializable; import java.util.HashSet; import java.util.Set; @@ -35,19 +41,13 @@ import javax.persistence.OneToMany; import javax.persistence.Table; import javax.persistence.Transient; -import com.att.research.xacml.api.Identifier; -import com.att.research.xacml.api.XACML3; -import com.att.research.xacml.std.IdentifierImpl; -import com.fasterxml.jackson.annotation.JsonBackReference; - - /** * The persistent class for the Categories database table. - * + * */ @Entity -@Table(name="Category") -@NamedQuery(name="Category.findAll", query="SELECT c FROM Category c") +@Table(name = "Category") +@NamedQuery(name = "Category.findAll", query = "SELECT c FROM Category c") public class Category implements Serializable { private static final long serialVersionUID = 1L; @@ -56,26 +56,29 @@ public class Category implements Serializable { @Id @GeneratedValue(strategy = GenerationType.AUTO) - @Column(name="id") + @Column(name = "id") private int id; - @Column(name="grouping", nullable=false, length=64) + @Column(name = "grouping", nullable = false, length = 64) private String grouping; - @Column(name="is_standard", nullable=false) + @Column(name = "is_standard", nullable = false) private char isStandard; - @Column(name="xacml_id", nullable=false, unique=true, length=255) + @Column(name = "xacml_id", nullable = false, unique = true, length = 255) private String xacmlId; - @Column(name="short_name", nullable=false, length=64) + @Column(name = "short_name", nullable = false, length = 64) private String shortName; - //bi-directional many-to-one association to Attribute - @OneToMany(mappedBy="categoryBean") + // bi-directional many-to-one association to Attribute + @OneToMany(mappedBy = "categoryBean") @JsonBackReference private Set attributes = new HashSet<>(); + /** + * Instantiates a new category. + */ public Category() { this.xacmlId = XACML3.ID_SUBJECT_CATEGORY_ACCESS_SUBJECT.stringValue(); this.grouping = "subject"; @@ -83,6 +86,13 @@ public class Category implements Serializable { this.shortName = "subject"; } + /** + * Instantiates a new category. + * + * @param cat the cat + * @param grouping the grouping + * @param isStandard the is standard + */ public Category(Identifier cat, String grouping, char isStandard) { if (cat != null) { this.xacmlId = cat.stringValue(); @@ -95,66 +105,149 @@ public class Category implements Serializable { } } + /** + * Instantiates a new category. + * + * @param cat the cat + * @param grouping the grouping + */ public Category(Identifier cat, String grouping) { this(cat, grouping, Category.STANDARD); } + /** + * Instantiates a new category. + * + * @param cat the cat + * @param standard the standard + */ public Category(Identifier cat, char standard) { this(cat, null, standard); } + /** + * Instantiates a new category. + * + * @param cat the cat + */ public Category(Identifier cat) { this(cat, Category.STANDARD); } + /** + * Gets the id. + * + * @return the id + */ public int getId() { return this.id; } + /** + * Sets the id. + * + * @param id the new id + */ public void setId(int id) { this.id = id; } + /** + * Gets the grouping. + * + * @return the grouping + */ public String getGrouping() { return this.grouping; } + /** + * Sets the grouping. + * + * @param grouping the new grouping + */ public void setGrouping(String grouping) { this.grouping = grouping; } + /** + * Gets the checks if is standard. + * + * @return the checks if is standard + */ public char getIsStandard() { return this.isStandard; } + /** + * Sets the checks if is standard. + * + * @param isStandard the new checks if is standard + */ public void setIsStandard(char isStandard) { this.isStandard = isStandard; } + /** + * Gets the xacml id. + * + * @return the xacml id + */ public String getXacmlId() { return this.xacmlId; } + /** + * Sets the xacml id. + * + * @param xacmlId the new xacml id + */ public void setXacmlId(String xacmlId) { this.xacmlId = xacmlId; } + /** + * Gets the short name. + * + * @return the short name + */ public String getShortName() { return this.shortName; } + /** + * Sets the short name. + * + * @param shortName the new short name + */ public void setShortName(String shortName) { this.shortName = shortName; } + /** + * Gets the attributes. + * + * @return the attributes + */ public Set getAttributes() { return this.attributes; } + /** + * Sets the attributes. + * + * @param attributes the new attributes + */ public void setAttributes(Set attributes) { this.attributes = attributes; } + /** + * Adds the attribute. + * + * @param attribute the attribute + * @return the attribute + */ public Attribute addAttribute(Attribute attribute) { getAttributes().add(attribute); attribute.setCategoryBean(this); @@ -162,6 +255,12 @@ public class Category implements Serializable { return attribute; } + /** + * Removes the attribute. + * + * @param attribute the attribute + * @return the attribute + */ public Attribute removeAttribute(Attribute attribute) { getAttributes().remove(attribute); attribute.setCategoryBean(null); @@ -169,30 +268,41 @@ public class Category implements Serializable { return attribute; } + /** + * Checks if is standard. + * + * @return true, if is standard + */ @Transient public boolean isStandard() { return this.isStandard == Category.STANDARD; } + /** + * Checks if is custom. + * + * @return true, if is custom + */ @Transient public boolean isCustom() { return this.isStandard == Category.CUSTOM; } + /** + * Extract grouping. + * + * @param xacmlId the xacml id + * @return the string + */ @Transient - public static String extractGrouping(String xacmlId) { + public static String extractGrouping(String xacmlId) { if (xacmlId == null) { return null; } String[] parts = xacmlId.split("[:]"); - if (xacmlId.matches(".*:attribute\\-category:.*")) { - if (parts.length > 0) { - return parts[parts.length - 1]; - } - } else if (xacmlId.matches(".*:[a-zA-Z]+[\\-]category:.*")) { - if (parts.length <= 0) { - return null; - } + if (xacmlId.matches(".*:attribute\\-category:.*")) { + return parts[parts.length - 1]; + } else if (xacmlId.matches(".*:[a-zA-Z]+[\\-]category:.*")) { for (String part : parts) { int index = part.indexOf("-category"); if (index > 0) { @@ -203,17 +313,26 @@ public class Category implements Serializable { return null; } + /** + * Gets the identifer. + * + * @return the identifer + */ @Transient public Identifier getIdentifer() { return new IdentifierImpl(this.xacmlId); } + /** + * To string. + * + * @return the string + */ @Transient @Override public String toString() { - return "Category [id=" + id + ", grouping=" + grouping - + ", isStandard=" + isStandard + ", xacmlId=" + xacmlId - + ", attributes=" + attributes + "]"; + return "Category [id=" + id + ", grouping=" + grouping + ", isStandard=" + isStandard + ", xacmlId=" + xacmlId + + ", attributes=" + attributes + "]"; } } diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ClosedLoopD2Services.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ClosedLoopD2Services.java index cd2ea591d..4f6b1d7cb 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ClosedLoopD2Services.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ClosedLoopD2Services.java @@ -3,6 +3,7 @@ * ONAP-REST * ================================================================================ * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,11 +20,13 @@ */ package org.onap.policy.rest.jpa; + /* * */ import java.io.Serializable; import java.util.Date; + import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; @@ -39,110 +42,190 @@ import javax.persistence.Table; import javax.persistence.Temporal; import javax.persistence.TemporalType; - +/** + * The Class ClosedLoopD2Services. + */ @Entity @Table(name = "ClosedLoopD2Services") -@NamedQuery(name="ClosedLoopD2Services.findAll", query="SELECT c FROM ClosedLoopD2Services c ") -public class ClosedLoopD2Services implements Serializable{ +@NamedQuery(name = "ClosedLoopD2Services.findAll", query = "SELECT c FROM ClosedLoopD2Services c ") +public class ClosedLoopD2Services implements Serializable { private static final long serialVersionUID = 1L; @Id - @Column(name ="id") + @Column(name = "id") @GeneratedValue(strategy = GenerationType.AUTO) private int id; - @Column(name="service_Name", nullable=false, unique=true) + @Column(name = "service_Name", nullable = false, unique = true) @OrderBy("asc") private String serviceName; - @Column(name="description", nullable=true, length=2048) + @Column(name = "description", nullable = true, length = 2048) private String description; @Temporal(TemporalType.TIMESTAMP) - @Column(name="created_date", updatable=false) + @Column(name = "created_date", updatable = false) private Date createdDate; @Temporal(TemporalType.TIMESTAMP) - @Column(name="modified_date", nullable=false) + @Column(name = "modified_date", nullable = false) private Date modifiedDate; @ManyToOne(optional = false) - @JoinColumn(name="created_by") + @JoinColumn(name = "created_by") private UserInfo userCreatedBy; @ManyToOne(optional = false) - @JoinColumn(name="modified_by") + @JoinColumn(name = "modified_by") private UserInfo userModifiedBy; + /** + * Instantiates a new closed loop D 2 services. + */ public ClosedLoopD2Services() { this.setModifiedDate(new Date()); } - + /** + * Gets the user created by. + * + * @return the user created by + */ public UserInfo getUserCreatedBy() { return userCreatedBy; } + /** + * Sets the user created by. + * + * @param userCreatedBy the new user created by + */ public void setUserCreatedBy(UserInfo userCreatedBy) { this.userCreatedBy = userCreatedBy; } + /** + * Gets the user modified by. + * + * @return the user modified by + */ public UserInfo getUserModifiedBy() { return userModifiedBy; } + /** + * Sets the user modified by. + * + * @param userModifiedBy the new user modified by + */ public void setUserModifiedBy(UserInfo userModifiedBy) { this.userModifiedBy = userModifiedBy; } + /** + * Pre persist. + */ @PrePersist - public void prePersist() { + public void prePersist() { Date date = new Date(); this.createdDate = date; this.modifiedDate = date; } + /** + * Pre update. + */ @PreUpdate public void preUpdate() { this.modifiedDate = new Date(); } + /** + * Gets the id. + * + * @return the id + */ public int getId() { return id; } + /** + * Sets the id. + * + * @param id the new id + */ public void setId(int id) { this.id = id; } + /** + * Gets the service name. + * + * @return the service name + */ public String getServiceName() { return serviceName; } + /** + * Sets the service name. + * + * @param serviceName the new service name + */ public void setServiceName(String serviceName) { this.serviceName = serviceName; } + /** + * Gets the description. + * + * @return the description + */ public String getDescription() { return description; } + /** + * Sets the description. + * + * @param description the new description + */ public void setDescription(String description) { this.description = description; } + /** + * Gets the created date. + * + * @return the created date + */ public Date getCreatedDate() { return createdDate; } + /** + * Sets the created date. + * + * @param createdDate the new created date + */ public void setCreatedDate(Date createdDate) { this.createdDate = createdDate; } + /** + * Gets the modified date. + * + * @return the modified date + */ public Date getModifiedDate() { return modifiedDate; } + /** + * Sets the modified date. + * + * @param modifiedDate the new modified date + */ public void setModifiedDate(Date modifiedDate) { this.modifiedDate = modifiedDate; } diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ClosedLoopSite.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ClosedLoopSite.java index 52b5a2a4a..fc8801042 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ClosedLoopSite.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ClosedLoopSite.java @@ -3,6 +3,7 @@ * ONAP-REST * ================================================================================ * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,6 +26,7 @@ package org.onap.policy.rest.jpa; */ import java.io.Serializable; import java.util.Date; + import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; @@ -40,111 +42,190 @@ import javax.persistence.Table; import javax.persistence.Temporal; import javax.persistence.TemporalType; - +/** + * The Class ClosedLoopSite. + */ @Entity @Table(name = "ClosedLoopSite") -@NamedQuery(name="ClosedLoopSite.findAll", query="SELECT c FROM ClosedLoopSite c ") -public class ClosedLoopSite implements Serializable{ +@NamedQuery(name = "ClosedLoopSite.findAll", query = "SELECT c FROM ClosedLoopSite c ") +public class ClosedLoopSite implements Serializable { private static final long serialVersionUID = 1L; - @Id - @Column(name ="id") + @Column(name = "id") @GeneratedValue(strategy = GenerationType.AUTO) private int id; - @Column(name="site_Name", nullable=false, unique=true) + @Column(name = "site_Name", nullable = false, unique = true) @OrderBy("asc") private String siteName; - @Column(name="description", nullable=true, length=2048) + @Column(name = "description", nullable = true, length = 2048) private String description; @Temporal(TemporalType.TIMESTAMP) - @Column(name="created_date", updatable=false) + @Column(name = "created_date", updatable = false) private Date createdDate; @Temporal(TemporalType.TIMESTAMP) - @Column(name="modified_date", nullable=false) + @Column(name = "modified_date", nullable = false) private Date modifiedDate; @ManyToOne(optional = false) - @JoinColumn(name="created_by") + @JoinColumn(name = "created_by") private UserInfo userCreatedBy; @ManyToOne(optional = false) - @JoinColumn(name="modified_by") + @JoinColumn(name = "modified_by") private UserInfo userModifiedBy; + /** + * Instantiates a new closed loop site. + */ public ClosedLoopSite() { this.setModifiedDate(new Date()); } - + /** + * Gets the user created by. + * + * @return the user created by + */ public UserInfo getUserCreatedBy() { return userCreatedBy; } + /** + * Sets the user created by. + * + * @param userCreatedBy the new user created by + */ public void setUserCreatedBy(UserInfo userCreatedBy) { this.userCreatedBy = userCreatedBy; } + /** + * Gets the user modified by. + * + * @return the user modified by + */ public UserInfo getUserModifiedBy() { return userModifiedBy; } + /** + * Sets the user modified by. + * + * @param userModifiedBy the new user modified by + */ public void setUserModifiedBy(UserInfo userModifiedBy) { this.userModifiedBy = userModifiedBy; } + /** + * Pre persist. + */ @PrePersist - public void prePersist() { + public void prePersist() { Date date = new Date(); this.createdDate = date; this.modifiedDate = date; } + /** + * Pre update. + */ @PreUpdate public void preUpdate() { this.modifiedDate = new Date(); } + /** + * Gets the id. + * + * @return the id + */ public int getId() { return id; } + /** + * Sets the id. + * + * @param id the new id + */ public void setId(int id) { this.id = id; } + /** + * Gets the site name. + * + * @return the site name + */ public String getSiteName() { return siteName; } + /** + * Sets the site name. + * + * @param siteName the new site name + */ public void setSiteName(String siteName) { this.siteName = siteName; } + /** + * Gets the description. + * + * @return the description + */ public String getDescription() { return description; } + /** + * Sets the description. + * + * @param description the new description + */ public void setDescription(String description) { this.description = description; } + /** + * Gets the created date. + * + * @return the created date + */ public Date getCreatedDate() { return createdDate; } + /** + * Sets the created date. + * + * @param createdDate the new created date + */ public void setCreatedDate(Date createdDate) { this.createdDate = createdDate; } + /** + * Gets the modified date. + * + * @return the modified date + */ public Date getModifiedDate() { return modifiedDate; } + /** + * Sets the modified date. + * + * @param modifiedDate the new modified date + */ public void setModifiedDate(Date modifiedDate) { this.modifiedDate = modifiedDate; } diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ClosedLoops.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ClosedLoops.java index 721a2c5f4..edeabce4b 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ClosedLoops.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ClosedLoops.java @@ -3,13 +3,14 @@ * ONAP-REST * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -33,35 +34,30 @@ import javax.persistence.OrderBy; import javax.persistence.Table; @Entity -@Table(name="ClosedLoops") -@NamedQueries({ - @NamedQuery(name="ClosedLoops.findAll", query="SELECT e FROM ClosedLoops e"), - @NamedQuery(name="ClosedLoops.deleteAll", query="DELETE FROM ClosedLoops WHERE 1=1") -}) +@Table(name = "ClosedLoops") +@NamedQueries( + { @NamedQuery(name = "ClosedLoops.findAll", query = "SELECT e FROM ClosedLoops e"), + @NamedQuery(name = "ClosedLoops.deleteAll", query = "DELETE FROM ClosedLoops WHERE 1=1") }) public class ClosedLoops implements Serializable { - - /** - * - */ private static final long serialVersionUID = -7796845092457926842L; @Id @GeneratedValue(strategy = GenerationType.AUTO) - @Column(name="id") + @Column(name = "id") private int id; - @Column(name="closedLoopControlName", nullable=false, length=255) + @Column(name = "closedLoopControlName", nullable = false, length = 255) @OrderBy("asc") private String closedLoopControlName; - @Column(name="alarmConditions", nullable=true, length=255) + @Column(name = "alarmConditions", nullable = true, length = 255) private String alarmConditions; - @Column(name="yaml", nullable=true, length=1028) + @Column(name = "yaml", nullable = true, length = 1028) private String yaml; public ClosedLoops() { - //An empty constructor + // An empty constructor } public int getId() { diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ConfigurationDataEntity.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ConfigurationDataEntity.java index 7bb73f36a..8fd839a18 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ConfigurationDataEntity.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ConfigurationDataEntity.java @@ -3,13 +3,14 @@ * ONAP-REST * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -19,11 +20,13 @@ */ package org.onap.policy.rest.jpa; + +import com.fasterxml.jackson.annotation.JsonBackReference; + /* */ import java.io.Serializable; import java.util.Date; -import java.util.Objects; import javax.persistence.Column; import javax.persistence.Entity; @@ -43,168 +46,238 @@ import javax.persistence.Version; * The Entity class to persist a policy object configuration data */ +import lombok.EqualsAndHashCode; -import com.fasterxml.jackson.annotation.JsonBackReference; - +/** + * The Class ConfigurationDataEntity. + */ +// @formatter:off @Entity -@Table(name="ConfigurationDataEntity") -@NamedQueries({ - @NamedQuery(name="ConfigurationDataEntity.findAll", query="SELECT e FROM ConfigurationDataEntity e "), - @NamedQuery(name="ConfigurationDataEntity.deleteAll", query="DELETE FROM ConfigurationDataEntity WHERE 1=1") -}) +@Table(name = "ConfigurationDataEntity") +@NamedQueries( + { + @NamedQuery(name = "ConfigurationDataEntity.findAll", query = "SELECT e FROM ConfigurationDataEntity e "), + @NamedQuery(name = "ConfigurationDataEntity.deleteAll", query = "DELETE FROM ConfigurationDataEntity WHERE 1=1") + } +) +@EqualsAndHashCode +//@formatter:on public class ConfigurationDataEntity implements Serializable { private static final long serialVersionUID = 1L; @Id @GeneratedValue(strategy = GenerationType.AUTO) - @Column(name="configurationDataId") + @Column(name = "configurationDataId") @JsonBackReference private long configurationDataId; - @Column(name="configurationName", nullable=false, length=255) + @Column(name = "configurationName", nullable = false, length = 255) private String configurationName = ""; @Version - @Column(name="version") + @Column(name = "version") private int version; - @Column(name="configType", nullable=false, length=255) + @Column(name = "configType", nullable = false, length = 255) private String configType = "NoType"; @Lob - @Column(name="configBody", nullable=false, columnDefinition="TEXT") + @Column(name = "configBody", nullable = false, columnDefinition = "TEXT") private String configBody = "NoBody"; - @Column(name="created_by", nullable=false, length=255) + @Column(name = "created_by", nullable = false, length = 255) private String createdBy = "guest"; @Temporal(TemporalType.TIMESTAMP) - @Column(name="created_date", updatable=false) + @Column(name = "created_date", updatable = false) private Date createdDate; - @Column(name="description", nullable=false, length=2048) + @Column(name = "description", nullable = false, length = 2048) private String description = "NoDescription"; - @Column(name="modified_by", nullable=false, length=255) + @Column(name = "modified_by", nullable = false, length = 255) private String modifiedBy = "guest"; @Temporal(TemporalType.TIMESTAMP) - @Column(name="modified_date", nullable=false) + @Column(name = "modified_date", nullable = false) private Date modifiedDate; - @Column(name="deleted", nullable=false) + @Column(name = "deleted", nullable = false) private boolean deleted = false; + /** + * Instantiates a new configuration data entity. + */ public ConfigurationDataEntity() { - //An empty constructor + // An empty constructor } + /** + * Pre persist. + */ @PrePersist - public void prePersist() { + public void prePersist() { Date date = new Date(); this.createdDate = date; this.modifiedDate = date; } + /** + * Pre update. + */ @PreUpdate public void preUpdate() { this.modifiedDate = new Date(); } + /** + * Gets the configuration data id. + * * @return the configurationDataId */ public long getConfigurationDataId() { return configurationDataId; } + /** - * @param configurationDataId the configurationDataId to set + * Sets the configuration name. + * + * @param configurationName the new configuration name */ public void setConfigurationName(String configurationName) { this.configurationName = configurationName; } - public String getConfigurationName(){ + + /** + * Gets the configuration name. + * + * @return the configuration name + */ + public String getConfigurationName() { return this.configurationName; } + /** + * Gets the config type. + * * @return the configType */ public String getConfigType() { return configType; } + /** + * Sets the config type. + * * @param configType the configType to set */ public void setConfigType(String configType) { this.configType = configType; } + /** + * Gets the config body. + * * @return the configBody */ public String getConfigBody() { return configBody; } + /** + * Sets the config body. + * * @param configBody the configBody to set */ public void setConfigBody(String configBody) { this.configBody = configBody; } + /** + * Gets the created by. + * * @return the createdBy */ public String getCreatedBy() { return createdBy; } + /** + * Sets the created by. + * * @param createdBy the createdBy to set */ public void setCreatedBy(String createdBy) { this.createdBy = createdBy; } + /** + * Gets the description. + * * @return the description */ public String getDescription() { return description; } + /** + * Sets the description. + * * @param description the description to set */ public void setDescription(String description) { this.description = description; } + /** + * Gets the modified by. + * * @return the modifiedBy */ public String getModifiedBy() { return modifiedBy; } + /** + * Sets the modified by. + * * @param modifiedBy the modifiedBy to set */ public void setModifiedBy(String modifiedBy) { this.modifiedBy = modifiedBy; } + /** + * Gets the modified date. + * * @return the modifiedDate */ public Date getModifiedDate() { return modifiedDate; } + /** + * Sets the modified date. + * * @param modifiedDate the modifiedDate to set */ public void setModifiedDate(Date modifiedDate) { this.modifiedDate = modifiedDate; } + /** + * Gets the version. + * * @return the version */ public int getVersion() { return version; } + /** + * Gets the created date. + * * @return the createdDate */ public Date getCreatedDate() { @@ -212,6 +285,8 @@ public class ConfigurationDataEntity implements Serializable { } /** + * Checks if is deleted. + * * @return the deleted */ public boolean isDeleted() { @@ -219,40 +294,11 @@ public class ConfigurationDataEntity implements Serializable { } /** + * Sets the deleted. + * * @param deleted the deleted to set */ public void setDeleted(boolean deleted) { this.deleted = deleted; } - - @Override - public int hashCode() { - return Objects.hash(configurationDataId, configurationName, version, configType, - configBody, createdBy, createdDate, description, modifiedBy, modifiedDate, deleted); - } - - @Override - public boolean equals(Object obj) { - if(obj == null){ - return false; - } - if(obj == this){ - return true; - } - if(!(obj instanceof ConfigurationDataEntity)){ - return false; - } - - return configurationDataId == ((ConfigurationDataEntity) obj).configurationDataId && - configurationName.equals(((ConfigurationDataEntity) obj).configurationName) && - version == ((ConfigurationDataEntity) obj).version && - configType.equals(((ConfigurationDataEntity) obj).configType) && - configBody.equals(((ConfigurationDataEntity) obj).configBody) && - createdBy.equals(((ConfigurationDataEntity) obj).createdBy) && - createdDate.equals(((ConfigurationDataEntity) obj).createdDate) && - description.equals(((ConfigurationDataEntity) obj).description) && - modifiedBy.equals(((ConfigurationDataEntity) obj).modifiedBy) && - modifiedDate.equals(((ConfigurationDataEntity) obj).modifiedDate) && - deleted == ((ConfigurationDataEntity) obj).deleted; - } } diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ConstraintType.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ConstraintType.java index 606403318..f7637013b 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ConstraintType.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ConstraintType.java @@ -3,13 +3,14 @@ * ONAP-REST * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -36,8 +37,8 @@ import javax.persistence.OneToMany; import javax.persistence.Table; @Entity -@Table(name="ConstraintType") -@NamedQuery(name="ConstraintType.findAll", query="SELECT a FROM ConstraintType a") +@Table(name = "ConstraintType") +@NamedQuery(name = "ConstraintType.findAll", query = "SELECT a FROM ConstraintType a") public class ConstraintType implements Serializable { private static final long serialVersionUID = 1L; @@ -46,30 +47,36 @@ public class ConstraintType implements Serializable { public static final String REGEXP_TYPE = "Regular Expression"; protected static final Map defaults = new HashMap<>(); + static { - defaults.put(ENUMERATION_TYPE, "Enumerate a set of values that the attribute may be set to during policy creation."); - defaults.put(RANGE_TYPE, "Set a range of min and/or max integer/double values the attribute can be set to during policy creation."); - defaults.put(REGEXP_TYPE, "Define a regular expression the attribute must match against during policy creation."); + defaults.put(ENUMERATION_TYPE, + "Enumerate a set of values that the attribute may be set to during policy creation."); + defaults.put(RANGE_TYPE, "Set a range of min and/or max integer/double values " + + "the attribute can be set to during policy creation."); + defaults.put(REGEXP_TYPE, + "Define a regular expression the attribute must match against during policy creation."); } - private static final String[] RANGE_TYPES = {"minExclusive", "minInclusive", "maxExclusive", "maxInclusive"}; + + private static final String[] RANGE_TYPES = + { "minExclusive", "minInclusive", "maxExclusive", "maxInclusive" }; @Id @GeneratedValue(strategy = GenerationType.AUTO) - @Column(name="id") + @Column(name = "id") private int id; - @Column(name="constraint_type", nullable=false, length=64) + @Column(name = "constraint_type", nullable = false, length = 64) private String constraintType; - @Column(name="description", nullable=false, length=255) + @Column(name = "description", nullable = false, length = 255) private String description; - //bi-directional many-to-one association to Attribute - @OneToMany(mappedBy="constraintType") + // bi-directional many-to-one association to Attribute + @OneToMany(mappedBy = "constraintType") private Set attributes = new HashSet<>(); public ConstraintType() { - //An empty constructor + // An empty constructor } public ConstraintType(String constraintType) { diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ConstraintValue.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ConstraintValue.java index 4c3bf6609..c30af1fd6 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ConstraintValue.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/ConstraintValue.java @@ -3,13 +3,14 @@ * ONAP-REST * ================================================================================ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -32,35 +33,34 @@ import javax.persistence.ManyToOne; import javax.persistence.NamedQuery; import javax.persistence.Table; - /** * The persistent class for the ConstraintValues database table. - * + * */ @Entity -@Table(name="ConstraintValues") -@NamedQuery(name="ConstraintValue.findAll", query="SELECT c FROM ConstraintValue c") +@Table(name = "ConstraintValues") +@NamedQuery(name = "ConstraintValue.findAll", query = "SELECT c FROM ConstraintValue c") public class ConstraintValue implements Serializable { private static final long serialVersionUID = 1L; @Id @GeneratedValue(strategy = GenerationType.AUTO) - @Column(name="id") + @Column(name = "id") private int id; - @Column(name="property") + @Column(name = "property") private String property; - @Column(name="value") + @Column(name = "value") private String value; - //bi-directional many-to-one association to Attribute + // bi-directional many-to-one association to Attribute @ManyToOne - @JoinColumn(name="attribute_id") + @JoinColumn(name = "attribute_id") private Attribute attribute; public ConstraintValue() { - //An empty constructor + // An empty constructor } public ConstraintValue(String property, String value) { diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/DatabaseLockEntity.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/DatabaseLockEntity.java index b82ec4882..73d2c99f9 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/DatabaseLockEntity.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/DatabaseLockEntity.java @@ -3,13 +3,14 @@ * ONAP-REST * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -28,20 +29,23 @@ import javax.persistence.Id; import javax.persistence.Table; @Entity -@Table(name="DatabaseLockEntity") +@Table(name = "DatabaseLockEntity") public class DatabaseLockEntity implements Serializable { private static final long serialVersionUID = 1L; @Id - @Column(name="lock_key") - private int lock_key = 1; - public DatabaseLockEntity(){ - //An empty constructor + @Column(name = "lock_key") + private int lockKey = 1; + + public DatabaseLockEntity() { + // An empty constructor } - public int getKey(){ - return lock_key; + + public int getKey() { + return lockKey; } - public void setKey(int key){ - this.lock_key = key; + + public void setKey(int key) { + this.lockKey = key; } } diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/Datatype.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/Datatype.java index 4ab577976..9da83ffb2 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/Datatype.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/Datatype.java @@ -3,13 +3,14 @@ * ONAP-REST * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -20,6 +21,12 @@ package org.onap.policy.rest.jpa; +import com.att.research.xacml.api.Identifier; +import com.att.research.xacml.api.XACML3; +import com.att.research.xacml.std.IdentifierImpl; +import com.fasterxml.jackson.annotation.JsonBackReference; +import com.fasterxml.jackson.annotation.JsonIgnore; + import java.io.Serializable; import java.util.HashSet; import java.util.Set; @@ -34,20 +41,13 @@ import javax.persistence.OneToMany; import javax.persistence.Table; import javax.persistence.Transient; -import com.att.research.xacml.api.Identifier; -import com.att.research.xacml.api.XACML3; -import com.att.research.xacml.std.IdentifierImpl; -import com.fasterxml.jackson.annotation.JsonBackReference; -import com.fasterxml.jackson.annotation.JsonIgnore; - - /** * The persistent class for the Datatype database table. - * + * */ @Entity -@Table(name="Datatype") -@NamedQuery(name="Datatype.findAll", query="SELECT d FROM Datatype d") +@Table(name = "Datatype") +@NamedQuery(name = "Datatype.findAll", query = "SELECT d FROM Datatype d") public class Datatype implements Serializable { private static final long serialVersionUID = 1L; @@ -56,39 +56,47 @@ public class Datatype implements Serializable { @Id @GeneratedValue(strategy = GenerationType.AUTO) - @Column(name="id") + @Column(name = "id") private int id; - @Column(name="is_standard", nullable=false) + @Column(name = "is_standard", nullable = false) private char isStandard; - @Column(name="xacml_id", nullable=false, unique=true, length=255) + @Column(name = "xacml_id", nullable = false, unique = true, length = 255) private String xacmlId; - @Column(name="short_name", nullable=false, length=64) + @Column(name = "short_name", nullable = false, length = 64) private String shortName; - //bi-directional many-to-one association to Attribute - @OneToMany(mappedBy="datatypeBean") + // bi-directional many-to-one association to Attribute + @OneToMany(mappedBy = "datatypeBean") @JsonBackReference private Set attributes = new HashSet<>(); - //bi-directional many-to-one association to Attribute - @OneToMany(mappedBy="datatypeBean") + // bi-directional many-to-one association to Attribute + @OneToMany(mappedBy = "datatypeBean") @JsonIgnore private Set functions = new HashSet<>(); - //bi-directional many-to-one association to Attribute - @OneToMany(mappedBy="datatypeBean") + // bi-directional many-to-one association to Attribute + @OneToMany(mappedBy = "datatypeBean") @JsonIgnore private Set arguments = new HashSet<>(); + /** + * Instantiates a new datatype. + */ public Datatype() { this.xacmlId = XACML3.ID_DATATYPE_STRING.stringValue(); this.isStandard = Datatype.STANDARD; } - + /** + * Instantiates a new datatype. + * + * @param id the id + * @param dt the dt + */ public Datatype(int id, Datatype dt) { this.id = id; this.isStandard = dt.isStandard; @@ -100,6 +108,12 @@ public class Datatype implements Serializable { this.attributes = new HashSet<>(); } + /** + * Instantiates a new datatype. + * + * @param identifier the identifier + * @param standard the standard + */ public Datatype(Identifier identifier, char standard) { if (identifier != null) { this.xacmlId = identifier.stringValue(); @@ -108,50 +122,111 @@ public class Datatype implements Serializable { this.isStandard = standard; } + /** + * Instantiates a new datatype. + * + * @param identifier the identifier + */ public Datatype(Identifier identifier) { this(identifier, Datatype.STANDARD); } + /** + * Gets the id. + * + * @return the id + */ public int getId() { return this.id; } + /** + * Sets the id. + * + * @param id the new id + */ public void setId(int id) { this.id = id; } + /** + * Gets the checks if is standard. + * + * @return the checks if is standard + */ public char getIsStandard() { return this.isStandard; } + /** + * Sets the checks if is standard. + * + * @param isStandard the new checks if is standard + */ public void setIsStandard(char isStandard) { this.isStandard = isStandard; } + /** + * Gets the xacml id. + * + * @return the xacml id + */ public String getXacmlId() { return this.xacmlId; } + /** + * Sets the xacml id. + * + * @param xacmlId the new xacml id + */ public void setXacmlId(String xacmlId) { this.xacmlId = xacmlId; } + /** + * Gets the short name. + * + * @return the short name + */ public String getShortName() { return shortName; } + /** + * Sets the short name. + * + * @param shortName the new short name + */ public void setShortName(String shortName) { this.shortName = shortName; } + /** + * Gets the attributes. + * + * @return the attributes + */ public Set getAttributes() { return this.attributes; } + /** + * Sets the attributes. + * + * @param attributes the new attributes + */ public void setAttributes(Set attributes) { this.attributes = attributes; } + /** + * Adds the attribute. + * + * @param attribute the attribute + * @return the attribute + */ public Attribute addAttribute(Attribute attribute) { getAttributes().add(attribute); attribute.setDatatypeBean(this); @@ -159,6 +234,12 @@ public class Datatype implements Serializable { return attribute; } + /** + * Removes the attribute. + * + * @param attribute the attribute + * @return the attribute + */ public Attribute removeAttribute(Attribute attribute) { getAttributes().remove(attribute); attribute.setDatatypeBean(null); @@ -166,14 +247,43 @@ public class Datatype implements Serializable { return attribute; } + /** + * Removes the attribute. + * + * @param function the function + * @return the function definition + */ + public FunctionDefinition removeAttribute(FunctionDefinition function) { + getFunctions().remove(function); + function.setDatatypeBean(null); + + return function; + } + + /** + * Gets the functions. + * + * @return the functions + */ public Set getFunctions() { return this.functions; } + /** + * Sets the functions. + * + * @param functions the new functions + */ public void setFunctions(Set functions) { this.functions = functions; } + /** + * Adds the function. + * + * @param function the function + * @return the function definition + */ public FunctionDefinition addFunction(FunctionDefinition function) { getFunctions().add(function); function.setDatatypeBean(this); @@ -181,21 +291,30 @@ public class Datatype implements Serializable { return function; } - public FunctionDefinition removeAttribute(FunctionDefinition function) { - getFunctions().remove(function); - function.setDatatypeBean(null); - - return function; - } - + /** + * Gets the arguments. + * + * @return the arguments + */ public Set getArguments() { return this.arguments; } + /** + * Sets the arguments. + * + * @param argument the new arguments + */ public void setArguments(Set argument) { this.arguments = argument; } + /** + * Adds the argument. + * + * @param argument the argument + * @return the function argument + */ public FunctionArgument addArgument(FunctionArgument argument) { getArguments().add(argument); argument.setDatatypeBean(this); @@ -203,6 +322,12 @@ public class Datatype implements Serializable { return argument; } + /** + * Removes the argument. + * + * @param argument the argument + * @return the function argument + */ public FunctionArgument removeArgument(FunctionArgument argument) { getArguments().remove(argument); argument.setDatatypeBean(null); @@ -210,33 +335,56 @@ public class Datatype implements Serializable { return argument; } + /** + * Gets the identifer. + * + * @return the identifer + */ @Transient public Identifier getIdentifer() { return new IdentifierImpl(this.xacmlId); } + /** + * Gets the identifer by short name. + * + * @return the identifer by short name + */ @Transient public Identifier getIdentiferByShortName() { return new IdentifierImpl(this.shortName); } + /** + * Checks if is standard. + * + * @return true, if is standard + */ @Transient public boolean isStandard() { return this.isStandard == Datatype.STANDARD; } + /** + * Checks if is custom. + * + * @return true, if is custom + */ @Transient public boolean isCustom() { return this.isStandard == Datatype.CUSTOM; } + /** + * To string. + * + * @return the string + */ @Transient @Override public String toString() { - return "Datatype [id=" + id + ", isStandard=" + isStandard - + ", xacmlId=" + xacmlId + ", shortName=" + shortName - + ", attributes=" + attributes + ", functions=" + functions - + ", arguments=" + arguments + "]"; + return "Datatype [id=" + id + ", isStandard=" + isStandard + ", xacmlId=" + xacmlId + ", shortName=" + shortName + + ", attributes=" + attributes + ", functions=" + functions + ", arguments=" + arguments + "]"; } } diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/DCAEUsers.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/DcaeUsers.java similarity index 79% rename from ONAP-REST/src/main/java/org/onap/policy/rest/jpa/DCAEUsers.java rename to ONAP-REST/src/main/java/org/onap/policy/rest/jpa/DcaeUsers.java index 31dd66056..1408c9fd4 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/DCAEUsers.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/DcaeUsers.java @@ -3,13 +3,14 @@ * ONAP-REST * ================================================================================ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -19,6 +20,7 @@ */ package org.onap.policy.rest.jpa; + /* */ import java.io.Serializable; @@ -32,24 +34,23 @@ import javax.persistence.NamedQuery; import javax.persistence.OrderBy; import javax.persistence.Table; - @Entity -@Table(name="DCAEUsers") -@NamedQuery(name="DCAEUsers.findAll", query="SELECT e FROM DCAEUsers e ") -public class DCAEUsers implements Serializable { +@Table(name = "DcaeUsers") +@NamedQuery(name = "DcaeUsers.findAll", query = "SELECT e FROM DcaeUsers e ") +public class DcaeUsers implements Serializable { private static final long serialVersionUID = 1L; @Id @GeneratedValue(strategy = GenerationType.AUTO) - @Column(name="id") + @Column(name = "id") private int id; - @Column(name="name", nullable=false) + @Column(name = "name", nullable = false) @OrderBy("asc") private String name; - @Column(name="description ") - private String description ; + @Column(name = "description ") + private String description; public int getId() { return this.id; @@ -58,6 +59,7 @@ public class DCAEUsers implements Serializable { public void setId(int id) { this.id = id; } + public String getName() { return this.name; } @@ -66,12 +68,13 @@ public class DCAEUsers implements Serializable { this.name = name; } + public String getDescriptionValue() { - return this.description ; + return this.description; } - public void setDescriptionValue(String description ) { - this.description = description ; + public void setDescriptionValue(String description) { + this.description = description; } } diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/DCAEuuid.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/DcaeUuid.java similarity index 86% rename from ONAP-REST/src/main/java/org/onap/policy/rest/jpa/DCAEuuid.java rename to ONAP-REST/src/main/java/org/onap/policy/rest/jpa/DcaeUuid.java index 5194093d1..8464ef7e8 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/DCAEuuid.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/DcaeUuid.java @@ -3,13 +3,14 @@ * ONAP-REST * ================================================================================ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -19,6 +20,7 @@ */ package org.onap.policy.rest.jpa; + /* */ import java.io.Serializable; @@ -32,23 +34,22 @@ import javax.persistence.NamedQuery; import javax.persistence.OrderBy; import javax.persistence.Table; - @Entity -@Table(name="DCAEuuid") -@NamedQuery(name="DCAEuuid.findAll", query="SELECT e FROM DCAEuuid e ") -public class DCAEuuid implements Serializable { +@Table(name = "DcaeUuid") +@NamedQuery(name = "DcaeUuid.findAll", query = "SELECT e FROM DcaeUuid e ") +public class DcaeUuid implements Serializable { private static final long serialVersionUID = 1L; @Id @GeneratedValue(strategy = GenerationType.AUTO) - @Column(name="id") + @Column(name = "id") private int id; - @Column(name="name", nullable=false) + @Column(name = "name", nullable = false) @OrderBy("asc") private String name; - @Column(name="description") + @Column(name = "description") private String description; public String getDescription() { @@ -66,6 +67,7 @@ public class DCAEuuid implements Serializable { public void setId(int id) { this.id = id; } + public String getName() { return this.name; } diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/DecisionSettings.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/DecisionSettings.java index e469c0b4f..693641e43 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/DecisionSettings.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/DecisionSettings.java @@ -3,13 +3,14 @@ * ONAP-REST * ================================================================================ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -39,40 +40,47 @@ import javax.persistence.Temporal; import javax.persistence.TemporalType; import javax.persistence.Transient; - +/** + * The Class DecisionSettings. + */ +// @formatter:off @Entity -@Table(name="DecisionSettings") -@NamedQuery(name="DecisionSettings.findAll", query="SELECT a FROM DecisionSettings a order by a.priority asc, a.xacmlId asc") +@Table(name = "DecisionSettings") +@NamedQuery( + name = "DecisionSettings.findAll", + query = "SELECT a FROM DecisionSettings a order by a.priority asc, a.xacmlId asc" +) +//@formatter:on public class DecisionSettings implements Serializable { private static final long serialVersionUID = 1L; @Id @GeneratedValue(strategy = GenerationType.AUTO) - @Column(name="id") + @Column(name = "id") private int id; @Temporal(TemporalType.TIMESTAMP) - @Column(name="created_date", updatable=false) + @Column(name = "created_date", updatable = false) private Date createdDate; - @Column(name="description", nullable=true, length=2048) + @Column(name = "description", nullable = true, length = 2048) private String description; @Temporal(TemporalType.TIMESTAMP) - @Column(name="modified_date", nullable=false) + @Column(name = "modified_date", nullable = false) private Date modifiedDate; - @Column(name="PRIORITY", nullable=true) + @Column(name = "PRIORITY", nullable = true) @OrderBy("asc") private String priority; - @Column(name="xacml_id", unique = true, nullable=false) + @Column(name = "xacml_id", unique = true, nullable = false) @OrderBy("asc") private String xacmlId = "urn"; - //bi-directional many-to-one association to Datatype + // bi-directional many-to-one association to Datatype @ManyToOne - @JoinColumn(name="datatype") + @JoinColumn(name = "datatype") private Datatype datatypeBean; @Transient @@ -82,116 +90,230 @@ public class DecisionSettings implements Serializable { private boolean mustBePresent = false; @ManyToOne(optional = false) - @JoinColumn(name="created_by") + @JoinColumn(name = "created_by") private UserInfo userCreatedBy; @ManyToOne(optional = false) - @JoinColumn(name="modified_by") + @JoinColumn(name = "modified_by") private UserInfo userModifiedBy; + /** + * Gets the user created by. + * + * @return the user created by + */ public UserInfo getUserCreatedBy() { return userCreatedBy; } + /** + * Sets the user created by. + * + * @param userCreatedBy the new user created by + */ public void setUserCreatedBy(UserInfo userCreatedBy) { this.userCreatedBy = userCreatedBy; } + /** + * Gets the user modified by. + * + * @return the user modified by + */ public UserInfo getUserModifiedBy() { return userModifiedBy; } + /** + * Sets the user modified by. + * + * @param userModifiedBy the new user modified by + */ public void setUserModifiedBy(UserInfo userModifiedBy) { this.userModifiedBy = userModifiedBy; } + /** + * Pre persist. + */ @PrePersist - public void prePersist() { + public void prePersist() { Date date = new Date(); this.createdDate = date; this.modifiedDate = date; } + /** + * Pre update. + */ @PreUpdate public void preUpdate() { this.modifiedDate = new Date(); } + /** + * Gets the id. + * + * @return the id + */ public int getId() { return this.id; } + /** + * Sets the id. + * + * @param id the new id + */ public void setId(int id) { this.id = id; } - + /** + * Gets the created date. + * + * @return the created date + */ public Date getCreatedDate() { return this.createdDate; } + /** + * Sets the created date. + * + * @param createdDate the new created date + */ public void setCreatedDate(Date createdDate) { this.createdDate = createdDate; } + /** + * Gets the description. + * + * @return the description + */ public String getDescription() { return this.description; } + /** + * Sets the description. + * + * @param description the new description + */ public void setDescription(String description) { this.description = description; } + /** + * Gets the modified date. + * + * @return the modified date + */ public Date getModifiedDate() { return this.modifiedDate; } + /** + * Sets the modified date. + * + * @param modifiedDate the new modified date + */ public void setModifiedDate(Date modifiedDate) { this.modifiedDate = modifiedDate; } + /** + * Gets the xacml id. + * + * @return the xacml id + */ public String getXacmlId() { return this.xacmlId; } + /** + * Sets the xacml id. + * + * @param xacmlId the new xacml id + */ public void setXacmlId(String xacmlId) { this.xacmlId = xacmlId; } + /** + * Gets the datatype bean. + * + * @return the datatype bean + */ public Datatype getDatatypeBean() { return this.datatypeBean; } + /** + * Sets the datatype bean. + * + * @param datatypeBean the new datatype bean + */ public void setDatatypeBean(Datatype datatypeBean) { this.datatypeBean = datatypeBean; } + /** + * Gets the issuer. + * + * @return the issuer + */ @Transient public String getIssuer() { return issuer; } + /** + * Sets the issuer. + * + * @param issuer the new issuer + */ @Transient public void setIssuer(String issuer) { this.issuer = issuer; } + /** + * Checks if is must be present. + * + * @return true, if is must be present + */ @Transient public boolean isMustBePresent() { return mustBePresent; } + /** + * Sets the must be present. + * + * @param mustBePresent the new must be present + */ @Transient public void setMustBePresent(boolean mustBePresent) { this.mustBePresent = mustBePresent; } + /** + * Gets the priority. + * + * @return the priority + */ public String getPriority() { return priority; } + /** + * Sets the priority. + * + * @param priority the new priority + */ public void setPriority(String priority) { this.priority = priority; } } - diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/DescriptiveScope.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/DescriptiveScope.java index aab9126e2..d571ed719 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/DescriptiveScope.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/DescriptiveScope.java @@ -3,13 +3,14 @@ * ONAP-REST * ================================================================================ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -38,10 +39,12 @@ import javax.persistence.Table; import javax.persistence.Temporal; import javax.persistence.TemporalType; - +/** + * The Class DescriptiveScope. + */ @Entity @Table(name = "DescriptiveScope") -@NamedQuery(name = "DescriptiveScope.findAll", query= "Select p from DescriptiveScope p") +@NamedQuery(name = "DescriptiveScope.findAll", query = "Select p from DescriptiveScope p") public class DescriptiveScope implements Serializable { private static final long serialVersionUID = 1L; @Id @@ -49,104 +52,191 @@ public class DescriptiveScope implements Serializable { @Column(name = "Id") private int id; - @Column(name="scopename", nullable=false) + @Column(name = "scopename", nullable = false) @OrderBy("asc") private String descriptiveScopeName; - @Column(name="description", nullable=true, length=2048) + @Column(name = "description", nullable = true, length = 2048) private String description; - @Column(name="search", nullable=true) + @Column(name = "search", nullable = true) @OrderBy("asc") private String search; @Temporal(TemporalType.TIMESTAMP) - @Column(name="created_date", updatable=false) + @Column(name = "created_date", updatable = false) private Date createdDate; @Temporal(TemporalType.TIMESTAMP) - @Column(name="modified_date", nullable=false) + @Column(name = "modified_date", nullable = false) private Date modifiedDate; @ManyToOne(optional = false) - @JoinColumn(name="created_by") + @JoinColumn(name = "created_by") private UserInfo userCreatedBy; @ManyToOne(optional = false) - @JoinColumn(name="modified_by") + @JoinColumn(name = "modified_by") private UserInfo userModifiedBy; + /** + * Gets the user created by. + * + * @return the user created by + */ public UserInfo getUserCreatedBy() { return userCreatedBy; } + /** + * Sets the user created by. + * + * @param userCreatedBy the new user created by + */ public void setUserCreatedBy(UserInfo userCreatedBy) { this.userCreatedBy = userCreatedBy; } + /** + * Gets the user modified by. + * + * @return the user modified by + */ public UserInfo getUserModifiedBy() { return userModifiedBy; } + /** + * Sets the user modified by. + * + * @param userModifiedBy the new user modified by + */ public void setUserModifiedBy(UserInfo userModifiedBy) { this.userModifiedBy = userModifiedBy; } + /** + * Pre persist. + */ @PrePersist - public void prePersist() { + public void prePersist() { Date date = new Date(); this.createdDate = date; this.modifiedDate = date; } + /** + * Pre update. + */ @PreUpdate public void preUpdate() { this.modifiedDate = new Date(); } + /** + * Gets the id. + * + * @return the id + */ public int getId() { return this.id; } + + /** + * Sets the id. + * + * @param id the new id + */ public void setId(int id) { this.id = id; } + /** + * Gets the scope name. + * + * @return the scope name + */ public String getScopeName() { return descriptiveScopeName; } + /** + * Sets the scope name. + * + * @param descriptiveScopeName the new scope name + */ public void setScopeName(String descriptiveScopeName) { this.descriptiveScopeName = descriptiveScopeName; } + /** + * Gets the search. + * + * @return the search + */ public String getSearch() { return search; } + /** + * Sets the search. + * + * @param search the new search + */ public void setSearch(String search) { this.search = search; } + /** + * Gets the created date. + * + * @return the created date + */ public Date getCreatedDate() { return this.createdDate; } + /** + * Sets the created date. + * + * @param createdDate the new created date + */ public void setCreatedDate(Date createdDate) { this.createdDate = createdDate; } + /** + * Gets the description. + * + * @return the description + */ public String getDescription() { return this.description; } + /** + * Sets the description. + * + * @param description the new description + */ public void setDescription(String description) { this.description = description; } + /** + * Gets the modified date. + * + * @return the modified date + */ public Date getModifiedDate() { return this.modifiedDate; } + /** + * Sets the modified date. + * + * @param modifiedDate the new modified date + */ public void setModifiedDate(Date modifiedDate) { this.modifiedDate = modifiedDate; } diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/DictionaryData.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/DictionaryData.java index 85a5091e8..40b8fcc33 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/DictionaryData.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/DictionaryData.java @@ -3,6 +3,7 @@ * ONAP-REST * ================================================================================ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,8 +33,6 @@ import javax.persistence.Table; @Table(name = "DictionaryData") @NamedQuery(name = "DictionaryData.findAll", query = "SELECT v FROM DictionaryData v ") public class DictionaryData { - private static final long serialVersionUID = 1L; - @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "id") diff --git a/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/ActionDictionaryJpaTest.java b/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/ActionDictionaryJpaTest.java index b2c3a77c1..047053a83 100644 --- a/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/ActionDictionaryJpaTest.java +++ b/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/ActionDictionaryJpaTest.java @@ -8,9 +8,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -21,8 +21,13 @@ package org.onap.policy.rest.jpa; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; +import com.att.research.xacml.api.Identifier; + import java.util.ArrayList; import java.util.Date; import java.util.HashSet; @@ -39,7 +44,7 @@ public class ActionDictionaryJpaTest { /** * Set up the test. - * + * * @throws Exception on test errors */ @Before @@ -141,7 +146,6 @@ public class ActionDictionaryJpaTest { data.removeAttribute(new Attribute()); data.isStandard(); data.isCustom(); - Category.extractGrouping("urn:oasis:names:tc:xacml:1.0:subject-category:intermediary-subject"); data.getIdentifer(); data.toString(); assertTrue(data.getAttributes() != null); @@ -153,6 +157,33 @@ public class ActionDictionaryJpaTest { assertTrue("Test".equals(data.getShortName())); data.setXacmlId("Test"); assertTrue("Test".equals(data.getXacmlId())); + + data.setIsStandard(Category.STANDARD); + assertEquals(Category.STANDARD, data.getIsStandard()); + assertTrue(data.isStandard()); + assertFalse(data.isCustom()); + + data.setIsStandard(Category.CUSTOM); + assertEquals(Category.CUSTOM, data.getIsStandard()); + assertFalse(data.isStandard()); + assertTrue(data.isCustom()); + + Identifier categoryIdentifier = new DummyIdentifier(); + Category data2 = new Category(categoryIdentifier, + "urn:oasis:names:tc:xacml:1.0:subject-category:intermediary-subject", Category.STANDARD); + assertEquals(DummyIdentifier.class.getName(), data2.getIdentifer().stringValue()); + + Category data3 = new Category(categoryIdentifier, + "urn:oasis:names:tc:xacml:1.0:subject-category:intermediary-subject"); + assertEquals(DummyIdentifier.class.getName(), data3.getIdentifer().stringValue()); + + assertEquals("subject", + Category.extractGrouping("urn:oasis:names:tc:xacml:1.0:subject-category:intermediary-subject")); + assertNull(Category.extractGrouping(null)); + assertNull(Category.extractGrouping("some random string")); + assertNull(Category.extractGrouping("")); + assertEquals("intermediary-attribute", Category + .extractGrouping("urn:oasis:names:tc:xacml:1.0:attribute-category:intermediary-attribute")); } @Test @@ -283,6 +314,19 @@ public class ActionDictionaryJpaTest { assertTrue(data.isStandard()); data.setIsStandard(Datatype.CUSTOM); assertTrue(data.isCustom()); + + data.setIsStandard(Category.STANDARD); + assertEquals(Category.STANDARD, data.getIsStandard()); + assertTrue(data.isStandard()); + assertFalse(data.isCustom()); + + data.setIsStandard(Category.CUSTOM); + assertEquals(Category.CUSTOM, data.getIsStandard()); + assertFalse(data.isStandard()); + assertTrue(data.isCustom()); + + Datatype data2 = new Datatype(new DummyIdentifier(), Datatype.STANDARD); + assertEquals(DummyIdentifier.class.getName(), data2.getIdentifer().stringValue()); } @Test diff --git a/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/BRMSDictionaryJPATest.java b/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/BrmsDictionaryJpaTest.java similarity index 71% rename from ONAP-REST/src/test/java/org/onap/policy/rest/jpa/BRMSDictionaryJPATest.java rename to ONAP-REST/src/test/java/org/onap/policy/rest/jpa/BrmsDictionaryJpaTest.java index 9012cca28..abfef0c35 100644 --- a/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/BRMSDictionaryJPATest.java +++ b/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/BrmsDictionaryJpaTest.java @@ -3,13 +3,14 @@ * ONAP-REST * ================================================================================ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,6 +18,7 @@ * limitations under the License. * ============LICENSE_END========================================================= */ + package org.onap.policy.rest.jpa; import static org.junit.Assert.assertTrue; @@ -28,11 +30,19 @@ import org.junit.Test; import org.onap.policy.common.logging.flexlogger.FlexLogger; import org.onap.policy.common.logging.flexlogger.Logger; -public class BRMSDictionaryJPATest { +/** + * The Class BrmsDictionaryJpaTest. + */ +public class BrmsDictionaryJpaTest { - private static Logger logger = FlexLogger.getLogger(BRMSDictionaryJPATest.class); + private static Logger logger = FlexLogger.getLogger(BrmsDictionaryJpaTest.class); private UserInfo userInfo; + /** + * Sets the up. + * + * @throws Exception the exception + */ @Before public void setUp() throws Exception { logger.info("setUp: Entering"); @@ -42,9 +52,12 @@ public class BRMSDictionaryJPATest { logger.info("setUp: exit"); } + /** + * Test BRMS param template. + */ @Test - public void testBRMSParamTemplate(){ - BRMSParamTemplate data = new BRMSParamTemplate(); + public void testBrmsParamTemplate() { + BrmsParamTemplate data = new BrmsParamTemplate(); data.prePersist(); data.setId(1); assertTrue(1 == data.getId()); @@ -55,14 +68,17 @@ public class BRMSDictionaryJPATest { data.setDescription("Test"); assertTrue("Test".equals(data.getDescription())); data.setCreatedDate(new Date()); - assertTrue(data.getCreatedDate()!=null); + assertTrue(data.getCreatedDate() != null); data.setUserCreatedBy(userInfo); - assertTrue(data.getUserCreatedBy()!=null); + assertTrue(data.getUserCreatedBy() != null); } + /** + * Test BRMS controller. + */ @Test - public void testBRMSController(){ - BRMSController data = new BRMSController(); + public void testBrmsController() { + BrmsController data = new BrmsController(); data.preUpdate(); data.prePersist(); data.setId(1); @@ -74,18 +90,21 @@ public class BRMSDictionaryJPATest { data.setDescription("Test"); assertTrue("Test".equals(data.getDescription())); data.setCreatedDate(new Date()); - assertTrue(data.getCreatedDate()!=null); + assertTrue(data.getCreatedDate() != null); data.setModifiedDate(new Date()); - assertTrue(data.getModifiedDate()!=null); + assertTrue(data.getModifiedDate() != null); data.setUserCreatedBy(userInfo); - assertTrue(data.getUserCreatedBy()!=null); + assertTrue(data.getUserCreatedBy() != null); data.setUserModifiedBy(userInfo); - assertTrue(data.getUserModifiedBy()!=null); + assertTrue(data.getUserModifiedBy() != null); } + /** + * Test BRMS dependency. + */ @Test - public void testBRMSDependency(){ - BRMSDependency data = new BRMSDependency(); + public void testrmsDependency() { + BrmsDependency data = new BrmsDependency(); data.preUpdate(); data.prePersist(); data.setId(1); @@ -97,13 +116,13 @@ public class BRMSDictionaryJPATest { data.setDescription("Test"); assertTrue("Test".equals(data.getDescription())); data.setCreatedDate(new Date()); - assertTrue(data.getCreatedDate()!=null); + assertTrue(data.getCreatedDate() != null); data.setModifiedDate(new Date()); - assertTrue(data.getModifiedDate()!=null); + assertTrue(data.getModifiedDate() != null); data.setUserCreatedBy(userInfo); - assertTrue(data.getUserCreatedBy()!=null); + assertTrue(data.getUserCreatedBy() != null); data.setUserModifiedBy(userInfo); - assertTrue(data.getUserModifiedBy()!=null); + assertTrue(data.getUserModifiedBy() != null); } } diff --git a/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/DummyIdentifier.java b/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/DummyIdentifier.java new file mode 100644 index 000000000..bd88db29a --- /dev/null +++ b/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/DummyIdentifier.java @@ -0,0 +1,46 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.rest.jpa; + +import com.att.research.xacml.api.Identifier; + +import java.net.URI; +import java.net.URISyntaxException; + +/** + * Dummy category identifier class. + */ +public class DummyIdentifier implements Identifier { + + @Override + public String stringValue() { + return this.getClass().getName(); + } + + @Override + public URI getUri() { + try { + return new URI(this.getClass().getName()); + } catch (URISyntaxException e) { + return null; + } + } +} diff --git a/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/MicroServiceDictionaryJPATest.java b/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/MicroServiceDictionaryJpaTest.java similarity index 81% rename from ONAP-REST/src/test/java/org/onap/policy/rest/jpa/MicroServiceDictionaryJPATest.java rename to ONAP-REST/src/test/java/org/onap/policy/rest/jpa/MicroServiceDictionaryJpaTest.java index 548e3fc84..5ea92fd13 100644 --- a/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/MicroServiceDictionaryJPATest.java +++ b/ONAP-REST/src/test/java/org/onap/policy/rest/jpa/MicroServiceDictionaryJpaTest.java @@ -3,13 +3,14 @@ * ONAP-REST * ================================================================================ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,6 +18,7 @@ * limitations under the License. * ============LICENSE_END========================================================= */ + package org.onap.policy.rest.jpa; import static org.junit.Assert.assertTrue; @@ -26,11 +28,19 @@ import org.junit.Test; import org.onap.policy.common.logging.flexlogger.FlexLogger; import org.onap.policy.common.logging.flexlogger.Logger; -public class MicroServiceDictionaryJPATest { +/** + * The Class MicroServiceDictionaryJpaTest. + */ +public class MicroServiceDictionaryJpaTest { - private static Logger logger = FlexLogger.getLogger(MicroServiceDictionaryJPATest.class); + private static Logger logger = FlexLogger.getLogger(MicroServiceDictionaryJpaTest.class); private UserInfo userInfo; + /** + * Sets the up. + * + * @throws Exception the exception + */ @Before public void setUp() throws Exception { logger.info("setUp: Entering"); @@ -40,9 +50,12 @@ public class MicroServiceDictionaryJPATest { logger.info("setUp: exit"); } + /** + * Test DCAE users. + */ @Test - public void testDCAEUsers(){ - DCAEUsers data = new DCAEUsers(); + public void testDcaeUsers() { + DcaeUsers data = new DcaeUsers(); data.setId(1); assertTrue(1 == data.getId()); data.setName("Test"); @@ -51,9 +64,12 @@ public class MicroServiceDictionaryJPATest { assertTrue("Test".equals(data.getDescriptionValue())); } + /** + * Test DCA euuid. + */ @Test - public void testDCAEuuid(){ - DCAEuuid data = new DCAEuuid(); + public void testDcaeUuid() { + DcaeUuid data = new DcaeUuid(); data.setId(1); assertTrue(1 == data.getId()); data.setName("Test"); @@ -62,8 +78,11 @@ public class MicroServiceDictionaryJPATest { assertTrue("Test".equals(data.getDescription())); } + /** + * Test MS config name. + */ @Test - public void testMSConfigName(){ + public void testMsConfigName() { MicroServiceConfigName data = new MicroServiceConfigName(); data.setId(1); assertTrue(1 == data.getId()); @@ -73,8 +92,11 @@ public class MicroServiceDictionaryJPATest { assertTrue("Test".equals(data.getDescriptionValue())); } + /** + * Test MS config location. + */ @Test - public void testMSConfigLocation(){ + public void testMsConfigLocation() { MicroServiceLocation data = new MicroServiceLocation(); data.setId(1); assertTrue(1 == data.getId()); @@ -84,8 +106,11 @@ public class MicroServiceDictionaryJPATest { assertTrue("Test".equals(data.getDescriptionValue())); } + /** + * Test MS models. + */ @Test - public void testMSModels(){ + public void testMsModels() { MicroServiceModels data = new MicroServiceModels(); data.setId(1); assertTrue(1 == data.getId()); @@ -104,15 +129,18 @@ public class MicroServiceDictionaryJPATest { data.setRef_attributes("Test"); assertTrue("Test".equals(data.getRef_attributes())); data.setUserCreatedBy(userInfo); - assertTrue(data.getUserCreatedBy()!=null); + assertTrue(data.getUserCreatedBy() != null); data.setSub_attributes("Test"); assertTrue("Test".equals(data.getSub_attributes())); data.setVersion("Test"); assertTrue("Test".equals(data.getVersion())); } + /** + * Test MS attribute dictionary. + */ @Test - public void testMSAttributeDictionary(){ + public void testMsAttributeDictionary() { MicroServiceAttribute data = new MicroServiceAttribute(); data.setId(1); assertTrue(1 == data.getId()); @@ -124,8 +152,11 @@ public class MicroServiceDictionaryJPATest { assertTrue("Test".equals(data.getModelName())); } + /** + * Test policy scope service. + */ @Test - public void testPolicyScopeService(){ + public void testPolicyScopeService() { PolicyScopeService data = new PolicyScopeService(); data.setId(1); assertTrue(1 == data.getId()); @@ -135,8 +166,11 @@ public class MicroServiceDictionaryJPATest { assertTrue("Test".equals(data.getDescriptionValue())); } + /** + * Test policy scope resource. + */ @Test - public void testPolicyScopeResource(){ + public void testPolicyScopeResource() { PolicyScopeResource data = new PolicyScopeResource(); data.setId(1); assertTrue(1 == data.getId()); @@ -146,8 +180,11 @@ public class MicroServiceDictionaryJPATest { assertTrue("Test".equals(data.getDescriptionValue())); } + /** + * Test policy scope type. + */ @Test - public void testPolicyScopeType(){ + public void testPolicyScopeType() { PolicyScopeType data = new PolicyScopeType(); data.setId(1); assertTrue(1 == data.getId()); @@ -157,8 +194,11 @@ public class MicroServiceDictionaryJPATest { assertTrue("Test".equals(data.getDescriptionValue())); } + /** + * Test policy scope closed loop. + */ @Test - public void testPolicyScopeClosedLoop(){ + public void testPolicyScopeClosedLoop() { PolicyScopeClosedLoop data = new PolicyScopeClosedLoop(); data.setId(1); assertTrue(1 == data.getId()); @@ -168,8 +208,11 @@ public class MicroServiceDictionaryJPATest { assertTrue("Test".equals(data.getDescriptionValue())); } + /** + * Test policy scope group policy scope list. + */ @Test - public void testPolicyScopeGroupPolicyScopeList(){ + public void testPolicyScopeGroupPolicyScopeList() { GroupPolicyScopeList data = new GroupPolicyScopeList(); data.setId(1); assertTrue(1 == data.getId()); @@ -181,8 +224,11 @@ public class MicroServiceDictionaryJPATest { assertTrue("Test".equals(data.getGroupList())); } + /** + * Test closed loops. + */ @Test - public void testClosedLoops(){ + public void testClosedLoops() { ClosedLoops data = new ClosedLoops(); data.setId(1); assertTrue(1 == data.getId()); @@ -194,8 +240,11 @@ public class MicroServiceDictionaryJPATest { assertTrue("Test".equals(data.getYaml())); } + /** + * Test VM type. + */ @Test - public void testVMType(){ + public void testVmType() { VMType data = new VMType(); data.setId(1); assertTrue(1 == data.getId()); diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateBRMSParamController.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateBRMSParamController.java index 244b7fd95..143d675bf 100644 --- a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateBRMSParamController.java +++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateBRMSParamController.java @@ -62,7 +62,7 @@ import org.onap.policy.common.logging.flexlogger.FlexLogger; import org.onap.policy.common.logging.flexlogger.Logger; import org.onap.policy.rest.adapter.PolicyRestAdapter; import org.onap.policy.rest.dao.CommonClassDao; -import org.onap.policy.rest.jpa.BRMSParamTemplate; +import org.onap.policy.rest.jpa.BrmsParamTemplate; import org.onap.policy.rest.jpa.PolicyEntity; import org.onap.policy.utils.PolicyUtils; import org.onap.policy.xacml.api.XACMLErrorConstants; @@ -131,9 +131,9 @@ public class CreateBRMSParamController extends RestrictedBaseController { } private String findRule(String ruleTemplate) { - List datas = commonClassDao.getDataById(BRMSParamTemplate.class, "ruleName", ruleTemplate); + List datas = commonClassDao.getDataById(BrmsParamTemplate.class, "ruleName", ruleTemplate); if (CollectionUtils.isNotEmpty(datas)) { - return ((BRMSParamTemplate) datas.get(0)).getRule(); + return ((BrmsParamTemplate) datas.get(0)).getRule(); } return null; } diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PolicyExportAndImportController.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PolicyExportAndImportController.java index 8f508ca31..651ee7e3a 100644 --- a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PolicyExportAndImportController.java +++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PolicyExportAndImportController.java @@ -55,7 +55,7 @@ import org.onap.policy.rest.adapter.PolicyExportAdapter; import org.onap.policy.rest.dao.CommonClassDao; import org.onap.policy.rest.jpa.ActionBodyEntity; import org.onap.policy.rest.jpa.ConfigurationDataEntity; -import org.onap.policy.rest.jpa.DCAEuuid; +import org.onap.policy.rest.jpa.DcaeUuid; import org.onap.policy.rest.jpa.GroupPolicyScopeList; import org.onap.policy.rest.jpa.MicroServiceConfigName; import org.onap.policy.rest.jpa.MicroServiceLocation; @@ -432,7 +432,7 @@ public class PolicyExportAndImportController extends RestrictedBaseController { private String validUuid(String uuid) { String message = null; if (uuid != null) { - List uuids = commonClassDao.getDataByColumn(DCAEuuid.class, "name"); + List uuids = commonClassDao.getDataByColumn(DcaeUuid.class, "name"); if (uuids != null && !(uuids.stream().filter(o -> o.equals(uuid)).findFirst().isPresent())) { message = POLICY + policyName + " uuid: " + uuid + NOTVALID; }