summaryrefslogtreecommitdiffstats
path: root/models-base/src
AgeCommit message (Collapse)AuthorFilesLines
2022-02-24Fix for ClassCastException on PfConceptContainer get method usagesRashmi Pujar1-8/+16
Typecasting Map to NavigableMap leads to ClassCastException. The usages of the get methods in delete policy, policyType endpoints in policy/api (using spring data jpa) cause the unchecked class-cast exception. Fix is to instead copy the Map entries into a newly created TreeMap instance. Issue-ID: POLICY-3924 Signed-off-by: Rashmi Pujar <rashmi.pujar1@bell.ca> Change-Id: I60625980d6f2692ffa7dd3bd9f53d10b43c13f4a
2022-02-16Fix issue with GeneratedValue in PfGeneratedIdKeya.sreekumar2-262/+0
PfGeneratedIdKey class (which is used as a composite key in JpaPolicyAudit and JpaPdpStatistics) uses GeneratedValue in a wrong way and not according to the specification. This review fixes it. PfGeneratedIdKey class is removed, and the generatedId is directly specified in the JpaPolicyAudit and JpaPdpStatistics classes. Note: These classes are only used by PAP, so the related methods for db interaction is removed as PAP directly talks to DB using spring repository layer. Also the only end result this change brings is that the 'generatedId' alone will be used as the primary key instead of 'generatedId, name and version' together. Corresponding changes in DB Migrator: https://gerrit.onap.org/r/c/policy/docker/+/127139 PAP: https://gerrit.onap.org/r/c/policy/pap/+/127130 Change-Id: Ib4ea8b60ffe5c2480746569c0354bf474a6b7006 Issue-ID: POLICY-3897 Signed-off-by: a.sreekumar <ajith.sreekumar@bell.ca>
2022-01-11Fix issues in existing entity classesa.sreekumar1-7/+3
Issues identified in the entity classes are fixed in this review. Some fixes doesn't affect the table structure at all. Tables actually affected by some of these fixes are not really used today, and doesn't contain any data. A separate review is raised for the db-migrator changes. Change-Id: I0efdf2c5f17e12225f1b443b5fe8e27c578229f7 Issue-ID: POLICY-3871 Signed-off-by: a.sreekumar <ajith.sreekumar@bell.ca>
2021-06-21Use lombok for events, base, daoJim Hahn6-40/+19
Issue-ID: POLICY-3396 Change-Id: I7b37efc13a25e0e27d63a85a3ee291e91a4e1682 Signed-off-by: Jim Hahn <jrh3@att.com>
2021-05-12Fix sonars in policy modelsJim Hahn9-27/+29
Fixed: - a few other "var" cases - use re2j instead of java.util.regex - use correct class for constants - remove unused constants Issue-ID: POLICY-3094 Change-Id: Ifcb2b0623e8df0527f0a279e666d062422978ded Signed-off-by: Jim Hahn <jrh3@att.com>
2021-04-29Remove GroupValidationResultJim Hahn4-19/+9
Removed GroupValidationResult, replacing it with BeanValidationResult. Modified the ParameterGroup subclasses to use BeanValidator, adding annotations where needed to trigger the validations that had been automatically performed by GroupValidationResult. Issue-ID: POLICY-2059 Change-Id: I245e4a647fcbb718faa63a7543f9f81c85da958c Signed-off-by: Jim Hahn <jrh3@att.com>
2021-04-22Add a new key class which uses @GeneratedValue to base classesktimoney2-0/+262
This will provide an alternative unique key. It will be used in place of PfTimestampKey in the PdpStatistics table. We make use of the @GeneratedValue annotation to provide this feature. Added DummyGeneratedIdEntity and unit tests Added PfFilterFactory class Added new filter classes Issue-ID: POLICY-3189 Change-Id: I097eab318d2cb958e1157e35825fd6d35d429a25 Signed-off-by: ktimoney <kevin.timoney@est.tech>
2021-03-24Merge "Fix sonar issues for tests in policy-models"Jim Hahn2-13/+34
2021-03-19Fix write failure on PDP statisticsliamfallon2-2/+4
Due to the precision of time stamps being saved to the nearest second, a millisecond precision timestamp was being compared to a second precision timestamp, causing the write to fail. This change fixes that. A unit test is also added to test for this on the provider. In addition, a USE-MARIADB flag is being introduced, which allows unit tests to be run against a locally installed MariaDB instance so that the unit tests can be verified against MariaDB locally rather than H2, the default in Gerrit. Issue-ID: POLICY-3146 Change-Id: I878f160956e89506743dc074679ee81ac1c48216 Signed-off-by: liamfallon <liam.fallon@est.tech>
2021-03-19Fix sonar issues for tests in policy-modelslapentafd2-13/+34
Tests refactoring to reduce number of assertions Issue-ID: POLICY-3094 Change-Id: I445462f0ec5d49474b10c1940c7fa12e687636de Signed-off-by: lapentafd <francesco.lapenta@est.tech>
2021-03-15Fix Sonar Issues on policy-models-toscalapentafd1-5/+0
Tests refactoring to reduce number of assertions Removed lines 167-169 in PfKeyImplTest Issue-ID: POLICY-3094 Change-Id: I94ef11068811c81108b0fbf3e5b878d02ab25306 Signed-off-by: lapentafd <francesco.lapenta@est.tech>
2021-03-08Merge "Use Date instead of Timestamp"Jim Hahn4-29/+37
2021-03-08Use Date instead of TimestampJim Hahn4-29/+37
Use of Timestamp in JPA classes appears to cause EntityNotFoundException. Changed from Timestamp back to Date. Issue-ID: POLICY-3125 Change-Id: I3ee29675849e3feda2641e9b240207c96fd975d4 Signed-off-by: Jim Hahn <jrh3@att.com>
2021-03-05Fix 4 newly added Sonar bugslapentafd2-4/+4
Added casting for 4 asserts in policy/models/base Issue-ID: POLICY-3094 Change-Id: Ibc97be3eca366a7e9b8b9611bc284f2473acff6e Signed-off-by: lapentafd <francesco.lapenta@est.tech>
2021-03-04Merge "Fix sonar issues on policy-models"Jim Hahn6-99/+195
2021-03-03Fix sonar issues on policy-modelslapentafd6-99/+195
Tests refactoring to reduce number of assertions to less then 25 Issue-ID: POLICY-3094 Change-Id: Icd3d83c7f8168dd81df13a584229eab36c646f37 Signed-off-by: lapentafd <francesco.lapenta@est.tech>
2021-03-03Fix Reference Key columns persistence issue in dbrameshiyer272-55/+128
Problem: When PfReferenceTimestamp Key is persisted in db, the parent class fields are ignored which causes inconsistent data while saving and fetching in db. Fix: JPA is not supporting inheritance in @Embeddable classes. Hence included the super class as @Embedded property in PfReferenceTimestamp key. @Embedded properties are unable to be queried directly. Slightly modified Dao methods to support querying @embedded fields. Issue-ID: POLICY-3049 Signed-off-by: zrrmmua <ramesh.murugan.iyer@est.tech> Change-Id: I5c2e03a5ae98525764a64dd6cce1a1298c5f9816
2021-02-25Fix Null key issue in PfReferenceTimestampKeyrameshiyer272-3/+8
isNUllKey check for PfReferenceTimestamp key is always returning false as the parent class is validating the child object in its method which has additional parameters (timestamp). Fixing the issue by validating only the fields of parent class. Issue-ID: POLICY-3069 Signed-off-by: zrrmmua <ramesh.murugan.iyer@est.tech> Change-Id: Ie22d09552c9d0cedb7535bda359df0d70e1ebe77
2021-02-19Refactor timestamp property in policy models to use Instantrameshiyer274-100/+114
Updated JPA classes to use java.sql.TImestamp rather than Instant. Issue-ID: POLICY-3069 Signed-off-by: zrrmmua <ramesh.murugan.iyer@est.tech> Change-Id: If5b874ec96931d4b8dd142d46a9980e83a4708fc
2021-02-16Add PfReference Timestamp key in policy-models-base to support timestamprameshiyer272-0/+375
property Issue-ID: POLICY-3011 Signed-off-by: zrrmmua <ramesh.murugan.iyer@est.tech> Change-Id: I7a9db3a4fb0345e0979952e5c086523cc1d960f9
2021-02-10More sonars in modelsJim Hahn6-20/+24
Addressed the following: - make constructors protected - check exception type - too many assertions - remove annotation lists - use "<>" - reduce cognitive complexity - extract constant - multiple method calls in one assert - don't use eq() in verify() - indentation Issue-ID: POLICY-2905 Change-Id: I25bb3951f781250e9cdfe8f5f3b80cb63e129184 Signed-off-by: Jim Hahn <jrh3@att.com>
2021-01-19Convert Model Exception to Runtime Exceptionliamfallon3-9/+38
Sometimes the exception thrown by the database providers has to be converted to a runtime exception, especiall if the database provider is running in a thread (called by the rum() method that does not return exceptions). It is convenient to have a constructor on the PfModelRuntimeException class that takes a PfModelException class as its argument, thus creating the runtime exception. Also the mapMap method in pfUtils is updated to allow the key of the map to be templated. By doing this, the utility can be used for maps that are keyed with types other than String (such as UUID). Issue-ID: POLICY-2971 Change-Id: Ib0b3678de531fd383753a1cd0ce47a06f4079ec0 Signed-off-by: liamfallon <liam.fallon@est.tech>
2021-01-06Use annotations on parameterized typesJim Hahn8-719/+282
Updated the code to place validation annotations directly on the annotated types instead of using the @Items and @Entries annotations. Also added/updated junits for validation code. Issue-ID: POLICY-2648 Change-Id: Ia535da07a38cec77a74c5c3215b5ae784d7a4e1a Signed-off-by: Jim Hahn <jrh3@att.com>
2020-12-23Merge "Add Service Template TOSCA handling"Liam Fallon3-11/+26
2020-12-23Add Service Template TOSCA handlingliamfallon3-11/+26
Today we can only handle a single service template in the database. We should be able to handle multiple service templates and assign arbitrary policy types and policies to maned and versioned service templates. This review brings in the Java API in models provider for handling service templates in this way and uses a simplistic single-teplate implementation in models-tosca, that will work but still only handles a single service template under the hood. Issue-ID: POLICY-2900 Change-Id: Ia02dea8abe44b7f407e685090a4b8e0360889653 Signed-off-by: liamfallon <liam.fallon@est.tech>
2020-12-22Allow wild-card in supportedPolicyTypesJim Hahn2-1/+3
Changes to the validation code broke the validation check for the supportedPolicyTypes field in PdpSubGroup - it no longer supports wild- cards in the name. Modified the validation annotation in PfSearchableKey to allow wild-card names. Issue-ID: POLICY-2648 Change-Id: Ibd2853025ce72ed88697dd9a7d6d5eed2b28475e Signed-off-by: Jim Hahn <jrh3@att.com>
2020-12-21Use annotations to do validationJim Hahn18-61/+450
Modified models to use annotations instead of function calls for most field validations. Created a few new validation annotations for use within models. Per review comments: - renamed Key to VerifyKey - enhanced VerifyKey to imply "@Valid", unless disabled Issue-ID: POLICY-2648 Change-Id: I2b53f218b0a2ab1ed1f5e278816a3509f1408972 Signed-off-by: Jim Hahn <jrh3@att.com>
2020-12-17Use ValidationResult for models v2.0Jim Hahn19-1097/+735
Policy models uses PfValidationXxx classes which are totally unrelated to ValidationResult in policy common. This precludes the use of various utility methods and annotations for doing validation. Modified policy models to use ValidationResult instead. This approach uses function calls, though a future approach could make use of annotations instead. Issue-ID: POLICY-2648 Change-Id: I9760f1dc46902ab6bef7f440f3caf5e951660a5d Signed-off-by: Jim Hahn <jrh3@att.com>
2020-12-14JPA concepts for TOSCAliamfallon4-54/+134
Implement the Database persistence parts for the new TOSCA concepts so that those concepts can be written to and read from the database. First batch of comment fixes Issue-ID: POLICY-2900 Change-Id: I45191c1ff57cf1ea8563399db6cc8e51b2724813 Signed-off-by: liamfallon <liam.fallon@est.tech>
2020-12-09Add functional method for mapping maps to PfUtilsliamfallon2-34/+30
Add a functional interface to PfUtils for mapping maps so that more complex conversions can be handled. List mapping functional methods added as well. Issue-ID: POLICY-2900 Change-Id: I4189e09d6d8621638960b5d9f0d19792a7faceb8 Signed-off-by: liamfallon <liam.fallon@est.tech>
2020-12-02Remove unused importsliamfallon4-5/+0
Issue-ID: POLICY-2900 Change-Id: Iaba37b81473b60d3da15a52ffcccdaa16a5b7091 Signed-off-by: liamfallon <liam.fallon@est.tech>
2020-12-01Add extra authorative TOSCA conceptsliamfallon12-27/+145
This review brings in extra TOSCA concepts for Node types, nodes, and capabilities. The TOSCA handling is also amended to make the handling of equality consistent. Now, if filtering or ordering is required using an order rather than natural ordering, a comparator must be supplied by the user. Issue-ID: POLICY-2900 Change-Id: Ie40e86870b97eb993b1338bdc0666ac116f72f67 Signed-off-by: liamfallon <liam.fallon@est.tech>
2020-10-02Fix eclipse/sonar warnings in modelsJim Hahn1-1/+0
Addressed the following eclipse/sonar warnings: - unused imports - unchanged type - unreachable "catch" block - reinterrupt Issue-ID: POLICY-2714 Change-Id: I2fe6011ec74b7fab8889050e5c83647ab034ea25 Signed-off-by: Jim Hahn <jrh3@att.com>
2020-09-30Remove Entity annotation from PfConceptContainerliamfallon1-1/+0
The PfConceptContainer class uses incompatible JPA anotations @MappedSuperClass and @Entity are incompatible as a MappedSuperClass cannot be an entity. Eclipselink silently tolerates this incompatibility but Hibernate (used in CLAMP) throws a build error on this class. Issue-ID: POLICY-2851 Change-Id: I2fd3d9217dc00717f8f2471e4848d254e7726b11 Signed-off-by: liamfallon <liam.fallon@est.tech>
2020-08-25Address more sonar issues in policy-modelsJim Hahn6-10/+8
Addressed sonar issues: - diamond operator Also removed a number of the "NOSONAR" comments now that we know how to address them without disabling sonar. Issue-ID: POLICY-2714 Change-Id: I440f4fa955968fd911616c2b6ee61b4b4d013821 Signed-off-by: Jim Hahn <jrh3@att.com>
2020-08-20Sonar Fixes policy/models, removing model-yamluj426b7-34/+39
Change-Id: Icd82ea1aef90e4d638b13958519aac5ed5a53f73 Issue-ID: POLICY-2714 Signed-off-by: uj426b <uj426b@att.com>
2020-06-19Merge "Changes for Checkstyle 8.32"Ram Krishna Verma30-59/+9
2020-06-18Changes for Checkstyle 8.32liamfallon31-60/+9
Issue-ID: POLICY-2188 Change-Id: I6db16763c1d2d80ff934302081a8dfc16afa7d9a Signed-off-by: liamfallon <liam.fallon@est.tech>
2020-06-18Replaced try/catch blocks in policy/models with assertj assertions.waynedunican1-14/+8
Issue-ID: POLICY-2451 Change-Id: I095beb674196d5ec5c4dd9b93d3a56cca5ee4788 Signed-off-by: waynedunican <wayne.dunican@est.tech>
2020-04-07Address sonar issues in modelsJim Hahn2-2/+7
Addressed the following sonar issues: - use RE2 instead of java.util Pattern for "+" and "*" - don't use deprecated methods - for Date(long), sonar appeared not to parse the argument's type correctly. Modified the code slightly to make sonar happy - duplicate blocks of code - either log or throw - missing assert in junit - for SDNR & VFC, eliminated threads, as they are unnecessary - duplicate code block in different branches - useless assignments - redeclaring abstract methods - cyclomatic complexity - used lombok in some cases (e.g., EqualsAndHashCode) - assert argument order - actually deleted ControlLoopTargetType, because it is not needed and sonar complains regardless of which order is used - add private constructor to utility classes - use StandardCharsets instead of literals Also: - added logback-test.xml to SO to eliminate the voluminous output from the junit test Issue-ID: POLICY-2305 Change-Id: I586c331781bedbd54a115a71847d04d293689445 Signed-off-by: Jim Hahn <jrh3@att.com>
2020-03-20Test cascaded multiple revision getsliamfallon2-1/+3
This patch tests cascaded get requests with multiple revisions. Issue-ID: POLICY-2377 Change-Id: Ie7dc849d7b930b861d38c386a9950ae7e84e2a05 Signed-off-by: liamfallon <liam.fallon@est.tech>
2020-03-20Merge "Misc simple sonar issue fixes"Liam Fallon2-5/+6
2020-03-19Misc simple sonar issue fixesChris Ramstad2-5/+6
Issue-ID: POLICY-2389 Signed-off-by: Chris Ramstad <cramstad@ciena.com> Change-Id: I7ce91e331a128aaadaab5ac837e19873a3388164
2020-03-19Add unit test for Version fetch changeliamfallon2-0/+71
Issue-ID: POLICY-2377 Change-Id: Iaad1da84de058fcb50d24663156b4b0bcedd427e Signed-off-by: liamfallon <liam.fallon@est.tech>
2020-03-19Allow fetch of old policy type verisonsliamfallon2-3/+48
Due to the problems with TOSCA and version handling, the filtering for policy types on old versions did not work. This change fixes that problem. Issue-ID: POLICY-2377 Change-Id: I462bd5710b9dea37475861d1021d28b2c7391a24 Signed-off-by: liamfallon <liam.fallon@est.tech>
2020-03-18Return latest entity on null versionsliamfallon2-2/+6
This review amends the behaviour of "get" operations on entities to always return the latest version of an entity when the version of the search key is the null key (value of 0.0.0). Issue-ID: POLICY-2377 Change-Id: I4f7c12637c90bc1a83ce2ba5ef40e15b461a7d51 Signed-off-by: liamfallon <liam.fallon@est.tech>
2020-03-13Consistent returns on Service Template getsliamfallon11-166/+212
This review enables specification of versions of entities on incoming service templates using a ':' delimiter. So this will load version 1.00, version 2.0.0, and version 3.0.0: org.onap.entitiy:1.0.0: version: 1.0.0 org.onap.entity:2.0.0: version: 2.0.0 org.onap.entity version: 3.0.0 So this will load version 1.00, version 2.0.0, and version 4.0.0: org.onap.entitiy:1.0.0: version: 1.0.0 org.onap.entity:2.0.0: version: 2.0.0 org.onap.entity: version: 3.0.0 org.onap.entity: version: 4.0.0 This will load org.onap.entity:1.0.0 name: org.onap.entity version: 1.0.0 This will throw an exception org.onap.entity:1.0.0 name: org.onap.some.other.entity version: 1.0.0 This will throw an exception org.onap.entity:1.0.0: name: org.onap.entity version: 2.0.0 Issue-ID: POLICY-2377 Change-Id: I34bccf065b4ee4d2fe71b052bf009d4a40e2cba8 Signed-off-by: liamfallon <liam.fallon@est.tech>
2020-02-12Implement validation and hierarchical getliamfallon1-2/+2
NOTE: This review will require changes to the persistence.xml file in other policy framework components. This change brings in two changes: 1) Validation of the references betwen policies, policy types, and data types This change mans that additions to and changes to policies, policy types, and data types must be structurally correct in the change coming in and with whatever is already in the database 2) Hierarchical return of referenced entitites on policy types, policies and data types. When a policy, policy type, or data type is read from the database, the entities referenced byt the returned policy, policy type, or data type are returned as well. Tests are amended for the stricter validation and structure. Examples are corrected where they are incorrect. Issue-ID: POLICY-1402 Change-Id: Ie6a4cb7ed336562338924079114df405f0ab889f Signed-off-by: liamfallon <liam.fallon@est.tech>
2020-02-04Add merge utility for service templatesliamfallon2-13/+11
This utility function allows a TOSCA service template fragment to be merged with an exsiting service template and will be tbe backbone of "create" methods on the API from now on. Issue-ID: POLICY-1402 Change-Id: I3381cb2a1bd30621a639dedc213c546eeb2bf9aa Signed-off-by: liamfallon <liam.fallon@est.tech>
2020-01-28Add service template persistence providerliamfallon1-18/+33
Persistence needs to be carried out at service template level in order to guarantee consistency of the service template in the database as much as possible. Therefire, service template lelve reading, writing, and delting is required. Issue-ID: POLICY-1402 Change-Id: I5be57c29381bf6ddc87afdbb64ddae66a5ea5e5f Signed-off-by: liamfallon <liam.fallon@est.tech>