aboutsummaryrefslogtreecommitdiffstats
path: root/models-base/src/main
AgeCommit message (Collapse)AuthorFilesLines
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-08Use Date instead of TimestampJim Hahn2-18/+25
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-04Merge "Fix sonar issues on policy-models"Jim Hahn1-1/+1
2021-03-03Fix sonar issues on policy-modelslapentafd1-1/+1
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 dbrameshiyer271-28/+100
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 PfReferenceTimestampKeyrameshiyer271-2/+4
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 Instantrameshiyer272-51/+60
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 timestamprameshiyer271-0/+222
property Issue-ID: POLICY-3011 Signed-off-by: zrrmmua <ramesh.murugan.iyer@est.tech> Change-Id: I7a9db3a4fb0345e0979952e5c086523cc1d960f9
2021-02-10More sonars in modelsJim Hahn5-18/+20
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 Exceptionliamfallon2-7/+19
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 Hahn6-412/+28
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 Hahn1-1/+1
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 Hahn14-44/+432
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 Hahn9-532/+332
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 TOSCAliamfallon3-44/+85
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 PfUtilsliamfallon1-23/+19
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-01Add extra authorative TOSCA conceptsliamfallon4-8/+44
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 Hahn2-5/+4
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-06-18Changes for Checkstyle 8.32liamfallon11-30/+5
Issue-ID: POLICY-2188 Change-Id: I6db16763c1d2d80ff934302081a8dfc16afa7d9a Signed-off-by: liamfallon <liam.fallon@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 getsliamfallon1-1/+1
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-19Allow fetch of old policy type verisonsliamfallon1-3/+39
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 getsliamfallon2-42/+67
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 templatesliamfallon1-4/+1
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>
2020-01-10Remove deprecated methods from modelsJim Hahn1-2/+2
Addressed the following issues related to the java 11 upgrade: - forClass().newInstance() - java.xml.bind no longer included in jdk - new mockito doesn't clear captured lists Issue-ID: POLICY-1406 Signed-off-by: Jim Hahn <jrh3@att.com> Change-Id: Ia254c1ed21f847d1824e7abc22528975372ee2b6
2019-12-11Merge "Fix minor checksyle issues in models"Pamela Dragosh2-17/+19
2019-12-10Fix minor checksyle issues in modelsliamfallon2-17/+19
New checkstyle profile flagged some minor issues in policy models. Issue-ID: POLICY-2165 Change-Id: I17ed070a3d55601ad31e48fdfd29fff01d29fa42 Signed-off-by: liamfallon <liam.fallon@est.tech>
2019-12-09Add JpaPdpStatistics entityshaoqiu1-0/+156
Add JpaPdpStatistics entity which will be used in provider. Add Pdp Statistics entities Issue-ID: POLICY-1628 Signed-off-by: shaoqiu <tim.huang@est.tech> Change-Id: Iab12eb02e2e7f0e366aff64fa665b5d6674f2905 Signed-off-by: shaoqiu <tim.huang@est.tech>
2019-11-15Support wild cards in "supported policy types"Jim Hahn3-218/+431
Refactored PfConceptKey, extracting most of it into PfKeyImpl. Added PfSearchableKey as a subclass of PfKeyImpl. Change-Id: I524f4ce9208fc9ba09e77db4cc7dde5a21e1d7fc Issue-ID: POLICY-2224 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-08-27Replace copyTo methods with copy constructorsJim Hahn7-97/+101
Deleted the copyTo() method from PfConcepts and replaced uses with deep-copy constructors. Also added mapMap() and makeCopy() methods to PfUtils to facilitate. Change-Id: Id6391bb806ef0dfab6c1089278bf2b514c7e303e Issue-ID: POLICY-1600 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-08-07replace hashCode function with compareToHenry.Sun5-5/+5
Issue-ID: POLICY-1600 Change-Id: If660cbe84424e492b6db3ab11ef97b37f046b3aa Signed-off-by: Henry.Sun <henry.a.sun@est.tech>
2019-06-18Change getCanonicalName to getName in modelsJim Hahn1-1/+2
Per javadocs, getName() should generally be used instead of Class.getCanonicalName(). This change only applies to classes; it does not apply to File objects. Note: this impacts the output from PfValidationMessage, as it will now list the names of embedded classes with a "$" separator instead of a ".". Change-Id: I2cd64bc0281dd324bf80eac57335a7299a516447 Issue-ID: POLICY-1646 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-06-14Allow multiple versions of entities to be returnedliamfallon1-4/+10
Fix .gitreviw file to point at "master" rather than "dublin" Allow return of multiple versions of policy types and data types in TOSCA service templates and multiple policies in TOSCA topology templates. Because the return type is a list of singleton maps, utility methods were added to return flat maps of poliicy types, data types, and policies keyed by a compound ToscaEntityKey name/version key. Issue-ID: POLICY-1807 Change-Id: I355038aaca26f41064d0e3cb3b45b1de2294cf5f Signed-off-by: liamfallon <liam.fallon@est.tech>
2019-05-22Fix name/version regexp in model keysliamfallon1-3/+3
The regular expressions for checking names and versions in policy key names and versions were not expressive enough to restrict all error names and versions. Issue-ID: POLICY-1777 Change-Id: I037eca051f6c7a9f1e7182150d40d8b8d906a75c Signed-off-by: liamfallon <liam.fallon@est.tech>
2019-05-21Add version on legacy get/deleteliamfallon2-3/+13
Issue-ID: POLICY-1777 Change-Id: I5b07ad1acdb4a614a50cb15978130c19bc5786f7 Signed-off-by: liamfallon <liam.fallon@est.tech>
2019-05-21Fix policy version compare on versions > 9liamfallon1-3/+3
Issue-ID: POLICY-1777 Change-Id: I83d6d15653a5bd934515980186349b8bd710c113 Signed-off-by: liamfallon <liam.fallon@est.tech>
2019-05-07Set default and check existance of Policy Typeliamfallon2-0/+86
The TOSCA specification has a "bug" in that it does not have a field to specify the version of a policy type to use. We already had introduced the "type_version" field for this. This review introduces setting of the default version of a policy type to be be used by a policy as the latest version of the policy type in the database. As a side effect of this, we now have to check for existence of the policy type of a policy in the database. This means that creation/update of a policy with a non-existant policy type specified will now fail. Issue-ID: POLICY-1738 Change-Id: I27080cf6cd358948810dab6897c72dfe4d41fe91 Signed-off-by: liamfallon <liam.fallon@est.tech>
2019-04-14Add prefix matching for policy versionJim Hahn1-4/+67
Re-introduced regular expressions to match policy version so that the policy version found in the metadata, which is just the major number, can be matched with a policy's version, which is of the form, major.minor.patch. Simplified equals() test, as we already know "text!=null". Added filterPrefixPred() and modified policy filter to use it when matching versions, as it is simpler to use when matching a version prefix. Also added tests to PfObjectFilterTest to test each of the XxxPred() methods. Change-Id: I0734873f701a539e883fe25b8eecfdde60cc8b6d Issue-ID: POLICY-1542 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-04-10Finish unit test on policy-modelsliamfallon1-2/+0
Unit test coverage well over 90% in policy-models-base policy-models-dao policy-models-pdp policy-models-tosca policy-models-provider Issue-ID: POLICY-1095 Change-Id: I7703e2ae8a93575ca478c3d809ff8c1fb9f0f334 Signed-off-by: liamfallon <liam.fallon@est.tech>
2019-04-09Add unit tests for policy type and policy filtersliamfallon1-1/+2
THis review adds unit tests for the authorative concepts in the models-tosc module and adds unit tests for the authorative and and database providers. Issue-ID: POLICY-1095 Change-Id: If98deea99658056030dd47725b0c0a4266d84106 Signed-off-by: liamfallon <liam.fallon@est.tech>
2019-04-09Complete unit test for models-pdpliamfallon1-2/+2
This review completes the unit test for the models-pdp module, for persistence of PDP groups and for PDP group filtering. Added unit test of filters for TOSCA policy types and policies. Added fix to allow filters to pass when the value being checked is null. Issue-ID: POLICY-1095 Change-Id: I982400ef39f0282d813d49e484a58207e03b8a63 Signed-off-by: liamfallon <liam.fallon@est.tech>