From 8ab6f7031e2b52c7fb5ec71ebb6d20f85dc87318 Mon Sep 17 00:00:00 2001 From: Oliver Grande Date: Tue, 24 Oct 2023 11:47:52 +0200 Subject: [PATCH] Feature/release 2.0.0 (#230) * Feature/transient fields (#142) * Fix null pointer if no enumerations are part of servcie * Enable HAS and enumeration as return type of operations * Allow Enumerations as operation parameter * Provide java based operations converted enumeration * Add SourceClear addon * Delete SourceClean addon * Enumerations at UDF functions - Works for bound functions - Works for functions with import * Correct unit tests * Enable multiple values for flags enumerations * Switch detection default between Embedded and Entity type * Allow collection attributes for metadata * Enable query without collection attributes * Rework query result conversion to reduce memory consumtion * Missing Metadata pom * First step entity with collections as return of function/action * Bugfix: Expand on Parent with $filter on navigation path * Enable the use of Join Tables - Filter on navigation via Join Table generally not supported * Create new query for inlinecount * Enable Join Tables@Navigation Filter - Not working mapped associations - Not working $count * Enable Join Tables@Navigation Filter - With mapped associations - With $count, know issue EclipsLink two sub types * Increase Version --> 0.2.6 * Remove deprecated JPAExecutableQuery * Bugfix: unidirectional join table based association * Access collection properties via navigation - New version * Access collection properties w and w/o $select * Access collection properties which are part of complex property * CUD operations on collection properties * Filter on collection properties pre optimization * Filter on collection properties any/all * Filter on collection w/o filter on $count and orderby $count * Correct issue #29 - Correct /$count implementation in JPAJoinQuery - Clean-up Hibernate differences -- Subquery from clause -- Id Class determination * Increase Version to 0.2.7 * Enable ..@odata.navigationLink in case of odata.metadata=full - links@complex types not yet working * Preparation for solution of issue OLINGO-1143 * Correct NullPointer and some clean-ups * Support order by $count - Increase version to 0.2.8 * Intermediate merge clean-up * Solve merge problem navigate complex collections * Resolve merge conflict converter * Correct error collection property and expand=* * Enable filter $count on collection property * Update version and url * Create and use page provider * Recreate change for solution of issue OLINGO-1143 * Finalize top level server driven paging * Correct string handling error * Correct link problem * Enable skiptoken to have other type than String * Move paging so next request injects old uriInfo correctly * Enable deep insert via complex properties * Ignore test for next commit * Enable create of a new entity linked by a to one using PATCH * Update to Olingo 4.5.0 - use new Olingo version - adopt one test to changed @odata.context content * Collection attributes rework. Issue #60 - Change processor pom -> javax.servlet became provided * Enable annotation for properties to mark them authorization relevant * Enable multiple protected properties at complex attributes * Rework EdmProtectedBy annotation to handle multiple claims at complex * Process protection * Rework handling of ignored protected * Made inner class static * Fixing issue #60 * $count query not working correctly on complex collection attributes * Various small bugs - Reorg. pom.xml - Correct http status on empty result - Correct empty check for collection properties * Correct typo in interface JPAODataPagingProvider * Prepare JPAODataDatabaseTableFunction for paging * Change to HSQLDB * Remove function from sql-file to work around problems with Derby * Correct NullPointerException EdmEntitySetResult * Determine result of create dependent based on before image * EntityType getAttribute did not return value for embedded id * Provide CUD example and correct query status codes * Correct query response * Maven Archetype for Spring based service * Upgrade to Junit5 to get support for Java > 1.8 * Extract interface for better unit test support - Cleanup tests * Clean-up interface implementation * Add SQL function handling * Complete DB function changes * Clean-up test class * Clean-up test class * Update Version number * Update Version number * Additional test for API classes * Enable suppress of wildcard in metadata * Enable wildcards during query processing * Increase information on error during filter * Support of PUT on collection properties and primitive properties * Fix Null Pointer on PATCH with return != minimal * Claims where not respected by queries issue #69 part one - /$count - ?$count=true - paging queries * Claims where not respected by queries issue #69 part two - $filter - Update on Olingo 4.6.0 * Restrict the DISTINCT to protections only * Increase test coverage - New tests - Rework vocabulary handling * Cleanup Vocabularies II - Add Action and Function - Remove NavigationProperty and dependent * Additional test and solution of issue #78 * Enable new annotation EdmVisibleFor at properties * Introduction of Request Context - Deprecation of two variants of JPAODataGetHandler.process - Increase test coverage * Restrict EdmVisiableFor to nullable non key attributes * Skip properties from selection that do not belong to provided group * Handle collection properties and navigation path * Enable groups at complex collections * Handle OrderBy clause * Correct unit test * Rework test containing images * Rework context handling - Move of cud handler to request context - Move of DebugSupport to request context (is request specific because of isUserAuthorized) - Introduction of builder for Service Context to get a leaner creation of handler * Providing groups during modifying requests * Re-enable old shortcut with late metadata provisioning * Update pom for missing jackson dependency * Update Archetype to version 0.3.4 * Update Version * Extension of session context, so an emf can be provided * Ignore annotation qualified if empty * Go back to Olingo JSON deserializer * Add qualifier to annotation * Increase release * Clean-up JPAEdmNameBuilder * Preparation of custom name builder - Create public interface - replace class by new interface * Revoke test adoption * Providing custome name builder * Update annotation EdmFunction * Increase release * Adopt archetype - Simplify service - Add integration test * Modify example did not persist on create * Deep Insert did not responded deep * Always select ETag * Complete ETag handling * Missing Context Changes * Reset unit test to current pushed state * Increase test coverage * Adopt test to real number of complex types * Enable V4.01 JSON format as request and response * Additional Integration tests support OData V4.01 JSON * Allow usage of different types of transaction * Increase Spring support * Bugfix/issue83 (#120) * Update Version * Extension of session context, so an emf can be provided * Preparation of custom name builder - Create public interface - replace class by new interface * Revoke test adoption * Providing custome name builder * Update annotation EdmFunction * Increase release * Adopt archetype - Simplify service - Add integration test * Modify example did not persist on create * Deep Insert did not responded deep * Always select ETag * Complete ETag handling * Missing Context Changes * Reset unit test to current pushed state * Increase test coverage * Adopt test to real number of complex types * Enable V4.01 JSON format as request and response * Additional Integration tests support OData V4.01 JSON * Allow usage of different types of transaction * Increase Spring support * Restrict $expand select by key range * Support root with navigation like AdministrativeDivision(...)/Children * Protect dilution of test coverage by test package (#133) * Increase release * Increase release (#136) * Protect dilution of test coverage by test package (#135) * Remove deprecated artifacts (#134) * Remove deprecated artefacts * Missing test adoptions * Upgrade Olingo version and processor version * Feature/transient fields (#137) * Increase release * Upgrade Olingo version and processor version * Prevent NPE on expand empty result (#138) * Correct SonarQube and SpotBug hints * Feature/transient fields (#139) * Increase release * Upgrade Olingo version and processor version * Correct SonarQube and SpotBug hints * SpotBugs and clean-ups * Build metadata I * First draft of criteria builder and query implementation (#140) * First draft of criteria builder and query implementation * Add Transient * First join version * Correct structured type * Test adoption was missing * Update criteria builder * Solve enum error * Support aggregation function * Correct buildInverseJoinColumns() error * Add Test buildInverseJoinColumns() error * Enable table join without entity type * Correct Error table name * Own test for JPAEdmProvider and correct name builder error * Additional test * Support parallel processing of batch requests * Complete synchronized creation of metadata * Enable transient field calculator * Suppress transient fields at $filter and $orderby * Enable transient collections and collections with transient attributes * Additional tests for changing operations * Enable absolute path in url * Add sonar plugin (#144) * Add sonar plugin * Update pom with sonar plugin * Feature/logging (#145) * Add sonar plugin * Update pom with sonar plugin * Remove old xmake version * Feature/logging (#147) * Add sonar plugin * Update pom with sonar plugin * Remove old xmake version * Logging as part of standard debugger * Generic authorization check for JPAExampleCUDRequestHandler * Feature/logging (#148) * Add sonar plugin * Update pom with sonar plugin * Remove old xmake version * Logging as part of standard debugger * Generic authorization check for JPAExampleCUDRequestHandler * Update xmake version * Feature/logging (#150) * Add sonar plugin * Update pom with sonar plugin * Remove old xmake version * Logging as part of standard debugger * Generic authorization check for JPAExampleCUDRequestHandler * Update xmake version * Clean-up sonar issues * Feature/logging (#151) * Add sonar plugin * Update pom with sonar plugin * Remove old xmake version * Logging as part of standard debugger * Generic authorization check for JPAExampleCUDRequestHandler * Update xmake version * Clean-up sonar issues * Update build status on read.me * New badges * Update README.md * Update README.md * Feature/logging (#152) * Add sonar plugin * Update pom with sonar plugin * Remove old xmake version * Logging as part of standard debugger * Generic authorization check for JPAExampleCUDRequestHandler * Update xmake version * Clean-up sonar issues * Update build status on read.me * New badges * Clean-up sonar issues * Create additional test for debugger * Add tests for debugger * Update README.md * Replace database derby -> hsqldb * Update README.md (#153) * Feature/logging (#154) * Add sonar plugin * Update pom with sonar plugin * Remove old xmake version * Logging as part of standard debugger * Generic authorization check for JPAExampleCUDRequestHandler * Update xmake version * Clean-up sonar issues * Update build status on read.me * New badges * Clean-up sonar issues * Create additional test for debugger * Add tests for debugger * Update README.md * Replace database derby -> hsqldb * Cleanup sonar issue * Increase test coverage for criteria builder (#155) * Feature/criteria builder (#156) * Increase test coverage for criteria builder * Replace double implementation by mocks * Update README.md (#157) * Feature/criteria builder (#158) * Increase test coverage for criteria builder * Replace double implementation by mocks * Rework vocabulary read * Feature/criteria builder (#159) * Increase test coverage for criteria builder * Replace double implementation by mocks * Rework vocabulary read * Add method to retrieve all claims * Update README.md (#160) * Update README.md * Update README.md * Remove potential null pointer (#161) * Bugfix/sonar issues (#162) * Remove potential null pointer * Remove potential Null Pointer * Bugfix/sonar issues (#163) * Remove potential null pointer * Remove potential Null Pointer * Remove potential Null Pointer * Bugfix/sonar issues (#164) * Remove potential null pointer * Remove potential Null Pointer * Remove potential Null Pointer * Additional clean-ups * Work on soanr issues * Bugfix/sonar issues (#165) * Remove potential null pointer * Remove potential Null Pointer * Remove potential Null Pointer * Additional clean-ups * Work on soanr issues * Additional cleanups * Feature/release 1.0.0 (#170) * Bugfix/typo package (#168) * Update version to 1.0.0-RC * Rename package to ...metadata.core.edm.mapper.extension * Rename message constants * Correct typos in method names * Rollback change to Optional * Support Include Annotation (#169) * Feature/include annotation (#171) * Support Include Annotation * Increase test coverage transient properties * Bugfix/issue98 (#173) * Support java.time.Instant and BigInteger * Correct issue #98 - Correct typo - Make DatabaseProcessor public * Enhance documentation of transient property calculator * Bugfix/issue98 (#174) * Support java.time.Instant and BigInteger * Correct issue #98 - Correct typo - Make DatabaseProcessor public * Enhance documentation of transient property calculator * Clean-up sonar issue * Clean-up sonar * Clean-up author * Meaningfull error message on $apply * Service Context creates Emf Wrapper if present in class path * Suppoprt of MappedSuperclass * $top and $skip use order by primary key * sonar issues (#175) * Support java.time.Instant and BigInteger * Correct issue #98 - Correct typo - Make DatabaseProcessor public * Enhance documentation of transient property calculator * Clean-up sonar issue * Clean-up sonar * Clean-up author * Meaningfull error message on $apply * Service Context creates Emf Wrapper if present in class path * Suppoprt of MappedSuperclass * $top and $skip use order by primary key * Clean-up sonar issues * Bugfix/issue98 (#176) * Support java.time.Instant and BigInteger * Correct issue #98 - Correct typo - Make DatabaseProcessor public * Enhance documentation of transient property calculator * Clean-up sonar issue * Clean-up sonar * Clean-up author * Meaningfull error message on $apply * Service Context creates Emf Wrapper if present in class path * Suppoprt of MappedSuperclass * $top and $skip use order by primary key * Clean-up sonar issues * Clean-up sonar issues * Bugfix/issue98 (#177) * Support java.time.Instant and BigInteger * Correct issue #98 - Correct typo - Make DatabaseProcessor public * Enhance documentation of transient property calculator * Clean-up sonar issue * Clean-up sonar * Clean-up author * Meaningfull error message on $apply * Service Context creates Emf Wrapper if present in class path * Suppoprt of MappedSuperclass * $top and $skip use order by primary key * Clean-up sonar issues * Clean-up sonar issues * Delete intermediate code * Feature/criteria builder (#178) * Increase test coverage for criteria builder * Replace double implementation by mocks * Rework vocabulary read * Add method to retrieve all claims * Add README.md and correct spelling errors * Add README.md and correct spelling errors (#179) * Feature/release 1.0.0 (#192) * Bugfix/typo package (#168) * Update version to 1.0.0-RC * Rename package to ...metadata.core.edm.mapper.extension * Rename message constants * Correct typos in method names * Rollback change to Optional * Support Include Annotation (#169) * Feature/include annotation (#171) * Support Include Annotation * Increase test coverage transient properties * Bugfix/syntax errors (#181) * Feature/release 1.0.0 (#170) * Bugfix/typo package (#168) * Update version to 1.0.0-RC * Rename package to ...metadata.core.edm.mapper.extension * Rename message constants * Correct typos in method names * Rollback change to Optional * Support Include Annotation (#169) * Feature/include annotation (#171) * Support Include Annotation * Increase test coverage transient properties * Bugfix/issue98 (#173) * Support java.time.Instant and BigInteger * Correct issue #98 - Correct typo - Make DatabaseProcessor public * Enhance documentation of transient property calculator * Bugfix/issue98 (#174) * Support java.time.Instant and BigInteger * Correct issue #98 - Correct typo - Make DatabaseProcessor public * Enhance documentation of transient property calculator * Clean-up sonar issue * Clean-up sonar * Clean-up author * Meaningfull error message on $apply * Service Context creates Emf Wrapper if present in class path * Suppoprt of MappedSuperclass * $top and $skip use order by primary key * sonar issues (#175) * Support java.time.Instant and BigInteger * Correct issue #98 - Correct typo - Make DatabaseProcessor public * Enhance documentation of transient property calculator * Clean-up sonar issue * Clean-up sonar * Clean-up author * Meaningfull error message on $apply * Service Context creates Emf Wrapper if present in class path * Suppoprt of MappedSuperclass * $top and $skip use order by primary key * Clean-up sonar issues * Bugfix/issue98 (#176) * Support java.time.Instant and BigInteger * Correct issue #98 - Correct typo - Make DatabaseProcessor public * Enhance documentation of transient property calculator * Clean-up sonar issue * Clean-up sonar * Clean-up author * Meaningfull error message on $apply * Service Context creates Emf Wrapper if present in class path * Suppoprt of MappedSuperclass * $top and $skip use order by primary key * Clean-up sonar issues * Clean-up sonar issues * Bugfix/issue98 (#177) * Support java.time.Instant and BigInteger * Correct issue #98 - Correct typo - Make DatabaseProcessor public * Enhance documentation of transient property calculator * Clean-up sonar issue * Clean-up sonar * Clean-up author * Meaningfull error message on $apply * Service Context creates Emf Wrapper if present in class path * Suppoprt of MappedSuperclass * $top and $skip use order by primary key * Clean-up sonar issues * Clean-up sonar issues * Delete intermediate code * Feature/criteria builder (#178) * Increase test coverage for criteria builder * Replace double implementation by mocks * Rework vocabulary read * Add method to retrieve all claims * Add README.md and correct spelling errors * Add README.md and correct spelling errors * Correct syntax errors metadata * Clean-up typos * Rework build of OrderBy creation (#183) * Bugfix/syntax errors (#185) * Feature/release 1.0.0 (#170) * Bugfix/typo package (#168) * Update version to 1.0.0-RC * Rename package to ...metadata.core.edm.mapper.extension * Rename message constants * Correct typos in method names * Rollback change to Optional * Support Include Annotation (#169) * Feature/include annotation (#171) * Support Include Annotation * Increase test coverage transient properties * Bugfix/issue98 (#173) * Support java.time.Instant and BigInteger * Correct issue #98 - Correct typo - Make DatabaseProcessor public * Enhance documentation of transient property calculator * Bugfix/issue98 (#174) * Support java.time.Instant and BigInteger * Correct issue #98 - Correct typo - Make DatabaseProcessor public * Enhance documentation of transient property calculator * Clean-up sonar issue * Clean-up sonar * Clean-up author * Meaningfull error message on $apply * Service Context creates Emf Wrapper if present in class path * Suppoprt of MappedSuperclass * $top and $skip use order by primary key * sonar issues (#175) * Support java.time.Instant and BigInteger * Correct issue #98 - Correct typo - Make DatabaseProcessor public * Enhance documentation of transient property calculator * Clean-up sonar issue * Clean-up sonar * Clean-up author * Meaningfull error message on $apply * Service Context creates Emf Wrapper if present in class path * Suppoprt of MappedSuperclass * $top and $skip use order by primary key * Clean-up sonar issues * Bugfix/issue98 (#176) * Support java.time.Instant and BigInteger * Correct issue #98 - Correct typo - Make DatabaseProcessor public * Enhance documentation of transient property calculator * Clean-up sonar issue * Clean-up sonar * Clean-up author * Meaningfull error message on $apply * Service Context creates Emf Wrapper if present in class path * Suppoprt of MappedSuperclass * $top and $skip use order by primary key * Clean-up sonar issues * Clean-up sonar issues * Bugfix/issue98 (#177) * Support java.time.Instant and BigInteger * Correct issue #98 - Correct typo - Make DatabaseProcessor public * Enhance documentation of transient property calculator * Clean-up sonar issue * Clean-up sonar * Clean-up author * Meaningfull error message on $apply * Service Context creates Emf Wrapper if present in class path * Suppoprt of MappedSuperclass * $top and $skip use order by primary key * Clean-up sonar issues * Clean-up sonar issues * Delete intermediate code * Feature/criteria builder (#178) * Increase test coverage for criteria builder * Replace double implementation by mocks * Rework vocabulary read * Add method to retrieve all claims * Add README.md and correct spelling errors * Add README.md and correct spelling errors * Add README.md and correct spelling errors (#179) * Correct syntax errors metadata * Clean-up typos * Update Version -> 1.0.0 * Usage of builder to create external request context (#187) * Bugfix/continue on error (#189) * Move batch processor from API to PROCESSOR package * Correct continue-on-error handling * Support generated Id in example CUD handler (#190) * Support generated Id in example CUD handler * Correct failing test * Adoption of archetype to 1.0.0 (#191) * Adoption of archetype to 1.0.0 * Correct sql error * Clean-up sonar issues * Correct criteria builder implementation (#193) * Feature/criteria builder (#194) * Correct criteria builder implementation * Enable sub query as FROM * Update tests * Update sonar issues * Update sonar issue * Add mutation testing to processor and metadata * Feature/criteria builder (#195) * Correct criteria builder implementation * Enable sub query as FROM * Update tests * Update sonar issues * Update sonar issue * Add mutation testing to processor and metadata * Eliminate duplicate code * Feature/criteria builder (#196) * Correct criteria builder implementation * Enable sub query as FROM * Update tests * Update sonar issues * Update sonar issue * Add mutation testing to processor and metadata * Eliminate duplicate code * Add Locale to request context, so it can be set from user data * Correct request context copy * Feature/criteria builder (#197) * Correct criteria builder implementation * Enable sub query as FROM * Update tests * Update sonar issues * Update sonar issue * Add mutation testing to processor and metadata * Eliminate duplicate code * Add Locale to request context, so it can be set from user data * Correct request context copy * Missing transient fields at $expand * Add tests * Feature/criteria builder (#198) * Correct criteria builder implementation * Enable sub query as FROM * Update tests * Update sonar issues * Update sonar issue * Add mutation testing to processor and metadata * Eliminate duplicate code * Add Locale to request context, so it can be set from user data * Correct request context copy * Missing transient fields at $expand * Add tests * Fix GeneratedKey problem * Feature/criteria builder (#199) * Correct criteria builder implementation * Enable sub query as FROM * Update tests * Update sonar issues * Update sonar issue * Add mutation testing to processor and metadata * Eliminate duplicate code * Add Locale to request context, so it can be set from user data * Correct request context copy * Missing transient fields at $expand * Add tests * Fix GeneratedKey problem * Intermediate state * Enable next block of queries * Expand with Join Tables * Last unit test corrections * Eliminate typos * Finalize changes * missing variable usage (#200) * missing variable usage * Increase processor version * Clean-up Sonar issues (#201) * Bugfix/no mapper for operations (#202) * Clean-up Sonar issues * Add test for type mapping for actions and java function + Cleanup test classes * Feature/1.0.1 (#203) * Correct criteria builder implementation * Enable sub query as FROM * Update tests * Update sonar issues * Update sonar issue * Add mutation testing to processor and metadata * Eliminate duplicate code * Add Locale to request context, so it can be set from user data * Correct request context copy * Missing transient fields at $expand * Add tests * Fix GeneratedKey problem * Change version to 1.0.1 * New version (#204) * Bugfix/filter eq withdate (#205) * New version * Support filter on Date and DateTime * Correct precision * Change another test * Us generated alias for column selection (#206) * Upgrade Version (#207) * Us generated alias for column selection * Upgrade version * Reduce complexity (#209) * ALL did not work with functions like startswith (#210) * Update version (#208) * Entity Set Path @ DB Functions (#211) * Feature/new archetype (#212) * Clean-up folder name * Create archetype repo * Use copy of spring archetype as start * Enable named queries * Feature/new archetype (#213) * Clean-up folder name * Create archetype repo * Use copy of spring archetype as start * Enable named queries * Allow Star for non string claim properties * Add Equals method to DeepProtectedExample * Feature/new archetype (#214) * Clean-up folder name * Create archetype repo * Use copy of spring archetype as start * Enable named queries * Allow Star for non string claim properties * Add Equals method to DeepProtectedExample * Enable grant access to all for non string fields read * Replace Reflections API by Reflections8 (#215) * Support entitytypes singeltons (#216) * New annotation to make singletons and entity types - Update to olingo 4.8.0 - Deprecate EdmAsEntitySet - Read not ready * Update README.md (#218) * Update README.md * Update README.md * Update README.md * Solve issue 136 (#217) * Solve issue 136 * Eliminate hyphen * Eliminate WhiteSource detected vulnerabilities (#219) * Eliminate WhiteSource detected vulnerabilities * Add now required dependency * Remove setExternalName from Metadata Post Processor (#220) * Support entitytypes singeltons (#221) * New annotation to make singletons and entity types - Update to olingo 4.8.0 - Deprecate EdmAsEntitySet * Wrong entity type on singleton only * Add java doc to TopLevelElementRepresentation * Finalize singleton metadata handling * Clean-up test classes * Add option to retrieve Singleton from SD * Rename test class * Support entitytypes singeltons (#222) * New annotation to make singletons and entity types - Update to olingo 4.8.0 - Deprecate EdmAsEntitySet * Wrong entity type on singleton only * Add java doc to TopLevelElementRepresentation * Finalize singleton metadata handling * Clean-up test classes * Add option to retrieve Singleton from SD * Rename test class * Add and clean-up unit tests * Query extension declaration (#223) * New annotation to make singletons and entity types - Update to olingo 4.8.0 - Deprecate EdmAsEntitySet * Wrong entity type on singleton only * Add java doc to TopLevelElementRepresentation * Finalize singleton metadata handling * Clean-up test classes * Add option to retrieve Singleton from SD * Rename test class * Add and clean-up unit tests * Introduce query extension metadata * Enable Singleton and Cast on subtypes - clean-up sonar issues * Support entity types and singletons (#224) * New annotation to make singletons and entity types - Update to olingo 4.8.0 - Deprecate EdmAsEntitySet * Wrong entity type on singleton only * Add java doc to TopLevelElementRepresentation * Finalize singleton metadata handling * Clean-up test classes * Add option to retrieve Singleton from SD * Rename test class * Add and clean-up unit tests * Introduce query extension metadata * Enable Singleton and Cast on subtypes - clean-up sonar issues * Clean-up sonar issues * Support cast on navigations (#225) * New annotation to make singletons and entity types - Update to olingo 4.8.0 - Deprecate EdmAsEntitySet * Wrong entity type on singleton only * Add java doc to TopLevelElementRepresentation * Finalize singleton metadata handling * Clean-up test classes * Add option to retrieve Singleton from SD * Rename test class * Add and clean-up unit tests * Introduce query extension metadata * Enable Singleton and Cast on subtypes - clean-up sonar issues * Clean-up sonar issues * Cast within navigation path * Add cast collections * Add tests for EdmBoundCast * Support Cast on $expand * Update README.md (#226) * Update README.md * Update README.md * Update README.md * Update README.md * Bugfix/no constranis with ignored properties (#227) * Suppress referential constraint for properties that shall be ignored * No Referential Constraint in case one property shall be ignored * Bugfix/no constranis with ignored properties (#228) * Suppress referential constraint for properties that shall be ignored * No Referential Constraint in case one property shall be ignored * Bring back error on ignored * Enable subtyping for complex types (#229) * Support transient properties that require ignored properties (#231) * Bugfix/multi level inheritance (#232) * Adopt process-cb * Correct type converter problem * Use dbType for tuple result mapping * Bugfix/multi level inheritance (#233) * Adopt process-cb * Correct type converter problem * Use dbType for tuple result mapping * Correct constructor test of extension * Feature/release 1.0.3 (#234) * Correct typos and replace deprecated method * Set final Version * Feature/release 1.0.4 (#235) * Error corrections - Debugger did not work - Transaction Factory not forwarded * Update release * Make debugger runtime a List * Feature/release 1.0.4 (#236) * Error corrections - Debugger did not work - Transaction Factory not forwarded * Update release * Make debugger runtime a List * Small adoptions to test model * Reset change * Error correction (#237) * Feature/release 1.0.5 (#238) * Error corrections - Debugger did not work - Transaction Factory not forwarded * Update release * Make debugger runtime a List * Small adoptions to test model * Reset change * Add test for criteria builder * Error correction * Update H2 version (#239) * Update H2 version * Update version and rework DataSourceHelper * Feature/release 1.0.6 (#240) * Update H2 version * Update version and rework DataSourceHelper * Let H2 run in Postges mode * Upgrade version and additional tests (#241) * Upgrade version and additional tests * Remove session context from queries * Remove session context from processors * New version an sonar clean-up (#242) * Release 1.1.0 (#243) * New version an sonar clean-up * New path property fro sonar * Release 1.1.0 (#244) * New version an sonar clean-up * New path property fro sonar * Test usage of SNAPSHOT version * Update version -> 1.0.8 (#245) * Update version -> 1.0.8 * Count queries support Integer as result * Update archetype to support PATCH * Feature/release 1.0.0 (#247) * New version an sonar clean-up * New path property fro sonar * Test usage of SNAPSHOT version * Adopt archetype * Clean-up sonar issues * Resolve more sonar issues * Introducing virtual property * Clean-up associations and enable default columns when using ...-cb * Generate metadata for overloaded action (#248) * Generate metadata for overloaded action * Process action * Feature/action overload (#249) * Generate metadata for overloaded action * Process action * Use constructor of entity type an action is called for not of binding * Fix claims in collections where (#250) * Fix claims in collections where * Missed interface definition * Missed test renaming * Use dbtype to build key pair in case a conversion exists (#251) * Enable more constructors for binding parameter (#252) * Feature/more flexable constructor determination operations (#253) * Enable more constructors for binding parameter * Clean-up sonar errors * New type cast added - they have possible data lost (#254) * Collection not longer retrieves transient (#255) * Collection not longer retrieves transient * Skip unit test * Enhance partner determination (#256) * Bugfix/reuse navigation as partner (#257) * Enhance partner determination * Remove one sonar issue * Bugfix/reuse navigation as partner (#258) * Enhance partner determination * Remove one sonar issue * Correct partner determination * No fallback to server locale in case bundle requested local not found (#259) * Replace file reader (#260) * Replace fixed values by variables (#261) * Bugfix/error in controller test (#262) * Replace fixed values by variables * Update pom * Update archetype pom (#265) * Defect/archetype pom (#266) * Update archetype pom * Check older version of sonar plugin * Update test constants (#267) * Correct count behavior (#268) * Change to Java 11 (#269) * Change to Java 11 * Revert Java 11 * Update README.md (#270) * Defect/count not working on hana (#271) * Correct count behavior * Ignore sonar check. Equal methods are generated * Defect/java function parameter name (#272) * Raise meaningful exception on empty function parameter name * Meaningful exception if action parameter name empty * Raise message in case of Void as return type for functions (#273) * Raise message in case of Void as return type for functions * Add extenstion * Error in if clause * Extension of visitor for java functions (#274) * Update version to 1.1.1 (#275) * Feature/predefined annotations (#276) * First list of predefined OData annotations * Update capabilities annotations * Sonar issues * Update dependencies * Adopt layer test * Add page to order by builder (#277) * Feature/predefined annotations (#278) * First list of predefined OData annotations * Update capabilities annotations * Sonar issues * Update dependencies * Adopt layer test * Intermediate state * Clean-up basic mapping and introduce annotation * Finalize annotation mapper * Feature/predefined annotations (#279) * First list of predefined OData annotations * Update capabilities annotations * Sonar issues * Update dependencies * Adopt layer test * Intermediate state * Clean-up basic mapping and introduce annotation * Finalize annotation mapper * Update dependency * Feature/predefined annotations (#280) * First list of predefined OData annotations * Update capabilities annotations * Sonar issues * Update dependencies * Adopt layer test * Intermediate state * Clean-up basic mapping and introduce annotation * Finalize annotation mapper * Update dependency * Adopt HSQLDB * Update .xmake.cfg (#283) * Update .xmake.cfg * Update .xmake.cfg * Correct spelling (#281) * Feature/predefined annotations (#282) * First list of predefined OData annotations * Update capabilities annotations * Sonar issues * Update dependencies * Adopt layer test * Intermediate state * Clean-up basic mapping and introduce annotation * Finalize annotation mapper * Update dependency * Adopt HSQLDB * Rename package for vocabulary parser * Move OData vocabularies to new module * Merge tests * Annotations in metadata * Finalize annotations within metadata * Update .xmake.cfg (#284) * Update .xmake.cfg * Update .xmake.cfg * Feature/predefined annotations (#286) * First list of predefined OData annotations * Update capabilities annotations * Sonar issues * Update dependencies * Adopt layer test * Intermediate state * Clean-up basic mapping and introduce annotation * Finalize annotation mapper * Update dependency * Adopt HSQLDB * Rename package for vocabulary parser * Move OData vocabularies to new module * Merge tests * Annotations in metadata * Finalize annotations within metadata * Support sorting restrictions by annotation * Build annotation based expand check * Expand star via path reads only requested from database * Check countability * Support collection property count * Annotations@Singeltons * Provide AnnotationProvider to all model elements * Enable annotations at properties * Feature/predefined annotations (#287) * First list of predefined OData annotations * Update capabilities annotations * Sonar issues * Update dependencies * Adopt layer test * Intermediate state * Clean-up basic mapping and introduce annotation * Finalize annotation mapper * Update dependency * Adopt HSQLDB * Rename package for vocabulary parser * Move OData vocabularies to new module * Merge tests * Annotations in metadata * Finalize annotations within metadata * Support sorting restrictions by annotation * Build annotation based expand check * Expand star via path reads only requested from database * Check countability * Support collection property count * Annotations@Singeltons * Provide AnnotationProvider to all model elements * Enable annotations at properties * Enable access to annotations via JPARequestEntity * Watch filtering * Clean-up pom and typo correction (#288) * Solve issue 212 and fix permission check issue with join tables (#289) * Solve issue 212 and fix permission check issue with join tables * $count for collection join as well * Clean-up code * Fix issue, converting type (#290) * Fix issue, converting type * Fix unit test * Correct type determination * Multi step Mapped Superclass (#291) * Upgrade H2 to 2.2.220 (#293) * Correct navigation to one is null (#294) * Fix join column determination with cyclic dependency (#295) * Fix join column determination with cyclic dependency * Additional test for navigation with mapped join table * Make OneToOne required and handle non JPA Processor errors in metadata (#296) * Defect/issue214 (#297) * Make OneToOne required and handle non JPA Processor errors in metadata * Clean-up warnings * Defect/issue214 (#298) * Make OneToOne required and handle non JPA Processor errors in metadata * Clean-up warnings * Add check for OneToMany * Clean-up sonar issues * Update .xmake.cfg (#300) * Update version to 2.0.0 (#299) * Update version to 2.0.0 * Unify junit version * Make use of Jakarta * Clean-up sonar issues created by switching to Java 17 * Update dependencies * Update dependencies and clean-up typos * Add unit tests * Increase test coverage * Additional correction * Update github workflow * Correct parent pom * Sonar and missed merge-conflicts * Jakarta also in java doc * Update archetype controller * Support of Java 21 * Find archetype test error * Remove import for LocalServerPort * Remove flyway dependency and use spring boot provided * Adopt EclipseLinkJpaConfiguration to Spring Boot 3.x * Add missing imports * Set package name * Bring back flyway to artifact pom * Update README * Update README.md * JPAEdmMetadataPostProcessor as interface * Update README * Fix sonar issue * Fix another issue --- .github/workflows/archetype.yml | 4 +- LICENSE.txt | 2 +- README.md | 42 +- additionalWords.directory | 11 +- .../odata-jpa-archetype-spring-scp/pom.xml | 34 - .../META-INF/maven/archetype-metadata.xml | 50 - .../resources/archetype-resources/pom.xml | 133 -- .../security/xs-security.json | 69 - .../src/main/java/SpringApp.java | 12 - .../config/EclipseLinkJpaConfiguration.java | 75 - .../java/config/ProcessorConfiguration.java | 47 - .../main/java/controller/ODataController.java | 33 - .../src/main/java/model/EntityTemplate.java | 75 - .../main/java/model/ValueObjectTemplate.java | 63 - .../java/model/ValueObjectTemplateKey.java | 56 - .../src/main/resources/application-test.yml | 23 - .../src/main/resources/application.yml | 29 - .../main/resources/db/migration/V1_0__jpa.sql | 14 - .../src/test/java/AppTest.java | 20 - .../java/integrationtest/ControllerTest.java | 158 -- .../requests/CreateEntityViaBatch.txt | 46 - .../odata-jpa-archetype-spring/pom.xml | 7 +- .../resources/archetype-resources/pom.xml | 60 +- .../config/EclipseLinkJpaConfiguration.java | 27 +- .../java/config/ProcessorConfiguration.java | 2 +- .../main/java/controller/ODataController.java | 4 +- .../src/main/java/model/EntityTemplate.java | 20 +- .../main/java/model/ValueObjectTemplate.java | 16 +- .../java/model/ValueObjectTemplateKey.java | 2 +- .../src/main/resources/application-test.yml | 2 +- .../java/integrationtest/ControllerTest.java | 3 - jpa-archetype/pom.xml | 7 +- jpa-tutorial/QuickStart/QuickStart.adoc | 26 +- jpa/.settings/org.eclipse.jdt.core.prefs | 2 - jpa/odata-jpa-annotation/.gitignore | 3 - .../.settings/org.eclipse.jdt.core.prefs | 6 +- ....eclipse.wst.common.project.facet.core.xml | 2 +- jpa/odata-jpa-annotation/pom.xml | 12 +- .../converter/OffsetDateTimeConverter.java | 4 +- .../converter/TimeInstantLongConverter.java | 4 +- .../core/edm/annotation/EdmAsEntitySet.java | 21 - .../core/edm/annotation/EdmEntityType.java | 4 +- .../core/edm/annotation/EdmEnumeration.java | 7 +- .../annotation/EdmQueryExtensionProvider.java | 13 +- .../core/edm/annotation/EdmTransient.java | 6 +- .../EdmTransientPropertyCalculator.java | 17 +- .../edm/annotation/EdmEnumerationTest.java | 6 +- .../EdmTransientPropertyCalculatorTest.java | 6 +- jpa/odata-jpa-coverage/pom.xml | 4 +- .../.settings/org.eclipse.jdt.core.prefs | 6 +- ....eclipse.wst.common.project.facet.core.xml | 2 +- jpa/odata-jpa-metadata/pom.xml | 6 +- .../api/JPAEdmMetadataPostProcessor.java | 19 +- .../jpa/metadata/api/JPAEdmProvider.java | 5 +- .../metadata/api/JPAEntityManagerFactory.java | 9 +- .../jpa/metadata/api/JPAJoinColumn.java | 2 +- .../metadata/api/JPAODataQueryContext.java | 6 +- .../core/edm/mapper/api/JPAAttribute.java | 3 +- .../edm/mapper/api/JPAEdmNameBuilder.java | 22 +- .../edm/mapper/extension/ODataAction.java | 2 +- .../edm/mapper/extension/ODataFunction.java | 2 +- .../mapper/impl/DefaultEdmPostProcessor.java | 2 +- .../impl/IntermediateActionFactory.java | 4 +- .../impl/IntermediateCollectionProperty.java | 23 +- .../mapper/impl/IntermediateComplexType.java | 4 +- .../impl/IntermediateDescriptionProperty.java | 30 +- .../impl/IntermediateEmbeddedIdProperty.java | 4 +- .../mapper/impl/IntermediateEntityType.java | 60 +- .../impl/IntermediateEnumerationType.java | 4 +- .../impl/IntermediateFunctionFactory.java | 8 +- .../mapper/impl/IntermediateJoinColumn.java | 2 +- .../mapper/impl/IntermediateJoinTable.java | 11 +- .../mapper/impl/IntermediateModelElement.java | 4 +- .../impl/IntermediateNavigationProperty.java | 1419 +++++++++-------- .../impl/IntermediateOperationFactory.java | 15 +- .../impl/IntermediateOperationHelper.java | 9 +- .../edm/mapper/impl/IntermediateProperty.java | 25 +- .../edm/mapper/impl/IntermediateSchema.java | 11 +- .../impl/IntermediateServiceDocument.java | 3 +- .../impl/IntermediateSimpleProperty.java | 12 +- .../impl/IntermediateStructuredType.java | 62 +- .../impl/IntermediateVirtualProperty.java | 3 +- .../mapper/impl/JPAAssociationPathImpl.java | 12 +- .../mapper/impl/JPADefaultEdmNameBuilder.java | 36 +- .../core/edm/mapper/impl/JPANameBuilder.java | 2 +- .../core/edm/mapper/impl/JPAPathImpl.java | 5 +- .../impl/JPAServiceDocumentFactory.java | 4 +- .../edm/mapper/impl/JPATypeConverter.java | 10 +- .../reuse/OffsetDateTimeConverter.java | 27 - .../metadata-exceptions-i18n.properties | 3 +- .../jpa/metadata/api/JPAEdmProviderTest.java | 5 +- .../edm/mapper/impl/CustomJPANameBuilder.java | 8 +- .../impl/IntermediateActionFactoryTest.java | 6 +- .../IntermediateCollectionPropertyTest.java | 12 +- .../impl/IntermediateComplexTypeTest.java | 4 +- .../impl/IntermediateContainerTest.java | 4 +- .../IntermediateDescriptionPropertyTest.java | 10 +- .../IntermediateEmbeddedIdPropertyTest.java | 4 +- .../impl/IntermediateEntitySetTest.java | 6 +- .../impl/IntermediateEntityTypeTest.java | 28 +- .../impl/IntermediateJoinTableTest.java | 6 +- .../IntermediateNavigationPropertyTest.java | 12 +- .../impl/IntermediateOperationHelperTest.java | 32 + .../impl/IntermediateReferencesTest.java | 2 +- .../mapper/impl/IntermediateSchemaTest.java | 4 +- .../impl/IntermediateSimplePropertyTest.java | 14 +- .../impl/IntermediateSingletonTest.java | 4 +- ...turedTypeTransientPluralAttributeTest.java | 4 +- ...ateStructuredTypeVirtualAttributeTest.java | 4 +- .../impl/IntermediateVirtualPropertyTest.java | 4 +- .../impl/IntermediateWrongAnnotationTest.java | 8 +- .../impl/JPAQueryExtensionProviderTest.java | 6 +- .../edm/mapper/impl/JPATypeConverterTest.java | 8 +- .../core/edm/mapper/impl/TestHelper.java | 14 +- .../core/edm/mapper/impl/TestMappingRoot.java | 4 +- .../mapper/testaction/ActionWithOverload.java | 8 +- .../core/edm/mapper/testaction/Actions.java | 10 +- .../ConverterWithConstructorError.java | 2 +- .../testobjects/ExampleFunctionForFilter.java | 4 +- .../testobjects/ExampleJavaEmConstructor.java | 10 +- .../ExampleJavaPrivateConstructor.java | 10 +- .../ExampleJavaTwoParameterConstructor.java | 10 +- .../testobjects/FileAccessConverter.java | 8 +- .../testobjects/TestActionCollection.java | 7 + .../testobjects/TestCollectionInterface.java | 8 + .../testobjects/WrongFunctionConstructor.java | 2 +- .../testobjects/WrongMemberConverter.java | 8 +- .../testobjects/WrongTypeConverter.java | 6 +- jpa/odata-jpa-odata-vocabularies/pom.xml | 8 +- .../JavaBasedODataAnnotationsProvider.java | 12 +- jpa/odata-jpa-processor-cb/README.md | 2 +- jpa/odata-jpa-processor-cb/pom.xml | 4 +- .../cb/api/EntityManagerFactoryWrapper.java | 26 +- .../processor/cb/impl/AbstractJoinImp.java | 11 +- .../processor/cb/impl/CollectionJoinImpl.java | 27 +- .../cb/impl/CompoundSelectionImpl.java | 65 +- .../cb/impl/CriteriaBuilderImpl.java | 104 +- .../processor/cb/impl/CriteriaQueryImpl.java | 37 +- .../cb/impl/EntityManagerWrapper.java | 62 +- .../jpa/processor/cb/impl/ExpressionImpl.java | 34 +- .../jpa/processor/cb/impl/FromImpl.java | 131 +- .../processor/cb/impl/InheritanceInfo.java | 9 +- .../cb/impl/JPAAttributeWrapper.java | 10 +- .../jpa/processor/cb/impl/JPAPathWrapper.java | 2 +- .../jpa/processor/cb/impl/JoinTableJoin.java | 9 +- .../jpa/processor/cb/impl/OrderImpl.java | 4 +- .../processor/cb/impl/ParameterBuffer.java | 7 +- .../jpa/processor/cb/impl/PathImpl.java | 40 +- .../jpa/processor/cb/impl/PathJoin.java | 9 +- .../jpa/processor/cb/impl/PredicateImpl.java | 17 +- .../jpa/processor/cb/impl/RootImpl.java | 10 +- .../jpa/processor/cb/impl/SelectionImpl.java | 5 +- .../jpa/processor/cb/impl/SelectionPath.java | 29 +- .../jpa/processor/cb/impl/SimpleJoin.java | 9 +- .../jpa/processor/cb/impl/SqlJoinType.java | 2 +- .../jpa/processor/cb/impl/SqlSelection.java | 2 +- .../jpa/processor/cb/impl/SubqueryImpl.java | 35 +- .../processor/cb/impl/SubqueryRootImpl.java | 39 +- .../jpa/processor/cb/impl/TupleImpl.java | 14 +- .../jpa/processor/cb/impl/TypeConverter.java | 16 +- .../jpa/processor/cb/impl/TypedQueryImpl.java | 129 +- .../cb/joiner/ExpressionCollector.java | 7 +- .../processor/cb/joiner/ExpressionJoiner.java | 7 +- .../cb/joiner/StringBuilderCollector.java | 7 +- .../api/EntityManagerFactoryWrapperTest.java | 18 +- .../cb/impl/AggregationExpressionTest.java | 6 +- .../cb/impl/ArithmeticExpressionTest.java | 4 +- .../processor/cb/impl/BuilderBaseTest.java | 29 +- .../cb/impl/CompoundSelectionImplTest.java | 4 +- .../cb/impl/CriteriaBuilderDerbyTest.java | 3 +- .../cb/impl/CriteriaBuilderH2Test.java | 11 +- .../cb/impl/CriteriaBuilderHSQLDBTest.java | 3 +- .../cb/impl/CriteriaBuilderImplTest.java | 414 ++--- .../cb/impl/CriteriaBuilderOverallTest.java | 20 +- .../cb/impl/CriteriaQueryImplTest.java | 32 +- .../cb/impl/EntityManagerWrapperTest.java | 29 +- .../processor/cb/impl/ExpressionImplTest.java | 4 +- .../processor/cb/impl/ExpressionPathTest.java | 6 +- .../jpa/processor/cb/impl/FromImplTest.java | 29 +- .../cb/impl/InheritanceInfoTest.java | 2 +- .../cb/impl/JPAAttributeWrapperTest.java | 2 +- .../processor/cb/impl/JPAPathWrapperTest.java | 2 +- .../processor/cb/impl/JoinTableJoinTest.java | 4 +- .../jpa/processor/cb/impl/OrderImplTest.java | 4 +- .../cb/impl/ParameterExpressionImplTest.java | 4 +- .../jpa/processor/cb/impl/PathImplTest.java | 12 +- .../processor/cb/impl/PrerdicateImplTest.java | 18 +- .../jpa/processor/cb/impl/SimpleJoinTest.java | 4 +- .../processor/cb/impl/SqlJoinTypeTest.java | 2 +- .../processor/cb/impl/SubqueryImplTest.java | 39 +- .../cb/impl/SubqueryRootImplTest.java | 55 + .../jpa/processor/cb/impl/TupleImplTest.java | 6 +- .../processor/cb/impl/TypedQueryImplTest.java | 16 +- .../cb/joiner/ExpressionJoinerTest.java | 16 +- .../processor/cb/testobjects/SubJoined.java | 4 +- .../processor/cb/testobjects/SuperJoined.java | 8 +- .../cb/testobjects/SuperTablePerClass.java | 8 +- jpa/odata-jpa-processor-ext/pom.xml | 2 +- .../cb/ProcessorCriteriaBuilder.java | 15 +- .../processor/cb/ProcessorCriteriaQuery.java | 6 +- .../jpa/processor/cb/ProcessorSelection.java | 24 +- .../jpa/processor/cb/ProcessorSubquery.java | 11 +- jpa/odata-jpa-processor-parallel/README.md | 8 +- jpa/odata-jpa-processor-parallel/pom.xml | 90 +- .../JPAODataBatchParallelRequestGroup.java | 7 +- .../JPAODataBatchSequentialRequestGroup.java | 3 +- .../JPAODataParallelBatchProcessor.java | 14 +- ...ParallelBatchProcessorIntegrationTest.java | 3 +- .../JPAODataParallelBatchProcessorTest.java | 4 +- .../test/util/IntegrationTestHelper.java | 30 +- .../test/util/JakartaRequestMapper.java | 380 +++++ .../test/util/JakartaResponseMapper.java | 200 +++ .../test/util/JakartaServletInputStream.java | 24 + .../test/util/JakartaServletOutputStream.java | 24 + .../.settings/org.eclipse.jdt.core.prefs | 6 +- ....eclipse.wst.common.project.facet.core.xml | 2 +- jpa/odata-jpa-processor/pom.xml | 26 +- .../api/JPAAbstractCUDRequestHandler.java | 2 +- .../core/api/JPACUDRequestHandler.java | 5 +- .../core/api/JPAODataBatchProcessor.java | 8 +- .../JPAODataDefaultTransactionFactory.java | 7 +- .../api/JPAODataExternalRequestContext.java | 3 +- .../jpa/processor/core/api/JPAODataPage.java | 31 +- .../core/api/JPAODataPagingProvider.java | 4 +- .../core/api/JPAODataRequestContext.java | 2 +- .../api/JPAODataRequestContextAccess.java | 3 +- .../core/api/JPAODataRequestHandler.java | 15 +- .../core/api/JPAODataRequestProcessor.java | 20 +- .../core/api/JPAODataServiceContext.java | 7 +- .../api/JPAODataSessionContextAccess.java | 2 +- .../core/api/JPAODataTransactionFactory.java | 23 +- .../example/JPAExampleCUDRequestHandler.java | 22 +- .../api/example/JPAExamplePagingProvider.java | 20 +- .../core/api/mapper/JakartaRequestMapper.java | 395 +++++ .../api/mapper/JakartaResponseMapper.java | 211 +++ .../api/mapper/JakartaServletInputStream.java | 24 + .../mapper/JakartaServletOutputStream.java | 24 + .../core/converter/JPAExpandResult.java | 3 +- .../JPAStructuredResultConverter.java | 2 +- .../processor/core/converter/JPATuple.java | 22 +- .../converter/JPATupleChildConverter.java | 22 +- .../JPATupleCollectionConverter.java | 6 +- .../converter/JPATupleResultConverter.java | 7 +- .../JPAAbstractDatabaseProcessor.java | 4 +- .../database/JPADefaultDatabaseProcessor.java | 12 +- .../database/JPAODataDatabaseOperations.java | 4 +- .../core/database/JPAODataDatabaseSearch.java | 14 +- .../JPAODataDatabaseTableFunction.java | 2 +- .../database/JPA_DERBY_DatabaseProcessor.java | 10 +- .../JPA_HSQLDB_DatabaseProcessor.java | 10 +- .../JPA_POSTSQL_DatabaseProcessor.java | 12 +- .../exception/ODataJPAQueryException.java | 1 + .../filter/JPAAggregationOperationImp.java | 4 +- .../core/filter/JPAArithmeticOperator.java | 4 +- .../core/filter/JPAArithmeticOperatorImp.java | 24 +- .../core/filter/JPABooleanOperator.java | 2 +- .../core/filter/JPABooleanOperatorImp.java | 10 +- .../core/filter/JPAComparisonOperator.java | 2 +- .../core/filter/JPAComparisonOperatorImp.java | 2 +- .../core/filter/JPADBFunctionOperator.java | 13 +- .../core/filter/JPAExistsOperation.java | 18 +- .../processor/core/filter/JPAExpression.java | 2 +- .../core/filter/JPAExpressionVisitor.java | 2 +- .../core/filter/JPAFilterComplier.java | 2 +- .../core/filter/JPAFilterComplierAccess.java | 4 +- .../core/filter/JPAFilterCrossComplier.java | 8 +- .../core/filter/JPAFilterElementComplier.java | 8 +- .../filter/JPAFilterRestrictionsWatchDog.java | 2 +- .../core/filter/JPAJavaFunctionOperator.java | 2 +- .../core/filter/JPALambdaAllOperation.java | 6 +- .../core/filter/JPALambdaOperation.java | 2 +- .../core/filter/JPALiteralOperator.java | 12 +- .../core/filter/JPAMemberOperator.java | 12 +- .../core/filter/JPAMethodBasedExpression.java | 6 +- .../core/filter/JPAMethodCallImp.java | 18 +- .../core/filter/JPANavigationOperation.java | 23 +- .../core/filter/JPAOperationConverter.java | 35 +- .../core/filter/JPAUnaryBooleanOperator.java | 2 +- .../filter/JPAUnaryBooleanOperatorImp.java | 2 +- .../jpa/processor/core/filter/JPAVisitor.java | 36 +- .../core/filter/ODataJPAQueryContext.java | 4 +- .../core/helper/AbstractWatchDog.java | 4 +- .../core/modify/JPAConversionHelper.java | 21 +- .../core/modify/JPACreateResult.java | 39 +- .../core/modify/JPAEntityBasedResult.java | 2 +- .../modify/JPAEntityCollectionResult.java | 6 +- .../modify/JPAEntityNavigationLinkResult.java | 11 +- .../core/modify/JPAEntityResult.java | 14 +- .../core/modify/JPAMapBaseResult.java | 10 +- .../core/modify/JPAMapCollectionResult.java | 7 +- .../modify/JPAMapNavigationLinkResult.java | 12 +- .../processor/core/modify/JPAMapResult.java | 14 +- .../core/modify/JPAUpdateResult.java | 18 +- .../JPAAbstractRequestProcessor.java | 4 +- .../processor/JPAActionRequestProcessor.java | 5 +- .../processor/JPACUDRequestProcessor.java | 34 +- .../core/processor/JPACoreDebugger.java | 2 +- .../core/processor/JPAExpandWatchDog.java | 2 +- .../core/processor/JPAHookFactory.java | 3 +- .../processor/JPAJavaFunctionProcessor.java | 5 +- .../core/processor/JPAModifyUtil.java | 32 +- .../JPANavigationRequestProcessor.java | 16 +- .../JPAODataInternalRequestContext.java | 17 +- .../JPAOperationRequestProcessor.java | 14 +- .../core/processor/JPAProcessorFactory.java | 15 +- .../core/processor/JPARequestProcessor.java | 4 +- .../core/query/ComparableByteArray.java | 15 +- ...essionUtil.java => ExpressionUtility.java} | 20 +- .../core/query/JPAAbstractExpandQuery.java | 16 +- .../core/query/JPAAbstractJoinQuery.java | 70 +- .../core/query/JPAAbstractQuery.java | 169 +- .../core/query/JPAAbstractSubQuery.java | 23 +- .../core/query/JPACollectionFilterQuery.java | 11 +- .../core/query/JPACollectionJoinQuery.java | 47 +- .../core/query/JPACollectionQueryResult.java | 2 +- .../core/query/JPACountWatchDog.java | 8 +- .../core/query/JPAExpandFilterQuery.java | 93 +- .../core/query/JPAExpandItemInfoFactory.java | 40 +- .../core/query/JPAExpandJoinCountQuery.java | 39 +- .../core/query/JPAExpandJoinQuery.java | 46 +- .../core/query/JPAExpandQueryFactory.java | 2 +- .../core/query/JPAExpandQueryResult.java | 5 +- .../core/query/JPAExpandSubCountQuery.java | 51 +- .../core/query/JPAExpandSubQuery.java | 103 +- .../processor/core/query/JPAJoinQuery.java | 27 +- .../jpa/processor/core/query/JPAKeyPair.java | 2 +- .../core/query/JPANavigationCountQuery.java | 8 +- .../core/query/JPANavigationFilterQuery.java | 11 +- .../JPANavigationFilterQueryBuilder.java | 18 +- .../core/query/JPANavigationNullQuery.java | 8 +- .../core/query/JPANavigationPropertyInfo.java | 40 +- .../core/query/JPANavigationSubQuery.java | 10 +- .../core/query/JPAOrderByBuilder.java | 36 +- .../core/query/JPAOrderByBuilderWatchDog.java | 3 +- .../core/query/JPAQueryCreationResult.java | 21 +- .../processor/core/query/JPAQueryPair.java | 17 +- .../core/query/JPARowNumberFilterQuery.java | 24 +- .../jpa/processor/core/query/Utility.java | 167 +- .../serializer/JPAPrimitivePropertyInfo.java | 19 +- .../core/serializer/JPASerializeFunction.java | 6 +- .../serializer/JPASerializePrimitive.java | 6 +- .../JPASerializePrimitiveAbstract.java | 4 +- .../core/serializer/JPASerializeValue.java | 10 +- .../core/serializer/JPASerializerFactory.java | 11 +- .../processor-exceptions-i18n.properties | 10 +- .../core/api/JPAODataBatchProcessorTest.java | 36 +- ...JPAODataDefaultTransactionFactoryTest.java | 4 +- .../JPAODataExternalRequestContextTest.java | 12 +- .../core/api/JPAODataRequestHandlerTest.java | 45 +- .../api/JPAODataRequestProcessorTest.java | 6 +- .../JPAODataServiceContextBuilderTest.java | 2 +- .../JPAExampleCUDRequestHandlerTest.java | 52 +- .../example/JPAExamplePagingProviderTest.java | 124 +- .../api/mapper/JakartaRequestMapperTest.java | 491 ++++++ .../api/mapper/JakartaResponseMapperTest.java | 292 ++++ .../JPADefaultDatabaseProcessorTest.java | 34 +- .../JPA_DERBY_DatabaseProcessorTest.java | 6 +- .../JPA_HSQLDB_DatabaseProcessorTest.java | 6 +- .../JPA_POSTSQL_DatabaseProcessorTest.java | 6 +- .../JPA_XXX_DatabaseProcessorTest.java | 4 +- .../filter/JPADBFunctionOperatorTest.java | 4 +- .../JPAFilterRestrictionsWatchDogTest.java | 2 +- .../filter/JPAJavaFunctionOperatorTest.java | 4 +- .../processor/core/filter/JPAVisitorTest.java | 9 +- .../core/filter/ODataJPAQueryContextTest.java | 4 +- .../filter/TestJPAArithmeticOperator.java | 6 +- .../filter/TestJPACustomScalarFunctions.java | 9 +- .../filter/TestJPAOperationConverter.java | 6 +- .../core/filter/TestJavaFunctions.java | 3 +- .../core/modify/TestJPACUDRequestHelper.java | 2 +- .../core/modify/TestJPACreateResult.java | 4 +- .../JPAActionRequestProcessorTest.java | 4 +- .../core/processor/JPAClearProcessorTest.java | 14 +- .../core/processor/JPACoreDebuggerTest.java | 8 +- .../processor/JPADebugSupportWrapperTest.java | 2 +- .../core/processor/JPAEmptyDebuggerTest.java | 4 +- .../JPAFunctionRequestProcessorTest.java | 4 +- .../core/processor/JPAHookFactoryTest.java | 8 +- .../JPAJavaFunctionProcessorTest.java | 2 +- .../JPAODataInternalRequestContextTest.java | 5 +- .../JPAODataRequestContextBuilderTest.java | 2 +- .../processor/TestCreateRequestEntity.java | 7 +- .../processor/TestJPACreateProcessor.java | 2 +- .../processor/TestJPADeleteProcessor.java | 2 +- .../processor/TestJPAModifyProcessor.java | 7 +- .../TestJPAODataRequestContextImpl.java | 2 +- .../processor/TestJPAUpdateProcessor.java | 6 +- .../core/query/JPAAbstractQueryTest.java | 106 ++ .../query/JPAExpandJoinCountQueryTest.java | 4 +- .../core/query/JPAExpandJoinQueryTest.java | 4 +- .../core/query/JPAExpandQueryResultTest.java | 2 +- .../query/JPAExpandSubCountQueryTest.java | 2 +- .../core/query/JPAJoinQueryTest.java | 10 +- .../processor/core/query/JPAKeyPairTest.java | 2 +- .../query/JPANavigationCountQueryTest.java | 20 +- .../JPANavigationFilterQueryBuilderTest.java | 14 +- .../query/JPANavigationFilterQueryTest.java | 21 +- .../query/JPANavigationNullQueryTest.java | 21 +- .../query/JPAOrderByBuilderWatchDogTest.java | 4 +- .../query/TestJPAExpandQueryCreateResult.java | 4 +- .../processor/core/query/TestJPAFunction.java | 13 +- .../core/query/TestJPAFunctionDB.java | 2 +- .../core/query/TestJPAFunctionJava.java | 9 +- .../core/query/TestJPAFunctionSerializer.java | 7 +- .../core/query/TestJPAOrderByBuilder.java | 24 +- .../TestJPAQueryBuildSelectionPathList.java | 2 +- .../core/query/TestJPAQueryFromClause.java | 12 +- .../core/query/TestJPAQueryPair.java | 4 +- .../core/query/TestJPAQuerySelectClause.java | 6 +- .../TestJPAQuerySelectWithGroupClause.java | 2 +- .../query/TestJPAQueryWithProtection.java | 10 +- .../core/query/TestJPAServerDrivenPaging.java | 13 +- .../query/TestJPATupleChildConverter.java | 2 +- ...TestJPATupleChildConverterCompoundKey.java | 2 +- .../ClassWithIdClassConstructor.java | 2 +- .../core/testobjects/FileAccessConverter.java | 8 +- .../testobjects/OrganizationWithAudit.java | 4 +- .../TestFunctionActionConstructor.java | 2 +- .../testobjects/TestFunctionForFilter.java | 4 +- .../testobjects/TestFunctionParameter.java | 2 +- .../core/testobjects/TestJavaActions.java | 20 +- ...eeParameterTransientPropertyConverter.java | 2 +- ...woParameterTransientPropertyConverter.java | 2 +- .../core/util/AbstractWatchDogTest.java | 3 +- .../core/util/IntegrationTestHelper.java | 29 +- .../jpa/processor/core/util/TestBase.java | 9 +- .../processor/core/util/TestGroupBase.java | 11 +- .../jpa/processor/core/util/TestHelper.java | 30 +- .../processor/core/util/TestQueryBase.java | 11 +- .../jpa/processor/core/util/TupleDouble.java | 20 +- .../core/util/TupleElementDouble.java | 4 +- jpa/odata-jpa-spring-support/pom.xml | 2 +- .../.settings/org.eclipse.jdt.core.prefs | 9 +- ....eclipse.wst.common.project.facet.core.xml | 4 +- jpa/odata-jpa-test/pom.xml | 25 +- .../errormodel/AdministrativeInformation.java | 12 +- .../core/errormodel/ChangeInformation.java | 8 +- .../CollectionAttributeProtected.java | 18 +- .../errormodel/ComplexProtectedNoPath.java | 22 +- .../errormodel/ComplexProtectedWrongPath.java | 22 +- .../core/errormodel/CompoundKey.java | 4 +- .../errormodel/DummyPropertyCalculator.java | 12 +- .../errormodel/EmbeddedKeyPartOfGroup.java | 10 +- .../core/errormodel/KeyPartOfGroup.java | 8 +- .../core/errormodel/MandatoryPartOfGroup.java | 18 +- .../MissingCardinalityAnnotation.java | 11 +- .../NavigationAttributeProtected.java | 18 +- .../NavigationPropertyPartOfGroup.java | 16 +- .../PersonDeepCollectionProtected.java | 16 +- .../core/errormodel/SingletonAsEntitySet.java | 21 - .../jpa/processor/core/errormodel/Team.java | 10 +- ...thTransientCalculatorConstructorError.java | 8 +- .../TeamWithTransientCalculatorError.java | 8 +- .../TeamWithTransientEmbeddableKey.java | 6 +- .../errormodel/TeamWithTransientError.java | 8 +- .../core/errormodel/TeamWithTransientKey.java | 12 +- ...ientPropertyCalculatorTwoConstructors.java | 6 +- ...entPropertyCalculatorWrongConstructor.java | 4 +- .../core/testmodel/AbstractGroup.java | 6 +- .../core/testmodel/AccessRightsConverter.java | 4 +- .../core/testmodel/AddressDeepProtected.java | 6 +- .../AddressDeepThreeProtections.java | 6 +- .../testmodel/AdministrativeDivision.java | 28 +- .../AdministrativeDivisionDescription.java | 12 +- .../AdministrativeDivisionDescriptionKey.java | 18 +- .../testmodel/AdministrativeDivisionKey.java | 16 +- .../testmodel/AdministrativeInformation.java | 16 +- .../core/testmodel/AnnotationsParent.java | 22 +- .../core/testmodel/AnnotationsSingleton.java | 18 +- .../testmodel/AssociationOneToManySource.java | 12 +- .../testmodel/AssociationOneToManyTarget.java | 12 +- .../testmodel/AssociationOneToOneSource.java | 14 +- .../testmodel/AssociationOneToOneTarget.java | 12 +- .../core/testmodel/BestOrganization.java | 11 +- .../core/testmodel/BusinessPartner.java | 30 +- .../testmodel/BusinessPartnerProtected.java | 26 +- .../core/testmodel/BusinessPartnerRole.java | 24 +- .../testmodel/BusinessPartnerRoleKey.java | 12 +- .../BusinessPartnerRoleProtected.java | 22 +- .../BusinessPartnerRoleWithGroup.java | 22 +- .../testmodel/BusinessPartnerWithGroups.java | 34 +- .../core/testmodel/ByteConverter.java | 8 +- .../core/testmodel/ChangeInformation.java | 14 +- .../processor/core/testmodel/Collection.java | 20 +- .../core/testmodel/CollectionDeep.java | 18 +- .../CollectionFirstLevelComplex.java | 14 +- .../testmodel/CollectionInnerComplex.java | 6 +- .../testmodel/CollectionNestedComplex.java | 6 +- .../CollectionNestedComplexWithTransient.java | 8 +- .../testmodel/CollectionPartOfComplex.java | 14 +- .../CollectionSecondLevelComplex.java | 14 +- .../testmodel/CollectionWithTransient.java | 32 +- .../jpa/processor/core/testmodel/Comment.java | 14 +- .../core/testmodel/CommunicationData.java | 12 +- .../core/testmodel/ComplexBaseType.java | 4 +- .../core/testmodel/ComplexSubType.java | 4 +- ...ComplexWithTransientComplexCollection.java | 10 +- .../jpa/processor/core/testmodel/Country.java | 10 +- .../processor/core/testmodel/CountryKey.java | 14 +- .../core/testmodel/CountryRestriction.java | 14 +- .../processor/core/testmodel/CurrentUser.java | 6 +- .../testmodel/CurrentUserQueryExtension.java | 8 +- .../core/testmodel/DateConverter.java | 10 +- .../core/testmodel/DateTimeConverter.java | 8 +- .../core/testmodel/DateTimeTest.java | 14 +- .../core/testmodel/DeepProtectedExample.java | 14 +- .../core/testmodel/DetailSettings.java | 6 +- .../core/testmodel/DummyEmbeddedToIgnore.java | 10 +- .../core/testmodel/DummyToBeIgnored.java | 18 +- .../EmptyQueryExtensionProvider.java | 8 +- .../core/testmodel/EntityTypeOnly.java | 16 +- .../core/testmodel/FullNameCalculator.java | 6 +- .../jpa/processor/core/testmodel/Group.java | 14 +- .../core/testmodel/GroupNameCalculator.java | 4 +- .../processor/core/testmodel/ImageLoader.java | 39 +- .../core/testmodel/InhouseAddress.java | 12 +- .../core/testmodel/InhouseAddressTable.java | 8 +- .../testmodel/InhouseAddressWithGroup.java | 12 +- .../InhouseAddressWithProtection.java | 4 +- .../InhouseAddressWithThreeProtections.java | 4 +- .../testmodel/InstanceRestrictionKey.java | 4 +- .../processor/core/testmodel/JoinComplex.java | 10 +- .../testmodel/JoinPartnerRoleRelation.java | 6 +- .../testmodel/JoinPartnerRoleRelationKey.java | 6 +- .../core/testmodel/JoinRelation.java | 6 +- .../core/testmodel/JoinRelationKey.java | 14 +- .../processor/core/testmodel/JoinSource.java | 16 +- .../processor/core/testmodel/JoinTarget.java | 14 +- .../processor/core/testmodel/LauFilter.java | 6 +- .../testmodel/LocalDateTimeConverter.java | 4 +- .../core/testmodel/LogarithmCalculator.java | 6 +- .../processor/core/testmodel/Membership.java | 10 +- .../core/testmodel/MembershipKey.java | 10 +- .../core/testmodel/Organization.java | 28 +- .../core/testmodel/OrganizationImage.java | 10 +- .../jpa/processor/core/testmodel/Person.java | 28 +- .../core/testmodel/PersonDeepProtected.java | 20 +- .../testmodel/PersonDeepProtectedHidden.java | 10 +- .../processor/core/testmodel/PersonImage.java | 10 +- .../core/testmodel/PostalAddressData.java | 42 +- .../testmodel/PostalAddressDataWithGroup.java | 40 +- .../processor/core/testmodel/SalesTeam.java | 8 +- .../processor/core/testmodel/Singleton.java | 14 +- .../testmodel/StreetPropertyCalculator.java | 6 +- .../core/testmodel/StringConverter.java | 8 +- .../core/testmodel/SupportRelationship.java | 8 +- .../jpa/processor/core/testmodel/Team.java | 10 +- .../testmodel/TemporalWithValidityPeriod.java | 10 +- .../TemporalWithValidityPeriodKey.java | 4 +- .../core/testmodel/TestDataConstants.java | 16 - .../core/testmodel/TransientRefComplex.java | 12 +- .../core/testmodel/TransientRefIgnore.java | 10 +- .../core/testmodel/UUIDToBinaryConverter.java | 18 +- .../core/testmodel/UUIDToStringConverter.java | 4 +- .../jpa/processor/core/testmodel/User.java | 8 +- .../core/util/ServletInputStreamDouble.java | 20 +- .../main/resources/META-INF/persistence.xml | 10 +- .../processor/test/AbstractConverterTest.java | 2 +- .../jpa/processor/test/TestAssociations.java | 18 +- .../processor/test/TestCriteriaBuilder.java | 34 +- .../test/TestEqualHashCodeMethods.java | 10 +- .../TestEqualHashCodeMethodsErrorModel.java | 9 +- .../TestEqualHashCodeMethodsTestModel.java | 7 +- .../jpa/processor/test/TestFunctions.java | 27 +- .../processor/test/TestFunctionsHSQLDB.java | 23 +- ...PropertyCalculatorTwoConstructorsTest.java | 2 +- ...ropertyCalculatorWrongConstructorTest.java | 2 +- jpa/odata-jpa-vocabularies/pom.xml | 8 +- .../core/edm/mapper/vocabularies/Action.java | 86 +- .../vocabularies/CsdlDocumentReader.java | 176 +- .../mapper/vocabularies/EdmxReference.java | 58 +- .../vocabularies/EdmxReferenceInclude.java | 50 +- .../edm/mapper/vocabularies/Function.java | 106 +- .../edm/mapper/vocabularies/Parameter.java | 124 +- .../edm/mapper/vocabularies/ReturnType.java | 112 +- .../edm/mapper/vocabularies/TermTest.java | 232 +-- .../vocabularies/TestAnnotationSchema.java | 774 ++++----- .../vocabularies/TestCsdlDocumentReader.java | 206 +-- jpa/pom.xml | 21 +- 579 files changed, 7876 insertions(+), 6458 deletions(-) delete mode 100644 jpa-archetype/odata-jpa-archetype-spring-scp/pom.xml delete mode 100644 jpa-archetype/odata-jpa-archetype-spring-scp/src/main/resources/META-INF/maven/archetype-metadata.xml delete mode 100644 jpa-archetype/odata-jpa-archetype-spring-scp/src/main/resources/archetype-resources/pom.xml delete mode 100644 jpa-archetype/odata-jpa-archetype-spring-scp/src/main/resources/archetype-resources/security/xs-security.json delete mode 100644 jpa-archetype/odata-jpa-archetype-spring-scp/src/main/resources/archetype-resources/src/main/java/SpringApp.java delete mode 100644 jpa-archetype/odata-jpa-archetype-spring-scp/src/main/resources/archetype-resources/src/main/java/config/EclipseLinkJpaConfiguration.java delete mode 100644 jpa-archetype/odata-jpa-archetype-spring-scp/src/main/resources/archetype-resources/src/main/java/config/ProcessorConfiguration.java delete mode 100644 jpa-archetype/odata-jpa-archetype-spring-scp/src/main/resources/archetype-resources/src/main/java/controller/ODataController.java delete mode 100644 jpa-archetype/odata-jpa-archetype-spring-scp/src/main/resources/archetype-resources/src/main/java/model/EntityTemplate.java delete mode 100644 jpa-archetype/odata-jpa-archetype-spring-scp/src/main/resources/archetype-resources/src/main/java/model/ValueObjectTemplate.java delete mode 100644 jpa-archetype/odata-jpa-archetype-spring-scp/src/main/resources/archetype-resources/src/main/java/model/ValueObjectTemplateKey.java delete mode 100644 jpa-archetype/odata-jpa-archetype-spring-scp/src/main/resources/archetype-resources/src/main/resources/application-test.yml delete mode 100644 jpa-archetype/odata-jpa-archetype-spring-scp/src/main/resources/archetype-resources/src/main/resources/application.yml delete mode 100644 jpa-archetype/odata-jpa-archetype-spring-scp/src/main/resources/archetype-resources/src/main/resources/db/migration/V1_0__jpa.sql delete mode 100644 jpa-archetype/odata-jpa-archetype-spring-scp/src/main/resources/archetype-resources/src/test/java/AppTest.java delete mode 100644 jpa-archetype/odata-jpa-archetype-spring-scp/src/main/resources/archetype-resources/src/test/java/integrationtest/ControllerTest.java delete mode 100644 jpa-archetype/odata-jpa-archetype-spring-scp/src/main/resources/archetype-resources/src/test/resources/requests/CreateEntityViaBatch.txt delete mode 100644 jpa/odata-jpa-annotation/src/main/java/com/sap/olingo/jpa/metadata/core/edm/annotation/EdmAsEntitySet.java delete mode 100644 jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/reuse/OffsetDateTimeConverter.java create mode 100644 jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateOperationHelperTest.java create mode 100644 jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/testobjects/TestActionCollection.java create mode 100644 jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/testobjects/TestCollectionInterface.java create mode 100644 jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/SubqueryRootImplTest.java create mode 100644 jpa/odata-jpa-processor-parallel/src/test/java/com/sap/olingo/jpa/processor/test/util/JakartaRequestMapper.java create mode 100644 jpa/odata-jpa-processor-parallel/src/test/java/com/sap/olingo/jpa/processor/test/util/JakartaResponseMapper.java create mode 100644 jpa/odata-jpa-processor-parallel/src/test/java/com/sap/olingo/jpa/processor/test/util/JakartaServletInputStream.java create mode 100644 jpa/odata-jpa-processor-parallel/src/test/java/com/sap/olingo/jpa/processor/test/util/JakartaServletOutputStream.java create mode 100644 jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/api/mapper/JakartaRequestMapper.java create mode 100644 jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/api/mapper/JakartaResponseMapper.java create mode 100644 jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/api/mapper/JakartaServletInputStream.java create mode 100644 jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/api/mapper/JakartaServletOutputStream.java rename jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/{ExpressionUtil.java => ExpressionUtility.java} (91%) create mode 100644 jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/api/mapper/JakartaRequestMapperTest.java create mode 100644 jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/api/mapper/JakartaResponseMapperTest.java create mode 100644 jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/JPAAbstractQueryTest.java delete mode 100644 jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/errormodel/SingletonAsEntitySet.java delete mode 100644 jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/TestDataConstants.java diff --git a/.github/workflows/archetype.yml b/.github/workflows/archetype.yml index cfb5b2f00..b8e147a3d 100644 --- a/.github/workflows/archetype.yml +++ b/.github/workflows/archetype.yml @@ -20,5 +20,7 @@ jobs: java-version: ${{ matrix.java-version }} distribution: 'temurin' cache: maven - - name: Build with Maven + - name: 1. Build JPA + run: cd ./jpa && mvn clean -Dmaven.test.skip + - name: 2. Build and test archetype run: cd ./jpa-archetype && mvn clean install archetype:integration-test diff --git a/LICENSE.txt b/LICENSE.txt index f6b599de5..826b70214 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -187,7 +187,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright 2016-2021 SAP SE or an SAP affiliate company and olingo-jpa-processor-v4 contributors + Copyright 2016-2023 SAP SE or an SAP affiliate company and olingo-jpa-processor-v4 contributors Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/README.md b/README.md index c3f5a529c..fd0b6589f 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ [![GitHub release](https://img.shields.io/github/release-pre/sap/olingo-jpa-processor-v4.svg?color=orange&label=release)](https://github.com/SAP/olingo-jpa-processor-v4/releases/) [![Project Map](https://sourcespy.com/shield.svg)](https://sourcespy.com/github/sapolingojpaprocessorv4/) -The JPA Processor shall fill the gap between [Olingo V4](https://olingo.apache.org/doc/odata4/index.html) and the database if [JPA](https://en.wikipedia.org/wiki/Java_Persistence_API) is used for object-relational mapping. +The JPA Processor shall fill the gap between [Olingo V4](https://olingo.apache.org/doc/odata4/index.html) and the database, if [JPA](https://en.wikipedia.org/wiki/Java_Persistence_API) is used for object-relational mapping. If you want to be updated about Olingo changes subscribe to Olingo's [user mailing list](user-subscribe@olingo.apache.org). At the current state the JPA Processor provide support for: @@ -22,10 +22,22 @@ The tutorials from the previous major version is still available under: [Tutoria ## Requirements -The JPA Processor requires, minimum Java version [1.8](http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html). The current version comes with [Olingo 4.9.0](https://github.com/apache/olingo-odata4). If you want to be updated about Olingo changes subscribe to Olingo's [user mailing list](user-subscribe@olingo.apache.org). +As of now, the JPA Processor has two major versions 1.1.x and 2.x.x. + +### 1.1.x + +The JPA Processor requires, minimum Java version [1.8](http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html). The current version comes with [Olingo 4.9.0](https://github.com/apache/olingo-odata4). Even so no JPA implementation is preferred, as long as it supports [JSR-338 Java Persistence 2.2](https://jcp.org/en/jsr/detail?id=338), it has to be stated that all test have been performed with [Eclipselink 2.7.9](http://www.eclipse.org/eclipselink/). If you have any problem e.g. with [Hibernate](http://hibernate.org) or [OpenJPA](https://openjpa.apache.org/), create an [issue](https://github.com/SAP/olingo-jpa-processor-v4/issues), but there is no guaranty that it can be solved, as e.g. Hibernate implements some JPA interfaces "differently" than EclipseLink. +There is no father development for this major version. + +### 2.x.x + +The current version is based on [Jakarta 10](https://projects.eclipse.org/releases/jakarta-10), so [JPA 3.1.0](https://projects.eclipse.org/projects/ee4j.jpa/releases/3.1) or [Jakarta Persistence Specification](https://github.com/jakartaee/persistence), receptively and [Jakarta Servlet 6.0](https://projects.eclipse.org/projects/ee4j.servlet/releases/6.0). Test are performed using [Eclipselink 4.0.2](https://projects.eclipse.org/projects/ee4j.eclipselink/releases/4.0.2), but there is no real dependency to a JPA implementation. This versions require Java [17](https://sap.github.io/SapMachine/#download). + +The current version comes with [Olingo 4.9.0](https://github.com/apache/olingo-odata4), which does not support Jakarta. Till Olingo supports Jakarta, requests get mapped by the JPA Processor. + ## Download and Installation The JPA Processor is a collection of [Maven](https://maven.apache.org) projects. To use it you need to @@ -35,7 +47,7 @@ clone the repository, import the projects and declare a dependency to either the com.sap.olingo odata-jpa-metadata - 1.1.1 + 2.0.0 ``` @@ -45,7 +57,7 @@ Or to the complete processor: com.sap.olingo odata-jpa-processor - 1.1.1 + 2.0.0 ``` @@ -53,7 +65,6 @@ Or to the complete processor: The core of this project became stable. Some of the addons are still in the state of incubation, so some incompatible changes my come up. Nevertheless feel free to use the JPA processor and the addons where ever it helps. - ## Contributing If you want to report a bug or have suggestions to improve the JPA Processor, read up on our [guidelines for contributing](./CONTRIBUTING.md) to learn about our submission process, coding rules and more. @@ -64,6 +75,7 @@ We'd love all and any contributions. The flowing extensions/changes are planned: +* Support of method call at $orderby * Tenant depended metadata * Enable hooks for retrieving data * Support of $ref @@ -82,24 +94,8 @@ Detailed information including third-party components and their licensing/copyri |Version|Changes|Incompatible Changes| |-- |-- |-- | -|0.2.4|- Switch to Olingo version 4.4.0
- Support of Enumeration Types
- Support of $count at $expand|Yes| -|0.2.6|- Solution for issue [#21](https://github.com/SAP/olingo-jpa-processor-v4/issues/21)
- JPA Join tables can be used e.g. for Many To Many relationship (issue [#22](https://github.com/SAP/olingo-jpa-processor-v4/issues/22)). If such relation shall be used in a filter a corresponding JPA entity is required, which can be hidden from the API using @EdmIgnore. Please be aware that in case both source and target are subtypes Eclipselink (version 2.7.1 used) may get confused when generating a subquery for filtering, see [Bug 529565](https://bugs.eclipse.org/bugs/show_bug.cgi?id=529565) | No| -|0.2.7|- Solution for issue [#29](https://github.com/SAP/olingo-jpa-processor-v4/issues/29)
- Solution for issue [#35](https://github.com/SAP/olingo-jpa-processor-v4/issues/35)
- Solution for issue [#37](https://github.com/SAP/olingo-jpa-processor-v4/issues/37)
|No| -|0.2.8|- Support of Collection Properties
- New tutorials 1.7 Suppressing Elements and 1.13 Collection Properties |No| -|0.2.9|- Support on top level server driven paging
- New tutorial 4.3 Server Driven Paging |No| -|0.2.10|- Handling of Content-Id in batch requests
- Update to Olingo 4.5.0
- Update tutorial 1.6, 3.3, 3.5 and 3.6 |No| -|0.3.1|- Support of instance based authorizations
- Solution for issue [#60](https://github.com/SAP/olingo-jpa-processor-v4/issues/60)
- Solution for issue [#49](https://github.com/SAP/olingo-jpa-processor-v4/issues/49)
- Correct typo in interface JPAODataPagingProvider
- New tutorials 2.3, 4.4 |Yes| -|0.3.2|- Lift unit tests to JUnit 5
- Correction of http return codes on empty responses |No| -|0.3.3|- Support of PUT requests on collection properties and simple primitive properties
- Update to Olingo 4.6.0
- Solution for issue [#69](https://github.com/SAP/olingo-jpa-processor-v4/issues/69)
- Solution for issue [#71](https://github.com/SAP/olingo-jpa-processor-v4/issues/71)
- Update tutorial [4.4](jpa-tutorial/Tutorials/SpecialTopics/4-4-InstanceBasedAuthorizations.md)|No -|0.3.4|- Support of $select as part of $expand
- Support of field groups
- Introduction of a request context, which includes deprecation of methods
- Etag now written into response e.g. @odata.etag when JSON was requested
- Solution for issue [#78](https://github.com/SAP/olingo-jpa-processor-v4/issues/78)
- Updated tutorials: [2.2](jpa-tutorial/Tutorials/RetrieveData/2-2-RetrievingData.md), [2.3](jpa-tutorial/Tutorials/RetrieveData/2-3-UsingFunctions.md), [3.1](jpa-tutorial/Tutorials/ChangeData/3-1-Preparation.md), [3.2](jpa-tutorial/Tutorials/ChangeData/3-2-CreatingEntities.md), [4.4](jpa-tutorial/Tutorials/SpecialTopics/4-4-InstanceBasedAuthorizations.md) |Yes| -|0.3.5|- Extension of session context, so an entity manager factory can be provided. This will allow creating Spring based services without `persistence.xml` file
- Solution for issue [#85](https://github.com/SAP/olingo-jpa-processor-v4/issues/85)
- Usage of Olingo JSON deserializer for CUD requests
- Extension of session context, so an own Edm Name Builder can be provided|Yes| -|0.3.6|- Enable more flexible transaction handling
- Part solution for issue [#83](https://github.com/SAP/olingo-jpa-processor-v4/issues/83)
- Increase support of Spring by performing request mapping in case a mapping path is provided via the service context|No| -|0.3.7| - Update Olingo dependency to 4.7.0|No| -|0.3.8| - Update Olingo dependency to 4.7.1
- Support of `java.time` data types. Prerequisite is the usage of JPA 2.2.
- Support of Absolute Context URL. See issue [#103](https://github.com/SAP/olingo-jpa-processor-v4/issues/103)
- Temporal data types do not longer require a Precision [#98](https://github.com/SAP/olingo-jpa-processor-v4/issues/98)
Support of MappedSuperclass|No| -|0.3.9| - Solutions for issue [#112](https://github.com/SAP/olingo-jpa-processor-v4/issues/112)
- Solutions for issue [#114](https://github.com/SAP/olingo-jpa-processor-v4/issues/114)|No| -|0.3.10| - Update Olingo dependency to 4.8.0
- Deprecation of ```setExternalName``` in ```IntermediateModelItemAccess```
- Solutions for issue [#134](https://github.com/SAP/olingo-jpa-processor-v4/issues/136)
- Solution for issue [#136](https://github.com/SAP/olingo-jpa-processor-v4/issues/136) |No| -|0.3.11| - Solutions for issue [#138](https://github.com/SAP/olingo-jpa-processor-v4/issues/138)|No| |1.0.6|- Transient Properties
- Singletons
- Entity Types without Entity Set
- Rework Request Context
- Deprecation of annotation EdmAsEntitySet |Yes| |1.0.8|- Solution for issue [#145](https://github.com/SAP/olingo-jpa-processor-v4/issues/145) |No| |1.0.9|- Update Olingo dependency to 4.9.0
- Solutions for issues [#164](https://github.com/SAP/olingo-jpa-processor-v4/issues/164), [#155](https://github.com/SAP/olingo-jpa-processor-v4/issues/155), [#191](https://github.com/SAP/olingo-jpa-processor-v4/issues/191), [#156](https://github.com/SAP/olingo-jpa-processor-v4/issues/156)
|No| -|1.1.1|- Enable action overload
- Basic support of OData annotations
- Solution of issues [#207](https://github.com/SAP/olingo-jpa-processor-v4/issues/207), [#211](https://github.com/SAP/olingo-jpa-processor-v4/issues/211), [#212](https://github.com/SAP/olingo-jpa-processor-v4/issues/212), [#213](https://github.com/SAP/olingo-jpa-processor-v4/issues/213), [#214](https://github.com/SAP/olingo-jpa-processor-v4/issues/214),[#218](https://github.com/SAP/olingo-jpa-processor-v4/issues/218)|No| \ No newline at end of file +|1.1.1|- Enable action overload
- Basic support of OData annotations
- Solution of issues [#207](https://github.com/SAP/olingo-jpa-processor-v4/issues/207), [#211](https://github.com/SAP/olingo-jpa-processor-v4/issues/211), [#212](https://github.com/SAP/olingo-jpa-processor-v4/issues/212), [#213](https://github.com/SAP/olingo-jpa-processor-v4/issues/213), [#214](https://github.com/SAP/olingo-jpa-processor-v4/issues/214),[#218](https://github.com/SAP/olingo-jpa-processor-v4/issues/218)|No| +|2.0.0|- Minimum Java release now 17
- Switch to Jakarta Persistency
- Support of Spring Boot 3.x
- JPAEdmMetadataPostProcessor became an interface|Yes| diff --git a/additionalWords.directory b/additionalWords.directory index 61ff23737..4cb830223 100644 --- a/additionalWords.directory +++ b/additionalWords.directory @@ -1,6 +1,5 @@ Sortable Annotatable -Meassument Metadata serializer es @@ -49,3 +48,13 @@ apis SQL Visitable Rethrow +Unboxed +UUID +JSON +Impl +Servlet +Jakarta +CUD +JPAO +subquery + diff --git a/jpa-archetype/odata-jpa-archetype-spring-scp/pom.xml b/jpa-archetype/odata-jpa-archetype-spring-scp/pom.xml deleted file mode 100644 index 068c6d5e7..000000000 --- a/jpa-archetype/odata-jpa-archetype-spring-scp/pom.xml +++ /dev/null @@ -1,34 +0,0 @@ - - 4.0.0 - - com.sap.olingo - odata-jpa-archetype - 1.1.1 - - odata-jpa-archetype-spring-scp - odata-jpa-archetype - - - https://github.com/SAP/olingo-jpa-processor-v4 - maven-archetype - - - - - org.apache.maven.archetype - archetype-packaging - 3.1.1 - - - - - - org.apache.maven.plugins - maven-archetype-plugin - 3.2.1 - - - - - \ No newline at end of file diff --git a/jpa-archetype/odata-jpa-archetype-spring-scp/src/main/resources/META-INF/maven/archetype-metadata.xml b/jpa-archetype/odata-jpa-archetype-spring-scp/src/main/resources/META-INF/maven/archetype-metadata.xml deleted file mode 100644 index a55ac5309..000000000 --- a/jpa-archetype/odata-jpa-archetype-spring-scp/src/main/resources/META-INF/maven/archetype-metadata.xml +++ /dev/null @@ -1,50 +0,0 @@ - - - - src/main/java - - **/*.java - - - - src/test/java - - **/*.java - - - - src/main/resources - - **/*.sql - **/*.json - **/*.xml - **/*.properties - **/*.yml - - - - src/test/resources - - **/*.txt - - - - - - - - - EntityTemplate - - - ValueObjectTemplate - - - 9010 - - - diff --git a/jpa-archetype/odata-jpa-archetype-spring-scp/src/main/resources/archetype-resources/pom.xml b/jpa-archetype/odata-jpa-archetype-spring-scp/src/main/resources/archetype-resources/pom.xml deleted file mode 100644 index f0c84a57a..000000000 --- a/jpa-archetype/odata-jpa-archetype-spring-scp/src/main/resources/archetype-resources/pom.xml +++ /dev/null @@ -1,133 +0,0 @@ - - - 4.0.0 - ${groupId} - ${artifactId} - ${version} - jar - - - org.springframework.boot - spring-boot-starter-parent - 2.7.6 - - - - - 1.1.1 - 1.8 - 2.7.9 - 2.2.1 - - - - - org.springframework.boot - spring-boot-starter - - - org.springframework.boot - spring-boot-starter-test - test - - - junit - junit - - - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.boot - spring-boot-starter-data-jpa - - - org.hibernate - hibernate-entitymanager - - - org.hibernate - hibernate-core - - - - - org.eclipse.persistence - javax.persistence - ${jpa.version} - compile - - - org.eclipse.persistence - eclipselink - ${eclipselink.version} - - - com.sap.olingo - odata-jpa-processor - ${processor.version} - - - com.sap.olingo - odata-jpa-processor-cb - ${processor.version} - - - com.sap.olingo - odata-jpa-spring-support - ${processor.version} - - - org.springframework.boot - spring-boot-configuration-processor - true - - - org.flywaydb - flyway-core - 8.4.0 - - - com.h2database - h2 - 2.2.220 - runtime - - - org.springframework.boot - spring-boot-devtools - true - - - io.rest-assured - spring-mock-mvc - test - - - org.junit.jupiter - junit-jupiter - 5.4.2 - test - - - org.junit.platform - junit-platform-launcher - 1.4.2 - test - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - - diff --git a/jpa-archetype/odata-jpa-archetype-spring-scp/src/main/resources/archetype-resources/security/xs-security.json b/jpa-archetype/odata-jpa-archetype-spring-scp/src/main/resources/archetype-resources/security/xs-security.json deleted file mode 100644 index 382c88908..000000000 --- a/jpa-archetype/odata-jpa-archetype-spring-scp/src/main/resources/archetype-resources/security/xs-security.json +++ /dev/null @@ -1,69 +0,0 @@ -{ - "xsappname" : "${app-name}", - "description": "Enabled bulletinboard for multi tenants", - "tenant-mode": "shared", - "scopes" : [ - { - "name" : "$XSAPPNAME.Display", - "description" : "Display Business Partner Master" - }, - { - "name" : "$XSAPPNAME.Update", - "description" : "Update Business Partner Master" - } - ], - "attributes" : [ - { - "name": "id_range", - "description": "Range of business partner id", - "valueType" : "int", - "valueRequired" : true - - } - ], - "role-templates": [ - { - "name": "ViewerAll", - "description": "View all Business Partner Master", - "scope-references": [ - "$XSAPPNAME.Display" - ], - "attribute-references" : [ - { - "name" : "id_range", - "default-values" : ["*"] - } - ] - }, - { - "name": "MaintainAll", - "description": "Maintain Business Partner Master", - "scope-references": [ - "$XSAPPNAME.Display", - "$XSAPPNAME.Update" - ], - "attribute-references" : [ - { - "name" : "id_range", - "default-values" : ["*"] - } - ] - } - ], - "role-collections": [ - { - "name": "RC_ViewerAll", - "description": "Viewer (public)", - "role-template-references": [ - "$XSAPPNAME.ViewerAll" - ] - }, - { - "name": "RC_MaintainAll", - "description": "Business Partner (CRUD, no restriction)", - "role-template-references": [ - "$XSAPPNAME.MaintainAll" - ] - } - ] -} \ No newline at end of file diff --git a/jpa-archetype/odata-jpa-archetype-spring-scp/src/main/resources/archetype-resources/src/main/java/SpringApp.java b/jpa-archetype/odata-jpa-archetype-spring-scp/src/main/resources/archetype-resources/src/main/java/SpringApp.java deleted file mode 100644 index c704b151d..000000000 --- a/jpa-archetype/odata-jpa-archetype-spring-scp/src/main/resources/archetype-resources/src/main/java/SpringApp.java +++ /dev/null @@ -1,12 +0,0 @@ -package $package; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -@SpringBootApplication -public class SpringApp { - - public static void main(String[] args) { - SpringApplication.run(SpringApp.class, args); - } -} diff --git a/jpa-archetype/odata-jpa-archetype-spring-scp/src/main/resources/archetype-resources/src/main/java/config/EclipseLinkJpaConfiguration.java b/jpa-archetype/odata-jpa-archetype-spring-scp/src/main/resources/archetype-resources/src/main/java/config/EclipseLinkJpaConfiguration.java deleted file mode 100644 index 8fad9e29c..000000000 --- a/jpa-archetype/odata-jpa-archetype-spring-scp/src/main/resources/archetype-resources/src/main/java/config/EclipseLinkJpaConfiguration.java +++ /dev/null @@ -1,75 +0,0 @@ -package ${package}.config; - -import static org.eclipse.persistence.config.PersistenceUnitProperties.CACHE_SHARED_DEFAULT; -import static org.eclipse.persistence.config.PersistenceUnitProperties.CONNECTION_POOL_MAX; -import static org.eclipse.persistence.config.PersistenceUnitProperties.DDL_GENERATION; -import static org.eclipse.persistence.config.PersistenceUnitProperties.LOGGING_LEVEL; -import static org.eclipse.persistence.config.PersistenceUnitProperties.TRANSACTION_TYPE; -import static org.eclipse.persistence.config.PersistenceUnitProperties.WEAVING; - -import java.util.HashMap; -import java.util.Map; - -import javax.sql.DataSource; - -import org.eclipse.persistence.logging.SessionLog; -import ${package}.model.EntityTemplate; -import org.springframework.beans.factory.ObjectProvider; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.autoconfigure.orm.jpa.JpaBaseConfiguration; -import org.springframework.boot.autoconfigure.orm.jpa.JpaProperties; -import org.springframework.boot.autoconfigure.transaction.TransactionManagerCustomizers; -import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; -import org.springframework.orm.jpa.vendor.AbstractJpaVendorAdapter; -import org.springframework.orm.jpa.vendor.EclipseLinkJpaVendorAdapter; -import org.springframework.transaction.jta.JtaTransactionManager; - -@Configuration -public class EclipseLinkJpaConfiguration extends JpaBaseConfiguration { - @Value("${odata.jpa.punit_name}") - private String punit; - - protected EclipseLinkJpaConfiguration(DataSource dataSource, JpaProperties properties, - ObjectProvider jtaTransactionManager, - ObjectProvider transactionManagerCustomizers) { - super(dataSource, properties, jtaTransactionManager, transactionManagerCustomizers); - } - - @Override - protected AbstractJpaVendorAdapter createJpaVendorAdapter() { - return new EclipseLinkJpaVendorAdapter(); - } - - @Override - protected Map getVendorProperties() { - // https://stackoverflow.com/questions/10769051/eclipselinkjpavendoradapter-instead-of-hibernatejpavendoradapter-issue - HashMap jpaProperties = new HashMap<>(); - jpaProperties.put(WEAVING, "false"); - // No table generation by JPA - jpaProperties.put(DDL_GENERATION, "none"); - jpaProperties.put(LOGGING_LEVEL, SessionLog.FINE_LABEL); - jpaProperties.put(TRANSACTION_TYPE, "RESOURCE_LOCAL"); - // do not cache entities locally, as this causes problems if multiple application instances are used - jpaProperties.put(CACHE_SHARED_DEFAULT, "false"); - // You can also tweak your application performance by configuring your database connection pool. - // https://www.eclipse.org/eclipselink/documentation/2.7/jpa/extensions/persistenceproperties_ref.htm#connectionpool - jpaProperties.put(CONNECTION_POOL_MAX, 50); - return jpaProperties; - } - - @Bean - public LocalContainerEntityManagerFactoryBean customerEntityManagerFactory( - final EntityManagerFactoryBuilder builder, @Autowired final DataSource ds) { - - return builder - .dataSource(ds) - .packages(EntityTemplate.class) - .properties(getVendorProperties()) - .jta(false) - .build(); - } -} \ No newline at end of file diff --git a/jpa-archetype/odata-jpa-archetype-spring-scp/src/main/resources/archetype-resources/src/main/java/config/ProcessorConfiguration.java b/jpa-archetype/odata-jpa-archetype-spring-scp/src/main/resources/archetype-resources/src/main/java/config/ProcessorConfiguration.java deleted file mode 100644 index 0b11836d2..000000000 --- a/jpa-archetype/odata-jpa-archetype-spring-scp/src/main/resources/archetype-resources/src/main/java/config/ProcessorConfiguration.java +++ /dev/null @@ -1,47 +0,0 @@ -package ${package}.config; - -import static org.springframework.web.context.WebApplicationContext.SCOPE_REQUEST; - -import javax.persistence.EntityManagerFactory; - -import org.apache.olingo.commons.api.ex.ODataException; -import org.apache.olingo.server.api.debug.DefaultDebugSupport; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Scope; - -import com.sap.olingo.jpa.processor.core.api.JPAODataRequestContext; -import com.sap.olingo.jpa.processor.core.api.JPAODataServiceContext; -import com.sap.olingo.jpa.processor.core.api.JPAODataSessionContextAccess; -import com.sap.olingo.jpa.processor.core.api.example.JPAExampleCUDRequestHandler; - -@Configuration -public class ProcessorConfiguration { - @Value("${odata.jpa.punit_name}") - private String punit; - @Value("${odata.jpa.root_packages}") - private String rootPackages; - - @Bean - public JPAODataSessionContextAccess sessionContext(@Autowired final EntityManagerFactory emf) throws ODataException { - - return JPAODataServiceContext.with() - .setPUnit(punit) - .setEntityManagerFactory(emf) - .setTypePackage(rootPackages) - .setRequestMappingPath("${punit}/v1") - .build(); - } - - @Bean - @Scope(scopeName = SCOPE_REQUEST) - public JPAODataRequestContext requestContext() { - - return JPAODataRequestContext.with() - .setCUDRequestHandler(new JPAExampleCUDRequestHandler()) - .setDebugSupport(new DefaultDebugSupport()) - .build(); - } -} \ No newline at end of file diff --git a/jpa-archetype/odata-jpa-archetype-spring-scp/src/main/resources/archetype-resources/src/main/java/controller/ODataController.java b/jpa-archetype/odata-jpa-archetype-spring-scp/src/main/resources/archetype-resources/src/main/java/controller/ODataController.java deleted file mode 100644 index 051d1bf33..000000000 --- a/jpa-archetype/odata-jpa-archetype-spring-scp/src/main/resources/archetype-resources/src/main/java/controller/ODataController.java +++ /dev/null @@ -1,33 +0,0 @@ -package ${package}.controller; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.apache.olingo.commons.api.ex.ODataException; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.context.annotation.RequestScope; - -import com.sap.olingo.jpa.processor.core.api.JPAODataRequestContext; -import com.sap.olingo.jpa.processor.core.api.JPAODataRequestHandler; -import com.sap.olingo.jpa.processor.core.api.JPAODataSessionContextAccess; - -@RestController -@RequestMapping("${punit}/v1/**") -@RequestScope -public class ODataController { - - @Autowired - private JPAODataSessionContextAccess serviceContext; - @Autowired - private JPAODataRequestContext requestContext; - - @RequestMapping(value = "**", method = { RequestMethod.GET, RequestMethod.PATCH, // NOSONAR - RequestMethod.POST, RequestMethod.DELETE }) - public void crud(final HttpServletRequest req, final HttpServletResponse resp) throws ODataException { - - new JPAODataRequestHandler(serviceContext, requestContext).process(req, resp); - } -} diff --git a/jpa-archetype/odata-jpa-archetype-spring-scp/src/main/resources/archetype-resources/src/main/java/model/EntityTemplate.java b/jpa-archetype/odata-jpa-archetype-spring-scp/src/main/resources/archetype-resources/src/main/java/model/EntityTemplate.java deleted file mode 100644 index 4f1d7acea..000000000 --- a/jpa-archetype/odata-jpa-archetype-spring-scp/src/main/resources/archetype-resources/src/main/java/model/EntityTemplate.java +++ /dev/null @@ -1,75 +0,0 @@ -package ${package}.model; - -import java.util.ArrayList; -import java.util.Collection; - -import javax.persistence.CascadeType; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.OneToMany; -import javax.persistence.SequenceGenerator; -import javax.persistence.Table; - -@Entity(name = "${entity-table}") -@Table(schema = "\"${schema}\"", name = "\"${entity-table}\"") -public class EntityTemplate { - @Id - @Column(name = "\"ID\"", length = 32) - @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "TemplateId") - @SequenceGenerator(name = "TemplateId", sequenceName = "\"${schema}\".\"TemplateId\"", allocationSize = 1) - private Long id; - - @Column(name = "\"Data\"", length = 255) - private String data; - - @OneToMany(mappedBy = "entity", fetch = FetchType.LAZY, cascade = CascadeType.ALL) - private Collection valueObjects = new ArrayList<>(); - - public Long getId() { - return id; - } - - public void setId(final Long id) { - this.id = id; - } - - public String getData() { - return data; - } - - public void setData(final String data) { - this.data = data; - } - - public Collection getValueObjects() { - return valueObjects; - } - - public void setValueObjects(Collection valueObjects) { - this.valueObjects = valueObjects; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((id == null) ? 0 : id.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null) return false; - if (getClass() != obj.getClass()) return false; - EntityTemplate other = (EntityTemplate) obj; - if (id == null) { - if (other.id != null) return false; - } else if (!id.equals(other.id)) return false; - return true; - } -} diff --git a/jpa-archetype/odata-jpa-archetype-spring-scp/src/main/resources/archetype-resources/src/main/java/model/ValueObjectTemplate.java b/jpa-archetype/odata-jpa-archetype-spring-scp/src/main/resources/archetype-resources/src/main/java/model/ValueObjectTemplate.java deleted file mode 100644 index 2f0d3ac4b..000000000 --- a/jpa-archetype/odata-jpa-archetype-spring-scp/src/main/resources/archetype-resources/src/main/java/model/ValueObjectTemplate.java +++ /dev/null @@ -1,63 +0,0 @@ -package ${package}.model; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.Id; -import javax.persistence.IdClass; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; -import javax.persistence.Table; - -@IdClass(ValueObjectTemplateKey.class) -@Entity(name = "${value-object-table}") -@Table(schema = "\"${schema}\"", name = "\"${value-object-table}\"") -public class ValueObjectTemplate { - @Id - @Column(name = "\"ID\"", length = 32) - private String id; - - @Id - @Column(name = "\"Entity\"", length = 32) - private Long entityId; - - @Column(name = "\"Data\"", length = 255) - private String data; - - @ManyToOne(optional = false, fetch = FetchType.LAZY) - @JoinColumn(name = "\"Entity\"", insertable = false, updatable = false) - private EntityTemplate entity; - - public String getId() { - return id; - } - - public void setId(final String id) { - this.id = id; - } - - public Long getEntityId() { - return entityId; - } - - public void setEntityId(final Long entityId) { - this.entityId = entityId; - } - - public String getData() { - return data; - } - - public void setData(final String data) { - this.data = data; - } - - public EntityTemplate getEntity() { - return entity; - } - - public void setEntity(final EntityTemplate entity) { - this.entityId = entity.getId(); - this.entity = entity; - } -} diff --git a/jpa-archetype/odata-jpa-archetype-spring-scp/src/main/resources/archetype-resources/src/main/java/model/ValueObjectTemplateKey.java b/jpa-archetype/odata-jpa-archetype-spring-scp/src/main/resources/archetype-resources/src/main/java/model/ValueObjectTemplateKey.java deleted file mode 100644 index 7371e40bd..000000000 --- a/jpa-archetype/odata-jpa-archetype-spring-scp/src/main/resources/archetype-resources/src/main/java/model/ValueObjectTemplateKey.java +++ /dev/null @@ -1,56 +0,0 @@ -package ${package}.model; - -import java.io.Serializable; - -import javax.persistence.Id; - -public class ValueObjectTemplateKey implements Serializable { - - private static final long serialVersionUID = 1L; - - @Id - private String id; - - @Id - private Long entityId; - - Long getEntityId() { - return entityId; - } - - void setEntityId(final Long entityId) { - this.entityId = entityId; - } - - String getId() { - return id; - } - - void setId(final String id) { - this.id = id; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((entityId == null) ? 0 : entityId.hashCode()); - result = prime * result + ((id == null) ? 0 : id.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null) return false; - if (getClass() != obj.getClass()) return false; - ValueObjectTemplateKey other = (ValueObjectTemplateKey) obj; - if (entityId == null) { - if (other.entityId != null) return false; - } else if (!entityId.equals(other.entityId)) return false; - if (id == null) { - if (other.id != null) return false; - } else if (!id.equals(other.id)) return false; - return true; - } -} diff --git a/jpa-archetype/odata-jpa-archetype-spring-scp/src/main/resources/archetype-resources/src/main/resources/application-test.yml b/jpa-archetype/odata-jpa-archetype-spring-scp/src/main/resources/archetype-resources/src/main/resources/application-test.yml deleted file mode 100644 index d4dd5e492..000000000 --- a/jpa-archetype/odata-jpa-archetype-spring-scp/src/main/resources/archetype-resources/src/main/resources/application-test.yml +++ /dev/null @@ -1,23 +0,0 @@ -logging: - level: - org: - springframework: DEBUG -odata: - jpa: - punit_name: ${punit} - root_packages: ${package} -server: - port: ${port} -spring: - datasource: - url: jdbc:h2:mem:testdb;MODE=PostgreSQL - driverClassName: org.h2.Driver - username: sa - password: '' - flyway: - enabled: true - schemas: - - ${schema} - servlet: - multipart: - enabled: false diff --git a/jpa-archetype/odata-jpa-archetype-spring-scp/src/main/resources/archetype-resources/src/main/resources/application.yml b/jpa-archetype/odata-jpa-archetype-spring-scp/src/main/resources/archetype-resources/src/main/resources/application.yml deleted file mode 100644 index aa82b9ce9..000000000 --- a/jpa-archetype/odata-jpa-archetype-spring-scp/src/main/resources/archetype-resources/src/main/resources/application.yml +++ /dev/null @@ -1,29 +0,0 @@ -logging: - level: - org: - springframework: INFO - com: - sap: - olingo: - jpa: TRACE -odata: - jpa: - punit_name: ${punit} - root_packages: ${package} -server: - port: ${port} -spring: - datasource: - driver-class-name: org.hsqldb.jdbc.JDBCDriver - password: '' - url: jdbc:hsqldb:file:${punit};DB_CLOSE_DELAY=-1 - username: sa - flyway: - password: '' - schemas: - - ${schema} - url: jdbc:hsqldb:file:${punit};DB_CLOSE_DELAY=-1 - user: sa - servlet: - multipart: - enabled: false diff --git a/jpa-archetype/odata-jpa-archetype-spring-scp/src/main/resources/archetype-resources/src/main/resources/db/migration/V1_0__jpa.sql b/jpa-archetype/odata-jpa-archetype-spring-scp/src/main/resources/archetype-resources/src/main/resources/db/migration/V1_0__jpa.sql deleted file mode 100644 index e60317fd8..000000000 --- a/jpa-archetype/odata-jpa-archetype-spring-scp/src/main/resources/archetype-resources/src/main/resources/db/migration/V1_0__jpa.sql +++ /dev/null @@ -1,14 +0,0 @@ -SET schema "${schema}"; - -CREATE SEQUENCE "TemplateId"; - -CREATE TABLE "${entity-table}"( - "ID" BIGINT NOT NULL , - "Data" VARCHAR(255), - PRIMARY KEY ("ID")); - -CREATE TABLE "${value-object-table}"( - "Entity" BIGINT NOT NULL , - "ID" VARCHAR(32) NOT NULL , - "Data" VARCHAR(255), - PRIMARY KEY ("Entity", "ID")); \ No newline at end of file diff --git a/jpa-archetype/odata-jpa-archetype-spring-scp/src/main/resources/archetype-resources/src/test/java/AppTest.java b/jpa-archetype/odata-jpa-archetype-spring-scp/src/main/resources/archetype-resources/src/test/java/AppTest.java deleted file mode 100644 index 183a67179..000000000 --- a/jpa-archetype/odata-jpa-archetype-spring-scp/src/main/resources/archetype-resources/src/test/java/AppTest.java +++ /dev/null @@ -1,20 +0,0 @@ -package ${package}; - -import static org.junit.jupiter.api.Assertions.assertTrue; - -import org.junit.jupiter.api.Test; - -/** - * Unit test for simple App. - */ - -public class AppTest { - - /** - * Rigourous Test :-) - */ - @Test - public void testApp() { - assertTrue(true); - } -} diff --git a/jpa-archetype/odata-jpa-archetype-spring-scp/src/main/resources/archetype-resources/src/test/java/integrationtest/ControllerTest.java b/jpa-archetype/odata-jpa-archetype-spring-scp/src/main/resources/archetype-resources/src/test/java/integrationtest/ControllerTest.java deleted file mode 100644 index d1144979f..000000000 --- a/jpa-archetype/odata-jpa-archetype-spring-scp/src/main/resources/archetype-resources/src/test/java/integrationtest/ControllerTest.java +++ /dev/null @@ -1,158 +0,0 @@ -package ${package}.integrationtest; - -import static io.restassured.module.mockmvc.RestAssuredMockMvc.given; -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.hasItems; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertTrue; - -import java.io.File; -import java.net.URI; -import java.net.URISyntaxException; -import java.util.Collection; - -import org.apache.olingo.commons.api.http.HttpStatusCode; -import ${package}.SpringApp; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.web.server.LocalServerPort; -import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit.jupiter.SpringExtension; -import org.springframework.web.context.WebApplicationContext; - -import io.restassured.http.ContentType; -import io.restassured.module.mockmvc.RestAssuredMockMvc; -import io.restassured.path.xml.XmlPath; -import io.restassured.path.xml.element.Node; - -@ExtendWith(SpringExtension.class) -@SpringBootTest(classes = SpringApp.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) -@TestPropertySource(properties = { "spring.config.location=classpath:application-test.yml" }) -public class ControllerTest { - - @Autowired - private WebApplicationContext context; - @LocalServerPort - private int port; - - @BeforeEach - public void setup() { - RestAssuredMockMvc.webAppContextSetup(context); - } - - @Test - public void testRetrieveServiceDocument() { - final String xml = given() - .accept(ContentType.XML) - .when() - .get("/${punit}/v1/") - .then() - .statusCode(HttpStatusCode.OK.getStatusCode()) - .contentType(ContentType.XML) - .extract() - .asString(); - - final XmlPath path = new XmlPath(xml); - final Collection n = ((Node) ((Node) path.get("service")).get("workspace")).get("collection"); - assertNotNull(n); - assertFalse(n.isEmpty()); - } - - @Test - public void testRetrieveMetadataDocument() { - final String xml = given() - .when() - .get("/${punit}/v1/$metadata") - .then() - .statusCode(HttpStatusCode.OK.getStatusCode()) - .contentType(ContentType.XML) - .extract() - .asString(); - - final XmlPath path = new XmlPath(xml); - final Node n = ((Node) ((Node) path.get("edmx:Edmx")).get("DataServices")).get("Schema"); - assertNotNull(n); - assertEquals("${punit}", n.getAttribute("Namespace")); - assertNotNull(n.get("EntityContainer")); - } - - @Test - public void testCreateInstance() { - given() - .contentType("application/json") - .body("{ \"Data\" : \"Hello World\" }") - .when() - .post("/${punit}/v1/${entity-table}s") - .then() - .statusCode(HttpStatusCode.CREATED.getStatusCode()); - given() - .accept(ContentType.JSON) - .when() - .get("/${punit}/v1/${entity-table}s(1)") - .then() - .statusCode(HttpStatusCode.OK.getStatusCode()); - } - - @Test - public void testCreateInstanceWithBatch() throws URISyntaxException { - - URI uri = getClass().getClassLoader() - .getResource("requests/CreateEntityViaBatch.txt").toURI(); - - File myFile = new File(uri); - final String responce = given() - .contentType("multipart/mixed;boundary=abc") - .body(myFile) - .when() - .post("/${punit}/v1/$batch") - .then() - .statusCode(HttpStatusCode.ACCEPTED.getStatusCode()) - .extract() - .asString(); - - given() - .accept(ContentType.JSON) - .when() - .get("/${punit}/v1/${entity-table}s(1)") - .then() - .statusCode(HttpStatusCode.OK.getStatusCode()); - - final String[] partResults = responce.split("--changeset"); - assertTrue(partResults[1].contains("HTTP/1.1 201")); - assertTrue(partResults[2].contains("HTTP/1.1 400")); - } - - @Test - public void testCreateInstanceDeep() { - given() - .contentType(ContentType.JSON) - .accept(ContentType.JSON) - .body("{ \"Data\" : \"Hello World\", \"ValueObjects\" : [{\"Id\" : \"1\"}, {\"Id\" : \"2\"}] }") - .when() - .post("/${punit}/v1/${entity-table}s") - .then() - .statusCode(HttpStatusCode.CREATED.getStatusCode()) - .body("ValueObjects.Id", hasItems("1", "2")) - .body("Id", equalTo(1)) - .extract() - .asString(); - given() - .accept(ContentType.JSON) - .when() - .get("/${punit}/v1/${value-object-table}s(EntityId=1,Id='2')") - .then() - .statusCode(HttpStatusCode.OK.getStatusCode()); - - } - - @AfterEach - public void teardown() { - RestAssuredMockMvc.reset(); - } -} diff --git a/jpa-archetype/odata-jpa-archetype-spring-scp/src/main/resources/archetype-resources/src/test/resources/requests/CreateEntityViaBatch.txt b/jpa-archetype/odata-jpa-archetype-spring-scp/src/main/resources/archetype-resources/src/test/resources/requests/CreateEntityViaBatch.txt deleted file mode 100644 index 32aff1745..000000000 --- a/jpa-archetype/odata-jpa-archetype-spring-scp/src/main/resources/archetype-resources/src/test/resources/requests/CreateEntityViaBatch.txt +++ /dev/null @@ -1,46 +0,0 @@ ---abc -Content-Type: multipart/mixed; boundary=xyz - ---xyz -Content-Type: application/http -Content-Transfer-Encoding: binary -Content-Id: 1 -Prefer: return=minimal - -POST ${entity-table}s HTTP/1.1 -Accept: application/json -Content-Type: application/json - -{ - "Data": "Hello World", - "ValueObjects": [ - { "Id": "1" } - ] -} - - ---xyz-- - ---abc -Content-Type: multipart/mixed; boundary=xyz2 - ---xyz2 -Content-Type: application/http -Content-Transfer-Encoding: binary -Content-Id: 1 -Prefer: return=minimal - -POST ${entity-table}s HTTP/1.1 -Accept: application/json -Content-Type: application/json - -{ - "Data": "Batch Test" - "ValueObjects": [ - { "Id": "1" }, - { "Id": "1" } - ] -} - ---xyz2-- ---abc-- \ No newline at end of file diff --git a/jpa-archetype/odata-jpa-archetype-spring/pom.xml b/jpa-archetype/odata-jpa-archetype-spring/pom.xml index 1d1f52f96..755f25edd 100644 --- a/jpa-archetype/odata-jpa-archetype-spring/pom.xml +++ b/jpa-archetype/odata-jpa-archetype-spring/pom.xml @@ -4,7 +4,7 @@ com.sap.olingo odata-jpa-archetype - 1.1.1 + 2.0.0 odata-jpa-archetype-spring Archetype - odata-jpa-archetype-spring @@ -17,7 +17,7 @@ org.apache.maven.archetype archetype-packaging - 3.1.1 + 3.2.1 @@ -26,6 +26,9 @@ org.apache.maven.plugins maven-archetype-plugin 3.2.1 + + true + diff --git a/jpa-archetype/odata-jpa-archetype-spring/src/main/resources/archetype-resources/pom.xml b/jpa-archetype/odata-jpa-archetype-spring/src/main/resources/archetype-resources/pom.xml index ffc742c14..9b6567b28 100644 --- a/jpa-archetype/odata-jpa-archetype-spring/src/main/resources/archetype-resources/pom.xml +++ b/jpa-archetype/odata-jpa-archetype-spring/src/main/resources/archetype-resources/pom.xml @@ -1,7 +1,7 @@ - + 4.0.0 ${groupId} ${artifactId} @@ -12,15 +12,15 @@ org.springframework.boot spring-boot-starter-parent - 2.7.6 + 3.1.3 - - 1.1.1 - 1.8 - 2.7.9 - 2.2.1 + + 2.0.0 + 17 + 4.0.2 + 3.1.0 @@ -37,7 +37,7 @@ junit junit - + org.springframework.boot @@ -58,8 +58,8 @@ - org.eclipse.persistence - javax.persistence + jakarta.persistence + jakarta.persistence-api ${jpa.version} compile @@ -73,37 +73,37 @@ odata-jpa-processor ${processor.version} - - com.sap.olingo - odata-jpa-processor-cb - ${processor.version} - + + com.sap.olingo + odata-jpa-processor-cb + ${processor.version} + com.sap.olingo odata-jpa-spring-support ${processor.version} - + org.springframework.boot spring-boot-configuration-processor true + + com.h2database + h2 + 2.2.222 + runtime + org.flywaydb flyway-core - 8.4.0 - - - com.h2database - h2 - 2.2.222 - runtime - - - org.hsqldb - hsqldb - runtime - + 9.22.0 + + + org.hsqldb + hsqldb + runtime + org.springframework.boot spring-boot-devtools @@ -125,7 +125,7 @@ junit-platform-launcher 1.9.1 test - + diff --git a/jpa-archetype/odata-jpa-archetype-spring/src/main/resources/archetype-resources/src/main/java/config/EclipseLinkJpaConfiguration.java b/jpa-archetype/odata-jpa-archetype-spring/src/main/resources/archetype-resources/src/main/java/config/EclipseLinkJpaConfiguration.java index 43a6aa5c9..083f2ab13 100644 --- a/jpa-archetype/odata-jpa-archetype-spring/src/main/resources/archetype-resources/src/main/java/config/EclipseLinkJpaConfiguration.java +++ b/jpa-archetype/odata-jpa-archetype-spring/src/main/resources/archetype-resources/src/main/java/config/EclipseLinkJpaConfiguration.java @@ -8,6 +8,7 @@ import static org.eclipse.persistence.config.PersistenceUnitProperties.WEAVING; import java.util.HashMap; +import java.util.List; import java.util.Map; import javax.sql.DataSource; @@ -15,17 +16,18 @@ import org.eclipse.persistence.logging.SessionLog; import ${package}.model.EntityTemplate; import org.springframework.beans.factory.ObjectProvider; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.autoconfigure.orm.jpa.JpaBaseConfiguration; import org.springframework.boot.autoconfigure.orm.jpa.JpaProperties; import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder; -import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; +import org.springframework.orm.jpa.persistenceunit.PersistenceManagedTypes; import org.springframework.orm.jpa.vendor.AbstractJpaVendorAdapter; import org.springframework.orm.jpa.vendor.EclipseLinkJpaVendorAdapter; import org.springframework.transaction.jta.JtaTransactionManager; +import org.springframework.util.ObjectUtils; +import org.springframework.util.StringUtils; @Configuration public class EclipseLinkJpaConfiguration extends JpaBaseConfiguration { @@ -59,15 +61,22 @@ protected Map getVendorProperties() { return jpaProperties; } - @Bean - public LocalContainerEntityManagerFactoryBean customerEntityManagerFactory( - final EntityManagerFactoryBuilder builder, @Autowired final DataSource ds) { - - return builder - .dataSource(ds) + @Override + public LocalContainerEntityManagerFactoryBean entityManagerFactory(EntityManagerFactoryBuilder factoryBuilder, + PersistenceManagedTypes persistenceManagedTypes) { + Map vendorProperties = getVendorProperties(); + customizeVendorProperties(vendorProperties); + return factoryBuilder + .dataSource(this.getDataSource()) + .properties(vendorProperties) + .mappingResources(getMapping()) .packages(EntityTemplate.class) - .properties(getVendorProperties()) .jta(false) .build(); } + + private String[] getMapping() { + List mappingResources = this.getProperties().getMappingResources(); + return (!ObjectUtils.isEmpty(mappingResources) ? StringUtils.toStringArray(mappingResources) : null); + } } \ No newline at end of file diff --git a/jpa-archetype/odata-jpa-archetype-spring/src/main/resources/archetype-resources/src/main/java/config/ProcessorConfiguration.java b/jpa-archetype/odata-jpa-archetype-spring/src/main/resources/archetype-resources/src/main/java/config/ProcessorConfiguration.java index 0b11836d2..c37bc7ace 100644 --- a/jpa-archetype/odata-jpa-archetype-spring/src/main/resources/archetype-resources/src/main/java/config/ProcessorConfiguration.java +++ b/jpa-archetype/odata-jpa-archetype-spring/src/main/resources/archetype-resources/src/main/java/config/ProcessorConfiguration.java @@ -2,7 +2,7 @@ import static org.springframework.web.context.WebApplicationContext.SCOPE_REQUEST; -import javax.persistence.EntityManagerFactory; +import jakarta.persistence.EntityManagerFactory; import org.apache.olingo.commons.api.ex.ODataException; import org.apache.olingo.server.api.debug.DefaultDebugSupport; diff --git a/jpa-archetype/odata-jpa-archetype-spring/src/main/resources/archetype-resources/src/main/java/controller/ODataController.java b/jpa-archetype/odata-jpa-archetype-spring/src/main/resources/archetype-resources/src/main/java/controller/ODataController.java index 1c3940666..35c78caa2 100644 --- a/jpa-archetype/odata-jpa-archetype-spring/src/main/resources/archetype-resources/src/main/java/controller/ODataController.java +++ b/jpa-archetype/odata-jpa-archetype-spring/src/main/resources/archetype-resources/src/main/java/controller/ODataController.java @@ -1,7 +1,7 @@ package ${package}.controller; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; import org.apache.olingo.commons.api.ex.ODataException; import org.springframework.beans.factory.annotation.Autowired; diff --git a/jpa-archetype/odata-jpa-archetype-spring/src/main/resources/archetype-resources/src/main/java/model/EntityTemplate.java b/jpa-archetype/odata-jpa-archetype-spring/src/main/resources/archetype-resources/src/main/java/model/EntityTemplate.java index 4f1d7acea..c08b9dee3 100644 --- a/jpa-archetype/odata-jpa-archetype-spring/src/main/resources/archetype-resources/src/main/java/model/EntityTemplate.java +++ b/jpa-archetype/odata-jpa-archetype-spring/src/main/resources/archetype-resources/src/main/java/model/EntityTemplate.java @@ -3,16 +3,16 @@ import java.util.ArrayList; import java.util.Collection; -import javax.persistence.CascadeType; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.OneToMany; -import javax.persistence.SequenceGenerator; -import javax.persistence.Table; +import jakarta.persistence.CascadeType; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.OneToMany; +import jakarta.persistence.SequenceGenerator; +import jakarta.persistence.Table; @Entity(name = "${entity-table}") @Table(schema = "\"${schema}\"", name = "\"${entity-table}\"") diff --git a/jpa-archetype/odata-jpa-archetype-spring/src/main/resources/archetype-resources/src/main/java/model/ValueObjectTemplate.java b/jpa-archetype/odata-jpa-archetype-spring/src/main/resources/archetype-resources/src/main/java/model/ValueObjectTemplate.java index 2f0d3ac4b..c9e03f9d8 100644 --- a/jpa-archetype/odata-jpa-archetype-spring/src/main/resources/archetype-resources/src/main/java/model/ValueObjectTemplate.java +++ b/jpa-archetype/odata-jpa-archetype-spring/src/main/resources/archetype-resources/src/main/java/model/ValueObjectTemplate.java @@ -1,13 +1,13 @@ package ${package}.model; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.Id; -import javax.persistence.IdClass; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; -import javax.persistence.Table; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.Id; +import jakarta.persistence.IdClass; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Table; @IdClass(ValueObjectTemplateKey.class) @Entity(name = "${value-object-table}") diff --git a/jpa-archetype/odata-jpa-archetype-spring/src/main/resources/archetype-resources/src/main/java/model/ValueObjectTemplateKey.java b/jpa-archetype/odata-jpa-archetype-spring/src/main/resources/archetype-resources/src/main/java/model/ValueObjectTemplateKey.java index 8090c1e6c..8df40eaa1 100644 --- a/jpa-archetype/odata-jpa-archetype-spring/src/main/resources/archetype-resources/src/main/java/model/ValueObjectTemplateKey.java +++ b/jpa-archetype/odata-jpa-archetype-spring/src/main/resources/archetype-resources/src/main/java/model/ValueObjectTemplateKey.java @@ -2,7 +2,7 @@ import java.io.Serializable; -import javax.persistence.Id; +import jakarta.persistence.Id; public class ValueObjectTemplateKey implements Serializable { diff --git a/jpa-archetype/odata-jpa-archetype-spring/src/main/resources/archetype-resources/src/main/resources/application-test.yml b/jpa-archetype/odata-jpa-archetype-spring/src/main/resources/archetype-resources/src/main/resources/application-test.yml index 2031fcdd8..ca3706a28 100644 --- a/jpa-archetype/odata-jpa-archetype-spring/src/main/resources/archetype-resources/src/main/resources/application-test.yml +++ b/jpa-archetype/odata-jpa-archetype-spring/src/main/resources/archetype-resources/src/main/resources/application-test.yml @@ -5,7 +5,7 @@ logging: com: sap: olingo: - jpa: INFO + jpa: TRACE odata: jpa: punit_name: ${punit} diff --git a/jpa-archetype/odata-jpa-archetype-spring/src/main/resources/archetype-resources/src/test/java/integrationtest/ControllerTest.java b/jpa-archetype/odata-jpa-archetype-spring/src/main/resources/archetype-resources/src/test/java/integrationtest/ControllerTest.java index b32b6af00..68fc27e45 100644 --- a/jpa-archetype/odata-jpa-archetype-spring/src/main/resources/archetype-resources/src/test/java/integrationtest/ControllerTest.java +++ b/jpa-archetype/odata-jpa-archetype-spring/src/main/resources/archetype-resources/src/test/java/integrationtest/ControllerTest.java @@ -21,7 +21,6 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.web.server.LocalServerPort; import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.web.context.WebApplicationContext; @@ -38,8 +37,6 @@ class ControllerTest { @Autowired private WebApplicationContext context; - @LocalServerPort - private int port; @BeforeEach void setup() { diff --git a/jpa-archetype/pom.xml b/jpa-archetype/pom.xml index 700a4eee4..fca039962 100644 --- a/jpa-archetype/pom.xml +++ b/jpa-archetype/pom.xml @@ -4,18 +4,17 @@ 4.0.0 com.sap.olingo odata-jpa-archetype - 1.1.1 + 2.0.0 pom https://github.com/SAP/olingo-jpa-processor-v4 UTF-8 - 1.8 - 1.1.1 + 17 + 2.0.0 odata-jpa-archetype-spring - odata-jpa-archetype-spring-scp \ No newline at end of file diff --git a/jpa-tutorial/QuickStart/QuickStart.adoc b/jpa-tutorial/QuickStart/QuickStart.adoc index 06d997b39..a8ae653aa 100644 --- a/jpa-tutorial/QuickStart/QuickStart.adoc +++ b/jpa-tutorial/QuickStart/QuickStart.adoc @@ -17,7 +17,7 @@ In order to follow this tutorial, you should have In order to perform the tutorial you need: -* A Java JDK 1.8 or higher +* A Java JDK 17 or higher * A Eclipse IDE for Java EE, or another one that provides the same functionality * Optional: Maven separately installed, to perform Maven commands in case the JPA Processor projects should not be imported into your IDE * Optional: Git separately installed. @@ -46,7 +46,7 @@ This should contain the information about archetype: com.sap.olingo odata-jpa-archetype-spring - 1.0.9 + 2.0.0 @@ -70,17 +70,17 @@ image:../images/quick-start/MavenSelectArchetype.png[Maven Select Archetype, 500 As a last step some parameter have to be provided: -[options="header"] -|=== -|Parameter Name |Value -//------------- +[options="header"] +|=== +|Parameter Name |Value +//------------- |Group Id|com.example |Artifact Id|trippin |punit|Trippin |schema|Trippin |entity-table|Person -|value-object-table|Trip -|=== +|value-object-table|Trip +|=== image:../images/quick-start/MavenSetParameterArchetype.png[Set parameter archetype, 500] @@ -144,7 +144,7 @@ The other JPA Processor dependencies are **optional**: === Configuration JPA Processor need to be customized to work properly. Package `com.example.trippin.config` contains two classes that provide this information. The first is `EclipseLinkJpaConfiguration`, -which is needed to make use of http://www.eclipse.org/eclipselink/[Eclipselink]. For our service the most important part is in method `customerEntityManagerFactory`. Here we provide with `.packages(EntityTemplate.class)` a reference to a package that contains the JPA entities and so defines our persistence-unit. +which is needed to make use of http://www.eclipse.org/eclipselink/[Eclipselink]. For our service the most important part is in method `entityManagerFactory`. Here we provide with `.packages(EntityTemplate.class)` a reference to a package that contains the JPA entities and so defines our persistence-unit. The second one is `ProcessorConfiguration`. It has two methods. The first one creates a service context, which should be valid for the live time of the service: @@ -169,8 +169,8 @@ public JPAODataSessionContextAccess sessionContext(@Autowired final EntityManage <3> The _RequestMappingPath_ is needed by Olingo in case a service uses Spring. -[NOTE] -==== +[NOTE] +==== The namepsace can be found in the metadata, after executing http://localhost:9010/Trippin/v1/$metadata: [source,xml] ---- @@ -186,8 +186,8 @@ The namepsace can be found in the metadata, after executing http://localhost:901 [NOTE] ==== -The persistence-unit name is injected from the `application.yml` that is located in `/src/main/resources/`. - +The persistence-unit name is injected from the `application.yml` that is located in `/src/main/resources/`. + ==== The second one is the creation of a request context, which is created for each request: diff --git a/jpa/.settings/org.eclipse.jdt.core.prefs b/jpa/.settings/org.eclipse.jdt.core.prefs index 070014fbf..01a729cd2 100644 --- a/jpa/.settings/org.eclipse.jdt.core.prefs +++ b/jpa/.settings/org.eclipse.jdt.core.prefs @@ -17,8 +17,6 @@ org.eclipse.jdt.core.compiler.compliance=1.8 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate -org.eclipse.jdt.core.compiler.problem.APILeak=warning -org.eclipse.jdt.core.compiler.problem.annotatedTypeArgumentToUnannotated=info org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.autoboxing=ignore diff --git a/jpa/odata-jpa-annotation/.gitignore b/jpa/odata-jpa-annotation/.gitignore index 3b248b28a..bcb74aa8a 100644 --- a/jpa/odata-jpa-annotation/.gitignore +++ b/jpa/odata-jpa-annotation/.gitignore @@ -4,7 +4,4 @@ target/ # JDT-specific (Eclipse Java Development Tools) .classpath -# --- EclipseIDE stuff START -.settings/ -.metadata /.sts4-cache/ diff --git a/jpa/odata-jpa-annotation/.settings/org.eclipse.jdt.core.prefs b/jpa/odata-jpa-annotation/.settings/org.eclipse.jdt.core.prefs index a9e7a4212..94ac14d17 100644 --- a/jpa/odata-jpa-annotation/.settings/org.eclipse.jdt.core.prefs +++ b/jpa/odata-jpa-annotation/.settings/org.eclipse.jdt.core.prefs @@ -1,7 +1,7 @@ eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 -org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 +org.eclipse.jdt.core.compiler.compliance=17 org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled org.eclipse.jdt.core.compiler.problem.enumIdentifier=error @@ -9,4 +9,4 @@ org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning org.eclipse.jdt.core.compiler.processAnnotations=disabled org.eclipse.jdt.core.compiler.release=disabled -org.eclipse.jdt.core.compiler.source=1.8 +org.eclipse.jdt.core.compiler.source=17 diff --git a/jpa/odata-jpa-annotation/.settings/org.eclipse.wst.common.project.facet.core.xml b/jpa/odata-jpa-annotation/.settings/org.eclipse.wst.common.project.facet.core.xml index ee260d978..babef879f 100644 --- a/jpa/odata-jpa-annotation/.settings/org.eclipse.wst.common.project.facet.core.xml +++ b/jpa/odata-jpa-annotation/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -1,5 +1,5 @@ - + diff --git a/jpa/odata-jpa-annotation/pom.xml b/jpa/odata-jpa-annotation/pom.xml index f574b4b1b..9f208e5c9 100644 --- a/jpa/odata-jpa-annotation/pom.xml +++ b/jpa/odata-jpa-annotation/pom.xml @@ -7,7 +7,7 @@ com.sap.olingo odata-jpa - 1.1.1 + 2.0.0 odata-jpa-annotation odata-jpa-annotation @@ -20,8 +20,8 @@ ${odata.version} - org.eclipse.persistence - javax.persistence + jakarta.persistence + jakarta.persistence-api ${jpa.version} @@ -33,19 +33,19 @@ org.junit.jupiter junit-jupiter - 5.9.1 + ${junit.version} test org.junit.platform junit-platform-launcher - 1.9.1 + ${junit-platform.version} test org.mockito mockito-core - 3.6.0 + ${mockito.version} test diff --git a/jpa/odata-jpa-annotation/src/main/java/com/sap/olingo/jpa/metadata/converter/OffsetDateTimeConverter.java b/jpa/odata-jpa-annotation/src/main/java/com/sap/olingo/jpa/metadata/converter/OffsetDateTimeConverter.java index e72140125..f4c8a5235 100644 --- a/jpa/odata-jpa-annotation/src/main/java/com/sap/olingo/jpa/metadata/converter/OffsetDateTimeConverter.java +++ b/jpa/odata-jpa-annotation/src/main/java/com/sap/olingo/jpa/metadata/converter/OffsetDateTimeConverter.java @@ -3,8 +3,8 @@ import java.time.OffsetDateTime; import java.time.ZonedDateTime; -import javax.persistence.AttributeConverter; -import javax.persistence.Converter; +import jakarta.persistence.AttributeConverter; +import jakarta.persistence.Converter; /** * Default converter to convert from {@link java.time.OffsetDateTime} to {@link java.time.ZonedDateTime}. This is diff --git a/jpa/odata-jpa-annotation/src/main/java/com/sap/olingo/jpa/metadata/converter/TimeInstantLongConverter.java b/jpa/odata-jpa-annotation/src/main/java/com/sap/olingo/jpa/metadata/converter/TimeInstantLongConverter.java index 54ee93415..130764507 100644 --- a/jpa/odata-jpa-annotation/src/main/java/com/sap/olingo/jpa/metadata/converter/TimeInstantLongConverter.java +++ b/jpa/odata-jpa-annotation/src/main/java/com/sap/olingo/jpa/metadata/converter/TimeInstantLongConverter.java @@ -2,8 +2,8 @@ import java.time.Instant; -import javax.persistence.AttributeConverter; -import javax.persistence.Converter; +import jakarta.persistence.AttributeConverter; +import jakarta.persistence.Converter; /** * Default converter to convert from {@link Long} to {@link java.time.Instant}. diff --git a/jpa/odata-jpa-annotation/src/main/java/com/sap/olingo/jpa/metadata/core/edm/annotation/EdmAsEntitySet.java b/jpa/odata-jpa-annotation/src/main/java/com/sap/olingo/jpa/metadata/core/edm/annotation/EdmAsEntitySet.java deleted file mode 100644 index 9aac176fa..000000000 --- a/jpa/odata-jpa-annotation/src/main/java/com/sap/olingo/jpa/metadata/core/edm/annotation/EdmAsEntitySet.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.sap.olingo.jpa.metadata.core.edm.annotation; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Allows to mark an jpa entity as an additional entity set of another entity type. - * This is only allowed for leafs in an inheritance hierarchy. The jpa entity must not have own columns

- * OData Version 4.0 Part 3 - 13 Entity Container Example 30 - * @deprecated (since 1.0.3, replace with {@link EdmEntityType}, deleted with 1.1.0 ) - */ -@Deprecated -@Target({ ElementType.TYPE }) -@Retention(value = RetentionPolicy.RUNTIME) -public @interface EdmAsEntitySet { - -} diff --git a/jpa/odata-jpa-annotation/src/main/java/com/sap/olingo/jpa/metadata/core/edm/annotation/EdmEntityType.java b/jpa/odata-jpa-annotation/src/main/java/com/sap/olingo/jpa/metadata/core/edm/annotation/EdmEntityType.java index ec3fe978b..02b1ba26a 100644 --- a/jpa/odata-jpa-annotation/src/main/java/com/sap/olingo/jpa/metadata/core/edm/annotation/EdmEntityType.java +++ b/jpa/odata-jpa-annotation/src/main/java/com/sap/olingo/jpa/metadata/core/edm/annotation/EdmEntityType.java @@ -28,11 +28,11 @@ /** * Query Extension Provider provides a set to methods to extend or influence the generated query. This may be from - * interest in case a subset of records shall be represented by an Entity Set or Singleton and it is not possible to + * interest in case a subset of records shall be represented by an Entity Set or Singleton and it is not possible to * use a database view. *

* - * Query Extension Provider are inherited. One that is given at a sub type overrides one that is given at the super + * Query Extension Provider are inherited. One that is given at a sub type overrides one that is given at the super * type or base type. */ Class extensionProvider() default EdmQueryExtensionProvider.class; diff --git a/jpa/odata-jpa-annotation/src/main/java/com/sap/olingo/jpa/metadata/core/edm/annotation/EdmEnumeration.java b/jpa/odata-jpa-annotation/src/main/java/com/sap/olingo/jpa/metadata/core/edm/annotation/EdmEnumeration.java index 220d53d95..e4b84f63d 100644 --- a/jpa/odata-jpa-annotation/src/main/java/com/sap/olingo/jpa/metadata/core/edm/annotation/EdmEnumeration.java +++ b/jpa/odata-jpa-annotation/src/main/java/com/sap/olingo/jpa/metadata/core/edm/annotation/EdmEnumeration.java @@ -6,13 +6,14 @@ import java.lang.annotation.Retention; import java.lang.annotation.Target; -import javax.persistence.AttributeConverter; -import javax.persistence.Enumerated; +import jakarta.persistence.AttributeConverter; +import jakarta.persistence.Enumerated; /** * Annotation to tag Java enumerations that shall be provided via an OData service. For details about OData Enumerations * see: 10 + * href= + * "http://docs.oasis-open.org/odata/odata/v4.0/errata03/os/complete/part3-csdl/odata-v4.0-errata03-os-part3-csdl-complete.html#_Toc453752565">10 * Enumeration Type. * The following conversion rule have been established: *

    diff --git a/jpa/odata-jpa-annotation/src/main/java/com/sap/olingo/jpa/metadata/core/edm/annotation/EdmQueryExtensionProvider.java b/jpa/odata-jpa-annotation/src/main/java/com/sap/olingo/jpa/metadata/core/edm/annotation/EdmQueryExtensionProvider.java index e14704305..a955f05f4 100644 --- a/jpa/odata-jpa-annotation/src/main/java/com/sap/olingo/jpa/metadata/core/edm/annotation/EdmQueryExtensionProvider.java +++ b/jpa/odata-jpa-annotation/src/main/java/com/sap/olingo/jpa/metadata/core/edm/annotation/EdmQueryExtensionProvider.java @@ -4,15 +4,18 @@ package com.sap.olingo.jpa.metadata.core.edm.annotation; import javax.annotation.CheckForNull; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.Expression; -import javax.persistence.criteria.From; + +import jakarta.persistence.criteria.CriteriaBuilder; +import jakarta.persistence.criteria.Expression; +import jakarta.persistence.criteria.From; /** - * Provides a set to methods to extend or influence the generated query.

    + * Provides a set to methods to extend or influence the generated query. + *

    * * An instance of the extension provider is created once per OData request. That is, it could be created multiple times - * per http request in case of $batch requests.

    + * per http request in case of $batch requests. + *

    * An implementing class may provide one constructor having no parameter or a combination of the following: *

      *
    • All header: com.sap.olingo.jpa.metadata.api.JPAHttpHeaderMap
    • diff --git a/jpa/odata-jpa-annotation/src/main/java/com/sap/olingo/jpa/metadata/core/edm/annotation/EdmTransient.java b/jpa/odata-jpa-annotation/src/main/java/com/sap/olingo/jpa/metadata/core/edm/annotation/EdmTransient.java index f0e7ca904..31f25c7ec 100644 --- a/jpa/odata-jpa-annotation/src/main/java/com/sap/olingo/jpa/metadata/core/edm/annotation/EdmTransient.java +++ b/jpa/odata-jpa-annotation/src/main/java/com/sap/olingo/jpa/metadata/core/edm/annotation/EdmTransient.java @@ -9,8 +9,6 @@ import java.lang.annotation.Retention; import java.lang.annotation.Target; -import javax.persistence.Transient; - /** * The annotation marks attributes that are transient, but shall be part of the Edm.
      * Please note that the attribute needs the corresponding JPA annotation {@link Transient} as well. @@ -23,7 +21,9 @@ public @interface EdmTransient { /** * Optional: An array of path to attributes that need to be present to build the annotated one. In case the path - * is composed, path segments joined together by forward slashes (/) e.g address/cityName.

      The correctness + * is composed, path segments joined together by forward slashes (/) e.g address/cityName. + *

      + * The correctness * of the path is check when the entity type is build. */ String[] requiredAttributes() default {}; diff --git a/jpa/odata-jpa-annotation/src/main/java/com/sap/olingo/jpa/metadata/core/edm/annotation/EdmTransientPropertyCalculator.java b/jpa/odata-jpa-annotation/src/main/java/com/sap/olingo/jpa/metadata/core/edm/annotation/EdmTransientPropertyCalculator.java index bec661383..b98a62f21 100644 --- a/jpa/odata-jpa-annotation/src/main/java/com/sap/olingo/jpa/metadata/core/edm/annotation/EdmTransientPropertyCalculator.java +++ b/jpa/odata-jpa-annotation/src/main/java/com/sap/olingo/jpa/metadata/core/edm/annotation/EdmTransientPropertyCalculator.java @@ -8,24 +8,29 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; -import javax.persistence.Tuple; + +import jakarta.persistence.Tuple; /** - * Transient property converter.

      + * Transient property converter. + *

      * A converter take a row returned from the database and calculates, based on its values, either one additional value or * a collection of values.
      - * The converter is mentioned in the {@link EdmTransient} annotation at a POJO attribute. E.g.:

      + * The converter is mentioned in the {@link EdmTransient} annotation at a POJO attribute. E.g.: + *

      * * {@literal @}EdmTransient(requiredAttributes = { "lastName", "firstName" }, calculator = FullNameCalculator.class)
      * {@literal @}Transient
      * private String fullName;
      - *

      + * + *

      * * An instance of the converter is created once per OData request. That is, it could be created multiple times per http - * request in case of $batch requests.

      + * request in case of $batch requests. + *

      * An implementing class may provide one constructor having no parameter or a combination of the following: *

        - *
      • An Entity Manager: javax.persistence.EntityManager
      • + *
      • An Entity Manager: jakarta.persistence.EntityManager
      • *
      • All header: com.sap.olingo.jpa.metadata.api.JPAHttpHeaderMap
      • *
      • Access to own request parameter: com.sap.olingo.jpa.metadata.api.JPARequestParameterMap
      • *
      diff --git a/jpa/odata-jpa-annotation/src/test/java/com/sap/olingo/jpa/metadata/core/edm/annotation/EdmEnumerationTest.java b/jpa/odata-jpa-annotation/src/test/java/com/sap/olingo/jpa/metadata/core/edm/annotation/EdmEnumerationTest.java index a18f26c87..24280a19c 100644 --- a/jpa/odata-jpa-annotation/src/test/java/com/sap/olingo/jpa/metadata/core/edm/annotation/EdmEnumerationTest.java +++ b/jpa/odata-jpa-annotation/src/test/java/com/sap/olingo/jpa/metadata/core/edm/annotation/EdmEnumerationTest.java @@ -6,13 +6,13 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNull; -import javax.persistence.AttributeConverter; - import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import jakarta.persistence.AttributeConverter; + /** - * @author Oliver Grande + * @author Oliver Grande * @since 1.0.9 * 18.01.2022 */ diff --git a/jpa/odata-jpa-annotation/src/test/java/com/sap/olingo/jpa/metadata/core/edm/annotation/EdmTransientPropertyCalculatorTest.java b/jpa/odata-jpa-annotation/src/test/java/com/sap/olingo/jpa/metadata/core/edm/annotation/EdmTransientPropertyCalculatorTest.java index dbf4eec43..0149cd61a 100644 --- a/jpa/odata-jpa-annotation/src/test/java/com/sap/olingo/jpa/metadata/core/edm/annotation/EdmTransientPropertyCalculatorTest.java +++ b/jpa/odata-jpa-annotation/src/test/java/com/sap/olingo/jpa/metadata/core/edm/annotation/EdmTransientPropertyCalculatorTest.java @@ -8,13 +8,13 @@ import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.Mockito.mock; -import javax.persistence.Tuple; - import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import jakarta.persistence.Tuple; + /** - * @author Oliver Grande + * @author Oliver Grande * @since 1.0.9 * 18.01.2022 */ diff --git a/jpa/odata-jpa-coverage/pom.xml b/jpa/odata-jpa-coverage/pom.xml index bdcdb6a2a..5e831a852 100644 --- a/jpa/odata-jpa-coverage/pom.xml +++ b/jpa/odata-jpa-coverage/pom.xml @@ -4,7 +4,7 @@ com.sap.olingo odata-jpa - 1.1.1 + 2.0.0 odata-jpa-coverage @@ -60,7 +60,7 @@ com.sap.olingo odata-jpa-vocabularies ${project.version} - + diff --git a/jpa/odata-jpa-metadata/.settings/org.eclipse.jdt.core.prefs b/jpa/odata-jpa-metadata/.settings/org.eclipse.jdt.core.prefs index 9b48fdc3d..acf518c14 100644 --- a/jpa/odata-jpa-metadata/.settings/org.eclipse.jdt.core.prefs +++ b/jpa/odata-jpa-metadata/.settings/org.eclipse.jdt.core.prefs @@ -1,9 +1,9 @@ eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 -org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 +org.eclipse.jdt.core.compiler.compliance=17 org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning org.eclipse.jdt.core.compiler.processAnnotations=disabled org.eclipse.jdt.core.compiler.release=disabled -org.eclipse.jdt.core.compiler.source=1.8 +org.eclipse.jdt.core.compiler.source=17 diff --git a/jpa/odata-jpa-metadata/.settings/org.eclipse.wst.common.project.facet.core.xml b/jpa/odata-jpa-metadata/.settings/org.eclipse.wst.common.project.facet.core.xml index ee260d978..babef879f 100644 --- a/jpa/odata-jpa-metadata/.settings/org.eclipse.wst.common.project.facet.core.xml +++ b/jpa/odata-jpa-metadata/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -1,5 +1,5 @@ - + diff --git a/jpa/odata-jpa-metadata/pom.xml b/jpa/odata-jpa-metadata/pom.xml index 8a10f23f2..6b291ab0e 100644 --- a/jpa/odata-jpa-metadata/pom.xml +++ b/jpa/odata-jpa-metadata/pom.xml @@ -7,7 +7,7 @@ com.sap.olingo odata-jpa - 1.1.1 + 2.0.0 odata-jpa-metadata @@ -36,8 +36,8 @@ ${project.version} - org.eclipse.persistence - javax.persistence + jakarta.persistence + jakarta.persistence-api ${jpa.version} diff --git a/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/api/JPAEdmMetadataPostProcessor.java b/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/api/JPAEdmMetadataPostProcessor.java index b29b7f4dc..17228fb5d 100644 --- a/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/api/JPAEdmMetadataPostProcessor.java +++ b/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/api/JPAEdmMetadataPostProcessor.java @@ -9,18 +9,17 @@ import com.sap.olingo.jpa.metadata.core.edm.mapper.extension.IntermediateReferenceList; import com.sap.olingo.jpa.metadata.core.edm.mapper.extension.IntermediateSingletonAccess; -public abstract class JPAEdmMetadataPostProcessor { +public interface JPAEdmMetadataPostProcessor { + public default void processEntityContainer(final IntermediateEntityContainerAccess container) {} - public void processEntityContainer(final IntermediateEntityContainerAccess container) {} + public default void processEntityType(final IntermediateEntityTypeAccess entityType){} - public abstract void processEntityType(final IntermediateEntityTypeAccess entityType); + public default void processEntitySet(final IntermediateEntitySetAccess entitySet) {} - public void processEntitySet(final IntermediateEntitySetAccess entitySet) {} + public default void processSingleton(final IntermediateSingletonAccess singleton) {} - public void processSingleton(final IntermediateSingletonAccess singleton) {} - - public abstract void processNavigationProperty(final IntermediateNavigationPropertyAccess property, - final String jpaManagedTypeClassName); + public default void processNavigationProperty(final IntermediateNavigationPropertyAccess property, + final String jpaManagedTypeClassName){} /** * @@ -28,12 +27,12 @@ public abstract void processNavigationProperty(final IntermediateNavigationPrope * @param jpaManagedTypeClassName * @return */ - public abstract void processProperty(final IntermediatePropertyAccess property, final String jpaManagedTypeClassName); + public default void processProperty(final IntermediatePropertyAccess property, final String jpaManagedTypeClassName){} /** * Option to provide references to external CSDL documents. The document must be an XML document * @param references List of refernces to external CSDL documents. * @throws ODataJPAModelException */ - public abstract void provideReferences(final IntermediateReferenceList references) throws ODataJPAModelException; + public default void provideReferences(final IntermediateReferenceList references) throws ODataJPAModelException{} } diff --git a/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/api/JPAEdmProvider.java b/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/api/JPAEdmProvider.java index ad32722bd..2433b7480 100644 --- a/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/api/JPAEdmProvider.java +++ b/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/api/JPAEdmProvider.java @@ -7,8 +7,6 @@ import java.util.Objects; import javax.annotation.Nonnull; -import javax.persistence.EntityManagerFactory; -import javax.persistence.metamodel.Metamodel; import org.apache.olingo.commons.api.edm.FullQualifiedName; import org.apache.olingo.commons.api.edm.provider.CsdlAbstractEdmProvider; @@ -37,6 +35,9 @@ import com.sap.olingo.jpa.metadata.core.edm.mapper.impl.JPADefaultEdmNameBuilder; import com.sap.olingo.jpa.metadata.core.edm.mapper.impl.JPAServiceDocumentFactory; +import jakarta.persistence.EntityManagerFactory; +import jakarta.persistence.metamodel.Metamodel; + public class JPAEdmProvider extends CsdlAbstractEdmProvider { private final JPAEdmNameBuilder nameBuilder; diff --git a/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/api/JPAEntityManagerFactory.java b/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/api/JPAEntityManagerFactory.java index 50f23c3b1..fee0dc3d0 100644 --- a/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/api/JPAEntityManagerFactory.java +++ b/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/api/JPAEntityManagerFactory.java @@ -3,12 +3,13 @@ import java.util.HashMap; import java.util.Map; -import javax.persistence.EntityManagerFactory; -import javax.persistence.Persistence; import javax.sql.DataSource; +import jakarta.persistence.EntityManagerFactory; +import jakarta.persistence.Persistence; + public class JPAEntityManagerFactory { - private static final String ENTITY_MANAGER_DATA_SOURCE = "javax.persistence.nonJtaDataSource"; + private static final String ENTITY_MANAGER_DATA_SOURCE = "jakarta.persistence.nonJtaDataSource"; private static Map> emfMap; private JPAEntityManagerFactory() { @@ -22,7 +23,7 @@ public static EntityManagerFactory getEntityManagerFactory(final String pUnit, f if (emfMap == null) { emfMap = new HashMap<>(); } - Integer dsKey = ds.hashCode(); + final Integer dsKey = ds.hashCode(); if (emfMap.containsKey(pUnit)) { final Map dsMap = emfMap.get(pUnit); EntityManagerFactory emf = dsMap.get(dsKey); diff --git a/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/api/JPAJoinColumn.java b/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/api/JPAJoinColumn.java index c1e6877d7..2a7ad07fc 100644 --- a/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/api/JPAJoinColumn.java +++ b/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/api/JPAJoinColumn.java @@ -8,7 +8,7 @@ * Created: 02.02.2020 * */ -public interface JPAJoinColumn { +public interface JPAJoinColumn { /** * Returns the name of the column of the target table. This can be different from the name given in the @JoinColumn * annotation. diff --git a/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/api/JPAODataQueryContext.java b/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/api/JPAODataQueryContext.java index 4a193682f..42341bfc2 100644 --- a/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/api/JPAODataQueryContext.java +++ b/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/api/JPAODataQueryContext.java @@ -1,10 +1,10 @@ package com.sap.olingo.jpa.metadata.api; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.From; - import com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAEntityType; +import jakarta.persistence.criteria.CriteriaBuilder; +import jakarta.persistence.criteria.From; + public interface JPAODataQueryContext { CriteriaBuilder getCriteriaBuilder(); diff --git a/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/api/JPAAttribute.java b/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/api/JPAAttribute.java index 45836ce5a..8e7f3b13d 100644 --- a/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/api/JPAAttribute.java +++ b/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/api/JPAAttribute.java @@ -5,7 +5,6 @@ import java.util.Set; import javax.annotation.CheckForNull; -import javax.persistence.AttributeConverter; import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind; import org.apache.olingo.commons.api.edm.provider.CsdlAbstractEdmItem; @@ -13,6 +12,8 @@ import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmTransientPropertyCalculator; import com.sap.olingo.jpa.metadata.core.edm.mapper.exception.ODataJPAModelException; +import jakarta.persistence.AttributeConverter; + public interface JPAAttribute extends JPAElement, JPAAnnotatable { /** * Returns an instance of the converter defined at the attribute, in case an explicit conversion is required. That is, diff --git a/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/api/JPAEdmNameBuilder.java b/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/api/JPAEdmNameBuilder.java index 9964267be..992feed22 100644 --- a/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/api/JPAEdmNameBuilder.java +++ b/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/api/JPAEdmNameBuilder.java @@ -4,9 +4,10 @@ package com.sap.olingo.jpa.metadata.core.edm.mapper.api; import javax.annotation.Nonnull; -import javax.persistence.metamodel.Attribute; -import javax.persistence.metamodel.EmbeddableType; -import javax.persistence.metamodel.EntityType; + +import jakarta.persistence.metamodel.Attribute; +import jakarta.persistence.metamodel.EmbeddableType; +import jakarta.persistence.metamodel.EntityType; import org.apache.olingo.commons.api.edm.provider.CsdlEntityType; @@ -29,7 +30,8 @@ public interface JPAEdmNameBuilder { /** * Container names are + * href= + * "http://docs.oasis-open.org/odata/odata/v4.0/errata02/os/complete/part3-csdl/odata-v4.0-errata02-os-part3-csdl-complete.html#_SimpleIdentifier"> * Simple Identifier, * so can contain only letters, digits and underscores. * @return non empty unique name of an Entity Set @@ -39,7 +41,8 @@ public interface JPAEdmNameBuilder { /** * Create a name of an + * href= + * "http://docs.oasis-open.org/odata/odata/v4.0/errata02/os/complete/part3-csdl/odata-v4.0-errata02-os-part3-csdl-complete.html#_12.2_The_edm:EntitySet"> * Entity Set derived from the name of the corresponding entity type. * @param entityTypeName * @return non empty unique name of an Entity Set @@ -53,7 +56,8 @@ default String buildEntitySetName(final CsdlEntityType entityType) { /** * Create a name of an + * href= + * "http://docs.oasis-open.org/odata/odata/v4.0/errata02/os/complete/part3-csdl/odata-v4.0-errata02-os-part3-csdl-complete.html#_Toc406398032"> * Singleton derived from the name of the corresponding entity type. * @param entityTypeName * @return non empty unique name of a Singleton @@ -69,7 +73,8 @@ default String buildSingletonName(final CsdlEntityType entityType) { /** * Creates the name of an Entity + * href= + * "http://docs.oasis-open.org/odata/odata/v4.0/errata02/os/complete/part3-csdl/odata-v4.0-errata02-os-part3-csdl-complete.html#_Toc406397976">Entity * Type derived from JPA Entity Type. * @param jpaEntityType * @return non empty unique name of an Entity Type @@ -79,7 +84,8 @@ default String buildSingletonName(final CsdlEntityType entityType) { /** * Converts the internal java class name of an enumeration into the external entity data model + * href= + * "http://docs.oasis-open.org/odata/odata/v4.0/errata02/os/complete/part3-csdl/odata-v4.0-errata02-os-part3-csdl-complete.html#_Toc406397991"> * Enumeration Type name. * @param javaEnum * @return non empty unique name of an Enumeration diff --git a/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/extension/ODataAction.java b/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/extension/ODataAction.java index f52fd8e58..eda0565bd 100644 --- a/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/extension/ODataAction.java +++ b/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/extension/ODataAction.java @@ -7,7 +7,7 @@ *

      * An implementing class may provide one constructor having no parameter or a combination of the following: *

        - *
      • An Entity Manager: javax.persistence.EntityManager
      • + *
      • An Entity Manager: jakarta.persistence.EntityManager
      • *
      • All header: com.sap.olingo.jpa.metadata.api.JPAHttpHeaderMap
      • *
      • Access to own request parameter: com.sap.olingo.jpa.metadata.api.JPARequestParameterMap
      • *
      diff --git a/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/extension/ODataFunction.java b/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/extension/ODataFunction.java index e5ba0f14d..42571caa5 100644 --- a/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/extension/ODataFunction.java +++ b/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/extension/ODataFunction.java @@ -10,7 +10,7 @@ *

      * An implementing class may provide one constructor having no parameter or a combination of the following: *

        - *
      • An Entity Manager: javax.persistence.EntityManager
      • + *
      • An Entity Manager: jakarta.persistence.EntityManager
      • *
      • All header: com.sap.olingo.jpa.metadata.api.JPAHttpHeaderMap
      • *
      • Access to own request parameter: com.sap.olingo.jpa.metadata.api.JPARequestParameterMap
      • *
      • diff --git a/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/DefaultEdmPostProcessor.java b/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/DefaultEdmPostProcessor.java index b82bd257a..4bafd6a62 100644 --- a/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/DefaultEdmPostProcessor.java +++ b/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/DefaultEdmPostProcessor.java @@ -6,7 +6,7 @@ import com.sap.olingo.jpa.metadata.core.edm.mapper.extension.IntermediatePropertyAccess; import com.sap.olingo.jpa.metadata.core.edm.mapper.extension.IntermediateReferenceList; -final class DefaultEdmPostProcessor extends JPAEdmMetadataPostProcessor { +final class DefaultEdmPostProcessor implements JPAEdmMetadataPostProcessor{ @Override public void processNavigationProperty(final IntermediateNavigationPropertyAccess property, diff --git a/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateActionFactory.java b/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateActionFactory.java index e1b408783..7dee39b99 100644 --- a/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateActionFactory.java +++ b/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateActionFactory.java @@ -15,10 +15,10 @@ import com.sap.olingo.jpa.metadata.core.edm.mapper.extension.ODataAction; import com.sap.olingo.jpa.metadata.core.edm.mapper.extension.ODataOperation; -class IntermediateActionFactory extends IntermediateOperationFactory { +class IntermediateActionFactory implements IntermediateOperationFactory { //Description @Override - IntermediateJavaAction createOperation(final JPAEdmNameBuilder nameBuilder, final IntermediateSchema schema, + public IntermediateJavaAction createOperation(final JPAEdmNameBuilder nameBuilder, final IntermediateSchema schema, final Method method, final Object functionDescription) throws ODataJPAModelException { return new IntermediateJavaAction(nameBuilder, (EdmAction) functionDescription, method, schema); diff --git a/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateCollectionProperty.java b/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateCollectionProperty.java index 66e954982..74829f66d 100644 --- a/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateCollectionProperty.java +++ b/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateCollectionProperty.java @@ -3,18 +3,11 @@ import static com.sap.olingo.jpa.metadata.core.edm.mapper.exception.ODataJPAModelException.MessageKeys.NOT_SUPPORTED_NO_IMPLICIT_COLUMNS; import static com.sap.olingo.jpa.metadata.core.edm.mapper.exception.ODataJPAModelException.MessageKeys.NOT_SUPPORTED_NO_IMPLICIT_COLUMNS_COMPLEX; import static com.sap.olingo.jpa.metadata.core.edm.mapper.exception.ODataJPAModelException.MessageKeys.NOT_SUPPORTED_PROTECTED_COLLECTION; -import static javax.persistence.metamodel.Type.PersistenceType.EMBEDDABLE; +import static jakarta.persistence.metamodel.Type.PersistenceType.EMBEDDABLE; import java.lang.reflect.AnnotatedElement; import java.util.ArrayList; import java.util.List; -import java.util.stream.Collectors; - -import javax.persistence.CollectionTable; -import javax.persistence.JoinColumn; -import javax.persistence.metamodel.PluralAttribute; -import javax.persistence.metamodel.Type; -import javax.persistence.metamodel.Type.PersistenceType; import org.apache.olingo.commons.api.edm.FullQualifiedName; @@ -33,6 +26,12 @@ import com.sap.olingo.jpa.metadata.core.edm.mapper.exception.ODataJPAModelException; import com.sap.olingo.jpa.metadata.core.edm.mapper.exception.ODataJPAModelException.MessageKeys; +import jakarta.persistence.CollectionTable; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.metamodel.PluralAttribute; +import jakarta.persistence.metamodel.Type; +import jakarta.persistence.metamodel.Type.PersistenceType; + /** * Represents a collection property. That is a property that may occur more than once. *

        @@ -212,8 +211,8 @@ String getDefaultValue() throws ODataJPAModelException { JPAJoinTable getJoinTable() throws ODataJPAModelException { if (joinTable == null) { - final javax.persistence.CollectionTable jpaJoinTable = ((AnnotatedElement) this.jpaAttribute.getJavaMember()) - .getAnnotation(javax.persistence.CollectionTable.class); + final jakarta.persistence.CollectionTable jpaJoinTable = ((AnnotatedElement) this.jpaAttribute.getJavaMember()) + .getAnnotation(jakarta.persistence.CollectionTable.class); joinTable = jpaJoinTable != null ? new IntermediateCollectionTable(jpaJoinTable, schema) : null; } return joinTable; @@ -330,14 +329,14 @@ else if (!(contextType instanceof IntermediateEntityType)) public List getRightColumnsList() throws ODataJPAModelException { return getJoinColumns().stream() .map(JPAOnConditionItem::getRightPath) - .collect(Collectors.toList()); + .toList(); } @Override public List getLeftColumnsList() throws ODataJPAModelException { return getJoinColumns().stream() .map(JPAOnConditionItem::getLeftPath) - .collect(Collectors.toList()); + .toList(); } } } \ No newline at end of file diff --git a/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateComplexType.java b/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateComplexType.java index dd2b3cb7d..8be651374 100644 --- a/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateComplexType.java +++ b/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateComplexType.java @@ -1,7 +1,5 @@ package com.sap.olingo.jpa.metadata.core.edm.mapper.impl; -import javax.persistence.metamodel.EmbeddableType; - import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.olingo.commons.api.edm.provider.CsdlComplexType; @@ -9,6 +7,8 @@ import com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAEdmNameBuilder; import com.sap.olingo.jpa.metadata.core.edm.mapper.exception.ODataJPAModelException; +import jakarta.persistence.metamodel.EmbeddableType; + /** * Complex Types are used to structure Entity Types by grouping properties that belong together. Complex Types can * contain of diff --git a/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateDescriptionProperty.java b/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateDescriptionProperty.java index f80993248..b749b4533 100644 --- a/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateDescriptionProperty.java +++ b/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateDescriptionProperty.java @@ -11,10 +11,6 @@ import java.util.Map; import java.util.Optional; -import javax.persistence.JoinColumn; -import javax.persistence.JoinColumns; -import javax.persistence.metamodel.Attribute; - import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmDescriptionAssociation; import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmDescriptionAssociation.valueAssignment; import com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAAssociationAttribute; @@ -30,6 +26,10 @@ import com.sap.olingo.jpa.metadata.core.edm.mapper.exception.ODataJPAModelException; import com.sap.olingo.jpa.metadata.core.edm.mapper.exception.ODataJPAModelException.MessageKeys; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.JoinColumns; +import jakarta.persistence.metamodel.Attribute; + final class IntermediateDescriptionProperty extends IntermediateSimpleProperty implements JPADescriptionAttribute, JPAAssociationAttribute { private IntermediateSimpleProperty descriptionProperty; @@ -87,9 +87,8 @@ protected synchronized void lazyBuildEdmItem() throws ODataJPAModelException { if (this.edmProperty == null) { super.lazyBuildEdmItem(); - if (jpaMember instanceof AnnotatedElement) { - final EdmDescriptionAssociation association = ((AnnotatedElement) jpaMember).getAnnotation( - EdmDescriptionAssociation.class); + if (jpaMember instanceof final AnnotatedElement annotatedElement) { + final EdmDescriptionAssociation association = annotatedElement.getAnnotation(EdmDescriptionAssociation.class); if (association != null) { // determine generic type of a collection in case of an OneToMany association determineTargetEntityType(jpaMember); @@ -129,8 +128,7 @@ private void checkConsistencyOfLocalInfo(final String languageAttribute) throws } private void determineTargetEntityType(final Member jpaMember) { - if (jpaMember instanceof Field) { - final Field jpaField = (Field) jpaMember; + if (jpaMember instanceof final Field jpaField) { final ParameterizedType jpaTargetEntityType = (ParameterizedType) jpaField.getGenericType(); if (jpaTargetEntityType != null) targetEntity = schema.getEntityType((Class) jpaTargetEntityType.getActualTypeArguments()[0]); @@ -158,9 +156,9 @@ private JPAPath convertAttributeToPath(final String attribute) throws ODataJPAMo } return new JPAPathImpl(nextHop.getExternalName(), nextHop.getDBFieldName(), targetPath); } else { - final IntermediateSimpleProperty p = (IntermediateSimpleProperty) targetEntity.getAttribute(attribute) + final IntermediateSimpleProperty property = (IntermediateSimpleProperty) targetEntity.getAttribute(attribute) .orElseThrow(() -> new ODataJPAModelException(MessageKeys.PATH_ELEMENT_NOT_FOUND, pathItems[0], attribute)); - return new JPAPathImpl(p.getExternalName(), p.getDBFieldName(), p); + return new JPAPathImpl(property.getExternalName(), property.getDBFieldName(), property); } } @@ -278,9 +276,9 @@ private List buildJoinColumnsFromAnnotations(final boole if (columns != null) { for (final JoinColumn column : columns) { final IntermediateJoinColumn intermediateColumn = new IntermediateJoinColumn(column); - final String refColumnName = intermediateColumn.getReferencedColumnName(); + final String referencedColumnName = intermediateColumn.getReferencedColumnName(); final String name = intermediateColumn.getName(); - if (refColumnName == null || refColumnName.isEmpty() || name == null || name.isEmpty()) { + if (referencedColumnName == null || referencedColumnName.isEmpty() || name == null || name.isEmpty()) { implicitColumns += 1; if (implicitColumns > 1) throw new ODataJPAModelException(ODataJPAModelException.MessageKeys.NOT_SUPPORTED_NO_IMPLICIT_COLUMNS, @@ -303,10 +301,10 @@ private List buildJoinColumnsFromAnnotations(final boole private void fillMissingName(final boolean isSourceOne, final IntermediateJoinColumn intermediateColumn) throws ODataJPAModelException { - final String refColumnName = intermediateColumn.getReferencedColumnName(); + final String referencedColumnName = intermediateColumn.getReferencedColumnName(); final String name = intermediateColumn.getName(); - if (isSourceOne && (emptyString(refColumnName))) + if (isSourceOne && (emptyString(referencedColumnName))) intermediateColumn.setReferencedColumnName( ((IntermediateSimpleProperty) ((IntermediateEntityType) sourceType) .getKey().get(0)).getDBFieldName()); @@ -314,7 +312,7 @@ else if (isSourceOne && (emptyString(name))) intermediateColumn.setReferencedColumnName( ((IntermediateSimpleProperty) ((IntermediateEntityType) targetEntity) .getKey().get(0)).getDBFieldName()); - else if (!isSourceOne && (emptyString(refColumnName))) + else if (!isSourceOne && (emptyString(referencedColumnName))) intermediateColumn.setReferencedColumnName( ((IntermediateSimpleProperty) ((IntermediateEntityType) targetEntity) .getKey().get(0)).getDBFieldName()); diff --git a/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateEmbeddedIdProperty.java b/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateEmbeddedIdProperty.java index dfe037e2e..7ccec97f8 100644 --- a/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateEmbeddedIdProperty.java +++ b/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateEmbeddedIdProperty.java @@ -4,12 +4,12 @@ import java.lang.reflect.AnnotatedElement; -import javax.persistence.metamodel.Attribute; - import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmTransient; import com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAEdmNameBuilder; import com.sap.olingo.jpa.metadata.core.edm.mapper.exception.ODataJPAModelException; +import jakarta.persistence.metamodel.Attribute; + final class IntermediateEmbeddedIdProperty extends IntermediateSimpleProperty { IntermediateEmbeddedIdProperty(final JPAEdmNameBuilder nameBuilder, final Attribute jpaAttribute, diff --git a/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateEntityType.java b/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateEntityType.java index 1e4b1e69d..74142c08c 100644 --- a/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateEntityType.java +++ b/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateEntityType.java @@ -1,7 +1,5 @@ package com.sap.olingo.jpa.metadata.core.edm.mapper.impl; -import static com.sap.olingo.jpa.metadata.core.edm.mapper.exception.ODataJPAModelException.MessageKeys.INVALID_TOP_LEVEL_SETTING; - import java.lang.annotation.Annotation; import java.lang.reflect.AnnotatedElement; import java.lang.reflect.Field; @@ -15,17 +13,8 @@ import java.util.Map; import java.util.Map.Entry; import java.util.Optional; -import java.util.stream.Collectors; import javax.annotation.Nonnull; -import javax.persistence.IdClass; -import javax.persistence.Table; -import javax.persistence.metamodel.EmbeddableType; -import javax.persistence.metamodel.EntityType; -import javax.persistence.metamodel.IdentifiableType; -import javax.persistence.metamodel.ManagedType; -import javax.persistence.metamodel.MappedSuperclassType; -import javax.persistence.metamodel.Type; import org.apache.olingo.commons.api.edm.provider.CsdlAbstractEdmItem; import org.apache.olingo.commons.api.edm.provider.CsdlAnnotation; @@ -34,7 +23,6 @@ import org.apache.olingo.commons.api.edm.provider.CsdlPropertyRef; import org.apache.olingo.server.api.uri.UriResourceProperty; -import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmAsEntitySet; import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmEntityType; import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmQueryExtensionProvider; import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmTopLevelElementRepresentation; @@ -49,6 +37,15 @@ import com.sap.olingo.jpa.metadata.core.edm.mapper.exception.ODataJPAModelException; import com.sap.olingo.jpa.metadata.core.edm.mapper.extension.IntermediateEntityTypeAccess; +import jakarta.persistence.IdClass; +import jakarta.persistence.Table; +import jakarta.persistence.metamodel.EmbeddableType; +import jakarta.persistence.metamodel.EntityType; +import jakarta.persistence.metamodel.IdentifiableType; +import jakarta.persistence.metamodel.ManagedType; +import jakarta.persistence.metamodel.MappedSuperclassType; +import jakarta.persistence.metamodel.Type; + /** * getAttribute(final UriResourceProperty uriResource @Override public JPACollectionAttribute getCollectionAttribute(final String externalName) throws ODataJPAModelException { final JPAPath path = getPath(externalName); - if (path != null && path.getLeaf() instanceof JPACollectionAttribute) - return (JPACollectionAttribute) path.getLeaf(); + if (path != null && path.getLeaf() instanceof final JPACollectionAttribute collectionAttribute) + return collectionAttribute; return null; } @@ -160,7 +157,7 @@ public List getKey() throws ODataJPAModelException { .map(ManagedType::getJavaType) .map(Class::getDeclaredFields) .flatMap(Arrays::stream) - .collect(Collectors.toList())); + .toList()); final IntermediateStructuredType baseType = getBaseType(); if (baseType != null) { @@ -292,12 +289,11 @@ protected List extractEdmModelElements( for (final IntermediateModelElement element : mappingBuffer.values()) { if (!element.ignore() // Skip Streams - && !(element instanceof IntermediateSimpleProperty && - ((IntermediateSimpleProperty) element).isStream())) { - if (element instanceof IntermediateEmbeddedIdProperty) { - extractionTarget.addAll((Collection) resolveEmbeddedId( - (IntermediateEmbeddedIdProperty) element)); - } else { + && !(element instanceof final IntermediateSimpleProperty simpleProperty + && simpleProperty.isStream())) { + if (element instanceof final IntermediateEmbeddedIdProperty embeddedId) { + extractionTarget.addAll((Collection) resolveEmbeddedId(embeddedId)); + } else { extractionTarget.add((I) element.getEdmItem()); } } @@ -326,7 +322,6 @@ protected synchronized void lazyBuildEdmItem() throws ODataJPAModelException { ((CsdlEntityType) edmStructuralType).setHasStream(determineHasStream()); edmStructuralType.setAnnotations(determineAnnotations()); determineHasEtag(); - checkTopLevelTypeConsistency(); checkPropertyConsistency(); // // TODO determine OpenType } @@ -396,7 +391,7 @@ List extractEdmKeyElements() throws ODataJPAModelException { return getKey().stream() .map(this::asPropertyRef) - .collect(Collectors.toList()); + .toList(); } @Override @@ -447,23 +442,14 @@ private List buildEmbeddedIdKey(final JPAAttribute attribute) thro return keyElements; } - private void checkTopLevelTypeConsistency() throws ODataJPAModelException { - final Optional jpaAsEntitySet = getAnnotation(jpaJavaType, EdmAsEntitySet.class); - final Optional jpaEntityType = getAnnotation(jpaJavaType, EdmEntityType.class); - if (jpaAsEntitySet.isPresent() && jpaEntityType.isPresent()) - throw new ODataJPAModelException(INVALID_TOP_LEVEL_SETTING, getInternalName()); - } - private List determineAnnotations() throws ODataJPAModelException { getAnnotations(edmAnnotations, this.jpaManagedType.getJavaType(), internalName); return edmAnnotations; } private boolean determineAsEntitySet() { - final Optional jpaAsEntitySet = getAnnotation(jpaJavaType, EdmAsEntitySet.class); final Optional jpaEntityType = getAnnotation(jpaJavaType, EdmEntityType.class); - return jpaAsEntitySet.isPresent() - || !jpaEntityType.isPresent() + return !jpaEntityType.isPresent() || jpaEntityType.get().as() == EdmTopLevelElementRepresentation.AS_ENTITY_SET || jpaEntityType.get().as() == EdmTopLevelElementRepresentation.AS_ENTITY_SET_ONLY; } @@ -475,12 +461,10 @@ private boolean determineAsSingleton() { } private boolean determineAsTopLevelOnly() { - final Optional jpaAsEntitySet = getAnnotation(jpaJavaType, EdmAsEntitySet.class); final Optional jpaEntityType = getAnnotation(jpaJavaType, EdmEntityType.class); - return jpaAsEntitySet.isPresent() - || (jpaEntityType.isPresent() - && (jpaEntityType.get().as() == EdmTopLevelElementRepresentation.AS_ENTITY_SET_ONLY - || jpaEntityType.get().as() == EdmTopLevelElementRepresentation.AS_SINGLETON_ONLY)); + return (jpaEntityType.isPresent() + && (jpaEntityType.get().as() == EdmTopLevelElementRepresentation.AS_ENTITY_SET_ONLY + || jpaEntityType.get().as() == EdmTopLevelElementRepresentation.AS_SINGLETON_ONLY)); } @SuppressWarnings("unchecked") diff --git a/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateEnumerationType.java b/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateEnumerationType.java index d5a12f58e..b2a531c4d 100644 --- a/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateEnumerationType.java +++ b/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateEnumerationType.java @@ -6,8 +6,6 @@ import java.util.Arrays; import java.util.List; -import javax.persistence.AttributeConverter; - import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind; import org.apache.olingo.commons.api.edm.FullQualifiedName; import org.apache.olingo.commons.api.edm.provider.CsdlEnumMember; @@ -20,6 +18,8 @@ import com.sap.olingo.jpa.metadata.core.edm.mapper.exception.ODataJPAModelException; import com.sap.olingo.jpa.metadata.core.edm.mapper.exception.ODataJPAModelException.MessageKeys; +import jakarta.persistence.AttributeConverter; + class IntermediateEnumerationType extends IntermediateModelElement implements JPAEnumerationAttribute { private CsdlEnumType edmEnumType; diff --git a/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateFunctionFactory.java b/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateFunctionFactory.java index 6615210bf..ecffd6fb6 100644 --- a/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateFunctionFactory.java +++ b/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateFunctionFactory.java @@ -5,8 +5,6 @@ import java.util.HashMap; import java.util.Map; -import javax.persistence.metamodel.EntityType; - import org.reflections8.Reflections; import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmFunction; @@ -15,7 +13,9 @@ import com.sap.olingo.jpa.metadata.core.edm.mapper.exception.ODataJPAModelException; import com.sap.olingo.jpa.metadata.core.edm.mapper.extension.ODataFunction; -final class IntermediateFunctionFactory extends IntermediateOperationFactory { +import jakarta.persistence.metamodel.EntityType; + +final class IntermediateFunctionFactory implements IntermediateOperationFactory { /** * Creates all functions declared at on entity type @@ -55,7 +55,7 @@ Map create(final JPAEdmNameBuilder nameBuilder, @SuppressWarnings("unchecked") @Override - F createOperation(final JPAEdmNameBuilder nameBuilder, final IntermediateSchema schema, + public F createOperation(final JPAEdmNameBuilder nameBuilder, final IntermediateSchema schema, final Method method, final Object functionDescription) throws ODataJPAModelException { return (F) new IntermediateJavaFunction(nameBuilder, (EdmFunction) functionDescription, method, schema); diff --git a/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateJoinColumn.java b/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateJoinColumn.java index 16f73d304..21e27c525 100644 --- a/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateJoinColumn.java +++ b/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateJoinColumn.java @@ -1,6 +1,6 @@ package com.sap.olingo.jpa.metadata.core.edm.mapper.impl; -import javax.persistence.JoinColumn; +import jakarta.persistence.JoinColumn; import com.sap.olingo.jpa.metadata.api.JPAJoinColumn; diff --git a/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateJoinTable.java b/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateJoinTable.java index d08a8abc1..b4978ab50 100644 --- a/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateJoinTable.java +++ b/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateJoinTable.java @@ -5,10 +5,6 @@ import java.util.ArrayList; import java.util.List; import java.util.Optional; -import java.util.stream.Collectors; - -import javax.persistence.JoinColumn; -import javax.persistence.JoinTable; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -20,6 +16,9 @@ import com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAPath; import com.sap.olingo.jpa.metadata.core.edm.mapper.exception.ODataJPAModelException; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.JoinTable; + class IntermediateJoinTable implements JPAJoinTable { private static final Log LOGGER = LogFactory.getLog(IntermediateJoinTable.class); @@ -103,7 +102,7 @@ public List getJoinColumns() throws ODataJPAModelException { public List getRightColumnsList() throws ODataJPAModelException { return getInverseJoinColumns().stream() .map(JPAOnConditionItem::getRightPath) - .collect(Collectors.toList()); + .toList(); } @Override @@ -111,7 +110,7 @@ public List getLeftColumnsList() throws ODataJPAModelException { return getJoinColumns().stream() .map(JPAOnConditionItem::getLeftPath) - .collect(Collectors.toList()); + .toList(); } @SuppressWarnings("unchecked") diff --git a/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateModelElement.java b/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateModelElement.java index bb7994adb..f31f62471 100644 --- a/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateModelElement.java +++ b/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateModelElement.java @@ -139,8 +139,8 @@ protected String returnNullIfEmpty(final String value) { */ protected void getAnnotations(final List edmAnnotations, final Member member, final String internalName) throws ODataJPAModelException { - if (member instanceof AnnotatedElement) { - extractAnnotations(edmAnnotations, (AnnotatedElement) member, internalName); + if (member instanceof final AnnotatedElement annotatedElement) { + extractAnnotations(edmAnnotations, annotatedElement, internalName); } } diff --git a/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateNavigationProperty.java b/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateNavigationProperty.java index 61ecff487..cab09edff 100644 --- a/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateNavigationProperty.java +++ b/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateNavigationProperty.java @@ -1,709 +1,710 @@ -package com.sap.olingo.jpa.metadata.core.edm.mapper.impl; - -import static com.sap.olingo.jpa.metadata.core.edm.mapper.exception.ODataJPAModelException.MessageKeys.MISSING_ONE_TO_ONE_ANNOTATION; -import static com.sap.olingo.jpa.metadata.core.edm.mapper.exception.ODataJPAModelException.MessageKeys.REFERENCED_PROPERTY_NOT_FOUND; - -import java.lang.reflect.AnnotatedElement; -import java.lang.reflect.Constructor; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Locale; -import java.util.Optional; -import java.util.Set; - -import javax.annotation.CheckForNull; -import javax.persistence.AssociationOverride; -import javax.persistence.AttributeConverter; -import javax.persistence.CascadeType; -import javax.persistence.JoinColumn; -import javax.persistence.JoinColumns; -import javax.persistence.ManyToMany; -import javax.persistence.ManyToOne; -import javax.persistence.OneToMany; -import javax.persistence.OneToOne; -import javax.persistence.metamodel.Attribute; -import javax.persistence.metamodel.Attribute.PersistentAttributeType; -import javax.persistence.metamodel.PluralAttribute; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind; -import org.apache.olingo.commons.api.edm.provider.CsdlAnnotation; -import org.apache.olingo.commons.api.edm.provider.CsdlNavigationProperty; -import org.apache.olingo.commons.api.edm.provider.CsdlOnDelete; -import org.apache.olingo.commons.api.edm.provider.CsdlOnDeleteAction; -import org.apache.olingo.commons.api.edm.provider.CsdlReferentialConstraint; - -import com.sap.olingo.jpa.metadata.api.JPAJoinColumn; -import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmIgnore; -import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmProtectedBy; -import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmTransientPropertyCalculator; -import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmVisibleFor; -import com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAAssociationAttribute; -import com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAAssociationPath; -import com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAEdmNameBuilder; -import com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAJoinTable; -import com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAStructuredType; -import com.sap.olingo.jpa.metadata.core.edm.mapper.exception.ODataJPAModelException; -import com.sap.olingo.jpa.metadata.core.edm.mapper.exception.ODataJPAModelException.MessageKeys; -import com.sap.olingo.jpa.metadata.core.edm.mapper.exception.ODataJPAModelIgnoreException; -import com.sap.olingo.jpa.metadata.core.edm.mapper.extension.IntermediateNavigationPropertyAccess; - -/** - * A navigation property describes a relation of one entity type to another entity type and allows to navigate to it. - * IntermediateNavigationProperty represents a navigation within on service, that is source and target are described by - * the same service document. - * OData Version 4.0 Part 3 - 7 Navigation Property - * @author Oliver Grande - * @param Type of the parent the navigation belongs to, also called source type - */ -final class IntermediateNavigationProperty extends IntermediateModelElement implements - IntermediateNavigationPropertyAccess, JPAAssociationAttribute { - - private static final Log LOGGER = LogFactory.getLog(IntermediateNavigationProperty.class); - - private final Attribute jpaAttribute; - private CsdlNavigationProperty edmNaviProperty; - private CsdlOnDelete edmOnDelete; - private final IntermediateStructuredType sourceType; - private IntermediateStructuredType targetType; - private JPAAssociationAttribute partner; - private IntermediateJoinTable joinTable; - private final IntermediateSchema schema; - private final List joinColumns = new ArrayList<>(); - private final List requiredDbColumns = new ArrayList<>(); - private PersistentAttributeType cardinality; - private Optional mappedBy; - - IntermediateNavigationProperty(final JPAEdmNameBuilder nameBuilder, final IntermediateStructuredType parent, - final Attribute jpaAttribute, final IntermediateSchema schema) throws ODataJPAModelException { - super(nameBuilder, InternalNameBuilder.buildAssociationName(jpaAttribute), schema.getAnnotationInformation()); - this.jpaAttribute = jpaAttribute; - this.schema = schema; - this.sourceType = parent; - buildNaviProperty(); - } - - @Override - public void addAnnotations(final List annotations) { - edmAnnotations.addAll(annotations); - } - - @Override - public > Constructor getCalculatorConstructor() { - return null; - } - - @Override - public AttributeConverter getConverter() { - return null; - } - - @Override - public Class getDbType() { - return null; - } - - @Override - public Class getJavaType() { - return null; - } - - @Override - public EdmPrimitiveTypeKind getEdmType() { - return null; - } - - public JPAJoinTable getJoinTable() { - return joinTable; - } - - @Override - public JPAAssociationAttribute getPartner() { - return partner; - } - - @Override - public JPAAssociationPath getPath() throws ODataJPAModelException { - return getStructuredType().getAssociationPath(getExternalName()); - } - - @Override - public CsdlNavigationProperty getProperty() throws ODataJPAModelException { - return getEdmItem(); - - } - - @Override - public Set getProtectionClaimNames() { - return new HashSet<>(0); - } - - @Override - public List getProtectionPath(final String claimName) throws ODataJPAModelException { - return new ArrayList<>(0); - } - - @Override - public AttributeConverter getRawConverter() { - return null; - } - - @Override - public List getRequiredProperties() { - return Collections.emptyList(); - } - - @Override - public JPAStructuredType getStructuredType() throws ODataJPAModelException { - if (edmNaviProperty == null) { - lazyBuildEdmItem(); - } - return sourceType; - } - - @Override - public JPAStructuredType getTargetEntity() throws ODataJPAModelException { - if (edmNaviProperty == null) { - lazyBuildEdmItem(); - } - return targetType; - } - - @Override - public Class getType() { - return jpaAttribute.getJavaType(); - } - - @Override - public boolean hasProtection() { - return false; - } - - @Override - public boolean isAssociation() { - return true; - } - - @Override - public boolean isCollection() { - return jpaAttribute.isCollection(); - } - - @Override - public boolean isComplex() { - return false; - } - - @Override - public boolean isEnum() { - return false; - } - - @Override - public boolean isEtag() { - return false; - } - - @Override - public boolean isKey() { - return false; - } - - @Override - public boolean isSearchable() { - return false; - } - - @Override - public boolean isTransient() { - return false; - } - - @Override - public void setOnDelete(final CsdlOnDelete onDelete) { - edmOnDelete = onDelete; - } - - @Override - public String toString() { - return getExternalName() + ": [sourceType=" + sourceType + ", targetType=" + targetType - + ", partner=" + partnerToString() + ", joinTable=" + joinTable + "]"; - } - - private String partnerToString() { - return partner == null ? "null" : partner.getExternalName(); - } - - @Override - protected synchronized void lazyBuildEdmItem() throws ODataJPAModelException { - if (edmNaviProperty == null) { - edmNaviProperty = new CsdlNavigationProperty(); - edmNaviProperty.setName(getExternalName()); - edmNaviProperty.setType(buildFQN(targetType.getExternalName())); - edmNaviProperty.setCollection(jpaAttribute.isCollection()); - edmNaviProperty.setAnnotations(edmAnnotations); - // Optional --> RelationAnnotation - determineMappedBy(); - buildJoinConditionInfo(); - // TODO determine ContainsTarget - determinePartner(); - } - } - - @Override - CsdlNavigationProperty getEdmItem() throws ODataJPAModelException { - if (edmNaviProperty == null) { - lazyBuildEdmItem(); - } - return edmNaviProperty; - } - - @Override - public CsdlAnnotation getAnnotation(final String alias, final String term) throws ODataJPAModelException { - return filterAnnotation(alias, term); - } - - PersistentAttributeType getJoinCardinality() { - return jpaAttribute.getPersistentAttributeType(); - } - - @SuppressWarnings("unchecked") - List getJoinColumns() throws ODataJPAModelException { - if (joinColumns.isEmpty()) { - lazyBuildEdmItem(); - buildJoinConditionInfo(); - } - return (List) joinColumns; - } - - List getRequiredDbColumns() throws ODataJPAModelException { - if (edmNaviProperty == null) - lazyBuildEdmItem(); - if (requiredDbColumns.isEmpty()) { - for (final IntermediateJoinColumn joinColumn : joinColumns) { - requiredDbColumns.add(joinColumn.getName()); - } - } - return requiredDbColumns; - } - - IntermediateStructuredType getSourceType() { - return sourceType; - } - - boolean isMapped() { - return mappedBy.isPresent(); - } - - /** - * In case the column name is not given at an association a default name is generated according to the JPA standard. - * The default name will be <association name>_<target key name>, all upper case. - * @param annotatedElement - * @param isSourceOne - * @return - * @throws ODataJPAModelException - */ - private String buildDefaultName(final boolean isSourceOne) throws ODataJPAModelException { - - final StringBuilder columnName = new StringBuilder(jpaAttribute.getName()); - columnName.append('_'); - if (isSourceOne) - columnName.append(((IntermediateSimpleProperty) ((IntermediateEntityType) targetType) - .getKey().get(0)).getDBFieldName()); - else - columnName.append(((IntermediateSimpleProperty) ((IntermediateEntityType) sourceType) - .getKey().get(0)).getDBFieldName()); - return columnName.toString().replace("\"", "").toUpperCase(Locale.ENGLISH); - } - - private IntermediateJoinColumn buildImplicitJoinColumnPair(final boolean isSourceOne) throws ODataJPAModelException { - final IntermediateJoinColumn intermediateColumn = new IntermediateJoinColumn(buildDefaultName(isSourceOne), - fillMissingName()); - if (LOGGER.isTraceEnabled()) - LOGGER.trace(getExternalName() + ": Add join condition with default name = " + intermediateColumn.toString()); - return intermediateColumn; - } - - private void buildJoinColumnPairList(final boolean isSourceOne, int implicitColumns, - final List result, final JoinColumn[] columns) throws ODataJPAModelException { - for (final JoinColumn column : columns) { - final String refColumnName = column.referencedColumnName(); - final String name = column.name(); - result.add(buildOneJoinColumnPair(isSourceOne, column)); - if (refColumnName == null || refColumnName.isEmpty() || name == null || name.isEmpty()) { - implicitColumns += 1; - if (implicitColumns > 1) - throw new ODataJPAModelException(ODataJPAModelException.MessageKeys.NOT_SUPPORTED_NO_IMPLICIT_COLUMNS, - getInternalName()); - } - } - } - - private void buildJoinColumns(final boolean isSourceOne, final AnnotatedElement annotatedElement) - throws ODataJPAModelException { - - joinColumns.clear(); - final List columns; - if (mappedBy.isPresent()) { - joinTable = ((IntermediateJoinTable) ((IntermediateNavigationProperty) targetType.getAssociation( - mappedBy.get())).getJoinTable()); - if (joinTable == null) - columns = buildJoinColumnsMapped(mappedBy.get()); - else - columns = joinTable.buildInverseJoinColumns(); - joinTable = joinTable == null ? null : joinTable.asMapped(this); - } else { - if (joinTable == null) - columns = buildJoinColumnsFromAnnotations(isSourceOne, annotatedElement); - else - columns = joinTable.buildJoinColumns(); - } - joinColumns.clear(); - joinColumns.addAll(columns); - } - - private List buildJoinColumnsFromAnnotations(final boolean isSourceOne, - final AnnotatedElement annotatedElement) throws ODataJPAModelException { - - final int implicitColumns = 0; - final List result = new ArrayList<>(); - final JoinColumn[] columns = annotatedElement.getAnnotation(JoinColumns.class) != null ? annotatedElement - .getAnnotation(JoinColumns.class).value() : null; - - if (columns != null) { - buildJoinColumnPairList(isSourceOne, implicitColumns, result, columns); - } else { - final JoinColumn column = annotatedElement.getAnnotation(JoinColumn.class); - if (column != null) { - result.add(buildOneJoinColumnPair(isSourceOne, column)); - } else { - // No explicit Join Columns given: Build implicit one. - result.add(buildImplicitJoinColumnPair(isSourceOne)); - } - } - return result; - } - - private List buildJoinColumnsMapped(final String mappedBy) throws ODataJPAModelException { - - int implicitColumns = 0; - final List result = invertJoinColumns(targetType.getJoinColumns(mappedBy)); - for (final IntermediateJoinColumn intermediateColumn : result) { - final String columnName = intermediateColumn.getName(); - if (columnName == null || columnName.isEmpty()) { - implicitColumns += 1; - if (implicitColumns > 1) - throw new ODataJPAModelException(ODataJPAModelException.MessageKeys.NOT_SUPPORTED_NO_IMPLICIT_COLUMNS, - getInternalName()); - intermediateColumn.setName(((IntermediateProperty) ((IntermediateEntityType) sourceType) - .getKey().get(0)).getDBFieldName()); - } - } - return result; - } - - private void buildJoinConditionInfo() throws ODataJPAModelException { - - if (jpaAttribute.getJavaMember() instanceof AnnotatedElement - && joinColumns.isEmpty()) { - final AnnotatedElement annotatedElement = (AnnotatedElement) jpaAttribute.getJavaMember(); -// Determine referential constraint - final boolean isOwner = !mappedBy.isPresent(); - buildJoinColumns(isOwner, annotatedElement); - determineReferentialConstraints(annotatedElement); - } - } - - private void buildNaviProperty() throws ODataJPAModelException { - - this.setExternalName(nameBuilder.buildNaviPropertyName(jpaAttribute)); - - evaluateAnnotation(); - - targetType = schema.getEntityType(determineTargetClass()); - if (targetType == null) - throw new ODataJPAModelException(ODataJPAModelException.MessageKeys.NAVI_PROPERTY_NOT_FOUND, - jpaAttribute.getName(), sourceType.internalName); - - postProcessor.processNavigationProperty(this, jpaAttribute.getDeclaringType().getJavaType() - .getCanonicalName()); - // Process annotations after post processing, as external name could have been changed - getAnnotations(edmAnnotations, this.jpaAttribute.getJavaMember(), internalName); - - checkConsistency(); - if (LOGGER.isTraceEnabled()) - LOGGER.trace(toString()); - } - - private void evaluateAnnotation() throws ODataJPAModelException { - - if (this.jpaAttribute.getJavaMember() instanceof AnnotatedElement) { - final EdmIgnore jpaIgnore = ((AnnotatedElement) this.jpaAttribute.getJavaMember()).getAnnotation( - EdmIgnore.class); - if (jpaIgnore != null) { - this.setIgnore(true); - } - final javax.persistence.JoinTable jpaJoinTable = ((AnnotatedElement) this.jpaAttribute.getJavaMember()) - .getAnnotation(javax.persistence.JoinTable.class); - joinTable = jpaJoinTable != null ? new IntermediateJoinTable(this, jpaJoinTable, schema) : null; - - final AnnotatedElement annotatedElement = (AnnotatedElement) jpaAttribute.getJavaMember(); - cardinality = jpaAttribute.getPersistentAttributeType(); - if (cardinality != null) { - switch (cardinality) { - case ONE_TO_MANY: - // Association '%1$s' of '%2$s' requires a cardinality annotation. - final OneToMany oneTOMany = Optional.ofNullable(annotatedElement.getAnnotation(OneToMany.class)) - .orElseThrow(() -> new ODataJPAModelException(MISSING_ONE_TO_ONE_ANNOTATION, internalName, sourceType - .getInternalName())); - mappedBy = Optional.ofNullable(returnNullIfEmpty(oneTOMany.mappedBy())); - break; - case ONE_TO_ONE: - // Association '%1$s' of '%2$s' requires a cardinality annotation. - final OneToOne oneToOne = Optional.ofNullable(annotatedElement.getAnnotation(OneToOne.class)) - .orElseThrow(() -> new ODataJPAModelException(MISSING_ONE_TO_ONE_ANNOTATION, internalName, sourceType - .getInternalName())); - mappedBy = Optional.ofNullable(returnNullIfEmpty(oneToOne.mappedBy())); - break; - case MANY_TO_MANY: - mappedBy = Optional.ofNullable(returnNullIfEmpty( - annotatedElement.getAnnotation(ManyToMany.class).mappedBy())); - break; - default: - mappedBy = Optional.empty(); - } - } else { - mappedBy = Optional.empty(); - } - } - } - - private Class determineTargetClass() { - Class targetClass = null; - if (jpaAttribute.isCollection()) { - targetClass = ((PluralAttribute) jpaAttribute).getElementType().getJavaType(); - } else { - targetClass = jpaAttribute.getJavaType(); - } - return targetClass; - } - - private IntermediateJoinColumn buildOneJoinColumnPair(final boolean isSourceOne, final JoinColumn column) - throws ODataJPAModelException { - IntermediateJoinColumn intermediateColumn = new IntermediateJoinColumn(column); - if (cardinality == PersistentAttributeType.ONE_TO_MANY) - intermediateColumn = new IntermediateJoinColumn(intermediateColumn.getReferencedColumnName(), - intermediateColumn.getName()); - fillMissingName(isSourceOne, intermediateColumn); - if (LOGGER.isTraceEnabled()) - LOGGER.trace(getExternalName() + ": Add join condition = " + intermediateColumn.toString()); - return intermediateColumn; - } - - private void checkConsistency() throws ODataJPAModelException { - final EdmProtectedBy jpaProtectedBy = ((AnnotatedElement) this.jpaAttribute.getJavaMember()) - .getAnnotation(EdmProtectedBy.class); - if (jpaProtectedBy != null) { - // Navigation Properties do not support EdmProtectedBy - throw new ODataJPAModelException(MessageKeys.NOT_SUPPORTED_PROTECTED_NAVIGATION, this.sourceType.getTypeClass() - .getCanonicalName(), this.internalName); - } - final EdmVisibleFor jpaFieldGroups = ((AnnotatedElement) this.jpaAttribute.getJavaMember()) - .getAnnotation(EdmVisibleFor.class); - if (jpaFieldGroups != null) { - throw new ODataJPAModelException(MessageKeys.NOT_SUPPORTED_NAVIGATION_PART_OF_GROUP, - this.sourceType.getTypeClass().getCanonicalName(), this.internalName); - } - } - - @CheckForNull - private void determineMappedBy() { - - if (jpaAttribute.getJavaMember() instanceof AnnotatedElement) { - final AnnotatedElement annotatedElement = (AnnotatedElement) jpaAttribute.getJavaMember(); - cardinality = jpaAttribute.getPersistentAttributeType(); - switch (cardinality) { - case ONE_TO_MANY: - final OneToMany cardinalityOtM = annotatedElement.getAnnotation(OneToMany.class); - edmNaviProperty.setOnDelete(edmOnDelete != null ? edmOnDelete : setJPAOnDelete(cardinalityOtM.cascade())); - break; - case ONE_TO_ONE: - final OneToOne cardinalityOtO = annotatedElement.getAnnotation(OneToOne.class); - edmNaviProperty.setNullable(cardinalityOtO.optional()); - edmNaviProperty.setOnDelete(edmOnDelete != null ? edmOnDelete : setJPAOnDelete(cardinalityOtO.cascade())); - break; - case MANY_TO_ONE: - final ManyToOne cardinalityMtO = annotatedElement.getAnnotation(ManyToOne.class); - edmNaviProperty.setNullable(cardinalityMtO.optional()); - edmNaviProperty.setOnDelete(edmOnDelete != null ? edmOnDelete : setJPAOnDelete(cardinalityMtO.cascade())); - break; - case MANY_TO_MANY: - final ManyToMany cardinalityMtM = annotatedElement.getAnnotation(ManyToMany.class); - edmNaviProperty.setOnDelete(edmOnDelete != null ? edmOnDelete : setJPAOnDelete(cardinalityMtM.cascade())); - break; - default: - break; - } - } - } - - private void determinePartner() throws ODataJPAModelException { - if (sourceType instanceof IntermediateEntityType) { - // Partner Attribute must not be defined at Complex Types. - // JPA bi-directional associations are defined at both sides, e.g. - // at the BusinessPartner and at the Roles. JPA only defines the - // "mappedBy" at the Parent. - if (mappedBy.isPresent()) { - partner = targetType.getAssociation(mappedBy.get()); - edmNaviProperty.setPartner(partner.getExternalName()); - } else { - partner = targetType.getCorrespondingAssociation(sourceType, getInternalName()); - if (partner != null - && ((IntermediateNavigationProperty) partner).isMapped()) { - edmNaviProperty.setPartner(partner.getExternalName()); - } - } - if (LOGGER.isTraceEnabled()) - LOGGER.trace(getExternalName() + ": Found partner = " + partnerToString()); - } - } - - private Optional determineReferentialConstraint( - final IntermediateJoinColumn intermediateColumn) throws ODataJPAModelException, ODataJPAModelIgnoreException { - - final CsdlReferentialConstraint constraint = new CsdlReferentialConstraint(); - boolean ignore = false; - IntermediateModelElement p = null; - p = sourceType.getPropertyByDBField(intermediateColumn.getName()); - if (p != null) { - if (p.ignore()) - ignore = true; - constraint.setProperty(p.getExternalName()); - p = targetType.getPropertyByDBField(intermediateColumn.getReferencedColumnName()); - if (p != null) { - if (p.ignore()) - ignore = true; - constraint.setReferencedProperty(p.getExternalName()); - } else { - throw new ODataJPAModelException(REFERENCED_PROPERTY_NOT_FOUND, getInternalName(), intermediateColumn - .getReferencedColumnName(), targetType.getExternalName()); - } - } else { - if (targetType.getPropertyByDBField(intermediateColumn.getReferencedColumnName()) != null) { - LOGGER.trace("Cloud not determine referential constraint for " + this.getType().getName() + "#" - + getInternalName()); - throw new ODataJPAModelIgnoreException(); - } else - return Optional.empty(); - } - if (ignore) - throw new ODataJPAModelIgnoreException(); - return Optional.of(constraint); - } - - private void determineReferentialConstraints(final AnnotatedElement annotatedElement) throws ODataJPAModelException { - - final AssociationOverride overwrite = annotatedElement.getAnnotation(AssociationOverride.class); - if (overwrite != null || joinTable != null) - return; - - final List constraints = edmNaviProperty.getReferentialConstraints(); - constraints.clear(); - boolean ignore = false; - for (final IntermediateJoinColumn intermediateColumn : joinColumns) { - try { - Optional constraint = determineReferentialConstraint(intermediateColumn); - if (!constraint.isPresent()) - constraint = determineReverseReferentialConstraint(intermediateColumn); - constraints.add(constraint.orElseThrow( - () -> new ODataJPAModelException(REFERENCED_PROPERTY_NOT_FOUND, getInternalName(), intermediateColumn - .getReferencedColumnName(), sourceType.getExternalName()))); - } catch (final ODataJPAModelIgnoreException e) { - ignore = true; - } - } - if (ignore) - constraints.clear(); - } - - private Optional determineReverseReferentialConstraint( - final IntermediateJoinColumn intermediateColumn) throws ODataJPAModelException, ODataJPAModelIgnoreException { - - final CsdlReferentialConstraint constraint = new CsdlReferentialConstraint(); - boolean ignore = false; - IntermediateModelElement p = null; - p = sourceType.getPropertyByDBField(intermediateColumn.getReferencedColumnName()); - if (p != null) { - if (p.ignore()) - ignore = true; - constraint.setProperty(p.getExternalName()); - p = targetType.getPropertyByDBField(intermediateColumn.getName()); - if (p != null) { - if (p.ignore()) - ignore = true; - constraint.setReferencedProperty(p.getExternalName()); - } else { - // Target not found: system will fallback to default column names, no referential constraint can be given - LOGGER.trace("Cloud not determine referential constraint for " + this.getType().getName() + "#" - + getInternalName()); - throw new ODataJPAModelIgnoreException(); - } - } else { - return Optional.empty(); - } - if (ignore) - throw new ODataJPAModelIgnoreException(); - return Optional.of(constraint); - } - - private String fillMissingName() throws ODataJPAModelException { - return ((IntermediateSimpleProperty) ((IntermediateEntityType) targetType) - .getKey().get(0)).getDBFieldName(); - } - - private void fillMissingName(final boolean isSourceOne, final IntermediateJoinColumn intermediateColumn) - throws ODataJPAModelException { - - final String referencedColumnName = intermediateColumn.getReferencedColumnName(); - final String name = intermediateColumn.getName(); - - if (isSourceOne && (name == null || name.isEmpty())) - intermediateColumn.setName(((IntermediateSimpleProperty) ((IntermediateEntityType) sourceType) - .getKey().get(0)).getDBFieldName()); - else if (isSourceOne && (referencedColumnName == null || referencedColumnName.isEmpty())) - intermediateColumn.setReferencedColumnName(((IntermediateSimpleProperty) ((IntermediateEntityType) targetType) - .getKey().get(0)).getDBFieldName()); - else if (!isSourceOne && (referencedColumnName == null || referencedColumnName.isEmpty())) - intermediateColumn.setName(((IntermediateSimpleProperty) ((IntermediateEntityType) targetType) - .getKey().get(0)).getDBFieldName()); - else if (!isSourceOne && (name == null || name.isEmpty())) - intermediateColumn.setReferencedColumnName(((IntermediateSimpleProperty) ((IntermediateEntityType) sourceType) - .getKey().get(0)).getDBFieldName()); - } - - private List invertJoinColumns(final List joinColumns) { - final List invertedJoinColumns = new ArrayList<>(joinColumns.size()); - for (final IntermediateJoinColumn joinColumn : joinColumns) { - invertedJoinColumns.add( - new IntermediateJoinColumn(joinColumn.getReferencedColumnName(), joinColumn.getName())); - } - return invertedJoinColumns; - } - - private CsdlOnDelete setJPAOnDelete(final CascadeType[] cascades) { - for (final CascadeType cascade : cascades) { - if (cascade == CascadeType.REMOVE || cascade == CascadeType.ALL) { - final CsdlOnDelete onDelete = new CsdlOnDelete(); - onDelete.setAction(CsdlOnDeleteAction.Cascade); - return onDelete; - } - } - return null; - } - -} +package com.sap.olingo.jpa.metadata.core.edm.mapper.impl; + +import static com.sap.olingo.jpa.metadata.core.edm.mapper.exception.ODataJPAModelException.MessageKeys.MISSING_ONE_TO_ONE_ANNOTATION; +import static com.sap.olingo.jpa.metadata.core.edm.mapper.exception.ODataJPAModelException.MessageKeys.REFERENCED_PROPERTY_NOT_FOUND; + +import java.lang.reflect.AnnotatedElement; +import java.lang.reflect.Constructor; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Locale; +import java.util.Optional; +import java.util.Set; + +import javax.annotation.CheckForNull; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind; +import org.apache.olingo.commons.api.edm.provider.CsdlAnnotation; +import org.apache.olingo.commons.api.edm.provider.CsdlNavigationProperty; +import org.apache.olingo.commons.api.edm.provider.CsdlOnDelete; +import org.apache.olingo.commons.api.edm.provider.CsdlOnDeleteAction; +import org.apache.olingo.commons.api.edm.provider.CsdlReferentialConstraint; + +import com.sap.olingo.jpa.metadata.api.JPAJoinColumn; +import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmIgnore; +import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmProtectedBy; +import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmTransientPropertyCalculator; +import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmVisibleFor; +import com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAAssociationAttribute; +import com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAAssociationPath; +import com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAEdmNameBuilder; +import com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAJoinTable; +import com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAStructuredType; +import com.sap.olingo.jpa.metadata.core.edm.mapper.exception.ODataJPAModelException; +import com.sap.olingo.jpa.metadata.core.edm.mapper.exception.ODataJPAModelException.MessageKeys; +import com.sap.olingo.jpa.metadata.core.edm.mapper.exception.ODataJPAModelIgnoreException; +import com.sap.olingo.jpa.metadata.core.edm.mapper.extension.IntermediateNavigationPropertyAccess; + +import jakarta.persistence.AssociationOverride; +import jakarta.persistence.AttributeConverter; +import jakarta.persistence.CascadeType; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.JoinColumns; +import jakarta.persistence.ManyToMany; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.OneToMany; +import jakarta.persistence.OneToOne; +import jakarta.persistence.metamodel.Attribute; +import jakarta.persistence.metamodel.Attribute.PersistentAttributeType; +import jakarta.persistence.metamodel.PluralAttribute; + +/** + * A navigation property describes a relation of one entity type to another entity type and allows to navigate to it. + * IntermediateNavigationProperty represents a navigation within on service, that is source and target are described by + * the same service document. + * OData Version 4.0 Part 3 - 7 Navigation Property + * @author Oliver Grande + * @param Type of the parent the navigation belongs to, also called source type + */ +final class IntermediateNavigationProperty extends IntermediateModelElement implements + IntermediateNavigationPropertyAccess, JPAAssociationAttribute { + + private static final Log LOGGER = LogFactory.getLog(IntermediateNavigationProperty.class); + + private final Attribute jpaAttribute; + private CsdlNavigationProperty edmNaviProperty; + private CsdlOnDelete edmOnDelete; + private final IntermediateStructuredType sourceType; + private IntermediateStructuredType targetType; + private JPAAssociationAttribute partner; + private IntermediateJoinTable joinTable; + private final IntermediateSchema schema; + private final List joinColumns = new ArrayList<>(); + private final List requiredDbColumns = new ArrayList<>(); + private PersistentAttributeType cardinality; + private Optional mappedBy; + + IntermediateNavigationProperty(final JPAEdmNameBuilder nameBuilder, final IntermediateStructuredType parent, + final Attribute jpaAttribute, final IntermediateSchema schema) throws ODataJPAModelException { + super(nameBuilder, InternalNameBuilder.buildAssociationName(jpaAttribute), schema.getAnnotationInformation()); + this.jpaAttribute = jpaAttribute; + this.schema = schema; + this.sourceType = parent; + buildNaviProperty(); + } + + @Override + public void addAnnotations(final List annotations) { + edmAnnotations.addAll(annotations); + } + + @Override + public > Constructor getCalculatorConstructor() { + return null; + } + + @Override + public AttributeConverter getConverter() { + return null; + } + + @Override + public Class getDbType() { + return null; + } + + @Override + public Class getJavaType() { + return null; + } + + @Override + public EdmPrimitiveTypeKind getEdmType() { + return null; + } + + public JPAJoinTable getJoinTable() { + return joinTable; + } + + @Override + public JPAAssociationAttribute getPartner() { + return partner; + } + + @Override + public JPAAssociationPath getPath() throws ODataJPAModelException { + return getStructuredType().getAssociationPath(getExternalName()); + } + + @Override + public CsdlNavigationProperty getProperty() throws ODataJPAModelException { + return getEdmItem(); + + } + + @Override + public Set getProtectionClaimNames() { + return new HashSet<>(0); + } + + @Override + public List getProtectionPath(final String claimName) throws ODataJPAModelException { + return new ArrayList<>(0); + } + + @Override + public AttributeConverter getRawConverter() { + return null; + } + + @Override + public List getRequiredProperties() { + return Collections.emptyList(); + } + + @Override + public JPAStructuredType getStructuredType() throws ODataJPAModelException { + if (edmNaviProperty == null) { + lazyBuildEdmItem(); + } + return sourceType; + } + + @Override + public JPAStructuredType getTargetEntity() throws ODataJPAModelException { + if (edmNaviProperty == null) { + lazyBuildEdmItem(); + } + return targetType; + } + + @Override + public Class getType() { + return jpaAttribute.getJavaType(); + } + + @Override + public boolean hasProtection() { + return false; + } + + @Override + public boolean isAssociation() { + return true; + } + + @Override + public boolean isCollection() { + return jpaAttribute.isCollection(); + } + + @Override + public boolean isComplex() { + return false; + } + + @Override + public boolean isEnum() { + return false; + } + + @Override + public boolean isEtag() { + return false; + } + + @Override + public boolean isKey() { + return false; + } + + @Override + public boolean isSearchable() { + return false; + } + + @Override + public boolean isTransient() { + return false; + } + + @Override + public void setOnDelete(final CsdlOnDelete onDelete) { + edmOnDelete = onDelete; + } + + @Override + public String toString() { + return getExternalName() + ": [sourceType=" + sourceType + ", targetType=" + targetType + + ", partner=" + partnerToString() + ", joinTable=" + joinTable + "]"; + } + + private String partnerToString() { + return partner == null ? "null" : partner.getExternalName(); + } + + @Override + protected synchronized void lazyBuildEdmItem() throws ODataJPAModelException { + if (edmNaviProperty == null) { + edmNaviProperty = new CsdlNavigationProperty(); + edmNaviProperty.setName(getExternalName()); + edmNaviProperty.setType(buildFQN(targetType.getExternalName())); + edmNaviProperty.setCollection(jpaAttribute.isCollection()); + edmNaviProperty.setAnnotations(edmAnnotations); + // Optional --> RelationAnnotation + determineMappedBy(); + buildJoinConditionInfo(); + // TODO determine ContainsTarget + determinePartner(); + } + } + + @Override + CsdlNavigationProperty getEdmItem() throws ODataJPAModelException { + if (edmNaviProperty == null) { + lazyBuildEdmItem(); + } + return edmNaviProperty; + } + + @Override + public CsdlAnnotation getAnnotation(final String alias, final String term) throws ODataJPAModelException { + return filterAnnotation(alias, term); + } + + PersistentAttributeType getJoinCardinality() { + return jpaAttribute.getPersistentAttributeType(); + } + + @SuppressWarnings("unchecked") + List getJoinColumns() throws ODataJPAModelException { + if (joinColumns.isEmpty()) { + lazyBuildEdmItem(); + buildJoinConditionInfo(); + } + return (List) joinColumns; + } + + List getRequiredDbColumns() throws ODataJPAModelException { + if (edmNaviProperty == null) + lazyBuildEdmItem(); + if (requiredDbColumns.isEmpty()) { + for (final IntermediateJoinColumn joinColumn : joinColumns) { + requiredDbColumns.add(joinColumn.getName()); + } + } + return requiredDbColumns; + } + + IntermediateStructuredType getSourceType() { + return sourceType; + } + + boolean isMapped() { + return mappedBy.isPresent(); + } + + /** + * In case the column name is not given at an association a default name is generated according to the JPA standard. + * The default name will be <association name>_<target key name>, all upper case. + * @param annotatedElement + * @param isSourceOne + * @return + * @throws ODataJPAModelException + */ + private String buildDefaultName(final boolean isSourceOne) throws ODataJPAModelException { + + final StringBuilder columnName = new StringBuilder(jpaAttribute.getName()); + columnName.append('_'); + if (isSourceOne) + columnName.append(((IntermediateSimpleProperty) ((IntermediateEntityType) targetType) + .getKey().get(0)).getDBFieldName()); + else + columnName.append(((IntermediateSimpleProperty) ((IntermediateEntityType) sourceType) + .getKey().get(0)).getDBFieldName()); + return columnName.toString().replace("\"", "").toUpperCase(Locale.ENGLISH); + } + + private IntermediateJoinColumn buildImplicitJoinColumnPair(final boolean isSourceOne) throws ODataJPAModelException { + final IntermediateJoinColumn intermediateColumn = new IntermediateJoinColumn(buildDefaultName(isSourceOne), + fillMissingName()); + if (LOGGER.isTraceEnabled()) + LOGGER.trace(getExternalName() + ": Add join condition with default name = " + intermediateColumn.toString()); + return intermediateColumn; + } + + private void buildJoinColumnPairList(final boolean isSourceOne, int implicitColumns, + final List result, final JoinColumn[] columns) throws ODataJPAModelException { + for (final JoinColumn column : columns) { + final String refColumnName = column.referencedColumnName(); + final String name = column.name(); + result.add(buildOneJoinColumnPair(isSourceOne, column)); + if (refColumnName == null || refColumnName.isEmpty() || name == null || name.isEmpty()) { + implicitColumns += 1; + if (implicitColumns > 1) + throw new ODataJPAModelException(ODataJPAModelException.MessageKeys.NOT_SUPPORTED_NO_IMPLICIT_COLUMNS, + getInternalName()); + } + } + } + + private void buildJoinColumns(final boolean isSourceOne, final AnnotatedElement annotatedElement) + throws ODataJPAModelException { + + joinColumns.clear(); + final List columns; + if (mappedBy.isPresent()) { + joinTable = ((IntermediateJoinTable) ((IntermediateNavigationProperty) targetType.getAssociation( + mappedBy.get())).getJoinTable()); + if (joinTable == null) + columns = buildJoinColumnsMapped(mappedBy.get()); + else + columns = joinTable.buildInverseJoinColumns(); + joinTable = joinTable == null ? null : joinTable.asMapped(this); + } else { + if (joinTable == null) + columns = buildJoinColumnsFromAnnotations(isSourceOne, annotatedElement); + else + columns = joinTable.buildJoinColumns(); + } + joinColumns.clear(); + joinColumns.addAll(columns); + } + + private List buildJoinColumnsFromAnnotations(final boolean isSourceOne, + final AnnotatedElement annotatedElement) throws ODataJPAModelException { + + final int implicitColumns = 0; + final List result = new ArrayList<>(); + final JoinColumn[] columns = annotatedElement.getAnnotation(JoinColumns.class) != null ? annotatedElement + .getAnnotation(JoinColumns.class).value() : null; + + if (columns != null) { + buildJoinColumnPairList(isSourceOne, implicitColumns, result, columns); + } else { + final JoinColumn column = annotatedElement.getAnnotation(JoinColumn.class); + if (column != null) { + result.add(buildOneJoinColumnPair(isSourceOne, column)); + } else { + // No explicit Join Columns given: Build implicit one. + result.add(buildImplicitJoinColumnPair(isSourceOne)); + } + } + return result; + } + + private List buildJoinColumnsMapped(final String mappedBy) throws ODataJPAModelException { + + int implicitColumns = 0; + final List result = invertJoinColumns(targetType.getJoinColumns(mappedBy)); + for (final IntermediateJoinColumn intermediateColumn : result) { + final String columnName = intermediateColumn.getName(); + if (columnName == null || columnName.isEmpty()) { + implicitColumns += 1; + if (implicitColumns > 1) + throw new ODataJPAModelException(ODataJPAModelException.MessageKeys.NOT_SUPPORTED_NO_IMPLICIT_COLUMNS, + getInternalName()); + intermediateColumn.setName(((IntermediateProperty) ((IntermediateEntityType) sourceType) + .getKey().get(0)).getDBFieldName()); + } + } + return result; + } + + private void buildJoinConditionInfo() throws ODataJPAModelException { + + if (jpaAttribute.getJavaMember() instanceof AnnotatedElement + && joinColumns.isEmpty()) { + final AnnotatedElement annotatedElement = (AnnotatedElement) jpaAttribute.getJavaMember(); +// Determine referential constraint + final boolean isOwner = !mappedBy.isPresent(); + buildJoinColumns(isOwner, annotatedElement); + determineReferentialConstraints(annotatedElement); + } + } + + private void buildNaviProperty() throws ODataJPAModelException { + + this.setExternalName(nameBuilder.buildNaviPropertyName(jpaAttribute)); + + evaluateAnnotation(); + + targetType = schema.getEntityType(determineTargetClass()); + if (targetType == null) + throw new ODataJPAModelException(ODataJPAModelException.MessageKeys.NAVI_PROPERTY_NOT_FOUND, + jpaAttribute.getName(), sourceType.internalName); + + postProcessor.processNavigationProperty(this, jpaAttribute.getDeclaringType().getJavaType() + .getCanonicalName()); + // Process annotations after post processing, as external name could have been changed + getAnnotations(edmAnnotations, this.jpaAttribute.getJavaMember(), internalName); + + checkConsistency(); + if (LOGGER.isTraceEnabled()) + LOGGER.trace(toString()); + } + + private void evaluateAnnotation() throws ODataJPAModelException { + + if (this.jpaAttribute.getJavaMember() instanceof AnnotatedElement) { + final EdmIgnore jpaIgnore = ((AnnotatedElement) this.jpaAttribute.getJavaMember()).getAnnotation( + EdmIgnore.class); + if (jpaIgnore != null) { + this.setIgnore(true); + } + final jakarta.persistence.JoinTable jpaJoinTable = ((AnnotatedElement) this.jpaAttribute.getJavaMember()) + .getAnnotation(jakarta.persistence.JoinTable.class); + joinTable = jpaJoinTable != null ? new IntermediateJoinTable(this, jpaJoinTable, schema) : null; + + final AnnotatedElement annotatedElement = (AnnotatedElement) jpaAttribute.getJavaMember(); + cardinality = jpaAttribute.getPersistentAttributeType(); + if (cardinality != null) { + switch (cardinality) { + case ONE_TO_MANY: + // Association '%1$s' of '%2$s' requires a cardinality annotation. + final OneToMany oneTOMany = Optional.ofNullable(annotatedElement.getAnnotation(OneToMany.class)) + .orElseThrow(() -> new ODataJPAModelException(MISSING_ONE_TO_ONE_ANNOTATION, internalName, sourceType + .getInternalName())); + mappedBy = Optional.ofNullable(returnNullIfEmpty(oneTOMany.mappedBy())); + break; + case ONE_TO_ONE: + // Association '%1$s' of '%2$s' requires a cardinality annotation. + final OneToOne annotation = Optional.ofNullable(annotatedElement.getAnnotation(OneToOne.class)) + .orElseThrow(() -> new ODataJPAModelException(MISSING_ONE_TO_ONE_ANNOTATION, internalName, sourceType + .getInternalName())); + mappedBy = Optional.ofNullable(returnNullIfEmpty(annotation.mappedBy())); + break; + case MANY_TO_MANY: + mappedBy = Optional.ofNullable(returnNullIfEmpty( + annotatedElement.getAnnotation(ManyToMany.class).mappedBy())); + break; + default: + mappedBy = Optional.empty(); + } + } else { + mappedBy = Optional.empty(); + } + } + } + + private Class determineTargetClass() { + Class targetClass = null; + if (jpaAttribute.isCollection()) { + targetClass = ((PluralAttribute) jpaAttribute).getElementType().getJavaType(); + } else { + targetClass = jpaAttribute.getJavaType(); + } + return targetClass; + } + + private IntermediateJoinColumn buildOneJoinColumnPair(final boolean isSourceOne, final JoinColumn column) + throws ODataJPAModelException { + IntermediateJoinColumn intermediateColumn = new IntermediateJoinColumn(column); + if (cardinality == PersistentAttributeType.ONE_TO_MANY) + intermediateColumn = new IntermediateJoinColumn(intermediateColumn.getReferencedColumnName(), + intermediateColumn.getName()); + fillMissingName(isSourceOne, intermediateColumn); + if (LOGGER.isTraceEnabled()) + LOGGER.trace(getExternalName() + ": Add join condition = " + intermediateColumn.toString()); + return intermediateColumn; + } + + private void checkConsistency() throws ODataJPAModelException { + final EdmProtectedBy jpaProtectedBy = ((AnnotatedElement) this.jpaAttribute.getJavaMember()) + .getAnnotation(EdmProtectedBy.class); + if (jpaProtectedBy != null) { + // Navigation Properties do not support EdmProtectedBy + throw new ODataJPAModelException(MessageKeys.NOT_SUPPORTED_PROTECTED_NAVIGATION, this.sourceType.getTypeClass() + .getCanonicalName(), this.internalName); + } + final EdmVisibleFor jpaFieldGroups = ((AnnotatedElement) this.jpaAttribute.getJavaMember()) + .getAnnotation(EdmVisibleFor.class); + if (jpaFieldGroups != null) { + throw new ODataJPAModelException(MessageKeys.NOT_SUPPORTED_NAVIGATION_PART_OF_GROUP, + this.sourceType.getTypeClass().getCanonicalName(), this.internalName); + } + } + + @CheckForNull + private void determineMappedBy() { + + if (jpaAttribute.getJavaMember() instanceof AnnotatedElement) { + final AnnotatedElement annotatedElement = (AnnotatedElement) jpaAttribute.getJavaMember(); + cardinality = jpaAttribute.getPersistentAttributeType(); + switch (cardinality) { + case ONE_TO_MANY: + final OneToMany cardinalityOtM = annotatedElement.getAnnotation(OneToMany.class); + edmNaviProperty.setOnDelete(edmOnDelete != null ? edmOnDelete : setJPAOnDelete(cardinalityOtM.cascade())); + break; + case ONE_TO_ONE: + final OneToOne cardinalityOtO = annotatedElement.getAnnotation(OneToOne.class); + edmNaviProperty.setNullable(cardinalityOtO.optional()); + edmNaviProperty.setOnDelete(edmOnDelete != null ? edmOnDelete : setJPAOnDelete(cardinalityOtO.cascade())); + break; + case MANY_TO_ONE: + final ManyToOne cardinalityMtO = annotatedElement.getAnnotation(ManyToOne.class); + edmNaviProperty.setNullable(cardinalityMtO.optional()); + edmNaviProperty.setOnDelete(edmOnDelete != null ? edmOnDelete : setJPAOnDelete(cardinalityMtO.cascade())); + break; + case MANY_TO_MANY: + final ManyToMany cardinalityMtM = annotatedElement.getAnnotation(ManyToMany.class); + edmNaviProperty.setOnDelete(edmOnDelete != null ? edmOnDelete : setJPAOnDelete(cardinalityMtM.cascade())); + break; + default: + break; + } + } + } + + private void determinePartner() throws ODataJPAModelException { + if (sourceType instanceof IntermediateEntityType) { + // Partner Attribute must not be defined at Complex Types. + // JPA bi-directional associations are defined at both sides, e.g. + // at the BusinessPartner and at the Roles. JPA only defines the + // "mappedBy" at the Parent. + if (mappedBy.isPresent()) { + partner = targetType.getAssociation(mappedBy.get()); + edmNaviProperty.setPartner(partner.getExternalName()); + } else { + partner = targetType.getCorrespondingAssociation(sourceType, getInternalName()); + if (partner != null + && ((IntermediateNavigationProperty) partner).isMapped()) { + edmNaviProperty.setPartner(partner.getExternalName()); + } + } + if (LOGGER.isTraceEnabled()) + LOGGER.trace(getExternalName() + ": Found partner = " + partnerToString()); + } + } + + private Optional determineReferentialConstraint( + final IntermediateJoinColumn intermediateColumn) throws ODataJPAModelException, ODataJPAModelIgnoreException { + + final CsdlReferentialConstraint constraint = new CsdlReferentialConstraint(); + boolean ignore = false; + IntermediateModelElement p = null; + p = sourceType.getPropertyByDBField(intermediateColumn.getName()); + if (p != null) { + if (p.ignore()) + ignore = true; + constraint.setProperty(p.getExternalName()); + p = targetType.getPropertyByDBField(intermediateColumn.getReferencedColumnName()); + if (p != null) { + if (p.ignore()) + ignore = true; + constraint.setReferencedProperty(p.getExternalName()); + } else { + throw new ODataJPAModelException(REFERENCED_PROPERTY_NOT_FOUND, getInternalName(), intermediateColumn + .getReferencedColumnName(), targetType.getExternalName()); + } + } else { + if (targetType.getPropertyByDBField(intermediateColumn.getReferencedColumnName()) != null) { + LOGGER.trace("Cloud not determine referential constraint for " + this.getType().getName() + "#" + + getInternalName()); + throw new ODataJPAModelIgnoreException(); + } else + return Optional.empty(); + } + if (ignore) + throw new ODataJPAModelIgnoreException(); + return Optional.of(constraint); + } + + private void determineReferentialConstraints(final AnnotatedElement annotatedElement) throws ODataJPAModelException { + + final AssociationOverride overwrite = annotatedElement.getAnnotation(AssociationOverride.class); + if (overwrite != null || joinTable != null) + return; + + final List constraints = edmNaviProperty.getReferentialConstraints(); + constraints.clear(); + boolean ignore = false; + for (final IntermediateJoinColumn intermediateColumn : joinColumns) { + try { + Optional constraint = determineReferentialConstraint(intermediateColumn); + if (!constraint.isPresent()) + constraint = determineReverseReferentialConstraint(intermediateColumn); + constraints.add(constraint.orElseThrow( + () -> new ODataJPAModelException(REFERENCED_PROPERTY_NOT_FOUND, getInternalName(), intermediateColumn + .getReferencedColumnName(), sourceType.getExternalName()))); + } catch (final ODataJPAModelIgnoreException e) { + ignore = true; + } + } + if (ignore) + constraints.clear(); + } + + private Optional determineReverseReferentialConstraint( + final IntermediateJoinColumn intermediateColumn) throws ODataJPAModelException, ODataJPAModelIgnoreException { + + final CsdlReferentialConstraint constraint = new CsdlReferentialConstraint(); + boolean ignore = false; + IntermediateModelElement p = null; + p = sourceType.getPropertyByDBField(intermediateColumn.getReferencedColumnName()); + if (p != null) { + if (p.ignore()) + ignore = true; + constraint.setProperty(p.getExternalName()); + p = targetType.getPropertyByDBField(intermediateColumn.getName()); + if (p != null) { + if (p.ignore()) + ignore = true; + constraint.setReferencedProperty(p.getExternalName()); + } else { + // Target not found: system will fallback to default column names, no referential constraint can be given + LOGGER.trace("Cloud not determine referential constraint for " + this.getType().getName() + "#" + + getInternalName()); + throw new ODataJPAModelIgnoreException(); + } + } else { + return Optional.empty(); + } + if (ignore) + throw new ODataJPAModelIgnoreException(); + return Optional.of(constraint); + } + + private String fillMissingName() throws ODataJPAModelException { + return ((IntermediateSimpleProperty) ((IntermediateEntityType) targetType) + .getKey().get(0)).getDBFieldName(); + } + + private void fillMissingName(final boolean isSourceOne, final IntermediateJoinColumn intermediateColumn) + throws ODataJPAModelException { + + final String referencedColumnName = intermediateColumn.getReferencedColumnName(); + final String name = intermediateColumn.getName(); + + if (isSourceOne && (name == null || name.isEmpty())) + intermediateColumn.setName(((IntermediateSimpleProperty) ((IntermediateEntityType) sourceType) + .getKey().get(0)).getDBFieldName()); + else if (isSourceOne && (referencedColumnName == null || referencedColumnName.isEmpty())) + intermediateColumn.setReferencedColumnName(((IntermediateSimpleProperty) ((IntermediateEntityType) targetType) + .getKey().get(0)).getDBFieldName()); + else if (!isSourceOne && (referencedColumnName == null || referencedColumnName.isEmpty())) + intermediateColumn.setName(((IntermediateSimpleProperty) ((IntermediateEntityType) targetType) + .getKey().get(0)).getDBFieldName()); + else if (!isSourceOne && (name == null || name.isEmpty())) + intermediateColumn.setReferencedColumnName(((IntermediateSimpleProperty) ((IntermediateEntityType) sourceType) + .getKey().get(0)).getDBFieldName()); + } + + private List invertJoinColumns(final List joinColumns) { + final List invertedJoinColumns = new ArrayList<>(joinColumns.size()); + for (final IntermediateJoinColumn joinColumn : joinColumns) { + invertedJoinColumns.add( + new IntermediateJoinColumn(joinColumn.getReferencedColumnName(), joinColumn.getName())); + } + return invertedJoinColumns; + } + + private CsdlOnDelete setJPAOnDelete(final CascadeType[] cascades) { + for (final CascadeType cascade : cascades) { + if (cascade == CascadeType.REMOVE || cascade == CascadeType.ALL) { + final CsdlOnDelete onDelete = new CsdlOnDelete(); + onDelete.setAction(CsdlOnDeleteAction.Cascade); + return onDelete; + } + } + return null; + } + +} diff --git a/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateOperationFactory.java b/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateOperationFactory.java index c1b1561e9..8aeb273af 100644 --- a/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateOperationFactory.java +++ b/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateOperationFactory.java @@ -19,21 +19,16 @@ * * @param Type of operation */ -public abstract class IntermediateOperationFactory { +interface IntermediateOperationFactory { - IntermediateOperationFactory() { - super(); - } - - abstract O createOperation(final JPAEdmNameBuilder nameBuilder, final IntermediateSchema schema, + O createOperation(final JPAEdmNameBuilder nameBuilder, final IntermediateSchema schema, final Method method, final Object functionDescription) throws ODataJPAModelException; @SuppressWarnings("unchecked") - Map createOperationMap(final JPAEdmNameBuilder nameBuilder, final Reflections reflections, + default Map createOperationMap(final JPAEdmNameBuilder nameBuilder, final Reflections reflections, final IntermediateSchema schema, final Class clazz, - final Class annotation) - throws ODataJPAModelException { + final Class annotation) throws ODataJPAModelException { final Map operations = new HashMap<>(); if (reflections != null) { @@ -45,7 +40,7 @@ Map createOperationMap(final JPAEdmNameBuilder nameBuilder, final Ref return operations; } - Set> findJavaOperations(final Reflections reflections, + default Set> findJavaOperations(final Reflections reflections, final Class clazz) { return reflections.getSubTypesOf(clazz); } diff --git a/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateOperationHelper.java b/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateOperationHelper.java index f59a886f0..bccdf18e7 100644 --- a/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateOperationHelper.java +++ b/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateOperationHelper.java @@ -14,7 +14,7 @@ import java.util.Arrays; import java.util.Collection; -import javax.persistence.EntityManager; +import jakarta.persistence.EntityManager; import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind; import org.apache.olingo.commons.api.edm.FullQualifiedName; @@ -24,7 +24,6 @@ import com.sap.olingo.jpa.metadata.api.JPARequestParameterMap; import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmFunction.ReturnType; import com.sap.olingo.jpa.metadata.core.edm.mapper.exception.ODataJPAModelException; -import com.sap.olingo.jpa.metadata.core.edm.mapper.exception.ODataJPAModelException.MessageKeys; public class IntermediateOperationHelper { @@ -74,7 +73,9 @@ private static void checkConstructorParameter(final Method javaOperation, fi static boolean isCollection(final Class declaredReturnType) { for (final Class inter : Arrays.asList(declaredReturnType.getInterfaces())) { - if (inter == Collection.class) + if (inter == Collection.class) { + return true; + } else if (isCollection(inter)) return true; } return false; @@ -102,7 +103,7 @@ static FullQualifiedName determineReturnType(final ReturnType definedReturnType, throw new ODataJPAModelException(FUNC_RETURN_TYPE_INVALID, definedReturnType.type().getName(), declaredReturnType.getName(), operationName); } - return edmType.getFullQualifiedName(); + return edmType.getFullQualifiedName(); } } } diff --git a/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateProperty.java b/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateProperty.java index fff63c9e2..aa70fb803 100644 --- a/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateProperty.java +++ b/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateProperty.java @@ -21,17 +21,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.stream.Collectors; - -import javax.persistence.AttributeConverter; -import javax.persistence.Column; -import javax.persistence.Convert; -import javax.persistence.EntityManager; -import javax.persistence.Lob; -import javax.persistence.metamodel.Attribute; -import javax.persistence.metamodel.Attribute.PersistentAttributeType; -import javax.persistence.metamodel.ManagedType; -import javax.persistence.metamodel.Type.PersistenceType; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -65,6 +54,16 @@ import com.sap.olingo.jpa.metadata.core.edm.mapper.exception.ODataJPAModelException; import com.sap.olingo.jpa.metadata.core.edm.mapper.extension.IntermediatePropertyAccess; +import jakarta.persistence.AttributeConverter; +import jakarta.persistence.Column; +import jakarta.persistence.Convert; +import jakarta.persistence.EntityManager; +import jakarta.persistence.Lob; +import jakarta.persistence.metamodel.Attribute; +import jakarta.persistence.metamodel.Attribute.PersistentAttributeType; +import jakarta.persistence.metamodel.ManagedType; +import jakarta.persistence.metamodel.Type.PersistenceType; + /** * Properties can be classified by two different aspects: *

          @@ -81,7 +80,7 @@ abstract class IntermediateProperty extends IntermediateModelElement implements private static final int UPPER_LIMIT_PRECISION_TEMP = 12; private static final int LOWER_LIMIT_PRECISION_TEMP = 0; private static final String DB_FIELD_NAME_PATTERN = "\"&1\""; - protected final Attribute jpaAttribute; + protected final jakarta.persistence.metamodel.Attribute jpaAttribute; protected final IntermediateSchema schema; protected CsdlProperty edmProperty; protected JPAStructuredType type; @@ -581,7 +580,7 @@ private void determineFieldGroups() { final EdmVisibleFor jpaFieldGroups = ((AnnotatedElement) this.jpaAttribute.getJavaMember()) .getAnnotation(EdmVisibleFor.class); if (jpaFieldGroups != null) - fieldGroups = Arrays.stream(jpaFieldGroups.value()).collect(Collectors.toList()); + fieldGroups = Arrays.stream(jpaFieldGroups.value()).toList(); else fieldGroups = new ArrayList<>(0); } diff --git a/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateSchema.java b/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateSchema.java index 2f797d397..9d378b5ea 100644 --- a/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateSchema.java +++ b/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateSchema.java @@ -10,11 +10,6 @@ import javax.annotation.CheckForNull; import javax.annotation.Nonnull; -import javax.persistence.metamodel.Attribute; -import javax.persistence.metamodel.EmbeddableType; -import javax.persistence.metamodel.EntityType; -import javax.persistence.metamodel.Metamodel; -import javax.persistence.metamodel.PluralAttribute; import org.apache.olingo.commons.api.edm.EdmEnumType; import org.apache.olingo.commons.api.edm.FullQualifiedName; @@ -30,6 +25,12 @@ import com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAStructuredType; import com.sap.olingo.jpa.metadata.core.edm.mapper.exception.ODataJPAModelException; +import jakarta.persistence.metamodel.Attribute; +import jakarta.persistence.metamodel.EmbeddableType; +import jakarta.persistence.metamodel.EntityType; +import jakarta.persistence.metamodel.Metamodel; +import jakarta.persistence.metamodel.PluralAttribute; + /** *

          * For details about Schema metadata see: diff --git a/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateServiceDocument.java b/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateServiceDocument.java index 42e0b3681..d2b67930f 100644 --- a/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateServiceDocument.java +++ b/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateServiceDocument.java @@ -8,7 +8,6 @@ import java.util.Optional; import javax.annotation.CheckForNull; -import javax.persistence.metamodel.Metamodel; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -46,6 +45,8 @@ import com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPATopLevelEntity; import com.sap.olingo.jpa.metadata.core.edm.mapper.exception.ODataJPAModelException; +import jakarta.persistence.metamodel.Metamodel; + /** * http://docs.oasis-open.org/odata/odata/v4.0/errata02/os/complete/schemas/edmx.xsd * A Service Document can contain multiple schemas, but only diff --git a/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateSimpleProperty.java b/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateSimpleProperty.java index 311e2bf3f..eeb435cef 100644 --- a/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateSimpleProperty.java +++ b/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateSimpleProperty.java @@ -9,12 +9,6 @@ import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Modifier; -import javax.persistence.Column; -import javax.persistence.Version; -import javax.persistence.metamodel.Attribute; -import javax.persistence.metamodel.Attribute.PersistentAttributeType; -import javax.persistence.metamodel.SingularAttribute; - import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.olingo.commons.api.edm.FullQualifiedName; @@ -23,6 +17,12 @@ import com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAEdmNameBuilder; import com.sap.olingo.jpa.metadata.core.edm.mapper.exception.ODataJPAModelException; +import jakarta.persistence.Column; +import jakarta.persistence.Version; +import jakarta.persistence.metamodel.Attribute; +import jakarta.persistence.metamodel.Attribute.PersistentAttributeType; +import jakarta.persistence.metamodel.SingularAttribute; + /** * A Property is described on the one hand by its Name and Type and on the other * hand by its Property Facets. The type is a qualified name of either a diff --git a/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateStructuredType.java b/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateStructuredType.java index a26f98514..7e33fed2d 100644 --- a/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateStructuredType.java +++ b/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateStructuredType.java @@ -4,13 +4,13 @@ import static com.sap.olingo.jpa.metadata.core.edm.mapper.exception.ODataJPAModelException.MessageKeys.DB_TYPE_NOT_DETERMINED; import static com.sap.olingo.jpa.metadata.core.edm.mapper.exception.ODataJPAModelException.MessageKeys.INVALID_NAVIGATION_PROPERTY; import static com.sap.olingo.jpa.metadata.core.edm.mapper.exception.ODataJPAModelException.MessageKeys.PROPERTY_REQUIRED_UNKNOWN; -import static javax.persistence.metamodel.Attribute.PersistentAttributeType.BASIC; -import static javax.persistence.metamodel.Attribute.PersistentAttributeType.ELEMENT_COLLECTION; -import static javax.persistence.metamodel.Attribute.PersistentAttributeType.EMBEDDED; -import static javax.persistence.metamodel.Attribute.PersistentAttributeType.MANY_TO_MANY; -import static javax.persistence.metamodel.Attribute.PersistentAttributeType.MANY_TO_ONE; -import static javax.persistence.metamodel.Attribute.PersistentAttributeType.ONE_TO_MANY; -import static javax.persistence.metamodel.Attribute.PersistentAttributeType.ONE_TO_ONE; +import static jakarta.persistence.metamodel.Attribute.PersistentAttributeType.BASIC; +import static jakarta.persistence.metamodel.Attribute.PersistentAttributeType.ELEMENT_COLLECTION; +import static jakarta.persistence.metamodel.Attribute.PersistentAttributeType.EMBEDDED; +import static jakarta.persistence.metamodel.Attribute.PersistentAttributeType.MANY_TO_MANY; +import static jakarta.persistence.metamodel.Attribute.PersistentAttributeType.MANY_TO_ONE; +import static jakarta.persistence.metamodel.Attribute.PersistentAttributeType.ONE_TO_MANY; +import static jakarta.persistence.metamodel.Attribute.PersistentAttributeType.ONE_TO_ONE; import java.lang.annotation.Annotation; import java.lang.reflect.AnnotatedElement; @@ -32,23 +32,6 @@ import java.util.stream.Collectors; import javax.annotation.Nonnull; -import javax.persistence.AssociationOverride; -import javax.persistence.AssociationOverrides; -import javax.persistence.AttributeOverride; -import javax.persistence.AttributeOverrides; -import javax.persistence.Column; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.OneToMany; -import javax.persistence.Version; -import javax.persistence.metamodel.Attribute; -import javax.persistence.metamodel.Attribute.PersistentAttributeType; -import javax.persistence.metamodel.IdentifiableType; -import javax.persistence.metamodel.ManagedType; -import javax.persistence.metamodel.MappedSuperclassType; -import javax.persistence.metamodel.PluralAttribute; -import javax.persistence.metamodel.SingularAttribute; -import javax.persistence.metamodel.Type; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -75,6 +58,24 @@ import com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAStructuredType; import com.sap.olingo.jpa.metadata.core.edm.mapper.exception.ODataJPAModelException; +import jakarta.persistence.AssociationOverride; +import jakarta.persistence.AssociationOverrides; +import jakarta.persistence.AttributeOverride; +import jakarta.persistence.AttributeOverrides; +import jakarta.persistence.Column; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.OneToMany; +import jakarta.persistence.Version; +import jakarta.persistence.metamodel.Attribute; +import jakarta.persistence.metamodel.Attribute.PersistentAttributeType; +import jakarta.persistence.metamodel.IdentifiableType; +import jakarta.persistence.metamodel.ManagedType; +import jakarta.persistence.metamodel.MappedSuperclassType; +import jakarta.persistence.metamodel.PluralAttribute; +import jakarta.persistence.metamodel.SingularAttribute; +import jakarta.persistence.metamodel.Type; + abstract class IntermediateStructuredType extends IntermediateModelElement implements JPAStructuredType, ODataAnnotatable { // @@ -408,7 +409,7 @@ void addTransientProperties() throws ODataJPAModelException { .map(Class::getDeclaredFields) .map(Arrays::asList) .flatMap(List::stream) - .collect(Collectors.toList())); + .toList()); } void addVirtualProperties() throws ODataJPAModelException { @@ -603,8 +604,7 @@ private void convertToProperty(final Attribute jpaAttribute) throws ODataJ final PersistentAttributeType attributeType = jpaAttribute.getPersistentAttributeType(); switch (attributeType) { - case BASIC: - case EMBEDDED: + case BASIC, EMBEDDED: if (jpaAttribute instanceof SingularAttribute && ((SingularAttribute) jpaAttribute).isId() && attributeType == PersistentAttributeType.EMBEDDED) { @@ -681,9 +681,8 @@ private List determineJoinColumns(final IntermediateMod @SuppressWarnings("unchecked") private List> determineMappedSuperclass(final ManagedType managedType) { - if (managedType instanceof IdentifiableType) { + if (managedType instanceof IdentifiableType type) { final List> result = new ArrayList<>(); - IdentifiableType type = (IdentifiableType) managedType; while (type.getSupertype() instanceof MappedSuperclassType) { type = type.getSupertype(); result.add((MappedSuperclassType) type); @@ -1125,9 +1124,8 @@ protected static class TransientRowType implements Type { * @param attribute */ public TransientRowType(final Field attribute, final IntermediateSchema schema) { - if (attribute.getGenericType() instanceof ParameterizedType) { - final java.lang.reflect.Type[] attributes = ((ParameterizedType) attribute.getGenericType()) - .getActualTypeArguments(); + if (attribute.getGenericType() instanceof final ParameterizedType type) { + final java.lang.reflect.Type[] attributes = type.getActualTypeArguments(); this.rowType = (Class) attributes[attributes.length - 1]; } else { this.rowType = attribute.getType(); diff --git a/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateVirtualProperty.java b/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateVirtualProperty.java index aa09718ad..cd9ee63ed 100644 --- a/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateVirtualProperty.java +++ b/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateVirtualProperty.java @@ -1,13 +1,14 @@ package com.sap.olingo.jpa.metadata.core.edm.mapper.impl; import javax.annotation.Nonnull; -import javax.persistence.metamodel.Attribute; import org.apache.olingo.commons.api.edm.FullQualifiedName; import com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAEdmNameBuilder; import com.sap.olingo.jpa.metadata.core.edm.mapper.exception.ODataJPAModelException; +import jakarta.persistence.metamodel.Attribute; + class IntermediateVirtualProperty extends IntermediateProperty { IntermediateVirtualProperty(final JPAEdmNameBuilder nameBuilder, final Attribute jpaAttribute, diff --git a/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/JPAAssociationPathImpl.java b/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/JPAAssociationPathImpl.java index 638bc31f5..76459f024 100644 --- a/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/JPAAssociationPathImpl.java +++ b/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/JPAAssociationPathImpl.java @@ -5,7 +5,6 @@ import java.util.List; import javax.annotation.Nonnull; -import javax.persistence.metamodel.Attribute.PersistentAttributeType; import com.sap.olingo.jpa.metadata.api.JPAJoinColumn; import com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAAssociationAttribute; @@ -18,6 +17,8 @@ import com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAStructuredType; import com.sap.olingo.jpa.metadata.core.edm.mapper.exception.ODataJPAModelException; +import jakarta.persistence.metamodel.Attribute.PersistentAttributeType; + final class JPAAssociationPathImpl implements JPAAssociationPath { private final String alias; private final List pathElements; @@ -53,7 +54,7 @@ final class JPAAssociationPathImpl implements JPAAssociationPath { pathElementsBuffer.add(attribute); pathElementsBuffer.addAll(associationPath.getPath()); - alias = buildNaviPropertyBindingName(associationPath, attribute); + alias = buildNavigationPropertyBindingName(associationPath, attribute); this.sourceType = source; this.targetType = (IntermediateStructuredType) associationPath.getTargetType(); if (joinColumns.isEmpty()) @@ -101,8 +102,8 @@ public String getAlias() { @Override public List getInverseLeftJoinColumnsList() throws ODataJPAModelException { final List result = new ArrayList<>(); - if (joinTable instanceof IntermediateJoinTable) - for (final IntermediateJoinColumn column : ((IntermediateJoinTable) joinTable).buildInverseJoinColumns()) { + if (joinTable instanceof final IntermediateJoinTable intermediateJoinTable) + for (final IntermediateJoinColumn column : intermediateJoinTable.buildInverseJoinColumns()) { result.add(targetType.getPathByDBField(column.getName())); } return result; @@ -246,7 +247,8 @@ private List getJoinColumns() { */ // TODO respect subtype name @Nonnull - private String buildNaviPropertyBindingName(final JPAAssociationPath associationPath, final JPAAttribute parent) { + private String buildNavigationPropertyBindingName(final JPAAssociationPath associationPath, + final JPAAttribute parent) { final StringBuilder name = new StringBuilder(); name.append(parent.getExternalName()); diff --git a/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/JPADefaultEdmNameBuilder.java b/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/JPADefaultEdmNameBuilder.java index 510985d94..599d01d04 100644 --- a/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/JPADefaultEdmNameBuilder.java +++ b/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/JPADefaultEdmNameBuilder.java @@ -1,15 +1,14 @@ package com.sap.olingo.jpa.metadata.core.edm.mapper.impl; -import java.util.Objects; - import javax.annotation.Nonnull; -import javax.persistence.metamodel.Attribute; -import javax.persistence.metamodel.EmbeddableType; -import javax.persistence.metamodel.EntityType; import com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAEdmNameBuilder; -public final class JPADefaultEdmNameBuilder implements JPAEdmNameBuilder { +import jakarta.persistence.metamodel.Attribute; +import jakarta.persistence.metamodel.EmbeddableType; +import jakarta.persistence.metamodel.EntityType; + +public final record JPADefaultEdmNameBuilder(@Nonnull String namespace) implements JPAEdmNameBuilder { private static final int DISTANCE_NEXT_TO_LAST_CHAR = 2; private static final int DISTANCE_LAST_CHAR = 1; // V2 NameBuilder: package org.apache.olingo.odata2.jpa.processor.core.access.model @@ -24,15 +23,9 @@ public static String firstToUpper(final String jpaAttributeName) { return Character.toUpperCase(jpaAttributeName.charAt(0)) + jpaAttributeName.substring(1); } - private final String namespace; - - public JPADefaultEdmNameBuilder(@Nonnull final String namespace) { - super(); - this.namespace = Objects.requireNonNull(namespace); - } - /** - * EDM Complex Type Name - RULE:

          + * EDM Complex Type Name - RULE: + *

          * Use JPA Embeddable Type Simple Name as Complex Type Name */ @Override @@ -41,7 +34,8 @@ public final String buildComplexTypeName(final EmbeddableType jpaEmbeddedType } /** - * EDM EntityContainer Name - RULE:

          + * EDM EntityContainer Name - RULE: + *

          * The Entity Container Name is build of EDM Namespace + Literal "Container". Container names are simple identifiers, * so contain only letter, digits and underscores. However namespaces * can contain also dots => eliminate dots and convert to camel case. @@ -58,7 +52,8 @@ public String buildContainerName() { } /** - * EDM EntitySet Name - RULE:

          + * EDM EntitySet Name - RULE: + *

          * Use plural of entity type name. The naming bases on the assumption that English nouns are used.
          * Entity Set Name = JPA Entity Type Name + Literal "s" */ @@ -76,7 +71,8 @@ public final String buildEntitySetName(final String entityTypeName) { } /** - * EDM EntityType Name - RULE:

          + * EDM EntityType Name - RULE: + *

          * Use JPA Entity Name as EDM Entity Type Name */ @Override @@ -90,7 +86,8 @@ public final String getNamespace() { } /** - * EDM Navigation Property Name - RULE:

          + * EDM Navigation Property Name - RULE: + *

          * OData requires: "The name of the navigation property MUST be unique * within the set of structural and navigation properties of the containing * structured type and any of its base types." @@ -104,7 +101,8 @@ public final String buildNaviPropertyName(final Attribute jpaAttribute) { } /** - * EDM Property Name - RULE:

          + * EDM Property Name - RULE: + *

          * OData Property Names are represented in Camel Case. The first character * of JPA Attribute Name is converted to an UpperCase Character. * @param jpaAttributeName diff --git a/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/JPANameBuilder.java b/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/JPANameBuilder.java index ec89aa95d..df86b7a80 100644 --- a/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/JPANameBuilder.java +++ b/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/JPANameBuilder.java @@ -1,6 +1,6 @@ package com.sap.olingo.jpa.metadata.core.edm.mapper.impl; -import javax.persistence.metamodel.Attribute; +import jakarta.persistence.metamodel.Attribute; import org.apache.olingo.commons.api.edm.FullQualifiedName; diff --git a/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/JPAPathImpl.java b/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/JPAPathImpl.java index 290ab3fd9..52fab616d 100644 --- a/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/JPAPathImpl.java +++ b/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/JPAPathImpl.java @@ -146,9 +146,10 @@ public String toString() { private List determineFieldGroups() throws ODataJPAModelException { List groups = null; for (final JPAElement pathElement : pathElements) { - if (pathElement instanceof IntermediateProperty && ((IntermediateProperty) pathElement).isPartOfGroup()) { + if (pathElement instanceof final IntermediateProperty intermediateProperty + && intermediateProperty.isPartOfGroup()) { if (groups == null) - groups = ((IntermediateProperty) pathElement).getGroups(); + groups = intermediateProperty.getGroups(); else { final List newGroups = ((IntermediateProperty) pathElement).getGroups(); if (groups.size() != newGroups.size() || !groups.stream().allMatch(newGroups::contains)) diff --git a/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/JPAServiceDocumentFactory.java b/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/JPAServiceDocumentFactory.java index 1aefe00ad..7a5e36e0e 100644 --- a/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/JPAServiceDocumentFactory.java +++ b/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/JPAServiceDocumentFactory.java @@ -2,14 +2,14 @@ import java.util.List; -import javax.persistence.metamodel.Metamodel; - import com.sap.olingo.jpa.metadata.api.JPAEdmMetadataPostProcessor; import com.sap.olingo.jpa.metadata.core.edm.extension.vocabularies.AnnotationProvider; import com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAEdmNameBuilder; import com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAServiceDocument; import com.sap.olingo.jpa.metadata.core.edm.mapper.exception.ODataJPAModelException; +import jakarta.persistence.metamodel.Metamodel; + public final class JPAServiceDocumentFactory { private final JPAEdmNameBuilder nameBuilder; diff --git a/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/JPATypeConverter.java b/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/JPATypeConverter.java index 4bbd357ad..2354160df 100644 --- a/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/JPATypeConverter.java +++ b/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/JPATypeConverter.java @@ -15,17 +15,17 @@ import java.util.Set; import java.util.UUID; -import javax.persistence.Lob; -import javax.persistence.Temporal; -import javax.persistence.TemporalType; -import javax.persistence.metamodel.Attribute; - import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind; import org.apache.olingo.commons.api.edm.geo.Geospatial.Dimension; import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmGeospatial; import com.sap.olingo.jpa.metadata.core.edm.mapper.exception.ODataJPAModelException; +import jakarta.persistence.Lob; +import jakarta.persistence.Temporal; +import jakarta.persistence.TemporalType; +import jakarta.persistence.metamodel.Attribute; + /** * This class holds utility methods for type conversions between JPA Java types and OData Types. * diff --git a/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/reuse/OffsetDateTimeConverter.java b/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/reuse/OffsetDateTimeConverter.java deleted file mode 100644 index b73758f5b..000000000 --- a/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/reuse/OffsetDateTimeConverter.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.sap.olingo.jpa.metadata.reuse; - -import java.time.OffsetDateTime; -import java.time.ZonedDateTime; - -import javax.persistence.AttributeConverter; - -/** - * Default converter to convert from {@link java.time.OffsetDateTime} to {@link java.time.ZonedDateTime}. This is - * required, as Olingo 4.7.1 only supports ZonedDateTime, where as JPA 2.2 supports OffsetDateTime. - * @author Oliver Grande - * Created: 09.03.2020 - * - */ - -public class OffsetDateTimeConverter implements AttributeConverter { - @Override - public OffsetDateTime convertToDatabaseColumn(final ZonedDateTime zonedDateTime) { - return zonedDateTime == null ? null : zonedDateTime.toOffsetDateTime(); - } - - @Override - public ZonedDateTime convertToEntityAttribute(final OffsetDateTime dateTimeWithOffset) { - return dateTimeWithOffset == null ? null : dateTimeWithOffset.toZonedDateTime(); - } - -} diff --git a/jpa/odata-jpa-metadata/src/main/resources/metadata-exceptions-i18n.properties b/jpa/odata-jpa-metadata/src/main/resources/metadata-exceptions-i18n.properties index 3a8fb758e..763d3155e 100644 --- a/jpa/odata-jpa-metadata/src/main/resources/metadata-exceptions-i18n.properties +++ b/jpa/odata-jpa-metadata/src/main/resources/metadata-exceptions-i18n.properties @@ -98,4 +98,5 @@ ODataJPAModelException.ON_LEFT_ATTRIBUTE_NULL = ON condition left attribute is n ODataJPAModelException.ON_RIGHT_ATTRIBUTE_NULL = ON condition right attribute is null / not found. ODataJPAModelException.DB_TYPE_NOT_DETERMINED = Type of column could not be determined for association '%1$s' of '%2$s'. -ODataJPAModelException.FILE_NOT_FOUND = File with file path '%1$s' not found. \ No newline at end of file +ODataJPAModelException.FILE_NOT_FOUND = File with file path '%1$s' not found. +ODataJPAModelException.MISSING_ONE_TO_ONE_ANNOTATION = Association '%1$s' of '%2$s' requires a cardinality annotation. diff --git a/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/api/JPAEdmProviderTest.java b/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/api/JPAEdmProviderTest.java index b2131ec39..74aa4ede6 100644 --- a/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/api/JPAEdmProviderTest.java +++ b/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/api/JPAEdmProviderTest.java @@ -13,9 +13,10 @@ import java.util.Collections; import java.util.List; -import javax.persistence.EntityManagerFactory; import javax.sql.DataSource; +import jakarta.persistence.EntityManagerFactory; + import org.apache.olingo.commons.api.edm.FullQualifiedName; import org.apache.olingo.commons.api.edm.provider.CsdlAction; import org.apache.olingo.commons.api.edm.provider.CsdlActionImport; @@ -345,7 +346,7 @@ private FullQualifiedName buildContainerFQN() { return fqn; } - private class PostProcessor extends JPAEdmMetadataPostProcessor { + private class PostProcessor implements JPAEdmMetadataPostProcessor { @Override public void processNavigationProperty(final IntermediateNavigationPropertyAccess property, final String jpaManagedTypeClassName) {} diff --git a/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/CustomJPANameBuilder.java b/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/CustomJPANameBuilder.java index ef25a6700..ddc69fabb 100644 --- a/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/CustomJPANameBuilder.java +++ b/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/CustomJPANameBuilder.java @@ -1,13 +1,13 @@ /** - * + * */ package com.sap.olingo.jpa.metadata.core.edm.mapper.impl; import java.util.stream.IntStream; -import javax.persistence.metamodel.Attribute; -import javax.persistence.metamodel.EmbeddableType; -import javax.persistence.metamodel.EntityType; +import jakarta.persistence.metamodel.Attribute; +import jakarta.persistence.metamodel.EmbeddableType; +import jakarta.persistence.metamodel.EntityType; import com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAEdmNameBuilder; diff --git a/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateActionFactoryTest.java b/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateActionFactoryTest.java index 20c408df7..56eab0276 100644 --- a/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateActionFactoryTest.java +++ b/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateActionFactoryTest.java @@ -38,8 +38,8 @@ void setUp() throws ODataJPAModelException { @Test void checkReturnEmptyMapIfReflectionsNull() throws ODataJPAModelException { - final Reflections r = null; - assertNotNull(cut.create(new JPADefaultEdmNameBuilder(PUNIT_NAME), r, helper.schema)); + final Reflections reflections = null; + assertNotNull(cut.create(new JPADefaultEdmNameBuilder(PUNIT_NAME), reflections, helper.schema)); } @Test @@ -77,6 +77,6 @@ void checkReturnMapWithWithOverloadedActions() throws ODataJPAModelException { javaActions.add(ActionWithOverload.class); final Map act = cut.create(new JPADefaultEdmNameBuilder( PUNIT_NAME), reflections, helper.schema); - assertEquals(2, act.size()); + assertEquals(3, act.size()); } } diff --git a/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateCollectionPropertyTest.java b/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateCollectionPropertyTest.java index 7d806ab81..b6f881915 100644 --- a/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateCollectionPropertyTest.java +++ b/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateCollectionPropertyTest.java @@ -13,11 +13,11 @@ import java.util.ArrayList; import java.util.List; -import javax.persistence.metamodel.Attribute.PersistentAttributeType; -import javax.persistence.metamodel.ManagedType; -import javax.persistence.metamodel.PluralAttribute; -import javax.persistence.metamodel.PluralAttribute.CollectionType; -import javax.persistence.metamodel.Type.PersistenceType; +import jakarta.persistence.metamodel.Attribute.PersistentAttributeType; +import jakarta.persistence.metamodel.ManagedType; +import jakarta.persistence.metamodel.PluralAttribute; +import jakarta.persistence.metamodel.PluralAttribute.CollectionType; +import jakarta.persistence.metamodel.Type.PersistenceType; import org.apache.olingo.commons.api.edm.EdmPrimitiveType; import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind; @@ -69,7 +69,7 @@ void setup() throws ODataJPAModelException { void checkSimpleCollectionPropertyType() throws ODataJPAModelException { when(jpaAttribute.getName()).thenReturn("Text"); @SuppressWarnings("rawtypes") - final javax.persistence.metamodel.Type type = mock(javax.persistence.metamodel.Type.class); + final jakarta.persistence.metamodel.Type type = mock(jakarta.persistence.metamodel.Type.class); when(type.getPersistenceType()).thenReturn(PersistenceType.BASIC); when(type.getJavaType()).thenAnswer(new Answer>() { @Override diff --git a/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateComplexTypeTest.java b/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateComplexTypeTest.java index ec8f400ba..28de9e6b6 100644 --- a/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateComplexTypeTest.java +++ b/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateComplexTypeTest.java @@ -14,7 +14,7 @@ import java.util.List; import java.util.Set; -import javax.persistence.metamodel.EmbeddableType; +import jakarta.persistence.metamodel.EmbeddableType; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Disabled; @@ -335,7 +335,7 @@ public Class answer(final InvocationOnMock invocation) throws Throwable { assertNull(ct.getBaseType()); } - private class PostProcessorSetIgnore extends JPAEdmMetadataPostProcessor { + private class PostProcessorSetIgnore implements JPAEdmMetadataPostProcessor { @Override public void processProperty(final IntermediatePropertyAccess property, final String jpaManagedTypeClassName) { diff --git a/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateContainerTest.java b/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateContainerTest.java index c6c24f6e7..4cec044be 100644 --- a/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateContainerTest.java +++ b/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateContainerTest.java @@ -10,7 +10,7 @@ import java.util.List; import java.util.Set; -import javax.persistence.metamodel.EntityType; +import jakarta.persistence.metamodel.EntityType; import org.apache.olingo.commons.api.edm.provider.CsdlAnnotation; import org.apache.olingo.commons.api.edm.provider.CsdlEntitySet; @@ -292,7 +292,7 @@ void checkReturnEntitySetBasedOnInternalEntityType() throws ODataJPAModelExcepti } - private class PostProcessorSetIgnore extends JPAEdmMetadataPostProcessor { + private class PostProcessorSetIgnore implements JPAEdmMetadataPostProcessor { @Override public void processProperty(final IntermediatePropertyAccess property, final String jpaManagedTypeClassName) { diff --git a/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateDescriptionPropertyTest.java b/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateDescriptionPropertyTest.java index 8fb1db4b7..1c61c63f9 100644 --- a/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateDescriptionPropertyTest.java +++ b/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateDescriptionPropertyTest.java @@ -17,10 +17,10 @@ import java.util.Collections; import java.util.List; -import javax.persistence.metamodel.Attribute; -import javax.persistence.metamodel.EmbeddableType; -import javax.persistence.metamodel.EntityType; -import javax.persistence.metamodel.ManagedType; +import jakarta.persistence.metamodel.Attribute; +import jakarta.persistence.metamodel.EmbeddableType; +import jakarta.persistence.metamodel.EntityType; +import jakarta.persistence.metamodel.ManagedType; import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind; import org.apache.olingo.commons.api.edm.provider.CsdlAnnotation; @@ -393,7 +393,7 @@ void checkPathHasJoinTableNull() throws ODataJPAModelException { assertNull(act.getJoinTable()); } - private class PostProcessorSetName extends JPAEdmMetadataPostProcessor { + private class PostProcessorSetName implements JPAEdmMetadataPostProcessor { @Override public void processProperty(final IntermediatePropertyAccess property, final String jpaManagedTypeClassName) { diff --git a/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateEmbeddedIdPropertyTest.java b/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateEmbeddedIdPropertyTest.java index 5c54ed533..dabd50d91 100644 --- a/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateEmbeddedIdPropertyTest.java +++ b/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateEmbeddedIdPropertyTest.java @@ -8,8 +8,8 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; -import javax.persistence.metamodel.Attribute; -import javax.persistence.metamodel.EntityType; +import jakarta.persistence.metamodel.Attribute; +import jakarta.persistence.metamodel.EntityType; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; diff --git a/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateEntitySetTest.java b/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateEntitySetTest.java index becc53c08..22f04af53 100644 --- a/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateEntitySetTest.java +++ b/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateEntitySetTest.java @@ -17,8 +17,8 @@ import java.util.Map; import java.util.Set; -import javax.persistence.Entity; -import javax.persistence.metamodel.EntityType; +import jakarta.persistence.Entity; +import jakarta.persistence.metamodel.EntityType; import org.apache.olingo.commons.api.edm.provider.CsdlAnnotation; import org.apache.olingo.commons.api.edm.provider.CsdlEntitySet; @@ -208,7 +208,7 @@ private void createAnnotation() { .thenReturn(annotations); } - private class PostProcessor extends JPAEdmMetadataPostProcessor { + private class PostProcessor implements JPAEdmMetadataPostProcessor { @Override public void processProperty(final IntermediatePropertyAccess property, final String jpaManagedTypeClassName) { diff --git a/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateEntityTypeTest.java b/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateEntityTypeTest.java index 97be9681e..a0d59ba9b 100644 --- a/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateEntityTypeTest.java +++ b/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateEntityTypeTest.java @@ -21,8 +21,8 @@ import java.util.Map; import java.util.Optional; -import javax.persistence.Table; -import javax.persistence.metamodel.EntityType; +import jakarta.persistence.Table; +import jakarta.persistence.metamodel.EntityType; import org.apache.olingo.commons.api.edm.EdmProperty; import org.apache.olingo.commons.api.edm.provider.CsdlAnnotation; @@ -43,6 +43,7 @@ import com.sap.olingo.jpa.metadata.core.edm.extension.vocabularies.ODataPathNotFoundException; import com.sap.olingo.jpa.metadata.core.edm.extension.vocabularies.ODataPropertyPath; import com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAAssociationAttribute; +import com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAAssociationPath; import com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAAttribute; import com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAEntityType; import com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAOnConditionItem; @@ -54,7 +55,6 @@ import com.sap.olingo.jpa.metadata.core.edm.mapper.extension.IntermediateNavigationPropertyAccess; import com.sap.olingo.jpa.metadata.core.edm.mapper.extension.IntermediatePropertyAccess; import com.sap.olingo.jpa.metadata.core.edm.mapper.extension.IntermediateReferenceList; -import com.sap.olingo.jpa.processor.core.errormodel.SingletonAsEntitySet; import com.sap.olingo.jpa.processor.core.errormodel.TeamWithTransientError; import com.sap.olingo.jpa.processor.core.testmodel.ABCClassification; import com.sap.olingo.jpa.processor.core.testmodel.AdministrativeDivision; @@ -227,6 +227,18 @@ void checkGetAssociationOfComplexTypeByNameJoinColumns() throws ODataJPAModelExc assertEquals(3, actCount, "Not all join columns found"); } + @Test + void checkGetAssociationOfMappedByWithVirtualProperty() throws ODataJPAModelException { + + final IntermediateStructuredType et = new IntermediateEntityType<>( + new JPADefaultEdmNameBuilder(PUNIT_NAME), getEntityType(AssociationOneToOneSource.class), schema); + final JPAAssociationPath act = et.getAssociationPath("DefaultTarget"); + assertEquals(1, act.getJoinColumnsList().size()); + final JPAOnConditionItem actColumn = act.getJoinColumnsList().get(0); + assertEquals("ID", actColumn.getRightPath().getAlias()); + assertEquals("Defaulttarget_id", actColumn.getLeftPath().getAlias()); + } + @Test void checkGetPropertiesSkipIgnored() throws ODataJPAModelException { final PostProcessorSetIgnore postProcessorDouble = new PostProcessorSetIgnore(); @@ -705,14 +717,6 @@ void checkAsSingletonReturnsFalseIfTypeIsNotAnnotated() { assertFalse(et.asSingleton()); } - @Test - void checkAsSingletonErrorOnAsEntitySet() throws ODataJPAModelException { - final EntityType jpaEt = errorEmf.getMetamodel().entity(SingletonAsEntitySet.class); - final IntermediateEntityType et = new IntermediateEntityType<>(new JPADefaultEdmNameBuilder( - ERROR_PUNIT), jpaEt, errorSchema); - assertThrows(ODataJPAModelException.class, () -> et.getEdmItem()); - } - @Test void checkAnnotatedAsEntityType() { final IntermediateEntityType et = new IntermediateEntityType<>(new JPADefaultEdmNameBuilder( @@ -1105,7 +1109,7 @@ private void assertInherited(final List act) { fail("Inherited not found"); } - private static class PostProcessorSetIgnore extends JPAEdmMetadataPostProcessor { + private static class PostProcessorSetIgnore implements JPAEdmMetadataPostProcessor { @Override public void processProperty(final IntermediatePropertyAccess property, final String jpaManagedTypeClassName) { diff --git a/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateJoinTableTest.java b/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateJoinTableTest.java index 4a28d8ca3..48ba6edd1 100644 --- a/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateJoinTableTest.java +++ b/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateJoinTableTest.java @@ -8,9 +8,9 @@ import java.util.ArrayList; import java.util.List; -import javax.persistence.JoinTable; -import javax.persistence.metamodel.Attribute; -import javax.persistence.metamodel.EntityType; +import jakarta.persistence.JoinTable; +import jakarta.persistence.metamodel.Attribute; +import jakarta.persistence.metamodel.EntityType; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; diff --git a/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateNavigationPropertyTest.java b/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateNavigationPropertyTest.java index ee81d377a..6ad08462a 100644 --- a/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateNavigationPropertyTest.java +++ b/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateNavigationPropertyTest.java @@ -20,10 +20,10 @@ import java.util.HashSet; import java.util.List; -import javax.persistence.metamodel.Attribute; -import javax.persistence.metamodel.EmbeddableType; -import javax.persistence.metamodel.EntityType; -import javax.persistence.metamodel.ManagedType; +import jakarta.persistence.metamodel.Attribute; +import jakarta.persistence.metamodel.EmbeddableType; +import jakarta.persistence.metamodel.EntityType; +import jakarta.persistence.metamodel.ManagedType; import org.apache.olingo.commons.api.edm.provider.CsdlAnnotation; import org.apache.olingo.commons.api.edm.provider.CsdlOnDelete; @@ -947,7 +947,7 @@ public Class answer(final InvocationOnMock invocation) throws Throwable { return jpaAttribute; } - private class PostProcessorSetName extends JPAEdmMetadataPostProcessor { + private class PostProcessorSetName implements JPAEdmMetadataPostProcessor { @Override public void processNavigationProperty(final IntermediateNavigationPropertyAccess property, final String jpaManagedTypeClassName) { @@ -971,7 +971,7 @@ public void processEntityType(final IntermediateEntityTypeAccess entity) {} public void provideReferences(final IntermediateReferenceList references) throws ODataJPAModelException {} } - private class PostProcessorOneDelete extends JPAEdmMetadataPostProcessor { + private class PostProcessorOneDelete implements JPAEdmMetadataPostProcessor { @Override public void processNavigationProperty(final IntermediateNavigationPropertyAccess property, final String jpaManagedTypeClassName) { diff --git a/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateOperationHelperTest.java b/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateOperationHelperTest.java new file mode 100644 index 000000000..7f76f6ac1 --- /dev/null +++ b/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateOperationHelperTest.java @@ -0,0 +1,32 @@ +package com.sap.olingo.jpa.metadata.core.edm.mapper.impl; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.stream.Stream; + +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; + +import com.sap.olingo.jpa.metadata.core.edm.mapper.testobjects.TestActionCollection; + +class IntermediateOperationHelperTest { + static Stream provideIsCollection() { + return Stream.of( + Arguments.of(ArrayList.class, true), + Arguments.of(List.class, true), + Arguments.of(TestActionCollection.class, true), + Arguments.of(Integer.class, false), + Arguments.of(HashMap.class, false), + Arguments.of(IntermediateProperty.class, false)); + } + + @ParameterizedTest + @MethodSource("provideIsCollection") + void testIsCollection(final Class clazz, final boolean expected) { + assertEquals(expected, IntermediateOperationHelper.isCollection(clazz)); + } +} diff --git a/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateReferencesTest.java b/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateReferencesTest.java index 558ce4e49..1c5ac86e5 100644 --- a/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateReferencesTest.java +++ b/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateReferencesTest.java @@ -257,7 +257,7 @@ void checkAddReferenceWithURIRethrowsException() throws URISyntaxException, ODat assertNotNull(act.getCause()); } - class PostProcessor extends JPAEdmMetadataPostProcessor { + class PostProcessor implements JPAEdmMetadataPostProcessor { @Override public void processNavigationProperty(final IntermediateNavigationPropertyAccess property, diff --git a/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateSchemaTest.java b/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateSchemaTest.java index 830ecb056..2b078d10c 100644 --- a/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateSchemaTest.java +++ b/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateSchemaTest.java @@ -14,8 +14,8 @@ import java.util.Collections; import java.util.HashSet; -import javax.persistence.metamodel.EntityType; -import javax.persistence.metamodel.Metamodel; +import jakarta.persistence.metamodel.EntityType; +import jakarta.persistence.metamodel.Metamodel; import org.apache.olingo.commons.api.edm.EdmEnumType; import org.apache.olingo.commons.api.edm.FullQualifiedName; diff --git a/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateSimplePropertyTest.java b/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateSimplePropertyTest.java index 7e00e4ab3..49d146787 100644 --- a/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateSimplePropertyTest.java +++ b/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateSimplePropertyTest.java @@ -33,12 +33,12 @@ import java.util.List; import java.util.Map; -import javax.persistence.Column; -import javax.persistence.metamodel.Attribute; -import javax.persistence.metamodel.Attribute.PersistentAttributeType; -import javax.persistence.metamodel.EmbeddableType; -import javax.persistence.metamodel.ManagedType; -import javax.persistence.metamodel.SingularAttribute; +import jakarta.persistence.Column; +import jakarta.persistence.metamodel.Attribute; +import jakarta.persistence.metamodel.Attribute.PersistentAttributeType; +import jakarta.persistence.metamodel.EmbeddableType; +import jakarta.persistence.metamodel.ManagedType; +import jakarta.persistence.metamodel.SingularAttribute; import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind; import org.apache.olingo.commons.api.edm.geo.Geospatial.Dimension; @@ -1027,7 +1027,7 @@ private Column createDummyColumn() { return jpaColumn; } - private class PostProcessorSetName extends JPAEdmMetadataPostProcessor { + private class PostProcessorSetName implements JPAEdmMetadataPostProcessor { @Override public void processProperty(final IntermediatePropertyAccess property, final String jpaManagedTypeClassName) { diff --git a/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateSingletonTest.java b/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateSingletonTest.java index 27db8f24f..95ffb24bc 100644 --- a/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateSingletonTest.java +++ b/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateSingletonTest.java @@ -16,7 +16,7 @@ import java.util.List; import java.util.Map; -import javax.persistence.Entity; +import jakarta.persistence.Entity; import org.apache.olingo.commons.api.edm.provider.CsdlAnnotation; import org.apache.olingo.commons.api.edm.provider.CsdlSingleton; @@ -200,7 +200,7 @@ private void createAnnotation() { .thenReturn(annotations); } - private class PostProcessor extends JPAEdmMetadataPostProcessor { + private class PostProcessor implements JPAEdmMetadataPostProcessor { @Override public void processProperty(final IntermediatePropertyAccess property, final String jpaManagedTypeClassName) { diff --git a/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateStructuredTypeTransientPluralAttributeTest.java b/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateStructuredTypeTransientPluralAttributeTest.java index 553d5cbc9..21f88c0a5 100644 --- a/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateStructuredTypeTransientPluralAttributeTest.java +++ b/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateStructuredTypeTransientPluralAttributeTest.java @@ -12,8 +12,8 @@ import java.util.Map; import java.util.Set; -import javax.persistence.metamodel.ManagedType; -import javax.persistence.metamodel.PluralAttribute.CollectionType; +import jakarta.persistence.metamodel.ManagedType; +import jakarta.persistence.metamodel.PluralAttribute.CollectionType; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DynamicTest; diff --git a/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateStructuredTypeVirtualAttributeTest.java b/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateStructuredTypeVirtualAttributeTest.java index 126c58645..704fa1d26 100644 --- a/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateStructuredTypeVirtualAttributeTest.java +++ b/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateStructuredTypeVirtualAttributeTest.java @@ -1,12 +1,12 @@ package com.sap.olingo.jpa.metadata.core.edm.mapper.impl; -import static javax.persistence.metamodel.Attribute.PersistentAttributeType.BASIC; +import static jakarta.persistence.metamodel.Attribute.PersistentAttributeType.BASIC; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNull; import static org.mockito.Mockito.mock; -import javax.persistence.metamodel.ManagedType; +import jakarta.persistence.metamodel.ManagedType; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; diff --git a/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateVirtualPropertyTest.java b/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateVirtualPropertyTest.java index 9034ea032..3daa30ac9 100644 --- a/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateVirtualPropertyTest.java +++ b/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateVirtualPropertyTest.java @@ -12,8 +12,8 @@ import java.util.ArrayList; import java.util.Arrays; -import javax.persistence.metamodel.Attribute; -import javax.persistence.metamodel.ManagedType; +import jakarta.persistence.metamodel.Attribute; +import jakarta.persistence.metamodel.ManagedType; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DynamicTest; diff --git a/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateWrongAnnotationTest.java b/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateWrongAnnotationTest.java index 5aef46cfc..419f09fbe 100644 --- a/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateWrongAnnotationTest.java +++ b/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateWrongAnnotationTest.java @@ -14,10 +14,10 @@ import java.util.ArrayList; -import javax.persistence.EntityManagerFactory; -import javax.persistence.metamodel.Attribute; -import javax.persistence.metamodel.EntityType; -import javax.persistence.metamodel.PluralAttribute; +import jakarta.persistence.EntityManagerFactory; +import jakarta.persistence.metamodel.Attribute; +import jakarta.persistence.metamodel.EntityType; +import jakarta.persistence.metamodel.PluralAttribute; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; diff --git a/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/JPAQueryExtensionProviderTest.java b/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/JPAQueryExtensionProviderTest.java index 97926e6e4..c0175a3ea 100644 --- a/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/JPAQueryExtensionProviderTest.java +++ b/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/JPAQueryExtensionProviderTest.java @@ -7,9 +7,9 @@ import java.util.List; import java.util.Map; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.Expression; -import javax.persistence.criteria.From; +import jakarta.persistence.criteria.CriteriaBuilder; +import jakarta.persistence.criteria.Expression; +import jakarta.persistence.criteria.From; import org.junit.jupiter.api.Test; diff --git a/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/JPATypeConverterTest.java b/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/JPATypeConverterTest.java index 76d78248c..3aa1f151d 100644 --- a/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/JPATypeConverterTest.java +++ b/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/JPATypeConverterTest.java @@ -24,10 +24,10 @@ import java.util.UUID; import java.util.stream.Stream; -import javax.persistence.Lob; -import javax.persistence.Temporal; -import javax.persistence.TemporalType; -import javax.persistence.metamodel.Attribute; +import jakarta.persistence.Lob; +import jakarta.persistence.Temporal; +import jakarta.persistence.TemporalType; +import jakarta.persistence.metamodel.Attribute; import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind; import org.apache.olingo.commons.api.edm.geo.Geospatial.Dimension; diff --git a/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/TestHelper.java b/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/TestHelper.java index b830350b5..f72133c11 100644 --- a/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/TestHelper.java +++ b/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/TestHelper.java @@ -9,13 +9,13 @@ import java.util.HashSet; import java.util.List; -import javax.persistence.metamodel.Attribute; -import javax.persistence.metamodel.EmbeddableType; -import javax.persistence.metamodel.EntityType; -import javax.persistence.metamodel.ManagedType; -import javax.persistence.metamodel.Metamodel; -import javax.persistence.metamodel.PluralAttribute; -import javax.persistence.metamodel.SingularAttribute; +import jakarta.persistence.metamodel.Attribute; +import jakarta.persistence.metamodel.EmbeddableType; +import jakarta.persistence.metamodel.EntityType; +import jakarta.persistence.metamodel.ManagedType; +import jakarta.persistence.metamodel.Metamodel; +import jakarta.persistence.metamodel.PluralAttribute; +import jakarta.persistence.metamodel.SingularAttribute; import org.reflections8.Reflections; diff --git a/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/TestMappingRoot.java b/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/TestMappingRoot.java index feddc4067..fb6b78e92 100644 --- a/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/TestMappingRoot.java +++ b/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/TestMappingRoot.java @@ -2,8 +2,8 @@ import java.util.Set; -import javax.persistence.EntityManagerFactory; -import javax.persistence.metamodel.EntityType; +import jakarta.persistence.EntityManagerFactory; +import jakarta.persistence.metamodel.EntityType; import org.junit.jupiter.api.BeforeAll; diff --git a/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/testaction/ActionWithOverload.java b/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/testaction/ActionWithOverload.java index 98abbfb58..c0908dd0c 100644 --- a/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/testaction/ActionWithOverload.java +++ b/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/testaction/ActionWithOverload.java @@ -1,12 +1,13 @@ package com.sap.olingo.jpa.metadata.core.edm.mapper.testaction; -import javax.persistence.EntityManager; +import jakarta.persistence.EntityManager; import com.sap.olingo.jpa.metadata.api.JPAHttpHeaderMap; import com.sap.olingo.jpa.metadata.api.JPARequestParameterMap; import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmAction; import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmParameter; import com.sap.olingo.jpa.metadata.core.edm.mapper.extension.ODataAction; +import com.sap.olingo.jpa.processor.core.testmodel.AdministrativeDivision; import com.sap.olingo.jpa.processor.core.testmodel.BusinessPartner; import com.sap.olingo.jpa.processor.core.testmodel.Person; @@ -26,4 +27,9 @@ public void baseAction(@EdmParameter(name = "Binding") final BusinessPartner par public void overloadedAction(@EdmParameter(name = "Binding") final Person partner) { } + + @EdmAction(name = "DoSometingFunny", isBound = true) + public void overloadedAction(@EdmParameter(name = "Binding") final AdministrativeDivision partner) { + + } } diff --git a/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/testaction/Actions.java b/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/testaction/Actions.java index 7365b121f..416f73e22 100644 --- a/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/testaction/Actions.java +++ b/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/testaction/Actions.java @@ -2,7 +2,7 @@ import java.math.BigDecimal; -import javax.persistence.EntityManager; +import jakarta.persistence.EntityManager; import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmAction; import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmParameter; @@ -16,15 +16,15 @@ public Actions(final EntityManager em) { @EdmAction(name = "BoundNoImport", isBound = true) public void boundNoImport( - @EdmParameter(name = "Person") Person person, - @EdmParameter(name = "A", precision = 34, scale = 10) BigDecimal a) { + @EdmParameter(name = "Person") final Person person, + @EdmParameter(name = "A", precision = 34, scale = 10) final BigDecimal a) { // Do nothing } @EdmAction(name = "WithImport", isBound = false) public void withImport( - @EdmParameter(name = "Person") Person person, - @EdmParameter(name = "A", precision = 34, scale = 10) BigDecimal a) { + @EdmParameter(name = "Person") final Person person, + @EdmParameter(name = "A", precision = 34, scale = 10) final BigDecimal a) { // Do nothing } } diff --git a/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/testobjects/ConverterWithConstructorError.java b/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/testobjects/ConverterWithConstructorError.java index 096ac2c36..ca96a1473 100644 --- a/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/testobjects/ConverterWithConstructorError.java +++ b/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/testobjects/ConverterWithConstructorError.java @@ -1,6 +1,6 @@ package com.sap.olingo.jpa.metadata.core.edm.mapper.testobjects; -import javax.persistence.AttributeConverter; +import jakarta.persistence.AttributeConverter; public class ConverterWithConstructorError implements AttributeConverter[], Integer> { diff --git a/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/testobjects/ExampleFunctionForFilter.java b/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/testobjects/ExampleFunctionForFilter.java index a5aeea3a8..b6088d531 100644 --- a/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/testobjects/ExampleFunctionForFilter.java +++ b/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/testobjects/ExampleFunctionForFilter.java @@ -2,8 +2,8 @@ import java.time.LocalDate; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.From; +import jakarta.persistence.criteria.CriteriaBuilder; +import jakarta.persistence.criteria.From; import com.sap.olingo.jpa.metadata.api.JPAODataQueryContext; import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmFunction; diff --git a/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/testobjects/ExampleJavaEmConstructor.java b/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/testobjects/ExampleJavaEmConstructor.java index 92210370f..8d9fc23d6 100644 --- a/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/testobjects/ExampleJavaEmConstructor.java +++ b/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/testobjects/ExampleJavaEmConstructor.java @@ -1,27 +1,27 @@ package com.sap.olingo.jpa.metadata.core.edm.mapper.testobjects; -import javax.persistence.EntityManager; +import jakarta.persistence.EntityManager; import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmAction; import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmFunction; import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmFunction.ReturnType; +import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmParameter; import com.sap.olingo.jpa.metadata.core.edm.mapper.extension.ODataAction; import com.sap.olingo.jpa.metadata.core.edm.mapper.extension.ODataFunction; -import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmParameter; public class ExampleJavaEmConstructor implements ODataFunction, ODataAction { - public ExampleJavaEmConstructor(EntityManager em) { + public ExampleJavaEmConstructor(final EntityManager em) { super(); } @EdmFunction(name = "", returnType = @ReturnType) public Integer sum( - @EdmParameter(name = "A") short a, @EdmParameter(name = "B") int b) { + @EdmParameter(name = "A") final short a, @EdmParameter(name = "B") final int b) { return a + b; } @EdmAction(name = "") public void mul( - @EdmParameter(name = "A") short a, @EdmParameter(name = "B") int b) {} + @EdmParameter(name = "A") final short a, @EdmParameter(name = "B") final int b) {} } diff --git a/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/testobjects/ExampleJavaPrivateConstructor.java b/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/testobjects/ExampleJavaPrivateConstructor.java index d5e7978d1..a83effe28 100644 --- a/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/testobjects/ExampleJavaPrivateConstructor.java +++ b/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/testobjects/ExampleJavaPrivateConstructor.java @@ -1,27 +1,27 @@ package com.sap.olingo.jpa.metadata.core.edm.mapper.testobjects; -import javax.persistence.EntityManager; +import jakarta.persistence.EntityManager; import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmAction; import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmFunction; import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmFunction.ReturnType; +import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmParameter; import com.sap.olingo.jpa.metadata.core.edm.mapper.extension.ODataAction; import com.sap.olingo.jpa.metadata.core.edm.mapper.extension.ODataFunction; -import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmParameter; public class ExampleJavaPrivateConstructor implements ODataFunction, ODataAction { - private ExampleJavaPrivateConstructor(EntityManager em) { + private ExampleJavaPrivateConstructor(final EntityManager em) { super(); } @EdmFunction(name = "", returnType = @ReturnType) public Integer sum( - @EdmParameter(name = "A") short a, @EdmParameter(name = "B") int b) { + @EdmParameter(name = "A") final short a, @EdmParameter(name = "B") final int b) { return a + b; } @EdmAction(name = "") public void mul( - @EdmParameter(name = "A") short a, @EdmParameter(name = "B") int b) {} + @EdmParameter(name = "A") final short a, @EdmParameter(name = "B") final int b) {} } diff --git a/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/testobjects/ExampleJavaTwoParameterConstructor.java b/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/testobjects/ExampleJavaTwoParameterConstructor.java index 0d05d82b6..55ef3c26c 100644 --- a/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/testobjects/ExampleJavaTwoParameterConstructor.java +++ b/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/testobjects/ExampleJavaTwoParameterConstructor.java @@ -1,27 +1,27 @@ package com.sap.olingo.jpa.metadata.core.edm.mapper.testobjects; -import javax.persistence.EntityManager; +import jakarta.persistence.EntityManager; import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmAction; import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmFunction; import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmFunction.ReturnType; +import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmParameter; import com.sap.olingo.jpa.metadata.core.edm.mapper.extension.ODataAction; import com.sap.olingo.jpa.metadata.core.edm.mapper.extension.ODataFunction; -import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmParameter; public class ExampleJavaTwoParameterConstructor implements ODataFunction, ODataAction { - public ExampleJavaTwoParameterConstructor(EntityManager em, Integer a) { + public ExampleJavaTwoParameterConstructor(final EntityManager em, final Integer a) { super(); } @EdmFunction(name = "", returnType = @ReturnType) public Integer sum( - @EdmParameter(name = "A") short a, @EdmParameter(name = "B") int b) { + @EdmParameter(name = "A") final short a, @EdmParameter(name = "B") final int b) { return a + b; } @EdmAction(name = "") public void mul( - @EdmParameter(name = "A") short a, @EdmParameter(name = "B") int b) {} + @EdmParameter(name = "A") final short a, @EdmParameter(name = "B") final int b) {} } diff --git a/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/testobjects/FileAccessConverter.java b/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/testobjects/FileAccessConverter.java index b1a59fc65..ec8cfb6f2 100644 --- a/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/testobjects/FileAccessConverter.java +++ b/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/testobjects/FileAccessConverter.java @@ -4,21 +4,21 @@ import java.util.Arrays; import java.util.List; -import javax.persistence.AttributeConverter; +import jakarta.persistence.AttributeConverter; public class FileAccessConverter implements AttributeConverter { @Override - public Short convertToDatabaseColumn(FileAccess[] attributes) { + public Short convertToDatabaseColumn(final FileAccess[] attributes) { return attributes[0].getValue(); } @Override - public FileAccess[] convertToEntityAttribute(Short dbData) { + public FileAccess[] convertToEntityAttribute(final Short dbData) { if (dbData == null) return null; final List accesses = new ArrayList<>(); - for (FileAccess e : Arrays.asList(FileAccess.values())) { + for (final FileAccess e : Arrays.asList(FileAccess.values())) { if (e.getValue() == dbData) accesses.add(e); } diff --git a/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/testobjects/TestActionCollection.java b/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/testobjects/TestActionCollection.java new file mode 100644 index 000000000..007429033 --- /dev/null +++ b/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/testobjects/TestActionCollection.java @@ -0,0 +1,7 @@ +package com.sap.olingo.jpa.metadata.core.edm.mapper.testobjects; + +import com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAAction; + +public interface TestActionCollection extends TestCollectionInterface, JPAAction { + +} diff --git a/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/testobjects/TestCollectionInterface.java b/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/testobjects/TestCollectionInterface.java new file mode 100644 index 000000000..206a66474 --- /dev/null +++ b/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/testobjects/TestCollectionInterface.java @@ -0,0 +1,8 @@ +package com.sap.olingo.jpa.metadata.core.edm.mapper.testobjects; + +import java.io.Serializable; +import java.util.Collection; + +public interface TestCollectionInterface extends Serializable, Collection { + +} \ No newline at end of file diff --git a/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/testobjects/WrongFunctionConstructor.java b/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/testobjects/WrongFunctionConstructor.java index 1aab0fa7a..d522a3def 100644 --- a/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/testobjects/WrongFunctionConstructor.java +++ b/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/testobjects/WrongFunctionConstructor.java @@ -1,6 +1,6 @@ package com.sap.olingo.jpa.metadata.core.edm.mapper.testobjects; -import javax.persistence.EntityManager; +import jakarta.persistence.EntityManager; import com.sap.olingo.jpa.metadata.api.JPAODataQueryContext; import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmFunction; diff --git a/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/testobjects/WrongMemberConverter.java b/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/testobjects/WrongMemberConverter.java index 7d2d23189..a1f9437d8 100644 --- a/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/testobjects/WrongMemberConverter.java +++ b/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/testobjects/WrongMemberConverter.java @@ -4,21 +4,21 @@ import java.util.Arrays; import java.util.List; -import javax.persistence.AttributeConverter; +import jakarta.persistence.AttributeConverter; public class WrongMemberConverter implements AttributeConverter { @Override - public Integer convertToDatabaseColumn(WrongMember[] attributes) { + public Integer convertToDatabaseColumn(final WrongMember[] attributes) { return attributes[0].getValue(); } @Override - public WrongMember[] convertToEntityAttribute(Integer dbData) { + public WrongMember[] convertToEntityAttribute(final Integer dbData) { if (dbData == null) return null; final List accesses = new ArrayList<>(); - for (WrongMember e : Arrays.asList(WrongMember.values())) { + for (final WrongMember e : Arrays.asList(WrongMember.values())) { if (e.getValue() == dbData) accesses.add(e); } diff --git a/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/testobjects/WrongTypeConverter.java b/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/testobjects/WrongTypeConverter.java index 5cc1af983..6beffe555 100644 --- a/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/testobjects/WrongTypeConverter.java +++ b/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/testobjects/WrongTypeConverter.java @@ -2,17 +2,17 @@ import java.math.BigDecimal; -import javax.persistence.AttributeConverter; +import jakarta.persistence.AttributeConverter; public class WrongTypeConverter implements AttributeConverter { @Override - public BigDecimal convertToDatabaseColumn(WrongType[] attribute) { + public BigDecimal convertToDatabaseColumn(final WrongType[] attribute) { return WrongType.TEST.getValue(); } @Override - public WrongType[] convertToEntityAttribute(BigDecimal dbData) { + public WrongType[] convertToEntityAttribute(final BigDecimal dbData) { return new WrongType[] { WrongType.TEST }; } diff --git a/jpa/odata-jpa-odata-vocabularies/pom.xml b/jpa/odata-jpa-odata-vocabularies/pom.xml index 34b8b160b..33f52f9a4 100644 --- a/jpa/odata-jpa-odata-vocabularies/pom.xml +++ b/jpa/odata-jpa-odata-vocabularies/pom.xml @@ -3,7 +3,7 @@ com.sap.olingo odata-jpa - 1.1.1 + 2.0.0 odata-jpa-odata-vocabularies odata-jpa-odata-vocabularies @@ -33,19 +33,19 @@ org.junit.jupiter junit-jupiter - 5.9.1 + ${junit.version} test org.junit.platform junit-platform-launcher - 1.9.1 + ${junit-platform.version} test org.mockito mockito-core - 3.6.0 + ${mockito.version} test diff --git a/jpa/odata-jpa-odata-vocabularies/src/main/java/com/sap/olingo/jpa/metadata/odata/v4/provider/JavaBasedODataAnnotationsProvider.java b/jpa/odata-jpa-odata-vocabularies/src/main/java/com/sap/olingo/jpa/metadata/odata/v4/provider/JavaBasedODataAnnotationsProvider.java index 49c15d3d5..774d25181 100644 --- a/jpa/odata-jpa-odata-vocabularies/src/main/java/com/sap/olingo/jpa/metadata/odata/v4/provider/JavaBasedODataAnnotationsProvider.java +++ b/jpa/odata-jpa-odata-vocabularies/src/main/java/com/sap/olingo/jpa/metadata/odata/v4/provider/JavaBasedODataAnnotationsProvider.java @@ -2,13 +2,10 @@ import static java.util.Objects.requireNonNull; -import java.lang.annotation.Annotation; import java.net.URI; import java.net.URISyntaxException; import java.util.Collection; -import java.util.Map; import java.util.Objects; -import java.util.stream.Collectors; import javax.annotation.Nonnull; @@ -19,7 +16,6 @@ import com.sap.olingo.jpa.metadata.core.edm.extension.vocabularies.JPAReferences; import com.sap.olingo.jpa.metadata.core.edm.extension.vocabularies.ODataAnnotatable; import com.sap.olingo.jpa.metadata.core.edm.extension.vocabularies.ODataVocabularyReadException; -import com.sap.olingo.jpa.metadata.core.edm.extension.vocabularies.ReferenceAccess; import com.sap.olingo.jpa.metadata.core.edm.extension.vocabularies.ReferenceList; abstract class JavaBasedODataAnnotationsProvider implements AnnotationProvider { @@ -36,7 +32,7 @@ abstract class JavaBasedODataAnnotationsProvider implements AnnotationProvider { public Collection getAnnotations(@Nonnull final Applicability appliesTo, final ODataAnnotatable annotatable, final JPAReferences references) { - final Map annotations = requireNonNull(annotatable).javaAnnotations(packageName); + final var annotations = requireNonNull(annotatable).javaAnnotations(packageName); return requireNonNull(references).getTerms(getAlias(), requireNonNull(appliesTo)).stream() .map(term -> annotations.get(term.getName())) @@ -44,15 +40,15 @@ public Collection getAnnotations(@Nonnull final Applicability ap .map(a -> converter.convert(references, a, annotatable)) .map(converted -> converted.orElse(null)) .filter(Objects::nonNull) - .collect(Collectors.toList()); + .toList(); } @Override public void addReferences(final ReferenceList references) throws ODataVocabularyReadException { try { - final URI uri = getUri(); - final ReferenceAccess reference = references.addReference(uri, getPath()); + final var uri = getUri(); + final var reference = references.addReference(uri, getPath()); reference.addInclude(getNameSpace(), getAlias()); } catch (final URISyntaxException e) { throw new ODataVocabularyReadException(getAlias(), getPath(), e); diff --git a/jpa/odata-jpa-processor-cb/README.md b/jpa/odata-jpa-processor-cb/README.md index 4af4bd846..7de885fbd 100644 --- a/jpa/odata-jpa-processor-cb/README.md +++ b/jpa/odata-jpa-processor-cb/README.md @@ -30,4 +30,4 @@ SELECT "CodePublisher", "CodeID", "DivisionCode", "CountryISOCode", "Area", "Pop are not supported. This type of queries are quite handy for client side or service driven paging. -This project contains an implementation of a set of interfaces from `javax.persistence.criteria.*` to enable the creation queries like mentioned above. This implementation is used if it is part of the build path or in other words if it can be found by the class loader. \ No newline at end of file +This project contains an implementation of a set of interfaces from `jakarta.persistence.criteria.*` to enable the creation queries like mentioned above. This implementation is used if it is part of the build path or in other words if it can be found by the class loader. \ No newline at end of file diff --git a/jpa/odata-jpa-processor-cb/pom.xml b/jpa/odata-jpa-processor-cb/pom.xml index 11b0c0176..43bfcaa58 100644 --- a/jpa/odata-jpa-processor-cb/pom.xml +++ b/jpa/odata-jpa-processor-cb/pom.xml @@ -5,7 +5,7 @@ com.sap.olingo odata-jpa - 1.1.1 + 2.0.0 odata-jpa-processor-cb @@ -35,7 +35,7 @@ org.springframework spring-jcl - 5.2.4.RELEASE + ${spring-jcl.version} diff --git a/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/api/EntityManagerFactoryWrapper.java b/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/api/EntityManagerFactoryWrapper.java index f0f402f2e..b136bf793 100644 --- a/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/api/EntityManagerFactoryWrapper.java +++ b/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/api/EntityManagerFactoryWrapper.java @@ -2,15 +2,15 @@ import java.util.Map; -import javax.persistence.Cache; -import javax.persistence.EntityGraph; -import javax.persistence.EntityManager; -import javax.persistence.EntityManagerFactory; -import javax.persistence.PersistenceUnitUtil; -import javax.persistence.Query; -import javax.persistence.SynchronizationType; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.metamodel.Metamodel; +import jakarta.persistence.Cache; +import jakarta.persistence.EntityGraph; +import jakarta.persistence.EntityManager; +import jakarta.persistence.EntityManagerFactory; +import jakarta.persistence.PersistenceUnitUtil; +import jakarta.persistence.Query; +import jakarta.persistence.SynchronizationType; +import jakarta.persistence.criteria.CriteriaBuilder; +import jakarta.persistence.metamodel.Metamodel; import com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAServiceDocument; import com.sap.olingo.jpa.processor.cb.impl.EntityManagerWrapper; @@ -48,7 +48,9 @@ public EntityManager createEntityManager(final SynchronizationType synchronizati @Override public CriteriaBuilder getCriteriaBuilder() { - return new EntityManagerWrapper(emf.createEntityManager(), sd).getCriteriaBuilder(); + try (EntityManager em = new EntityManagerWrapper(emf.createEntityManager(), sd)) { + return em.getCriteriaBuilder(); + } } @Override @@ -87,8 +89,8 @@ public void addNamedQuery(final String name, final Query query) { } @Override - public T unwrap(final Class cls) { - return emf.unwrap(cls); + public T unwrap(final Class clazz) { + return emf.unwrap(clazz); } @Override diff --git a/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/AbstractJoinImp.java b/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/AbstractJoinImp.java index 3f95ae74c..cd2cbf7b1 100644 --- a/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/AbstractJoinImp.java +++ b/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/AbstractJoinImp.java @@ -4,11 +4,12 @@ import java.util.Optional; import javax.annotation.Nonnull; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.Expression; -import javax.persistence.criteria.From; -import javax.persistence.criteria.Join; -import javax.persistence.criteria.Predicate; + +import jakarta.persistence.criteria.CriteriaBuilder; +import jakarta.persistence.criteria.Expression; +import jakarta.persistence.criteria.From; +import jakarta.persistence.criteria.Join; +import jakarta.persistence.criteria.Predicate; import com.sap.olingo.jpa.metadata.api.JPAJoinColumn; import com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAEntityType; diff --git a/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/CollectionJoinImpl.java b/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/CollectionJoinImpl.java index 650abcf10..2d2d3d123 100644 --- a/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/CollectionJoinImpl.java +++ b/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/CollectionJoinImpl.java @@ -3,14 +3,14 @@ import java.util.ArrayList; import java.util.List; import java.util.Optional; -import java.util.stream.Collectors; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.JoinType; -import javax.persistence.criteria.Path; -import javax.persistence.metamodel.Attribute; + +import jakarta.persistence.criteria.CriteriaBuilder; +import jakarta.persistence.criteria.JoinType; +import jakarta.persistence.criteria.Path; +import jakarta.persistence.metamodel.Attribute; import com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPACollectionAttribute; import com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAEntityType; @@ -67,7 +67,7 @@ public StringBuilder asSQL(final StringBuilder statement) { .getJoinTable() .getTableName()); - tableAlias.ifPresent(p -> statement.append(" ").append(p)); + tableAlias.ifPresent(alias -> statement.append(" ").append(alias)); statement.append(" ON "); return ((SqlConvertible) on).asSQL(statement); } catch (final ODataJPAModelException e) { @@ -106,8 +106,9 @@ List getPathList() { final JPAPath path = source.getPath(this.alias.orElse(attribute.getExternalName())); pathList.add(path); } else { - pathList.addAll(attribute.getStructuredType().getPathList().stream().filter(p -> !p.ignore()).collect(Collectors - .toList())); + pathList.addAll(attribute.getStructuredType().getPathList().stream() + .filter(path -> !path.ignore()) + .toList()); } } catch (final ODataJPAModelException e) { throw new IllegalStateException(e); @@ -138,11 +139,11 @@ public int hashCode() { } @Override - public boolean equals(final Object obj) { - if (this == obj) return true; - if (!super.equals(obj)) return false; - if (getClass() != obj.getClass()) return false; - final CollectionJoinImpl other = (CollectionJoinImpl) obj; + public boolean equals(final Object object) { + if (this == object) return true; + if (!super.equals(object)) return false; + if (getClass() != object.getClass()) return false; + final CollectionJoinImpl other = (CollectionJoinImpl) object; if (attribute == null) { if (other.attribute != null) return false; } else if (!attribute.equals(other.attribute)) return false; diff --git a/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/CompoundSelectionImpl.java b/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/CompoundSelectionImpl.java index a99573659..13e1fd0c0 100644 --- a/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/CompoundSelectionImpl.java +++ b/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/CompoundSelectionImpl.java @@ -1,7 +1,5 @@ package com.sap.olingo.jpa.processor.cb.impl; -import static java.util.stream.Collectors.toList; - import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -9,8 +7,9 @@ import java.util.Optional; import javax.annotation.Nonnull; -import javax.persistence.criteria.CompoundSelection; -import javax.persistence.criteria.Selection; + +import jakarta.persistence.criteria.CompoundSelection; +import jakarta.persistence.criteria.Selection; import com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAPath; import com.sap.olingo.jpa.processor.cb.ProcessorSelection; @@ -50,7 +49,7 @@ public SqlSelection alias(@Nonnull final String name) { public StringBuilder asSQL(@Nonnull final StringBuilder statement) { statement.append(getCompoundSelectionItems().stream() - .map(s -> (Selection) s) // NOSONAR + .map(selection -> (Selection) selection) // NOSONAR .collect(new StringBuilderCollector.SelectionCollector(statement, ", "))); return statement; } @@ -78,19 +77,19 @@ public List> getCompoundSelectionItems() { } private List> asSelectionLate() { - final List> selItems = new ArrayList<>(); + final List> selectionItems = new ArrayList<>(); for (final Selection sel : rawSelections) { if (sel instanceof PathImpl) { - selItems.addAll(((PathImpl) sel) + selectionItems.addAll(((PathImpl) sel) .resolvePathElements() .stream() .map(element -> new SelectionImpl<>(element, element.getJavaType(), aliasBuilder)) - .collect(toList())); + .toList()); } else { - selItems.add(new SelectionImpl<>(sel, sel.getJavaType(), aliasBuilder)); + selectionItems.add(new SelectionImpl<>(sel, sel.getJavaType(), aliasBuilder)); } } - selections = Optional.of(selItems); + selections = Optional.of(selectionItems); return selections.get(); } @@ -115,46 +114,46 @@ public boolean isCompoundSelection() { } List> resolveSelectionLate() { - final AliasBuilder ab = new AliasBuilder("S"); + final AliasBuilder selectionAliasBuilder = new AliasBuilder("S"); final List> resolved = new ArrayList<>(); for (final Selection sel : rawSelections) { - resolveSelectionItem(ab, resolved, sel); + resolveSelectionItem(selectionAliasBuilder, resolved, sel); } resolvedSelection = Optional.of(resolved); return resolvedSelection.get(); } - private void addSelectionList(final AliasBuilder ab, final List> resolved, - final Selection sel) { - for (final JPAPath p : ((PathImpl) sel).getPathList()) { - resolved.add(new ProcessorSelection.SelectionItem(sel.getAlias().isEmpty() - ? ab.getNext() : (sel.getAlias() + "." + p.getAlias()), p)); + private void addSelectionList(final AliasBuilder aliasBuilder, final List> resolved, + final List selectionItems, String alias) { + for (final JPAPath p : selectionItems) { + resolved.add(new ProcessorSelection.SelectionItem(alias.isEmpty() + ? aliasBuilder.getNext() : (alias + "." + p.getAlias()), p)); } } - private void addSingleSelectionItem(final AliasBuilder ab, final List> resolved, - final Selection sel, final List selItems) { - resolved.add(new ProcessorSelection.SelectionItem(sel.getAlias().isEmpty() - ? ab.getNext() : sel.getAlias(), selItems.get(0))); + private void addSingleSelectionItem(final AliasBuilder aliasBuilder, final List> resolved, + final Selection selection, final List selectionItems) { + resolved.add(new ProcessorSelection.SelectionItem(selection.getAlias().isEmpty() + ? aliasBuilder.getNext() : selection.getAlias(), selectionItems.get(0))); } - private void resolveSelectionItem(final AliasBuilder ab, final List> resolved, - final Selection sel) { + private void resolveSelectionItem(final AliasBuilder aliasBuilder, final List> resolved, + final Selection selection) { - if (sel instanceof PathImpl || sel instanceof SelectionPath) { - final List selItems; - if (sel instanceof PathImpl) - selItems = ((PathImpl) sel).getPathList(); + if (selection instanceof PathImpl || selection instanceof SelectionPath) { + final List selectionItems; + if (selection instanceof PathImpl) + selectionItems = ((PathImpl) selection).getPathList(); else - selItems = ((PathImpl) ((SelectionPath) sel).selection.getSelection()).getPathList(); - if (selItems.size() == 1) { - addSingleSelectionItem(ab, resolved, sel, selItems); + selectionItems = ((PathImpl) ((SelectionPath) selection).selection.getSelection()).getPathList(); + if (selectionItems.size() == 1) { + addSingleSelectionItem(aliasBuilder, resolved, selection, selectionItems); } else { - addSelectionList(ab, resolved, sel); + addSelectionList(aliasBuilder, resolved, selectionItems, selection.getAlias()); } } else { - resolved.add(new ProcessorSelection.SelectionItem(sel.getAlias().isEmpty() - ? ab.getNext() : sel.getAlias(), new JPAPathWrapper(sel))); + resolved.add(new ProcessorSelection.SelectionItem(selection.getAlias().isEmpty() + ? aliasBuilder.getNext() : selection.getAlias(), new JPAPathWrapper(selection))); } } diff --git a/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/CriteriaBuilderImpl.java b/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/CriteriaBuilderImpl.java index ad04800bf..2f7ea287f 100644 --- a/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/CriteriaBuilderImpl.java +++ b/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/CriteriaBuilderImpl.java @@ -5,6 +5,9 @@ import java.sql.Date; import java.sql.Time; import java.sql.Timestamp; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; import java.util.Arrays; import java.util.Collection; import java.util.Collections; @@ -13,25 +16,25 @@ import java.util.Objects; import java.util.Optional; import java.util.Set; -import java.util.stream.Collectors; import javax.annotation.Nonnull; -import javax.persistence.Tuple; -import javax.persistence.criteria.CollectionJoin; -import javax.persistence.criteria.CompoundSelection; -import javax.persistence.criteria.CriteriaDelete; -import javax.persistence.criteria.CriteriaUpdate; -import javax.persistence.criteria.Expression; -import javax.persistence.criteria.Join; -import javax.persistence.criteria.ListJoin; -import javax.persistence.criteria.MapJoin; -import javax.persistence.criteria.Order; -import javax.persistence.criteria.Path; -import javax.persistence.criteria.Predicate; -import javax.persistence.criteria.Root; -import javax.persistence.criteria.Selection; -import javax.persistence.criteria.SetJoin; -import javax.persistence.criteria.Subquery; + +import jakarta.persistence.Tuple; +import jakarta.persistence.criteria.CollectionJoin; +import jakarta.persistence.criteria.CompoundSelection; +import jakarta.persistence.criteria.CriteriaDelete; +import jakarta.persistence.criteria.CriteriaUpdate; +import jakarta.persistence.criteria.Expression; +import jakarta.persistence.criteria.Join; +import jakarta.persistence.criteria.ListJoin; +import jakarta.persistence.criteria.MapJoin; +import jakarta.persistence.criteria.Order; +import jakarta.persistence.criteria.Path; +import jakarta.persistence.criteria.Predicate; +import jakarta.persistence.criteria.Root; +import jakarta.persistence.criteria.Selection; +import jakarta.persistence.criteria.SetJoin; +import jakarta.persistence.criteria.Subquery; import com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAServiceDocument; import com.sap.olingo.jpa.processor.cb.ProcessorCriteriaBuilder; @@ -58,7 +61,7 @@ class CriteriaBuilderImpl implements ProcessorCriteriaBuilder { // NOSONAR * @return absolute value */ @Override - public Expression abs(@Nonnull final Expression x) { + public Expression abs(@Nonnull final Expression expression) { throw new NotImplementedException(); } @@ -414,8 +417,7 @@ public Predicate exists(@Nonnull final Subquery subquery) { public Expression function(@Nonnull final String name, @Nonnull final Class type, final Expression... args) { final List> parameters = args == null ? Collections.emptyList() : Arrays.asList(args).stream() - .map( - p -> ((Expression) p)).collect(Collectors.toList()); + .map(p -> ((Expression) p)).toList(); return new ExpressionImpl.FunctionExpression<>(name, type, parameters); } @@ -1181,7 +1183,7 @@ public Predicate or(final Predicate... restrictions) { * @return parameter expression */ @Override - public javax.persistence.criteria.ParameterExpression parameter(@Nonnull final Class paramClass) { + public jakarta.persistence.criteria.ParameterExpression parameter(@Nonnull final Class paramClass) { throw new NotImplementedException(); } @@ -1193,7 +1195,7 @@ public javax.persistence.criteria.ParameterExpression parameter(@Nonnull * @return parameter expression */ @Override - public javax.persistence.criteria.ParameterExpression parameter(@Nonnull final Class paramClass, + public jakarta.persistence.criteria.ParameterExpression parameter(@Nonnull final Class paramClass, @Nonnull final String name) { throw new NotImplementedException(); } @@ -1324,8 +1326,7 @@ public Expression some(@Nonnull final Subquery subquery) { @Override public Expression sqrt(final Expression x) { - // "SQRT" - return null; + throw new NotImplementedException(); } /** @@ -1701,4 +1702,59 @@ private Predicate binaryExpression(@Nonnull final Expression x, @Nonnull fina @Nonnull final Operation p) { return new PredicateImpl.BinaryExpressionPredicate(p, Objects.requireNonNull(x), literal(y, x)); } + + @Override + public Expression sign(final Expression x) { + throw new NotImplementedException(); + } + + @Override + public Expression ceiling(final Expression x) { + throw new NotImplementedException(); + } + + @Override + public Expression floor(final Expression x) { + throw new NotImplementedException(); + } + + @Override + public Expression exp(final Expression x) { + throw new NotImplementedException(); + } + + @Override + public Expression ln(final Expression x) { + throw new NotImplementedException(); + } + + @Override + public Expression power(final Expression x, final Expression y) { + throw new NotImplementedException(); + } + + @Override + public Expression power(final Expression x, final Number y) { + throw new NotImplementedException(); + } + + @Override + public Expression round(final Expression x, final Integer n) { + throw new NotImplementedException(); + } + + @Override + public Expression localDate() { + throw new NotImplementedException(); + } + + @Override + public Expression localDateTime() { + throw new NotImplementedException(); + } + + @Override + public Expression localTime() { + throw new NotImplementedException(); + } } diff --git a/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/CriteriaQueryImpl.java b/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/CriteriaQueryImpl.java index f192fa7bc..23a51b8d3 100644 --- a/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/CriteriaQueryImpl.java +++ b/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/CriteriaQueryImpl.java @@ -14,17 +14,18 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.CriteriaQuery; -import javax.persistence.criteria.Expression; -import javax.persistence.criteria.Join; -import javax.persistence.criteria.Order; -import javax.persistence.criteria.ParameterExpression; -import javax.persistence.criteria.Predicate; -import javax.persistence.criteria.Predicate.BooleanOperator; -import javax.persistence.criteria.Root; -import javax.persistence.criteria.Selection; -import javax.persistence.metamodel.EntityType; + +import jakarta.persistence.criteria.CriteriaBuilder; +import jakarta.persistence.criteria.CriteriaQuery; +import jakarta.persistence.criteria.Expression; +import jakarta.persistence.criteria.Join; +import jakarta.persistence.criteria.Order; +import jakarta.persistence.criteria.ParameterExpression; +import jakarta.persistence.criteria.Predicate; +import jakarta.persistence.criteria.Predicate.BooleanOperator; +import jakarta.persistence.criteria.Root; +import jakarta.persistence.criteria.Selection; +import jakarta.persistence.metamodel.EntityType; import com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAEntityType; import com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAServiceDocument; @@ -288,10 +289,12 @@ public boolean isDistinct() { * The type of the result of the query execution depends on * the specification of the type of the criteria query object * created as well as the arguments to the multiselect method. - *

          An argument to the multiselect method must not be a tuple- + *

          + * An argument to the multiselect method must not be a tuple- * or array-valued compound selection item. * - *

          The semantics of this method are as follows: + *

          + * The semantics of this method are as follows: *

            *
          • * If the type of the criteria query is @@ -304,26 +307,26 @@ public boolean isDistinct() { * method, in the specified order, will be instantiated and * returned for each row that results from the query execution. * - *
          • If the type of the criteria query is CriteriaQuery<X> for + *
          • If the type of the criteria query is CriteriaQuery<X> for * some user-defined class X (i.e., a criteria query object * created by passing a X class argument to the createQuery * method), the arguments to the multiselect method will be * passed to the X constructor and an instance of type X will be * returned for each row. * - *
          • If the type of the criteria query is CriteriaQuery<X[]> for + *
          • If the type of the criteria query is CriteriaQuery<X[]> for * some class X, an instance of type X[] will be returned for * each row. The elements of the array will correspond to the * arguments of the multiselect method, in the * specified order. * - *
          • If the type of the criteria query is CriteriaQuery<Object> + *
          • If the type of the criteria query is CriteriaQuery<Object> * or if the criteria query was created without specifying a * type, and only a single argument is passed to the multiselect * method, an instance of type Object will be returned for * each row. * - *
          • If the type of the criteria query is CriteriaQuery<Object> + *
          • If the type of the criteria query is CriteriaQuery<Object> * or if the criteria query was created without specifying a * type, and more than one argument is passed to the multiselect * method, an instance of type Object[] will be instantiated diff --git a/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/EntityManagerWrapper.java b/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/EntityManagerWrapper.java index e967b243a..a0e4b6983 100644 --- a/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/EntityManagerWrapper.java +++ b/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/EntityManagerWrapper.java @@ -4,22 +4,22 @@ import java.util.Map; import java.util.Optional; -import javax.persistence.EntityExistsException; -import javax.persistence.EntityGraph; -import javax.persistence.EntityManager; -import javax.persistence.EntityManagerFactory; -import javax.persistence.EntityTransaction; -import javax.persistence.FlushModeType; -import javax.persistence.LockModeType; -import javax.persistence.PersistenceException; -import javax.persistence.Query; -import javax.persistence.StoredProcedureQuery; -import javax.persistence.TransactionRequiredException; -import javax.persistence.TypedQuery; -import javax.persistence.criteria.CriteriaDelete; -import javax.persistence.criteria.CriteriaQuery; -import javax.persistence.criteria.CriteriaUpdate; -import javax.persistence.metamodel.Metamodel; +import jakarta.persistence.EntityExistsException; +import jakarta.persistence.EntityGraph; +import jakarta.persistence.EntityManager; +import jakarta.persistence.EntityManagerFactory; +import jakarta.persistence.EntityTransaction; +import jakarta.persistence.FlushModeType; +import jakarta.persistence.LockModeType; +import jakarta.persistence.PersistenceException; +import jakarta.persistence.Query; +import jakarta.persistence.StoredProcedureQuery; +import jakarta.persistence.TransactionRequiredException; +import jakarta.persistence.TypedQuery; +import jakarta.persistence.criteria.CriteriaDelete; +import jakarta.persistence.criteria.CriteriaQuery; +import jakarta.persistence.criteria.CriteriaUpdate; +import jakarta.persistence.metamodel.Metamodel; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -437,9 +437,11 @@ public Query createNativeQuery(final String sqlString, final String resultSetMap /** * Create an instance of StoredProcedureQuery for executing a * stored procedure in the database. - *

            Parameters must be registered before the stored procedure can + *

            + * Parameters must be registered before the stored procedure can * be executed. - *

            If the stored procedure returns one or more result sets, + *

            + * If the stored procedure returns one or more result sets, * any result set will be returned as a list of type Object[]. * @param name name assigned to the stored procedure query * in metadata @@ -456,9 +458,11 @@ public StoredProcedureQuery createNamedStoredProcedureQuery(final String name) { /** * Create an instance of StoredProcedureQuery for executing a * stored procedure in the database. - *

            Parameters must be registered before the stored procedure can + *

            + * Parameters must be registered before the stored procedure can * be executed. - *

            If the stored procedure returns one or more result sets, + *

            + * If the stored procedure returns one or more result sets, * any result set will be returned as a list of type Object[]. * @param procedureName name of the stored procedure in the * database @@ -476,9 +480,11 @@ public StoredProcedureQuery createStoredProcedureQuery(final String procedureNam /** * Create an instance of StoredProcedureQuery for executing a * stored procedure in the database. - *

            Parameters must be registered before the stored procedure can + *

            + * Parameters must be registered before the stored procedure can * be executed. - *

            The resultClass arguments must be specified in the order in + *

            + * The resultClass arguments must be specified in the order in * which the result sets will be returned by the stored procedure * invocation. * @param procedureName name of the stored procedure in the @@ -501,9 +507,11 @@ public StoredProcedureQuery createStoredProcedureQuery(final String procedureNam /** * Create an instance of StoredProcedureQuery for executing a * stored procedure in the database. - *

            Parameters must be registered before the stored procedure can + *

            + * Parameters must be registered before the stored procedure can * be executed. - *

            The resultSetMapping arguments must be specified in the order + *

            + * The resultSetMapping arguments must be specified in the order * in which the result sets will be returned by the stored * procedure invocation. * @param procedureName name of the stored procedure in the @@ -525,7 +533,8 @@ public StoredProcedureQuery createStoredProcedureQuery(final String procedureNam /** * Indicate to the entity manager that a JTA transaction is * active and join the persistence context to it. - *

            This method should be called on a JTA application + *

            + * This method should be called on a JTA application * managed entity manager that was created outside the scope * of the active transaction or on an entity manager of type * SynchronizationType.UNSYNCHRONIZED to associate @@ -573,7 +582,8 @@ public boolean isJoinedToTransaction() { * Return the underlying provider object for the EntityManager, * if available. The result of this method is implementation * specific. - *

            The unwrap method is to be preferred for new applications. + *

            + * The unwrap method is to be preferred for new applications. * @return underlying provider object for EntityManager */ @Override diff --git a/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/ExpressionImpl.java b/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/ExpressionImpl.java index 196d56acf..bb1398a9c 100644 --- a/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/ExpressionImpl.java +++ b/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/ExpressionImpl.java @@ -10,19 +10,20 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; -import javax.persistence.AttributeConverter; -import javax.persistence.Parameter; -import javax.persistence.criteria.CriteriaBuilder.Coalesce; -import javax.persistence.criteria.Expression; -import javax.persistence.criteria.Order; -import javax.persistence.criteria.Path; -import javax.persistence.criteria.Predicate; -import javax.persistence.criteria.Selection; -import javax.persistence.criteria.Subquery; -import javax.persistence.metamodel.Bindable; -import javax.persistence.metamodel.MapAttribute; -import javax.persistence.metamodel.PluralAttribute; -import javax.persistence.metamodel.SingularAttribute; + +import jakarta.persistence.AttributeConverter; +import jakarta.persistence.Parameter; +import jakarta.persistence.criteria.CriteriaBuilder.Coalesce; +import jakarta.persistence.criteria.Expression; +import jakarta.persistence.criteria.Order; +import jakarta.persistence.criteria.Path; +import jakarta.persistence.criteria.Predicate; +import jakarta.persistence.criteria.Selection; +import jakarta.persistence.criteria.Subquery; +import jakarta.persistence.metamodel.Bindable; +import jakarta.persistence.metamodel.MapAttribute; +import jakarta.persistence.metamodel.PluralAttribute; +import jakarta.persistence.metamodel.SingularAttribute; import com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAAttribute; import com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAPath; @@ -133,9 +134,9 @@ static class AggregationExpression extends ExpressionImpl { private final SqlAggregation function; private final SqlConvertible expression; - AggregationExpression(@Nonnull final SqlAggregation function, @Nonnull final Expression x) { + AggregationExpression(@Nonnull final SqlAggregation function, @Nonnull final Expression expression) { this.function = Objects.requireNonNull(function); - this.expression = Objects.requireNonNull((SqlConvertible) x); + this.expression = Objects.requireNonNull((SqlConvertible) expression); } @Override @@ -147,8 +148,7 @@ public StringBuilder asSQL(final StringBuilder statement) { } private StringBuilder expression(final StringBuilder statement) { - if (expression instanceof FromImpl) { - final FromImpl from = (FromImpl) expression; + if (expression instanceof final FromImpl from) { final String tableAlias = from.tableAlias.orElseThrow(IllegalStateException::new); try { final List keys = from.st.getKey(); diff --git a/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/FromImpl.java b/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/FromImpl.java index 1875f594e..22a4509d3 100644 --- a/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/FromImpl.java +++ b/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/FromImpl.java @@ -7,25 +7,26 @@ import java.util.Set; import javax.annotation.Nonnull; -import javax.persistence.DiscriminatorValue; -import javax.persistence.InheritanceType; -import javax.persistence.criteria.CollectionJoin; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.Expression; -import javax.persistence.criteria.Fetch; -import javax.persistence.criteria.From; -import javax.persistence.criteria.Join; -import javax.persistence.criteria.JoinType; -import javax.persistence.criteria.ListJoin; -import javax.persistence.criteria.MapJoin; -import javax.persistence.criteria.Path; -import javax.persistence.criteria.SetJoin; -import javax.persistence.metamodel.CollectionAttribute; -import javax.persistence.metamodel.ListAttribute; -import javax.persistence.metamodel.MapAttribute; -import javax.persistence.metamodel.PluralAttribute; -import javax.persistence.metamodel.SetAttribute; -import javax.persistence.metamodel.SingularAttribute; + +import jakarta.persistence.DiscriminatorValue; +import jakarta.persistence.InheritanceType; +import jakarta.persistence.criteria.CollectionJoin; +import jakarta.persistence.criteria.CriteriaBuilder; +import jakarta.persistence.criteria.Expression; +import jakarta.persistence.criteria.Fetch; +import jakarta.persistence.criteria.From; +import jakarta.persistence.criteria.Join; +import jakarta.persistence.criteria.JoinType; +import jakarta.persistence.criteria.ListJoin; +import jakarta.persistence.criteria.MapJoin; +import jakarta.persistence.criteria.Path; +import jakarta.persistence.criteria.SetJoin; +import jakarta.persistence.metamodel.CollectionAttribute; +import jakarta.persistence.metamodel.ListAttribute; +import jakarta.persistence.metamodel.MapAttribute; +import jakarta.persistence.metamodel.PluralAttribute; +import jakarta.persistence.metamodel.SetAttribute; +import jakarta.persistence.metamodel.SingularAttribute; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -65,15 +66,15 @@ class FromImpl extends PathImpl implements From { private InheritanceInfo inInfo; private final CriteriaBuilder cb; - FromImpl(final JPAEntityType type, final AliasBuilder ab, final CriteriaBuilder cb) { - this(type, null, ab, cb); + FromImpl(final JPAEntityType type, final AliasBuilder aliasBuilder, final CriteriaBuilder cb) { + this(type, null, aliasBuilder, cb); } - FromImpl(final JPAEntityType type, final JPAPath path, final AliasBuilder ab, final CriteriaBuilder cb) { - super(Optional.ofNullable(path), Optional.empty(), type, Optional.of(ab.getNext())); + FromImpl(final JPAEntityType type, final JPAPath path, final AliasBuilder aliasBuilder, final CriteriaBuilder cb) { + super(Optional.ofNullable(path), Optional.empty(), type, Optional.of(aliasBuilder.getNext())); this.joins = new HashSet<>(); this.fetches = new HashSet<>(); - this.aliasBuilder = ab; + this.aliasBuilder = aliasBuilder; this.cb = cb; this.inInfo = new InheritanceInfo(type); } @@ -106,7 +107,7 @@ public Expression as(final Class type) { @Override public StringBuilder asSQL(final StringBuilder statement) { statement.append(st.getTableName()); - tableAlias.ifPresent(p -> statement.append(" ").append(p)); + tableAlias.ifPresent(alias -> statement.append(" ").append(alias)); statement.append(joins.stream().collect(new StringBuilderCollector.ExpressionCollector(statement, " "))); return statement; } @@ -126,11 +127,12 @@ public Fetch fetch(@Nonnull final PluralAttribute att * Create a fetch join to the specified collection-valued * attribute using the given join type. * @param attribute target of the join - * @param jt join type + * @param joinType join type * @return the resulting join */ @Override - public Fetch fetch(@Nonnull final PluralAttribute attribute, @Nonnull final JoinType jt) { + public Fetch fetch(@Nonnull final PluralAttribute attribute, + @Nonnull final JoinType joinType) { throw new NotImplementedException(); } @@ -149,11 +151,12 @@ public Fetch fetch(@Nonnull final SingularAttribute attr * Create a fetch join to the specified single-valued attribute * using the given join type. * @param attribute target of the join - * @param jt join type + * @param joinType join type * @return the resulting fetch join */ @Override - public Fetch fetch(@Nonnull final SingularAttribute attribute, @Nonnull final JoinType jt) { + public Fetch fetch(@Nonnull final SingularAttribute attribute, + @Nonnull final JoinType joinType) { throw new NotImplementedException(); } @@ -177,13 +180,13 @@ public Fetch fetch(@Nonnull final String attributeName) { * the given join type. * @param attributeName name of the attribute for the * target of the join - * @param jt join type + * @param joinType join type * @return the resulting fetch join * @throws IllegalArgumentException if attribute of the given * name does not exist */ @Override - public Fetch fetch(@Nonnull final String attributeName, @Nonnull final JoinType jt) { + public Fetch fetch(@Nonnull final String attributeName, @Nonnull final JoinType joinType) { throw new NotImplementedException(); } @@ -250,7 +253,7 @@ public boolean isCorrelated() { */ @Override public CollectionJoin join(@Nonnull final CollectionAttribute collection) { - return join(collection, JoinType.INNER); + throw new NotImplementedException(); } /** @@ -261,7 +264,7 @@ public CollectionJoin join(@Nonnull final CollectionAttribute CollectionJoin join(@Nonnull final CollectionAttribute collection, - @Nonnull final JoinType jt) { + @Nonnull final JoinType joinType) { throw new NotImplementedException(); } @@ -272,7 +275,7 @@ public CollectionJoin join(@Nonnull final CollectionAttribute ListJoin join(@Nonnull final ListAttribute list) { - return join(list, JoinType.INNER); + throw new NotImplementedException(); } /** @@ -281,7 +284,7 @@ public ListJoin join(@Nonnull final ListAttribute list) * @return the resulting join */ @Override - public ListJoin join(@Nonnull final ListAttribute list, @Nonnull final JoinType jt) { + public ListJoin join(@Nonnull final ListAttribute list, @Nonnull final JoinType joinType) { throw new NotImplementedException(); } @@ -292,7 +295,7 @@ public ListJoin join(@Nonnull final ListAttribute list, */ @Override public MapJoin join(@Nonnull final MapAttribute map) { - return join(map, JoinType.INNER); + throw new NotImplementedException(); } /** @@ -301,7 +304,8 @@ public MapJoin join(@Nonnull final MapAttribute * @return the resulting join */ @Override - public MapJoin join(@Nonnull final MapAttribute map, @Nonnull final JoinType jt) { + public MapJoin join(@Nonnull final MapAttribute map, + @Nonnull final JoinType joinType) { throw new NotImplementedException(); } @@ -312,7 +316,7 @@ public MapJoin join(@Nonnull final MapAttribute */ @Override public SetJoin join(@Nonnull final SetAttribute set) { - return join(set, JoinType.INNER); + throw new NotImplementedException(); } /** @@ -321,7 +325,7 @@ public SetJoin join(@Nonnull final SetAttribute set) { * @return the resulting join */ @Override - public SetJoin join(@Nonnull final SetAttribute set, @Nonnull final JoinType jt) { + public SetJoin join(@Nonnull final SetAttribute set, @Nonnull final JoinType joinType) { throw new NotImplementedException(); } @@ -332,18 +336,18 @@ public SetJoin join(@Nonnull final SetAttribute set, @No */ @Override public Join join(@Nonnull final SingularAttribute attribute) { - return join(attribute, JoinType.INNER); + throw new NotImplementedException(); } /** * Create a join to the specified single-valued attribute * using the given join type. * @param attribute target of the join - * @param jt join type + * @param joinType join type * @return the resulting join */ @Override - public Join join(@Nonnull final SingularAttribute attribute, final JoinType jt) { + public Join join(@Nonnull final SingularAttribute attribute, final JoinType joinType) { throw new NotImplementedException(); } @@ -363,7 +367,7 @@ public Join join(@Nonnull final String attributeName) { /** * Create a join to the specified attribute using the given join type. * @param attributeName name of the attribute for the target of the join - * @param jt join type + * @param joinType join type * @return the resulting join * @throws IllegalArgumentException if attribute of the given name does not exist */ @@ -382,10 +386,9 @@ public Join join(@Nonnull final String attributeName, final JoinTyp final JPAPath joinPath = determinePath(joinAttribute); @SuppressWarnings("rawtypes") Join join; - if (joinAttribute instanceof JPADescriptionAttribute) { + if (joinAttribute instanceof final JPADescriptionAttribute attribute) { final JoinType joinType = jt == null ? JoinType.LEFT : jt; - final Optional path = Optional.ofNullable(((JPADescriptionAttribute) joinAttribute) - .asAssociationAttribute().getPath()); + final Optional path = Optional.ofNullable(attribute.asAssociationAttribute().getPath()); join = new SimpleJoin<>(path.orElseThrow(() -> new IllegalArgumentException(buildExceptionText(attributeName))), joinType, determineParent(), aliasBuilder, cb); } else if (joinAttribute instanceof JPACollectionAttribute) { @@ -399,8 +402,7 @@ public Join join(@Nonnull final String attributeName, final JoinTyp associationPath = Optional.ofNullable(st.getAssociationPath(path.get().getAlias() + JPAPath.PATH_SEPARATOR + joinAttribute.getExternalName())); else - associationPath = Optional.ofNullable(source.getAssociationPath(joinAttribute - .getExternalName())); + associationPath = Optional.ofNullable(source.getAssociationPath(joinAttribute.getExternalName())); if (associationPath.orElseThrow(() -> new IllegalArgumentException(buildExceptionText(attributeName))) .hasJoinTable()) join = new JoinTableJoin<>(associationPath.orElseThrow(() -> new IllegalArgumentException(buildExceptionText( @@ -424,18 +426,19 @@ public Join join(@Nonnull final String attributeName, final JoinTyp */ @Override public CollectionJoin joinCollection(@Nonnull final String attributeName) { - return joinCollection(attributeName, JoinType.INNER); + throw new NotImplementedException(); } /** * Create a join to the specified Collection-valued attribute using the given join type. * @param attributeName name of the attribute for the target of the join - * @param jt join type + * @param joinType join type * @return the resulting join * @throws IllegalArgumentException if attribute of the given name does not exist */ @Override - public CollectionJoin joinCollection(@Nonnull final String attributeName, @Nonnull final JoinType jt) { + public CollectionJoin joinCollection(@Nonnull final String attributeName, + @Nonnull final JoinType joinType) { throw new NotImplementedException(); } @@ -449,18 +452,18 @@ public CollectionJoin joinCollection(@Nonnull final String attribut */ @Override public ListJoin joinList(@Nonnull final String attributeName) { - return joinList(attributeName, JoinType.INNER); + throw new NotImplementedException(); } /** * Create a join to the specified List-valued attribute using the given join type. * @param attributeName name of the attribute for the target of the join - * @param jt join type + * @param joinType join type * @return the resulting join * @throws IllegalArgumentException if attribute of the given name does not exist */ @Override - public ListJoin joinList(@Nonnull final String attributeName, @Nonnull final JoinType jt) { + public ListJoin joinList(@Nonnull final String attributeName, @Nonnull final JoinType joinType) { throw new NotImplementedException(); } @@ -474,18 +477,18 @@ public ListJoin joinList(@Nonnull final String attributeName, @Nonn */ @Override public MapJoin joinMap(@Nonnull final String attributeName) { - return joinMap(attributeName, JoinType.INNER); + throw new NotImplementedException(); } /** * Create a join to the specified Map-valued attribute using the given join type. * @param attributeName name of the attribute for the target of the join - * @param jt join type + * @param joinType join type * @return the resulting join * @throws IllegalArgumentException if attribute of the given name does not exist */ @Override - public MapJoin joinMap(@Nonnull final String attributeName, @Nonnull final JoinType jt) { + public MapJoin joinMap(@Nonnull final String attributeName, @Nonnull final JoinType joinType) { throw new NotImplementedException(); } @@ -499,18 +502,18 @@ public MapJoin joinMap(@Nonnull final String attributeName, @ */ @Override public SetJoin joinSet(@Nonnull final String attributeName) { - return joinSet(attributeName, JoinType.INNER); + throw new NotImplementedException(); } /** * Create a join to the specified Set-valued attribute using the given join type. * @param attributeName name of the attribute for the target of the join - * @param jt join type + * @param joinType join type * @return the resulting join * @throws IllegalArgumentException if attribute of the given name does not exist */ @Override - public SetJoin joinSet(@Nonnull final String attributeName, @Nonnull final JoinType jt) { + public SetJoin joinSet(@Nonnull final String attributeName, @Nonnull final JoinType joinType) { throw new NotImplementedException(); } @@ -520,7 +523,7 @@ String buildExceptionText(final String attributeName) { } Expression createInheritanceWhere() { - if (inInfo.getInheritanceType().filter(t -> t == InheritanceType.SINGLE_TABLE).isPresent()) { + if (inInfo.getInheritanceType().filter(type -> type == InheritanceType.SINGLE_TABLE).isPresent()) { final Optional columnName = inInfo.getDiscriminatorColumn(); if (!columnName.isPresent()) throw new IllegalStateException("DiscriminatorColumn annotation missing at " + st.getTypeClass().getSuperclass() @@ -540,7 +543,7 @@ Expression createInheritanceWhere() { throw new IllegalStateException("DiscriminatorValue annotation missing at " + st.getTypeClass() .getCanonicalName()); return cb.equal(columnPath, value.value()); - } else if (inInfo.getInheritanceType().filter(t -> t == InheritanceType.JOINED).isPresent()) { + } else if (inInfo.getInheritanceType().filter(type -> type == InheritanceType.JOINED).isPresent()) { LOGGER.warn("Unsupported inheritance type " + inInfo.getInheritanceType() + " not supported"); } return null; @@ -598,7 +601,7 @@ public int hashCode() { } @Override - public boolean equals(final Object obj) { - return super.equals(obj); + public boolean equals(final Object object) { + return super.equals(object); } } \ No newline at end of file diff --git a/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/InheritanceInfo.java b/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/InheritanceInfo.java index 7d79a89d3..22d40a821 100644 --- a/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/InheritanceInfo.java +++ b/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/InheritanceInfo.java @@ -4,10 +4,11 @@ import javax.annotation.CheckForNull; import javax.annotation.Nonnull; -import javax.persistence.DiscriminatorColumn; -import javax.persistence.Entity; -import javax.persistence.Inheritance; -import javax.persistence.InheritanceType; + +import jakarta.persistence.DiscriminatorColumn; +import jakarta.persistence.Entity; +import jakarta.persistence.Inheritance; +import jakarta.persistence.InheritanceType; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; diff --git a/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/JPAAttributeWrapper.java b/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/JPAAttributeWrapper.java index 13954fd61..f2345b1e7 100644 --- a/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/JPAAttributeWrapper.java +++ b/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/JPAAttributeWrapper.java @@ -5,8 +5,8 @@ import java.util.List; import java.util.Set; -import javax.persistence.AttributeConverter; -import javax.persistence.criteria.Selection; +import jakarta.persistence.AttributeConverter; +import jakarta.persistence.criteria.Selection; import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind; import org.apache.olingo.commons.api.edm.FullQualifiedName; @@ -20,9 +20,9 @@ class JPAAttributeWrapper implements JPAAttribute { private final Selection selection; - - public JPAAttributeWrapper(final Selection sel) { - this.selection = sel; + + public JPAAttributeWrapper(final Selection selection) { + this.selection = selection; } @Override diff --git a/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/JPAPathWrapper.java b/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/JPAPathWrapper.java index 82697fccc..6ef04b13d 100644 --- a/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/JPAPathWrapper.java +++ b/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/JPAPathWrapper.java @@ -3,7 +3,7 @@ import java.util.Collections; import java.util.List; -import javax.persistence.criteria.Selection; +import jakarta.persistence.criteria.Selection; import com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAAttribute; import com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAElement; diff --git a/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/JoinTableJoin.java b/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/JoinTableJoin.java index c2cf18393..5d046ae29 100644 --- a/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/JoinTableJoin.java +++ b/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/JoinTableJoin.java @@ -1,10 +1,11 @@ package com.sap.olingo.jpa.processor.cb.impl; import javax.annotation.Nonnull; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.From; -import javax.persistence.criteria.JoinType; -import javax.persistence.metamodel.Attribute; + +import jakarta.persistence.criteria.CriteriaBuilder; +import jakarta.persistence.criteria.From; +import jakarta.persistence.criteria.JoinType; +import jakarta.persistence.metamodel.Attribute; import com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAAssociationPath; import com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAEntityType; diff --git a/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/OrderImpl.java b/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/OrderImpl.java index af2e6b315..9ab43d4b0 100644 --- a/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/OrderImpl.java +++ b/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/OrderImpl.java @@ -2,8 +2,8 @@ import java.util.Optional; -import javax.persistence.criteria.Expression; -import javax.persistence.criteria.Order; +import jakarta.persistence.criteria.Expression; +import jakarta.persistence.criteria.Order; import com.sap.olingo.jpa.metadata.core.edm.mapper.exception.ODataJPAModelException; import com.sap.olingo.jpa.processor.cb.exceptions.InternalServerError; diff --git a/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/ParameterBuffer.java b/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/ParameterBuffer.java index 98c1e3bc6..cbf356f47 100644 --- a/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/ParameterBuffer.java +++ b/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/ParameterBuffer.java @@ -5,7 +5,8 @@ import java.util.Objects; import javax.annotation.Nonnull; -import javax.persistence.criteria.Expression; + +import jakarta.persistence.criteria.Expression; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -27,9 +28,9 @@ ParameterExpression addValue(@Nonnull final S value) { } @SuppressWarnings("unchecked") - ParameterExpression addValue(@Nonnull final S value, final Expression x) { + ParameterExpression addValue(@Nonnull final S value, final Expression expression) { - ParameterExpression param = new ParameterExpression<>(index, Objects.requireNonNull(value), x); + ParameterExpression param = new ParameterExpression<>(index, Objects.requireNonNull(value), expression); if (!parameterByHash.containsKey(param.hashCode())) { parameterByHash.put(param.hashCode(), param); index++; diff --git a/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/PathImpl.java b/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/PathImpl.java index 824ab7d62..170bde339 100644 --- a/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/PathImpl.java +++ b/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/PathImpl.java @@ -11,12 +11,13 @@ import java.util.Optional; import javax.annotation.Nonnull; -import javax.persistence.criteria.Expression; -import javax.persistence.criteria.Path; -import javax.persistence.metamodel.Bindable; -import javax.persistence.metamodel.MapAttribute; -import javax.persistence.metamodel.PluralAttribute; -import javax.persistence.metamodel.SingularAttribute; + +import jakarta.persistence.criteria.Expression; +import jakarta.persistence.criteria.Path; +import jakarta.persistence.metamodel.Bindable; +import jakarta.persistence.metamodel.MapAttribute; +import jakarta.persistence.metamodel.PluralAttribute; +import jakarta.persistence.metamodel.SingularAttribute; import com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAAttribute; import com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAEntityType; @@ -56,14 +57,6 @@ class PathImpl extends ExpressionImpl implements Path { this.tableAlias = Optional.ofNullable(tableAlias.orElseGet(this::tableAliasFromParent)); } - PathImpl(final PathImpl s, final Optional newTableAlias) { - super(); - this.path = s.path; - this.parent = s.parent; - this.st = s.st; - this.tableAlias = newTableAlias; - } - @Override public StringBuilder asSQL(final StringBuilder statement) { tableAlias.ifPresent(p -> { @@ -110,7 +103,8 @@ public Path get(final SingularAttribute attribute) { /** * Create a path corresponding to the referenced attribute. * - *

            Note: Applications using the string-based API may need to + *

            + * Note: Applications using the string-based API may need to * specify the type resulting from the get operation in order * to avoid the use of Path variables. * @@ -174,7 +168,7 @@ public Path get(final String attributeName) { private boolean isKeyPath(final JPAPath jpaPath) throws ODataJPAModelException { return st.getKeyPath() .stream() - .anyMatch(p -> p.getAlias().equals(jpaPath.getAlias())); + .anyMatch(keyPath -> keyPath.getAlias().equals(jpaPath.getAlias())); } /** @@ -227,8 +221,8 @@ List> resolvePathElements() { return singletonList((Path) this); return getPathList() .stream() - .map(e -> new PathImpl<>(e, parent, st, tableAlias)) - .collect(toList()); + .map(jpaPath -> new PathImpl<>(jpaPath, parent, st, tableAlias)) + .collect(toList()); // NOSONAR } @@ -243,11 +237,11 @@ public int hashCode() { @SuppressWarnings("rawtypes") @Override - public boolean equals(final Object obj) { - if (this == obj) return true; - if (obj == null) return false; - if (getClass() != obj.getClass()) return false; - final PathImpl other = (PathImpl) obj; + public boolean equals(final Object object) { + if (this == object) return true; + if (object == null) return false; + if (getClass() != object.getClass()) return false; + final PathImpl other = (PathImpl) object; if (!path.isPresent()) { if (other.path.isPresent()) return false; } else if (!path.equals(other.path)) return false; diff --git a/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/PathJoin.java b/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/PathJoin.java index f2249b5a2..df05035d1 100644 --- a/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/PathJoin.java +++ b/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/PathJoin.java @@ -1,10 +1,11 @@ package com.sap.olingo.jpa.processor.cb.impl; import javax.annotation.Nonnull; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.Expression; -import javax.persistence.criteria.JoinType; -import javax.persistence.metamodel.Attribute; + +import jakarta.persistence.criteria.CriteriaBuilder; +import jakarta.persistence.criteria.Expression; +import jakarta.persistence.criteria.JoinType; +import jakarta.persistence.metamodel.Attribute; import com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAPath; import com.sap.olingo.jpa.processor.cb.exceptions.NotImplementedException; diff --git a/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/PredicateImpl.java b/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/PredicateImpl.java index 35c18ef9e..26c7dec2d 100644 --- a/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/PredicateImpl.java +++ b/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/PredicateImpl.java @@ -8,12 +8,13 @@ import javax.annotation.CheckForNull; import javax.annotation.Nonnull; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.Expression; -import javax.persistence.criteria.Path; -import javax.persistence.criteria.Predicate; -import javax.persistence.criteria.Selection; -import javax.persistence.criteria.Subquery; + +import jakarta.persistence.criteria.CriteriaBuilder; +import jakarta.persistence.criteria.Expression; +import jakarta.persistence.criteria.Path; +import jakarta.persistence.criteria.Predicate; +import jakarta.persistence.criteria.Selection; +import jakarta.persistence.criteria.Subquery; import com.sap.olingo.jpa.processor.cb.exceptions.NotImplementedException; import com.sap.olingo.jpa.processor.cb.joiner.SqlConvertible; @@ -358,12 +359,12 @@ public StringBuilder asSQL(final StringBuilder statement) { } @Override - public javax.persistence.criteria.CriteriaBuilder.In value(final X value) { + public jakarta.persistence.criteria.CriteriaBuilder.In value(final X value) { throw new NotImplementedException(); } @Override - public javax.persistence.criteria.CriteriaBuilder.In value(final Expression value) { + public jakarta.persistence.criteria.CriteriaBuilder.In value(final Expression value) { throw new NotImplementedException(); } diff --git a/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/RootImpl.java b/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/RootImpl.java index ff2b844b2..36448fd8e 100644 --- a/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/RootImpl.java +++ b/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/RootImpl.java @@ -1,16 +1,16 @@ package com.sap.olingo.jpa.processor.cb.impl; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.Root; -import javax.persistence.metamodel.EntityType; +import jakarta.persistence.criteria.CriteriaBuilder; +import jakarta.persistence.criteria.Root; +import jakarta.persistence.metamodel.EntityType; import com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAEntityType; import com.sap.olingo.jpa.processor.cb.exceptions.NotImplementedException; class RootImpl extends FromImpl implements Root { - RootImpl(final JPAEntityType type, final AliasBuilder ab, final CriteriaBuilder cb) { - super(type, ab, cb); + RootImpl(final JPAEntityType type, final AliasBuilder aliasBuilder, final CriteriaBuilder cb) { + super(type, aliasBuilder, cb); } @Override diff --git a/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/SelectionImpl.java b/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/SelectionImpl.java index a6273f11a..304bc80d3 100644 --- a/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/SelectionImpl.java +++ b/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/SelectionImpl.java @@ -9,8 +9,9 @@ import java.util.Optional; import javax.annotation.Nonnull; -import javax.persistence.criteria.Path; -import javax.persistence.criteria.Selection; + +import jakarta.persistence.criteria.Path; +import jakarta.persistence.criteria.Selection; import com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAPath; import com.sap.olingo.jpa.processor.cb.joiner.SqlConvertible; diff --git a/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/SelectionPath.java b/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/SelectionPath.java index 8e684d497..7ffb42af2 100644 --- a/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/SelectionPath.java +++ b/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/SelectionPath.java @@ -5,12 +5,13 @@ import java.util.Optional; import javax.annotation.Nonnull; -import javax.persistence.criteria.Expression; -import javax.persistence.criteria.Path; -import javax.persistence.metamodel.Bindable; -import javax.persistence.metamodel.MapAttribute; -import javax.persistence.metamodel.PluralAttribute; -import javax.persistence.metamodel.SingularAttribute; + +import jakarta.persistence.criteria.Expression; +import jakarta.persistence.criteria.Path; +import jakarta.persistence.metamodel.Bindable; +import jakarta.persistence.metamodel.MapAttribute; +import jakarta.persistence.metamodel.PluralAttribute; +import jakarta.persistence.metamodel.SingularAttribute; import com.sap.olingo.jpa.processor.cb.exceptions.NotImplementedException; @@ -25,37 +26,37 @@ class SelectionPath extends ExpressionImpl implements Path { final SqlSelection selection; final Optional tableAlias; - SelectionPath(@Nonnull final SqlSelection selImpl, @Nonnull final Optional tableAlias) { - this.selection = selImpl; + SelectionPath(@Nonnull final SqlSelection selection, @Nonnull final Optional tableAlias) { + this.selection = selection; this.tableAlias = tableAlias; } @Override public StringBuilder asSQL(final StringBuilder statement) { - tableAlias.ifPresent(p -> { - statement.append(p); + tableAlias.ifPresent(alias -> { + statement.append(alias); statement.append(DOT); }); return statement.append(selection.getAlias().replaceAll(SELECTION_REPLACEMENT_REGEX, SELECTION_REPLACEMENT)); } @Override - public Path get(final SingularAttribute arg0) { + public Path get(final SingularAttribute attribute) { throw new NotImplementedException(); } @Override - public > Expression get(final PluralAttribute arg0) { + public > Expression get(final PluralAttribute attribute) { throw new NotImplementedException(); } @Override - public > Expression get(final MapAttribute arg0) { + public > Expression get(final MapAttribute attribute) { throw new NotImplementedException(); } @Override - public Path get(final String arg0) { + public Path get(final String attribute) { throw new NotImplementedException(); } diff --git a/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/SimpleJoin.java b/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/SimpleJoin.java index 737e245e6..1b7e7ba94 100644 --- a/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/SimpleJoin.java +++ b/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/SimpleJoin.java @@ -3,10 +3,11 @@ import java.util.Objects; import javax.annotation.Nonnull; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.From; -import javax.persistence.criteria.JoinType; -import javax.persistence.metamodel.Attribute; + +import jakarta.persistence.criteria.CriteriaBuilder; +import jakarta.persistence.criteria.From; +import jakarta.persistence.criteria.JoinType; +import jakarta.persistence.metamodel.Attribute; import com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAAssociationPath; import com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAEntityType; diff --git a/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/SqlJoinType.java b/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/SqlJoinType.java index b55ef7b21..8618fe9b8 100644 --- a/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/SqlJoinType.java +++ b/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/SqlJoinType.java @@ -2,7 +2,7 @@ import java.util.EnumMap; -import javax.persistence.criteria.JoinType; +import jakarta.persistence.criteria.JoinType; enum SqlJoinType { diff --git a/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/SqlSelection.java b/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/SqlSelection.java index d0cd10c76..001d29112 100644 --- a/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/SqlSelection.java +++ b/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/SqlSelection.java @@ -1,6 +1,6 @@ package com.sap.olingo.jpa.processor.cb.impl; -import javax.persistence.criteria.Selection; +import jakarta.persistence.criteria.Selection; import com.sap.olingo.jpa.processor.cb.ProcessorSelection; import com.sap.olingo.jpa.processor.cb.joiner.SqlConvertible; diff --git a/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/SubqueryImpl.java b/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/SubqueryImpl.java index f3b9e953f..4962ada1b 100644 --- a/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/SubqueryImpl.java +++ b/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/SubqueryImpl.java @@ -11,23 +11,24 @@ import java.util.Set; import javax.annotation.Nonnull; -import javax.persistence.criteria.AbstractQuery; -import javax.persistence.criteria.CollectionJoin; -import javax.persistence.criteria.CommonAbstractCriteria; -import javax.persistence.criteria.CompoundSelection; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.CriteriaQuery; -import javax.persistence.criteria.Expression; -import javax.persistence.criteria.Join; -import javax.persistence.criteria.ListJoin; -import javax.persistence.criteria.MapJoin; -import javax.persistence.criteria.Order; -import javax.persistence.criteria.Predicate; -import javax.persistence.criteria.Root; -import javax.persistence.criteria.Selection; -import javax.persistence.criteria.SetJoin; -import javax.persistence.criteria.Subquery; -import javax.persistence.metamodel.EntityType; + +import jakarta.persistence.criteria.AbstractQuery; +import jakarta.persistence.criteria.CollectionJoin; +import jakarta.persistence.criteria.CommonAbstractCriteria; +import jakarta.persistence.criteria.CompoundSelection; +import jakarta.persistence.criteria.CriteriaBuilder; +import jakarta.persistence.criteria.CriteriaQuery; +import jakarta.persistence.criteria.Expression; +import jakarta.persistence.criteria.Join; +import jakarta.persistence.criteria.ListJoin; +import jakarta.persistence.criteria.MapJoin; +import jakarta.persistence.criteria.Order; +import jakarta.persistence.criteria.Predicate; +import jakarta.persistence.criteria.Root; +import jakarta.persistence.criteria.Selection; +import jakarta.persistence.criteria.SetJoin; +import jakarta.persistence.criteria.Subquery; +import jakarta.persistence.metamodel.EntityType; import com.sap.olingo.jpa.processor.cb.ProcessorCriteriaQuery; import com.sap.olingo.jpa.processor.cb.ProcessorSubquery; diff --git a/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/SubqueryRootImpl.java b/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/SubqueryRootImpl.java index 8eb2e59c2..bd7836232 100644 --- a/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/SubqueryRootImpl.java +++ b/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/SubqueryRootImpl.java @@ -1,11 +1,12 @@ package com.sap.olingo.jpa.processor.cb.impl; import javax.annotation.Nonnull; -import javax.persistence.criteria.Path; -import javax.persistence.criteria.Root; -import javax.persistence.criteria.Selection; -import javax.persistence.criteria.Subquery; -import javax.persistence.metamodel.EntityType; + +import jakarta.persistence.criteria.Path; +import jakarta.persistence.criteria.Root; +import jakarta.persistence.criteria.Selection; +import jakarta.persistence.criteria.Subquery; +import jakarta.persistence.metamodel.EntityType; import com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAServiceDocument; import com.sap.olingo.jpa.metadata.core.edm.mapper.exception.ODataJPAModelException; @@ -18,7 +19,7 @@ class SubqueryRootImpl extends FromImpl implements Root { private final Subquery query; SubqueryRootImpl(@Nonnull final ProcessorSubquery inner, @Nonnull final AliasBuilder ab, - final JPAServiceDocument sd) throws ODataJPAModelException { + @Nonnull final JPAServiceDocument sd) throws ODataJPAModelException { super(sd.getEntity(inner.getJavaType()), ab, null); this.query = inner; @@ -53,10 +54,9 @@ public EntityType getModel() { @Override public Path get(final String attributeName) { - for (final Selection sel : query.getCompoundSelectionItems()) { - if (sel instanceof SelectionImpl) { - final SelectionImpl selImpl = (SelectionImpl) sel; - final Selection x = selImpl.selection; + for (final Selection selection : query.getCompoundSelectionItems()) { + if (selection instanceof final SelectionImpl selectionImpl) { + final Selection x = selectionImpl.selection; if (x instanceof PathImpl) { if (x.getAlias().equals(attributeName) @@ -66,7 +66,7 @@ public Path get(final String attributeName) { || ((PathImpl) x).path .orElseThrow(IllegalStateException::new) .getLeaf().getInternalName().equals(attributeName)) { - return new SelectionPath(selImpl, tableAlias); + return new SelectionPath(selectionImpl, tableAlias); } } else if (x instanceof WindowFunctionExpression && x.getAlias().equals(attributeName)) { @@ -81,20 +81,17 @@ public Path get(final String attributeName) { public int hashCode() { final int prime = 31; int result = super.hashCode(); - result = prime * result + ((query == null) ? 0 : query.hashCode()); + result = prime * result + query.hashCode(); return result; } @Override - public boolean equals(final Object obj) { - if (this == obj) return true; - if (!super.equals(obj)) return false; - if (getClass() != obj.getClass()) return false; + public boolean equals(final Object object) { + if (this == object) return true; + if (!super.equals(object)) return false; + if (getClass() != object.getClass()) return false; @SuppressWarnings("unchecked") - final SubqueryRootImpl other = (SubqueryRootImpl) obj; - if (query == null) { - if (other.query != null) return false; - } else if (!query.equals(other.query)) return false; - return true; + final SubqueryRootImpl other = (SubqueryRootImpl) object; + return (query.equals(other.query)); } } diff --git a/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/TupleImpl.java b/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/TupleImpl.java index 6280eea86..cc5ea8f82 100644 --- a/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/TupleImpl.java +++ b/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/TupleImpl.java @@ -9,8 +9,8 @@ import java.util.Optional; import java.util.stream.Collectors; -import javax.persistence.Tuple; -import javax.persistence.TupleElement; +import jakarta.persistence.Tuple; +import jakarta.persistence.TupleElement; import com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAAttribute; @@ -41,7 +41,8 @@ class TupleImpl implements Tuple { /** * Get the value of the element at the specified - * position in the result tuple. The first position is 0.

            + * position in the result tuple. The first position is 0. + *

            * Please note: As of now no conversions are made. * @param i position in result tuple * @return value of the tuple element @@ -57,7 +58,8 @@ public Object get(final int index) { /** * Get the value of the element at the specified - * position in the result tuple. The first position is 0.

            + * position in the result tuple. The first position is 0. + *

            * Please note: As of now no conversions are made. * @param i position in result tuple * @param type type of the tuple element @@ -154,8 +156,8 @@ private List> asTupleElements() { tupleElements = Optional.of( selectionIndex.entrySet() .stream() - .map(e -> new TupleElementImpl<>(e.getValue())) - .collect(Collectors.toList())); + .map(element -> new TupleElementImpl<>(element.getValue())) + .collect(Collectors.toList())); // NOSONAR return tupleElements.orElseThrow(IllegalStateException::new); } diff --git a/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/TypeConverter.java b/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/TypeConverter.java index 81341ae43..ae0fdb0a9 100644 --- a/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/TypeConverter.java +++ b/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/TypeConverter.java @@ -31,18 +31,18 @@ static Object convert(final Object source, final Class target) { // NOSONAR if (target == String.class) { return source.toString(); } - if (boxed(target) == Boolean.class && source instanceof String) - return Boolean.valueOf((String) source); - if (boxed(target) == Boolean.class && source instanceof Number) - return ((Number) source).intValue() == 0 ? Boolean.FALSE : Boolean.TRUE; - if (source instanceof Number && Number.class.isAssignableFrom(boxed(target))) { - return convertNumber((Number) source, target); + if (boxed(target) == Boolean.class && source instanceof final String asString) + return Boolean.valueOf(asString); + if (boxed(target) == Boolean.class && source instanceof final Number asNumber) + return asNumber.intValue() == 0 ? Boolean.FALSE : Boolean.TRUE; + if (source instanceof final Number asNumber && Number.class.isAssignableFrom(boxed(target))) { + return convertNumber(asNumber, target); } if (Temporal.class.isAssignableFrom(target)) { return convertTemporal(source, target); } - if (boxed(target) == Character.class && source instanceof String) { - return convertToCharacter((String) source); + if (boxed(target) == Character.class && source instanceof final String asString) { + return convertToCharacter(asString); } if (target == Duration.class) { return convertDuration(source); diff --git a/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/TypedQueryImpl.java b/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/TypedQueryImpl.java index 3d3dd8a39..3253b80a9 100644 --- a/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/TypedQueryImpl.java +++ b/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/impl/TypedQueryImpl.java @@ -10,22 +10,22 @@ import java.util.Set; import java.util.stream.Collectors; -import javax.persistence.EntityManager; -import javax.persistence.FlushModeType; -import javax.persistence.LockModeType; -import javax.persistence.LockTimeoutException; -import javax.persistence.NoResultException; -import javax.persistence.NonUniqueResultException; -import javax.persistence.Parameter; -import javax.persistence.PersistenceException; -import javax.persistence.PessimisticLockException; -import javax.persistence.Query; -import javax.persistence.QueryTimeoutException; -import javax.persistence.TemporalType; -import javax.persistence.TransactionRequiredException; -import javax.persistence.Tuple; -import javax.persistence.TypedQuery; -import javax.persistence.criteria.CriteriaQuery; +import jakarta.persistence.EntityManager; +import jakarta.persistence.FlushModeType; +import jakarta.persistence.LockModeType; +import jakarta.persistence.LockTimeoutException; +import jakarta.persistence.NoResultException; +import jakarta.persistence.NonUniqueResultException; +import jakarta.persistence.Parameter; +import jakarta.persistence.PersistenceException; +import jakarta.persistence.PessimisticLockException; +import jakarta.persistence.Query; +import jakarta.persistence.QueryTimeoutException; +import jakarta.persistence.TemporalType; +import jakarta.persistence.TransactionRequiredException; +import jakarta.persistence.Tuple; +import jakarta.persistence.TypedQuery; +import jakarta.persistence.criteria.CriteriaQuery; import com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAAttribute; import com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAPath; @@ -35,7 +35,7 @@ class TypedQueryImpl implements TypedQuery { private final CriteriaQueryImpl parent; - private final Query q; + private final Query query; private final ProcessorSelection selection; TypedQueryImpl(final CriteriaQuery criteriaQuery, final EntityManager em, @@ -44,78 +44,78 @@ class TypedQueryImpl implements TypedQuery { this.parent = (CriteriaQueryImpl) criteriaQuery; this.parent.getResultType(); this.selection = (ProcessorSelection) parent.getSelection(); - this.q = em.createNativeQuery(parent.asSQL(sql).toString()); + this.query = em.createNativeQuery(parent.asSQL(sql).toString()); copyParameter(parameterBuffer.getParameter()); } @Override public int executeUpdate() { - return q.executeUpdate(); + return query.executeUpdate(); } @Override public int getFirstResult() { - return q.getFirstResult(); + return query.getFirstResult(); } @Override public FlushModeType getFlushMode() { - return q.getFlushMode(); + return query.getFlushMode(); } @Override public Map getHints() { - return q.getHints(); + return query.getHints(); } @Override public LockModeType getLockMode() { - return q.getLockMode(); + return query.getLockMode(); } @Override public int getMaxResults() { - return q.getMaxResults(); + return query.getMaxResults(); } @Override public Parameter getParameter(final int position) { - return q.getParameter(position); + return query.getParameter(position); } @Override public Parameter getParameter(final int position, final Class type) { - return q.getParameter(position, type); + return query.getParameter(position, type); } @Override public Parameter getParameter(final String name) { - return q.getParameter(name); + return query.getParameter(name); } @Override public Parameter getParameter(final String name, final Class type) { - return q.getParameter(name, type); + return query.getParameter(name, type); } @Override public Set> getParameters() { - return q.getParameters(); + return query.getParameters(); } @Override public Object getParameterValue(final int position) { - return q.getParameterValue(position); + return query.getParameterValue(position); } @Override public X getParameterValue(final Parameter param) { - return q.getParameterValue(param); + return query.getParameterValue(param); } @Override public Object getParameterValue(final String name) { - return q.getParameterValue(name); + return query.getParameterValue(name); } /** @@ -142,21 +142,21 @@ public Object getParameterValue(final String name) { @Override public List getResultList() { - final List result = q.getResultList(); + final List result = query.getResultList(); if (parent.getResultType().isAssignableFrom(Tuple.class)) { if (result.isEmpty()) return Collections.emptyList(); - final List> selPath = buildSelection(); - final Map index = buildSelectionIndex(selPath); - final List> selAttributes = toAttributeList(selPath); + final List> selectionPath = buildSelection(); + final Map index = buildSelectionIndex(selectionPath); + final List> selectionAttributes = toAttributeList(selectionPath); if (result.get(0).getClass().isArray()) { return (List) ((List) result).stream() - .map(r -> new TupleImpl(r, selAttributes, index)) - .collect(Collectors.toList()); + .map(item -> new TupleImpl(item, selectionAttributes, index)) + .collect(Collectors.toList()); // NOSONAR } return (List) ((List) result).stream() - .map(r -> new TupleImpl(r, selAttributes, index)) - .collect(Collectors.toList()); + .map(item -> new TupleImpl(item, selectionAttributes, index)) + .collect(Collectors.toList()); // NOSONAR } return (List) result; } @@ -192,118 +192,119 @@ public T getSingleResult() { @Override public boolean isBound(final Parameter param) { - return q.isBound(param); + return query.isBound(param); } @Override public TypedQuery setFirstResult(final int startPosition) { - q.setFirstResult(startPosition); + query.setFirstResult(startPosition); return this; } @Override public TypedQuery setFlushMode(final FlushModeType flushMode) { - q.setFlushMode(flushMode); + query.setFlushMode(flushMode); return this; } @Override public TypedQuery setHint(final String hintName, final Object value) { - q.setHint(hintName, value); + query.setHint(hintName, value); return this; } @Override public TypedQuery setLockMode(final LockModeType lockMode) { - q.setLockMode(lockMode); + query.setLockMode(lockMode); return this; } @Override public TypedQuery setMaxResults(final int maxResult) { - q.setMaxResults(maxResult); + query.setMaxResults(maxResult); return this; } @Override public TypedQuery setParameter(final int position, final Calendar value, final TemporalType temporalType) { - q.setParameter(position, value, temporalType); + query.setParameter(position, value, temporalType); return this; } @Override public TypedQuery setParameter(final int position, final Date value, final TemporalType temporalType) { - q.setParameter(position, value, temporalType); + query.setParameter(position, value, temporalType); return this; } @Override public TypedQuery setParameter(final int position, final Object value) { - q.setParameter(position, value); + query.setParameter(position, value); return this; } @Override public TypedQuery setParameter(final Parameter param, final Calendar value, final TemporalType temporalType) { - q.setParameter(param, value, temporalType); + query.setParameter(param, value, temporalType); return this; } @Override public TypedQuery setParameter(final Parameter param, final Date value, final TemporalType temporalType) { - q.setParameter(param, value, temporalType); + query.setParameter(param, value, temporalType); return this; } @Override public TypedQuery setParameter(final Parameter param, final X value) { - q.setParameter(param, value); + query.setParameter(param, value); return this; } @Override public TypedQuery setParameter(final String name, final Calendar value, final TemporalType temporalType) { - q.setParameter(name, value, temporalType); + query.setParameter(name, value, temporalType); return this; } @Override public TypedQuery setParameter(final String name, final Date value, final TemporalType temporalType) { - q.setParameter(name, value, temporalType); + query.setParameter(name, value, temporalType); return this; } @Override public TypedQuery setParameter(final String name, final Object value) { - q.setParameter(name, value); + query.setParameter(name, value); return this; } @Override - public X unwrap(final Class cls) { - return q.unwrap(cls); + public X unwrap(final Class clazz) { + return query.unwrap(clazz); } private List> buildSelection() { return selection.getResolvedSelection(); } - private Map buildSelectionIndex(final List> selPath) { + private Map buildSelectionIndex(final List> selectionPath) { final int[] count = { 0 }; - return selPath.stream() - .collect(Collectors.toMap(Entry::getKey, p -> count[0]++)); + return selectionPath.stream() + .collect(Collectors.toMap(Entry::getKey, path -> count[0]++)); } private void copyParameter(final Map> map) { - map.entrySet().stream().forEach(e -> this.q.setParameter(e.getValue().getPosition(), e.getValue().getValue())); + map.entrySet().stream().forEach(es -> this.query.setParameter(es.getValue().getPosition(), es.getValue() + .getValue())); } - private List> toAttributeList(final List> selPath) { - final List> result = new ArrayList<>(selPath.size()); - for (final Entry entity : selPath) { + private List> toAttributeList(final List> selectionPath) { + final List> result = new ArrayList<>(selectionPath.size()); + for (final Entry entity : selectionPath) { result.add(new ProcessorSelection.SelectionAttribute(entity.getKey(), entity.getValue().getLeaf())); } return result; diff --git a/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/joiner/ExpressionCollector.java b/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/joiner/ExpressionCollector.java index 4c1fdba5f..a5c3ae97f 100644 --- a/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/joiner/ExpressionCollector.java +++ b/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/joiner/ExpressionCollector.java @@ -9,9 +9,10 @@ import java.util.stream.Collector; import javax.annotation.Nonnull; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.Expression; -import javax.persistence.criteria.Predicate.BooleanOperator; + +import jakarta.persistence.criteria.CriteriaBuilder; +import jakarta.persistence.criteria.Expression; +import jakarta.persistence.criteria.Predicate.BooleanOperator; public class ExpressionCollector implements Collector, ExpressionJoiner, Expression> { diff --git a/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/joiner/ExpressionJoiner.java b/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/joiner/ExpressionJoiner.java index d74ba5d80..d1e6550a0 100644 --- a/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/joiner/ExpressionJoiner.java +++ b/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/joiner/ExpressionJoiner.java @@ -3,9 +3,10 @@ import java.util.Objects; import javax.annotation.Nonnull; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.Expression; -import javax.persistence.criteria.Predicate.BooleanOperator; + +import jakarta.persistence.criteria.CriteriaBuilder; +import jakarta.persistence.criteria.Expression; +import jakarta.persistence.criteria.Predicate.BooleanOperator; final class ExpressionJoiner { diff --git a/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/joiner/StringBuilderCollector.java b/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/joiner/StringBuilderCollector.java index cce42d1f7..4bb3882b5 100644 --- a/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/joiner/StringBuilderCollector.java +++ b/jpa/odata-jpa-processor-cb/src/main/java/com/sap/olingo/jpa/processor/cb/joiner/StringBuilderCollector.java @@ -9,9 +9,10 @@ import java.util.stream.Collector; import javax.annotation.Nonnull; -import javax.persistence.criteria.Expression; -import javax.persistence.criteria.Order; -import javax.persistence.criteria.Selection; + +import jakarta.persistence.criteria.Expression; +import jakarta.persistence.criteria.Order; +import jakarta.persistence.criteria.Selection; public abstract class StringBuilderCollector implements Collector, String> { diff --git a/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/api/EntityManagerFactoryWrapperTest.java b/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/api/EntityManagerFactoryWrapperTest.java index dd3926528..a91f45c02 100644 --- a/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/api/EntityManagerFactoryWrapperTest.java +++ b/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/api/EntityManagerFactoryWrapperTest.java @@ -13,15 +13,15 @@ import java.util.Map; import java.util.stream.Stream; -import javax.persistence.Cache; -import javax.persistence.EntityGraph; -import javax.persistence.EntityManager; -import javax.persistence.EntityManagerFactory; -import javax.persistence.PersistenceUnitUtil; -import javax.persistence.Query; -import javax.persistence.SynchronizationType; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.metamodel.Metamodel; +import jakarta.persistence.Cache; +import jakarta.persistence.EntityGraph; +import jakarta.persistence.EntityManager; +import jakarta.persistence.EntityManagerFactory; +import jakarta.persistence.PersistenceUnitUtil; +import jakarta.persistence.Query; +import jakarta.persistence.SynchronizationType; +import jakarta.persistence.criteria.CriteriaBuilder; +import jakarta.persistence.metamodel.Metamodel; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; diff --git a/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/AggregationExpressionTest.java b/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/AggregationExpressionTest.java index 3f27dd1b5..0189e2ef6 100644 --- a/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/AggregationExpressionTest.java +++ b/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/AggregationExpressionTest.java @@ -8,9 +8,9 @@ import java.util.Arrays; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.From; -import javax.persistence.criteria.Path; +import jakarta.persistence.criteria.CriteriaBuilder; +import jakarta.persistence.criteria.From; +import jakarta.persistence.criteria.Path; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; diff --git a/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/ArithmeticExpressionTest.java b/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/ArithmeticExpressionTest.java index fb59b6d1d..5082708f8 100644 --- a/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/ArithmeticExpressionTest.java +++ b/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/ArithmeticExpressionTest.java @@ -3,8 +3,8 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.Mockito.mock; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.From; +import jakarta.persistence.criteria.CriteriaBuilder; +import jakarta.persistence.criteria.From; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; diff --git a/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/BuilderBaseTest.java b/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/BuilderBaseTest.java index 995c18c60..a6bf71da5 100644 --- a/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/BuilderBaseTest.java +++ b/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/BuilderBaseTest.java @@ -9,9 +9,10 @@ import java.util.ArrayList; import java.util.List; -import javax.persistence.EntityManagerFactory; import javax.sql.DataSource; +import jakarta.persistence.EntityManagerFactory; + import org.apache.olingo.commons.api.ex.ODataException; import org.junit.jupiter.api.BeforeAll; @@ -40,9 +41,9 @@ public static void classSetup() throws ODataException { sd.getEdmEntityContainer(); } - protected void testNotImplemented(final Method m, final Object cut) throws IllegalAccessException { + protected void testNotImplemented(final Method method, final Object cut) throws IllegalAccessException { try { - invokeMethod(m, cut); + invokeMethod(method, cut); } catch (final InvocationTargetException e) { assertTrue(e.getCause() instanceof NotImplementedException); return; @@ -50,30 +51,30 @@ protected void testNotImplemented(final Method m, final Object cut) throws Illeg fail(); } - protected Object invokeMethod(final Method m, final Object cut) throws IllegalAccessException, + protected Object invokeMethod(final Method method, final Object cut) throws IllegalAccessException, InvocationTargetException { - if (m.getParameterCount() >= 1) { - final Class[] params = m.getParameterTypes(); - final List paramValues = new ArrayList<>(m.getParameterCount()); - for (int i = 0; i < m.getParameterCount(); i++) { + if (method.getParameterCount() >= 1) { + final Class[] params = method.getParameterTypes(); + final List paramValues = new ArrayList<>(method.getParameterCount()); + for (int i = 0; i < method.getParameterCount(); i++) { if (params[i] == char.class) paramValues.add(' '); else paramValues.add(null); } - return m.invoke(cut, paramValues.toArray()); + return method.invoke(cut, paramValues.toArray()); } else { - return m.invoke(cut); + return method.invoke(cut); } } - protected Object invokeMethod(final Method m, final Object cut, final Object... paramValues) + protected Object invokeMethod(final Method method, final Object cut, final Object... paramValues) throws IllegalAccessException, InvocationTargetException { - if (m.getParameterCount() >= 1) { - return m.invoke(cut, paramValues); + if (method.getParameterCount() >= 1) { + return method.invoke(cut, paramValues); } else { - return m.invoke(cut); + return method.invoke(cut); } } } diff --git a/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/CompoundSelectionImplTest.java b/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/CompoundSelectionImplTest.java index ea0f08fd6..6f1d8ac3a 100644 --- a/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/CompoundSelectionImplTest.java +++ b/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/CompoundSelectionImplTest.java @@ -12,8 +12,8 @@ import java.util.List; import java.util.Map.Entry; -import javax.persistence.criteria.Path; -import javax.persistence.criteria.Selection; +import jakarta.persistence.criteria.Path; +import jakarta.persistence.criteria.Selection; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; diff --git a/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/CriteriaBuilderDerbyTest.java b/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/CriteriaBuilderDerbyTest.java index 8ecec216d..00de83997 100644 --- a/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/CriteriaBuilderDerbyTest.java +++ b/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/CriteriaBuilderDerbyTest.java @@ -1,8 +1,9 @@ package com.sap.olingo.jpa.processor.cb.impl; -import javax.persistence.EntityManagerFactory; import javax.sql.DataSource; +import jakarta.persistence.EntityManagerFactory; + import org.apache.olingo.commons.api.ex.ODataException; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; diff --git a/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/CriteriaBuilderH2Test.java b/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/CriteriaBuilderH2Test.java index 4832b6472..02c51c096 100644 --- a/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/CriteriaBuilderH2Test.java +++ b/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/CriteriaBuilderH2Test.java @@ -6,13 +6,14 @@ import java.util.Arrays; import java.util.List; -import javax.persistence.EntityManagerFactory; -import javax.persistence.Tuple; -import javax.persistence.TypedQuery; -import javax.persistence.criteria.Expression; -import javax.persistence.criteria.Root; import javax.sql.DataSource; +import jakarta.persistence.EntityManagerFactory; +import jakarta.persistence.Tuple; +import jakarta.persistence.TypedQuery; +import jakarta.persistence.criteria.Expression; +import jakarta.persistence.criteria.Root; + import org.apache.olingo.commons.api.ex.ODataException; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; diff --git a/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/CriteriaBuilderHSQLDBTest.java b/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/CriteriaBuilderHSQLDBTest.java index 69c142432..24b967f34 100644 --- a/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/CriteriaBuilderHSQLDBTest.java +++ b/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/CriteriaBuilderHSQLDBTest.java @@ -1,8 +1,9 @@ package com.sap.olingo.jpa.processor.cb.impl; -import javax.persistence.EntityManagerFactory; import javax.sql.DataSource; +import jakarta.persistence.EntityManagerFactory; + import org.apache.olingo.commons.api.ex.ODataException; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; diff --git a/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/CriteriaBuilderImplTest.java b/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/CriteriaBuilderImplTest.java index c04667f1f..a01aa60c1 100644 --- a/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/CriteriaBuilderImplTest.java +++ b/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/CriteriaBuilderImplTest.java @@ -3,6 +3,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.params.provider.Arguments.arguments; import java.lang.reflect.InvocationTargetException; @@ -12,22 +13,22 @@ import java.util.Map; import java.util.stream.Stream; -import javax.persistence.Tuple; -import javax.persistence.criteria.CollectionJoin; -import javax.persistence.criteria.CriteriaBuilder.Coalesce; -import javax.persistence.criteria.CriteriaBuilder.Trimspec; -import javax.persistence.criteria.CriteriaQuery; -import javax.persistence.criteria.Expression; -import javax.persistence.criteria.Join; -import javax.persistence.criteria.ListJoin; -import javax.persistence.criteria.MapJoin; -import javax.persistence.criteria.Order; -import javax.persistence.criteria.Path; -import javax.persistence.criteria.Predicate; -import javax.persistence.criteria.Root; -import javax.persistence.criteria.Selection; -import javax.persistence.criteria.SetJoin; -import javax.persistence.criteria.Subquery; +import jakarta.persistence.Tuple; +import jakarta.persistence.criteria.CollectionJoin; +import jakarta.persistence.criteria.CriteriaBuilder.Coalesce; +import jakarta.persistence.criteria.CriteriaBuilder.Trimspec; +import jakarta.persistence.criteria.CriteriaQuery; +import jakarta.persistence.criteria.Expression; +import jakarta.persistence.criteria.Join; +import jakarta.persistence.criteria.ListJoin; +import jakarta.persistence.criteria.MapJoin; +import jakarta.persistence.criteria.Order; +import jakarta.persistence.criteria.Path; +import jakarta.persistence.criteria.Predicate; +import jakarta.persistence.criteria.Root; +import jakarta.persistence.criteria.Selection; +import jakarta.persistence.criteria.SetJoin; +import jakarta.persistence.criteria.Subquery; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -36,6 +37,7 @@ import org.junit.jupiter.params.provider.MethodSource; import com.sap.olingo.jpa.processor.cb.exceptions.NotImplementedException; +import com.sap.olingo.jpa.processor.cb.impl.ExpressionImpl.ConcatExpression; import com.sap.olingo.jpa.processor.cb.impl.ExpressionImpl.ParameterExpression; import com.sap.olingo.jpa.processor.cb.joiner.SqlConvertible; import com.sap.olingo.jpa.processor.core.testmodel.AccessRights; @@ -47,8 +49,8 @@ class CriteriaBuilderImplTest extends BuilderBaseTest { CriteriaBuilderImpl cut; - private StringBuilder stmt; - private CriteriaQuery q; + private StringBuilder statement; + private CriteriaQuery query; static Stream notImplemented() throws NoSuchMethodException, SecurityException { final Class c = CriteriaBuilderImpl.class; @@ -108,7 +110,19 @@ static Stream notImplemented() throws NoSuchMethodException, Security arguments(c.getMethod("parameter", Class.class)), arguments(c.getMethod("parameter", Class.class, String.class)), arguments(c.getMethod("currentDate")), - arguments(c.getMethod("currentTime"))); + arguments(c.getMethod("currentTime")), + arguments(c.getMethod("sign", Expression.class)), + arguments(c.getMethod("ceiling", Expression.class)), + arguments(c.getMethod("floor", Expression.class)), + arguments(c.getMethod("exp", Expression.class)), + arguments(c.getMethod("power", Expression.class, Expression.class)), + arguments(c.getMethod("power", Expression.class, Number.class)), + arguments(c.getMethod("round", Expression.class, Integer.class)), + arguments(c.getMethod("localDate")), + arguments(c.getMethod("localDateTime")), + arguments(c.getMethod("localTime")), + arguments(c.getMethod("ln", Expression.class)), + arguments(c.getMethod("sqrt", Expression.class))); } static Stream binaryImplemented() throws NoSuchMethodException, SecurityException { @@ -231,8 +245,8 @@ static Stream subQueryExpressionsImplemented() throws NoSuchMethodExc @BeforeEach void setup() { cut = new CriteriaBuilderImpl(sd, new ParameterBuffer()); - stmt = new StringBuilder(); - q = cut.createTupleQuery(); + statement = new StringBuilder(); + query = cut.createTupleQuery(); } @ParameterizedTest @@ -246,12 +260,12 @@ void testThrowsNotImplemented(final Method m) throws IllegalAccessException, Ill void testBinaryExpressionWithExpression(final Method m, final String exp) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException { - final Root adminDiv = q.from(AdministrativeDivision.class); + final Root administrativeDivision = query.from(AdministrativeDivision.class); - final Object[] params = { adminDiv.get("codeID"), adminDiv.get("parentCodeID") }; + final Object[] params = { administrativeDivision.get("codeID"), administrativeDivision.get("parentCodeID") }; final Predicate act = (Predicate) m.invoke(cut, params); assertNotNull(act); - assertEquals(exp, ((SqlConvertible) act).asSQL(stmt).toString()); + assertEquals(exp, ((SqlConvertible) act).asSQL(statement).toString()); assertEquals(0, cut.getParameter().getParameter().size()); } @@ -260,13 +274,13 @@ void testBinaryExpressionWithExpression(final Method m, final String exp) throws void testBinaryExpressionWithObject(final Method m, final String exp) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException { - final Root adminDiv = q.from(AdministrativeDivision.class); + final Root administrativeDivision = query.from(AdministrativeDivision.class); - final Object[] params = { adminDiv.get("codeID"), "NUTS2" }; + final Object[] params = { administrativeDivision.get("codeID"), "NUTS2" }; final Predicate act = (Predicate) m.invoke(cut, params); assertNotNull(act); - assertEquals(exp, ((SqlConvertible) act).asSQL(stmt).toString()); + assertEquals(exp, ((SqlConvertible) act).asSQL(statement).toString()); assertEquals(1, cut.getParameter().getParameter().size()); for (final ParameterExpression parameter : cut.getParameter().getParameter().values()) { if (parameter.getPosition() == 1) @@ -279,11 +293,11 @@ void testBinaryExpressionWithObject(final Method m, final String exp) throws Ill void testBinaryNumericExpressionWithExpression(final Method m, final String exp) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException { - final Root adminDiv = q.from(AdministrativeDivision.class); - final Object[] params = { adminDiv.get("area"), adminDiv.get("population") }; + final Root administrativeDivision = query.from(AdministrativeDivision.class); + final Object[] params = { administrativeDivision.get("area"), administrativeDivision.get("population") }; final Expression act = (Expression) m.invoke(cut, params); assertNotNull(act); - assertEquals(exp, ((SqlConvertible) act).asSQL(stmt).toString()); + assertEquals(exp, ((SqlConvertible) act).asSQL(statement).toString()); assertEquals(0, cut.getParameter().getParameter().size()); } @@ -292,12 +306,12 @@ void testBinaryNumericExpressionWithExpression(final Method m, final String exp) void testBinaryNumericExpressionWithObject(final Method m, final String exp) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException { - final Root adminDiv = q.from(AdministrativeDivision.class); - final Object[] params = { adminDiv.get("area"), 1000 }; + final Root administrativeDivision = query.from(AdministrativeDivision.class); + final Object[] params = { administrativeDivision.get("area"), 1000 }; final Expression act = (Expression) m.invoke(cut, params); assertNotNull(act); - assertEquals(exp, ((SqlConvertible) act).asSQL(stmt).toString()); + assertEquals(exp, ((SqlConvertible) act).asSQL(statement).toString()); assertEquals(1, cut.getParameter().getParameter().size()); for (final ParameterExpression parameter : cut.getParameter().getParameter().values()) { if (parameter.getPosition() == 1) @@ -311,12 +325,12 @@ void testBinaryNumericExpressionWithObjectFirst(final Method m, final String exp throws IllegalAccessException, IllegalArgumentException, InvocationTargetException { - final Root adminDiv = q.from(AdministrativeDivision.class); - final Object[] params = { 1000, adminDiv.get("area") }; + final Root administrativeDivision = query.from(AdministrativeDivision.class); + final Object[] params = { 1000, administrativeDivision.get("area") }; final Expression act = (Expression) m.invoke(cut, params); assertNotNull(act); - assertEquals(exp, ((SqlConvertible) act).asSQL(stmt).toString()); + assertEquals(exp, ((SqlConvertible) act).asSQL(statement).toString()); assertEquals(1, cut.getParameter().getParameter().size()); for (final ParameterExpression parameter : cut.getParameter().getParameter().values()) { if (parameter.getPosition() == 1) @@ -328,22 +342,22 @@ void testBinaryNumericExpressionWithObjectFirst(final Method m, final String exp @MethodSource("unaryFunctionsImplemented") void testCreateUnaryFunction(final Method m, final String exp) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException { - final Root adminDiv = q.from(AdministrativeDivisionDescription.class); - final Object[] params = { adminDiv.get("name") }; + final Root administrativeDivision = query.from(AdministrativeDivisionDescription.class); + final Object[] params = { administrativeDivision.get("name") }; final Expression act = (Expression) m.invoke(cut, params); - assertEquals(exp, ((SqlConvertible) act).asSQL(stmt).toString()); + assertEquals(exp, ((SqlConvertible) act).asSQL(statement).toString()); } @ParameterizedTest @MethodSource("subQueryExpressionsImplemented") void testCreateSubQuery(final Method m, final String exp) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException { - final Subquery sub = q.subquery(Long.class); + final Subquery sub = query.subquery(Long.class); sub.select(cut.literal(1L)); sub.from(AdministrativeDivision.class); final Object[] params = { sub }; final Expression act = (Expression) m.invoke(cut, params); - assertEquals(exp, ((SqlConvertible) act).asSQL(stmt).toString()); + assertEquals(exp, ((SqlConvertible) act).asSQL(statement).toString()); } @Test @@ -381,11 +395,11 @@ void testCreateEqualThrowsNullPointerExpressionNull() { @Test void testCreateGeExpressionWithExpression() { - final Root adminDiv = q.from(AdministrativeDivision.class); - final Predicate act = cut.ge(adminDiv.get("area"), adminDiv.get("population")); + final Root administrativeDivision = query.from(AdministrativeDivision.class); + final Predicate act = cut.ge(administrativeDivision.get("area"), administrativeDivision.get("population")); assertNotNull(act); - assertEquals("(E0.\"Area\" >= E0.\"Population\")", ((SqlConvertible) act).asSQL(stmt).toString()); + assertEquals("(E0.\"Area\" >= E0.\"Population\")", ((SqlConvertible) act).asSQL(statement).toString()); assertEquals(0, cut.getParameter().getParameter().size()); } @@ -394,16 +408,26 @@ void testThrowsNullPointerExpressionNull() { assertThrows(NullPointerException.class, () -> cut.equal(null, "NUTS2")); } + @Test + void testCreateAnd() { + final String exp = "((E0.\"CodeID\" = ?1) AND (E0.\"DivisionCode\" = ?2))"; + final Root administrativeDivision = query.from(AdministrativeDivision.class); + final Predicate restriction1 = cut.equal(administrativeDivision.get("codeID"), "NUTS2"); + final Predicate restriction2 = cut.equal(administrativeDivision.get("divisionCode"), "BE34"); + final Predicate act = cut.and(restriction1, restriction2); + assertEquals(exp, ((SqlConvertible) act).asSQL(statement).toString()); + } + @Test void testCreateMultiAnd() { final String exp = "(((E0.\"CodeID\" = ?1) AND (E0.\"DivisionCode\" = ?2)) AND (E0.\"CodePublisher\" = ?3))"; - final Root adminDiv = q.from(AdministrativeDivision.class); + final Root administrativeDivision = query.from(AdministrativeDivision.class); final Predicate[] restrictions = new Predicate[3]; - restrictions[0] = cut.equal(adminDiv.get("codeID"), "NUTS2"); - restrictions[1] = cut.equal(adminDiv.get("divisionCode"), "BE34"); - restrictions[2] = cut.equal(adminDiv.get("codePublisher"), "Eurostat"); + restrictions[0] = cut.equal(administrativeDivision.get("codeID"), "NUTS2"); + restrictions[1] = cut.equal(administrativeDivision.get("divisionCode"), "BE34"); + restrictions[2] = cut.equal(administrativeDivision.get("codePublisher"), "Eurostat"); final Predicate act = cut.and(restrictions); - assertEquals(exp, ((SqlConvertible) act).asSQL(stmt).toString()); + assertEquals(exp, ((SqlConvertible) act).asSQL(statement).toString()); } @Test @@ -414,20 +438,20 @@ void testCreateMultiAndThrowsExceptionOnWrongParameter() { final Predicate[] rEmpty = new Predicate[3]; assertThrows(IllegalArgumentException.class, () -> cut.and(rEmpty)); - final Root adminDiv = q.from(AdministrativeDivision.class); + final Root administrativeDivision = query.from(AdministrativeDivision.class); final Predicate[] rOneEntry = new Predicate[1]; - rOneEntry[0] = cut.equal(adminDiv.get("codeID"), "NUTS2"); + rOneEntry[0] = cut.equal(administrativeDivision.get("codeID"), "NUTS2"); assertThrows(IllegalArgumentException.class, () -> cut.and(rOneEntry)); } @Test void testCreateOneOr() { final String exp = "((E0.\"CodeID\" = ?1) OR (E0.\"CodeID\" = ?2))"; - final Root adminDiv = q.from(AdministrativeDivision.class); - final Predicate one = cut.equal(adminDiv.get("codeID"), "NUTS2"); - final Predicate two = cut.equal(adminDiv.get("codeID"), "NUTS3"); + final Root administrativeDivision = query.from(AdministrativeDivision.class); + final Predicate one = cut.equal(administrativeDivision.get("codeID"), "NUTS2"); + final Predicate two = cut.equal(administrativeDivision.get("codeID"), "NUTS3"); final Predicate act = cut.or(one, two); - assertEquals(exp, ((SqlConvertible) act).asSQL(stmt).toString()); + assertEquals(exp, ((SqlConvertible) act).asSQL(statement).toString()); } @Test @@ -438,38 +462,38 @@ void testCreateMultiOrThrowsExceptionOnWrongParameter() { final Predicate[] rEmpty = new Predicate[3]; assertThrows(IllegalArgumentException.class, () -> cut.or(rEmpty)); - final Root adminDiv = q.from(AdministrativeDivision.class); + final Root administrativeDivision = query.from(AdministrativeDivision.class); final Predicate[] rOneEntry = new Predicate[1]; - rOneEntry[0] = cut.equal(adminDiv.get("codeID"), "NUTS2"); + rOneEntry[0] = cut.equal(administrativeDivision.get("codeID"), "NUTS2"); assertThrows(IllegalArgumentException.class, () -> cut.and(rOneEntry)); } @Test void testCreateMultiOr() { final String exp = "(((E0.\"CodeID\" = ?1) OR (E0.\"DivisionCode\" = ?2)) OR (E0.\"CodePublisher\" = ?3))"; - final Root adminDiv = q.from(AdministrativeDivision.class); + final Root administrativeDivision = query.from(AdministrativeDivision.class); final Predicate[] restrictions = new Predicate[3]; - restrictions[0] = cut.equal(adminDiv.get("codeID"), "NUTS2"); - restrictions[1] = cut.equal(adminDiv.get("divisionCode"), "BE34"); - restrictions[2] = cut.equal(adminDiv.get("codePublisher"), "Eurostat"); + restrictions[0] = cut.equal(administrativeDivision.get("codeID"), "NUTS2"); + restrictions[1] = cut.equal(administrativeDivision.get("divisionCode"), "BE34"); + restrictions[2] = cut.equal(administrativeDivision.get("codePublisher"), "Eurostat"); final Predicate act = cut.or(restrictions); - assertEquals(exp, ((SqlConvertible) act).asSQL(stmt).toString()); + assertEquals(exp, ((SqlConvertible) act).asSQL(statement).toString()); } @Test void testCreateNot() { final String exp = "(NOT (E0.\"CodeID\" = ?1))"; - final Root adminDiv = q.from(AdministrativeDivision.class); - final Predicate one = cut.equal(adminDiv.get("codeID"), "NUTS2"); + final Root administrativeDivision = query.from(AdministrativeDivision.class); + final Predicate one = cut.equal(administrativeDivision.get("codeID"), "NUTS2"); final Predicate act = cut.not(one); - assertEquals(exp, ((SqlConvertible) act).asSQL(stmt).toString()); + assertEquals(exp, ((SqlConvertible) act).asSQL(statement).toString()); } @Test void testLiteralExpressionReturnsParameter() { final String exp = "?1"; final Expression act = cut.literal(LocalDate.now()); - assertEquals(exp, ((SqlConvertible) act).asSQL(stmt).toString()); + assertEquals(exp, ((SqlConvertible) act).asSQL(statement).toString()); assertNotNull(cut.getParameter()); assertEquals(1, cut.getParameter().getParameter().size()); } @@ -482,206 +506,206 @@ void testLiteralThrowsExceptionOnNullValue() { @Test void testCreateLikeExpressionWithString() { final String exp = "(E0.\"CodeID\" LIKE ?1)"; - final Root adminDiv = q.from(AdministrativeDivision.class); - final Predicate act = cut.like(adminDiv.get("codeID"), "6-1"); - assertEquals(exp, ((SqlConvertible) act).asSQL(stmt).toString()); + final Root administrativeDivision = query.from(AdministrativeDivision.class); + final Predicate act = cut.like(administrativeDivision.get("codeID"), "6-1"); + assertEquals(exp, ((SqlConvertible) act).asSQL(statement).toString()); } @Test void testCreateNotLikeExpressionWithString() { final String exp = "(NOT (E0.\"CodeID\" LIKE ?1))"; - final Root adminDiv = q.from(AdministrativeDivision.class); - final Predicate act = cut.notLike(adminDiv.get("codeID"), "6-1"); - assertEquals(exp, ((SqlConvertible) act).asSQL(stmt).toString()); + final Root administrativeDivision = query.from(AdministrativeDivision.class); + final Predicate act = cut.notLike(administrativeDivision.get("codeID"), "6-1"); + assertEquals(exp, ((SqlConvertible) act).asSQL(statement).toString()); } @Test void testCreateLikeExpressionWithStringAndEscape() { final String exp = "(E0.\"CodeID\" LIKE ?1 ESCAPE ?2)"; - final Root adminDiv = q.from(AdministrativeDivision.class); - final Predicate act = cut.like(adminDiv.get("codeID"), "%6-1", '/'); - assertEquals(exp, ((SqlConvertible) act).asSQL(stmt).toString()); + final Root administrativeDivision = query.from(AdministrativeDivision.class); + final Predicate act = cut.like(administrativeDivision.get("codeID"), "%6-1", '/'); + assertEquals(exp, ((SqlConvertible) act).asSQL(statement).toString()); } @Test void testCreateNotLikeExpressionWithStringAndEscape() { final String exp = "(NOT (E0.\"CodeID\" LIKE ?1 ESCAPE ?2))"; - final Root adminDiv = q.from(AdministrativeDivision.class); - final Predicate act = cut.notLike(adminDiv.get("codeID"), "%6-1", '/'); - assertEquals(exp, ((SqlConvertible) act).asSQL(stmt).toString()); + final Root administrativeDivision = query.from(AdministrativeDivision.class); + final Predicate act = cut.notLike(administrativeDivision.get("codeID"), "%6-1", '/'); + assertEquals(exp, ((SqlConvertible) act).asSQL(statement).toString()); } @Test void testCreateLikeExpressionWithLiteral() { final String exp = "(E0.\"CodeID\" LIKE ?1)"; final Expression literal = cut.literal("%6-1"); - final Root adminDiv = q.from(AdministrativeDivision.class); - final Predicate act = cut.like(adminDiv.get("codeID"), literal); - assertEquals(exp, ((SqlConvertible) act).asSQL(stmt).toString()); + final Root administrativeDivision = query.from(AdministrativeDivision.class); + final Predicate act = cut.like(administrativeDivision.get("codeID"), literal); + assertEquals(exp, ((SqlConvertible) act).asSQL(statement).toString()); } @Test void testCreateNotLikeExpressionWithLiteral() { final String exp = "(NOT (E0.\"CodeID\" LIKE ?1))"; final Expression literal = cut.literal("%6-1"); - final Root adminDiv = q.from(AdministrativeDivision.class); - final Predicate act = cut.notLike(adminDiv.get("codeID"), literal); - assertEquals(exp, ((SqlConvertible) act).asSQL(stmt).toString()); + final Root administrativeDivision = query.from(AdministrativeDivision.class); + final Predicate act = cut.notLike(administrativeDivision.get("codeID"), literal); + assertEquals(exp, ((SqlConvertible) act).asSQL(statement).toString()); } @Test void testCreateLikeExpressionWithLiteralLiteral() { final String exp = "(E0.\"CodeID\" LIKE ?1 ESCAPE ?2)"; - final Root adminDiv = q.from(AdministrativeDivision.class); + final Root administrativeDivision = query.from(AdministrativeDivision.class); final Expression p = cut.literal("6-1"); final Expression e = cut.literal('/'); - final Predicate act = cut.like(adminDiv.get("codeID"), p, e); - assertEquals(exp, ((SqlConvertible) act).asSQL(stmt).toString()); + final Predicate act = cut.like(administrativeDivision.get("codeID"), p, e); + assertEquals(exp, ((SqlConvertible) act).asSQL(statement).toString()); } @Test void testCreateNotLikeExpressionWithLiteralLiteral() { final String exp = "(NOT (E0.\"CodeID\" LIKE ?1 ESCAPE ?2))"; - final Root adminDiv = q.from(AdministrativeDivision.class); + final Root administrativeDivision = query.from(AdministrativeDivision.class); final Expression p = cut.literal("6-1"); final Expression e = cut.literal('/'); - final Predicate act = cut.notLike(adminDiv.get("codeID"), p, e); - assertEquals(exp, ((SqlConvertible) act).asSQL(stmt).toString()); + final Predicate act = cut.notLike(administrativeDivision.get("codeID"), p, e); + assertEquals(exp, ((SqlConvertible) act).asSQL(statement).toString()); } @Test void testCreateLikeExpressionWithLiteralString() { final String exp = "(E0.\"CodeID\" LIKE ?2 ESCAPE ?1)"; - final Root adminDiv = q.from(AdministrativeDivision.class); + final Root administrativeDivision = query.from(AdministrativeDivision.class); final Expression e = cut.literal('/'); - final Predicate act = cut.like(adminDiv.get("codeID"), "%6-1", e); - assertEquals(exp, ((SqlConvertible) act).asSQL(stmt).toString()); + final Predicate act = cut.like(administrativeDivision.get("codeID"), "%6-1", e); + assertEquals(exp, ((SqlConvertible) act).asSQL(statement).toString()); } @Test void testCreateNotLikeExpressionWithLiteralString() { final String exp = "(NOT (E0.\"CodeID\" LIKE ?2 ESCAPE ?1))"; - final Root adminDiv = q.from(AdministrativeDivision.class); + final Root administrativeDivision = query.from(AdministrativeDivision.class); final Expression e = cut.literal('/'); - final Predicate act = cut.notLike(adminDiv.get("codeID"), "%6-1", e); - assertEquals(exp, ((SqlConvertible) act).asSQL(stmt).toString()); + final Predicate act = cut.notLike(administrativeDivision.get("codeID"), "%6-1", e); + assertEquals(exp, ((SqlConvertible) act).asSQL(statement).toString()); } @Test void testCreateLikeExpressionWithStringLiteral() { final String exp = "(E0.\"CodeID\" LIKE ?1 ESCAPE ?2)"; - final Root adminDiv = q.from(AdministrativeDivision.class); + final Root administrativeDivision = query.from(AdministrativeDivision.class); final Expression p = cut.literal("6-1"); - final Predicate act = cut.like(adminDiv.get("codeID"), p, '/'); - assertEquals(exp, ((SqlConvertible) act).asSQL(stmt).toString()); + final Predicate act = cut.like(administrativeDivision.get("codeID"), p, '/'); + assertEquals(exp, ((SqlConvertible) act).asSQL(statement).toString()); } @Test void testCreateNotLikeExpressionWithStringLiteral() { final String exp = "(NOT (E0.\"CodeID\" LIKE ?1 ESCAPE ?2))"; - final Root adminDiv = q.from(AdministrativeDivision.class); + final Root administrativeDivision = query.from(AdministrativeDivision.class); final Expression p = cut.literal("6-1"); - final Predicate act = cut.notLike(adminDiv.get("codeID"), p, '/'); - assertEquals(exp, ((SqlConvertible) act).asSQL(stmt).toString()); + final Predicate act = cut.notLike(administrativeDivision.get("codeID"), p, '/'); + assertEquals(exp, ((SqlConvertible) act).asSQL(statement).toString()); } @Test void testCreateOrderByDescending() { final String exp = "E0.\"CodeID\" DESC"; - final Root adminDiv = q.from(AdministrativeDivision.class); - final Order act = cut.desc(adminDiv.get("codeID")); - assertEquals(exp, ((SqlConvertible) act).asSQL(stmt).toString()); + final Root administrativeDivision = query.from(AdministrativeDivision.class); + final Order act = cut.desc(administrativeDivision.get("codeID")); + assertEquals(exp, ((SqlConvertible) act).asSQL(statement).toString()); } @Test void testCreateOrderByAscending() { final String exp = "E0.\"CodeID\" ASC"; - final Root adminDiv = q.from(AdministrativeDivision.class); - final Order act = cut.asc(adminDiv.get("codeID")); - assertEquals(exp, ((SqlConvertible) act).asSQL(stmt).toString()); + final Root administrativeDivision = query.from(AdministrativeDivision.class); + final Order act = cut.asc(administrativeDivision.get("codeID")); + assertEquals(exp, ((SqlConvertible) act).asSQL(statement).toString()); } @Test void testCreateOrderByAscendingCount() { final String exp = "COUNT(E0.\"CodeID\") ASC"; - final Root adminDiv = q.from(AdministrativeDivision.class); - final Expression count = cut.count(adminDiv.get("codeID")); + final Root administrativeDivision = query.from(AdministrativeDivision.class); + final Expression count = cut.count(administrativeDivision.get("codeID")); final Order act = cut.asc(count); - assertEquals(exp, ((SqlConvertible) act).asSQL(stmt).toString()); + assertEquals(exp, ((SqlConvertible) act).asSQL(statement).toString()); } @Test void testCreateOrderByEntity() { final String exp = "E0.\"CodePublisher\" ASC, E0.\"CodeID\" ASC, E0.\"DivisionCode\" ASC"; - final Root adminDiv = q.from(AdministrativeDivision.class); - final Order act = cut.asc(adminDiv); - assertEquals(exp, ((SqlConvertible) act).asSQL(stmt).toString()); + final Root administrativeDivision = query.from(AdministrativeDivision.class); + final Order act = cut.asc(administrativeDivision); + assertEquals(exp, ((SqlConvertible) act).asSQL(statement).toString()); } @Test void testCreateIsNull() { final String exp = "(E0.\"ParentCodeID\" IS NULL)"; - final Root adminDiv = q.from(AdministrativeDivision.class); - final Expression act = cut.isNull(adminDiv.get("parentCodeID")); - assertEquals(exp, ((SqlConvertible) act).asSQL(stmt).toString()); + final Root administrativeDivision = query.from(AdministrativeDivision.class); + final Expression act = cut.isNull(administrativeDivision.get("parentCodeID")); + assertEquals(exp, ((SqlConvertible) act).asSQL(statement).toString()); } @Test void testCreateIsNotNull() { final String exp = "(E0.\"ParentCodeID\" IS NOT NULL)"; - final Root adminDiv = q.from(AdministrativeDivision.class); - final Expression act = cut.isNotNull(adminDiv.get("parentCodeID")); - assertEquals(exp, ((SqlConvertible) act).asSQL(stmt).toString()); + final Root administrativeDivision = query.from(AdministrativeDivision.class); + final Expression act = cut.isNotNull(administrativeDivision.get("parentCodeID")); + assertEquals(exp, ((SqlConvertible) act).asSQL(statement).toString()); } @Test void testCreateLocateExpressionWithStringNull() { final String exp = "LOCATE(?1, E0.\"DivisionCode\")"; - final Root adminDiv = q.from(AdministrativeDivision.class); - final Expression act = cut.locate(adminDiv.get("divisionCode"), "3"); - assertEquals(exp, ((SqlConvertible) act).asSQL(stmt).toString()); + final Root administrativeDivision = query.from(AdministrativeDivision.class); + final Expression act = cut.locate(administrativeDivision.get("divisionCode"), "3"); + assertEquals(exp, ((SqlConvertible) act).asSQL(statement).toString()); } @Test void testCreateLocateExpressionWithLiteralNull() { final String exp = "LOCATE(?1, E0.\"DivisionCode\")"; final Expression literal = cut.literal("3"); - final Root adminDiv = q.from(AdministrativeDivision.class); - final Expression act = cut.locate(adminDiv.get("divisionCode"), literal); - assertEquals(exp, ((SqlConvertible) act).asSQL(stmt).toString()); + final Root administrativeDivision = query.from(AdministrativeDivision.class); + final Expression act = cut.locate(administrativeDivision.get("divisionCode"), literal); + assertEquals(exp, ((SqlConvertible) act).asSQL(statement).toString()); } @Test void testCreateLocateExpressionWithLiteralLiteral() { final String exp = "LOCATE(?1, E0.\"DivisionCode\", ?2)"; final Expression literal = cut.literal("3"); - final Root adminDiv = q.from(AdministrativeDivision.class); - final Expression act = cut.locate(adminDiv.get("divisionCode"), literal, cut.literal(2)); - assertEquals(exp, ((SqlConvertible) act).asSQL(stmt).toString()); + final Root administrativeDivision = query.from(AdministrativeDivision.class); + final Expression act = cut.locate(administrativeDivision.get("divisionCode"), literal, cut.literal(2)); + assertEquals(exp, ((SqlConvertible) act).asSQL(statement).toString()); } @Test void testCreateLocateExpressionWithStringInt() { final String exp = "LOCATE(?1, E0.\"DivisionCode\", ?2)"; - final Root adminDiv = q.from(AdministrativeDivision.class); - final Expression act = cut.locate(adminDiv.get("divisionCode"), "3", 2); - assertEquals(exp, ((SqlConvertible) act).asSQL(stmt).toString()); + final Root administrativeDivision = query.from(AdministrativeDivision.class); + final Expression act = cut.locate(administrativeDivision.get("divisionCode"), "3", 2); + assertEquals(exp, ((SqlConvertible) act).asSQL(statement).toString()); } @Test void testCreateSubstringExpressionWithIntInt() { final String exp = "SUBSTRING(E0.\"Name\", ?1, ?2)"; - final Root adminDiv = q.from(AdministrativeDivisionDescription.class); - final Expression act = cut.substring(adminDiv.get("name"), 1, 5); - assertEquals(exp, ((SqlConvertible) act).asSQL(stmt).toString()); + final Root administrativeDivision = query.from(AdministrativeDivisionDescription.class); + final Expression act = cut.substring(administrativeDivision.get("name"), 1, 5); + assertEquals(exp, ((SqlConvertible) act).asSQL(statement).toString()); } @Test void testCreateSubstringExpressionWithInt() { final String exp = "SUBSTRING(E0.\"Name\", ?1)"; - final Root adminDiv = q.from(AdministrativeDivisionDescription.class); - final Expression act = cut.substring(adminDiv.get("name"), 1); - assertEquals(exp, ((SqlConvertible) act).asSQL(stmt).toString()); + final Root administrativeDivision = query.from(AdministrativeDivisionDescription.class); + final Expression act = cut.substring(administrativeDivision.get("name"), 1); + assertEquals(exp, ((SqlConvertible) act).asSQL(statement).toString()); } @Test @@ -689,26 +713,27 @@ void testCreateSubstringExpressionWithLiteralLiteral() { final String exp = "SUBSTRING(E0.\"Name\", ?1, ?2)"; final Expression from = cut.literal(1); final Expression len = cut.literal(5); - final Root adminDiv = q.from(AdministrativeDivisionDescription.class); - final Expression act = cut.substring(adminDiv.get("name"), from, len); - assertEquals(exp, ((SqlConvertible) act).asSQL(stmt).toString()); + final Root administrativeDivision = query.from(AdministrativeDivisionDescription.class); + final Expression act = cut.substring(administrativeDivision.get("name"), from, len); + assertEquals(exp, ((SqlConvertible) act).asSQL(statement).toString()); } @Test void testCreateSubstringExpressionWithLiteral() { final String exp = "SUBSTRING(E0.\"Name\", ?1)"; final Expression literal = cut.literal(1); - final Root adminDiv = q.from(AdministrativeDivisionDescription.class); - final Expression act = cut.substring(adminDiv.get("name"), literal); - assertEquals(exp, ((SqlConvertible) act).asSQL(stmt).toString()); + final Root administrativeDivision = query.from(AdministrativeDivisionDescription.class); + final Expression act = cut.substring(administrativeDivision.get("name"), literal); + assertEquals(exp, ((SqlConvertible) act).asSQL(statement).toString()); } @Test void testCreateCoalesceExpressionWithExpressionExpression() { final String exp = "COALESCE(E0.\"Area\", E0.\"ParentCodeID\")"; - final Root adminDiv = q.from(AdministrativeDivision.class); - final Expression act = cut.coalesce(adminDiv.get("area"), adminDiv.get("parentCodeID")); - assertEquals(exp, ((SqlConvertible) act).asSQL(stmt).toString()); + final Root administrativeDivision = query.from(AdministrativeDivision.class); + final Expression act = cut.coalesce(administrativeDivision.get("area"), administrativeDivision.get( + "parentCodeID")); + assertEquals(exp, ((SqlConvertible) act).asSQL(statement).toString()); } @Test @@ -720,28 +745,28 @@ void testCreateCoalesceExpression() { @Test void testCreateCoalesceExpressionWithExpressionValue() { final String exp = "COALESCE(E0.\"Area\", ?1)"; - final Root adminDiv = q.from(AdministrativeDivision.class); - final Expression act = cut.coalesce(adminDiv.get("area"), 10); - assertEquals(exp, ((SqlConvertible) act).asSQL(stmt).toString()); + final Root administrativeDivision = query.from(AdministrativeDivision.class); + final Expression act = cut.coalesce(administrativeDivision.get("area"), 10); + assertEquals(exp, ((SqlConvertible) act).asSQL(statement).toString()); } @Test void testCreateCountDistinctExpression() { final String exp = "COUNT(DISTINCT(E0.\"CodeID\"))"; - final Root adminDiv = q.from(AdministrativeDivision.class); - final Expression act = cut.countDistinct(adminDiv.get("codeID")); - assertEquals(exp, ((SqlConvertible) act).asSQL(stmt).toString()); + final Root administrativeDivision = query.from(AdministrativeDivision.class); + final Expression act = cut.countDistinct(administrativeDivision.get("codeID")); + assertEquals(exp, ((SqlConvertible) act).asSQL(statement).toString()); } @Test void testCreateFunctionExpression() { // return cb.function(jpaFunction.getDBName(), jpaFunction.getResultParameter().getType(), jpaParameter); final String exp = "\"OLINGO\".\"PopulationDensity\"(E0.\"Area\", E0.\"Population\")"; - final Root adminDiv = q.from(AdministrativeDivision.class); + final Root administrativeDivision = query.from(AdministrativeDivision.class); final Expression act = cut.function("\"OLINGO\".\"PopulationDensity\"", Double.class, - adminDiv.get("area"), adminDiv.get("population")); - assertEquals(exp, ((SqlConvertible) act).asSQL(stmt).toString()); + administrativeDivision.get("area"), administrativeDivision.get("population")); + assertEquals(exp, ((SqlConvertible) act).asSQL(statement).toString()); assertEquals(Double.class, act.getJavaType()); } @@ -749,10 +774,10 @@ void testCreateFunctionExpression() { void testCreateEqualWithValueAndConverter() { // return cb.function(jpaFunction.getDBName(), jpaFunction.getResultParameter().getType(), jpaParameter); final String exp = "(E0.\"AccessRights\" = ?1)"; - final Root person = q.from(Person.class); + final Root person = query.from(Person.class); final AccessRights[] rights = { AccessRights.READ, AccessRights.DELETE }; final Expression act = cut.equal(person.get("accessRights"), rights); - assertEquals(exp, ((SqlConvertible) act).asSQL(stmt).toString()); + assertEquals(exp, ((SqlConvertible) act).asSQL(statement).toString()); for (final ParameterExpression parameter : cut.getParameter().getParameter().values()) { if (parameter.getPosition() == 1) assertEquals((short) 9, parameter.getValue()); @@ -764,10 +789,10 @@ void testCreateEqualWithLiteralAndConverter() { // return cb.function(jpaFunction.getDBName(), jpaFunction.getResultParameter().getType(), jpaParameter); // AccessRights[] accessRights final String exp = "(E0.\"AccessRights\" = ?1)"; - final Root person = q.from(Person.class); + final Root person = query.from(Person.class); final AccessRights[] rights = { AccessRights.READ, AccessRights.DELETE }; final Expression act = cut.equal(person.get("accessRights"), cut.literal(rights)); - assertEquals(exp, ((SqlConvertible) act).asSQL(stmt).toString()); + assertEquals(exp, ((SqlConvertible) act).asSQL(statement).toString()); for (final ParameterExpression parameter : cut.getParameter().getParameter().values()) { if (parameter.getPosition() == 1) assertEquals((short) 9, parameter.getValue()); @@ -777,67 +802,98 @@ void testCreateEqualWithLiteralAndConverter() { @Test void testCreateBetweenObject() { final String exp = "(E0.\"BusinessPartnerRole\" BETWEEN ?1 AND ?2)"; - final Root roles = q.from(BusinessPartnerRole.class); + final Root roles = query.from(BusinessPartnerRole.class); final Expression act = cut.between(roles.get("roleCategory"), "A", "B"); - assertEquals(exp, ((SqlConvertible) act).asSQL(stmt).toString()); + assertEquals(exp, ((SqlConvertible) act).asSQL(statement).toString()); } @Test void testCreateBetweenExpression() { final String exp = "(E0.\"BusinessPartnerRole\" BETWEEN ?1 AND ?2)"; - final Root roles = q.from(BusinessPartnerRole.class); + final Root roles = query.from(BusinessPartnerRole.class); final Expression low = cut.literal("A"); final Expression high = cut.literal("B"); final Expression act = cut.between(roles.get("roleCategory"), low, high); - assertEquals(exp, ((SqlConvertible) act).asSQL(stmt).toString()); + assertEquals(exp, ((SqlConvertible) act).asSQL(statement).toString()); } @Test void testCreateRowNumber() { final String exp = "ROW_NUMBER() OVER()"; final Selection act = cut.rowNumber(); - assertEquals(exp, ((SqlConvertible) act).asSQL(stmt).toString()); + assertEquals(exp, ((SqlConvertible) act).asSQL(statement).toString()); } @Test void testCreateRowNumberWithAlice() { final String exp = "ROW_NUMBER() OVER()"; final Selection act = cut.rowNumber().alias("\"A\""); - assertEquals(exp, ((SqlConvertible) act).asSQL(stmt).toString()); + assertEquals(exp, ((SqlConvertible) act).asSQL(statement).toString()); } @Test void testCreateRowNumberWithOrderBy() { final String exp = "ROW_NUMBER() OVER( ORDER BY E0.\"CodeID\" ASC)"; - final Root adminDiv = q.from(AdministrativeDivision.class); - final Selection act = cut.rowNumber().orderBy(cut.asc(adminDiv.get("codeID"))); - assertEquals(exp, ((SqlConvertible) act).asSQL(stmt).toString()); + final Root administrativeDivision = query.from(AdministrativeDivision.class); + final Selection act = cut.rowNumber().orderBy(cut.asc(administrativeDivision.get("codeID"))); + assertEquals(exp, ((SqlConvertible) act).asSQL(statement).toString()); } @Test void testCreateRowNumberWithOrderByPrimaryKey() { final String exp = "ROW_NUMBER() OVER( ORDER BY E0.\"CodePublisher\" ASC, E0.\"CodeID\" ASC, E0.\"DivisionCode\" ASC)"; - final Root adminDiv = q.from(AdministrativeDivision.class); - final Selection act = cut.rowNumber().orderBy(cut.asc(adminDiv)); - assertEquals(exp, ((SqlConvertible) act).asSQL(stmt).toString()); + final Root administrativeDivision = query.from(AdministrativeDivision.class); + final Selection act = cut.rowNumber().orderBy(cut.asc(administrativeDivision)); + assertEquals(exp, ((SqlConvertible) act).asSQL(statement).toString()); } @Test void testCreateRowNumberWithPartitionBy() { final String exp = "ROW_NUMBER() OVER( PARTITION BY E0.\"CodeID\")"; - final Root adminDiv = q.from(AdministrativeDivision.class); - final Selection act = cut.rowNumber().partitionBy(adminDiv.get("codeID")); - assertEquals(exp, ((SqlConvertible) act).asSQL(stmt).toString()); + final Root administrativeDivision = query.from(AdministrativeDivision.class); + final Selection act = cut.rowNumber().partitionBy(administrativeDivision.get("codeID")); + assertEquals(exp, ((SqlConvertible) act).asSQL(statement).toString()); } @Test void testCreateRowNumberWithPartitionAndOrder() { final String exp = "ROW_NUMBER() OVER( PARTITION BY E0.\"CodeID\" ORDER BY E0.\"CodeID\" ASC)"; - final Root adminDiv = q.from(AdministrativeDivision.class); + final Root administrativeDivision = query.from(AdministrativeDivision.class); final Selection act = cut.rowNumber() - .partitionBy(adminDiv.get("codeID")) - .orderBy(cut.asc(adminDiv.get("codeID"))); - assertEquals(exp, ((SqlConvertible) act).asSQL(stmt).toString()); + .partitionBy(administrativeDivision.get("codeID")) + .orderBy(cut.asc(administrativeDivision.get("codeID"))); + assertEquals(exp, ((SqlConvertible) act).asSQL(statement).toString()); + } + + @Test + void testCreateConcatExpression() { + final String stringA = "A"; + final String stringB = "B"; + + final Expression literalA = cut.literal(stringA); + final Expression literalB = cut.literal(stringB); + + assertConcatExpression(stringA, stringB, cut.concat(literalA, literalB)); + assertConcatExpression(stringA, stringB, cut.concat(stringA, literalB)); + assertConcatExpression(stringA, stringB, cut.concat(literalA, stringB)); + } + + void assertConcatExpression(final String stringA, final String stringB, final Expression act) { + final StringBuilder builder = new StringBuilder(); + assertTrue(act instanceof ConcatExpression); + assertEquals("CONCAT(?1, ?2)", ((ExpressionImpl) act).asSQL(builder).toString()); + final Map> actMap = cut.getParameter().getParameter(); + assertEquals(2, actMap.size()); + boolean aFound = false; + boolean bFound = false; + for (final ParameterExpression parameter : actMap.values()) { + if (stringA.equals(parameter.getValue())) + aFound = true; + if (stringB.equals(parameter.getValue())) + bFound = true; + } + assertTrue(aFound); + assertTrue(bFound); } } diff --git a/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/CriteriaBuilderOverallTest.java b/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/CriteriaBuilderOverallTest.java index 382123890..352f79ef8 100644 --- a/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/CriteriaBuilderOverallTest.java +++ b/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/CriteriaBuilderOverallTest.java @@ -9,16 +9,16 @@ import java.time.LocalDateTime; import java.util.List; -import javax.persistence.EntityManager; -import javax.persistence.EntityManagerFactory; -import javax.persistence.Tuple; -import javax.persistence.TypedQuery; -import javax.persistence.criteria.CriteriaQuery; -import javax.persistence.criteria.Expression; -import javax.persistence.criteria.Join; -import javax.persistence.criteria.Path; -import javax.persistence.criteria.Predicate; -import javax.persistence.criteria.Root; +import jakarta.persistence.EntityManager; +import jakarta.persistence.EntityManagerFactory; +import jakarta.persistence.Tuple; +import jakarta.persistence.TypedQuery; +import jakarta.persistence.criteria.CriteriaQuery; +import jakarta.persistence.criteria.Expression; +import jakarta.persistence.criteria.Join; +import jakarta.persistence.criteria.Path; +import jakarta.persistence.criteria.Predicate; +import jakarta.persistence.criteria.Root; import org.junit.jupiter.api.Test; diff --git a/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/CriteriaQueryImplTest.java b/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/CriteriaQueryImplTest.java index e6d948a12..852bfe24d 100644 --- a/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/CriteriaQueryImplTest.java +++ b/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/CriteriaQueryImplTest.java @@ -12,12 +12,12 @@ import java.util.Map.Entry; import java.util.stream.Stream; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.CriteriaQuery; -import javax.persistence.criteria.Expression; -import javax.persistence.criteria.Order; -import javax.persistence.criteria.Root; -import javax.persistence.criteria.Selection; +import jakarta.persistence.criteria.CriteriaBuilder; +import jakarta.persistence.criteria.CriteriaQuery; +import jakarta.persistence.criteria.Expression; +import jakarta.persistence.criteria.Order; +import jakarta.persistence.criteria.Root; +import jakarta.persistence.criteria.Selection; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -110,29 +110,29 @@ void testResetOrderByWithList() { @Test void testWithBaseClass() { - final StringBuilder stmt = new StringBuilder(); + final StringBuilder statement = new StringBuilder(); final Root act = cut.from(Organization.class); cut.multiselect(act.get("iD")); assertEquals("SELECT E0.\"ID\" S0 FROM \"OLINGO\".\"BusinessPartner\" E0 WHERE (E0.\"Type\" = ?1)", - cut.asSQL(stmt).toString()); + cut.asSQL(statement).toString()); } @Test void testGroupBy() { - final StringBuilder stmt = new StringBuilder(); + final StringBuilder statement = new StringBuilder(); final Root act = cut.from(Organization.class); cut.groupBy(act.get("aBCClass"), act.get("name2")); cut.multiselect(act.get("aBCClass"), act.get("name2")); assertEquals( "SELECT E0.\"ABCClass\" S0, E0.\"NameLine2\" S1 FROM \"OLINGO\".\"BusinessPartner\" E0 " + "WHERE (E0.\"Type\" = ?1) GROUP BY E0.\"ABCClass\", E0.\"NameLine2\"", - cut.asSQL(stmt).toString()); + cut.asSQL(statement).toString()); } @Test void testReplaceGroupByEmpty() { final Expression[] nullArray = null; - final StringBuilder stmt = new StringBuilder(); + final StringBuilder statement = new StringBuilder(); final Root act = cut.from(Organization.class); cut.groupBy(act.get("aBCClass"), act.get("name2")); cut.multiselect(act.get("aBCClass"), act.get("name2")); @@ -140,12 +140,12 @@ void testReplaceGroupByEmpty() { assertEquals( "SELECT E0.\"ABCClass\" S0, E0.\"NameLine2\" S1 FROM \"OLINGO\".\"BusinessPartner\" E0 " + "WHERE (E0.\"Type\" = ?1)", - cut.asSQL(stmt).toString()); + cut.asSQL(statement).toString()); } @Test void testHaving() { - final StringBuilder stmt = new StringBuilder(); + final StringBuilder statement = new StringBuilder(); final Root act = cut.from(Organization.class); cut.having(cb.gt(cb.count(act.get("iD")), 1)); cut.groupBy(act.get("name2")); @@ -155,15 +155,15 @@ void testHaving() { + "WHERE (E0.\"Type\" = ?2) " + "GROUP BY E0.\"NameLine2\" " + "HAVING (COUNT(E0.\"ID\") > ?1)", - cut.asSQL(stmt).toString()); + cut.asSQL(statement).toString()); } @Test void testDefaultImplementationOnPathWrapper() { final Root act = cut.from(Organization.class); cut.multiselect(act.get("aBCClass"), act.get("name2")); - final Selection sel = cut.getSelection(); - final List> resolvedSelections = ((ProcessorSelection) sel).getResolvedSelection(); + final Selection selection = cut.getSelection(); + final List> resolvedSelections = ((ProcessorSelection) selection).getResolvedSelection(); assertNotNull(resolvedSelections.get(0).getValue()); } diff --git a/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/EntityManagerWrapperTest.java b/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/EntityManagerWrapperTest.java index 4b03d4f6a..026437997 100644 --- a/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/EntityManagerWrapperTest.java +++ b/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/EntityManagerWrapperTest.java @@ -6,6 +6,7 @@ import static org.junit.jupiter.params.provider.Arguments.arguments; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.clearInvocations; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -18,18 +19,18 @@ import java.util.Map; import java.util.stream.Stream; -import javax.persistence.EntityGraph; -import javax.persistence.EntityManager; -import javax.persistence.EntityManagerFactory; -import javax.persistence.EntityTransaction; -import javax.persistence.FlushModeType; -import javax.persistence.LockModeType; -import javax.persistence.Query; -import javax.persistence.StoredProcedureQuery; -import javax.persistence.TypedQuery; -import javax.persistence.criteria.CriteriaDelete; -import javax.persistence.criteria.CriteriaUpdate; -import javax.persistence.metamodel.Metamodel; +import jakarta.persistence.EntityGraph; +import jakarta.persistence.EntityManager; +import jakarta.persistence.EntityManagerFactory; +import jakarta.persistence.EntityTransaction; +import jakarta.persistence.FlushModeType; +import jakarta.persistence.LockModeType; +import jakarta.persistence.Query; +import jakarta.persistence.StoredProcedureQuery; +import jakarta.persistence.TypedQuery; +import jakarta.persistence.criteria.CriteriaDelete; +import jakarta.persistence.criteria.CriteriaUpdate; +import jakarta.persistence.metamodel.Metamodel; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; @@ -204,10 +205,10 @@ static Stream notImplementedMethod() throws NoSuchMethodException, Se @ParameterizedTest @MethodSource("parameterFreeMethod") void testOriginalIsCalledNoParameter(final Method m, final Object r) throws IllegalAccessException, - IllegalArgumentException, - InvocationTargetException { + IllegalArgumentException, InvocationTargetException { if (m.getParameterCount() == 0) { + clearInvocations(em); final Object response = m.invoke(cut); final EntityManager v = verify(em); m.invoke(v); diff --git a/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/ExpressionImplTest.java b/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/ExpressionImplTest.java index de0b7c217..a307bb738 100644 --- a/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/ExpressionImplTest.java +++ b/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/ExpressionImplTest.java @@ -16,8 +16,8 @@ import java.util.List; import java.util.stream.Stream; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.Expression; +import jakarta.persistence.criteria.CriteriaBuilder; +import jakarta.persistence.criteria.Expression; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; diff --git a/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/ExpressionPathTest.java b/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/ExpressionPathTest.java index 91b9a9e4e..e0c7a77d7 100644 --- a/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/ExpressionPathTest.java +++ b/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/ExpressionPathTest.java @@ -8,9 +8,9 @@ import java.util.Optional; import java.util.stream.Stream; -import javax.persistence.metamodel.MapAttribute; -import javax.persistence.metamodel.PluralAttribute; -import javax.persistence.metamodel.SingularAttribute; +import jakarta.persistence.metamodel.MapAttribute; +import jakarta.persistence.metamodel.PluralAttribute; +import jakarta.persistence.metamodel.SingularAttribute; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; diff --git a/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/FromImplTest.java b/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/FromImplTest.java index b3c6a711a..a7c8d3d2d 100644 --- a/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/FromImplTest.java +++ b/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/FromImplTest.java @@ -14,18 +14,18 @@ import java.util.List; import java.util.stream.Stream; -import javax.persistence.InheritanceType; -import javax.persistence.criteria.Expression; -import javax.persistence.criteria.From; -import javax.persistence.criteria.Join; -import javax.persistence.criteria.JoinType; -import javax.persistence.criteria.Path; -import javax.persistence.metamodel.CollectionAttribute; -import javax.persistence.metamodel.ListAttribute; -import javax.persistence.metamodel.MapAttribute; -import javax.persistence.metamodel.PluralAttribute; -import javax.persistence.metamodel.SetAttribute; -import javax.persistence.metamodel.SingularAttribute; +import jakarta.persistence.InheritanceType; +import jakarta.persistence.criteria.Expression; +import jakarta.persistence.criteria.From; +import jakarta.persistence.criteria.Join; +import jakarta.persistence.criteria.JoinType; +import jakarta.persistence.criteria.Path; +import jakarta.persistence.metamodel.CollectionAttribute; +import jakarta.persistence.metamodel.ListAttribute; +import jakarta.persistence.metamodel.MapAttribute; +import jakarta.persistence.metamodel.PluralAttribute; +import jakarta.persistence.metamodel.SetAttribute; +import jakarta.persistence.metamodel.SingularAttribute; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -277,4 +277,9 @@ void testAsRethrowsModelException() throws ODataJPAModelException { void testJoinThrowsExceptionOnUnknownAttribute() { assertThrows(IllegalArgumentException.class, () -> cut.join("dummy")); } + + @Test + void testGetFetchesReturnsEmpty() { + assertEquals(0, cut.getFetches().size()); + } } diff --git a/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/InheritanceInfoTest.java b/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/InheritanceInfoTest.java index bea65d680..6c926eebf 100644 --- a/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/InheritanceInfoTest.java +++ b/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/InheritanceInfoTest.java @@ -6,7 +6,7 @@ import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; -import javax.persistence.InheritanceType; +import jakarta.persistence.InheritanceType; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; diff --git a/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/JPAAttributeWrapperTest.java b/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/JPAAttributeWrapperTest.java index fbd29b3c2..263887d83 100644 --- a/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/JPAAttributeWrapperTest.java +++ b/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/JPAAttributeWrapperTest.java @@ -13,7 +13,7 @@ import java.util.Collection; import java.util.stream.Stream; -import javax.persistence.criteria.Selection; +import jakarta.persistence.criteria.Selection; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; diff --git a/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/JPAPathWrapperTest.java b/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/JPAPathWrapperTest.java index 3c69707a1..ef1aa20e1 100644 --- a/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/JPAPathWrapperTest.java +++ b/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/JPAPathWrapperTest.java @@ -14,7 +14,7 @@ import java.util.List; import java.util.stream.Stream; -import javax.persistence.criteria.Selection; +import jakarta.persistence.criteria.Selection; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; diff --git a/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/JoinTableJoinTest.java b/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/JoinTableJoinTest.java index 007e1667f..349d97c5a 100644 --- a/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/JoinTableJoinTest.java +++ b/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/JoinTableJoinTest.java @@ -7,8 +7,8 @@ import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; -import javax.persistence.Tuple; -import javax.persistence.criteria.JoinType; +import jakarta.persistence.Tuple; +import jakarta.persistence.criteria.JoinType; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; diff --git a/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/OrderImplTest.java b/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/OrderImplTest.java index 71b24f708..70f03c041 100644 --- a/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/OrderImplTest.java +++ b/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/OrderImplTest.java @@ -7,8 +7,8 @@ import static org.mockito.Mockito.when; import static org.mockito.Mockito.withSettings; -import javax.persistence.criteria.Expression; -import javax.persistence.criteria.Order; +import jakarta.persistence.criteria.Expression; +import jakarta.persistence.criteria.Order; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; diff --git a/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/ParameterExpressionImplTest.java b/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/ParameterExpressionImplTest.java index 2c91cccf9..5b7dd2082 100644 --- a/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/ParameterExpressionImplTest.java +++ b/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/ParameterExpressionImplTest.java @@ -11,8 +11,8 @@ import java.util.Optional; import java.util.stream.Stream; -import javax.persistence.AttributeConverter; -import javax.persistence.criteria.Expression; +import jakarta.persistence.AttributeConverter; +import jakarta.persistence.criteria.Expression; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DynamicTest; diff --git a/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/PathImplTest.java b/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/PathImplTest.java index b16a62ee2..6d1f8eab1 100644 --- a/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/PathImplTest.java +++ b/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/PathImplTest.java @@ -14,12 +14,12 @@ import java.util.Optional; import java.util.stream.Stream; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.From; -import javax.persistence.criteria.Path; -import javax.persistence.metamodel.MapAttribute; -import javax.persistence.metamodel.PluralAttribute; -import javax.persistence.metamodel.SingularAttribute; +import jakarta.persistence.criteria.CriteriaBuilder; +import jakarta.persistence.criteria.From; +import jakarta.persistence.criteria.Path; +import jakarta.persistence.metamodel.MapAttribute; +import jakarta.persistence.metamodel.PluralAttribute; +import jakarta.persistence.metamodel.SingularAttribute; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; diff --git a/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/PrerdicateImplTest.java b/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/PrerdicateImplTest.java index e35a4bcac..e4a164ad8 100644 --- a/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/PrerdicateImplTest.java +++ b/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/PrerdicateImplTest.java @@ -18,15 +18,15 @@ import java.util.List; import java.util.stream.Stream; -import javax.persistence.Tuple; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.CriteriaBuilder.In; -import javax.persistence.criteria.CriteriaQuery; -import javax.persistence.criteria.Expression; -import javax.persistence.criteria.Path; -import javax.persistence.criteria.Predicate; -import javax.persistence.criteria.Root; -import javax.persistence.criteria.Subquery; +import jakarta.persistence.Tuple; +import jakarta.persistence.criteria.CriteriaBuilder; +import jakarta.persistence.criteria.CriteriaBuilder.In; +import jakarta.persistence.criteria.CriteriaQuery; +import jakarta.persistence.criteria.Expression; +import jakarta.persistence.criteria.Path; +import jakarta.persistence.criteria.Predicate; +import jakarta.persistence.criteria.Root; +import jakarta.persistence.criteria.Subquery; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; diff --git a/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/SimpleJoinTest.java b/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/SimpleJoinTest.java index b60875d6b..6bfb86b50 100644 --- a/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/SimpleJoinTest.java +++ b/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/SimpleJoinTest.java @@ -11,8 +11,8 @@ import java.util.Arrays; -import javax.persistence.Tuple; -import javax.persistence.criteria.JoinType; +import jakarta.persistence.Tuple; +import jakarta.persistence.criteria.JoinType; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; diff --git a/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/SqlJoinTypeTest.java b/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/SqlJoinTypeTest.java index 9629647c2..e50a619d4 100644 --- a/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/SqlJoinTypeTest.java +++ b/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/SqlJoinTypeTest.java @@ -2,7 +2,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; -import javax.persistence.criteria.JoinType; +import jakarta.persistence.criteria.JoinType; import org.junit.jupiter.api.Test; diff --git a/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/SubqueryImplTest.java b/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/SubqueryImplTest.java index 120395ab9..f3ac6bb8f 100644 --- a/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/SubqueryImplTest.java +++ b/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/SubqueryImplTest.java @@ -16,18 +16,18 @@ import java.util.List; import java.util.stream.Stream; -import javax.persistence.criteria.CollectionJoin; -import javax.persistence.criteria.CompoundSelection; -import javax.persistence.criteria.Expression; -import javax.persistence.criteria.Join; -import javax.persistence.criteria.ListJoin; -import javax.persistence.criteria.MapJoin; -import javax.persistence.criteria.Order; -import javax.persistence.criteria.Predicate; -import javax.persistence.criteria.Root; -import javax.persistence.criteria.Selection; -import javax.persistence.criteria.SetJoin; -import javax.persistence.metamodel.EntityType; +import jakarta.persistence.criteria.CollectionJoin; +import jakarta.persistence.criteria.CompoundSelection; +import jakarta.persistence.criteria.Expression; +import jakarta.persistence.criteria.Join; +import jakarta.persistence.criteria.ListJoin; +import jakarta.persistence.criteria.MapJoin; +import jakarta.persistence.criteria.Order; +import jakarta.persistence.criteria.Predicate; +import jakarta.persistence.criteria.Root; +import jakarta.persistence.criteria.Selection; +import jakarta.persistence.criteria.SetJoin; +import jakarta.persistence.metamodel.EntityType; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -76,16 +76,16 @@ static Stream returnsSelf() throws NoSuchMethodException, SecurityExc return Stream.of( arguments(c.getMethod("select", Expression.class), mock(Expression.class)), arguments(c.getMethod("where", Expression.class), mock(Expression.class)), - arguments(c.getMethod("groupBy", List.class), new ArrayList()), + arguments(c.getMethod("groupBy", List.class), new ArrayList<>()), arguments(c.getMethod("groupBy", Expression[].class), new Predicate[] {}), arguments(c.getMethod("having", Expression.class), mock(Predicate.class)), arguments(c.getMethod("having", Predicate[].class), new Predicate[] {}), arguments(c.getMethod("distinct", boolean.class), true), arguments(c.getMethod("setMaxResults", Integer.class), Integer.valueOf(10)), arguments(c.getMethod("setFirstResult", Integer.class), Integer.valueOf(10)), - arguments(c.getMethod("multiselect", List.class), new ArrayList()), + arguments(c.getMethod("multiselect", List.class), new ArrayList<>()), arguments(c.getMethod("multiselect", Selection[].class), new Selection[] {}), - arguments(c.getMethod("orderBy", List.class), new ArrayList()), + arguments(c.getMethod("orderBy", List.class), new ArrayList<>()), arguments(c.getMethod("orderBy", Order[].class), new Order[] {})); } @@ -101,16 +101,17 @@ void setup() { @ParameterizedTest @MethodSource("notImplemented") - void testThrowsNotImplemented(final Method m) throws IllegalAccessException { + void testThrowsNotImplemented(final Method method) throws IllegalAccessException { - testNotImplemented(m, cut); + testNotImplemented(method, cut); } @ParameterizedTest @MethodSource("returnsSelf") - void testReturnsSelf(final Method m, final Object param) throws IllegalAccessException, InvocationTargetException { + void testReturnsSelf(final Method method, final Object param) throws IllegalAccessException, + InvocationTargetException { - assertEquals(cut, invokeMethod(m, cut, param)); + assertEquals(cut, invokeMethod(method, cut, param)); } @Test diff --git a/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/SubqueryRootImplTest.java b/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/SubqueryRootImplTest.java new file mode 100644 index 000000000..2f732d5db --- /dev/null +++ b/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/SubqueryRootImplTest.java @@ -0,0 +1,55 @@ +package com.sap.olingo.jpa.processor.cb.impl; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.mockito.Mockito.mock; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAServiceDocument; +import com.sap.olingo.jpa.metadata.core.edm.mapper.exception.ODataJPAModelException; +import com.sap.olingo.jpa.processor.cb.ProcessorSubquery; +import com.sap.olingo.jpa.processor.cb.exceptions.NotImplementedException; + +class SubqueryRootImplTest { + private SubqueryRootImpl cut; + + private ProcessorSubquery processor; + private JPAServiceDocument sd; + private AliasBuilder aliasBuilder; + + @BeforeEach + void setup() throws ODataJPAModelException { + processor = mock(ProcessorSubquery.class); + sd = mock(JPAServiceDocument.class); + aliasBuilder = new AliasBuilder(); + cut = new SubqueryRootImpl<>(processor, aliasBuilder, sd); + } + + @Test + void testHashCode() throws ODataJPAModelException { + assertNotEquals(31, cut.hashCode()); + } + + @Test + void testGetModelThrowsException() { + assertThrows(NotImplementedException.class, () -> cut.getModel()); + } + + @Test + void testEquals() throws ODataJPAModelException { + final ProcessorSubquery otherQuery = mock(ProcessorSubquery.class); + final SubqueryRootImpl other = new SubqueryRootImpl<>(otherQuery, aliasBuilder, sd); + assertEquals(cut, cut); + assertNotEquals(cut, null); // NOSONAR + assertNotEquals(cut, other); + } + + @Test + void testEqualsOtherClass() throws ODataJPAModelException { + final FromImpl other = mock(FromImpl.class); + assertNotEquals(cut, other); + } +} diff --git a/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/TupleImplTest.java b/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/TupleImplTest.java index d4a5c04cc..cddb45144 100644 --- a/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/TupleImplTest.java +++ b/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/TupleImplTest.java @@ -17,9 +17,9 @@ import java.util.Map; import java.util.Map.Entry; -import javax.persistence.AttributeConverter; -import javax.persistence.Tuple; -import javax.persistence.TupleElement; +import jakarta.persistence.AttributeConverter; +import jakarta.persistence.Tuple; +import jakarta.persistence.TupleElement; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; diff --git a/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/TypedQueryImplTest.java b/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/TypedQueryImplTest.java index b61c87046..f7c4486c4 100644 --- a/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/TypedQueryImplTest.java +++ b/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/impl/TypedQueryImplTest.java @@ -11,12 +11,12 @@ import java.util.Calendar; import java.util.GregorianCalendar; -import javax.persistence.EntityManager; -import javax.persistence.FlushModeType; -import javax.persistence.LockModeType; -import javax.persistence.Parameter; -import javax.persistence.Query; -import javax.persistence.TemporalType; +import jakarta.persistence.EntityManager; +import jakarta.persistence.FlushModeType; +import jakarta.persistence.LockModeType; +import jakarta.persistence.Parameter; +import jakarta.persistence.Query; +import jakarta.persistence.TemporalType; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -206,8 +206,8 @@ void testSetParameterByTemporalDateByParameter() { void testSetParameterByValue() { @SuppressWarnings("unchecked") final Parameter param = mock(Parameter.class); - assertEquals(cut, cut.setParameter(param, Integer.valueOf(1))); - verify(q).setParameter(param, Integer.valueOf(1)); + assertEquals(cut, cut.setParameter(param, 1)); + verify(q).setParameter(param, 1); } @Test diff --git a/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/joiner/ExpressionJoinerTest.java b/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/joiner/ExpressionJoinerTest.java index 4bffc06e9..ca0dea51e 100644 --- a/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/joiner/ExpressionJoinerTest.java +++ b/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/joiner/ExpressionJoinerTest.java @@ -5,10 +5,10 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.Expression; -import javax.persistence.criteria.Predicate; -import javax.persistence.criteria.Predicate.BooleanOperator; +import jakarta.persistence.criteria.CriteriaBuilder; +import jakarta.persistence.criteria.Expression; +import jakarta.persistence.criteria.Predicate; +import jakarta.persistence.criteria.Predicate.BooleanOperator; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -44,8 +44,8 @@ void testAddFirst() { } @SuppressWarnings("unchecked") - @Test - void testAddTwoViwAnd() { + @Test + void testAddTwoWithAnd() { final Expression second = mock(Expression.class); cut.add(first); assertEquals(cut, cut.add(second)); @@ -53,8 +53,8 @@ void testAddTwoViwAnd() { } @SuppressWarnings("unchecked") - @Test - void testAddTwoViwOr() { + @Test + void testAddTwoWithOr() { final Expression second = mock(Expression.class); cut = new ExpressionJoiner(cb, BooleanOperator.OR); cut.add(first); diff --git a/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/testobjects/SubJoined.java b/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/testobjects/SubJoined.java index 395d261c5..01eae7386 100644 --- a/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/testobjects/SubJoined.java +++ b/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/testobjects/SubJoined.java @@ -1,6 +1,6 @@ package com.sap.olingo.jpa.processor.cb.testobjects; - -import javax.persistence.PrimaryKeyJoinColumn; + +import jakarta.persistence.PrimaryKeyJoinColumn; @PrimaryKeyJoinColumn(name = "\"Key1\"", referencedColumnName = "\"Value1\"") public class SubJoined extends SuperJoined { diff --git a/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/testobjects/SuperJoined.java b/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/testobjects/SuperJoined.java index eed7d471b..f410f6f0b 100644 --- a/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/testobjects/SuperJoined.java +++ b/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/testobjects/SuperJoined.java @@ -1,8 +1,8 @@ package com.sap.olingo.jpa.processor.cb.testobjects; - -import javax.persistence.Entity; -import javax.persistence.Inheritance; -import javax.persistence.InheritanceType; + +import jakarta.persistence.Entity; +import jakarta.persistence.Inheritance; +import jakarta.persistence.InheritanceType; @Entity(name = "Super") @Inheritance(strategy = InheritanceType.JOINED) diff --git a/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/testobjects/SuperTablePerClass.java b/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/testobjects/SuperTablePerClass.java index 514d472a4..af53869f2 100644 --- a/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/testobjects/SuperTablePerClass.java +++ b/jpa/odata-jpa-processor-cb/src/test/java/com/sap/olingo/jpa/processor/cb/testobjects/SuperTablePerClass.java @@ -1,8 +1,8 @@ package com.sap.olingo.jpa.processor.cb.testobjects; - -import javax.persistence.Entity; -import javax.persistence.Inheritance; -import javax.persistence.InheritanceType; + +import jakarta.persistence.Entity; +import jakarta.persistence.Inheritance; +import jakarta.persistence.InheritanceType; @Entity(name = "Super") @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) diff --git a/jpa/odata-jpa-processor-ext/pom.xml b/jpa/odata-jpa-processor-ext/pom.xml index 718e774db..3fc740706 100644 --- a/jpa/odata-jpa-processor-ext/pom.xml +++ b/jpa/odata-jpa-processor-ext/pom.xml @@ -4,7 +4,7 @@ com.sap.olingo odata-jpa - 1.1.1 + 2.0.0 odata-jpa-processor-ext odata-jpa-processor-ext diff --git a/jpa/odata-jpa-processor-ext/src/main/java/com/sap/olingo/jpa/processor/cb/ProcessorCriteriaBuilder.java b/jpa/odata-jpa-processor-ext/src/main/java/com/sap/olingo/jpa/processor/cb/ProcessorCriteriaBuilder.java index 521f41c6e..11bfbd6ce 100644 --- a/jpa/odata-jpa-processor-ext/src/main/java/com/sap/olingo/jpa/processor/cb/ProcessorCriteriaBuilder.java +++ b/jpa/odata-jpa-processor-ext/src/main/java/com/sap/olingo/jpa/processor/cb/ProcessorCriteriaBuilder.java @@ -2,12 +2,12 @@ import java.util.List; -import javax.persistence.Tuple; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.Expression; -import javax.persistence.criteria.Order; -import javax.persistence.criteria.Path; -import javax.persistence.criteria.Subquery; +import jakarta.persistence.Tuple; +import jakarta.persistence.criteria.CriteriaBuilder; +import jakarta.persistence.criteria.Expression; +import jakarta.persistence.criteria.Order; +import jakarta.persistence.criteria.Path; +import jakarta.persistence.criteria.Subquery; public interface ProcessorCriteriaBuilder extends CriteriaBuilder { @@ -39,13 +39,14 @@ public static interface WindowFunction extends Expression { WindowFunction orderBy(final Order... order); WindowFunction orderBy(final List order); + /** * Takes an array of simple path expressions. * @param path * @return */ WindowFunction partitionBy(final Path... path); - + WindowFunction partitionBy(final List> path); Path asPath(final String tableAlias); diff --git a/jpa/odata-jpa-processor-ext/src/main/java/com/sap/olingo/jpa/processor/cb/ProcessorCriteriaQuery.java b/jpa/odata-jpa-processor-ext/src/main/java/com/sap/olingo/jpa/processor/cb/ProcessorCriteriaQuery.java index 59e1c70ca..d487aae92 100644 --- a/jpa/odata-jpa-processor-ext/src/main/java/com/sap/olingo/jpa/processor/cb/ProcessorCriteriaQuery.java +++ b/jpa/odata-jpa-processor-ext/src/main/java/com/sap/olingo/jpa/processor/cb/ProcessorCriteriaQuery.java @@ -1,9 +1,9 @@ package com.sap.olingo.jpa.processor.cb; -import javax.persistence.criteria.CriteriaQuery; -import javax.persistence.criteria.Root; +import jakarta.persistence.criteria.CriteriaQuery; +import jakarta.persistence.criteria.Root; -public interface ProcessorCriteriaQuery extends CriteriaQuery , ProcessorSubQueryProvider{ +public interface ProcessorCriteriaQuery extends CriteriaQuery, ProcessorSubQueryProvider { @Override public ProcessorSubquery subquery(Class type); diff --git a/jpa/odata-jpa-processor-ext/src/main/java/com/sap/olingo/jpa/processor/cb/ProcessorSelection.java b/jpa/odata-jpa-processor-ext/src/main/java/com/sap/olingo/jpa/processor/cb/ProcessorSelection.java index 22808f549..cb840e483 100644 --- a/jpa/odata-jpa-processor-ext/src/main/java/com/sap/olingo/jpa/processor/cb/ProcessorSelection.java +++ b/jpa/odata-jpa-processor-ext/src/main/java/com/sap/olingo/jpa/processor/cb/ProcessorSelection.java @@ -4,7 +4,7 @@ import java.util.Map; import java.util.Map.Entry; -import javax.persistence.criteria.Selection; +import jakarta.persistence.criteria.Selection; import com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAAttribute; import com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAPath; @@ -21,16 +21,7 @@ public interface ProcessorSelection extends Selection { * @author Oliver Grande * */ - public static class SelectionItem implements Map.Entry { - - private final String key; - private final JPAPath value; - - public SelectionItem(final String key, final JPAPath value) { - super(); - this.key = key; - this.value = value; - } + public static record SelectionItem(String key, JPAPath value) implements Map.Entry { @Override public String getKey() { @@ -48,16 +39,7 @@ public JPAPath setValue(final JPAPath value) { } } - public static class SelectionAttribute implements Map.Entry { - - private final String key; - private final JPAAttribute value; - - public SelectionAttribute(final String key, final JPAAttribute value) { - super(); - this.key = key; - this.value = value; - } + public static record SelectionAttribute(String key, JPAAttribute value) implements Map.Entry { @Override public String getKey() { diff --git a/jpa/odata-jpa-processor-ext/src/main/java/com/sap/olingo/jpa/processor/cb/ProcessorSubquery.java b/jpa/odata-jpa-processor-ext/src/main/java/com/sap/olingo/jpa/processor/cb/ProcessorSubquery.java index 4d81db81a..5564950cd 100644 --- a/jpa/odata-jpa-processor-ext/src/main/java/com/sap/olingo/jpa/processor/cb/ProcessorSubquery.java +++ b/jpa/odata-jpa-processor-ext/src/main/java/com/sap/olingo/jpa/processor/cb/ProcessorSubquery.java @@ -3,12 +3,13 @@ import java.util.List; import javax.annotation.Nullable; -import javax.persistence.criteria.Order; -import javax.persistence.criteria.Root; -import javax.persistence.criteria.Selection; -import javax.persistence.criteria.Subquery; -public interface ProcessorSubquery extends Subquery , ProcessorSubQueryProvider{ +import jakarta.persistence.criteria.Order; +import jakarta.persistence.criteria.Root; +import jakarta.persistence.criteria.Selection; +import jakarta.persistence.criteria.Subquery; + +public interface ProcessorSubquery extends Subquery, ProcessorSubQueryProvider { @Override public ProcessorSubquery subquery(Class type); diff --git a/jpa/odata-jpa-processor-parallel/README.md b/jpa/odata-jpa-processor-parallel/README.md index d03fea6ca..3b7249e83 100644 --- a/jpa/odata-jpa-processor-parallel/README.md +++ b/jpa/odata-jpa-processor-parallel/README.md @@ -1,11 +1,11 @@ # Parallel Processing -__This project is under construction! Feel free to try it__ +__This project is under construction! Feel free to try it.__ -This project contains JPA Processor enhancements to process OData requests in parallel. - -As a first step GET requests that a combined in a $batch request are executed in parallel. The parallel processing is used if the corresponding factory is provided via the service context: +This project contains JPA Processor enhancements to process OData requests in parallel. As a first step GET requests that a combined in a $batch request are executed in parallel. The parallel processing is used if the corresponding factory is provided via the service context: ```java .setBatchProcessorFactory(new JPAODataParallelBatchProcessorFactory()) ``` + +It shall be mentioned that the OData specification would allow a parallel processing only if the clients sends a `` header, seeter diff --git a/jpa/odata-jpa-processor-parallel/pom.xml b/jpa/odata-jpa-processor-parallel/pom.xml index e847362ba..3e5df27cd 100644 --- a/jpa/odata-jpa-processor-parallel/pom.xml +++ b/jpa/odata-jpa-processor-parallel/pom.xml @@ -1,46 +1,54 @@ - - 4.0.0 - - com.sap.olingo - odata-jpa - 1.1.1 - + + 4.0.0 + + com.sap.olingo + odata-jpa + 2.0.0 + - odata-jpa-processor-parallel + odata-jpa-processor-parallel - - This project shall support parallel processing of GET requests. In its first - version on batch request level. - At this state the project in a beta state. Before using test carefully! - + + This project shall support parallel processing of GET requests. In its + first + version on batch request level. + At this state the project in a beta state. Before using test carefully! + - - UTF-8 - - - - com.sap.olingo - odata-jpa-test - test - ${project.version} - - - com.sap.olingo - odata-jpa-annotation - ${project.version} - - - com.sap.olingo - odata-jpa-processor - ${project.version} - - - com.sap.olingo - odata-jpa-processor-cb - ${project.version} - test - - + + UTF-8 + + + + com.sap.olingo + odata-jpa-test + test + ${project.version} + + + com.sap.olingo + odata-jpa-annotation + ${project.version} + + + com.sap.olingo + odata-jpa-processor + ${project.version} + + + com.sap.olingo + odata-jpa-processor-cb + ${project.version} + test + + + javax.servlet + javax.servlet-api + 3.0.1 + test + + \ No newline at end of file diff --git a/jpa/odata-jpa-processor-parallel/src/main/java/com/sap/olingo/jpa/processor/core/processor/JPAODataBatchParallelRequestGroup.java b/jpa/odata-jpa-processor-parallel/src/main/java/com/sap/olingo/jpa/processor/core/processor/JPAODataBatchParallelRequestGroup.java index a31841e32..04901ebe9 100644 --- a/jpa/odata-jpa-processor-parallel/src/main/java/com/sap/olingo/jpa/processor/core/processor/JPAODataBatchParallelRequestGroup.java +++ b/jpa/odata-jpa-processor-parallel/src/main/java/com/sap/olingo/jpa/processor/core/processor/JPAODataBatchParallelRequestGroup.java @@ -2,7 +2,6 @@ import java.util.List; import java.util.concurrent.CompletableFuture; -import java.util.stream.Collectors; import org.apache.olingo.commons.api.ex.ODataException; import org.apache.olingo.server.api.ODataApplicationException; @@ -35,13 +34,13 @@ public List execute() { final List> requests = requestParts.stream() .map(part -> startBatchPart(buildFacade(), part)) - .collect(Collectors.toList()); + .toList(); return CompletableFuture.allOf(requests.toArray(new CompletableFuture[requests.size()])) .thenApply(dummy -> requests.stream() .map(CompletableFuture::join) - .collect(Collectors.toList())).join(); - } catch (RuntimeException e) { + .toList()).join(); + } catch (final RuntimeException e) { // startBatchPart throws an runtime exception that wraps the original exception. This runtime exception gets is // wrapped into an CompletionException. The original exception has to be re-wrapped, so the caller can handle it. throw new ODataJPABatchRuntimeException((ODataException) e.getCause().getCause()); diff --git a/jpa/odata-jpa-processor-parallel/src/main/java/com/sap/olingo/jpa/processor/core/processor/JPAODataBatchSequentialRequestGroup.java b/jpa/odata-jpa-processor-parallel/src/main/java/com/sap/olingo/jpa/processor/core/processor/JPAODataBatchSequentialRequestGroup.java index 6c619cf01..e6dd54986 100644 --- a/jpa/odata-jpa-processor-parallel/src/main/java/com/sap/olingo/jpa/processor/core/processor/JPAODataBatchSequentialRequestGroup.java +++ b/jpa/odata-jpa-processor-parallel/src/main/java/com/sap/olingo/jpa/processor/core/processor/JPAODataBatchSequentialRequestGroup.java @@ -1,7 +1,6 @@ package com.sap.olingo.jpa.processor.core.processor; import java.util.List; -import java.util.stream.Collectors; import org.apache.olingo.server.api.ODataApplicationException; import org.apache.olingo.server.api.ODataHandler; @@ -30,7 +29,7 @@ public List execute() { final BatchFacade facade = buildFacade(); return groupElements.stream() .map(part -> executePart(facade, part)) - .collect(Collectors.toList()); + .toList(); } private ODataResponsePart executePart(final BatchFacade facade, final BatchRequestPart part) { diff --git a/jpa/odata-jpa-processor-parallel/src/main/java/com/sap/olingo/jpa/processor/core/processor/JPAODataParallelBatchProcessor.java b/jpa/odata-jpa-processor-parallel/src/main/java/com/sap/olingo/jpa/processor/core/processor/JPAODataParallelBatchProcessor.java index 285fa21bd..1e703841f 100644 --- a/jpa/odata-jpa-processor-parallel/src/main/java/com/sap/olingo/jpa/processor/core/processor/JPAODataParallelBatchProcessor.java +++ b/jpa/odata-jpa-processor-parallel/src/main/java/com/sap/olingo/jpa/processor/core/processor/JPAODataParallelBatchProcessor.java @@ -5,7 +5,6 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; -import java.util.stream.Collectors; import javax.annotation.Nonnull; @@ -27,13 +26,14 @@ /** * Process parts of a batch request in parallel. This is possible for GET requests until the first request with side - * effects comes. In case a request with side effect is followed by a set of request without side effect, they are processed in + * effects comes. In case a request with side effect is followed by a set of request without side effect, they are + * processed in * parallel again. *

            * Please note that this is, according to the OData specification,only allowed: *

              - *
            1. In case the client sends an continue-on-error=true
            2. - *
            3. It is guaranteed that the GET do not fail + *
            4. In case the client sends an continue-on-error=true
            5. + *
            6. It is guaranteed that the GET do not fail *
            * @author Oliver Grande * Created: 27.02.2020 @@ -54,7 +54,7 @@ protected List executeBatchParts(final BatchFacade facade, return buildGroups(requestParts).stream() .map(JPAODataBatchRequestGroup::execute) .flatMap(List::stream) - .collect(Collectors.toList()); + .toList(); } catch (final ODataJPABatchRuntimeException e) { throw new ODataJPABatchException(e); } @@ -94,11 +94,11 @@ List buildGroups(@Nonnull final List())); + final ODataHttpHandler handler = odata.createHandler(odata.createServiceMetadata(edmProvider, + new ArrayList<>())); final JPAODataInternalRequestContext requestContext = new JPAODataInternalRequestContext(customContext, sessionContext); handler.register(new JPAODataRequestProcessor(sessionContext, requestContext)); - handler.register(new JPAODataBatchProcessor(sessionContext, requestContext)); - handler.process(req, resp); + handler.register(new JPAODataBatchProcessor(sessionContext, requestContext)); + handler.process(new JakartaRequestMapper(req), new JakartaResponseMapper(resp)); } public List getRawBatchResult() throws IOException { @@ -176,7 +176,17 @@ public Iterator getBuffer() { public int getSize() { return buffer.size(); + } + + @Override + public boolean isReady() { + return true; } + + @Override + public void setWriteListener(final WriteListener writeListener) { + + } } // diff --git a/jpa/odata-jpa-processor-parallel/src/test/java/com/sap/olingo/jpa/processor/test/util/JakartaRequestMapper.java b/jpa/odata-jpa-processor-parallel/src/test/java/com/sap/olingo/jpa/processor/test/util/JakartaRequestMapper.java new file mode 100644 index 000000000..e9866f17a --- /dev/null +++ b/jpa/odata-jpa-processor-parallel/src/test/java/com/sap/olingo/jpa/processor/test/util/JakartaRequestMapper.java @@ -0,0 +1,380 @@ +package com.sap.olingo.jpa.processor.test.util; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.security.Principal; +import java.util.Collection; +import java.util.Enumeration; +import java.util.Locale; +import java.util.Map; + +import javax.servlet.AsyncContext; +import javax.servlet.DispatcherType; +import javax.servlet.RequestDispatcher; +import javax.servlet.ServletContext; +import javax.servlet.ServletException; +import javax.servlet.ServletInputStream; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; +import javax.servlet.http.Cookie; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; +import javax.servlet.http.Part; + +import jakarta.servlet.http.HttpServletRequest; + +public class JakartaRequestMapper implements javax.servlet.http.HttpServletRequest { + + private final HttpServletRequest jakartaRequest; + + public JakartaRequestMapper(final HttpServletRequest jakartaRequest) { + super(); + this.jakartaRequest = jakartaRequest; + } + + @Override + public Object getAttribute(final String name) { + return jakartaRequest.getAttribute(name); + } + + @Override + public Enumeration getAttributeNames() { + return jakartaRequest.getAttributeNames(); + } + + @Override + public String getCharacterEncoding() { + return jakartaRequest.changeSessionId(); + } + + @Override + public void setCharacterEncoding(final String env) throws UnsupportedEncodingException { + jakartaRequest.setCharacterEncoding(env); + } + + @Override + public int getContentLength() { + return jakartaRequest.getContentLength(); + } + + @Override + public String getContentType() { + return jakartaRequest.getContentType(); + } + + @Override + public ServletInputStream getInputStream() throws IOException { + return new JakartaServletInputStream(jakartaRequest.getInputStream()); + } + + @Override + public String getParameter(final String name) { + return jakartaRequest.getParameter(name); + } + + @Override + public Enumeration getParameterNames() { + return jakartaRequest.getParameterNames(); + } + + @Override + public String[] getParameterValues(final String name) { + return jakartaRequest.getParameterValues(name); + } + + @Override + public Map getParameterMap() { + return jakartaRequest.getParameterMap(); + } + + @Override + public String getProtocol() { + return jakartaRequest.getProtocol(); + } + + @Override + public String getScheme() { + return jakartaRequest.getScheme(); + } + + @Override + public String getServerName() { + return jakartaRequest.getServerName(); + } + + @Override + public int getServerPort() { + return getServerPort(); + } + + @Override + public BufferedReader getReader() throws IOException { + return jakartaRequest.getReader(); + } + + @Override + public String getRemoteAddr() { + return jakartaRequest.getRemoteAddr(); + } + + @Override + public String getRemoteHost() { + return jakartaRequest.getRemoteHost(); + } + + @Override + public void setAttribute(final String name, final Object o) { + jakartaRequest.setAttribute(name, o); + } + + @Override + public void removeAttribute(final String name) { + jakartaRequest.removeAttribute(name); + } + + @Override + public Locale getLocale() { + return jakartaRequest.getLocale(); + } + + @Override + public Enumeration getLocales() { + return jakartaRequest.getLocales(); + } + + @Override + public boolean isSecure() { + return jakartaRequest.isSecure(); + } + + @Override + public RequestDispatcher getRequestDispatcher(final String path) { + throw new IllegalAccessError(); + } + + @Override + public String getRealPath(final String path) { + throw new IllegalAccessError(); + } + + @Override + public int getRemotePort() { + return 0; + } + + @Override + public String getLocalName() { + return jakartaRequest.getLocalName(); + } + + @Override + public String getLocalAddr() { + + return jakartaRequest.getLocalAddr(); + } + + @Override + public int getLocalPort() { + return 0; + } + + @Override + public ServletContext getServletContext() { + throw new IllegalAccessError(); + } + + @Override + public AsyncContext startAsync() throws IllegalStateException { + throw new IllegalAccessError(); + } + + @Override + public AsyncContext startAsync(final ServletRequest servletRequest, final ServletResponse servletResponse) + throws IllegalStateException { + throw new IllegalAccessError(); + } + + @Override + public boolean isAsyncStarted() { + return jakartaRequest.isAsyncStarted(); + } + + @Override + public boolean isAsyncSupported() { + return jakartaRequest.isAsyncSupported(); + } + + @Override + public AsyncContext getAsyncContext() { + throw new IllegalAccessError(); + } + + @Override + public DispatcherType getDispatcherType() { + throw new IllegalAccessError(); + } + + @Override + public String getAuthType() { + return jakartaRequest.getAuthType(); + } + + @Override + public Cookie[] getCookies() { + final Cookie[] cookies = new Cookie[jakartaRequest.getCookies().length]; + for (int i = 0; i < jakartaRequest.getCookies().length; i++) + cookies[i] = new Cookie(jakartaRequest.getCookies()[i].getName(), jakartaRequest.getCookies()[i].getValue()); + return cookies; + } + + @Override + public long getDateHeader(final String name) { + return jakartaRequest.getDateHeader(name); + } + + @Override + public String getHeader(final String name) { + return jakartaRequest.getHeader(name); + } + + @Override + public Enumeration getHeaders(final String name) { + return jakartaRequest.getHeaders(name); + } + + @Override + public Enumeration getHeaderNames() { + return jakartaRequest.getHeaderNames(); + } + + @Override + public int getIntHeader(final String name) { + return jakartaRequest.getIntHeader(name); + } + + @Override + public String getMethod() { + return jakartaRequest.getMethod(); + } + + @Override + public String getPathInfo() { + return jakartaRequest.getPathInfo(); + } + + @Override + public String getPathTranslated() { + return jakartaRequest.getPathTranslated(); + } + + @Override + public String getContextPath() { + return jakartaRequest.getContextPath(); + } + + @Override + public String getQueryString() { + return jakartaRequest.getQueryString(); + } + + @Override + public String getRemoteUser() { + return jakartaRequest.getRemoteUser(); + } + + @Override + public boolean isUserInRole(final String role) { + return jakartaRequest.isUserInRole(role); + } + + @Override + public Principal getUserPrincipal() { + return jakartaRequest.getUserPrincipal(); + } + + @Override + public String getRequestedSessionId() { + return jakartaRequest.getRequestedSessionId(); + } + + @Override + public String getRequestURI() { + return jakartaRequest.getRequestURI(); + } + + @Override + public StringBuffer getRequestURL() { + return jakartaRequest.getRequestURL(); + } + + @Override + public String getServletPath() { + return jakartaRequest.getServletPath(); + } + + @Override + public HttpSession getSession(final boolean create) { + throw new IllegalAccessError(); + } + + @Override + public HttpSession getSession() { + throw new IllegalAccessError(); + } + + @Override + public boolean isRequestedSessionIdValid() { + return jakartaRequest.isRequestedSessionIdValid(); + } + + @Override + public boolean isRequestedSessionIdFromCookie() { + return jakartaRequest.isRequestedSessionIdFromCookie(); + } + + @Override + public boolean isRequestedSessionIdFromURL() { + return jakartaRequest.isRequestedSessionIdFromURL(); + } + + @Override + public boolean isRequestedSessionIdFromUrl() { + return jakartaRequest.isRequestedSessionIdFromURL(); + } + + @Override + public boolean authenticate(final HttpServletResponse response) throws IOException, ServletException { + + return false; + } + + @Override + public void login(final String userName, final String password) throws ServletException { + try { + jakartaRequest.login(userName, password); + } catch (final jakarta.servlet.ServletException e) { + throw new ServletException(e); + } + } + + @Override + public void logout() throws ServletException { + try { + jakartaRequest.logout(); + } catch (final jakarta.servlet.ServletException e) { + throw new ServletException(e); + } + } + + @Override + public Collection getParts() throws IOException, ServletException { + throw new IllegalAccessError(); + } + + @Override + public Part getPart(final String name) throws IOException, ServletException { + throw new IllegalAccessError(); + } + +} diff --git a/jpa/odata-jpa-processor-parallel/src/test/java/com/sap/olingo/jpa/processor/test/util/JakartaResponseMapper.java b/jpa/odata-jpa-processor-parallel/src/test/java/com/sap/olingo/jpa/processor/test/util/JakartaResponseMapper.java new file mode 100644 index 000000000..24f855ce2 --- /dev/null +++ b/jpa/odata-jpa-processor-parallel/src/test/java/com/sap/olingo/jpa/processor/test/util/JakartaResponseMapper.java @@ -0,0 +1,200 @@ +package com.sap.olingo.jpa.processor.test.util; + +import java.io.IOException; +import java.io.PrintWriter; +import java.util.Collection; +import java.util.Locale; + +import javax.servlet.ServletOutputStream; +import javax.servlet.http.Cookie; +import javax.servlet.http.HttpServletResponse; + +public class JakartaResponseMapper implements HttpServletResponse { + + private final jakarta.servlet.http.HttpServletResponse jakartaResponse; + + public JakartaResponseMapper(final jakarta.servlet.http.HttpServletResponse response) { + this.jakartaResponse = response; + } + + @Override + public String getCharacterEncoding() { + return jakartaResponse.getCharacterEncoding(); + } + + @Override + public String getContentType() { + return jakartaResponse.getContentType(); + } + + @Override + public ServletOutputStream getOutputStream() throws IOException { + return new JakartaServletOutputStream(jakartaResponse.getOutputStream()); + } + + @Override + public PrintWriter getWriter() throws IOException { + return jakartaResponse.getWriter(); + } + + @Override + public void setCharacterEncoding(final String charset) { + jakartaResponse.setCharacterEncoding(charset); + } + + @Override + public void setContentLength(final int len) { + jakartaResponse.setContentLength(len); + } + + @Override + public void setContentType(final String type) { + jakartaResponse.setContentType(type); + } + + @Override + public void setBufferSize(final int size) { + jakartaResponse.setBufferSize(size); + } + + @Override + public int getBufferSize() { + return jakartaResponse.getBufferSize(); + } + + @Override + public void flushBuffer() throws IOException { + jakartaResponse.flushBuffer(); + } + + @Override + public void resetBuffer() { + jakartaResponse.resetBuffer(); + } + + @Override + public boolean isCommitted() { + return jakartaResponse.isCommitted(); + } + + @Override + public void reset() { + jakartaResponse.reset(); + } + + @Override + public void setLocale(final Locale loc) { + jakartaResponse.setLocale(loc); + } + + @Override + public Locale getLocale() { + return jakartaResponse.getLocale(); + } + + @Override + public void addCookie(final Cookie cookie) { + jakartaResponse.addCookie(new jakarta.servlet.http.Cookie(cookie.getName(), cookie.getValue())); + } + + @Override + public boolean containsHeader(final String name) { + return jakartaResponse.containsHeader(name); + } + + @Override + public String encodeURL(final String url) { + return jakartaResponse.encodeURL(url); + } + + @Override + public String encodeRedirectURL(final String url) { + return jakartaResponse.encodeRedirectURL(url); + } + + @Override + public String encodeUrl(final String url) { + return jakartaResponse.encodeURL(url); + } + + @Override + public String encodeRedirectUrl(final String url) { + return jakartaResponse.encodeRedirectURL(url); + } + + @Override + public void sendError(final int sc, final String msg) throws IOException { + jakartaResponse.sendError(sc, msg); + } + + @Override + public void sendError(final int sc) throws IOException { + jakartaResponse.sendError(sc); + } + + @Override + public void sendRedirect(final String location) throws IOException { + jakartaResponse.sendRedirect(location); + } + + @Override + public void setDateHeader(final String name, final long date) { + jakartaResponse.setDateHeader(name, date); + } + + @Override + public void addDateHeader(final String name, final long date) { + jakartaResponse.addDateHeader(name, date); + } + + @Override + public void setHeader(final String name, final String value) { + jakartaResponse.setHeader(name, value); + } + + @Override + public void addHeader(final String name, final String value) { + jakartaResponse.addHeader(name, value); + } + + @Override + public void setIntHeader(final String name, final int value) { + jakartaResponse.setIntHeader(name, value); + } + + @Override + public void addIntHeader(final String name, final int value) { + jakartaResponse.addIntHeader(name, value); + } + + @Override + public void setStatus(final int sc) { + jakartaResponse.setStatus(sc); + } + + @Override + public void setStatus(final int sc, final String sm) { + jakartaResponse.setBufferSize(sc); + } + + @Override + public int getStatus() { + return getStatus(); + } + + @Override + public String getHeader(final String name) { + return jakartaResponse.getHeader(name); + } + + @Override + public Collection getHeaders(final String name) { + return jakartaResponse.getHeaders(name); + } + + @Override + public Collection getHeaderNames() { + return jakartaResponse.getHeaderNames(); + } + +} diff --git a/jpa/odata-jpa-processor-parallel/src/test/java/com/sap/olingo/jpa/processor/test/util/JakartaServletInputStream.java b/jpa/odata-jpa-processor-parallel/src/test/java/com/sap/olingo/jpa/processor/test/util/JakartaServletInputStream.java new file mode 100644 index 000000000..2ca9f95e9 --- /dev/null +++ b/jpa/odata-jpa-processor-parallel/src/test/java/com/sap/olingo/jpa/processor/test/util/JakartaServletInputStream.java @@ -0,0 +1,24 @@ +package com.sap.olingo.jpa.processor.test.util; + +import java.io.IOException; + +import javax.servlet.ServletInputStream; + +public class JakartaServletInputStream extends ServletInputStream { + private final jakarta.servlet.ServletInputStream inputStream; + + public JakartaServletInputStream(final jakarta.servlet.ServletInputStream inputStream) { + this.inputStream = inputStream; + } + + @Override + public int read() throws IOException { + return inputStream.read(); + } + + @Override + public int readLine(final byte[] b, final int off, final int len) throws IOException { + return inputStream.readLine(b, off, len); + } + +} diff --git a/jpa/odata-jpa-processor-parallel/src/test/java/com/sap/olingo/jpa/processor/test/util/JakartaServletOutputStream.java b/jpa/odata-jpa-processor-parallel/src/test/java/com/sap/olingo/jpa/processor/test/util/JakartaServletOutputStream.java new file mode 100644 index 000000000..97980dae7 --- /dev/null +++ b/jpa/odata-jpa-processor-parallel/src/test/java/com/sap/olingo/jpa/processor/test/util/JakartaServletOutputStream.java @@ -0,0 +1,24 @@ +package com.sap.olingo.jpa.processor.test.util; + +import java.io.IOException; + +import javax.servlet.ServletOutputStream; + +public class JakartaServletOutputStream extends ServletOutputStream { + + private final jakarta.servlet.ServletOutputStream jakartaOutputStream; + + public JakartaServletOutputStream(final jakarta.servlet.ServletOutputStream outputStream) { + this.jakartaOutputStream = outputStream; + } + + @Override + public void write(final int b) throws IOException { + jakartaOutputStream.write(b); + } + + @Override + public void print(final String s) throws IOException { + jakartaOutputStream.print(s); + } +} diff --git a/jpa/odata-jpa-processor/.settings/org.eclipse.jdt.core.prefs b/jpa/odata-jpa-processor/.settings/org.eclipse.jdt.core.prefs index 9b48fdc3d..acf518c14 100644 --- a/jpa/odata-jpa-processor/.settings/org.eclipse.jdt.core.prefs +++ b/jpa/odata-jpa-processor/.settings/org.eclipse.jdt.core.prefs @@ -1,9 +1,9 @@ eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 -org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 +org.eclipse.jdt.core.compiler.compliance=17 org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning org.eclipse.jdt.core.compiler.processAnnotations=disabled org.eclipse.jdt.core.compiler.release=disabled -org.eclipse.jdt.core.compiler.source=1.8 +org.eclipse.jdt.core.compiler.source=17 diff --git a/jpa/odata-jpa-processor/.settings/org.eclipse.wst.common.project.facet.core.xml b/jpa/odata-jpa-processor/.settings/org.eclipse.wst.common.project.facet.core.xml index ee260d978..babef879f 100644 --- a/jpa/odata-jpa-processor/.settings/org.eclipse.wst.common.project.facet.core.xml +++ b/jpa/odata-jpa-processor/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -1,5 +1,5 @@ - + diff --git a/jpa/odata-jpa-processor/pom.xml b/jpa/odata-jpa-processor/pom.xml index 7632dc474..2e3b0c4ba 100644 --- a/jpa/odata-jpa-processor/pom.xml +++ b/jpa/odata-jpa-processor/pom.xml @@ -7,7 +7,7 @@ com.sap.olingo odata-jpa - 1.1.1 + 2.0.0 odata-jpa-processor @@ -16,7 +16,7 @@ https://github.com/SAP/olingo-jpa-processor-v4 UTF-8 - 2.5 + 6.0.0 @@ -46,15 +46,25 @@ ${odata.version} - javax.servlet - servlet-api - ${javax.version} + jakarta.persistence + jakarta.persistence-api + ${jpa.version} provided - javax.transaction - javax.transaction-api - 1.3 + jakarta.servlet + jakarta.servlet-api + ${javax.version} + + + javax.servlet + javax.servlet-api + 3.0.1 + + + jakarta.transaction + jakarta.transaction-api + 2.0.1 com.google.code.findbugs diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/api/JPAAbstractCUDRequestHandler.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/api/JPAAbstractCUDRequestHandler.java index 3b564e343..e81504bad 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/api/JPAAbstractCUDRequestHandler.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/api/JPAAbstractCUDRequestHandler.java @@ -1,6 +1,6 @@ package com.sap.olingo.jpa.processor.core.api; -import javax.persistence.EntityManager; +import jakarta.persistence.EntityManager; import org.apache.olingo.commons.api.http.HttpMethod; import org.apache.olingo.commons.api.http.HttpStatusCode; diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/api/JPACUDRequestHandler.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/api/JPACUDRequestHandler.java index 5a84fbf2f..664d480a9 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/api/JPACUDRequestHandler.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/api/JPACUDRequestHandler.java @@ -1,6 +1,6 @@ package com.sap.olingo.jpa.processor.core.api; -import javax.persistence.EntityManager; +import jakarta.persistence.EntityManager; import org.apache.olingo.commons.api.http.HttpMethod; @@ -65,7 +65,8 @@ public JPAUpdateResult updateEntity(final JPARequestEntity requestEntity, final /** * Hook that is called after all changes of one transaction have been processed. The method shall enable a check of * all modification within the new context. This can be imported if multiple entities are changes with the same - * request (batch request or deep-insert) and consistency constrains exist between them.

            + * request (batch request or deep-insert) and consistency constrains exist between them. + *

            * In case changes are made to the entities, these changes are not part of the response in case of batch requests. * @throws ODataJPAProcessException */ diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/api/JPAODataBatchProcessor.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/api/JPAODataBatchProcessor.java index 29cecde15..c4a5cbee9 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/api/JPAODataBatchProcessor.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/api/JPAODataBatchProcessor.java @@ -6,8 +6,8 @@ import java.util.Optional; import java.util.UUID; -import javax.persistence.OptimisticLockException; -import javax.persistence.RollbackException; +import jakarta.persistence.OptimisticLockException; +import jakarta.persistence.RollbackException; import org.apache.olingo.commons.api.format.ContentType; import org.apache.olingo.commons.api.format.PreferenceName; @@ -63,7 +63,7 @@ public final void init(final OData odata, final ServiceMetadata serviceMetadata) public final void processBatch(final BatchFacade facade, final ODataRequest request, final ODataResponse response) throws ODataApplicationException, ODataLibraryException { - try (JPARuntimeMeasurement meassument = requestContext.getDebugger().newMeasurement(this, "processBatch")) { + try (JPARuntimeMeasurement measurement = requestContext.getDebugger().newMeasurement(this, "processBatch")) { final String boundary = facade.extractBoundaryFromContentType(request.getHeader(HttpHeader.CONTENT_TYPE)); final BatchOptions options = BatchOptions.with() .rawBaseUri(request.getRawBaseUri()) @@ -130,7 +130,7 @@ public final ODataResponsePart processChangeSet(final BatchFacade facade, final * to the other processor interfaces. */ final List responses = new ArrayList<>(); - try (JPARuntimeMeasurement meassument = requestContext.getDebugger().newMeasurement(this, "processChangeSet")) { + try (JPARuntimeMeasurement measurement = requestContext.getDebugger().newMeasurement(this, "processChangeSet")) { final JPAODataTransaction t = requestContext.getTransactionFactory().createTransaction(); try { for (final ODataRequest request : requests) { diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/api/JPAODataDefaultTransactionFactory.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/api/JPAODataDefaultTransactionFactory.java index c73b3db1d..fa2838b5d 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/api/JPAODataDefaultTransactionFactory.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/api/JPAODataDefaultTransactionFactory.java @@ -5,9 +5,10 @@ import java.util.Objects; import javax.annotation.Nonnull; -import javax.persistence.EntityManager; -import javax.persistence.EntityTransaction; -import javax.persistence.RollbackException; + +import jakarta.persistence.EntityManager; +import jakarta.persistence.EntityTransaction; +import jakarta.persistence.RollbackException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/api/JPAODataExternalRequestContext.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/api/JPAODataExternalRequestContext.java index 959f2ea85..b2bf19274 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/api/JPAODataExternalRequestContext.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/api/JPAODataExternalRequestContext.java @@ -10,7 +10,8 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; -import javax.persistence.EntityManager; + +import jakarta.persistence.EntityManager; import org.apache.olingo.server.api.debug.DebugSupport; diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/api/JPAODataPage.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/api/JPAODataPage.java index 1cb501a50..8d9803294 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/api/JPAODataPage.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/api/JPAODataPage.java @@ -2,33 +2,4 @@ import org.apache.olingo.server.api.uri.UriInfo; -public class JPAODataPage { - private final int skip; - private final int top; - private final Object skipToken; - private final UriInfo uriInfo; - - public JPAODataPage(final UriInfo uriInfo, final int skip, final int top, final Object skipToken) { - super(); - this.skip = skip; - this.top = top; - this.skipToken = skipToken; - this.uriInfo = uriInfo; - } - - public int getSkip() { - return skip; - } - - public int getTop() { - return top; - } - - public Object getSkipToken() { - return skipToken; - } - - public UriInfo getUriInfo() { - return uriInfo; - } -} +public record JPAODataPage(UriInfo uriInfo, int skip, int top, Object skipToken) {} diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/api/JPAODataPagingProvider.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/api/JPAODataPagingProvider.java index b337f19f5..b6ba58dc0 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/api/JPAODataPagingProvider.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/api/JPAODataPagingProvider.java @@ -1,6 +1,6 @@ package com.sap.olingo.jpa.processor.core.api; -import javax.persistence.EntityManager; +import jakarta.persistence.EntityManager; import org.apache.olingo.server.api.ODataApplicationException; import org.apache.olingo.server.api.uri.UriInfo; @@ -8,7 +8,7 @@ import com.sap.olingo.jpa.processor.core.query.JPACountQuery; /** - * + * * @author Oliver Grande * */ diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/api/JPAODataRequestContext.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/api/JPAODataRequestContext.java index 0bf4e2bbd..c06f55a1f 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/api/JPAODataRequestContext.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/api/JPAODataRequestContext.java @@ -4,7 +4,7 @@ import java.util.Locale; import java.util.Optional; -import javax.persistence.EntityManager; +import jakarta.persistence.EntityManager; import org.apache.olingo.server.api.debug.DebugSupport; diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/api/JPAODataRequestContextAccess.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/api/JPAODataRequestContextAccess.java index a8c451677..81a495cd4 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/api/JPAODataRequestContextAccess.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/api/JPAODataRequestContextAccess.java @@ -6,7 +6,8 @@ import javax.annotation.CheckForNull; import javax.annotation.Nonnull; -import javax.persistence.EntityManager; + +import jakarta.persistence.EntityManager; import org.apache.olingo.server.api.uri.UriInfoResource; diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/api/JPAODataRequestHandler.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/api/JPAODataRequestHandler.java index 215316e1a..7db6b456d 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/api/JPAODataRequestHandler.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/api/JPAODataRequestHandler.java @@ -2,17 +2,19 @@ import java.util.Optional; -import javax.persistence.EntityManager; -import javax.persistence.EntityManagerFactory; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletRequestWrapper; -import javax.servlet.http.HttpServletResponse; +import jakarta.persistence.EntityManager; +import jakarta.persistence.EntityManagerFactory; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletRequestWrapper; +import jakarta.servlet.http.HttpServletResponse; import org.apache.olingo.commons.api.ex.ODataException; import org.apache.olingo.server.api.OData; import org.apache.olingo.server.api.ODataHttpHandler; import com.sap.olingo.jpa.metadata.api.JPAEdmProvider; +import com.sap.olingo.jpa.processor.core.api.mapper.JakartaRequestMapper; +import com.sap.olingo.jpa.processor.core.api.mapper.JakartaResponseMapper; import com.sap.olingo.jpa.processor.core.processor.JPAODataInternalRequestContext; public class JPAODataRequestHandler { @@ -71,7 +73,6 @@ public void process(final HttpServletRequest request, final HttpServletResponse } } - @SuppressWarnings("unchecked") private void processInternal(final HttpServletRequest request, final HttpServletResponse response) throws ODataException { @@ -85,7 +86,7 @@ private void processInternal(final HttpServletRequest request, final HttpServlet handler.register(serviceContext.getEdmProvider().getServiceDocument()); handler.register(serviceContext.getErrorProcessor()); handler.register(new JPAODataServiceDocumentProcessor(serviceContext)); - handler.process(mappedRequest, response); + handler.process(new JakartaRequestMapper(mappedRequest), new JakartaResponseMapper(response)); } private HttpServletRequest prepareRequestMapping(final HttpServletRequest req, final String requestPath) { diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/api/JPAODataRequestProcessor.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/api/JPAODataRequestProcessor.java index 2de6a2212..ba14cbf13 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/api/JPAODataRequestProcessor.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/api/JPAODataRequestProcessor.java @@ -1,7 +1,7 @@ package com.sap.olingo.jpa.processor.core.api; -import javax.persistence.OptimisticLockException; -import javax.persistence.RollbackException; +import jakarta.persistence.OptimisticLockException; +import jakarta.persistence.RollbackException; import org.apache.olingo.commons.api.ex.ODataException; import org.apache.olingo.commons.api.format.ContentType; @@ -117,8 +117,8 @@ public void deleteEntity(final ODataRequest request, final ODataResponse respons .getAllHeaders()); processor.deleteEntity(request, response); } catch (ODataApplicationException | ODataLibraryException e) { - if (e.getCause() instanceof RollbackException) - handleRollbackException((RollbackException) e.getCause()); + if (e.getCause() instanceof final RollbackException rollback) + handleRollbackException(rollback); throw e; } catch (final ODataException e) { throw new ODataApplicationException(e.getLocalizedMessage(), @@ -324,8 +324,8 @@ public void updateEntity(final ODataRequest request, final ODataResponse respons request.getAllHeaders()); processor.updateEntity(request, response, requestFormat, responseFormat); } catch (ODataApplicationException | ODataLibraryException e) { - if (e.getCause() instanceof RollbackException) - handleRollbackException((RollbackException) e.getCause()); + if (e.getCause() instanceof final RollbackException rollback) + handleRollbackException(rollback); throw e; } catch (final ODataException e) { throw new ODataApplicationException(e.getLocalizedMessage(), @@ -435,12 +435,12 @@ public void processActionVoid(final ODataRequest request, final ODataResponse re } private void performCountRequest(final ODataRequest request, final ODataResponse response, final UriInfo uriInfo) - throws ODataApplicationException, ODataLibraryException { + throws ODataApplicationException { try { final JPARequestProcessor processor = factory.createProcessor(uriInfo, ContentType.TEXT_PLAIN, request .getAllHeaders(), requestContext); processor.retrieveData(request, response, ContentType.TEXT_PLAIN); - } catch (ODataApplicationException | ODataLibraryException e) { + } catch (final ODataApplicationException e) { throw e; } catch (final ODataException e) { throw new ODataApplicationException(e.getLocalizedMessage(), @@ -457,8 +457,8 @@ private void performClearFieldsRequest(final ODataRequest request, final ODataRe .getAllHeaders()); processor.clearFields(request, response); } catch (ODataApplicationException | ODataLibraryException e) { - if (e.getCause() instanceof RollbackException) - handleRollbackException((RollbackException) e.getCause()); + if (e.getCause() instanceof final RollbackException rollback) + handleRollbackException(rollback); throw e; } catch (final ODataException e) { throw new ODataApplicationException(e.getLocalizedMessage(), diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/api/JPAODataServiceContext.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/api/JPAODataServiceContext.java index 1c47ca2ff..41ce4577f 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/api/JPAODataServiceContext.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/api/JPAODataServiceContext.java @@ -9,11 +9,12 @@ import java.util.Optional; import javax.annotation.Nonnull; -import javax.persistence.EntityManager; -import javax.persistence.EntityManagerFactory; -import javax.persistence.PersistenceException; import javax.sql.DataSource; +import jakarta.persistence.EntityManager; +import jakarta.persistence.EntityManagerFactory; +import jakarta.persistence.PersistenceException; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.olingo.commons.api.edmx.EdmxReference; diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/api/JPAODataSessionContextAccess.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/api/JPAODataSessionContextAccess.java index 8ad0e4af3..e383b14c2 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/api/JPAODataSessionContextAccess.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/api/JPAODataSessionContextAccess.java @@ -3,7 +3,7 @@ import java.util.List; import java.util.Optional; -import javax.persistence.EntityManagerFactory; +import jakarta.persistence.EntityManagerFactory; import org.apache.olingo.commons.api.edmx.EdmxReference; import org.apache.olingo.commons.api.ex.ODataException; diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/api/JPAODataTransactionFactory.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/api/JPAODataTransactionFactory.java index 11830d41c..46f79855d 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/api/JPAODataTransactionFactory.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/api/JPAODataTransactionFactory.java @@ -1,29 +1,32 @@ package com.sap.olingo.jpa.processor.core.api; -import javax.persistence.RollbackException; +import jakarta.persistence.RollbackException; import com.sap.olingo.jpa.processor.core.exception.ODataJPATransactionException; /** * A wrapper to abstract from various transaction APIs provided by JAVA or e.g. Spring like - * javax.persistence.EntityTransaction, javax.transaction.UserTransaction, javax.transaction.Transaction or - * org.springframework.transaction.jta.JtaTransactionManager.

            - * + * jakarta.persistence.EntityTransaction, javax.transaction.UserTransaction, javax.transaction.Transaction or + * org.springframework.transaction.jta.JtaTransactionManager. + *

            + * * JPA Processor needs to be able to create transactions to be able to handle Change + * href= + * "http://docs.oasis-open.org/odata/odata/v4.0/errata03/os/complete/part1-protocol/odata-v4.0-errata03-os-part1-protocol-complete.html#_Toc453752316">Change * Sets correctly. Each Change Set has to be processed in an own transaction. Please not that the batch processor - * will create a response with http status code 501 Not Implemented in case he cannot create a transaction.

            - * + * will create a response with http status code 501 Not Implemented in case he cannot create a transaction. + *

            + * * In case not TransactionFactory is provided the JPA Processor will create an instance of * {@link JPAODataDefaultTransactionFactory}, which shall be sufficient for most uses cases. - * + * * @author Oliver Grande * Created: 07.10.2019 * */ public interface JPAODataTransactionFactory { /** - * + * * @return a new transaction */ JPAODataTransaction createTransaction() throws ODataJPATransactionException; @@ -33,7 +36,7 @@ public interface JPAODataTransactionFactory { public static interface JPAODataTransaction { /** - * + * * @throws ODataJPATransactionException * @throws RollbackException */ diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/api/example/JPAExampleCUDRequestHandler.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/api/example/JPAExampleCUDRequestHandler.java index 62f7287fd..c9f4830c9 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/api/example/JPAExampleCUDRequestHandler.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/api/example/JPAExampleCUDRequestHandler.java @@ -19,10 +19,10 @@ import java.util.Optional; import java.util.regex.Pattern; -import javax.persistence.EntityManager; -import javax.persistence.GeneratedValue; -import javax.persistence.metamodel.EntityType; -import javax.persistence.metamodel.SingularAttribute; +import jakarta.persistence.EntityManager; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.metamodel.EntityType; +import jakarta.persistence.metamodel.SingularAttribute; import org.apache.olingo.commons.api.http.HttpMethod; import org.apache.olingo.commons.api.http.HttpStatusCode; @@ -178,7 +178,8 @@ private boolean checkAuthorizationsOnePairWithWildcard(final Object value, boole } private void checkAuthorities(final Object instance, final JPAStructuredType entityType, - final Optional claims, final JPAModifyUtil modifyUtility) throws JPAExampleModifyException { + final Optional claims, final JPAModifyUtil modifyUtility) + throws JPAExampleModifyException { try { final List protections = entityType.getProtections(); if (!protections.isEmpty()) { @@ -327,14 +328,13 @@ private void processRelatedEntities(final Map claims, final boolean created) { - if (instance instanceof JPAExampleAuditable) { - final JPAExampleAuditable auditable = (JPAExampleAuditable) instance; + if (instance instanceof final JPAExampleAuditable auditable) { if (created) { auditable.setCreatedAt(now); - claims.ifPresent(c -> auditable.setCreatedBy(c.user().orElse(""))); + claims.ifPresent(claim -> auditable.setCreatedBy(claim.user().orElse(""))); } auditable.setUpdatedAt(now); - claims.ifPresent(c -> auditable.setUpdatedBy(c.user().orElse(""))); + claims.ifPresent(claim -> auditable.setUpdatedBy(claim.user().orElse(""))); } } @@ -358,11 +358,11 @@ private boolean hasGeneratedKey(final JPARequestEntity requestEntity, final Enti .stream() .filter(type -> type.getName().equals(et.getExternalName())) .findFirst() - .map(jpaEt -> hasGeneratedKeyInt(et, jpaEt)) + .map(jpaEt -> hasGeneratedKeyInternal(et, jpaEt)) .orElse(false); } - private boolean hasGeneratedKeyInt(final JPAEntityType et, final EntityType jpaEt) { + private boolean hasGeneratedKeyInternal(final JPAEntityType et, final EntityType jpaEt) { try { if (jpaEt.hasSingleIdAttribute()) { final JPAAttribute key = et.getKey().get(0); diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/api/example/JPAExamplePagingProvider.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/api/example/JPAExamplePagingProvider.java index c03afe446..093ceec73 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/api/example/JPAExamplePagingProvider.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/api/example/JPAExamplePagingProvider.java @@ -6,7 +6,7 @@ import java.util.Queue; import java.util.UUID; -import javax.persistence.EntityManager; +import jakarta.persistence.EntityManager; import org.apache.olingo.server.api.ODataApplicationException; import org.apache.olingo.server.api.uri.UriInfo; @@ -41,14 +41,14 @@ public JPAODataPage getNextPage(final String skipToken) { final CacheEntry previousPage = pageCache.get(skipToken.replace("'", "")); if (previousPage != null) { // Calculate next page - final Integer skip = previousPage.getPage().getSkip() + previousPage.getPage().getTop(); + final Integer skip = previousPage.getPage().skip() + previousPage.getPage().top(); // Create a new skip token if next page is not the last one String nextToken = null; - if (skip + previousPage.getPage().getTop() < previousPage.getMaxTop()) + if (skip + previousPage.getPage().top() < previousPage.getMaxTop()) nextToken = UUID.randomUUID().toString(); - final int top = (int) ((skip + previousPage.getPage().getTop()) < previousPage.getMaxTop() ? previousPage - .getPage().getTop() : previousPage.getMaxTop() - skip); - final JPAODataPage page = new JPAODataPage(previousPage.getPage().getUriInfo(), + final int top = (int) ((skip + previousPage.getPage().top()) < previousPage.getMaxTop() ? previousPage + .getPage().top() : previousPage.getMaxTop() - skip); + final JPAODataPage page = new JPAODataPage(previousPage.getPage().uriInfo(), skip, top, nextToken); if (nextToken != null) addToCache(page, previousPage.getMaxTop()); @@ -64,9 +64,9 @@ public JPAODataPage getFirstPage(final UriInfo uriInfo, final Integer preferredP final UriResource root = uriInfo.getUriResourceParts().get(0); // Paging will only be done for Entity Sets - if (root instanceof UriResourceEntitySet) { + if (root instanceof final UriResourceEntitySet entitySet) { // Check if Entity Set shall be packaged - final Integer maxSize = maxPageSizes.get(((UriResourceEntitySet) root).getEntitySet().getName()); + final Integer maxSize = maxPageSizes.get(entitySet.getEntitySet().getName()); if (maxSize != null) { // Read $top and $skip final Integer skipValue = uriInfo.getSkipOption() != null ? uriInfo.getSkipOption().getValue() : 0; @@ -95,8 +95,8 @@ private void addToCache(final JPAODataPage page, final Long count) { if (pageCache.size() == cacheSize) pageCache.remove(index.poll()); - pageCache.put((String) page.getSkipToken(), new CacheEntry(count, page)); - index.add((String) page.getSkipToken()); + pageCache.put((String) page.skipToken(), new CacheEntry(count, page)); + index.add((String) page.skipToken()); } private static class CacheEntry { diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/api/mapper/JakartaRequestMapper.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/api/mapper/JakartaRequestMapper.java new file mode 100644 index 000000000..34224f2ee --- /dev/null +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/api/mapper/JakartaRequestMapper.java @@ -0,0 +1,395 @@ +package com.sap.olingo.jpa.processor.core.api.mapper; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.security.Principal; +import java.util.Collection; +import java.util.Enumeration; +import java.util.Locale; +import java.util.Map; +import java.util.Objects; + +import javax.annotation.Nonnull; +import javax.servlet.AsyncContext; +import javax.servlet.DispatcherType; +import javax.servlet.RequestDispatcher; +import javax.servlet.ServletContext; +import javax.servlet.ServletException; +import javax.servlet.ServletInputStream; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; +import javax.servlet.http.Cookie; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; +import javax.servlet.http.Part; + +import jakarta.servlet.http.HttpServletRequest; + +public class JakartaRequestMapper implements javax.servlet.http.HttpServletRequest { + + private final HttpServletRequest jakartaRequest; + + public JakartaRequestMapper(@Nonnull final HttpServletRequest jakartaRequest) { + super(); + this.jakartaRequest = Objects.requireNonNull(jakartaRequest); + } + + @Override + public Object getAttribute(final String name) { + return jakartaRequest.getAttribute(name); + } + + @Override + public Enumeration getAttributeNames() { + return jakartaRequest.getAttributeNames(); + } + + @Override + public String getCharacterEncoding() { + return jakartaRequest.getCharacterEncoding(); + } + + @Override + public void setCharacterEncoding(final String env) throws UnsupportedEncodingException { + jakartaRequest.setCharacterEncoding(env); + } + + @Override + public int getContentLength() { + return jakartaRequest.getContentLength(); + } + + @Override + public String getContentType() { + return jakartaRequest.getContentType(); + } + + @Override + public ServletInputStream getInputStream() throws IOException { + return new JakartaServletInputStream(jakartaRequest.getInputStream()); + } + + @Override + public String getParameter(final String name) { + return jakartaRequest.getParameter(name); + } + + @Override + public Enumeration getParameterNames() { + return jakartaRequest.getParameterNames(); + } + + @Override + public String[] getParameterValues(final String name) { + return jakartaRequest.getParameterValues(name); + } + + @Override + public Map getParameterMap() { + return jakartaRequest.getParameterMap(); + } + + @Override + public String getProtocol() { + return jakartaRequest.getProtocol(); + } + + @Override + public String getScheme() { + return jakartaRequest.getScheme(); + } + + @Override + public String getServerName() { + return jakartaRequest.getServerName(); + } + + @Override + public int getServerPort() { + return jakartaRequest.getServerPort(); + } + + @Override + public BufferedReader getReader() throws IOException { + return jakartaRequest.getReader(); + } + + @Override + public String getRemoteAddr() { + return jakartaRequest.getRemoteAddr(); + } + + @Override + public String getRemoteHost() { + return jakartaRequest.getRemoteHost(); + } + + @Override + public void setAttribute(final String name, final Object o) { + jakartaRequest.setAttribute(name, o); + } + + @Override + public void removeAttribute(final String name) { + jakartaRequest.removeAttribute(name); + } + + @Override + public Locale getLocale() { + return jakartaRequest.getLocale(); + } + + @Override + public Enumeration getLocales() { + return jakartaRequest.getLocales(); + } + + @Override + public boolean isSecure() { + return jakartaRequest.isSecure(); + } + + @Override + public RequestDispatcher getRequestDispatcher(final String path) { + throw new IllegalAccessError(); + } + + @Override + public String getRealPath(final String path) { + throw new IllegalAccessError(); + } + + @Override + public int getRemotePort() { + return jakartaRequest.getRemotePort(); + } + + @Override + public String getLocalName() { + return jakartaRequest.getLocalName(); + } + + @Override + public String getLocalAddr() { + + return jakartaRequest.getLocalAddr(); + } + + @Override + public int getLocalPort() { + return jakartaRequest.getLocalPort(); + } + + @Override + public ServletContext getServletContext() { + throw new IllegalAccessError(); + } + + @Override + public AsyncContext startAsync() throws IllegalStateException { + throw new IllegalAccessError(); + } + + @Override + public AsyncContext startAsync(final ServletRequest servletRequest, final ServletResponse servletResponse) + throws IllegalStateException { + throw new IllegalAccessError(); + } + + @Override + public boolean isAsyncStarted() { + return jakartaRequest.isAsyncStarted(); + } + + @Override + public boolean isAsyncSupported() { + return jakartaRequest.isAsyncSupported(); + } + + @Override + public AsyncContext getAsyncContext() { + throw new IllegalAccessError(); + } + + @Override + public DispatcherType getDispatcherType() { + throw new IllegalAccessError(); + } + + @Override + public String getAuthType() { + return jakartaRequest.getAuthType(); + } + + @Override + public Cookie[] getCookies() { + final Cookie[] cookies = new Cookie[jakartaRequest.getCookies().length]; + for (int i = 0; i < jakartaRequest.getCookies().length; i++) { + final Cookie cookie = new Cookie(jakartaRequest.getCookies()[i].getName(), jakartaRequest.getCookies()[i] + .getValue()); + cookie.setHttpOnly(jakartaRequest.getCookies()[i].isHttpOnly()); + cookie.setSecure(jakartaRequest.getCookies()[i].getSecure()); + cookie.setComment(jakartaRequest.getCookies()[i].getComment()); + cookie.setDomain(jakartaRequest.getCookies()[i].getDomain()); + cookie.setMaxAge(jakartaRequest.getCookies()[i].getMaxAge()); + cookie.setPath(jakartaRequest.getCookies()[i].getPath()); + cookie.setVersion(jakartaRequest.getCookies()[i].getVersion()); + cookies[i] = cookie; + } + return cookies; + } + + @Override + public long getDateHeader(final String name) { + return jakartaRequest.getDateHeader(name); + } + + @Override + public String getHeader(final String name) { + return jakartaRequest.getHeader(name); + } + + @Override + public Enumeration getHeaders(final String name) { + return jakartaRequest.getHeaders(name); + } + + @Override + public Enumeration getHeaderNames() { + return jakartaRequest.getHeaderNames(); + } + + @Override + public int getIntHeader(final String name) { + return jakartaRequest.getIntHeader(name); + } + + @Override + public String getMethod() { + return jakartaRequest.getMethod(); + } + + @Override + public String getPathInfo() { + return jakartaRequest.getPathInfo(); + } + + @Override + public String getPathTranslated() { + return jakartaRequest.getPathTranslated(); + } + + @Override + public String getContextPath() { + return jakartaRequest.getContextPath(); + } + + @Override + public String getQueryString() { + return jakartaRequest.getQueryString(); + } + + @Override + public String getRemoteUser() { + return jakartaRequest.getRemoteUser(); + } + + @Override + public boolean isUserInRole(final String role) { + return jakartaRequest.isUserInRole(role); + } + + @Override + public Principal getUserPrincipal() { + return jakartaRequest.getUserPrincipal(); + } + + @Override + public String getRequestedSessionId() { + //Fix sonar issue. OData does not care about session handling + return null; + } + + @Override + public String getRequestURI() { + return jakartaRequest.getRequestURI(); + } + + @Override + public StringBuffer getRequestURL() { + return jakartaRequest.getRequestURL(); + } + + @Override + public String getServletPath() { + return jakartaRequest.getServletPath(); + } + + @Override + public HttpSession getSession(final boolean create) { + throw new IllegalAccessError(); + } + + @Override + public HttpSession getSession() { + throw new IllegalAccessError(); + } + + @Override + public boolean isRequestedSessionIdValid() { + return jakartaRequest.isRequestedSessionIdValid(); + } + + @Override + public boolean isRequestedSessionIdFromCookie() { + return jakartaRequest.isRequestedSessionIdFromCookie(); + } + + @Override + public boolean isRequestedSessionIdFromURL() { + return jakartaRequest.isRequestedSessionIdFromURL(); + } + + @Override + public boolean isRequestedSessionIdFromUrl() { + return jakartaRequest.isRequestedSessionIdFromURL(); + } + + @Override + public boolean authenticate(final HttpServletResponse response) throws IOException, ServletException { + return false; + } + + @Override + public void login(final String userName, final String password) throws ServletException { + try { + jakartaRequest.login(userName, password); + } catch (final jakarta.servlet.ServletException e) { + throw new ServletException(e); + } + } + + @Override + public void logout() throws ServletException { + try { + jakartaRequest.logout(); + } catch (final jakarta.servlet.ServletException e) { + throw new ServletException(e); + } + } + + @Override + public Collection getParts() throws IOException, ServletException { + throw new IllegalAccessError(); + } + + @Override + public Part getPart(final String name) throws IOException, ServletException { + throw new IllegalAccessError(); + } + + public HttpServletRequest getWrapped() { + return jakartaRequest; + } +} diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/api/mapper/JakartaResponseMapper.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/api/mapper/JakartaResponseMapper.java new file mode 100644 index 000000000..3c9af8dc5 --- /dev/null +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/api/mapper/JakartaResponseMapper.java @@ -0,0 +1,211 @@ +package com.sap.olingo.jpa.processor.core.api.mapper; + +import java.io.IOException; +import java.io.PrintWriter; +import java.util.Collection; +import java.util.Locale; + +import javax.servlet.ServletOutputStream; +import javax.servlet.http.Cookie; +import javax.servlet.http.HttpServletResponse; + +public class JakartaResponseMapper implements HttpServletResponse { + + private final jakarta.servlet.http.HttpServletResponse jakartaResponse; + + public JakartaResponseMapper(final jakarta.servlet.http.HttpServletResponse response) { + this.jakartaResponse = response; + } + + @Override + public String getCharacterEncoding() { + return jakartaResponse.getCharacterEncoding(); + } + + @Override + public String getContentType() { + return jakartaResponse.getContentType(); + } + + @Override + public ServletOutputStream getOutputStream() throws IOException { + return new JakartaServletOutputStream(jakartaResponse.getOutputStream()); + } + + @Override + public PrintWriter getWriter() throws IOException { + return jakartaResponse.getWriter(); + } + + @Override + public void setCharacterEncoding(final String charset) { + jakartaResponse.setCharacterEncoding(charset); + } + + @Override + public void setContentLength(final int len) { + jakartaResponse.setContentLength(len); + } + + @Override + public void setContentType(final String type) { + jakartaResponse.setContentType(type); + } + + @Override + public void setBufferSize(final int size) { + jakartaResponse.setBufferSize(size); + } + + @Override + public int getBufferSize() { + return jakartaResponse.getBufferSize(); + } + + @Override + public void flushBuffer() throws IOException { + jakartaResponse.flushBuffer(); + } + + @Override + public void resetBuffer() { + jakartaResponse.resetBuffer(); + } + + @Override + public boolean isCommitted() { + return jakartaResponse.isCommitted(); + } + + @Override + public void reset() { + jakartaResponse.reset(); + } + + @Override + public void setLocale(final Locale loc) { + jakartaResponse.setLocale(loc); + } + + @Override + public Locale getLocale() { + return jakartaResponse.getLocale(); + } + + @SuppressWarnings("removal") + @Override + public void addCookie(final Cookie cookie) { + final jakarta.servlet.http.Cookie newCookie = + new jakarta.servlet.http.Cookie(cookie.getName(), cookie.getValue()); + + newCookie.setHttpOnly(cookie.isHttpOnly()); + newCookie.setSecure(cookie.getSecure()); + newCookie.setComment(cookie.getComment()); + newCookie.setDomain(cookie.getDomain()); + newCookie.setMaxAge(cookie.getMaxAge()); + newCookie.setPath(cookie.getPath()); + newCookie.setVersion(cookie.getVersion()); + jakartaResponse.addCookie(newCookie); + } + + @Override + public boolean containsHeader(final String name) { + return jakartaResponse.containsHeader(name); + } + + @Override + public String encodeURL(final String url) { + return jakartaResponse.encodeURL(url); + } + + @Override + public String encodeRedirectURL(final String url) { + return jakartaResponse.encodeRedirectURL(url); + } + + @Override + public String encodeUrl(final String url) { + return jakartaResponse.encodeURL(url); + } + + @Override + public String encodeRedirectUrl(final String url) { + return jakartaResponse.encodeRedirectURL(url); + } + + @Override + public void sendError(final int sc, final String msg) throws IOException { + jakartaResponse.sendError(sc, msg); + } + + @Override + public void sendError(final int sc) throws IOException { + jakartaResponse.sendError(sc); + } + + @Override + public void sendRedirect(final String location) throws IOException { + jakartaResponse.sendRedirect(location); + } + + @Override + public void setDateHeader(final String name, final long date) { + jakartaResponse.setDateHeader(name, date); + } + + @Override + public void addDateHeader(final String name, final long date) { + jakartaResponse.addDateHeader(name, date); + } + + @Override + public void setHeader(final String name, final String value) { + jakartaResponse.setHeader(name, value); + } + + @Override + public void addHeader(final String name, final String value) { + jakartaResponse.addHeader(name, value); + } + + @Override + public void setIntHeader(final String name, final int value) { + jakartaResponse.setIntHeader(name, value); + } + + @Override + public void addIntHeader(final String name, final int value) { + jakartaResponse.addIntHeader(name, value); + } + + @Override + public void setStatus(final int status) { + jakartaResponse.setStatus(status); + } + + @Override + public void setStatus(final int status, final String message) { + jakartaResponse.setStatus(status); + } + + @Override + public int getStatus() { + return jakartaResponse.getStatus(); + } + + @Override + public String getHeader(final String name) { + return jakartaResponse.getHeader(name); + } + + @Override + public Collection getHeaders(final String name) { + return jakartaResponse.getHeaders(name); + } + + @Override + public Collection getHeaderNames() { + return jakartaResponse.getHeaderNames(); + } + +} diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/api/mapper/JakartaServletInputStream.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/api/mapper/JakartaServletInputStream.java new file mode 100644 index 000000000..ed214afbb --- /dev/null +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/api/mapper/JakartaServletInputStream.java @@ -0,0 +1,24 @@ +package com.sap.olingo.jpa.processor.core.api.mapper; + +import java.io.IOException; + +import javax.servlet.ServletInputStream; + +public class JakartaServletInputStream extends ServletInputStream { + private final jakarta.servlet.ServletInputStream inputStream; + + public JakartaServletInputStream(final jakarta.servlet.ServletInputStream inputStream) { + this.inputStream = inputStream; + } + + @Override + public int read() throws IOException { + return inputStream.read(); + } + + @Override + public int readLine(final byte[] b, final int off, final int len) throws IOException { + return inputStream.readLine(b, off, len); + } + +} diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/api/mapper/JakartaServletOutputStream.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/api/mapper/JakartaServletOutputStream.java new file mode 100644 index 000000000..169090ca6 --- /dev/null +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/api/mapper/JakartaServletOutputStream.java @@ -0,0 +1,24 @@ +package com.sap.olingo.jpa.processor.core.api.mapper; + +import java.io.IOException; + +import javax.servlet.ServletOutputStream; + +public class JakartaServletOutputStream extends ServletOutputStream { + + private final jakarta.servlet.ServletOutputStream jakartaOutputStream; + + public JakartaServletOutputStream(final jakarta.servlet.ServletOutputStream outputStream) { + this.jakartaOutputStream = outputStream; + } + + @Override + public void write(final int b) throws IOException { + jakartaOutputStream.write(b); + } + + @Override + public void print(final String s) throws IOException { + jakartaOutputStream.print(s); + } +} diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/converter/JPAExpandResult.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/converter/JPAExpandResult.java index dccc9bc75..5107d5ca8 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/converter/JPAExpandResult.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/converter/JPAExpandResult.java @@ -5,7 +5,8 @@ import javax.annotation.CheckForNull; import javax.annotation.Nonnull; -import javax.persistence.Tuple; + +import jakarta.persistence.Tuple; import org.apache.olingo.server.api.ODataApplicationException; diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/converter/JPAStructuredResultConverter.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/converter/JPAStructuredResultConverter.java index c31820be8..8cfc20a29 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/converter/JPAStructuredResultConverter.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/converter/JPAStructuredResultConverter.java @@ -10,7 +10,7 @@ import java.util.List; import java.util.Map; -import javax.persistence.AttributeConverter; +import jakarta.persistence.AttributeConverter; import org.apache.olingo.commons.api.data.ComplexValue; import org.apache.olingo.commons.api.data.Property; diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/converter/JPATuple.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/converter/JPATuple.java index 4de2000e6..698ffda01 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/converter/JPATuple.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/converter/JPATuple.java @@ -5,16 +5,16 @@ import java.util.List; import java.util.Map; -import javax.persistence.Tuple; -import javax.persistence.TupleElement; +import jakarta.persistence.Tuple; +import jakarta.persistence.TupleElement; public final class JPATuple implements Tuple { - private List> elements = new ArrayList<>(); - private Map values = new HashMap<>(); + private final List> elements = new ArrayList<>(); + private final Map values = new HashMap<>(); - public void addElement(final String alias, Class javaType, final Object value) { - elements.add(new JPATupleElement(alias, javaType)); + public void addElement(final String alias, final Class javaType, final Object value) { + elements.add(new JPATupleElement<>(alias, javaType)); values.put(alias, value); } @@ -66,15 +66,7 @@ public Object[] toArray() { return new Object[] {}; } - private static class JPATupleElement implements TupleElement { - - private final String alias; - private final Class javaType; - - public JPATupleElement(final String alias, final Class javaType) { - this.alias = alias; - this.javaType = javaType; - } + private static record JPATupleElement(String alias, Class javaType) implements TupleElement { @Override public String getAlias() { diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/converter/JPATupleChildConverter.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/converter/JPATupleChildConverter.java index 825c77593..72f45305a 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/converter/JPATupleChildConverter.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/converter/JPATupleChildConverter.java @@ -11,7 +11,8 @@ import java.util.Optional; import javax.annotation.Nonnull; -import javax.persistence.Tuple; + +import jakarta.persistence.Tuple; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -96,7 +97,7 @@ public Map getResult(@Nonnull final JPAExpandResult jp } result.put(tuple.getKey(), entityCollection); } - childResult.replaceAll((k, v) -> null); + childResult.replaceAll((key, value) -> null); return result; } @@ -191,17 +192,16 @@ private List findOrCreateComplexProperty(List result, final } } if (!found - && pathElement instanceof JPAAttribute - && ((JPAAttribute) pathElement).isComplex() - && !((JPAAttribute) pathElement).isCollection()) { - final JPAAttribute a = (JPAAttribute) pathElement; - final Property p = new Property( - a.getStructuredType().getExternalFQN().getFullQualifiedNameAsString(), - a.getExternalName(), + && pathElement instanceof final JPAAttribute attribute + && attribute.isComplex() + && !attribute.isCollection()) { + final Property path = new Property( + attribute.getStructuredType().getExternalFQN().getFullQualifiedNameAsString(), + attribute.getExternalName(), ValueType.COMPLEX, new ComplexValue()); - result.add(p); - result = ((ComplexValue) p.getValue()).getValue(); + result.add(path); + result = ((ComplexValue) path.getValue()).getValue(); } return result; } diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/converter/JPATupleCollectionConverter.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/converter/JPATupleCollectionConverter.java index a9f765003..58c7d34c0 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/converter/JPATupleCollectionConverter.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/converter/JPATupleCollectionConverter.java @@ -9,9 +9,9 @@ import java.util.Map.Entry; import java.util.Optional; -import javax.persistence.AttributeConverter; -import javax.persistence.Tuple; -import javax.persistence.TupleElement; +import jakarta.persistence.AttributeConverter; +import jakarta.persistence.Tuple; +import jakarta.persistence.TupleElement; import org.apache.olingo.commons.api.data.ComplexValue; import org.apache.olingo.commons.api.http.HttpStatusCode; diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/converter/JPATupleResultConverter.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/converter/JPATupleResultConverter.java index b5758e499..6a134a447 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/converter/JPATupleResultConverter.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/converter/JPATupleResultConverter.java @@ -8,9 +8,10 @@ import java.util.Optional; import javax.annotation.Nullable; -import javax.persistence.AttributeConverter; -import javax.persistence.Tuple; -import javax.persistence.TupleElement; + +import jakarta.persistence.AttributeConverter; +import jakarta.persistence.Tuple; +import jakarta.persistence.TupleElement; import org.apache.olingo.commons.api.Constants; import org.apache.olingo.commons.api.data.ComplexValue; diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/database/JPAAbstractDatabaseProcessor.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/database/JPAAbstractDatabaseProcessor.java index 846d53ae4..f540246bd 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/database/JPAAbstractDatabaseProcessor.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/database/JPAAbstractDatabaseProcessor.java @@ -7,8 +7,8 @@ import java.util.List; -import javax.persistence.EntityManager; -import javax.persistence.Query; +import jakarta.persistence.EntityManager; +import jakarta.persistence.Query; import org.apache.olingo.commons.api.edm.EdmElement; import org.apache.olingo.commons.api.edm.EdmFunction; diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/database/JPADefaultDatabaseProcessor.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/database/JPADefaultDatabaseProcessor.java index 2111489f7..7aa36a7b4 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/database/JPADefaultDatabaseProcessor.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/database/JPADefaultDatabaseProcessor.java @@ -5,11 +5,11 @@ import java.util.ArrayList; import java.util.List; -import javax.persistence.EntityManager; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.CriteriaQuery; -import javax.persistence.criteria.Expression; -import javax.persistence.criteria.From; +import jakarta.persistence.EntityManager; +import jakarta.persistence.criteria.CriteriaBuilder; +import jakarta.persistence.criteria.CriteriaQuery; +import jakarta.persistence.criteria.Expression; +import jakarta.persistence.criteria.From; import org.apache.olingo.commons.api.http.HttpStatusCode; import org.apache.olingo.server.api.ODataApplicationException; @@ -92,7 +92,7 @@ public Expression convert(final JPAUnaryBooleanOperator jpaOperator) th @Override public Expression createSearchWhereClause(final CriteriaBuilder cb, final CriteriaQuery cq, - From root, final JPAEntityType entityType, final SearchOption searchOption) + final From root, final JPAEntityType entityType, final SearchOption searchOption) throws ODataApplicationException { throw new ODataJPADBAdaptorException(ODataJPADBAdaptorException.MessageKeys.NOT_SUPPORTED_SEARCH, HttpStatusCode.NOT_IMPLEMENTED); diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/database/JPAODataDatabaseOperations.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/database/JPAODataDatabaseOperations.java index b9cc99f4a..5660a280d 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/database/JPAODataDatabaseOperations.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/database/JPAODataDatabaseOperations.java @@ -1,7 +1,7 @@ package com.sap.olingo.jpa.processor.core.database; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.Expression; +import jakarta.persistence.criteria.CriteriaBuilder; +import jakarta.persistence.criteria.Expression; import org.apache.olingo.server.api.ODataApplicationException; diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/database/JPAODataDatabaseSearch.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/database/JPAODataDatabaseSearch.java index 3f942c95a..c065746f7 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/database/JPAODataDatabaseSearch.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/database/JPAODataDatabaseSearch.java @@ -1,9 +1,9 @@ package com.sap.olingo.jpa.processor.core.database; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.CriteriaQuery; -import javax.persistence.criteria.Expression; -import javax.persistence.criteria.From; +import jakarta.persistence.criteria.CriteriaBuilder; +import jakarta.persistence.criteria.CriteriaQuery; +import jakarta.persistence.criteria.Expression; +import jakarta.persistence.criteria.From; import org.apache.olingo.server.api.ODataApplicationException; import org.apache.olingo.server.api.uri.queryoption.SearchOption; @@ -13,10 +13,12 @@ public interface JPAODataDatabaseSearch { /** * Search implemented differently in various databases, so a database specific implementation needs to be provided. - * For details about search at OData see:

            + * For details about search at OData see: + *

            * - * OData Version 4.0 Part 1 - 11.2.5.6 System Query Option $search

            + * OData Version 4.0 Part 1 - 11.2.5.6 System Query Option $search + *

            * * OData Version 4.0 Part 2 - 5.1.7 System Query Option $search diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/database/JPAODataDatabaseTableFunction.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/database/JPAODataDatabaseTableFunction.java index 88ace959a..8c6fbf874 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/database/JPAODataDatabaseTableFunction.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/database/JPAODataDatabaseTableFunction.java @@ -2,7 +2,7 @@ import java.util.List; -import javax.persistence.EntityManager; +import jakarta.persistence.EntityManager; import org.apache.olingo.server.api.ODataApplicationException; import org.apache.olingo.server.api.uri.UriResource; diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/database/JPA_DERBY_DatabaseProcessor.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/database/JPA_DERBY_DatabaseProcessor.java index 5ee59d95d..4ebc1e1e0 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/database/JPA_DERBY_DatabaseProcessor.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/database/JPA_DERBY_DatabaseProcessor.java @@ -5,11 +5,11 @@ import java.util.ArrayList; import java.util.List; -import javax.persistence.EntityManager; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.CriteriaQuery; -import javax.persistence.criteria.Expression; -import javax.persistence.criteria.From; +import jakarta.persistence.EntityManager; +import jakarta.persistence.criteria.CriteriaBuilder; +import jakarta.persistence.criteria.CriteriaQuery; +import jakarta.persistence.criteria.Expression; +import jakarta.persistence.criteria.From; import org.apache.olingo.commons.api.http.HttpStatusCode; import org.apache.olingo.server.api.ODataApplicationException; diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/database/JPA_HSQLDB_DatabaseProcessor.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/database/JPA_HSQLDB_DatabaseProcessor.java index 8426c6960..84b5358f9 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/database/JPA_HSQLDB_DatabaseProcessor.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/database/JPA_HSQLDB_DatabaseProcessor.java @@ -5,11 +5,11 @@ import java.util.ArrayList; import java.util.List; -import javax.persistence.EntityManager; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.CriteriaQuery; -import javax.persistence.criteria.Expression; -import javax.persistence.criteria.From; +import jakarta.persistence.EntityManager; +import jakarta.persistence.criteria.CriteriaBuilder; +import jakarta.persistence.criteria.CriteriaQuery; +import jakarta.persistence.criteria.Expression; +import jakarta.persistence.criteria.From; import org.apache.olingo.commons.api.http.HttpStatusCode; import org.apache.olingo.server.api.ODataApplicationException; diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/database/JPA_POSTSQL_DatabaseProcessor.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/database/JPA_POSTSQL_DatabaseProcessor.java index b68d95899..d0ccede8b 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/database/JPA_POSTSQL_DatabaseProcessor.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/database/JPA_POSTSQL_DatabaseProcessor.java @@ -5,11 +5,11 @@ import java.util.ArrayList; import java.util.List; -import javax.persistence.EntityManager; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.CriteriaQuery; -import javax.persistence.criteria.Expression; -import javax.persistence.criteria.From; +import jakarta.persistence.EntityManager; +import jakarta.persistence.criteria.CriteriaBuilder; +import jakarta.persistence.criteria.CriteriaQuery; +import jakarta.persistence.criteria.Expression; +import jakarta.persistence.criteria.From; import org.apache.olingo.commons.api.http.HttpStatusCode; import org.apache.olingo.server.api.ODataApplicationException; @@ -24,7 +24,7 @@ /** * Sample implementation a database processor for PostgreSQL - * + * * @author Oliver Grande * Created: 04.07.2019 * diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/exception/ODataJPAQueryException.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/exception/ODataJPAQueryException.java index 8b38dd9c9..422253cb1 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/exception/ODataJPAQueryException.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/exception/ODataJPAQueryException.java @@ -34,6 +34,7 @@ public enum MessageKeys implements ODataJPAMessageKey { QUERY_PREPARATION_NOT_IMPLEMENTED, QUERY_PREPARATION_NOT_ALLOWED_MEMBER, QUERY_PREPARATION_ORDER_BY_TRANSIENT, + QUERY_PREPARATION_ORDER_BY_NOT_SUPPORTED, QUERY_PREPARATION_JOIN_TABLE_TYPE_MISSING, NOT_SUPPORTED_RESOURCE_TYPE, MISSING_CLAIMS_PROVIDER, diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPAAggregationOperationImp.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPAAggregationOperationImp.java index c7f888b97..79babb57a 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPAAggregationOperationImp.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPAAggregationOperationImp.java @@ -1,7 +1,7 @@ package com.sap.olingo.jpa.processor.core.filter; -import javax.persistence.criteria.Expression; -import javax.persistence.criteria.From; +import jakarta.persistence.criteria.Expression; +import jakarta.persistence.criteria.From; import org.apache.olingo.server.api.ODataApplicationException; diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPAArithmeticOperator.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPAArithmeticOperator.java index 27832efd8..686a437aa 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPAArithmeticOperator.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPAArithmeticOperator.java @@ -1,7 +1,7 @@ package com.sap.olingo.jpa.processor.core.filter; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.Expression; +import jakarta.persistence.criteria.CriteriaBuilder; +import jakarta.persistence.criteria.Expression; import org.apache.olingo.server.api.ODataApplicationException; import org.apache.olingo.server.api.uri.queryoption.expression.BinaryOperatorKind; diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPAArithmeticOperatorImp.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPAArithmeticOperatorImp.java index eb0a11c9a..5d8c10cfa 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPAArithmeticOperatorImp.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPAArithmeticOperatorImp.java @@ -1,7 +1,7 @@ package com.sap.olingo.jpa.processor.core.filter; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.Expression; +import jakarta.persistence.criteria.CriteriaBuilder; +import jakarta.persistence.criteria.Expression; import org.apache.olingo.commons.api.http.HttpStatusCode; import org.apache.olingo.server.api.ODataApplicationException; @@ -26,7 +26,7 @@ public JPAArithmeticOperatorImp(final JPAOperationConverter converter, final Bin /* * (non-Javadoc) - * + * * @see com.sap.olingo.jpa.processor.core.filter.JPAArithmeticOperator#get() */ @Override @@ -36,7 +36,7 @@ public Expression get() throws ODataApplicationException { /* * (non-Javadoc) - * + * * @see com.sap.olingo.jpa.processor.core.filter.JPAArithmeticOperator#getOperator() */ @Override @@ -46,7 +46,7 @@ public BinaryOperatorKind getOperator() { /* * (non-Javadoc) - * + * * @see com.sap.olingo.jpa.processor.core.filter.JPAArithmeticOperator#getRight() */ @Override @@ -58,8 +58,8 @@ public Object getRight() { /* * (non-Javadoc) - * - * @see com.sap.olingo.jpa.processor.core.filter.JPAArithmeticOperator#getLeft(javax.persistence.criteria. + * + * @see com.sap.olingo.jpa.processor.core.filter.JPAArithmeticOperator#getLeft(jakarta.persistence.criteria. * CriteriaBuilder) */ @Override @@ -76,8 +76,8 @@ public Expression getLeft(final CriteriaBuilder cb) throws ODataApplicat /* * (non-Javadoc) - * - * @see com.sap.olingo.jpa.processor.core.filter.JPAArithmeticOperator#getRightAsNumber(javax.persistence.criteria. + * + * @see com.sap.olingo.jpa.processor.core.filter.JPAArithmeticOperator#getRightAsNumber(jakarta.persistence.criteria. * CriteriaBuilder) */ @Override @@ -113,7 +113,7 @@ else if (right instanceof JPAMemberOperator) /* * (non-Javadoc) - * + * * @see com.sap.olingo.jpa.processor.core.filter.JPAArithmeticOperator#getRightAsExpression() */ @Override @@ -124,7 +124,7 @@ public Expression getRightAsExpression() throws ODataApplicationExceptio /* * (non-Javadoc) - * + * * @see com.sap.olingo.jpa.processor.core.filter.JPAArithmeticOperator#getLeftAsIntExpression() */ @Override @@ -137,7 +137,7 @@ public Expression getLeftAsIntExpression() throws ODataApplicationExcep /* * (non-Javadoc) - * + * * @see com.sap.olingo.jpa.processor.core.filter.JPAArithmeticOperator#getRightAsIntExpression() */ @Override diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPABooleanOperator.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPABooleanOperator.java index c427141be..49fc785b5 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPABooleanOperator.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPABooleanOperator.java @@ -1,6 +1,6 @@ package com.sap.olingo.jpa.processor.core.filter; -import javax.persistence.criteria.Expression; +import jakarta.persistence.criteria.Expression; import org.apache.olingo.server.api.ODataApplicationException; diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPABooleanOperatorImp.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPABooleanOperatorImp.java index bcf41eaa9..d09fc0b93 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPABooleanOperatorImp.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPABooleanOperatorImp.java @@ -1,6 +1,6 @@ package com.sap.olingo.jpa.processor.core.filter; -import javax.persistence.criteria.Expression; +import jakarta.persistence.criteria.Expression; import org.apache.olingo.server.api.ODataApplicationException; import org.apache.olingo.server.api.uri.queryoption.expression.BinaryOperatorKind; @@ -23,7 +23,7 @@ public JPABooleanOperatorImp(final JPAOperationConverter converter, final Binary /* * (non-Javadoc) - * + * * @see com.sap.olingo.jpa.processor.core.filter.JPABooleanOperator#get() */ @Override @@ -33,7 +33,7 @@ public Expression get() throws ODataApplicationException { /* * (non-Javadoc) - * + * * @see com.sap.olingo.jpa.processor.core.filter.JPABooleanOperator#getOperator() */ @SuppressWarnings("unchecked") @@ -44,7 +44,7 @@ public BinaryOperatorKind getOperator() { /* * (non-Javadoc) - * + * * @see com.sap.olingo.jpa.processor.core.filter.JPABooleanOperator#getLeft() */ @Override @@ -54,7 +54,7 @@ public Expression getLeft() throws ODataApplicationException { /* * (non-Javadoc) - * + * * @see com.sap.olingo.jpa.processor.core.filter.JPABooleanOperator#getRight() */ @Override diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPAComparisonOperator.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPAComparisonOperator.java index b3142f4ea..3003ec42e 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPAComparisonOperator.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPAComparisonOperator.java @@ -1,6 +1,6 @@ package com.sap.olingo.jpa.processor.core.filter; -import javax.persistence.criteria.Expression; +import jakarta.persistence.criteria.Expression; import org.apache.olingo.server.api.ODataApplicationException; diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPAComparisonOperatorImp.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPAComparisonOperatorImp.java index 153242eea..3726e3530 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPAComparisonOperatorImp.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPAComparisonOperatorImp.java @@ -1,6 +1,6 @@ package com.sap.olingo.jpa.processor.core.filter; -import javax.persistence.criteria.Expression; +import jakarta.persistence.criteria.Expression; import org.apache.olingo.server.api.ODataApplicationException; import org.apache.olingo.server.api.uri.queryoption.expression.BinaryOperatorKind; diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPADBFunctionOperator.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPADBFunctionOperator.java index dd2b7e41f..0671e50e4 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPADBFunctionOperator.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPADBFunctionOperator.java @@ -4,8 +4,8 @@ import java.util.List; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.Expression; +import jakarta.persistence.criteria.CriteriaBuilder; +import jakarta.persistence.criteria.Expression; import org.apache.olingo.commons.api.edm.EdmType; import org.apache.olingo.commons.api.http.HttpStatusCode; @@ -105,14 +105,7 @@ public String getName() { return jpaFunction.getDBName(); } - private class ParameterLiteral implements Literal { - - public ParameterLiteral(final String text) { - super(); - this.text = text; - } - - private final String text; + private record ParameterLiteral(String text) implements Literal { @Override public T accept(final ExpressionVisitor visitor) throws ExpressionVisitException, ODataApplicationException { diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPAExistsOperation.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPAExistsOperation.java index 315d54d00..b3ace6741 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPAExistsOperation.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPAExistsOperation.java @@ -4,10 +4,10 @@ import java.util.List; import java.util.Optional; -import javax.persistence.EntityManager; -import javax.persistence.criteria.Expression; -import javax.persistence.criteria.From; -import javax.persistence.criteria.Subquery; +import jakarta.persistence.EntityManager; +import jakarta.persistence.criteria.Expression; +import jakarta.persistence.criteria.From; +import jakarta.persistence.criteria.Subquery; import org.apache.olingo.server.api.OData; import org.apache.olingo.server.api.ODataApplicationException; @@ -75,9 +75,9 @@ protected List determineAssociations(final JPAService associationName.insert(0, ((UriResourceNavigation) navigation).getProperty().getName()); } if (navigation != null) { - if (resourceParts.get(i) instanceof UriResourceComplexProperty) { + if (resourceParts.get(i) instanceof final UriResourceComplexProperty complexProperty) { associationName.insert(0, JPAPath.PATH_SEPARATOR); - associationName.insert(0, ((UriResourceComplexProperty) resourceParts.get(i)).getProperty().getName()); + associationName.insert(0, complexProperty.getProperty().getName()); } if (resourcePart instanceof UriResourceEntitySet) pathList.add(new JPANavigationPropertyInfo(sd, navigation, Utility.determineAssociationPath(sd, @@ -92,9 +92,9 @@ protected List determineAssociations(final JPAService associationName = new StringBuilder(); associationName.insert(0, ((UriResourceProperty) navigation).getProperty().getName()); } else if (navigation != null) { - if (resourceParts.get(i) instanceof UriResourceComplexProperty) { + if (resourceParts.get(i) instanceof final UriResourceComplexProperty complexProperty) { associationName.insert(0, JPAPath.PATH_SEPARATOR); - associationName.insert(0, ((UriResourceComplexProperty) resourceParts.get(i)).getProperty().getName()); + associationName.insert(0, complexProperty.getProperty().getName()); } if (resourcePart instanceof UriResourceEntitySet) pathList.add(new JPANavigationPropertyInfo(sd, navigation, Utility.determineAssociationPath(sd, @@ -117,6 +117,6 @@ public boolean hasCollection(final List resourceParts) { public boolean isCollection(final UriResource resourcePart) { - return (resourcePart instanceof UriResourceProperty && ((UriResourceProperty) resourcePart).isCollection()); + return (resourcePart instanceof final UriResourceProperty resourceProperty && resourceProperty.isCollection()); } } \ No newline at end of file diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPAExpression.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPAExpression.java index 6d2819452..b44c1fdb2 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPAExpression.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPAExpression.java @@ -1,6 +1,6 @@ package com.sap.olingo.jpa.processor.core.filter; -import javax.persistence.criteria.Expression; +import jakarta.persistence.criteria.Expression; import org.apache.olingo.server.api.ODataApplicationException; diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPAExpressionVisitor.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPAExpressionVisitor.java index 521817dc7..d01dfc1a7 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPAExpressionVisitor.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPAExpressionVisitor.java @@ -1,6 +1,6 @@ package com.sap.olingo.jpa.processor.core.filter; -import javax.persistence.criteria.From; +import jakarta.persistence.criteria.From; import org.apache.olingo.server.api.OData; import org.apache.olingo.server.api.uri.queryoption.expression.ExpressionVisitor; diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPAFilterComplier.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPAFilterComplier.java index 79c6f10d5..56e2b70f9 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPAFilterComplier.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPAFilterComplier.java @@ -2,7 +2,7 @@ import java.util.List; -import javax.persistence.criteria.Expression; +import jakarta.persistence.criteria.Expression; import org.apache.olingo.server.api.ODataApplicationException; import org.apache.olingo.server.api.uri.queryoption.expression.ExpressionVisitException; diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPAFilterComplierAccess.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPAFilterComplierAccess.java index 768c44065..345adc7c8 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPAFilterComplierAccess.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPAFilterComplierAccess.java @@ -3,8 +3,8 @@ import java.util.List; import java.util.Optional; -import javax.persistence.EntityManager; -import javax.persistence.criteria.From; +import jakarta.persistence.EntityManager; +import jakarta.persistence.criteria.From; import org.apache.olingo.server.api.OData; import org.apache.olingo.server.api.uri.UriResource; diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPAFilterCrossComplier.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPAFilterCrossComplier.java index c8f4e851d..0e8c02758 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPAFilterCrossComplier.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPAFilterCrossComplier.java @@ -4,9 +4,9 @@ import java.util.List; import java.util.Optional; -import javax.persistence.EntityManager; -import javax.persistence.criteria.Expression; -import javax.persistence.criteria.From; +import jakarta.persistence.EntityManager; +import jakarta.persistence.criteria.Expression; +import jakarta.persistence.criteria.From; import org.apache.olingo.server.api.OData; import org.apache.olingo.server.api.ODataApplicationException; @@ -110,7 +110,7 @@ public JPAFilterCrossComplier(final OData odata, final JPAServiceDocument sd, fi @SuppressWarnings("unchecked") public Expression compile() throws ExpressionVisitException, ODataApplicationException { - try (JPARuntimeMeasurement meassument = parent.getDebugger().newMeasurement(this, "compile")) { + try (JPARuntimeMeasurement measurement = parent.getDebugger().newMeasurement(this, "compile")) { if (expression == null) { return null; } diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPAFilterElementComplier.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPAFilterElementComplier.java index 800a4a382..3e9668286 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPAFilterElementComplier.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPAFilterElementComplier.java @@ -3,9 +3,9 @@ import java.util.List; import java.util.Optional; -import javax.persistence.EntityManager; -import javax.persistence.criteria.Expression; -import javax.persistence.criteria.From; +import jakarta.persistence.EntityManager; +import jakarta.persistence.criteria.Expression; +import jakarta.persistence.criteria.From; import org.apache.olingo.server.api.OData; import org.apache.olingo.server.api.ODataApplicationException; @@ -62,7 +62,7 @@ public JPAFilterElementComplier(final OData odata, final JPAServiceDocument sd, @SuppressWarnings("unchecked") public Expression compile() throws ExpressionVisitException, ODataApplicationException { - try (JPARuntimeMeasurement meassument = parent.getDebugger().newMeasurement(this, "compile")) { + try (JPARuntimeMeasurement measurement = parent.getDebugger().newMeasurement(this, "compile")) { final ExpressionVisitor visitor = new JPAVisitor(this); return (Expression) expression.accept(visitor).get(); } diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPAFilterRestrictionsWatchDog.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPAFilterRestrictionsWatchDog.java index a844699b7..0c8ecd238 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPAFilterRestrictionsWatchDog.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPAFilterRestrictionsWatchDog.java @@ -10,7 +10,7 @@ import java.util.Set; import java.util.stream.Collectors; -import javax.persistence.criteria.Expression; +import jakarta.persistence.criteria.Expression; import org.apache.olingo.commons.api.edm.provider.CsdlAnnotation; import org.apache.olingo.commons.api.edm.provider.annotation.CsdlDynamicExpression; diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPAJavaFunctionOperator.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPAJavaFunctionOperator.java index dea3d3f70..787062f2d 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPAJavaFunctionOperator.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPAJavaFunctionOperator.java @@ -1,6 +1,6 @@ package com.sap.olingo.jpa.processor.core.filter; -import javax.persistence.criteria.Expression; +import jakarta.persistence.criteria.Expression; import org.apache.olingo.server.api.ODataApplicationException; import org.apache.olingo.server.api.uri.UriResourceFunction; diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPALambdaAllOperation.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPALambdaAllOperation.java index 858d2c4be..fd9700512 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPALambdaAllOperation.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPALambdaAllOperation.java @@ -1,8 +1,8 @@ package com.sap.olingo.jpa.processor.core.filter; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.Expression; -import javax.persistence.criteria.Subquery; +import jakarta.persistence.criteria.CriteriaBuilder; +import jakarta.persistence.criteria.Expression; +import jakarta.persistence.criteria.Subquery; import org.apache.olingo.server.api.ODataApplicationException; import org.apache.olingo.server.api.uri.queryoption.expression.ExpressionVisitException; diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPALambdaOperation.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPALambdaOperation.java index 12781039f..b93942dd2 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPALambdaOperation.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPALambdaOperation.java @@ -3,7 +3,7 @@ import java.util.ArrayList; import java.util.List; -import javax.persistence.criteria.Subquery; +import jakarta.persistence.criteria.Subquery; import org.apache.olingo.server.api.ODataApplicationException; import org.apache.olingo.server.api.uri.UriInfoResource; diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPALiteralOperator.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPALiteralOperator.java index f4d997930..98c400053 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPALiteralOperator.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPALiteralOperator.java @@ -11,7 +11,7 @@ import com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAOperationResultParameter; import com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAParameter; import com.sap.olingo.jpa.processor.core.exception.ODataJPAFilterException; -import com.sap.olingo.jpa.processor.core.query.ExpressionUtil; +import com.sap.olingo.jpa.processor.core.query.ExpressionUtility; public class JPALiteralOperator implements JPAPrimitiveTypeOperator { private final Literal literal; @@ -39,8 +39,8 @@ public Object get() throws ODataApplicationException { try { final Object value = edmType.valueOfString(literalText, true, null, null, null, true, edmType.getDefaultType()); - if (value instanceof String) - return ((String) value).replace("'", ""); + if (value instanceof final String asString) + return asString.replace("'", ""); return value; } catch (final EdmPrimitiveTypeException e) { throw new ODataJPAFilterException(e, HttpStatusCode.INTERNAL_SERVER_ERROR); @@ -51,16 +51,16 @@ public Object get() throws ODataApplicationException { * Converts a literal value into system type of attribute */ public Object get(final JPAAttribute attribute) throws ODataApplicationException { - return ExpressionUtil.convertValueOnAttribute(odata, attribute, literalText); + return ExpressionUtility.convertValueOnAttribute(odata, attribute, literalText); } public Object get(final JPAOperationResultParameter returnType) throws ODataApplicationException { - return ExpressionUtil.convertValueOnFacet(odata, returnType, literalText); + return ExpressionUtility.convertValueOnFacet(odata, returnType, literalText); } public Object get(final JPAParameter jpaParameter) throws ODataApplicationException { - return ExpressionUtil.convertValueOnFacet(odata, jpaParameter, literalText); + return ExpressionUtility.convertValueOnFacet(odata, jpaParameter, literalText); } @Override diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPAMemberOperator.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPAMemberOperator.java index d2283b5f8..9bc3b79bc 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPAMemberOperator.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPAMemberOperator.java @@ -6,9 +6,9 @@ import java.util.List; import java.util.Set; -import javax.persistence.criteria.From; -import javax.persistence.criteria.Join; -import javax.persistence.criteria.Path; +import jakarta.persistence.criteria.From; +import jakarta.persistence.criteria.Join; +import jakarta.persistence.criteria.Path; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -67,9 +67,9 @@ private Path determineCriteriaPath(final JPAPath selectItemPath) throws OData for (final JPAElement jpaPathElement : selectItemPath.getPath()) { if (jpaPathElement instanceof JPADescriptionAttribute) { path = determineDescriptionCriteriaPath(selectItemPath, path, jpaPathElement); - } else if (jpaPathElement instanceof JPACollectionAttribute) { - if (!((JPACollectionAttribute) jpaPathElement).isComplex()) try { - path = path.get(((JPACollectionAttribute) jpaPathElement).getTargetAttribute().getInternalName()); + } else if (jpaPathElement instanceof final JPACollectionAttribute collectionAttribute) { + if (!collectionAttribute.isComplex()) try { + path = path.get(collectionAttribute.getTargetAttribute().getInternalName()); } catch (final ODataJPAModelException e) { throw new ODataJPAFilterException(e, HttpStatusCode.INTERNAL_SERVER_ERROR); } diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPAMethodBasedExpression.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPAMethodBasedExpression.java index a3cb8fb44..01ff9f029 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPAMethodBasedExpression.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPAMethodBasedExpression.java @@ -2,15 +2,15 @@ import java.util.List; -import javax.persistence.criteria.Expression; +import jakarta.persistence.criteria.Expression; import org.apache.olingo.server.api.ODataApplicationException; import org.apache.olingo.server.api.uri.queryoption.expression.MethodKind; final class JPAMethodBasedExpression extends JPAMethodCallImp implements JPAExpression { - public JPAMethodBasedExpression(JPAOperationConverter converter, MethodKind methodCall, - List parameters) { + public JPAMethodBasedExpression(final JPAOperationConverter converter, final MethodKind methodCall, + final List parameters) { super(converter, methodCall, parameters); } diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPAMethodCallImp.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPAMethodCallImp.java index 3f7dd15ab..8adb18b49 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPAMethodCallImp.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPAMethodCallImp.java @@ -4,7 +4,7 @@ import java.util.Collections; import java.util.List; -import javax.persistence.criteria.Expression; +import jakarta.persistence.criteria.Expression; import org.apache.olingo.server.api.ODataApplicationException; import org.apache.olingo.server.api.uri.queryoption.expression.MethodKind; @@ -24,7 +24,7 @@ public JPAMethodCallImp(final JPAOperationConverter converter, final MethodKind /* * (non-Javadoc) - * + * * @see com.sap.olingo.jpa.processor.core.filter.JPAFunctionCall#get() */ @Override @@ -34,24 +34,24 @@ public Object get() throws ODataApplicationException { /* * (non-Javadoc) - * + * * @see com.sap.olingo.jpa.processor.core.filter.JPAFunctionCall#get(String prefix, String suffix) */ @Override public Object get(final String prefix, final String suffix) throws ODataApplicationException { final List paramCopy = new ArrayList<>(parameters); - if (!parameters.isEmpty() && parameters.get(0) instanceof JPALiteralOperator) { - parameters.add(((JPALiteralOperator) parameters.get(0)).clone(prefix, suffix)); + if (!parameters.isEmpty() && parameters.get(0) instanceof final JPALiteralOperator literalOperator) { + parameters.add(literalOperator.clone(prefix, suffix)); parameters.remove(0); } - Expression result = converter.convert(this); + final Expression result = converter.convert(this); Collections.copy(parameters, paramCopy); return result; } /* * (non-Javadoc) - * + * * @see com.sap.olingo.jpa.processor.core.filter.JPAFunctionCall#getFunction() */ @Override @@ -61,7 +61,7 @@ public MethodKind getFunction() { /* * (non-Javadoc) - * + * * @see com.sap.olingo.jpa.processor.core.filter.JPAFunctionCall#getParameter(int) */ @Override @@ -71,7 +71,7 @@ public JPAOperator getParameter(final int index) { /* * (non-Javadoc) - * + * * @see com.sap.olingo.jpa.processor.core.filter.JPAFunctionCall#noParameters() */ @Override diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPANavigationOperation.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPANavigationOperation.java index 15b292fee..f4e1b9c9d 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPANavigationOperation.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPANavigationOperation.java @@ -3,9 +3,9 @@ import java.util.ArrayList; import java.util.List; -import javax.persistence.criteria.Expression; -import javax.persistence.criteria.From; -import javax.persistence.criteria.Subquery; +import jakarta.persistence.criteria.Expression; +import jakarta.persistence.criteria.From; +import jakarta.persistence.criteria.Subquery; import org.apache.olingo.commons.api.edm.EdmType; import org.apache.olingo.server.api.ODataApplicationException; @@ -77,8 +77,8 @@ public JPANavigationOperation(final BinaryOperatorKind operator, super(jpaComplier); this.operator = operator; this.methodCall = null; - if (left instanceof JPAMemberOperator) { - jpaMember = (JPAMemberOperator) left; + if (left instanceof final JPAMemberOperator memberOperator) { + jpaMember = memberOperator; operand = (JPALiteralOperator) right; } else { jpaMember = (JPAMemberOperator) right; @@ -91,8 +91,8 @@ public JPANavigationOperation(final JPAFilterComplierAccess jpaComplier, final M super(jpaComplier); this.operator = null; this.methodCall = methodCall; - if (parameters.get(0) instanceof JPAMemberOperator) { - jpaMember = (JPAMemberOperator) parameters.get(0); + if (parameters.get(0) instanceof final JPAMemberOperator memberOperator) { + jpaMember = memberOperator; operand = parameters.size() > 1 ? (JPALiteralOperator) parameters.get(1) : null; } else { jpaMember = (JPAMemberOperator) parameters.get(1); @@ -105,9 +105,9 @@ public Expression get() throws ODataApplicationException { // return converter.cb.greaterThan(getExistsQuery().as("a"), converter.cb.literal('5')); //NOSONAR final Subquery existQuery = getExistsQuery(); - if (expression instanceof JPAInvertibleVisitableExpression - && ((JPAInvertibleVisitableExpression) expression).isInversionRequired()) { - ((JPAInvertibleVisitableExpression) expression).inversionPerformed(); + if (expression instanceof final JPAInvertibleVisitableExpression visitableExpression + && visitableExpression.isInversionRequired()) { + visitableExpression.inversionPerformed(); return converter.cb.not(converter.cb.exists(existQuery)); } return converter.cb.exists(existQuery); @@ -321,7 +321,8 @@ public List getUriResourceParts() { for (int i = source.size() - 1; i > 0; i--) { if (source.get(i).getKind() == UriResourceKind.navigationProperty || source.get(i).getKind() == UriResourceKind.entitySet - || (source.get(i) instanceof UriResourceProperty && ((UriResourceProperty) source.get(i)).isCollection())) { + || (source.get(i) instanceof final UriResourceProperty resourceProperty + && resourceProperty.isCollection())) { break; } result.add(0, source.get(i)); diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPAOperationConverter.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPAOperationConverter.java index ae75643e7..4234ac10e 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPAOperationConverter.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPAOperationConverter.java @@ -3,8 +3,8 @@ import java.util.function.BiFunction; import java.util.function.Function; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.Expression; +import jakarta.persistence.criteria.CriteriaBuilder; +import jakarta.persistence.criteria.Expression; import org.apache.olingo.server.api.ODataApplicationException; import org.apache.olingo.server.api.uri.queryoption.expression.UnaryOperatorKind; @@ -84,20 +84,26 @@ public final Expression convert(@SuppressWarnings("rawtypes") final JPA switch (jpaOperator.getOperator()) { case EQ: - return equalExpression((left, right) -> (cb.equal(left, right)), (left, right) -> (cb.equal(left, right)), left -> (cb.isNull(left)), + return equalExpression((left, right) -> (cb.equal(left, right)), (left, right) -> (cb.equal(left, right)), + left -> (cb.isNull(left)), jpaOperator); case NE: - return equalExpression((left, right) -> (cb.notEqual(left, right)), (left, right) -> (cb.notEqual(left, right)), left -> (cb.isNotNull(left)), + return equalExpression((left, right) -> (cb.notEqual(left, right)), (left, right) -> (cb.notEqual(left, right)), + left -> (cb.isNotNull(left)), jpaOperator); case GE: - return comparisonExpression((left, right) -> (cb.greaterThanOrEqualTo(left, right)), (left, right) -> (cb.greaterThanOrEqualTo(left, - right)), jpaOperator); + return comparisonExpression((left, right) -> (cb.greaterThanOrEqualTo(left, right)), (left, right) -> (cb + .greaterThanOrEqualTo(left, + right)), jpaOperator); case GT: - return comparisonExpression((left, right) -> (cb.greaterThan(left, right)), (left, right) -> (cb.greaterThan(left, right)), jpaOperator); + return comparisonExpression((left, right) -> (cb.greaterThan(left, right)), (left, right) -> (cb.greaterThan( + left, right)), jpaOperator); case LT: - return comparisonExpression((left, right) -> (cb.lessThan(left, right)), (left, right) -> (cb.lessThan(left, right)), jpaOperator); + return comparisonExpression((left, right) -> (cb.lessThan(left, right)), (left, right) -> (cb.lessThan(left, + right)), jpaOperator); case LE: - return comparisonExpression((left, right) -> (cb.lessThanOrEqualTo(left, right)), (left, right) -> (cb.lessThanOrEqualTo(left, right)), + return comparisonExpression((left, right) -> (cb.lessThanOrEqualTo(left, right)), (left, right) -> (cb + .lessThanOrEqualTo(left, right)), jpaOperator); default: return dbConverter.convert(jpaOperator); @@ -164,13 +170,10 @@ public Expression convert(final JPAMethodCall jpaFunction) throws ODataApplic case TRIM: return cb.trim((Expression) (jpaFunction.getParameter(0).get())); case CONCAT: - if (jpaFunction.getParameter(0).get() instanceof String) - return cb.concat((String) jpaFunction.getParameter(0).get(), (Expression) (jpaFunction.getParameter(1) - .get())); - if (jpaFunction.getParameter(1).get() instanceof String) - return cb.concat((Expression) (jpaFunction.getParameter(0).get()), (String) jpaFunction.getParameter( - 1) - .get()); + if (jpaFunction.getParameter(0).get() instanceof final String parameter0) + return cb.concat(parameter0, (Expression) (jpaFunction.getParameter(1).get())); + if (jpaFunction.getParameter(1).get() instanceof final String parameter1) + return cb.concat((Expression) (jpaFunction.getParameter(0).get()), parameter1); else return cb.concat((Expression) (jpaFunction.getParameter(0).get()), (Expression) (jpaFunction.getParameter(1).get())); diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPAUnaryBooleanOperator.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPAUnaryBooleanOperator.java index f78328d1b..2bbda4ff5 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPAUnaryBooleanOperator.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPAUnaryBooleanOperator.java @@ -1,6 +1,6 @@ package com.sap.olingo.jpa.processor.core.filter; -import javax.persistence.criteria.Expression; +import jakarta.persistence.criteria.Expression; import org.apache.olingo.server.api.ODataApplicationException; import org.apache.olingo.server.api.uri.queryoption.expression.UnaryOperatorKind; diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPAUnaryBooleanOperatorImp.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPAUnaryBooleanOperatorImp.java index 0c6ad0cde..249c3c64a 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPAUnaryBooleanOperatorImp.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPAUnaryBooleanOperatorImp.java @@ -1,6 +1,6 @@ package com.sap.olingo.jpa.processor.core.filter; -import javax.persistence.criteria.Expression; +import jakarta.persistence.criteria.Expression; import org.apache.olingo.server.api.ODataApplicationException; import org.apache.olingo.server.api.uri.queryoption.expression.UnaryOperatorKind; diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPAVisitor.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPAVisitor.java index 01659b2b3..47ba4d361 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPAVisitor.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/JPAVisitor.java @@ -11,9 +11,10 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.From; -import javax.persistence.criteria.Predicate; + +import jakarta.persistence.criteria.CriteriaBuilder; +import jakarta.persistence.criteria.From; +import jakarta.persistence.criteria.Predicate; import org.apache.olingo.commons.api.edm.EdmEnumType; import org.apache.olingo.commons.api.edm.EdmType; @@ -89,7 +90,7 @@ public JPAOperator visitAlias(final String aliasName) throws ExpressionVisitExce public JPAOperator visitBinaryOperator(final BinaryOperatorKind operator, final JPAOperator left, final JPAOperator right) throws ExpressionVisitException, ODataApplicationException { - try (JPARuntimeMeasurement meassument = debugger.newMeasurement(this, "visitBinaryOperator")) { + try (JPARuntimeMeasurement measurement = debugger.newMeasurement(this, "visitBinaryOperator")) { if (operator == BinaryOperatorKind.AND || operator == BinaryOperatorKind.OR) { // Connecting operations have to be handled first, as JPANavigationOperation do not need special treatment return new JPABooleanOperatorImp(this.jpaComplier.getConverter(), operator, (JPAExpression) left, @@ -130,7 +131,7 @@ public JPAOperator visitBinaryOperator(final BinaryOperatorKind operator, final public JPAEnumerationOperator visitEnum(final EdmEnumType type, final List enumValues) throws ExpressionVisitException, ODataApplicationException { - try (JPARuntimeMeasurement meassument = debugger.newMeasurement(this, "visitEnum")) { + try (JPARuntimeMeasurement measurement = debugger.newMeasurement(this, "visitEnum")) { final JPAEnumerationAttribute jpaEnumerationAttribute = this.jpaComplier.getSd().getEnumType(type); try { if (jpaEnumerationAttribute == null) @@ -163,7 +164,7 @@ public JPAOperator visitLambdaReference(final String variableName) throws Expres @Override public JPAOperator visitLiteral(final Literal literal) throws ExpressionVisitException, ODataApplicationException { - try (JPARuntimeMeasurement meassument = debugger.newMeasurement(this, "visitLiteral")) { + try (JPARuntimeMeasurement measurement = debugger.newMeasurement(this, "visitLiteral")) { return new JPALiteralOperator(this.jpaComplier.getOData(), literal); } } @@ -171,7 +172,7 @@ public JPAOperator visitLiteral(final Literal literal) throws ExpressionVisitExc @Override public JPAOperator visitMember(final Member member) throws ExpressionVisitException, ODataApplicationException { - try (JPARuntimeMeasurement meassument = debugger.newMeasurement(this, "visitMember")) { + try (JPARuntimeMeasurement measurement = debugger.newMeasurement(this, "visitMember")) { final JPAPath attributePath = determineAttributePath(this.jpaComplier.getJpaEntityType(), member, jpaComplier.getAssociation()); checkTransient(attributePath); @@ -185,9 +186,9 @@ public JPAOperator visitMember(final Member member) throws ExpressionVisitExcept final UriResource resource = member.getResourcePath().getUriResourceParts().get(0); final JPAFunction jpaFunction = this.jpaComplier.getSd().getFunction( ((UriResourceFunction) resource).getFunction()); - if (jpaFunction instanceof JPADataBaseFunction) { + if (jpaFunction instanceof final JPADataBaseFunction dbFunction) { final List odataParams = ((UriResourceFunction) resource).getParameters(); - return new JPADBFunctionOperator(this, odataParams, (JPADataBaseFunction) jpaFunction); + return new JPADBFunctionOperator(this, odataParams, dbFunction); } else return new JPAJavaFunctionOperator(this, (UriResourceFunction) resource, (JPAJavaFunction) jpaFunction); } @@ -201,7 +202,7 @@ public JPAOperator visitMember(final Member member) throws ExpressionVisitExcept public JPAOperator visitMethodCall(final MethodKind methodCall, final List parameters) throws ExpressionVisitException, ODataApplicationException { - try (JPARuntimeMeasurement meassument = debugger.newMeasurement(this, "visitMethodCall")) { + try (JPARuntimeMeasurement measurement = debugger.newMeasurement(this, "visitMethodCall")) { if (!parameters.isEmpty()) { if (parameters.get(0) instanceof JPANavigationOperation || (parameters.size() == 2 && parameters.get(1) instanceof JPANavigationOperation)) @@ -227,7 +228,7 @@ public JPAOperator visitTypeLiteral(final EdmType type) throws ExpressionVisitEx public JPAOperator visitUnaryOperator(final UnaryOperatorKind operator, final JPAOperator operand) throws ExpressionVisitException, ODataApplicationException { - try (JPARuntimeMeasurement meassument = debugger.newMeasurement(this, "visitUnaryOperator")) { + try (JPARuntimeMeasurement measurement = debugger.newMeasurement(this, "visitUnaryOperator")) { if (operator == UnaryOperatorKind.NOT) { return new JPAUnaryBooleanOperatorImp(this.jpaComplier.getConverter(), operator, (JPAExpression) operand); @@ -255,13 +256,13 @@ JPAServiceDocument getSd() { } boolean hasNavigation(final JPAOperator operand) { - if (operand instanceof JPAMemberOperator) { - final List uriResourceParts = ((JPAMemberOperator) operand).getMember().getResourcePath() + if (operand instanceof final JPAMemberOperator memberOperator) { + final List uriResourceParts = memberOperator.getMember().getResourcePath() .getUriResourceParts(); for (int i = uriResourceParts.size() - 1; i >= 0; i--) { if (uriResourceParts.get(i) instanceof UriResourceNavigation - || (uriResourceParts.get(i) instanceof UriResourceProperty - && ((UriResourceProperty) uriResourceParts.get(i)).isCollection())) + || (uriResourceParts.get(i) instanceof final UriResourceProperty resourceProperty + && resourceProperty.isCollection())) return true; } } @@ -274,9 +275,8 @@ private JPAOperator handleBinaryWithNavigation(final BinaryOperatorKind operator throw new ODataJPAFilterException(NOT_SUPPORTED_FILTER, NOT_IMPLEMENTED, "Binary operations comparing two navigation"); - if (left instanceof JPANavigationOperation) { - return new JPANavigationOperation(operator, (JPANavigationOperation) left, (JPALiteralOperator) right, - jpaComplier); + if (left instanceof final JPANavigationOperation navigationOperation) { + return new JPANavigationOperation(operator, navigationOperation, (JPALiteralOperator) right, jpaComplier); } return new JPANavigationOperation(operator, (JPANavigationOperation) right, (JPALiteralOperator) left, jpaComplier); } diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/ODataJPAQueryContext.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/ODataJPAQueryContext.java index 901349cb4..d5f003c35 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/ODataJPAQueryContext.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/filter/ODataJPAQueryContext.java @@ -1,7 +1,7 @@ package com.sap.olingo.jpa.processor.core.filter; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.From; +import jakarta.persistence.criteria.CriteriaBuilder; +import jakarta.persistence.criteria.From; import com.sap.olingo.jpa.metadata.api.JPAODataQueryContext; import com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAEntityType; diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/helper/AbstractWatchDog.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/helper/AbstractWatchDog.java index fa327cae2..add8f03e1 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/helper/AbstractWatchDog.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/helper/AbstractWatchDog.java @@ -43,7 +43,7 @@ protected List getPathItems(final Map properties .map(CsdlExpression::asDynamic) .map(CsdlDynamicExpression::asPropertyPath) .map(CsdlPropertyPath::getValue) - .collect(Collectors.toList()); + .toList(); } protected List getNavigationPathItems(final Map properties, final String property) { @@ -52,7 +52,7 @@ protected List getNavigationPathItems(final Map .map(CsdlExpression::asDynamic) .map(CsdlDynamicExpression::asNavigationPropertyPath) .map(CsdlNavigationPropertyPath::getValue) - .collect(Collectors.toList()); + .toList(); } protected Map getAnnotationProperties(final Optional annotation) { diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/modify/JPAConversionHelper.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/modify/JPAConversionHelper.java index 6b062385f..191fca4e8 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/modify/JPAConversionHelper.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/modify/JPAConversionHelper.java @@ -14,7 +14,7 @@ import java.util.List; import java.util.Map; -import javax.persistence.AttributeConverter; +import jakarta.persistence.AttributeConverter; import org.apache.olingo.commons.api.data.ComplexValue; import org.apache.olingo.commons.api.data.Entity; @@ -47,7 +47,7 @@ import com.sap.olingo.jpa.processor.core.exception.ODataJPAProcessorException; import com.sap.olingo.jpa.processor.core.exception.ODataJPAProcessorException.MessageKeys; import com.sap.olingo.jpa.processor.core.query.EdmBindingTargetInfo; -import com.sap.olingo.jpa.processor.core.query.ExpressionUtil; +import com.sap.olingo.jpa.processor.core.query.ExpressionUtility; import com.sap.olingo.jpa.processor.core.query.Utility; /** @@ -128,14 +128,14 @@ public Entity convertInputStream(final OData odata, final ODataRequest request, final ODataDeserializer deserializer = createDeserializer(odata, requestFormat, request.getHeaders(HttpHeader.ODATA_VERSION)); final UriResource lastPart = uriResourceParts.get(uriResourceParts.size() - 1); - if (lastPart instanceof UriResourceProperty) { + if (lastPart instanceof final UriResourceProperty lastResourceProperty) { // Convert requests on property level into request on entity level final Entity requestEntity = new Entity(); final String startProperty = targetEntityInfo.getNavigationPath().split(JPAPath.PATH_SEPARATOR)[0]; int i = uriResourceParts.size() - 1; for (; i > 0; i--) { - if (uriResourceParts.get(i) instanceof UriResourceProperty - && ((UriResourceProperty) uriResourceParts.get(i)).getProperty().getName().equals(startProperty)) { + if (uriResourceParts.get(i) instanceof final UriResourceProperty resourceProperty + && resourceProperty.getProperty().getName().equals(startProperty)) { break; } } @@ -153,8 +153,7 @@ public Entity convertInputStream(final OData odata, final ODataRequest request, properties.add(intermediateProperty); properties = ((ComplexValue) intermediateProperty.getValue()).getValue(); } - properties.add(deserializer.property(requestInputStream, ((UriResourceProperty) lastPart).getProperty()) - .getProperty()); + properties.add(deserializer.property(requestInputStream, lastResourceProperty.getProperty()).getProperty()); return requestEntity; } else { return deserializer.entity(requestInputStream, targetEntityInfo.getTargetEdmBindingTarget().getEntityType()) @@ -225,14 +224,12 @@ public Map convertProperties(final OData odata, final JPAStructu throw new ODataJPAProcessorException(e, HttpStatusCode.INTERNAL_SERVER_ERROR); } break; - case PRIMITIVE: - case ENUM: + case PRIMITIVE, ENUM: final JPAAttribute attribute = path.getLeaf(); internalName = attribute.getInternalName(); jpaAttribute = processAttributeConverter(odataProperty.getValue(), attribute); break; - case COLLECTION_PRIMITIVE: - case COLLECTION_ENUM: + case COLLECTION_PRIMITIVE, COLLECTION_ENUM: final JPAAttribute attribute2 = path.getLeaf(); internalName = attribute2.getInternalName(); jpaAttribute = new ArrayList<>(); @@ -280,7 +277,7 @@ public Map convertUriKeys(final OData odata, final JPAStructured try { final JPAAttribute attribute = st.getPath(key.getName()).getLeaf(); internalName = attribute.getInternalName(); - final Object jpaAttribute = ExpressionUtil.convertValueOnAttribute(odata, attribute, key.getText(), true); + final Object jpaAttribute = ExpressionUtility.convertValueOnAttribute(odata, attribute, key.getText(), true); result.put(internalName, jpaAttribute); } catch (final ODataJPAModelException e) { throw new ODataJPAProcessorException(e, HttpStatusCode.INTERNAL_SERVER_ERROR); diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/modify/JPACreateResult.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/modify/JPACreateResult.java index 49146654b..9125d67aa 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/modify/JPACreateResult.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/modify/JPACreateResult.java @@ -19,7 +19,7 @@ import com.sap.olingo.jpa.processor.core.converter.JPATuple; import com.sap.olingo.jpa.processor.core.converter.JPATupleChildConverter; import com.sap.olingo.jpa.processor.core.exception.ODataJPAProcessorException; -import com.sap.olingo.jpa.processor.core.query.ExpressionUtil; +import com.sap.olingo.jpa.processor.core.query.ExpressionUtility; abstract class JPACreateResult implements JPAExpandResult { @@ -37,7 +37,7 @@ abstract class JPACreateResult implements JPAExpandResult { this.helper = new JPAConversionHelper(); this.children = new HashMap<>(0); this.pathList = et.getPathList(); - this.locale = ExpressionUtil.determineFallbackLocale(requestHeaders); + this.locale = ExpressionUtility.determineFallbackLocale(requestHeaders); this.requestHeaders = requestHeaders; } @@ -73,17 +73,17 @@ public boolean hasCount() { protected void addValueToTuple(final JPATuple tuple, final JPAPath path, final int index, final Object value) throws ODataJPAProcessorException { - if (path.getPath().get(index) instanceof JPADescriptionAttribute) { + if (path.getPath().get(index) instanceof final JPADescriptionAttribute descriptionAttribute) { @SuppressWarnings("unchecked") - final Collection desc = (Collection) value; - if (desc != null) { - for (final Object entry : desc) { - final Map descGetterMap = entryAsMap(entry); - final JPADescriptionAttribute jpaAttribute = (JPADescriptionAttribute) path.getPath().get(index); - final String providedLocale = determineLocale(descGetterMap, jpaAttribute); + final Collection values = (Collection) value; + if (values != null) { + for (final Object entry : values) { + final Map descriptionGetterMap = entryAsMap(entry); + final String providedLocale = determineLocale(descriptionGetterMap, descriptionAttribute); if (locale.getLanguage().equals(providedLocale) || locale.toString().equals(providedLocale)) { - final Object description = descGetterMap.get(jpaAttribute.getDescriptionAttribute().getInternalName()); + final Object description = descriptionGetterMap.get(descriptionAttribute.getDescriptionAttribute() + .getInternalName()); tuple.addElement(path.getAlias(), path.getLeaf().getType(), description); break; } @@ -108,20 +108,25 @@ protected void convertPathToTuple(final JPATuple tuple, final Map descGetterMap, + protected abstract String determineLocale(final Map descriptionGetterMap, JPAPath localeAttribute, final int index) throws ODataJPAProcessorException; - protected abstract Map entryAsMap(final Object entry) throws ODataJPAProcessorException; + @SuppressWarnings("unchecked") + protected Map entryAsMap(final Object entry) throws ODataJPAProcessorException { // NOSONAR + return (Map) entry; + } protected boolean notContainsCollection(final JPAPath path) { - for (final JPAElement e : path.getPath()) - if (e instanceof JPAAttribute && ((JPAAttribute) e).isCollection()) + for (final JPAElement element : path.getPath()) + if (element instanceof final JPAAttribute attribute + && attribute.isCollection()) return false; return true; } - private String determineLocale(final Map descGetterMap, - final JPADescriptionAttribute descAttribute) throws ODataJPAProcessorException { - return determineLocale(descGetterMap, descAttribute.getLocaleFieldName(), 0); + private String determineLocale(final Map descriptionGetterMap, + final JPADescriptionAttribute descriptionAttribute) throws ODataJPAProcessorException { + return determineLocale(descriptionGetterMap, descriptionAttribute.getLocaleFieldName(), 0); } + } \ No newline at end of file diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/modify/JPAEntityBasedResult.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/modify/JPAEntityBasedResult.java index 5bdb8731b..91cfbea6a 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/modify/JPAEntityBasedResult.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/modify/JPAEntityBasedResult.java @@ -4,7 +4,7 @@ import java.util.List; import java.util.Map; -import javax.persistence.Tuple; +import jakarta.persistence.Tuple; import com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAEntityType; import com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAPath; diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/modify/JPAEntityCollectionResult.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/modify/JPAEntityCollectionResult.java index 196399e87..455e5919b 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/modify/JPAEntityCollectionResult.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/modify/JPAEntityCollectionResult.java @@ -6,7 +6,7 @@ import java.util.List; import java.util.Map; -import javax.persistence.Tuple; +import jakarta.persistence.Tuple; import org.apache.olingo.server.api.ODataApplicationException; @@ -43,7 +43,7 @@ private List convertToTuple(final JPAEntityType et, final Collection v final JPATuple tuple = new JPATuple(); if (attribute.isComplex()) { final Map embeddedGetterMap = helper.buildGetterMap(value); - for (JPAPath p : attribute.getStructuredType().getPathList()) + for (final JPAPath p : attribute.getStructuredType().getPathList()) convertPathToTuple(tuple, embeddedGetterMap, et.getPath(this.path.getAlias() + JPAPath.PATH_SEPARATOR + p.getAlias()), 1); } else { @@ -60,7 +60,7 @@ public void convert(final JPATupleChildConverter converter) throws ODataApplicat } @Override - public List getPropertyCollection(String key) { + public List getPropertyCollection(final String key) { return converted.get(ROOT_RESULT_KEY); } diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/modify/JPAEntityNavigationLinkResult.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/modify/JPAEntityNavigationLinkResult.java index e3804e917..2187c0e3c 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/modify/JPAEntityNavigationLinkResult.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/modify/JPAEntityNavigationLinkResult.java @@ -7,7 +7,7 @@ import java.util.List; import java.util.Map; -import javax.persistence.Tuple; +import jakarta.persistence.Tuple; import org.apache.olingo.commons.api.data.EntityCollection; import org.apache.olingo.server.api.ODataApplicationException; @@ -32,13 +32,13 @@ final class JPAEntityNavigationLinkResult extends JPACreateResult implements JPA super(et, requestHeaders); this.converter = converter; this.result = new ArrayList<>(); - for (Object v : value) { + for (final Object v : value) { result.add(new JPAEntityResult(et, v, requestHeaders, converter).getResult(ROOT_RESULT_KEY).get(0)); } } @Override - public Map asEntityCollection(JPATupleChildConverter converter) + public Map asEntityCollection(final JPATupleChildConverter converter) throws ODataApplicationException { convert(new JPATupleChildConverter(converter)); return odataResult; @@ -56,7 +56,7 @@ public EntityCollection getEntityCollection(final String key) throws ODataApplic } @Override - public List getResult(String key) { + public List getResult(final String key) { return result; } @@ -68,7 +68,8 @@ public Map> getResults() { } @Override - public void putChildren(Map childResults) throws ODataApplicationException { + public void putChildren(final Map childResults) + throws ODataApplicationException { // Not needed for JPAEntityNavigationLinkResult } diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/modify/JPAEntityResult.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/modify/JPAEntityResult.java index e97f8d73d..8a936ef4e 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/modify/JPAEntityResult.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/modify/JPAEntityResult.java @@ -5,7 +5,7 @@ import java.util.List; import java.util.Map; -import javax.persistence.Tuple; +import jakarta.persistence.Tuple; import org.apache.olingo.server.api.ODataApplicationException; @@ -54,17 +54,17 @@ private void createChildren(final JPATupleChildConverter converter) throws OData } for (final JPAPath path : et.getCollectionAttributesPath()) { Map embeddedGetterMap = valuePairedResult; - for (final JPAElement e : path.getPath()) { - final Object value = embeddedGetterMap.get(e.getInternalName()); - if (e instanceof JPAAttribute && ((JPAAttribute) e).isComplex() && !(((JPAAttribute) e).isCollection()) + for (final JPAElement element : path.getPath()) { + final Object value = embeddedGetterMap.get(element.getInternalName()); + if (element instanceof final JPAAttribute attribute && attribute.isComplex() && !(attribute.isCollection()) && value != null) { embeddedGetterMap = helper.buildGetterMap(value); continue; } - if (e instanceof JPACollectionAttribute && value != null) { - final JPAAssociationPath assPath = ((JPACollectionAttribute) e).asAssociation(); + if (element instanceof final JPACollectionAttribute attribute && value != null) { + final JPAAssociationPath assPath = attribute.asAssociation(); final JPAExpandResult child = new JPAEntityCollectionResult(et, (Collection) value, requestHeaders, - (JPACollectionAttribute) e); + attribute); child.convert(converter); children.put(assPath, child); } diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/modify/JPAMapBaseResult.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/modify/JPAMapBaseResult.java index c4d8d1140..ab9b42e0f 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/modify/JPAMapBaseResult.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/modify/JPAMapBaseResult.java @@ -4,7 +4,7 @@ import java.util.List; import java.util.Map; -import javax.persistence.Tuple; +import jakarta.persistence.Tuple; import com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAEntityType; import com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAPath; @@ -44,11 +44,5 @@ protected String determineLocale(final Map descGetterMap, final } else { return determineLocale((Map) value, localeAttribute, index + 1); } - } - - @SuppressWarnings("unchecked") - @Override - protected Map entryAsMap(final Object entry) throws ODataJPAProcessorException { - return (Map) entry; - } + } } \ No newline at end of file diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/modify/JPAMapCollectionResult.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/modify/JPAMapCollectionResult.java index 9aea88ca4..b40c05784 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/modify/JPAMapCollectionResult.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/modify/JPAMapCollectionResult.java @@ -6,7 +6,7 @@ import java.util.List; import java.util.Map; -import javax.persistence.Tuple; +import jakarta.persistence.Tuple; import org.apache.olingo.server.api.ODataApplicationException; @@ -40,7 +40,7 @@ private List convertToTuple(final JPAEntityType et, final Collection v for (final Object value : values) { final JPATuple tuple = new JPATuple(); if (attribute.isComplex()) { - for (JPAPath p : attribute.getStructuredType().getPathList()) + for (final JPAPath p : attribute.getStructuredType().getPathList()) convertPathToTuple(tuple, (Map) value, et.getPath(this.path.getAlias() + JPAPath.PATH_SEPARATOR + p.getAlias()), 1); } else { @@ -57,7 +57,7 @@ public void convert(final JPATupleChildConverter converter) throws ODataApplicat } @Override - public Collection getPropertyCollection(String key) { + public Collection getPropertyCollection(final String key) { return converted.get(ROOT_RESULT_KEY); } @@ -67,3 +67,4 @@ public JPAAssociationPath getAssociation() { } } + diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/modify/JPAMapNavigationLinkResult.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/modify/JPAMapNavigationLinkResult.java index 5fc27e30e..77fe6cd3d 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/modify/JPAMapNavigationLinkResult.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/modify/JPAMapNavigationLinkResult.java @@ -5,7 +5,7 @@ import java.util.List; import java.util.Map; -import javax.persistence.Tuple; +import jakarta.persistence.Tuple; import org.apache.olingo.server.api.ODataApplicationException; @@ -26,7 +26,7 @@ public JPAMapNavigationLinkResult(final JPAEntityType targetType, final List(); - for (JPARequestEntity entity : entities) { + for (final JPARequestEntity entity : entities) { result.add(new JPAMapResult(entity.getEntityType(), entity.getData(), requestHeaders, converter).getResult( ROOT_RESULT_KEY) .get(0)); @@ -34,7 +34,7 @@ public JPAMapNavigationLinkResult(final JPAEntityType targetType, final List getResult(String key) { + public List getResult(final String key) { return result; } @@ -51,10 +51,4 @@ protected String determineLocale(final Map descGetterMap, final // Not needed for JPAMapNavigationLinkResult return null; } - - @SuppressWarnings("unchecked") - @Override - protected Map entryAsMap(final Object entry) throws ODataJPAProcessorException { - return (Map) entry; - } } diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/modify/JPAMapResult.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/modify/JPAMapResult.java index 2b54dbfa4..0c99848bb 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/modify/JPAMapResult.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/modify/JPAMapResult.java @@ -5,7 +5,7 @@ import java.util.List; import java.util.Map; -import javax.persistence.Tuple; +import jakarta.persistence.Tuple; import org.apache.olingo.server.api.ODataApplicationException; @@ -48,17 +48,17 @@ private void createChildren(final JPATupleChildConverter converter) throws OData } for (final JPAPath path : et.getCollectionAttributesPath()) { Map attributes = valuePairedResult; - for (final JPAElement e : path.getPath()) { - final Object value = attributes.get(e.getInternalName()); - if (e instanceof JPAAttribute && ((JPAAttribute) e).isComplex() && !(((JPAAttribute) e).isCollection()) + for (final JPAElement element : path.getPath()) { + final Object value = attributes.get(element.getInternalName()); + if (element instanceof final JPAAttribute attribute && attribute.isComplex() && !(attribute.isCollection()) && value != null) { attributes = (Map) value; continue; } - if (e instanceof JPACollectionAttribute && value != null) { - final JPAAssociationPath assPath = ((JPACollectionAttribute) e).asAssociation(); + if (element instanceof final JPACollectionAttribute attribute && value != null) { + final JPAAssociationPath assPath = attribute.asAssociation(); final JPAExpandResult child = new JPAMapCollectionResult(et, (Collection) value, requestHeaders, - (JPACollectionAttribute) e); + attribute); child.convert(converter); children.put(assPath, child); } diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/modify/JPAUpdateResult.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/modify/JPAUpdateResult.java index 36c1c0314..aab11f4d6 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/modify/JPAUpdateResult.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/modify/JPAUpdateResult.java @@ -1,20 +1,4 @@ package com.sap.olingo.jpa.processor.core.modify; -public final class JPAUpdateResult { - private final boolean wasCreate; - private final Object modifiedEntity; +public final record JPAUpdateResult(boolean wasCreate, Object modifiedEntity) {} - public JPAUpdateResult(boolean wasCreate, Object modifiedEntity) { - super(); - this.wasCreate = wasCreate; - this.modifiedEntity = modifiedEntity; - } - - public boolean wasCreate() { - return wasCreate; - } - - public Object getModifiedEntity() { - return modifiedEntity; - } -} diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/processor/JPAAbstractRequestProcessor.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/processor/JPAAbstractRequestProcessor.java index ff3f67d94..0704a3b98 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/processor/JPAAbstractRequestProcessor.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/processor/JPAAbstractRequestProcessor.java @@ -1,7 +1,7 @@ package com.sap.olingo.jpa.processor.core.processor; -import javax.persistence.EntityManager; -import javax.persistence.criteria.CriteriaBuilder; +import jakarta.persistence.EntityManager; +import jakarta.persistence.criteria.CriteriaBuilder; import org.apache.olingo.commons.api.ex.ODataException; import org.apache.olingo.commons.api.format.ContentType; diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/processor/JPAActionRequestProcessor.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/processor/JPAActionRequestProcessor.java index 44044c9a6..410184a64 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/processor/JPAActionRequestProcessor.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/processor/JPAActionRequestProcessor.java @@ -85,9 +85,8 @@ public void performAction(final ODataRequest request, final ODataResponse respon } catch (InstantiationException | IllegalAccessException | IllegalArgumentException e) { throw new ODataJPAProcessorException(e, INTERNAL_SERVER_ERROR); } catch (InvocationTargetException | ODataException e) { - final Throwable cause = e.getCause(); - if (cause instanceof ODataApplicationException) { - throw (ODataApplicationException) cause; + if (e.getCause() instanceof final ODataApplicationException cause) { + throw cause; } else { throw new ODataJPAProcessorException(e, INTERNAL_SERVER_ERROR); } diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/processor/JPACUDRequestProcessor.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/processor/JPACUDRequestProcessor.java index 0d674be4c..738d15148 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/processor/JPACUDRequestProcessor.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/processor/JPACUDRequestProcessor.java @@ -19,7 +19,7 @@ import java.util.Map; import java.util.Optional; -import javax.persistence.EntityManager; +import jakarta.persistence.EntityManager; import org.apache.olingo.commons.api.data.Entity; import org.apache.olingo.commons.api.data.EntityCollection; @@ -69,7 +69,7 @@ import com.sap.olingo.jpa.processor.core.modify.JPACreateResultFactory; import com.sap.olingo.jpa.processor.core.modify.JPAUpdateResult; import com.sap.olingo.jpa.processor.core.query.EdmBindingTargetInfo; -import com.sap.olingo.jpa.processor.core.query.ExpressionUtil; +import com.sap.olingo.jpa.processor.core.query.ExpressionUtility; import com.sap.olingo.jpa.processor.core.query.Utility; public final class JPACUDRequestProcessor extends JPAAbstractRequestProcessor { @@ -90,7 +90,7 @@ public JPACUDRequestProcessor(final OData odata, final ServiceMetadata serviceMe public void clearFields(final ODataRequest request, final ODataResponse response) throws ODataJPAProcessException { - try (JPARuntimeMeasurement meassument = debugger.newMeasurement(this, "clearFields")) { + try (JPARuntimeMeasurement measurement = debugger.newMeasurement(this, "clearFields")) { final JPACUDRequestHandler handler = requestContext.getCUDRequestHandler(); final EdmBindingTargetInfo edmEntitySetInfo = Utility.determineBindingTargetAndKeys(uriInfo .getUriResourceParts()); @@ -102,7 +102,7 @@ public void clearFields(final ODataRequest request, final ODataResponse response if (!foreignTransaction) ownTransaction = requestContext.getTransactionFactory().createTransaction(); - try (JPARuntimeMeasurement updateMeassument = debugger.newMeasurement(this, DEBUG_UPDATE_ENTITY)) { + try (JPARuntimeMeasurement updateMeasurement = debugger.newMeasurement(this, DEBUG_UPDATE_ENTITY)) { handler.updateEntity(requestEntity, em, determineHttpVerb(request, uriInfo.getUriResourceParts())); if (!foreignTransaction) handler.validateChanges(em); @@ -122,7 +122,7 @@ public void clearFields(final ODataRequest request, final ODataResponse response public void createEntity(final ODataRequest request, final ODataResponse response, final ContentType requestFormat, final ContentType responseFormat) throws ODataApplicationException, ODataLibraryException { - try (JPARuntimeMeasurement meassument = debugger.newMeasurement(this, DEBUG_CREATE_ENTITY)) { + try (JPARuntimeMeasurement measurement = debugger.newMeasurement(this, DEBUG_CREATE_ENTITY)) { final JPACUDRequestHandler handler = requestContext.getCUDRequestHandler(); final EdmBindingTargetInfo edmEntitySetInfo = Utility.determineModifyEntitySetAndKeys(uriInfo .getUriResourceParts()); @@ -138,7 +138,7 @@ public void createEntity(final ODataRequest request, final ODataResponse respons final boolean foreignTransaction = requestContext.getTransactionFactory().hasActiveTransaction(); if (!foreignTransaction) ownTransaction = requestContext.getTransactionFactory().createTransaction(); - try (JPARuntimeMeasurement createMeassument = debugger.newMeasurement(this, DEBUG_CREATE_ENTITY)) { + try (JPARuntimeMeasurement createMeasurement = debugger.newMeasurement(this, DEBUG_CREATE_ENTITY)) { result = handler.createEntity(requestEntity, em); if (!foreignTransaction) handler.validateChanges(em); @@ -170,7 +170,7 @@ public void createEntity(final ODataRequest request, final ODataResponse respons */ public void deleteEntity(final ODataRequest request, final ODataResponse response) throws ODataJPAProcessException { - try (JPARuntimeMeasurement meassument = debugger.newMeasurement(this, "deleteEntity")) { + try (JPARuntimeMeasurement measurement = debugger.newMeasurement(this, "deleteEntity")) { final JPACUDRequestHandler handler = requestContext.getCUDRequestHandler(); final JPAEntityType et; final Map jpaKeyPredicates = new HashMap<>(); @@ -190,7 +190,7 @@ public void deleteEntity(final ODataRequest request, final ODataResponse respons final List uriKeyPredicates = uriResourceEntitySet.getKeyPredicates(); for (final UriParameter uriParam : uriKeyPredicates) { final JPAAttribute attribute = et.getPath(uriParam.getName()).getLeaf(); - jpaKeyPredicates.put(attribute.getInternalName(), ExpressionUtil.convertValueOnAttribute(odata, attribute, + jpaKeyPredicates.put(attribute.getInternalName(), ExpressionUtility.convertValueOnAttribute(odata, attribute, uriParam.getText(), true)); } } catch (final ODataException e) { @@ -203,7 +203,7 @@ public void deleteEntity(final ODataRequest request, final ODataResponse respons final boolean foreignTransaction = requestContext.getTransactionFactory().hasActiveTransaction(); if (!foreignTransaction) ownTransaction = requestContext.getTransactionFactory().createTransaction(); - try (JPARuntimeMeasurement deleteMeassument = debugger.newMeasurement(this, "deleteEntity")) { + try (JPARuntimeMeasurement deleteMeasurement = debugger.newMeasurement(this, "deleteEntity")) { handler.deleteEntity(requestEntity, em); if (!foreignTransaction) handler.validateChanges(em); @@ -225,7 +225,7 @@ public void deleteEntity(final ODataRequest request, final ODataResponse respons public void updateEntity(final ODataRequest request, final ODataResponse response, final ContentType requestFormat, final ContentType responseFormat) throws ODataJPAProcessException, ODataLibraryException { - try (JPARuntimeMeasurement meassument = debugger.newMeasurement(this, DEBUG_UPDATE_ENTITY)) { + try (JPARuntimeMeasurement measurement = debugger.newMeasurement(this, DEBUG_UPDATE_ENTITY)) { final JPACUDRequestHandler handler = requestContext.getCUDRequestHandler(); final EdmBindingTargetInfo edmBindingTargetInfo = Utility.determineModifyEntitySetAndKeys(uriInfo .getUriResourceParts()); @@ -277,11 +277,11 @@ public void updateEntity(final ODataRequest request, final ODataResponse respons checkForRollback(ownTransaction, foreignTransaction); throw new ODataJPAProcessorException(RETURN_NULL, INTERNAL_SERVER_ERROR); } - if (updateResult.getModifiedEntity() != null && !requestEntity.getEntityType().getTypeClass().isInstance( - updateResult.getModifiedEntity())) { + if (updateResult.modifiedEntity() != null && !requestEntity.getEntityType().getTypeClass().isInstance( + updateResult.modifiedEntity())) { checkForRollback(ownTransaction, foreignTransaction); throw new ODataJPAProcessorException(WRONG_RETURN_TYPE, INTERNAL_SERVER_ERROR, - updateResult.getModifiedEntity().getClass().toString(), requestEntity.getEntityType().getTypeClass() + updateResult.modifiedEntity().getClass().toString(), requestEntity.getEntityType().getTypeClass() .toString()); } if (!foreignTransaction) @@ -289,7 +289,7 @@ public void updateEntity(final ODataRequest request, final ODataResponse respons if (updateResult.wasCreate()) { createCreateResponse(request, response, responseFormat, requestEntity.getEntityType(), - (EdmEntitySet) edmBindingTargetInfo.getEdmBindingTarget(), updateResult.getModifiedEntity()); // Singleton + (EdmEntitySet) edmBindingTargetInfo.getEdmBindingTarget(), updateResult.modifiedEntity()); // Singleton } else { createUpdateResponse(request, response, responseFormat, requestEntity, edmBindingTargetInfo, updateResult); } @@ -666,7 +666,7 @@ private void createUpdateResponse(final ODataRequest request, final ODataRespons response.setStatusCode(NO_CONTENT.getStatusCode()); response.setHeader(HttpHeader.PREFERENCE_APPLIED, "return=minimal"); } else { - if (updateResult.getModifiedEntity() == null) + if (updateResult.modifiedEntity() == null) throw new ODataJPAProcessorException(RETURN_MISSING_ENTITY, INTERNAL_SERVER_ERROR); Entity updatedEntity = null; @@ -680,10 +680,10 @@ private void createUpdateResponse(final ODataRequest request, final ODataRespons if (path != null) { // PATCH .../Organizations('1')/AdministrativeInformation/Updated/User final JPARequestEntity linkedEntity = requestEntity.getRelatedEntities().get(path).get(0); - final Object linkedResult = getLinkedResult(updateResult.getModifiedEntity(), path, Optional.empty()); + final Object linkedResult = getLinkedResult(updateResult.modifiedEntity(), path, Optional.empty()); updatedEntity = convertEntity(linkedEntity.getEntityType(), linkedResult, request.getAllHeaders()); } else { - updatedEntity = convertEntity(requestEntity.getEntityType(), updateResult.getModifiedEntity(), request + updatedEntity = convertEntity(requestEntity.getEntityType(), updateResult.modifiedEntity(), request .getAllHeaders()); } final EntityCollection entities = new EntityCollection(); diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/processor/JPACoreDebugger.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/processor/JPACoreDebugger.java index d80bee287..e0112dfdf 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/processor/JPACoreDebugger.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/processor/JPACoreDebugger.java @@ -95,7 +95,7 @@ public void close() { final long runtime = (this.getTimeStopped() - this.getTimeStarted()) / 1000; final Long memory = memoryReader.getCurrentThreadMemoryConsumption() / 1000; LogFactory.getLog(this.getClassName()) - .info(String.format("thread: %d, method: %s, runtime [µs]: %d; memory [kb]: %d", + .debug(String.format("thread: %d, method: %s, runtime [µs]: %d; memory [kb]: %d", threadID, this.getMethodName(), runtime, diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/processor/JPAExpandWatchDog.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/processor/JPAExpandWatchDog.java index 5db06f5db..0ade748ed 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/processor/JPAExpandWatchDog.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/processor/JPAExpandWatchDog.java @@ -110,7 +110,7 @@ List filter(final List itemInfoList) { remainingLevels--; return itemInfoList.stream() .filter(info -> !nonExpandableProperties.contains(info.getExpandAssociation().getAlias())) - .collect(Collectors.toList()); + .toList(); } private void watchExpandLevel(@Nonnull final ExpandOption expandOption) throws ODataJPAProcessorException { diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/processor/JPAHookFactory.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/processor/JPAHookFactory.java index 934ac4678..1f25c580c 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/processor/JPAHookFactory.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/processor/JPAHookFactory.java @@ -8,7 +8,8 @@ import java.util.Optional; import javax.annotation.Nonnull; -import javax.persistence.EntityManager; + +import jakarta.persistence.EntityManager; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/processor/JPAJavaFunctionProcessor.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/processor/JPAJavaFunctionProcessor.java index 363d44c82..393dbbcc3 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/processor/JPAJavaFunctionProcessor.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/processor/JPAJavaFunctionProcessor.java @@ -50,9 +50,8 @@ public Object process() throws ODataApplicationException { } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | ODataJPAModelException e) { throw new ODataJPAProcessorException(e, HttpStatusCode.INTERNAL_SERVER_ERROR); } catch (final InvocationTargetException e) { - final Throwable cause = e.getCause(); - if (cause instanceof ODataApplicationException) { - throw (ODataApplicationException) cause; + if (e.getCause() instanceof final ODataApplicationException cause) { + throw cause; } else { throw new ODataJPAProcessorException(e, HttpStatusCode.INTERNAL_SERVER_ERROR); } diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/processor/JPAModifyUtil.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/processor/JPAModifyUtil.java index 7644a56e2..cd5be773c 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/processor/JPAModifyUtil.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/processor/JPAModifyUtil.java @@ -292,8 +292,9 @@ private Object determineSourceForLink(final Object sourceInstance, final JPAAsso Object next = getter.invoke(source); if (next == null) { try { - final Constructor c = ((JPAAttribute) pathItem).getStructuredType().getTypeClass().getConstructor(); - next = c.newInstance(); + final Constructor constructor = ((JPAAttribute) pathItem).getStructuredType().getTypeClass() + .getConstructor(); + next = constructor.newInstance(); final Method setter = source.getClass().getMethod("set" + methodSuffix, next.getClass()); setter.invoke(source, next); } catch (ODataJPAModelException | InstantiationException e) { @@ -327,8 +328,7 @@ private Object getAttribute(final Object instance, final JPAElement attribute) t } private void handleInvocationTargetException(final JPAStructuredType st, final String attributeName, - final Exception e) - throws ODataJPAInvocationTargetException, ODataJPAProcessorException { + final Exception exception) throws ODataJPAInvocationTargetException, ODataJPAProcessorException { String pathPart = null; try { @@ -336,18 +336,18 @@ private void handleInvocationTargetException(final JPAStructuredType st, final S HttpStatusCode.INTERNAL_SERVER_ERROR, attributeName)).getExternalName(); if (this.st != null && this.st.equals(st)) { final String path = st.getExternalName() + JPAPath.PATH_SEPARATOR + pathPart + JPAPath.PATH_SEPARATOR - + ((ODataJPAInvocationTargetException) e).getPath(); + + ((ODataJPAInvocationTargetException) exception).getPath(); this.st = null; - throw new ODataJPAInvocationTargetException(e.getCause(), path); + throw new ODataJPAInvocationTargetException(exception.getCause(), path); } } catch (final ODataJPAModelException e1) { throw new ODataJPAProcessorException(e1, HttpStatusCode.INTERNAL_SERVER_ERROR); } - if (e instanceof ODataJPAInvocationTargetException) - throw new ODataJPAInvocationTargetException(e.getCause(), pathPart + JPAPath.PATH_SEPARATOR - + ((ODataJPAInvocationTargetException) e).getPath()); + if (exception instanceof final ODataJPAInvocationTargetException invocationTargetException) + throw new ODataJPAInvocationTargetException(exception.getCause(), pathPart + JPAPath.PATH_SEPARATOR + + invocationTargetException.getPath()); else - throw new ODataJPAInvocationTargetException(e.getCause(), pathPart); + throw new ODataJPAInvocationTargetException(exception.getCause(), pathPart); } /** @@ -378,7 +378,7 @@ private void setAttribute(final Object instance, final JPAElement attribute, fin setter.invoke(instance, value); } - private void setAttributeDeep(final Object instance, final JPAStructuredType st, final Method meth, + private void setAttributeDeep(final Object instance, final JPAStructuredType st, final Method method, final String attributeName, final Object value, final Class[] parameters) throws ODataJPAProcessorException, ODataJPAInvocationTargetException { try { @@ -387,12 +387,12 @@ private void setAttributeDeep(final Object instance, final JPAStructuredType st, HttpStatusCode.INTERNAL_SERVER_ERROR, attributeName)); if (!attribute.isComplex() || value == null) { if (value == null || parameters[0].isAssignableFrom(value.getClass())) { - meth.invoke(instance, value); + method.invoke(instance, value); } } else if (attribute.isCollection()) { - setEmbeddedCollectionAttributeDeep(instance, st, meth, value, parameters, attribute); + setEmbeddedCollectionAttributeDeep(instance, st, method, value, parameters, attribute); } else { - setEmbeddedAttributeDeep(instance, st, meth, value, parameters, attribute); + setEmbeddedAttributeDeep(instance, st, method, value, parameters, attribute); } } catch (IllegalAccessException | IllegalArgumentException | ODataJPAModelException | NoSuchMethodException | SecurityException | InstantiationException e) { @@ -424,7 +424,7 @@ private void setEmbeddedAttributeDeep(final Object instance, final JPAStructured } @SuppressWarnings("unchecked") - private void setEmbeddedCollectionAttributeDeep(final Object instance, final JPAStructuredType st, final Method meth, + private void setEmbeddedCollectionAttributeDeep(final Object instance, final JPAStructuredType st, final Method method, final Object value, final Class[] parameters, final JPAAttribute attribute) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException, ODataJPAModelException, ODataJPAProcessorException, ODataJPAInvocationTargetException { @@ -437,7 +437,7 @@ private void setEmbeddedCollectionAttributeDeep(final Object instance, final JPA } else { embedded = (Collection) createInstance(parameters[0]); } - meth.invoke(instance, embedded); + method.invoke(instance, embedded); } if (embedded != null) { if (this.st == null) diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/processor/JPANavigationRequestProcessor.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/processor/JPANavigationRequestProcessor.java index 9cfc40a56..8530bb8a1 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/processor/JPANavigationRequestProcessor.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/processor/JPANavigationRequestProcessor.java @@ -77,7 +77,7 @@ public JPANavigationRequestProcessor(final OData odata, final ServiceMetadata se public > void retrieveData(final ODataRequest request, final ODataResponse response, final ContentType responseFormat) throws ODataException { - try (JPARuntimeMeasurement meassument = debugger.newMeasurement(this, "retrieveData")) { + try (JPARuntimeMeasurement measurement = debugger.newMeasurement(this, "retrieveData")) { checkRequestSupported(); // Create a JPQL Query and execute it @@ -98,7 +98,7 @@ public > void retrieveData(final ODataRequest request, f watchDog)); // Convert tuple result into an OData Result EntityCollection entityCollection; - try (JPARuntimeMeasurement converterMeassument = debugger.newMeasurement(this, "convertResult")) { + try (JPARuntimeMeasurement converterMeasurement = debugger.newMeasurement(this, "convertResult")) { entityCollection = result.asEntityCollection(new JPATupleChildConverter(sd, odata.createUriHelper(), serviceMetadata, requestContext)).get(ROOT_RESULT_KEY); } catch (final ODataApplicationException e) { @@ -146,7 +146,7 @@ else if (doesNotExists(entityCollection.getEntities())) response.setStatusCode(HttpStatusCode.NOT_FOUND.getStatusCode()); // 200 OK indicates that either a result was found or that the a Entity Collection query had no result else if (entityCollection.getEntities() != null) { - try (JPARuntimeMeasurement serializerMeassument = debugger.newMeasurement(this, "serialize")) { + try (JPARuntimeMeasurement serializerMeasurement = debugger.newMeasurement(this, "serialize")) { final SerializerResult serializerResult = serializer.serialize(request, entityCollection); createSuccessResponse(response, responseFormat, serializerResult); } @@ -164,14 +164,14 @@ private void checkRequestSupported() throws ODataJPAProcessException { } private URI buildNextLink(final JPAODataPage page) throws ODataJPAProcessorException { - if (page != null && page.getSkipToken() != null) { + if (page != null && page.skipToken() != null) { try { - if (page.getSkipToken() instanceof String) + if (page.skipToken() instanceof String) return new URI(Utility.determineBindingTarget(uriInfo.getUriResourceParts()).getName() + "?" - + SystemQueryOptionKind.SKIPTOKEN.toString() + "='" + page.getSkipToken() + "'"); + + SystemQueryOptionKind.SKIPTOKEN.toString() + "='" + page.skipToken() + "'"); else return new URI(Utility.determineBindingTarget(uriInfo.getUriResourceParts()).getName() + "?" - + SystemQueryOptionKind.SKIPTOKEN.toString() + "=" + page.getSkipToken().toString()); + + SystemQueryOptionKind.SKIPTOKEN.toString() + "=" + page.skipToken().toString()); } catch (final URISyntaxException e) { throw new ODataJPAProcessorException(ODATA_MAXPAGESIZE_NOT_A_NUMBER, HttpStatusCode.INTERNAL_SERVER_ERROR, e); } @@ -275,7 +275,7 @@ private Map readExpandEntities(final Map parentHops, final UriInfoResource uriResourceInfo, final Optional keyBoundary, final JPAExpandWatchDog watchDog) throws ODataException { - try (JPARuntimeMeasurement expandMeassument = debugger.newMeasurement(this, "readExpandEntities")) { + try (JPARuntimeMeasurement expandMeasurement = debugger.newMeasurement(this, "readExpandEntities")) { final JPAExpandQueryFactory factory = new JPAExpandQueryFactory(odata, requestContext, cb); final Map allExpResults = new HashMap<>(); diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/processor/JPAODataInternalRequestContext.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/processor/JPAODataInternalRequestContext.java index b2083a2b2..2f0769329 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/processor/JPAODataInternalRequestContext.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/processor/JPAODataInternalRequestContext.java @@ -13,7 +13,8 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; -import javax.persistence.EntityManager; + +import jakarta.persistence.EntityManager; import org.apache.olingo.commons.api.ex.ODataException; import org.apache.olingo.server.api.uri.UriInfo; @@ -42,7 +43,7 @@ import com.sap.olingo.jpa.processor.core.database.JPAODataDatabaseOperations; import com.sap.olingo.jpa.processor.core.exception.ODataJPAIllegalAccessException; import com.sap.olingo.jpa.processor.core.exception.ODataJPAProcessorException; -import com.sap.olingo.jpa.processor.core.query.ExpressionUtil; +import com.sap.olingo.jpa.processor.core.query.ExpressionUtility; import com.sap.olingo.jpa.processor.core.serializer.JPASerializer; public final class JPAODataInternalRequestContext implements JPAODataRequestContextAccess, @@ -204,7 +205,7 @@ public UriInfoResource getUriInfo() { @Override public Locale getLocale() { if (locales == null || locales.isEmpty()) - return ExpressionUtil.determineFallbackLocale(header); + return ExpressionUtility.determineFallbackLocale(header); return locales.get(0); } @@ -221,7 +222,7 @@ public void setEntityManager(@Nonnull final EntityManager em) { public void setJPAODataPage(@Nonnull final JPAODataPage page) throws ODataJPAIllegalAccessException { if (this.uriInfo != null) throw new ODataJPAIllegalAccessException(); - this.setUriInfo(page.getUriInfo()); + this.setUriInfo(page.uriInfo()); this.page = Objects.requireNonNull(page); } @@ -261,8 +262,8 @@ private void copyContextValues(final JPAODataRequestContextAccess context) this.cudRequestHandler = context.getCUDRequestHandler(); this.transactionFactory = context.getTransactionFactory(); this.locales = context.getProvidedLocale(); - this.debugSupport = context instanceof JPAODataInternalRequestContext ? ((JPAODataInternalRequestContext) context) - .getDebugSupport() : null; + this.debugSupport = context instanceof final JPAODataInternalRequestContext internalContext + ? internalContext.getDebugSupport() : null; this.dbProcessor = context.getDatabaseProcessor(); this.edmProvider = Optional.ofNullable(context.getEdmProvider()); this.operationConverter = context.getOperationConverter(); @@ -290,8 +291,8 @@ private Optional determineEdmProvider(final JPAODataSessionConte final EntityManager em) { try { return sessionContext.getEdmProvider() == null - && sessionContext instanceof JPAODataServiceContext - ? Optional.ofNullable(((JPAODataServiceContext) sessionContext).getEdmProvider(em)) + && sessionContext instanceof final JPAODataServiceContext serviceContext + ? Optional.ofNullable(serviceContext.getEdmProvider(em)) : Optional.ofNullable(sessionContext.getEdmProvider()); } catch (final ODataException e) { debugger.debug(this, Arrays.toString(e.getStackTrace())); diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/processor/JPAOperationRequestProcessor.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/processor/JPAOperationRequestProcessor.java index 64bbb1cc4..3357a90a8 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/processor/JPAOperationRequestProcessor.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/processor/JPAOperationRequestProcessor.java @@ -7,7 +7,7 @@ import java.util.Collection; import java.util.List; -import javax.persistence.EntityManager; +import jakarta.persistence.EntityManager; import org.apache.olingo.commons.api.data.Annotatable; import org.apache.olingo.commons.api.data.ComplexValue; @@ -129,8 +129,8 @@ protected void serializeResult(final EdmType returnType, final ODataResponse res throws ODataJPASerializerException, SerializerException { if (result != null - && !(result instanceof EntityCollection && ((EntityCollection) result).getEntities().isEmpty())) { - + && !(result instanceof final EntityCollection collection + && collection.getEntities().isEmpty())) { final SerializerResult serializerResult = ((JPAOperationSerializer) serializer).serialize(result, returnType, request); createSuccessResponse(response, responseFormat, serializerResult); @@ -142,11 +142,11 @@ protected void serializeResult(final EdmType returnType, final ODataResponse res protected Object createInstance(final EntityManager em, final JPAJavaOperation jpaOperation) throws InstantiationException, IllegalAccessException, InvocationTargetException { - final Constructor c = jpaOperation.getConstructor(); - if (c.getParameterCount() == 1) - return c.newInstance(em); + final Constructor constructor = jpaOperation.getConstructor(); + if (constructor.getParameterCount() == 1) + return constructor.newInstance(em); else - return c.newInstance(); + return constructor.newInstance(); } } diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/processor/JPAProcessorFactory.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/processor/JPAProcessorFactory.java index 6d2a2f5a4..92696746a 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/processor/JPAProcessorFactory.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/processor/JPAProcessorFactory.java @@ -85,7 +85,7 @@ public JPARequestProcessor createProcessor(final UriInfo uriInfo, final ContentT JPAODataRequestContextAccess requestContext; try { requestContext = new JPAODataInternalRequestContext(page, serializerFactory - .createSerializer(responseFormat, page.getUriInfo(), Optional.ofNullable(header.get( + .createSerializer(responseFormat, page.uriInfo(), Optional.ofNullable(header.get( HttpHeader.ODATA_MAX_VERSION))), context, header); } catch (final ODataJPAIllegalAccessException e) { throw new ODataJPAProcessorException(e, HttpStatusCode.INTERNAL_SERVER_ERROR); @@ -97,12 +97,7 @@ public JPARequestProcessor createProcessor(final UriInfo uriInfo, final ContentT case function: checkFunctionPathSupported(resourceParts); return new JPAFunctionRequestProcessor(odata, requestContext); - case complexProperty: - case primitiveProperty: - case navigationProperty: - case entitySet: - case singleton: - case value: + case complexProperty, primitiveProperty, navigationProperty, entitySet, singleton, value: checkNavigationPathSupported(resourceParts); return new JPANavigationRequestProcessor(odata, serviceMetadata, requestContext); default: @@ -144,8 +139,8 @@ private JPAODataPage getPage(final Map> headers, final UriI } else { final JPACountQuery countQuery = new JPAJoinQuery(odata, new JPAODataInternalRequestContext(uriInfo, requestContext, headers)); - final Integer preferredPagesize = getPreferredPagesize(headers); - final JPAODataPage firstPage = sessionContext.getPagingProvider().getFirstPage(uriInfo, preferredPagesize, + final Integer preferredPageSize = getPreferredPageSize(headers); + final JPAODataPage firstPage = sessionContext.getPagingProvider().getFirstPage(uriInfo, preferredPageSize, countQuery, requestContext.getEntityManager()); page = firstPage != null ? firstPage : page; } @@ -153,7 +148,7 @@ private JPAODataPage getPage(final Map> headers, final UriI return page; } - private Integer getPreferredPagesize(final Map> headers) throws ODataJPAProcessorException { + private Integer getPreferredPageSize(final Map> headers) throws ODataJPAProcessorException { final List preferredHeaders = getHeader("Prefer", headers); if (preferredHeaders != null) { diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/processor/JPARequestProcessor.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/processor/JPARequestProcessor.java index 84f098428..65f6b9c50 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/processor/JPARequestProcessor.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/processor/JPARequestProcessor.java @@ -2,13 +2,11 @@ import org.apache.olingo.commons.api.ex.ODataException; import org.apache.olingo.commons.api.format.ContentType; -import org.apache.olingo.server.api.ODataApplicationException; -import org.apache.olingo.server.api.ODataLibraryException; import org.apache.olingo.server.api.ODataRequest; import org.apache.olingo.server.api.ODataResponse; public interface JPARequestProcessor { public > void retrieveData(ODataRequest request, ODataResponse response, - ContentType responseFormat) throws ODataApplicationException, ODataLibraryException, ODataException; + ContentType responseFormat) throws ODataException; } diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/ComparableByteArray.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/ComparableByteArray.java index 56c55ee7d..d03454884 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/ComparableByteArray.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/ComparableByteArray.java @@ -8,15 +8,14 @@ class ComparableByteArray implements Comparable { private final String value; static byte[] unboxedArray(final Object object) { - if (object instanceof Byte[]) { - final Byte[] input = (Byte[]) object; + if (object instanceof final Byte[] input) { final byte[] result = new byte[input.length]; for (int i = 0; i < input.length; i++) { result[i] = input[i]; // NOSONAR } return result; - } else if (object instanceof byte[]) - return (byte[]) object; + } else if (object instanceof final byte[] bytes) + return bytes; else throw new IllegalArgumentException("Method called with wrong Type"); } @@ -41,10 +40,10 @@ public int hashCode() { } @Override - public boolean equals(final Object obj) { - if (this == obj) return true; - if (!(obj instanceof ComparableByteArray)) return false; // NOSONAR - final ComparableByteArray other = (ComparableByteArray) obj; + public boolean equals(final Object object) { + if (this == object) return true; + if (!(object instanceof ComparableByteArray)) return false; // NOSONAR + final ComparableByteArray other = (ComparableByteArray) object; return Arrays.equals(bytes, other.bytes); } } diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/ExpressionUtil.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/ExpressionUtility.java similarity index 91% rename from jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/ExpressionUtil.java rename to jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/ExpressionUtility.java index c4899b3c3..018121b71 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/ExpressionUtil.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/ExpressionUtility.java @@ -5,12 +5,12 @@ import java.util.Locale; import java.util.Map; -import javax.persistence.AttributeConverter; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.Expression; -import javax.persistence.criteria.From; -import javax.persistence.criteria.Join; -import javax.persistence.criteria.Path; +import jakarta.persistence.AttributeConverter; +import jakarta.persistence.criteria.CriteriaBuilder; +import jakarta.persistence.criteria.Expression; +import jakarta.persistence.criteria.From; +import jakarta.persistence.criteria.Join; +import jakarta.persistence.criteria.Path; import org.apache.olingo.commons.api.edm.EdmPrimitiveType; import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException; @@ -31,12 +31,12 @@ import com.sap.olingo.jpa.processor.core.exception.ODataJPAFilterException; import com.sap.olingo.jpa.processor.core.exception.ODataJPAQueryException; -public final class ExpressionUtil { +public final class ExpressionUtility { public static final int CONTAINS_ONLY_LANGU = 1; public static final int CONTAINS_LANGU_COUNTRY = 2; public static final String SELECT_ITEM_SEPARATOR = ","; - private ExpressionUtil() {} + private ExpressionUtility() {} public static Expression createEQExpression(final OData odata, final CriteriaBuilder cb, final From root, final JPAEntityType jpaEntity, final UriParameter keyPredicate) @@ -62,9 +62,9 @@ public static Path convertToCriteriaPath(final Map> jo final List jpaPath) { Path p = root; for (final JPAElement jpaPathElement : jpaPath) - if (jpaPathElement instanceof JPADescriptionAttribute) { + if (jpaPathElement instanceof final JPADescriptionAttribute descriptionAttribute) { final Join join = (Join) joinTables.get(jpaPathElement.getInternalName()); - p = join.get(((JPADescriptionAttribute) jpaPathElement).getDescriptionAttribute().getInternalName()); + p = join.get(descriptionAttribute.getDescriptionAttribute().getInternalName()); } else if (jpaPathElement instanceof JPACollectionAttribute) { p = joinTables.get(jpaPathElement.getExternalName()); } else { diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPAAbstractExpandQuery.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPAAbstractExpandQuery.java index e9ec18b2b..b84aac438 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPAAbstractExpandQuery.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPAAbstractExpandQuery.java @@ -8,12 +8,12 @@ import java.util.List; import java.util.Map; -import javax.persistence.Tuple; -import javax.persistence.criteria.Expression; -import javax.persistence.criteria.From; -import javax.persistence.criteria.Order; -import javax.persistence.criteria.Path; -import javax.persistence.criteria.Selection; +import jakarta.persistence.Tuple; +import jakarta.persistence.criteria.Expression; +import jakarta.persistence.criteria.From; +import jakarta.persistence.criteria.Order; +import jakarta.persistence.criteria.Path; +import jakarta.persistence.criteria.Selection; import org.apache.olingo.commons.api.ex.ODataException; import org.apache.olingo.commons.api.http.HttpStatusCode; @@ -135,7 +135,7 @@ protected List> buildExpandCountGroupBy(final From root) try { final List associationPathList = association.getJoinColumnsList(); for (final JPAOnConditionItem onCondition : associationPathList) { - groupBy.add(ExpressionUtil.convertToCriteriaPath(root, onCondition.getRightPath().getPath())); + groupBy.add(ExpressionUtility.convertToCriteriaPath(root, onCondition.getRightPath().getPath())); } } catch (final ODataJPAModelException e) { throw new ODataJPAQueryException(e, HttpStatusCode.BAD_REQUEST); @@ -160,7 +160,7 @@ protected List> buildExpandJoinPath(final From root) throws O try { final List associationPathList = association.getJoinColumnsList(); for (final JPAOnConditionItem onCondition : associationPathList) { - final Path p = ExpressionUtil.convertToCriteriaPath(root, onCondition.getRightPath().getPath()); + final Path p = ExpressionUtility.convertToCriteriaPath(root, onCondition.getRightPath().getPath()); p.alias(onCondition.getRightPath().getAlias()); selections.add(p); } diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPAAbstractJoinQuery.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPAAbstractJoinQuery.java index cfd0d26f8..1cea2ce00 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPAAbstractJoinQuery.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPAAbstractJoinQuery.java @@ -19,14 +19,14 @@ import java.util.Set; import java.util.stream.Collectors; -import javax.persistence.Tuple; -import javax.persistence.TypedQuery; -import javax.persistence.criteria.AbstractQuery; -import javax.persistence.criteria.CriteriaQuery; -import javax.persistence.criteria.From; -import javax.persistence.criteria.JoinType; -import javax.persistence.criteria.Path; -import javax.persistence.criteria.Root; +import jakarta.persistence.Tuple; +import jakarta.persistence.TypedQuery; +import jakarta.persistence.criteria.AbstractQuery; +import jakarta.persistence.criteria.CriteriaQuery; +import jakarta.persistence.criteria.From; +import jakarta.persistence.criteria.JoinType; +import jakarta.persistence.criteria.Path; +import jakarta.persistence.criteria.Root; import org.apache.olingo.commons.api.edm.EdmBindingTarget; import org.apache.olingo.commons.api.edm.EdmEntitySet; @@ -224,7 +224,7 @@ protected SelectionPathInfo buildSelectionPathList(final UriInfoResourc } } - protected > javax.persistence.criteria.Expression createBoundary( + protected > jakarta.persistence.criteria.Expression createBoundary( final List info, final Optional keyBoundary) throws ODataJPAQueryException { @@ -279,10 +279,10 @@ protected > javax.persistence.criteria.Expressio return joinTables; } - protected final javax.persistence.criteria.Expression createKeyWhere( + protected final jakarta.persistence.criteria.Expression createKeyWhere( final List info) throws ODataApplicationException { - javax.persistence.criteria.Expression whereCondition = null; + jakarta.persistence.criteria.Expression whereCondition = null; // Given key: Organizations('1')/Roles(...) for (final JPANavigationPropertyInfo naviInfo : info) { if (naviInfo.getKeyPredicates() != null) { @@ -299,10 +299,10 @@ protected final javax.persistence.criteria.Expression createKeyWhere( return whereCondition; } - protected javax.persistence.criteria.Expression createProtectionWhere( + protected jakarta.persistence.criteria.Expression createProtectionWhere( final Optional claimsProvider) throws ODataJPAQueryException { - javax.persistence.criteria.Expression restriction = null; + jakarta.persistence.criteria.Expression restriction = null; for (final JPANavigationPropertyInfo navigation : navigationInfo) { // for all participating entity types/tables try { final JPAEntityType et = navigation.getEntityType(); @@ -315,11 +315,11 @@ protected javax.persistence.criteria.Expression createProtectionWhere( return restriction; } - protected javax.persistence.criteria.Expression createWhere(final UriInfoResource uriInfo, + protected jakarta.persistence.criteria.Expression createWhere(final UriInfoResource uriInfo, final List navigationInfo) throws ODataApplicationException { try (JPARuntimeMeasurement serializerMeassument = debugger.newMeasurement(this, "createWhere")) { - javax.persistence.criteria.Expression whereCondition = null; + jakarta.persistence.criteria.Expression whereCondition = null; // Given keys: Organizations('1')/Roles(...) whereCondition = createKeyWhere(navigationInfo); // http://docs.oasis-open.org/odata/odata/v4.0/errata02/os/complete/part1-protocol/odata-v4.0-errata02-os-part1-protocol-complete.html#_Toc406398301 @@ -355,7 +355,7 @@ protected final boolean determineTargetIsCollection(final UriInfoResource uriRes final UriResource last = !uriResource.getUriResourceParts().isEmpty() ? uriResource.getUriResourceParts().get( uriResource.getUriResourceParts().size() - 1) : null; - return (last instanceof UriResourceProperty && ((UriResourceProperty) last).isCollection()); + return (last instanceof final UriResourceProperty property && property.isCollection()); } protected void expandPath(final JPAEntityType jpaEntity, final SelectionPathInfo jpaPathList, @@ -441,8 +441,8 @@ private void addCollection(final Map> joinTables, final JPAPa private void addSkip(final TypedQuery typedQuery) throws ODataJPAQueryException { final SkipOption skipOption = uriResource.getSkipOption(); if (skipOption != null || page != null) { - int skipNumber = skipOption != null ? skipOption.getValue() : page.getSkip(); - skipNumber = skipOption != null && page != null ? Math.max(skipOption.getValue(), page.getSkip()) : skipNumber; + int skipNumber = skipOption != null ? skipOption.getValue() : page.skip(); + skipNumber = skipOption != null && page != null ? Math.max(skipOption.getValue(), page.skip()) : skipNumber; if (skipNumber >= 0) typedQuery.setFirstResult(skipNumber); else @@ -451,14 +451,14 @@ private void addSkip(final TypedQuery typedQuery) throws ODataJPAQueryExc } } - private void addTop(final TypedQuery tq) throws ODataJPAQueryException { + private void addTop(final TypedQuery tupleQuery) throws ODataJPAQueryException { final TopOption topOption = uriResource.getTopOption(); if (topOption != null || page != null) { - int topNumber = topOption != null ? topOption.getValue() : page.getTop(); - topNumber = topOption != null && page != null ? Math.min(topOption.getValue(), page.getTop()) + int topNumber = topOption != null ? topOption.getValue() : page.top(); + topNumber = topOption != null && page != null ? Math.min(topOption.getValue(), page.top()) : topNumber; if (topNumber >= 0) - tq.setMaxResults(topNumber); + tupleQuery.setMaxResults(topNumber); else throw new ODataJPAQueryException(ODataJPAQueryException.MessageKeys.QUERY_PREPARATION_INVALID_VALUE, HttpStatusCode.BAD_REQUEST, Integer.toString(topNumber), "$top"); @@ -490,8 +490,8 @@ private void buildRequiredSelections(final JPAEntityType et, final JPAPath trans for (int i = 0; i < transientAttributePath.getPath().size() - 1; i++) { final JPAElement element = transientAttributePath.getPath().get(i); pathName.append(element.getExternalName()).append(JPAPath.PATH_SEPARATOR); - if (element instanceof JPAAttribute) { - st = ((JPAAttribute) element).getStructuredType(); + if (element instanceof final JPAAttribute attribute) { + st = attribute.getStructuredType(); } } @@ -606,11 +606,11 @@ private void copySelectableProperties(final SelectionPathInfo selectabl for (final JPAPath p : allPathList) { boolean skip = false; for (final JPAElement pathElement : p.getPath()) { - if (pathElement instanceof JPAAttribute) { - if (((JPAAttribute) pathElement).isTransient()) { + if (pathElement instanceof final JPAAttribute attribute) { + if (attribute.isTransient()) { addTransientAttribute(jpaEntity, selectablePathList, p); } - if (((JPAAttribute) pathElement).isCollection() || ((JPAAttribute) pathElement).isTransient()) { + if (attribute.isCollection() || attribute.isTransient()) { skip = true; break; } @@ -622,17 +622,17 @@ private void copySelectableProperties(final SelectionPathInfo selectabl } @SuppressWarnings("unchecked") - private > javax.persistence.criteria.Expression createBoundaryEquals( + private > jakarta.persistence.criteria.Expression createBoundaryEquals( final JPAEntityType et, final From from, final JPAKeyPair jpaKeyPair) throws ODataJPAModelException { - javax.persistence.criteria.Expression whereCondition = null; + jakarta.persistence.criteria.Expression whereCondition = null; final List keyElements = new ArrayList<>(et.getKey()); Collections.reverse(keyElements); for (final JPAAttribute keyElement : keyElements) { - final Path keyPath = (Path) ExpressionUtil.convertToCriteriaPath(from, et.getPath(keyElement + final Path keyPath = (Path) ExpressionUtility.convertToCriteriaPath(from, et.getPath(keyElement .getExternalName()) .getPath()); - final javax.persistence.criteria.Expression equalFragment = cb.equal(keyPath, jpaKeyPair.getMin().get( + final jakarta.persistence.criteria.Expression equalFragment = cb.equal(keyPath, jpaKeyPair.getMin().get( keyElement)); if (whereCondition == null) whereCondition = equalFragment; @@ -643,17 +643,17 @@ private > javax.persistence.criteria.Expression< } @SuppressWarnings("unchecked") - private > javax.persistence.criteria.Expression createBoundaryWithUpper( + private > jakarta.persistence.criteria.Expression createBoundaryWithUpper( final JPAEntityType et, final From from, final JPAKeyPair jpaKeyPair) throws ODataJPAModelException { final List keyElements = new ArrayList<>(et.getKey()); Collections.reverse(keyElements); - javax.persistence.criteria.Expression lowerExpression = null; - javax.persistence.criteria.Expression upperExpression = null; + jakarta.persistence.criteria.Expression lowerExpression = null; + jakarta.persistence.criteria.Expression upperExpression = null; for (int primaryIndex = 0; primaryIndex < keyElements.size(); primaryIndex++) { for (int secondaryIndex = primaryIndex; secondaryIndex < keyElements.size(); secondaryIndex++) { final JPAAttribute keyElement = keyElements.get(secondaryIndex); - final Path keyPath = (Path) ExpressionUtil.convertToCriteriaPath(from, + final Path keyPath = (Path) ExpressionUtility.convertToCriteriaPath(from, et.getPath(keyElement.getExternalName()).getPath()); final Y lowerBoundary = jpaKeyPair.getMinElement(keyElement); final Y upperBoundary = jpaKeyPair.getMaxElement(keyElement); diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPAAbstractQuery.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPAAbstractQuery.java index 76dc5f67e..eb14f70ac 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPAAbstractQuery.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPAAbstractQuery.java @@ -2,11 +2,13 @@ import static com.sap.olingo.jpa.processor.core.exception.ODataJPAQueryException.MessageKeys.MISSING_CLAIM; import static com.sap.olingo.jpa.processor.core.exception.ODataJPAQueryException.MessageKeys.MISSING_CLAIMS_PROVIDER; +import static com.sap.olingo.jpa.processor.core.exception.ODataJPAQueryException.MessageKeys.QUERY_PREPARATION_ORDER_BY_NOT_SUPPORTED; import static com.sap.olingo.jpa.processor.core.exception.ODataJPAQueryException.MessageKeys.QUERY_PREPARATION_ORDER_BY_TRANSIENT; import static com.sap.olingo.jpa.processor.core.exception.ODataJPAQueryException.MessageKeys.QUERY_RESULT_CONV_ERROR; import static com.sap.olingo.jpa.processor.core.exception.ODataJPAQueryException.MessageKeys.QUERY_RESULT_ENTITY_TYPE_ERROR; import static com.sap.olingo.jpa.processor.core.exception.ODataJPAQueryException.MessageKeys.WILDCARD_UPPER_NOT_SUPPORTED; import static java.util.stream.Collectors.toList; +import static org.apache.olingo.commons.api.http.HttpStatusCode.BAD_REQUEST; import static org.apache.olingo.commons.api.http.HttpStatusCode.INTERNAL_SERVER_ERROR; import static org.apache.olingo.commons.api.http.HttpStatusCode.NOT_IMPLEMENTED; @@ -21,19 +23,18 @@ import java.util.NoSuchElementException; import java.util.Optional; import java.util.Set; -import java.util.stream.Collectors; - -import javax.persistence.EntityManager; -import javax.persistence.criteria.AbstractQuery; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.Expression; -import javax.persistence.criteria.From; -import javax.persistence.criteria.Join; -import javax.persistence.criteria.JoinType; -import javax.persistence.criteria.Path; -import javax.persistence.criteria.Predicate; -import javax.persistence.criteria.Selection; -import javax.persistence.criteria.Subquery; + +import jakarta.persistence.EntityManager; +import jakarta.persistence.criteria.AbstractQuery; +import jakarta.persistence.criteria.CriteriaBuilder; +import jakarta.persistence.criteria.Expression; +import jakarta.persistence.criteria.From; +import jakarta.persistence.criteria.Join; +import jakarta.persistence.criteria.JoinType; +import jakarta.persistence.criteria.Path; +import jakarta.persistence.criteria.Predicate; +import jakarta.persistence.criteria.Selection; +import jakarta.persistence.criteria.Subquery; import org.apache.olingo.commons.api.edm.EdmEntityType; import org.apache.olingo.commons.api.edm.EdmNavigationProperty; @@ -149,9 +150,9 @@ public JPAServiceDebugger getDebugger() { public abstract From getRoot(); - protected javax.persistence.criteria.Expression addWhereClause( - javax.persistence.criteria.Expression whereCondition, - final javax.persistence.criteria.Expression additionalExpression) { + protected jakarta.persistence.criteria.Expression addWhereClause( + jakarta.persistence.criteria.Expression whereCondition, + final jakarta.persistence.criteria.Expression additionalExpression) { if (additionalExpression != null) { if (whereCondition == null) @@ -192,13 +193,13 @@ protected void createFromClauseOrderBy(final List orderByTar } } - protected List> createGroupBy(final Map> joinTables, // NOSONAR + protected List> createGroupBy(final Map> joinTables, // NOSONAR final From from, final Collection selectionPathList) { - try (JPARuntimeMeasurement serializerMeassument = debugger.newMeasurement(this, "createGroupBy")) { - final List> groupBy = new ArrayList<>(); + try (JPARuntimeMeasurement serializerMeasurement = debugger.newMeasurement(this, "createGroupBy")) { + final List> groupBy = new ArrayList<>(); for (final JPAPath jpaPath : selectionPathList) { - groupBy.add(ExpressionUtil.convertToCriteriaPath(joinTables, from, jpaPath.getPath())); + groupBy.add(ExpressionUtility.convertToCriteriaPath(joinTables, from, jpaPath.getPath())); } return groupBy; } @@ -208,17 +209,17 @@ protected Join createJoinFromPath(final String alias, final List root, final JoinType finalJoinType) { Join join = null; - JoinType jt; + JoinType joinType; for (int i = 0; i < pathList.size(); i++) { if (i == pathList.size() - 1) - jt = finalJoinType; + joinType = finalJoinType; else - jt = JoinType.INNER; + joinType = JoinType.INNER; if (i == 0) { - join = root.join(pathList.get(i).getInternalName(), jt); + join = root.join(pathList.get(i).getInternalName(), joinType); join.alias(alias); } else if (i < pathList.size()) { - join = join.join(pathList.get(i).getInternalName(), jt); + join = join.join(pathList.get(i).getInternalName(), joinType); join.alias(pathList.get(i).getExternalName()); } } @@ -250,34 +251,35 @@ protected List> createSelectClause(final Map> jo final Collection requestedProperties, final From target, final List groups) throws ODataApplicationException { // NOSONAR Allow subclasses to throw an exception - try (JPARuntimeMeasurement serializerMeassument = debugger.newMeasurement(this, "createSelectClause")) { + try (JPARuntimeMeasurement serializerMeasurement = debugger.newMeasurement(this, "createSelectClause")) { final List> selections = new ArrayList<>(); // Build select clause for (final JPAPath jpaPath : requestedProperties) { if (jpaPath.isPartOfGroups(groups)) { - final Path p = ExpressionUtil.convertToCriteriaPath(joinTables, target, jpaPath.getPath()); - p.alias(jpaPath.getAlias()); - selections.add(p); + final Path path = ExpressionUtility.convertToCriteriaPath(joinTables, target, jpaPath.getPath()); + path.alias(jpaPath.getAlias()); + selections.add(path); } } return selections; } } - protected javax.persistence.criteria.Expression createProtectionWhereForEntityType( + protected jakarta.persistence.criteria.Expression createProtectionWhereForEntityType( final Optional claimsProvider, final JPAEntityType et, final From from) throws ODataJPAQueryException { try { - javax.persistence.criteria.Expression restriction = null; + jakarta.persistence.criteria.Expression restriction = null; final Map> dummyJoinTables = new HashMap<>(1); for (final JPAProtectionInfo protection : et.getProtections()) { // look for protected attributes final List> values = claimsProvider.get().get(protection.getClaimName()); // NOSONAR if (values.isEmpty()) throw new ODataJPAQueryException(MISSING_CLAIM, HttpStatusCode.FORBIDDEN); if (!(containsAll(values))) { - final Path p = ExpressionUtil.convertToCriteriaPath(dummyJoinTables, from, protection.getPath().getPath()); - restriction = addWhereClause(restriction, createProtectionWhereForAttribute(values, p, protection + final Path path = ExpressionUtility.convertToCriteriaPath(dummyJoinTables, from, protection.getPath() + .getPath()); + restriction = addWhereClause(restriction, createProtectionWhereForAttribute(values, path, protection .supportsWildcards())); } } @@ -294,23 +296,23 @@ private boolean containsAll(final List> values) { .anyMatch(value -> JPAClaimsPair.ALL.equals(value.min)); } - protected Expression createWhereByKey(final JPANavigationPropertyInfo naviInfo) + protected Expression createWhereByKey(final JPANavigationPropertyInfo navigationInfo) throws ODataJPAModelException, ODataApplicationException { - return createWhereByKey(naviInfo.getFromClause(), naviInfo.getKeyPredicates(), naviInfo + return createWhereByKey(navigationInfo.getFromClause(), navigationInfo.getKeyPredicates(), navigationInfo .getEntityType()); } - protected javax.persistence.criteria.Expression createWhereByKey(final From root, + protected jakarta.persistence.criteria.Expression createWhereByKey(final From root, final List keyPredicates, final JPAEntityType et) throws ODataApplicationException { // .../Organizations('3') // .../BusinessPartnerRoles(BusinessPartnerID='6',RoleCategory='C') - javax.persistence.criteria.Expression compoundCondition = null; + jakarta.persistence.criteria.Expression compoundCondition = null; if (keyPredicates != null) { for (final UriParameter keyPredicate : keyPredicates) { try { - final javax.persistence.criteria.Expression equalCondition = - ExpressionUtil.createEQExpression(odata, cb, root, et, keyPredicate); + final jakarta.persistence.criteria.Expression equalCondition = + ExpressionUtility.createEQExpression(odata, cb, root, et, keyPredicate); compoundCondition = addWhereClause(compoundCondition, equalCondition); } catch (final ODataJPAModelException e) { throw new ODataJPAQueryException(e, HttpStatusCode.BAD_REQUEST); @@ -321,12 +323,12 @@ protected javax.persistence.criteria.Expression createWhereByKey(final } protected final Expression createWhereKeyIn(final JPAAssociationPath associationPath, - final From target, final Subquery sq) throws ODataJPAQueryException { + final From target, final Subquery subQuery) throws ODataJPAQueryException { try { final List> paths = createWhereKeyInPathList(associationPath, target); debugger.trace(this, "Creating WHERE snipped for in clause %s", paths); - return ((ProcessorCriteriaBuilder) cb).in(paths, sq); + return ((ProcessorCriteriaBuilder) cb).in(paths, subQuery); } catch (final ODataJPAModelException e) { throw new ODataJPAQueryException(ODataJPAQueryException.MessageKeys.QUERY_PREPARATION_ERROR, HttpStatusCode.INTERNAL_SERVER_ERROR, e); @@ -337,20 +339,20 @@ protected List> createWhereKeyInPathList(final JPAAssociationPath associ throws ODataJPAModelException { if (associationPath.hasJoinTable()) { - final JPAJoinTable jt = associationPath.getJoinTable(); + final JPAJoinTable joinTable = associationPath.getJoinTable(); // jt.getInverseJoinColumns().get(0).getLeftPath() - debugger.trace(this, "Creating WHERE snipped for key in with join conditions %s", jt.getJoinColumns()); - return jt + debugger.trace(this, "Creating WHERE snipped for key in with join conditions %s", joinTable.getJoinColumns()); + return joinTable .getJoinColumns() .stream() .map(JPAOnConditionItem::getRightPath) .map(JPAPath::getLeaf) .map(leaf -> target.get(leaf.getInternalName())) - .collect(toList()); + .collect(toList()); // NOSONAR } return associationPath.getJoinColumnsList().stream() .map(key -> mapOnToWhere(key, target)) - .collect(Collectors.toList()); + .collect(toList()); // NOSONAR } protected final List extractDescriptionAttributes(final Collection jpaPathList) { @@ -368,44 +370,48 @@ protected final List extractDescriptionAttributes(final Collection extractOrderByNaviAttributes(final OrderByOption orderBy) + protected List extractOrderByNavigationAttributes(final OrderByOption orderBy) throws ODataApplicationException { - final List naviAttributes = new ArrayList<>(); + final List navigationAttributes = new ArrayList<>(); if (orderBy != null) { for (final OrderByItem orderByItem : orderBy.getOrders()) { final org.apache.olingo.server.api.uri.queryoption.expression.Expression expression = orderByItem.getExpression(); - if (expression instanceof Member) { - final UriInfoResource resourcePath = ((Member) expression).getResourcePath(); + if (expression instanceof final Member member) { + final UriInfoResource resourcePath = member.getResourcePath(); final StringBuilder pathString = new StringBuilder(); for (final UriResource uriResource : resourcePath.getUriResourceParts()) { try { - if (uriResource instanceof UriResourceNavigation) { - final EdmNavigationProperty edmNaviProperty = ((UriResourceNavigation) uriResource).getProperty(); - naviAttributes.add(jpaEntity.getAssociationPath(edmNaviProperty.getName())); - } else if (uriResource instanceof UriResourceProperty && ((UriResourceProperty) uriResource) + if (uriResource instanceof final UriResourceNavigation resourceNavigation) { + final EdmNavigationProperty edmNavigationProperty = resourceNavigation.getProperty(); + navigationAttributes.add(jpaEntity.getAssociationPath(edmNavigationProperty.getName())); + } else if (uriResource instanceof final UriResourceProperty resourceProperty && resourceProperty .isCollection()) { pathString.append(((UriResourceProperty) uriResource).getProperty().getName()); final JPAPath jpaPath = jpaEntity.getPath(pathString.toString()); if (jpaPath.isTransient()) throw new ODataJPAQueryException(QUERY_PREPARATION_ORDER_BY_TRANSIENT, NOT_IMPLEMENTED, jpaPath .getLeaf().toString()); - naviAttributes.add(((JPACollectionAttribute) jpaPath.getLeaf()).asAssociation()); + navigationAttributes.add(((JPACollectionAttribute) jpaPath.getLeaf()).asAssociation()); - } else if (uriResource instanceof UriResourceProperty) { - pathString.append(((UriResourceProperty) uriResource).getProperty().getName()); + } else if (uriResource instanceof final UriResourceProperty resourceProperty) { + pathString.append(resourceProperty.getProperty().getName()); pathString.append(JPAPath.PATH_SEPARATOR); } } catch (final ODataJPAModelException e) { throw new ODataJPAQueryException(QUERY_RESULT_CONV_ERROR, INTERNAL_SERVER_ERROR, e); } } - } + } else + // TODO Support methods like tolower for order by as well + throw new ODataJPAQueryException(QUERY_PREPARATION_ORDER_BY_NOT_SUPPORTED, BAD_REQUEST, + expression.getClass().getSimpleName()); } } - debugger.trace(this, "The following navigation attributes in order by were found: %s", naviAttributes.toString()); - return naviAttributes; + debugger.trace(this, "The following navigation attributes in order by were found: %s", navigationAttributes + .toString()); + return navigationAttributes; } protected void generateDescriptionJoin(final Map> joinTables, final Set pathSet, @@ -425,9 +431,9 @@ protected void generateDescriptionJoin(final Map> joinTables, protected abstract Locale getLocale(); - protected javax.persistence.criteria.Expression orWhereClause( - javax.persistence.criteria.Expression whereCondition, - final javax.persistence.criteria.Expression additionalExpression) { + protected jakarta.persistence.criteria.Expression orWhereClause( + jakarta.persistence.criteria.Expression whereCondition, + final jakarta.persistence.criteria.Expression additionalExpression) { if (additionalExpression != null) { if (whereCondition == null) @@ -458,8 +464,8 @@ Set determineAllDescriptionPath(final List descriptionFields, abstract JPAODataRequestContextAccess getContext(); @SuppressWarnings({ "unchecked" }) - private > Predicate createBetween(final JPAClaimsPair value, final Path p) { - return cb.between((javax.persistence.criteria.Expression) p, (Y) value.min, (Y) value.max); + private > Predicate createBetween(final JPAClaimsPair value, final Path path) { + return cb.between((jakarta.persistence.criteria.Expression) path, (Y) value.min, (Y) value.max); } private Expression createOnCondition(final Join join, final JPADescriptionAttribute descriptionField, @@ -476,43 +482,42 @@ private Expression createOnCondition(final Join join, final JPADe } @SuppressWarnings("unchecked") - private javax.persistence.criteria.Expression createProtectionWhereForAttribute( - final List> values, final Path p, final boolean wildcardsSupported) + private jakarta.persistence.criteria.Expression createProtectionWhereForAttribute( + final List> values, final Path path, final boolean wildcardsSupported) throws ODataJPAQueryException { - javax.persistence.criteria.Expression attributeRestriction = null; + jakarta.persistence.criteria.Expression attributeRestriction = null; for (final JPAClaimsPair value : values) { // for each given claim value if (value.hasUpperBoundary) { if (wildcardsSupported && containsWildcard((String) value.min)) throw new ODataJPAQueryException(WILDCARD_UPPER_NOT_SUPPORTED, HttpStatusCode.BAD_REQUEST); else - attributeRestriction = orWhereClause(attributeRestriction, createBetween(value, p)); + attributeRestriction = orWhereClause(attributeRestriction, createBetween(value, path)); } else { if (wildcardsSupported && containsWildcard((String) value.min)) - attributeRestriction = orWhereClause(attributeRestriction, cb.like((Path) p, + attributeRestriction = orWhereClause(attributeRestriction, cb.like((Path) path, ((String) value.min).replace('*', '%').replace('+', '_'))); else - attributeRestriction = orWhereClause(attributeRestriction, cb.equal(p, value.min)); + attributeRestriction = orWhereClause(attributeRestriction, cb.equal(path, value.min)); } } return attributeRestriction; } private boolean containsWildcard(final String min) { - // TODO: Check regex usage after upgrade to java >= 9 min.matches(PERMISSIONS_REGEX) return min.contains("*") || min.contains("+") || min.contains("%") || min.contains("_"); } - private javax.persistence.criteria.Expression determineLocalePath(final Join join, + private jakarta.persistence.criteria.Expression determineLocalePath(final Join join, final JPAPath jpaPath) { - Path p = join; + Path path = join; for (final JPAElement pathElement : jpaPath.getPath()) { - p = p.get(pathElement.getInternalName()); + path = path.get(pathElement.getInternalName()); } - return p; + return path; } private Path mapOnToWhere(final JPAOnConditionItem on, final From target) { @@ -543,14 +548,16 @@ protected Expression createWhereTableJoin(final From joinRoot, fi final JPAAssociationPath association, final boolean useInverse) throws ODataJPAQueryException { if (association.hasJoinTable()) { try { - final JPAJoinTable jt = association.getJoinTable(); - final List jcl = useInverse ? jt.getInverseJoinColumns() : jt.getJoinColumns(); - debugger.trace(this, "Creating WHERE snipped for join table %s with join conditions %s and inverse: %s", jt - .toString(), jcl, useInverse); + final JPAJoinTable jpaJoinTable = association.getJoinTable(); + final List joinColumns = useInverse ? jpaJoinTable.getInverseJoinColumns() : jpaJoinTable + .getJoinColumns(); + debugger.trace(this, "Creating WHERE snipped for join table %s with join conditions %s and inverse: %s", + jpaJoinTable + .toString(), joinColumns, useInverse); debugger.trace(this, "Creating WHERE snipped for join table, with target: '%s', root: '%s'", joinTable .getJavaType(), joinRoot.getJavaType()); Expression whereCondition = null; - for (final JPAOnConditionItem jc : jcl) { + for (final JPAOnConditionItem jc : joinColumns) { final String leftColumn = jc.getLeftPath().getLeaf().getInternalName(); final String rightColumn = jc.getRightPath().getLeaf().getInternalName(); final Path left = useInverse ? joinRoot.get(leftColumn) : joinRoot.get(rightColumn); diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPAAbstractSubQuery.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPAAbstractSubQuery.java index fb44080e6..2b850063b 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPAAbstractSubQuery.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPAAbstractSubQuery.java @@ -6,12 +6,13 @@ import java.util.Optional; import javax.annotation.Nullable; -import javax.persistence.EntityManager; -import javax.persistence.criteria.AbstractQuery; -import javax.persistence.criteria.Expression; -import javax.persistence.criteria.From; -import javax.persistence.criteria.Path; -import javax.persistence.criteria.Subquery; + +import jakarta.persistence.EntityManager; +import jakarta.persistence.criteria.AbstractQuery; +import jakarta.persistence.criteria.Expression; +import jakarta.persistence.criteria.From; +import jakarta.persistence.criteria.Path; +import jakarta.persistence.criteria.Subquery; import org.apache.olingo.commons.api.edm.EdmEntityType; import org.apache.olingo.commons.api.http.HttpStatusCode; @@ -216,11 +217,11 @@ protected void handleAggregation(final Subquery subQuery, final From gr protected UriResourceKind getAggregationType(final VisitableExpression expression) { UriInfoResource member = null; - if (expression instanceof Binary) { - if (((Binary) expression).getLeftOperand() instanceof JPAMemberOperator) - member = ((JPAMemberOperator) ((Binary) expression).getLeftOperand()).getMember().getResourcePath(); - else if (((Binary) expression).getRightOperand() instanceof JPAMemberOperator) - member = ((JPAMemberOperator) ((Binary) expression).getRightOperand()).getMember().getResourcePath(); + if (expression instanceof final Binary binary) { + if (binary.getLeftOperand() instanceof final JPAMemberOperator leftMemberOperator) + member = leftMemberOperator.getMember().getResourcePath(); + else if (binary.getRightOperand() instanceof final JPAMemberOperator rightMemberOperator) + member = rightMemberOperator.getMember().getResourcePath(); } else if (expression instanceof JPAFilterExpression || expression instanceof JPACountExpression) { member = ((JPAVisitableExpression) expression).getMember(); diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPACollectionFilterQuery.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPACollectionFilterQuery.java index 27a357e97..fd77c621d 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPACollectionFilterQuery.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPACollectionFilterQuery.java @@ -3,11 +3,12 @@ import java.util.List; import javax.annotation.Nullable; -import javax.persistence.EntityManager; -import javax.persistence.criteria.Expression; -import javax.persistence.criteria.From; -import javax.persistence.criteria.JoinType; -import javax.persistence.criteria.Subquery; + +import jakarta.persistence.EntityManager; +import jakarta.persistence.criteria.Expression; +import jakarta.persistence.criteria.From; +import jakarta.persistence.criteria.JoinType; +import jakarta.persistence.criteria.Subquery; import org.apache.olingo.commons.api.http.HttpStatusCode; import org.apache.olingo.server.api.OData; diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPACollectionJoinQuery.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPACollectionJoinQuery.java index 08c6cecd4..e27064617 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPACollectionJoinQuery.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPACollectionJoinQuery.java @@ -15,13 +15,13 @@ import java.util.Optional; import java.util.stream.Collectors; -import javax.persistence.Tuple; -import javax.persistence.TypedQuery; -import javax.persistence.criteria.Expression; -import javax.persistence.criteria.From; -import javax.persistence.criteria.Order; -import javax.persistence.criteria.Path; -import javax.persistence.criteria.Selection; +import jakarta.persistence.Tuple; +import jakarta.persistence.TypedQuery; +import jakarta.persistence.criteria.Expression; +import jakarta.persistence.criteria.From; +import jakarta.persistence.criteria.Order; +import jakarta.persistence.criteria.Path; +import jakarta.persistence.criteria.Selection; import org.apache.olingo.commons.api.ex.ODataException; import org.apache.olingo.server.api.OData; @@ -57,11 +57,11 @@ public JPACollectionJoinQuery(final OData odata, final JPACollectionItemInfo ite @Override public JPACollectionQueryResult execute() throws ODataApplicationException { - try (JPARuntimeMeasurement meassument = debugger.newMeasurement(this, "executeStandardQuery")) { + try (JPARuntimeMeasurement measurement = debugger.newMeasurement(this, "executeStandardQuery")) { final SelectionPathInfo requestedSelection = buildSelectionPathList(this.uriResource); final TypedQuery tupleQuery = createTupleQuery(requestedSelection); List intermediateResult; - try (JPARuntimeMeasurement resultMeassument = debugger.newMeasurement(this, "getResultList")) { + try (JPARuntimeMeasurement resultMeasurement = debugger.newMeasurement(this, "getResultList")) { intermediateResult = tupleQuery.getResultList(); } final Map> result = convertResult(intermediateResult, association, 0, Long.MAX_VALUE); @@ -113,10 +113,11 @@ protected SelectionPathInfo buildSelectionPathList(final UriInfoResourc return jpaPathList; } - private JPAPath selectItemAsPath(final String pathPrefix, final SelectItem sItem) throws ODataJPAModelException, + private JPAPath selectItemAsPath(final String pathPrefix, final SelectItem selectionItem) + throws ODataJPAModelException, ODataJPAQueryException { - String pathItem = sItem.getResourcePath().getUriResourceParts().stream().map(path -> (path + String pathItem = selectionItem.getResourcePath().getUriResourceParts().stream().map(path -> (path .getSegmentValue())).collect(Collectors.joining(JPAPath.PATH_SEPARATOR)); pathItem = pathPrefix == null || pathPrefix.isEmpty() ? pathItem : pathPrefix + JPAPath.PATH_SEPARATOR + pathItem; @@ -131,7 +132,7 @@ protected List> createSelectClause(final Map> jo final Collection jpaPathList, final From target, final List groups) throws ODataApplicationException { // NOSONAR Allow // subclasses to throw an exception - try (JPARuntimeMeasurement meassument = debugger.newMeasurement(this, "createSelectClause")) { + try (JPARuntimeMeasurement measurement = debugger.newMeasurement(this, "createSelectClause")) { final List> selections = new ArrayList<>(); // Based on an error in Eclipse Link first the join columns have to be selected. Otherwise the alias is assigned // to @@ -144,9 +145,9 @@ protected List> createSelectClause(final Map> jo // Build select clause for (final JPAPath jpaPath : jpaPathList) { if (jpaPath.isPartOfGroups(groups)) { - final Path p = ExpressionUtil.convertToCriteriaPath(joinTables, target, jpaPath.getPath()); - p.alias(jpaPath.getAlias()); - selections.add(p); + final Path path = ExpressionUtility.convertToCriteriaPath(joinTables, target, jpaPath.getPath()); + path.alias(jpaPath.getAlias()); + selections.add(path); } } return selections; @@ -201,12 +202,12 @@ private String buildConcatenatedKey(final Tuple row, final JPAAssociationPath as if (!associationPath.hasJoinTable()) { final List joinColumns = associationPath.getRightColumnsList(); return joinColumns.stream() - .map(c -> (row.get(c.getAlias())).toString()) + .map(column -> (row.get(column.getAlias())).toString()) .collect(joining(JPAPath.PATH_SEPARATOR)); } else { final List joinColumns = associationPath.getLeftColumnsList(); return joinColumns.stream() - .map(c -> (row.get(association.getAlias() + ALIAS_SEPARATOR + c.getAlias())).toString()) + .map(column -> (row.get(association.getAlias() + ALIAS_SEPARATOR + column.getAlias())).toString()) .collect(joining(JPAPath.PATH_SEPARATOR)); } } @@ -238,13 +239,13 @@ private TypedQuery createTupleQuery(final SelectionPathInfo sele throws ODataApplicationException, JPANoSelectionException { - try (JPARuntimeMeasurement meassument = debugger.newMeasurement(this, "createTupleQuery")) { + try (JPARuntimeMeasurement measurement = debugger.newMeasurement(this, "createTupleQuery")) { final Map> joinTables = createFromClause(new ArrayList<>(1), selectionPath.joinedPersistent(), cq, lastInfo); // TODO handle Join Column is ignored cq.multiselect(createSelectClause(joinTables, selectionPath.joinedPersistent(), target, groups)); cq.distinct(true); - final javax.persistence.criteria.Expression whereClause = createWhere(); + final jakarta.persistence.criteria.Expression whereClause = createWhere(); if (whereClause != null) cq.where(whereClause); @@ -258,8 +259,8 @@ private TypedQuery createTupleQuery(final SelectionPathInfo sele private Expression createWhere() throws ODataApplicationException { - try (JPARuntimeMeasurement meassument = debugger.newMeasurement(this, "createWhere")) { - javax.persistence.criteria.Expression whereCondition = null; + try (JPARuntimeMeasurement measurement = debugger.newMeasurement(this, "createWhere")) { + jakarta.persistence.criteria.Expression whereCondition = null; // Given keys: Organizations('1')/Roles(...) whereCondition = createKeyWhere(navigationInfo); whereCondition = addWhereClause(whereCondition, createBoundary(navigationInfo, keyBoundary)); @@ -288,7 +289,7 @@ private void createAdditionSelectionForJoinTable(final List> select final From parent = determineParentFrom(); // e.g. JoinSource try { for (final JPAPath p : association.getLeftColumnsList()) { - final Path selection = ExpressionUtil.convertToCriteriaPath(parent, p.getPath()); + final Path selection = ExpressionUtility.convertToCriteriaPath(parent, p.getPath()); // If source and target of an association use the same name for their key we get conflicts with the alias. // Therefore it is necessary to unify them. selection.alias(association.getAlias() + ALIAS_SEPARATOR + p.getAlias()); @@ -301,7 +302,7 @@ private void createAdditionSelectionForJoinTable(final List> select private boolean pathContainsCollection(final JPAPath p) { for (final JPAElement pathElement : p.getPath()) { - if (pathElement instanceof JPAAttribute && ((JPAAttribute) pathElement).isCollection()) { + if (pathElement instanceof final JPAAttribute attribute && attribute.isCollection()) { return true; } } diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPACollectionQueryResult.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPACollectionQueryResult.java index 57c9c17a8..ce6bd6b83 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPACollectionQueryResult.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPACollectionQueryResult.java @@ -6,7 +6,7 @@ import java.util.List; import java.util.Map; -import javax.persistence.Tuple; +import jakarta.persistence.Tuple; import org.apache.olingo.commons.api.data.Entity; import org.apache.olingo.commons.api.data.EntityCollection; diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPACountWatchDog.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPACountWatchDog.java index 024710a4d..bb479409b 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPACountWatchDog.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPACountWatchDog.java @@ -106,10 +106,10 @@ private String buildPath(final UriInfoResource uriResource) { final List pathItems = new ArrayList<>(uriResource.getUriResourceParts().size()); for (int i = 1; i < uriResource.getUriResourceParts().size() - 1; i++) { final UriResource resourcePart = uriResource.getUriResourceParts().get(i); - if (resourcePart instanceof UriResourceNavigation) - pathItems.add(((UriResourceNavigation) resourcePart).getProperty().getName()); - if (resourcePart instanceof UriResourceProperty && ((UriResourceProperty) resourcePart).isCollection()) - pathItems.add(((UriResourceProperty) resourcePart).getProperty().getName()); + if (resourcePart instanceof final UriResourceNavigation navigation) + pathItems.add(navigation.getProperty().getName()); + if (resourcePart instanceof final UriResourceProperty property && property.isCollection()) + pathItems.add(property.getProperty().getName()); } return pathItems.stream().collect(Collectors.joining("/")); } diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPAExpandFilterQuery.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPAExpandFilterQuery.java index 02d936bda..4ab243ed5 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPAExpandFilterQuery.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPAExpandFilterQuery.java @@ -16,12 +16,13 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; -import javax.persistence.criteria.Expression; -import javax.persistence.criteria.From; -import javax.persistence.criteria.Order; -import javax.persistence.criteria.Path; -import javax.persistence.criteria.Selection; -import javax.persistence.criteria.Subquery; + +import jakarta.persistence.criteria.Expression; +import jakarta.persistence.criteria.From; +import jakarta.persistence.criteria.Order; +import jakarta.persistence.criteria.Path; +import jakarta.persistence.criteria.Selection; +import jakarta.persistence.criteria.Subquery; import org.apache.olingo.commons.api.edm.EdmEntityType; import org.apache.olingo.commons.api.ex.ODataException; @@ -57,51 +58,53 @@ class JPAExpandFilterQuery extends JPAAbstractSubQuery { final Map> joinTables; JPAExpandFilterQuery(final OData odata, final JPAODataRequestContextAccess requestContext, - final JPANavigationPropertyInfo naviInfo, final JPAAbstractQuery parent, + final JPANavigationPropertyInfo navigationInfo, final JPAAbstractQuery parent, final JPAAssociationPath childAssociation) throws ODataException { super(odata, requestContext.getEdmProvider().getServiceDocument(), - (EdmEntityType) naviInfo.getUriResource().getType(), + (EdmEntityType) navigationInfo.getUriResource().getType(), requestContext.getEntityManager(), parent, null, - naviInfo.getAssociationPath(), + navigationInfo.getAssociationPath(), requestContext.getClaimsProvider()); this.requestContext = requestContext; - this.keyPredicates = naviInfo.getKeyPredicates(); + this.keyPredicates = navigationInfo.getKeyPredicates(); this.subQuery = parent.getQuery().subquery(this.jpaEntity.getKeyType()); this.locale = parent.getLocale(); - this.navigationInfo = naviInfo; + this.navigationInfo = navigationInfo; this.childAssociation = Optional.ofNullable(childAssociation); this.joinTables = new HashMap<>(); this.debugger = requestContext.getDebugger(); - setFilter(navigationInfo); + setFilter(this.navigationInfo); } public JPAExpandFilterQuery(final OData odata, final JPAODataRequestContextAccess requestContext, - final JPANavigationPropertyInfo naviInfo, final JPAAbstractQuery parent, final JPAAssociationPath association, + final JPANavigationPropertyInfo navigationInfo, final JPAAbstractQuery parent, + final JPAAssociationPath association, final JPAAssociationPath childAssociation) throws ODataException { super(odata, requestContext.getEdmProvider().getServiceDocument(), - (EdmEntityType) naviInfo.getUriResource().getType(), + (EdmEntityType) navigationInfo.getUriResource().getType(), requestContext.getEntityManager(), parent, null, association, requestContext.getClaimsProvider()); this.requestContext = requestContext; - this.keyPredicates = naviInfo.getKeyPredicates(); + this.keyPredicates = navigationInfo.getKeyPredicates(); this.subQuery = parent.getQuery().subquery(this.jpaEntity.getKeyType()); this.locale = parent.getLocale(); - this.navigationInfo = naviInfo; + this.navigationInfo = navigationInfo; this.childAssociation = Optional.ofNullable(childAssociation); this.joinTables = new HashMap<>(); this.debugger = requestContext.getDebugger(); - setFilter(navigationInfo); + setFilter(this.navigationInfo); } + @SuppressWarnings("unchecked") @Override public From getRoot() { return queryRoot; @@ -116,10 +119,10 @@ public JPAExpandFilterQuery(final OData odata, final JPAODataRequestContextAcces public Subquery getSubQuery(@Nullable final Subquery childQuery, final VisitableExpression expression) throws ODataApplicationException { // Last childQuery == null - try (JPARuntimeMeasurement meassument = debugger.newMeasurement(this, "createSubQuery")) { + try (JPARuntimeMeasurement measurement = debugger.newMeasurement(this, "createSubQuery")) { final ProcessorSubquery nextQuery = (ProcessorSubquery) this.subQuery; final JPAQueryPair queries = createQueries(childQuery); - final List orderByAttributes = extractOrderByNaviAttributes(navigationInfo.getUriInfo() + final List orderByAttributes = extractOrderByNavigationAttributes(navigationInfo.getUriInfo() .getOrderByOption()); createRoots(childQuery, queries, nextQuery); buildJoinTable(orderByAttributes, emptyList(), childQuery); @@ -134,16 +137,16 @@ public Subquery getSubQuery(@Nullable final Subquery childQuery, } } - protected final JPAFilterCrossComplier addFilterCompiler(final JPANavigationPropertyInfo naviInfo) + protected final JPAFilterCrossComplier addFilterCompiler(final JPANavigationPropertyInfo navigationInfo) throws ODataJPAModelException, ODataJPAProcessorException, ODataJPAQueryException { final JPAOperationConverter converter = new JPAOperationConverter(cb, requestContext.getOperationConverter()); - final JPAODataRequestContextAccess subContext = new JPAODataInternalRequestContext(naviInfo.getUriInfo(), + final JPAODataRequestContextAccess subContext = new JPAODataInternalRequestContext(navigationInfo.getUriInfo(), requestContext); final JPAFilterRestrictionsWatchDog watchDog = new JPAFilterRestrictionsWatchDog(this.association.getLeaf()); - return new JPAFilterCrossComplier(odata, sd, naviInfo.getEntityType(), converter, this, - naviInfo.getFromClause(), null, subContext, watchDog); + return new JPAFilterCrossComplier(odata, sd, navigationInfo.getEntityType(), converter, this, + navigationInfo.getFromClause(), null, subContext, watchDog); } @Override @@ -169,11 +172,11 @@ void buildJoinTable(final List orderByAttributes, final Coll private void createFromClauseJoinTable(final Map> joinTables, final Subquery childQuery) { if (!hasRowLimit(childQuery)) { - final Optional jtEt = childAssociation + final Optional joinTableEt = childAssociation .map(JPAAssociationPath::getJoinTable) .map(JPAJoinTable::getEntityType); - jtEt.ifPresent(et -> { - debugger.trace(this, "Join table found: %s, join will be created", jtEt.toString()); + joinTableEt.ifPresent(et -> { + debugger.trace(this, "Join table found: %s, join will be created", joinTableEt.toString()); queryJoinTable = subQuery.from(et.getTypeClass()); queryJoinTable.alias(association.getAlias()); joinTables.put(association.getAlias(), queryJoinTable); @@ -181,10 +184,11 @@ private void createFromClauseJoinTable(final Map> joinTables, } } - void setFilter(final JPANavigationPropertyInfo naviInfo) throws ODataJPAModelException, ODataJPAProcessorException, + void setFilter(final JPANavigationPropertyInfo navigationInfo) throws ODataJPAModelException, + ODataJPAProcessorException, ODataJPAQueryException { - if (naviInfo.getFilterCompiler() == null) - naviInfo.setFilterCompiler(addFilterCompiler(naviInfo)); + if (navigationInfo.getFilterCompiler() == null) + navigationInfo.setFilterCompiler(addFilterCompiler(navigationInfo)); } private List> createGroupBy(final Subquery childQuery, @@ -192,8 +196,8 @@ private List> createGroupBy(final Subquery childQuery, if (!orderByAttributes.isEmpty()) { return selections.stream() - .map(p -> mapOnToSelection(p, queryRoot, childQuery)) - .collect(toList()); + .map(path -> mapOnToSelection(path, queryRoot, childQuery)) + .collect(toList()); // NOSONAR } return emptyList(); } @@ -210,14 +214,15 @@ JPAQueryPair createQueries(@Nullable final Subquery childQuery) throws ODataA if (hasRowLimit(navigationInfo) && childQuery != null) { debugger.trace(this, "Row number required"); - JPARowNumberFilterQuery rq; + JPARowNumberFilterQuery rowNumberQuery; try { - rq = new JPARowNumberFilterQuery(odata, requestContext, navigationInfo, parentQuery, childAssociation, jpaEntity - .getKeyPath()); + rowNumberQuery = new JPARowNumberFilterQuery(odata, requestContext, navigationInfo, parentQuery, + childAssociation, jpaEntity + .getKeyPath()); } catch (final ODataException e) { throw new ODataJPAQueryException(e, INTERNAL_SERVER_ERROR); } - return new JPAQueryPair(rq, this); + return new JPAQueryPair(rowNumberQuery, this); } else { debugger.trace(this, "Row number not required"); return new JPAQueryPair(this, this); @@ -228,7 +233,7 @@ void createRoots(final Subquery childQuery, final JPAQueryPair queries, final ProcessorSubquery nextQuery) throws ODataApplicationException { if (hasRowLimit(childQuery)) - this.queryRoot = nextQuery.from((ProcessorSubquery) ((JPARowNumberFilterQuery) queries.getInner()).getSubQuery( + this.queryRoot = nextQuery.from((ProcessorSubquery) ((JPARowNumberFilterQuery) queries.inner()).getSubQuery( childQuery, null)); else this.queryRoot = subQuery.from(this.jpaEntity.getTypeClass()); @@ -281,21 +286,21 @@ private boolean hasRowLimit(@Nullable final Subquery childQuery) { } Expression mapOnToSelection(final JPAPath on, final From root, @Nullable final Subquery childQuery) { - final Path p; + final Path path; if (hasRowLimit(childQuery)) { - p = root.get(on.getAlias()); + path = root.get(on.getAlias()); } else { - p = ExpressionUtil.convertToCriteriaPath(root, on.getPath()); + path = ExpressionUtility.convertToCriteriaPath(root, on.getPath()); } - p.alias(on.getLeaf().getInternalName()); - return p; + path.alias(on.getLeaf().getInternalName()); + return path; } private List> selectIn(final Subquery childQuery, final List selections) { return selections.stream() - .map(p -> mapOnToSelection(p, queryRoot, childQuery)) - .collect(toList()); + .map(path -> mapOnToSelection(path, queryRoot, childQuery)) + .collect(toList());// NOSONAR } private List selectionPathIn() throws ODataJPAQueryException { @@ -305,7 +310,7 @@ private List selectionPathIn() throws ODataJPAQueryException { : association.getJoinColumnsList(); return columns.stream() .map(JPAOnConditionItem::getLeftPath) - .collect(toList()); + .toList(); } catch (final ODataJPAModelException e) { if (e.getId().equals(NO_JOIN_TABLE_TYPE.getKey())) { throw new ODataJPAQueryException(QUERY_PREPARATION_JOIN_TABLE_TYPE_MISSING, INTERNAL_SERVER_ERROR, diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPAExpandItemInfoFactory.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPAExpandItemInfoFactory.java index 8b48aa6b1..774dcf749 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPAExpandItemInfoFactory.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPAExpandItemInfoFactory.java @@ -79,8 +79,8 @@ public List buildCollectionItemInfo(final JPAServiceDocum final List itemList = new ArrayList<>(); final List startResourceList = uriResourceInfo.getUriResourceParts(); final SelectOption select = uriResourceInfo.getSelectOption(); - final JPAEntityType et = uriResourceInfo instanceof JPAExpandItem ? ((JPAExpandItem) uriResourceInfo) - .getEntityType() : null; + final JPAEntityType et = uriResourceInfo instanceof final JPAExpandItem expandItem + ? expandItem.getEntityType() : null; final Object[] pathInfo = determineNavigationElements(sd, startResourceList, et); try { @@ -102,9 +102,9 @@ public List buildCollectionItemInfo(final JPAServiceDocum final StringBuilder pathName = new StringBuilder(pathInfo[PATH_INDEX].toString()); for (final JPAElement pathElement : path.getPath()) { pathName.append(pathElement.getExternalName()).append(JPAPath.PATH_SEPARATOR); - if (pathElement instanceof JPAAttribute && ((JPAAttribute) pathElement).isCollection()) { + if (pathElement instanceof final JPAAttribute attribute && attribute.isCollection()) { if (path.isPartOfGroups(groups.isPresent() ? groups.get().getGroups() : new ArrayList<>(0)) - && !((JPAAttribute) pathElement).isTransient()) { + && !attribute.isTransient()) { final JPAPath collectionPath = ((JPAEntityType) pathInfo[ET_INDEX]) .getPath(pathName.deleteCharAt(pathName.length() - 1).toString()); collectionProperties.add(collectionPath.getLeaf()); @@ -152,14 +152,14 @@ private Object[] determineNavigationElements(final JPAServiceDocument sd, result[ST_INDEX] = result[ET_INDEX] = sd.getEntity(((UriResourcePartTyped) uriElement) .getType()); path = new StringBuilder(); // Reset path on switch between entities - } else if (uriElement instanceof UriResourceComplexProperty - && !((UriResourceProperty) uriElement).isCollection()) { - result[ST_INDEX] = sd.getComplexType(((UriResourceComplexProperty) uriElement).getComplexType()); - path.append(((UriResourceComplexProperty) uriElement).getProperty().getName()) + } else if (uriElement instanceof final UriResourceComplexProperty complexProperty + && !complexProperty.isCollection()) { + result[ST_INDEX] = sd.getComplexType(complexProperty.getComplexType()); + path.append(complexProperty.getProperty().getName()) .append(JPAPath.PATH_SEPARATOR); - } else if (uriElement instanceof UriResourceProperty + } else if (uriElement instanceof final UriResourceProperty resourceProperty && result[ST_INDEX] != null) { - result[PROPERTY_INDEX] = ((JPAStructuredType) result[ST_INDEX]).getPath(((UriResourceProperty) uriElement) + result[PROPERTY_INDEX] = ((JPAStructuredType) result[ST_INDEX]).getPath(resourceProperty .getProperty().getName()); } } catch (final ODataJPAModelException e) { @@ -195,27 +195,27 @@ protected Set getCollectionAttributesFromSelection(final JPAStructuredT return collectionAttributes; } - private JPAPath getCollection(final JPAStructuredType jpaEntity, final JPAPath p, final String prefix) + private JPAPath getCollection(final JPAStructuredType jpaEntity, final JPAPath path, final String prefix) throws ODataJPAModelException { final StringBuilder pathAlias = new StringBuilder(prefix); - for (final JPAElement pathElement : p.getPath()) { + for (final JPAElement pathElement : path.getPath()) { pathAlias.append(JPAPath.PATH_SEPARATOR); pathAlias.append(pathElement.getExternalName()); - if (pathElement instanceof JPAAttribute - && ((JPAAttribute) pathElement).isCollection() - && !((JPAAttribute) pathElement).isTransient()) { + if (pathElement instanceof final JPAAttribute attribute + && attribute.isCollection() + && !attribute.isTransient()) { return jpaEntity.getPath(pathAlias.toString()); } } return null; } - private boolean pathContainsCollection(final JPAPath p) throws ODataJPAModelException { - for (final JPAElement pathElement : p.getPath()) { - if (pathElement instanceof JPAAttribute - && ((JPAAttribute) pathElement).isCollection() - && !((JPAAttribute) pathElement).isTransient()) { + private boolean pathContainsCollection(final JPAPath path) { + for (final JPAElement pathElement : path.getPath()) { + if (pathElement instanceof final JPAAttribute attribute + && attribute.isCollection() + && !attribute.isTransient()) { return true; } } diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPAExpandJoinCountQuery.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPAExpandJoinCountQuery.java index 03794bce3..38989eef0 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPAExpandJoinCountQuery.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPAExpandJoinCountQuery.java @@ -9,16 +9,16 @@ import java.util.List; import java.util.Map; import java.util.Optional; -import java.util.stream.Collectors; import javax.annotation.Nonnull; -import javax.persistence.Tuple; -import javax.persistence.TypedQuery; -import javax.persistence.criteria.CriteriaQuery; -import javax.persistence.criteria.Expression; -import javax.persistence.criteria.From; -import javax.persistence.criteria.JoinType; -import javax.persistence.criteria.Selection; + +import jakarta.persistence.Tuple; +import jakarta.persistence.TypedQuery; +import jakarta.persistence.criteria.CriteriaQuery; +import jakarta.persistence.criteria.Expression; +import jakarta.persistence.criteria.From; +import jakarta.persistence.criteria.JoinType; +import jakarta.persistence.criteria.Selection; import org.apache.olingo.commons.api.ex.ODataException; import org.apache.olingo.commons.api.http.HttpStatusCode; @@ -57,13 +57,13 @@ public JPAExpandJoinCountQuery(final OData odata, private static List copyHops(final List hops) { return hops.stream() .map(JPANavigationPropertyInfo::new) - .collect(Collectors.toList()); + .toList(); } @Override public JPAExpandQueryResult execute() throws ODataApplicationException { - try (JPARuntimeMeasurement meassument = debugger.newMeasurement(this, "execute")) { + try (JPARuntimeMeasurement measurement = debugger.newMeasurement(this, "execute")) { return null; } } @@ -101,13 +101,13 @@ private void createFromClauseRoot(final CriteriaQuery query, final HashMap count() throws ODataApplicationException { - try (JPARuntimeMeasurement meassument = debugger.newMeasurement(this, "count")) { + try (JPARuntimeMeasurement measurement = debugger.newMeasurement(this, "count")) { if (countRequested(lastInfo)) { final CriteriaQuery countQuery = cb.createTupleQuery(); createCountFrom(countQuery); final List> selectionPath = buildExpandJoinPath(target); countQuery.multiselect(addCount(selectionPath)); - final javax.persistence.criteria.Expression whereClause = createWhere(); + final jakarta.persistence.criteria.Expression whereClause = createWhere(); if (whereClause != null) countQuery.where(whereClause); countQuery.groupBy(buildExpandCountGroupBy(target)); @@ -125,9 +125,10 @@ void createCountFrom(final CriteriaQuery countQuery) throws ODataJPAQuery createFromClauseRoot(countQuery, joinTables); target = root; for (int i = 0; i < this.navigationInfo.size() - 1; i++) { - final JPANavigationPropertyInfo naviInfo = this.navigationInfo.get(i); - naviInfo.setFromClause(target); - target = createJoinFromPath(naviInfo.getAssociationPath().getAlias(), naviInfo.getAssociationPath().getPath(), + final JPANavigationPropertyInfo navigationInfo = this.navigationInfo.get(i); + navigationInfo.setFromClause(target); + target = createJoinFromPath(navigationInfo.getAssociationPath().getAlias(), navigationInfo.getAssociationPath() + .getPath(), target, JoinType.INNER); } lastInfo.setFromClause(target); @@ -135,8 +136,8 @@ void createCountFrom(final CriteriaQuery countQuery) throws ODataJPAQuery private Expression createWhere() throws ODataApplicationException { - try (JPARuntimeMeasurement meassument = debugger.newMeasurement(this, "createWhere")) { - javax.persistence.criteria.Expression whereCondition = null; + try (JPARuntimeMeasurement measurement = debugger.newMeasurement(this, "createWhere")) { + jakarta.persistence.criteria.Expression whereCondition = null; // Given keys: Organizations('1')/Roles(...) whereCondition = createKeyWhere(navigationInfo); whereCondition = addWhereClause(whereCondition, createBoundary(navigationInfo, keyBoundary)); @@ -146,9 +147,9 @@ private Expression createWhere() throws ODataApplicationException { } } - private javax.persistence.criteria.Expression createExpandWhere() throws ODataApplicationException { + private jakarta.persistence.criteria.Expression createExpandWhere() throws ODataApplicationException { - javax.persistence.criteria.Expression whereCondition = null; + jakarta.persistence.criteria.Expression whereCondition = null; for (final JPANavigationPropertyInfo info : this.navigationInfo) { if (info.getFilterCompiler() != null) { try { diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPAExpandJoinQuery.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPAExpandJoinQuery.java index 36d578cc4..a102471df 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPAExpandJoinQuery.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPAExpandJoinQuery.java @@ -12,13 +12,13 @@ import java.util.Map; import java.util.Optional; -import javax.persistence.Tuple; -import javax.persistence.TypedQuery; -import javax.persistence.criteria.Expression; -import javax.persistence.criteria.From; -import javax.persistence.criteria.Order; -import javax.persistence.criteria.Path; -import javax.persistence.criteria.Selection; +import jakarta.persistence.Tuple; +import jakarta.persistence.TypedQuery; +import jakarta.persistence.criteria.Expression; +import jakarta.persistence.criteria.From; +import jakarta.persistence.criteria.Order; +import jakarta.persistence.criteria.Path; +import jakarta.persistence.criteria.Selection; import org.apache.olingo.commons.api.ex.ODataException; import org.apache.olingo.commons.api.http.HttpStatusCode; @@ -89,16 +89,16 @@ public JPAExpandJoinQuery(final OData odata, final JPAAssociationPath associatio @Override public JPAExpandQueryResult execute() throws ODataApplicationException { - try (JPARuntimeMeasurement meassument = debugger.newMeasurement(this, "execute")) { + try (JPARuntimeMeasurement measurement = debugger.newMeasurement(this, "execute")) { tupleQuery = createTupleQuery(); List intermediateResult; - try (JPARuntimeMeasurement resultMeassument = debugger.newMeasurement(tupleQuery, "getResultList")) { - intermediateResult = tupleQuery.getQuery().getResultList(); + try (JPARuntimeMeasurement resultMeasurement = debugger.newMeasurement(tupleQuery, "getResultList")) { + intermediateResult = tupleQuery.query().getResultList(); } // Simplest solution for the top/skip problem. Read all and throw away, what is not requested final Map> result = convertResult(intermediateResult, association, determineSkip(), determineTop()); - return new JPAExpandQueryResult(result, count(), jpaEntity, tupleQuery.getSelection().joinedRequested()); + return new JPAExpandQueryResult(result, count(), jpaEntity, tupleQuery.selection().joinedRequested()); } catch (final JPANoSelectionException e) { return new JPAExpandQueryResult(emptyMap(), emptyMap(), this.jpaEntity, emptyList()); } @@ -123,12 +123,12 @@ private long determineSkip() { * @throws ODataJPAQueryException */ String getSQLString() throws ODataJPAQueryException { - if (tupleQuery != null && tupleQuery.getQuery().getClass().getCanonicalName().equals( + if (tupleQuery != null && tupleQuery.query().getClass().getCanonicalName().equals( "org.eclipse.persistence.internal.jpa.EJBQueryImpl")) { try { - final Object dbQuery = tupleQuery.getQuery().getClass().getMethod("getDatabaseQuery") - .invoke(tupleQuery.getQuery()); + final Object dbQuery = tupleQuery.query().getClass().getMethod("getDatabaseQuery") + .invoke(tupleQuery.query()); return (String) dbQuery.getClass().getMethod("getSQLString").invoke(dbQuery); } catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { @@ -157,7 +157,7 @@ private void createAdditionSelectionForJoinTable(final List> select final From parent = determineParentFrom(); // e.g. JoinSource try { for (final JPAPath p : association.getLeftColumnsList()) { - final Path selection = ExpressionUtil.convertToCriteriaPath(parent, p.getPath()); + final Path selection = ExpressionUtility.convertToCriteriaPath(parent, p.getPath()); // If source and target of an association use the same name for their key we get conflicts with the alias. // Therefore it is necessary to unify them. selection.alias(association.getAlias() + ALIAS_SEPARATOR + p.getAlias()); @@ -213,7 +213,7 @@ Map> convertResult(final List intermediateResult, fin @Override final Map count() throws ODataApplicationException { - try (JPARuntimeMeasurement meassument = debugger.newMeasurement(this, "count")) { + try (JPARuntimeMeasurement measurement = debugger.newMeasurement(this, "count")) { final JPAExpandJoinCountQuery countQuery = new JPAExpandJoinCountQuery(odata, requestContext, jpaEntity, association, navigationInfo, keyBoundary); return countQuery.count(); @@ -224,14 +224,14 @@ final Map count() throws ODataApplicationException { private JPAQueryCreationResult createTupleQuery() throws ODataApplicationException, JPANoSelectionException { - try (JPARuntimeMeasurement meassument = debugger.newMeasurement(this, "createTupleQuery")) { - final List orderByAttributes = extractOrderByNaviAttributes(uriResource.getOrderByOption()); + try (JPARuntimeMeasurement measurement = debugger.newMeasurement(this, "createTupleQuery")) { + final List orderByAttributes = extractOrderByNavigationAttributes(uriResource.getOrderByOption()); final SelectionPathInfo selectionPath = buildSelectionPathList(this.uriResource); final Map> joinTables = createFromClause(orderByAttributes, selectionPath.joinedPersistent(), cq, lastInfo); // TODO handle Join Column is ignored cq.multiselect(createSelectClause(joinTables, selectionPath.joinedPersistent(), target, groups)); - final javax.persistence.criteria.Expression whereClause = createWhere(); + final jakarta.persistence.criteria.Expression whereClause = createWhere(); if (whereClause != null) cq.where(whereClause); @@ -251,8 +251,8 @@ private JPAQueryCreationResult createTupleQuery() throws ODataApplicationExcepti private Expression createWhere() throws ODataApplicationException { - try (JPARuntimeMeasurement meassument = debugger.newMeasurement(this, "createWhere")) { - javax.persistence.criteria.Expression whereCondition = null; + try (JPARuntimeMeasurement measurement = debugger.newMeasurement(this, "createWhere")) { + jakarta.persistence.criteria.Expression whereCondition = null; // Given keys: Organizations('1')/Roles(...) whereCondition = createKeyWhere(navigationInfo); whereCondition = addWhereClause(whereCondition, createBoundary(navigationInfo, keyBoundary)); @@ -262,9 +262,9 @@ private Expression createWhere() throws ODataApplicationException { } } - private javax.persistence.criteria.Expression createExpandWhere() throws ODataApplicationException { + private jakarta.persistence.criteria.Expression createExpandWhere() throws ODataApplicationException { - javax.persistence.criteria.Expression whereCondition = null; + jakarta.persistence.criteria.Expression whereCondition = null; for (final JPANavigationPropertyInfo info : this.navigationInfo) { if (info.getFilterCompiler() != null) { try { diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPAExpandQueryFactory.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPAExpandQueryFactory.java index 52d32764a..f8e14da7d 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPAExpandQueryFactory.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPAExpandQueryFactory.java @@ -2,7 +2,7 @@ import java.util.Optional; -import javax.persistence.criteria.CriteriaBuilder; +import jakarta.persistence.criteria.CriteriaBuilder; import org.apache.olingo.commons.api.ex.ODataException; import org.apache.olingo.server.api.OData; diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPAExpandQueryResult.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPAExpandQueryResult.java index 6e5789d55..680cb278e 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPAExpandQueryResult.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPAExpandQueryResult.java @@ -11,7 +11,8 @@ import java.util.stream.Collectors; import javax.annotation.Nonnull; -import javax.persistence.Tuple; + +import jakarta.persistence.Tuple; import org.apache.olingo.commons.api.data.EntityCollection; import org.apache.olingo.commons.api.http.HttpStatusCode; @@ -199,7 +200,7 @@ public Optional getKeyBoundary(final JPAODataRequestContextAcces || collectionPropertyRequested(requestContext)) && ((requestContext.getUriInfo().getTopOption() != null || requestContext.getUriInfo().getSkipOption() != null) - || (page != null && (page.getSkip() != 0 || page.getTop() != Integer.MAX_VALUE)))) { + || (page != null && (page.skip() != 0 || page.top() != Integer.MAX_VALUE)))) { final JPAKeyPair boundary = new JPAKeyPair(jpaEntityType.getKey()); for (final Tuple tuple : jpaResult.get(ROOT_RESULT_KEY)) { @SuppressWarnings("rawtypes") diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPAExpandSubCountQuery.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPAExpandSubCountQuery.java index 55c3bfb0b..b17d3258c 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPAExpandSubCountQuery.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPAExpandSubCountQuery.java @@ -10,15 +10,14 @@ import java.util.LinkedList; import java.util.List; import java.util.Map; -import java.util.stream.Collectors; -import javax.persistence.Tuple; -import javax.persistence.TypedQuery; -import javax.persistence.criteria.CriteriaQuery; -import javax.persistence.criteria.Expression; -import javax.persistence.criteria.From; -import javax.persistence.criteria.Selection; -import javax.persistence.criteria.Subquery; +import jakarta.persistence.Tuple; +import jakarta.persistence.TypedQuery; +import jakarta.persistence.criteria.CriteriaQuery; +import jakarta.persistence.criteria.Expression; +import jakarta.persistence.criteria.From; +import jakarta.persistence.criteria.Selection; +import jakarta.persistence.criteria.Subquery; import org.apache.olingo.commons.api.ex.ODataException; import org.apache.olingo.commons.api.http.HttpStatusCode; @@ -54,12 +53,12 @@ public JPAExpandSubCountQuery(final OData odata, final JPAODataRequestContextAcc private static List copyHops(final List hops) { return hops.stream() .map(JPANavigationPropertyInfo::new) - .collect(Collectors.toList()); + .toList(); } @Override public JPAExpandQueryResult execute() throws ODataApplicationException { - try (JPARuntimeMeasurement meassument = debugger.newMeasurement(this, "execute")) { + try (JPARuntimeMeasurement measurement = debugger.newMeasurement(this, "execute")) { // return null; } @@ -83,11 +82,11 @@ protected JPAAssociationPath getAssociation(final JPAInlineItemInfo item) { return item.hops.get(item.hops.size() - 2).getAssociationPath(); } - private Expression createExpandWhere(final JPANavigationPropertyInfo naviInfo) + private Expression createExpandWhere(final JPANavigationPropertyInfo navigationInfo) throws ODataApplicationException { try { - return naviInfo.getFilterCompiler().compile(); + return navigationInfo.getFilterCompiler().compile(); } catch (final ExpressionVisitException e) { throw new ODataJPAQueryException(ODataJPAQueryException.MessageKeys.QUERY_PREPARATION_FILTER_ERROR, HttpStatusCode.BAD_REQUEST, e); @@ -109,9 +108,9 @@ private void createFromClauseRoot(final CriteriaQuery query, final HashMap count() throws ODataApplicationException { - try (JPARuntimeMeasurement meassument = debugger.newMeasurement(this, "count")) { + try (JPARuntimeMeasurement measurement = debugger.newMeasurement(this, "count")) { if (countRequested(lastInfo)) { - final ProcessorCriteriaQuery tq = (ProcessorCriteriaQuery) cb.createTupleQuery(); + final ProcessorCriteriaQuery tupleQuery = (ProcessorCriteriaQuery) cb.createTupleQuery(); final LinkedList hops = new LinkedList<>(); addFilterCompiler(lastInfo); hops.push(this); @@ -128,12 +127,12 @@ final Map count() throws ODataApplicationException { final JPAAbstractSubQuery hop = (JPAAbstractSubQuery) hops.pop(); subQuery = hop.getSubQuery(subQuery, null); } - createFromClause(emptyList(), emptyList(), tq, lastInfo); + createFromClause(emptyList(), emptyList(), tupleQuery, lastInfo); final List> selectionPath = buildExpandJoinPath(root); - tq.multiselect(addCount(selectionPath)); - tq.where(createWhere(subQuery, lastInfo)); - tq.groupBy(buildExpandCountGroupBy(root)); - final TypedQuery query = em.createQuery(tq); + tupleQuery.multiselect(addCount(selectionPath)); + tupleQuery.where(createWhere(subQuery, lastInfo)); + tupleQuery.groupBy(buildExpandCountGroupBy(root)); + final TypedQuery query = em.createQuery(tupleQuery); final List intermediateResult = query.getResultList(); return convertCountResult(intermediateResult); } @@ -143,16 +142,16 @@ final Map count() throws ODataApplicationException { } } - private Expression createWhere(final Subquery sq, final JPANavigationPropertyInfo naviInfo) + private Expression createWhere(final Subquery subQuery, final JPANavigationPropertyInfo navigationInfo) throws ODataApplicationException { - try (JPARuntimeMeasurement meassument = debugger.newMeasurement(this, "createWhere")) { - javax.persistence.criteria.Expression whereCondition = null; + try (JPARuntimeMeasurement measurement = debugger.newMeasurement(this, "createWhere")) { + jakarta.persistence.criteria.Expression whereCondition = null; // Given keys: Organizations('1')/Roles(...) - whereCondition = createWhereByKey(naviInfo.getFromClause(), naviInfo.getKeyPredicates(), naviInfo - .getEntityType()); - whereCondition = addWhereClause(whereCondition, createWhereKeyIn(this.association, target, sq)); - whereCondition = addWhereClause(whereCondition, createExpandWhere(naviInfo)); + whereCondition = createWhereByKey(navigationInfo.getFromClause(), navigationInfo.getKeyPredicates(), + navigationInfo.getEntityType()); + whereCondition = addWhereClause(whereCondition, createWhereKeyIn(this.association, target, subQuery)); + whereCondition = addWhereClause(whereCondition, createExpandWhere(navigationInfo)); whereCondition = addWhereClause(whereCondition, createProtectionWhere(claimsProvider)); return whereCondition; } catch (final ODataJPAModelException e) { diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPAExpandSubQuery.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPAExpandSubQuery.java index 9b3b56199..cb84d3ff2 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPAExpandSubQuery.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPAExpandSubQuery.java @@ -17,15 +17,16 @@ import java.util.Optional; import javax.annotation.Nonnull; -import javax.persistence.Tuple; -import javax.persistence.TypedQuery; -import javax.persistence.criteria.CriteriaQuery; -import javax.persistence.criteria.Expression; -import javax.persistence.criteria.From; -import javax.persistence.criteria.Order; -import javax.persistence.criteria.Path; -import javax.persistence.criteria.Selection; -import javax.persistence.criteria.Subquery; + +import jakarta.persistence.Tuple; +import jakarta.persistence.TypedQuery; +import jakarta.persistence.criteria.CriteriaQuery; +import jakarta.persistence.criteria.Expression; +import jakarta.persistence.criteria.From; +import jakarta.persistence.criteria.Order; +import jakarta.persistence.criteria.Path; +import jakarta.persistence.criteria.Selection; +import jakarta.persistence.criteria.Subquery; import org.apache.olingo.commons.api.ex.ODataException; import org.apache.olingo.commons.api.http.HttpStatusCode; @@ -63,11 +64,11 @@ public JPAExpandSubQuery(final OData odata, final JPAInlineItemInfo item, @Override public JPAExpandQueryResult execute() throws ODataApplicationException { - try (JPARuntimeMeasurement meassument = debugger.newMeasurement(this, "execute")) { + try (JPARuntimeMeasurement measurement = debugger.newMeasurement(this, "execute")) { final JPAQueryCreationResult tupleQuery = createTupleQuery(); - final List intermediateResult = tupleQuery.getQuery().getResultList(); + final List intermediateResult = tupleQuery.query().getResultList(); final Map> result = convertResult(intermediateResult); - return new JPAExpandQueryResult(result, count(), jpaEntity, tupleQuery.getSelection().joinedRequested()); + return new JPAExpandQueryResult(result, count(), jpaEntity, tupleQuery.selection().joinedRequested()); } catch (final JPANoSelectionException e) { return new JPAExpandQueryResult(emptyMap(), emptyMap(), this.jpaEntity, emptyList()); } catch (final ODataApplicationException e) { @@ -102,9 +103,9 @@ private List> createSelectClause(final Map> join selections = new ArrayList<>(requestedProperties.size()); for (final JPAPath jpaPath : requestedProperties) { if (jpaPath.isPartOfGroups(groups)) { - final Path p = target.get(jpaPath.getAlias()); - p.alias(jpaPath.getAlias()); - selections.add(p); + final Path path = target.get(jpaPath.getAlias()); + path.alias(jpaPath.getAlias()); + selections.add(path); } } } else { @@ -118,9 +119,9 @@ private List> createSelectClause(final Map> join void addSelectJoinTable(final List> selections) throws ODataJPAQueryException { if (association.hasJoinTable()) { try { - final JPAJoinTable jt = association.getJoinTable(); - debugger.trace(this, "Creating SELECT snipped for join table %s with join conditions %s", jt.toString(), - jt.getJoinColumns()); + final JPAJoinTable joinTable = association.getJoinTable(); + debugger.trace(this, "Creating SELECT snipped for join table %s with join conditions %s", joinTable.toString(), + joinTable.getJoinColumns()); for (final JPAOnConditionItem jc : association.getJoinTable().getJoinColumns()) { final Path path = root.get(jc.getRightPath().getLeaf().getInternalName()); path.alias(association.getAlias() + ALIAS_SEPARATOR + jc.getLeftPath().getAlias()); @@ -139,7 +140,7 @@ protected JPAAssociationPath getAssociation(final JPAInlineItemInfo item) { LinkedList buildSubQueries(final JPAQueryPair queries) throws ODataException { final LinkedList hops = new LinkedList<>(); - hops.push(queries.getInner()); + hops.push(queries.inner()); for (int i = navigationInfo.size() - 2; i >= 0; i--) { final JPANavigationPropertyInfo hop = navigationInfo.get(i); if (hop.getUriInfo() != null) { @@ -155,7 +156,7 @@ LinkedList buildSubQueries(final JPAQueryPair queries) throws @Override final Map count() throws ODataApplicationException { - try (JPARuntimeMeasurement meassument = debugger.newMeasurement(this, "count")) { + try (JPARuntimeMeasurement measurement = debugger.newMeasurement(this, "count")) { final JPAExpandSubCountQuery countQuery = new JPAExpandSubCountQuery(odata, requestContext, jpaEntity, association, navigationInfo); return countQuery.count(); @@ -197,11 +198,11 @@ private Map> convertResult(final List intermediateRes return convertedResult; } - private Expression createExpandWhere(final JPANavigationPropertyInfo naviInfo) + private Expression createExpandWhere(final JPANavigationPropertyInfo navigationInfo) throws ODataApplicationException { try { - return naviInfo.getFilterCompiler().compile(); + return navigationInfo.getFilterCompiler().compile(); } catch (final ExpressionVisitException e) { throw new ODataJPAQueryException(QUERY_PREPARATION_FILTER_ERROR, HttpStatusCode.BAD_REQUEST, e); } @@ -209,12 +210,12 @@ private Expression createExpandWhere(final JPANavigationPropertyInfo na private void createFromClauseJoinTable(final HashMap> joinTables) throws ODataJPAQueryException { if (association.hasJoinTable()) { - final JPAJoinTable jt = association.getJoinTable(); - final JPAEntityType jtEt = Optional.ofNullable(jt.getEntityType()) + final JPAJoinTable joinTable = association.getJoinTable(); + final JPAEntityType joinTableEt = Optional.ofNullable(joinTable.getEntityType()) .orElseThrow(() -> new ODataJPAQueryException(QUERY_PREPARATION_JOIN_TABLE_TYPE_MISSING, - INTERNAL_SERVER_ERROR, jt.getTableName())); - debugger.trace(this, "Join table found: %s, join will be created", jtEt.toString()); - root = cq.from(jtEt.getTypeClass()); + INTERNAL_SERVER_ERROR, joinTable.getTableName())); + debugger.trace(this, "Join table found: %s, join will be created", joinTableEt.toString()); + root = cq.from(joinTableEt.getTypeClass()); root.alias(association.getAlias()); joinTables.put(association.getAlias(), target); } @@ -237,8 +238,8 @@ private List createOrderBy(final Map> joinTables) thro final List orders = new ArrayList<>(); for (final JPAOnConditionItem c : association.getJoinTable().getJoinColumns()) { - final Path p = root.get(c.getLeftPath().getAlias()); - orders.add(cb.asc(p)); + final Path path = root.get(c.getLeftPath().getAlias()); + orders.add(cb.asc(path)); } return orders; } catch (final ODataJPAModelException e) { @@ -264,9 +265,9 @@ private JPAQueryPair createQueries(final SelectionPathInfo selectionPat debugger.trace(this, "Row number required"); final int lastIndex = navigationInfo.size() - 2; final JPAAssociationPath childAssociation = navigationInfo.get(lastIndex).getAssociationPath(); - final JPARowNumberFilterQuery rq = new JPARowNumberFilterQuery(odata, requestContext, lastInfo, + final JPARowNumberFilterQuery rowNumberQuery = new JPARowNumberFilterQuery(odata, requestContext, lastInfo, this, association, childAssociation, selectionPath); - return new JPAQueryPair(rq, this); + return new JPAQueryPair(rowNumberQuery, this); } else { debugger.trace(this, "Row number not required"); return new JPAQueryPair(this, this); @@ -276,34 +277,36 @@ private JPAQueryPair createQueries(final SelectionPathInfo selectionPat private @Nonnull JPAQueryCreationResult createTupleQuery() throws JPANoSelectionException, ODataException { - try (JPARuntimeMeasurement meassument = debugger.newMeasurement(this, "createTupleQuery")) { - final ProcessorCriteriaQuery tq = (ProcessorCriteriaQuery) cq; - final List orderByAttributes = extractOrderByNaviAttributes(uriResource.getOrderByOption()); + try (JPARuntimeMeasurement measurement = debugger.newMeasurement(this, "createTupleQuery")) { + final ProcessorCriteriaQuery tupleQuery = (ProcessorCriteriaQuery) cq; + final List orderByAttributes = extractOrderByNavigationAttributes(uriResource + .getOrderByOption()); final SelectionPathInfo selectionPath = buildSelectionPathList(this.uriResource); final JPAQueryPair queries = createQueries(selectionPath); addFilterCompiler(lastInfo); final LinkedList hops = buildSubQueries(queries); - final Subquery sq = linkSubQueries(hops); - final Map> joinTables = createJoinTables(tq, selectionPath, orderByAttributes, sq); - tq.where(createWhere(sq, lastInfo)); - tq.multiselect(createSelectClause(joinTables, selectionPath.joinedPersistent(), groups)); - tq.orderBy(createOrderBy(joinTables)); - tq.distinct(orderByAttributes.isEmpty()); + final Subquery subQuery = linkSubQueries(hops); + final Map> joinTables = createJoinTables(tupleQuery, selectionPath, orderByAttributes, + subQuery); + tupleQuery.where(createWhere(subQuery, lastInfo)); + tupleQuery.multiselect(createSelectClause(joinTables, selectionPath.joinedPersistent(), groups)); + tupleQuery.orderBy(createOrderBy(joinTables)); + tupleQuery.distinct(orderByAttributes.isEmpty()); if (!orderByAttributes.isEmpty()) cq.groupBy(createGroupBy(joinTables, target, selectionPath.joinedPersistent())); - final TypedQuery query = em.createQuery(tq); + final TypedQuery query = em.createQuery(tupleQuery); return new JPAQueryCreationResult(query, selectionPath); } } - Map> createJoinTables(final ProcessorCriteriaQuery tq, + Map> createJoinTables(final ProcessorCriteriaQuery tupleQuery, final SelectionPathInfo selectionPath, final List orderByAttributes, - final Subquery sq) throws ODataApplicationException, JPANoSelectionException { + final Subquery subQuery) throws ODataApplicationException, JPANoSelectionException { Map> joinTables = new HashMap<>(); if (hasRowLimit(lastInfo)) { - this.target = this.root = tq.from((ProcessorSubquery) sq); + this.target = this.root = tupleQuery.from((ProcessorSubquery) subQuery); } else { joinTables = createFromClause(emptyList(), selectionPath.joinedPersistent(), cq, lastInfo); } @@ -311,19 +314,19 @@ private JPAQueryPair createQueries(final SelectionPathInfo selectionPat return joinTables; } - private Expression createWhere(final Subquery sq, final JPANavigationPropertyInfo naviInfo) + private Expression createWhere(final Subquery subQuery, final JPANavigationPropertyInfo navigationInfo) throws ODataApplicationException { - try (JPARuntimeMeasurement meassument = debugger.newMeasurement(this, "createWhere")) { + try (JPARuntimeMeasurement measurement = debugger.newMeasurement(this, "createWhere")) { if (hasRowLimit(lastInfo)) { return createWhereByRowNumber(target, lastInfo); } - javax.persistence.criteria.Expression whereCondition = null; + jakarta.persistence.criteria.Expression whereCondition = null; // Given keys: Organizations('1')/Roles(...) - whereCondition = createWhereByKey(naviInfo); + whereCondition = createWhereByKey(navigationInfo); whereCondition = addWhereClause(whereCondition, createWhereTableJoin(root, target, association, true)); - whereCondition = addWhereClause(whereCondition, createWhereKeyIn(this.association, root, sq)); - whereCondition = addWhereClause(whereCondition, createExpandWhere(naviInfo)); + whereCondition = addWhereClause(whereCondition, createWhereKeyIn(this.association, root, subQuery)); + whereCondition = addWhereClause(whereCondition, createExpandWhere(navigationInfo)); whereCondition = addWhereClause(whereCondition, createProtectionWhereForEntityType(claimsProvider, jpaEntity, target)); return whereCondition; diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPAJoinQuery.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPAJoinQuery.java index 145a7c542..61f290782 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPAJoinQuery.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPAJoinQuery.java @@ -12,12 +12,13 @@ import java.util.Optional; import javax.annotation.Nonnull; -import javax.persistence.Tuple; -import javax.persistence.TypedQuery; -import javax.persistence.criteria.AbstractQuery; -import javax.persistence.criteria.CriteriaQuery; -import javax.persistence.criteria.Expression; -import javax.persistence.criteria.From; + +import jakarta.persistence.Tuple; +import jakarta.persistence.TypedQuery; +import jakarta.persistence.criteria.AbstractQuery; +import jakarta.persistence.criteria.CriteriaQuery; +import jakarta.persistence.criteria.Expression; +import jakarta.persistence.criteria.From; import org.apache.olingo.commons.api.edm.EdmBindingTarget; import org.apache.olingo.commons.api.ex.ODataException; @@ -95,11 +96,11 @@ public Long countResults() throws ODataApplicationException { * .../Organizations/$count * .../Organizations('3')/Roles/$count */ - try (JPARuntimeMeasurement meassument = debugger.newMeasurement(this, "countResults")) { + try (JPARuntimeMeasurement measurement = debugger.newMeasurement(this, "countResults")) { new JPACountWatchDog(entitySet.map(JPAAnnotatable.class::cast)).watch(this.uriResource); final CriteriaQuery countQuery = cb.createQuery(Number.class); createFromClause(Collections.emptyList(), Collections.emptyList(), countQuery, lastInfo); - final javax.persistence.criteria.Expression whereClause = createWhere(); + final jakarta.persistence.criteria.Expression whereClause = createWhere(); if (whereClause != null) countQuery.where(whereClause); countQuery.select(cb.count(target)); @@ -113,8 +114,8 @@ public Long countResults() throws ODataApplicationException { public JPAConvertibleResult execute() throws ODataApplicationException { // Pre-process URI parameter, so they can be used at different places final SelectionPathInfo selectionPath = buildSelectionPathList(this.uriResource); - try (JPARuntimeMeasurement meassument = debugger.newMeasurement(this, "execute")) { - final List orderByNavigationAttributes = extractOrderByNaviAttributes(uriResource + try (JPARuntimeMeasurement measurement = debugger.newMeasurement(this, "execute")) { + final List orderByNavigationAttributes = extractOrderByNavigationAttributes(uriResource .getOrderByOption()); final Map> joinTables = createFromClause(orderByNavigationAttributes, selectionPath.joinedPersistent(), cq, lastInfo); @@ -122,7 +123,7 @@ public JPAConvertibleResult execute() throws ODataApplicationException { cq.multiselect(createSelectClause(joinTables, selectionPath.joinedPersistent(), target, groups)) .distinct(determineDistinct()); - final javax.persistence.criteria.Expression whereClause = createWhere(); + final jakarta.persistence.criteria.Expression whereClause = createWhere(); if (whereClause != null) cq.where(whereClause); @@ -136,7 +137,7 @@ public JPAConvertibleResult execute() throws ODataApplicationException { final HashMap> result = new HashMap<>(1); List intermediateResult; - try (JPARuntimeMeasurement resultMeassument = debugger.newMeasurement(this, "getResultList")) { + try (JPARuntimeMeasurement resultMeasurement = debugger.newMeasurement(this, "getResultList")) { intermediateResult = typedQuery.getResultList(); } result.put(ROOT_RESULT_KEY, intermediateResult); @@ -162,7 +163,7 @@ public AbstractQuery getQuery() { return cq; } - private javax.persistence.criteria.Expression createWhere() throws ODataApplicationException { + private jakarta.persistence.criteria.Expression createWhere() throws ODataApplicationException { final Expression filter = super.createWhere(uriResource, navigationInfo); return addWhereClause(filter, createProtectionWhere(claimsProvider)); diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPAKeyPair.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPAKeyPair.java index 672fbd81f..af392da2e 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPAKeyPair.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPAKeyPair.java @@ -3,7 +3,7 @@ import java.util.List; import java.util.Map; -import javax.persistence.AttributeConverter; +import jakarta.persistence.AttributeConverter; import com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAAttribute; import com.sap.olingo.jpa.processor.core.exception.ODataJPAKeyPairException; diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPANavigationCountQuery.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPANavigationCountQuery.java index dc4e61926..61dc83621 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPANavigationCountQuery.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPANavigationCountQuery.java @@ -5,10 +5,10 @@ import java.util.List; import java.util.Optional; -import javax.persistence.EntityManager; -import javax.persistence.criteria.Expression; -import javax.persistence.criteria.From; -import javax.persistence.criteria.Subquery; +import jakarta.persistence.EntityManager; +import jakarta.persistence.criteria.Expression; +import jakarta.persistence.criteria.From; +import jakarta.persistence.criteria.Subquery; import org.apache.olingo.commons.api.edm.EdmEntityType; import org.apache.olingo.commons.api.http.HttpStatusCode; diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPANavigationFilterQuery.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPANavigationFilterQuery.java index ac6d0a453..361412db7 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPANavigationFilterQuery.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPANavigationFilterQuery.java @@ -4,11 +4,12 @@ import java.util.Optional; import javax.annotation.Nullable; -import javax.persistence.EntityManager; -import javax.persistence.criteria.Expression; -import javax.persistence.criteria.From; -import javax.persistence.criteria.Predicate; -import javax.persistence.criteria.Subquery; + +import jakarta.persistence.EntityManager; +import jakarta.persistence.criteria.Expression; +import jakarta.persistence.criteria.From; +import jakarta.persistence.criteria.Predicate; +import jakarta.persistence.criteria.Subquery; import org.apache.olingo.commons.api.edm.EdmEntityType; import org.apache.olingo.commons.api.http.HttpStatusCode; diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPANavigationFilterQueryBuilder.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPANavigationFilterQueryBuilder.java index d31bd99cc..f1aaafa87 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPANavigationFilterQueryBuilder.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPANavigationFilterQueryBuilder.java @@ -3,8 +3,8 @@ import java.util.List; import java.util.Optional; -import javax.persistence.EntityManager; -import javax.persistence.criteria.From; +import jakarta.persistence.EntityManager; +import jakarta.persistence.criteria.From; import org.apache.olingo.commons.api.edm.EdmEntityType; import org.apache.olingo.server.api.OData; @@ -132,11 +132,11 @@ public JPANavigationFilterQueryBuilder setGroups(final List groups) { private UriResourceKind getAggregationType(final VisitableExpression expression) { UriInfoResource member = null; - if (expression instanceof Binary) { - if (((Binary) expression).getLeftOperand() instanceof JPAMemberOperator) - member = ((JPAMemberOperator) ((Binary) expression).getLeftOperand()).getMember().getResourcePath(); - else if (((Binary) expression).getRightOperand() instanceof JPAMemberOperator) - member = ((JPAMemberOperator) ((Binary) expression).getRightOperand()).getMember().getResourcePath(); + if (expression instanceof final Binary binary) { + if (binary.getLeftOperand() instanceof final JPAMemberOperator leftMember) + member = leftMember.getMember().getResourcePath(); + else if (binary.getRightOperand() instanceof final JPAMemberOperator rightMember) + member = rightMember.getMember().getResourcePath(); } else if (expression instanceof JPAFilterExpression || expression instanceof JPACountExpression) { member = ((JPAVisitableExpression) expression).getMember(); @@ -152,8 +152,8 @@ else if (((Binary) expression).getRightOperand() instanceof JPAMemberOperator) private boolean isNullExpression(final VisitableExpression expression) { - return expression instanceof JPANullExpression - && NULL.equals(((JPANullExpression) expression).getLiteral().getText()); + return expression instanceof final JPANullExpression nullExpression + && NULL.equals(nullExpression.getLiteral().getText()); } } diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPANavigationNullQuery.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPANavigationNullQuery.java index 2c8d7ea48..d99729eba 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPANavigationNullQuery.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPANavigationNullQuery.java @@ -5,10 +5,10 @@ import java.util.List; import java.util.Optional; -import javax.persistence.EntityManager; -import javax.persistence.criteria.Expression; -import javax.persistence.criteria.From; -import javax.persistence.criteria.Subquery; +import jakarta.persistence.EntityManager; +import jakarta.persistence.criteria.Expression; +import jakarta.persistence.criteria.From; +import jakarta.persistence.criteria.Subquery; import org.apache.olingo.commons.api.edm.EdmEntityType; import org.apache.olingo.commons.api.http.HttpStatusCode; diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPANavigationPropertyInfo.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPANavigationPropertyInfo.java index 4c2e6e80a..8634b89ec 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPANavigationPropertyInfo.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPANavigationPropertyInfo.java @@ -3,7 +3,7 @@ import java.util.Collections; import java.util.List; -import javax.persistence.criteria.From; +import jakarta.persistence.criteria.From; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -97,29 +97,29 @@ private JPAEntityType determineEntityType() throws ODataJPAModelException { final UriResourcePartTyped resource = getUriResource(); String castFrom = null; - if (getUriResource() instanceof UriResourceEntitySet) { - et = sd.getEntity(((UriResourceEntitySet) resource).getEntitySet().getName()); - if (((UriResourceEntitySet) resource).getTypeFilterOnCollection() != null) { - et = sd.getEntity(((UriResourceEntitySet) resource).getTypeFilterOnCollection()); - castFrom = ((UriResourceEntitySet) resource).getEntitySet().getName(); - } else if (((UriResourceEntitySet) resource).getTypeFilterOnEntry() != null) { - et = sd.getEntity(((UriResourceEntitySet) resource).getTypeFilterOnEntry()); + if (resource instanceof final UriResourceEntitySet entitySet) { + et = sd.getEntity(entitySet.getEntitySet().getName()); + if (entitySet.getTypeFilterOnCollection() != null) { + et = sd.getEntity(entitySet.getTypeFilterOnCollection()); castFrom = ((UriResourceEntitySet) resource).getEntitySet().getName(); + } else if (entitySet.getTypeFilterOnEntry() != null) { + et = sd.getEntity(entitySet.getTypeFilterOnEntry()); + castFrom = entitySet.getEntitySet().getName(); } - } else if (resource instanceof UriResourceSingleton) { - et = sd.getEntity(((UriResourceSingleton) resource).getSingleton().getName()); - if (((UriResourceSingleton) resource).getEntityTypeFilter() != null) { - et = sd.getEntity(((UriResourceSingleton) resource).getEntityTypeFilter()); - castFrom = ((UriResourceSingleton) resource).getSingleton().getName(); + } else if (resource instanceof final UriResourceSingleton singleton) { + et = sd.getEntity(singleton.getSingleton().getName()); + if (singleton.getEntityTypeFilter() != null) { + et = sd.getEntity(singleton.getEntityTypeFilter()); + castFrom = singleton.getSingleton().getName(); } - } else if (resource instanceof UriResourceNavigation) { + } else if (resource instanceof final UriResourceNavigation navigation) { et = sd.getEntity(resource.getType()); - if (((UriResourceNavigation) resource).getTypeFilterOnEntry() != null) { - et = sd.getEntity(((UriResourceNavigation) resource).getTypeFilterOnEntry()); - castFrom = ((UriResourceNavigation) resource).getProperty().getName(); - } else if (((UriResourceNavigation) resource).getTypeFilterOnCollection() != null) { - et = sd.getEntity(((UriResourceNavigation) resource).getTypeFilterOnCollection()); - castFrom = ((UriResourceNavigation) resource).getProperty().getName(); + if (navigation.getTypeFilterOnEntry() != null) { + et = sd.getEntity(navigation.getTypeFilterOnEntry()); + castFrom = navigation.getProperty().getName(); + } else if (navigation.getTypeFilterOnCollection() != null) { + et = sd.getEntity(navigation.getTypeFilterOnCollection()); + castFrom = navigation.getProperty().getName(); } } else { et = sd.getEntity(resource.getType()); diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPANavigationSubQuery.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPANavigationSubQuery.java index f89aec3e5..a62988d01 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPANavigationSubQuery.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPANavigationSubQuery.java @@ -7,11 +7,11 @@ import java.util.Optional; import java.util.Set; -import javax.persistence.EntityManager; -import javax.persistence.criteria.Expression; -import javax.persistence.criteria.From; -import javax.persistence.criteria.Path; -import javax.persistence.criteria.Subquery; +import jakarta.persistence.EntityManager; +import jakarta.persistence.criteria.Expression; +import jakarta.persistence.criteria.From; +import jakarta.persistence.criteria.Path; +import jakarta.persistence.criteria.Subquery; import org.apache.olingo.commons.api.edm.EdmEntityType; import org.apache.olingo.commons.api.http.HttpStatusCode; diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPAOrderByBuilder.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPAOrderByBuilder.java index 7ff8b06f7..969f6e0dc 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPAOrderByBuilder.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPAOrderByBuilder.java @@ -14,14 +14,14 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.util.stream.Collectors; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.From; -import javax.persistence.criteria.Order; -import javax.persistence.criteria.Path; + +import jakarta.persistence.criteria.CriteriaBuilder; +import jakarta.persistence.criteria.From; +import jakarta.persistence.criteria.Order; +import jakarta.persistence.criteria.Path; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -135,7 +135,7 @@ List createOrderByList(@Nonnull final Map> joinTables, watchDog.watch(result); } if (uriResource.getTopOption() != null || uriResource.getSkipOption() != null - || (page != null && page.getTop() != Integer.MAX_VALUE)) { + || (page != null && page.top() != Integer.MAX_VALUE)) { LOGGER.trace("Determined $top/$skip or page: add primary key to Order By"); addOrderByPrimaryKey(result, orderBys); } @@ -251,7 +251,7 @@ private List asPathList(final JPAAssociationPath association) throws OD final List joinColumns = association.getJoinTable().getJoinColumns(); return joinColumns.stream() .map(JPAOnConditionItem::getRightPath) - .collect(Collectors.toList()); + .toList(); } @SuppressWarnings("unchecked") @@ -267,7 +267,7 @@ From determineParentFrom(final JPAAss } private void addOrderByExpression(final List orders, final OrderByItem orderByItem, - final javax.persistence.criteria.Expression expression) { + final jakarta.persistence.criteria.Expression expression) { if (orderByItem.isDescending()) orders.add(cb.desc(expression)); @@ -290,8 +290,8 @@ private void addOrderByFromUriResource(final Map> joinTables, for (final OrderByItem orderByItem : orderByOption.getOrders()) { final Expression expression = orderByItem.getExpression(); - if (expression instanceof Member) { - final UriInfoResource resourcePath = ((Member) expression).getResourcePath(); + if (expression instanceof final Member member) { + final UriInfoResource resourcePath = member.getResourcePath(); JPAStructuredType type = jpaEntity; Path path = target; final StringBuilder externalPath = new StringBuilder(); @@ -305,8 +305,8 @@ private void addOrderByFromUriResource(final Map> joinTables, path = path.get(attribute.getInternalName()); type = attribute.getStructuredType(); } else if (uriResourceItem instanceof UriResourceNavigation - || (uriResourceItem instanceof UriResourceProperty - && ((UriResourceProperty) uriResourceItem).isCollection())) { + || (uriResourceItem instanceof final UriResourceProperty property + && property.isCollection())) { // In case the orderby contains a navigation or collection a $count has to follow. This is ensured by Olingo appendPathByCollection(externalPath, uriResourceItem); final From join = joinTables.get(externalPath.toString()); @@ -320,7 +320,7 @@ private void addOrderByFromUriResource(final Map> joinTables, } private Path convertPropertyPath(final JPAStructuredType type, - final UriResource uriResourceItem, final Path p) + final UriResource uriResourceItem, final Path startPath) throws ODataJPAQueryException, ODataJPAProcessorException, ODataJPAModelException { final JPAPath attributePath = type.getPath(((UriResourceProperty) uriResourceItem).getProperty().getName()); @@ -329,9 +329,9 @@ private Path convertPropertyPath(final JPAStructuredType type, uriResourceItem.getSegmentValue()); if (!attributePath.isPartOfGroups(groups)) throw new ODataJPAQueryException(QUERY_PREPARATION_NOT_ALLOWED_MEMBER, FORBIDDEN, attributePath.getAlias()); - Path path = p; + Path path = startPath; for (final JPAElement pathElement : attributePath.getPath()) { - if (pathElement instanceof JPAAttribute && ((JPAAttribute) pathElement).isTransient()) + if (pathElement instanceof final JPAAttribute attribute && attribute.isTransient()) throw new ODataJPAQueryException(QUERY_PREPARATION_ORDER_BY_TRANSIENT, NOT_IMPLEMENTED, pathElement.getExternalName()); path = path.get(pathElement.getInternalName()); @@ -343,7 +343,7 @@ private Path convertPropertyPath(final JPAStructuredType type, private void addOrderByPrimaryKey(final List orders, final Set> existing) throws ODataJPAQueryException, ODataJPAModelException { - final List> paths = ExpressionUtil.convertToCriteriaPathList(target, jpaEntity, jpaEntity.getKey()); + final List> paths = ExpressionUtility.convertToCriteriaPathList(target, jpaEntity, jpaEntity.getKey()); for (final Path p : paths) { if (!existing.contains(p)) { orders.add(cb.asc(p)); @@ -358,8 +358,8 @@ private void addPathByAttribute(final StringBuilder externalPath, final JPAAttri } private void appendPathByCollection(final StringBuilder externalPath, final UriResource uriResourceItem) { - if (uriResourceItem instanceof UriResourceNavigation) - externalPath.append(((UriResourceNavigation) uriResourceItem).getProperty().getName()); + if (uriResourceItem instanceof final UriResourceNavigation navigation) + externalPath.append(navigation.getProperty().getName()); else externalPath.append(((UriResourceProperty) uriResourceItem).getProperty().getName()); } diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPAOrderByBuilderWatchDog.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPAOrderByBuilderWatchDog.java index c7c4f9221..9da7709a2 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPAOrderByBuilderWatchDog.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPAOrderByBuilderWatchDog.java @@ -11,7 +11,8 @@ import java.util.Optional; import javax.annotation.Nonnull; -import javax.persistence.criteria.Order; + +import jakarta.persistence.criteria.Order; import org.apache.olingo.commons.api.edm.provider.CsdlAnnotation; import org.apache.olingo.commons.api.edm.provider.annotation.CsdlConstantExpression; diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPAQueryCreationResult.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPAQueryCreationResult.java index fd880ae15..213945b1d 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPAQueryCreationResult.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPAQueryCreationResult.java @@ -1,26 +1,11 @@ package com.sap.olingo.jpa.processor.core.query; -import javax.persistence.Tuple; -import javax.persistence.TypedQuery; +import jakarta.persistence.Tuple; +import jakarta.persistence.TypedQuery; import com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAPath; -class JPAQueryCreationResult { - private final TypedQuery query; - private final SelectionPathInfo selection; - - JPAQueryCreationResult(final TypedQuery query, final SelectionPathInfo selection) { - this.query = query; - this.selection = selection; - } - - TypedQuery getQuery() { - return query; - } - - SelectionPathInfo getSelection() { - return selection; - } +record JPAQueryCreationResult(TypedQuery query, SelectionPathInfo selection) { @Override public String toString() { diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPAQueryPair.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPAQueryPair.java index 79ca0018f..612c12c68 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPAQueryPair.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPAQueryPair.java @@ -1,21 +1,6 @@ package com.sap.olingo.jpa.processor.core.query; -class JPAQueryPair { - private final JPAAbstractQuery inner; - private final JPAAbstractQuery outer; - - JPAQueryPair(final JPAAbstractQuery inner, final JPAAbstractQuery outer) { - this.inner = inner; - this.outer = outer; - } - - public JPAAbstractQuery getOuter() { - return outer; - } - - public JPAAbstractQuery getInner() { - return inner; - } +record JPAQueryPair(JPAAbstractQuery inner, JPAAbstractQuery outer) { @Override public String toString() { diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPARowNumberFilterQuery.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPARowNumberFilterQuery.java index 7188fa186..1252bd764 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPARowNumberFilterQuery.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/JPARowNumberFilterQuery.java @@ -6,7 +6,6 @@ import static java.util.Collections.emptyList; import static java.util.Collections.emptyMap; import static java.util.Collections.singletonList; -import static java.util.stream.Collectors.toList; import static java.util.stream.Collectors.toSet; import static org.apache.olingo.commons.api.http.HttpStatusCode.INTERNAL_SERVER_ERROR; @@ -17,11 +16,12 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; -import javax.persistence.criteria.Expression; -import javax.persistence.criteria.Order; -import javax.persistence.criteria.Path; -import javax.persistence.criteria.Selection; -import javax.persistence.criteria.Subquery; + +import jakarta.persistence.criteria.Expression; +import jakarta.persistence.criteria.Order; +import jakarta.persistence.criteria.Path; +import jakarta.persistence.criteria.Selection; +import jakarta.persistence.criteria.Subquery; import org.apache.olingo.commons.api.ex.ODataException; import org.apache.olingo.commons.api.http.HttpStatusCode; @@ -82,7 +82,7 @@ final class JPARowNumberFilterQuery extends JPAExpandFilterQuery { public Subquery getSubQuery(@Nullable final Subquery childQuery, @Nullable final VisitableExpression expression) throws ODataApplicationException { - try (JPARuntimeMeasurement meassument = debugger.newMeasurement(this, "createSubQuery")) { + try (JPARuntimeMeasurement measurement = debugger.newMeasurement(this, "createSubQuery")) { final ProcessorSubquery nextQuery = (ProcessorSubquery) this.subQuery; this.queryRoot = subQuery.from(this.jpaEntity.getTypeClass()); this.navigationInfo.setFromClause(queryRoot); @@ -105,7 +105,7 @@ private List> crateSelectionJoinTable() throws ODataJPAQu return columns .stream() .map(key -> mapOnToSelection(key.getRightPath(), queryJoinTable, null)) - .collect(toList()); + .toList(); } catch (final ODataJPAModelException e) { if (e.getId().equals(NO_JOIN_TABLE_TYPE.getKey())) { throw new ODataJPAQueryException(QUERY_PREPARATION_JOIN_TABLE_TYPE_MISSING, INTERNAL_SERVER_ERROR, @@ -119,14 +119,14 @@ private List> crateSelectionJoinTable() throws ODataJPAQu private List> createSelectForParent() { - try (JPARuntimeMeasurement meassument = debugger.newMeasurement(this, "createSelectClause")) { + try (JPARuntimeMeasurement measurement = debugger.newMeasurement(this, "createSelectClause")) { final List> selections = new ArrayList<>(); // Build select clause for (final JPAPath jpaPath : this.outerSelections) { if (jpaPath.isPartOfGroups(groups)) { - final Path p = ExpressionUtil.convertToCriteriaPath(joinTables, queryRoot, jpaPath.getPath()); - p.alias(jpaPath.getAlias()); - selections.add(p); + final Path path = ExpressionUtility.convertToCriteriaPath(joinTables, queryRoot, jpaPath.getPath()); + path.alias(jpaPath.getAlias()); + selections.add(path); } } return selections; diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/Utility.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/Utility.java index b28c1eaa6..5297abdfa 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/Utility.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/query/Utility.java @@ -12,6 +12,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Objects; import javax.annotation.Nonnull; @@ -73,21 +74,21 @@ public static JPAAssociationPath determineAssociationPath(final JPAServiceDocume JPAEntityType navigationStartType = null; try { - if (navigationStart instanceof UriResourceEntitySet) { - if (((UriResourceEntitySet) navigationStart).getTypeFilterOnEntry() != null) - navigationStartType = sd.getEntity(((UriResourceEntitySet) navigationStart).getTypeFilterOnEntry()); - else if (((UriResourceEntitySet) navigationStart).getTypeFilterOnCollection() != null) - navigationStartType = sd.getEntity(((UriResourceEntitySet) navigationStart).getTypeFilterOnCollection()); + if (navigationStart instanceof final UriResourceEntitySet entitySet) { + if (entitySet.getTypeFilterOnEntry() != null) + navigationStartType = sd.getEntity(entitySet.getTypeFilterOnEntry()); + else if (entitySet.getTypeFilterOnCollection() != null) + navigationStartType = sd.getEntity(entitySet.getTypeFilterOnCollection()); else - navigationStartType = sd.getEntity(((UriResourceEntitySet) navigationStart).getType()); + navigationStartType = sd.getEntity(entitySet.getType()); } - if (navigationStart instanceof UriResourceSingleton) { - navigationStartType = sd.getEntity(((UriResourceSingleton) navigationStart).getType()); - } else if (navigationStart instanceof UriResourceNavigation) { - if (((UriResourceNavigation) navigationStart).getTypeFilterOnEntry() != null) - navigationStartType = sd.getEntity(((UriResourceNavigation) navigationStart).getTypeFilterOnEntry()); + if (navigationStart instanceof final UriResourceSingleton singleton) { + navigationStartType = sd.getEntity(singleton.getType()); + } else if (navigationStart instanceof final UriResourceNavigation navigation) { + if (navigation.getTypeFilterOnEntry() != null) + navigationStartType = sd.getEntity(navigation.getTypeFilterOnEntry()); else - navigationStartType = sd.getEntity(((UriResourceNavigation) navigationStart).getProperty().getType()); + navigationStartType = sd.getEntity(navigation.getProperty().getType()); } JPAAssociationPath path = navigationStartType == null ? null : navigationStartType.getAssociationPath( associationName @@ -110,19 +111,8 @@ public static Map determineAssociations(final final Map pathList = new HashMap<>(); final StringBuilder associationNamePrefix = new StringBuilder(); - UriResource startResourceItem = null; if (startResourceList != null && expandOption != null) { - // Example1 : /Organizations('3')/AdministrativeInformation?$expand=Created/User - // Example2 : /Organizations('3')/AdministrativeInformation?$expand=* - // Association name needs AdministrativeInformation as prefix - for (int i = startResourceList.size() - 1; i >= 0; i--) { - startResourceItem = startResourceList.get(i); - if (startResourceItem instanceof UriResourceEntitySet || startResourceItem instanceof UriResourceNavigation) { - break; - } - associationNamePrefix.insert(0, PATH_SEPARATOR); - associationNamePrefix.insert(0, ((UriResourceProperty) startResourceItem).getProperty().getName()); - } + final UriResource startResourceItem = createAssociationNamePrefix(startResourceList, associationNamePrefix); // Example1 : ?$expand=Created/User (Property/NavigationProperty) // Example2 : ?$expand=Parent/CodeID (NavigationProperty/Property) // Example3 : ?$expand=Parent,Children (NavigationProperty, NavigationProperty) @@ -131,55 +121,87 @@ public static Map determineAssociations(final // Example6 : ?$expand=Parent($levels=2) // Example7 : ?$expand=*($levels=2) // Example8 : ?$expand=BusinessPartner/com.sap.olingo.jpa.Person - StringBuilder associationName; for (final ExpandItem item : expandOption.getExpandItems()) { if (item.isStar()) { - final EdmBindingTarget edmBindingTarget = determineBindingTarget(startResourceList); - try { - final JPAStructuredType jpaStructuredType = sd.getEntity(edmBindingTarget.getName()); - if (jpaStructuredType == null) - throw new ODataJPAUtilException(UNKNOWN_ENTITY_TYPE, BAD_REQUEST); - final List associationPaths = jpaStructuredType.getAssociationPathList(); - for (final JPAAssociationPath path : associationPaths) { - if (associationNamePrefix.length() == 0 || - path.getAlias().startsWith(associationNamePrefix.toString())) { - if (item.getLevelsOption() != null && path.getSourceType() == path.getTargetType()) - pathList.put(new JPAExpandLevelWrapper(expandOption, (JPAEntityType) path.getTargetType(), - findNavigationProperty(edmBindingTarget, path), item), path); - else - pathList.put(new JPAExpandItemWrapper(item, (JPAEntityType) path.getTargetType()), path); - } - } - } catch (final ODataJPAModelException e) { - throw new ODataJPAUtilException(UNKNOWN_ENTITY_TYPE, BAD_REQUEST, e); - } + determineAssociationsStar(sd, startResourceList, expandOption, pathList, associationNamePrefix, item); } else { - final List targetResourceList = item.getResourcePath().getUriResourceParts(); // Has Cast - associationName = new StringBuilder(); - associationName.append(associationNamePrefix); - UriResource targetResourceItem = null; - for (int i = 0; i < targetResourceList.size(); i++) { - targetResourceItem = targetResourceList.get(i); - if (targetResourceItem.getKind() != UriResourceKind.navigationProperty) { - associationName.append(((UriResourceProperty) targetResourceItem).getProperty().getName()); - associationName.append(PATH_SEPARATOR); - } else { - associationName.append(((UriResourceNavigation) targetResourceItem).getProperty().getName()); - break; - } - } - if (item.getLevelsOption() != null) - pathList.put(new JPAExpandLevelWrapper(sd, expandOption, item), Utility.determineAssociation(sd, - ((UriResourcePartTyped) startResourceItem).getType(), associationName)); - else - pathList.put(new JPAExpandItemWrapper(sd, item), Utility.determineAssociation(sd, - ((UriResourcePartTyped) startResourceItem).getType(), associationName)); + determineAssociations(sd, expandOption, pathList, associationNamePrefix, Objects.requireNonNull( + startResourceItem), item); } } } return pathList; } + private static UriResource createAssociationNamePrefix(final List startResourceList, + final StringBuilder associationNamePrefix) { + // Example1 : /Organizations('3')/AdministrativeInformation?$expand=Created/User + // Example2 : /Organizations('3')/AdministrativeInformation?$expand=* + // Association name needs AdministrativeInformation as prefix + UriResource startResourceItem = null; + for (int i = startResourceList.size() - 1; i >= 0; i--) { + startResourceItem = startResourceList.get(i); + if (startResourceItem instanceof UriResourceEntitySet || startResourceItem instanceof UriResourceNavigation) { + break; + } + associationNamePrefix.insert(0, PATH_SEPARATOR); + associationNamePrefix.insert(0, ((UriResourceProperty) startResourceItem).getProperty().getName()); + } + return startResourceItem; + } + + private static void determineAssociations(final JPAServiceDocument sd, final ExpandOption expandOption, + final Map pathList, final StringBuilder associationNamePrefix, + final UriResource startResourceItem, final ExpandItem item) throws ODataApplicationException { + + StringBuilder associationName; + final List targetResourceList = item.getResourcePath().getUriResourceParts(); // Has Cast + associationName = new StringBuilder(); + associationName.append(associationNamePrefix); + UriResource targetResourceItem = null; + for (int i = 0; i < targetResourceList.size(); i++) { + targetResourceItem = targetResourceList.get(i); + if (targetResourceItem.getKind() != UriResourceKind.navigationProperty) { + associationName.append(((UriResourceProperty) targetResourceItem).getProperty().getName()); + associationName.append(PATH_SEPARATOR); + } else { + associationName.append(((UriResourceNavigation) targetResourceItem).getProperty().getName()); + break; + } + } + if (item.getLevelsOption() != null) + pathList.put(new JPAExpandLevelWrapper(sd, expandOption, item), Utility.determineAssociation(sd, + ((UriResourcePartTyped) startResourceItem).getType(), associationName)); + else + pathList.put(new JPAExpandItemWrapper(sd, item), Utility.determineAssociation(sd, + ((UriResourcePartTyped) startResourceItem).getType(), associationName)); + } + + private static void determineAssociationsStar(final JPAServiceDocument sd, final List startResourceList, + final ExpandOption expandOption, final Map pathList, + final StringBuilder associationNamePrefix, final ExpandItem item) throws ODataJPAUtilException { + + final EdmBindingTarget edmBindingTarget = determineBindingTarget(startResourceList); + try { + final JPAStructuredType jpaStructuredType = sd.getEntity(edmBindingTarget.getName()); + if (jpaStructuredType == null) + throw new ODataJPAUtilException(UNKNOWN_ENTITY_TYPE, BAD_REQUEST); + final List associationPaths = jpaStructuredType.getAssociationPathList(); + for (final JPAAssociationPath path : associationPaths) { + if (associationNamePrefix.length() == 0 || + path.getAlias().startsWith(associationNamePrefix.toString())) { + if (item.getLevelsOption() != null && path.getSourceType() == path.getTargetType()) + pathList.put(new JPAExpandLevelWrapper(expandOption, (JPAEntityType) path.getTargetType(), + findNavigationProperty(edmBindingTarget, path), item), path); + else + pathList.put(new JPAExpandItemWrapper(item, (JPAEntityType) path.getTargetType()), path); + } + } + } catch (final ODataJPAModelException e) { + throw new ODataJPAUtilException(UNKNOWN_ENTITY_TYPE, BAD_REQUEST, e); + } + } + public static EdmBindingTarget determineBindingTarget(final List resources) { return determineBindingTargetAndKeys(resources).getEdmBindingTarget(); } @@ -232,10 +254,10 @@ else if (resourceItem.getTypeFilterOnCollection() != null) public static List determineKeyPredicates(final UriResource uriResourceItem) throws ODataApplicationException { - if (uriResourceItem instanceof UriResourceEntitySet) - return ((UriResourceEntitySet) uriResourceItem).getKeyPredicates(); - else if (uriResourceItem instanceof UriResourceNavigation) - return ((UriResourceNavigation) uriResourceItem).getKeyPredicates(); + if (uriResourceItem instanceof final UriResourceEntitySet entiySet) + return entiySet.getKeyPredicates(); + else if (uriResourceItem instanceof final UriResourceNavigation navigation) + return navigation.getKeyPredicates(); else if (uriResourceItem instanceof UriResourceSingleton) return Collections.emptyList(); else @@ -297,8 +319,8 @@ public static List determineNavigationPath(final JPAS || resourcePart instanceof UriResourceEntitySet || resourcePart instanceof UriResourceSingleton) { if (source != null) { - if (resourcePart instanceof UriResourceNavigation) - extendNavigationPath(associationName, ((UriResourceNavigation) resourcePart).getProperty().getName()); + if (resourcePart instanceof final UriResourceNavigation navigation) + extendNavigationPath(associationName, navigation.getProperty().getName()); pathList.add(new JPANavigationPropertyInfo(sd, source, determineAssociationPath(sd, source, associationName), null)); } @@ -306,7 +328,7 @@ public static List determineNavigationPath(final JPAS associationName = new StringBuilder(); } else { if ((resourcePart instanceof UriResourceComplexProperty - || resourcePart instanceof UriResourceProperty && ((UriResourceProperty) resourcePart).isCollection()) + || resourcePart instanceof final UriResourceProperty property && property.isCollection()) && associationName != null) { extendNavigationPath(associationName, ((UriResourceProperty) resourcePart).getProperty().getName()); } @@ -329,8 +351,7 @@ public static String determinePropertyNavigationPath(final List res if (resourceItem instanceof UriResourceValue) { pathName.insert(0, VALUE_RESOURCE); pathName.insert(0, PATH_SEPARATOR); - } else if (resourceItem instanceof UriResourceProperty) { - final UriResourceProperty property = (UriResourceProperty) resourceItem; + } else if (resourceItem instanceof final UriResourceProperty property) { pathName.insert(0, property.getProperty().getName()); pathName.insert(0, PATH_SEPARATOR); } diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/serializer/JPAPrimitivePropertyInfo.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/serializer/JPAPrimitivePropertyInfo.java index 8b924fb92..067d381b9 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/serializer/JPAPrimitivePropertyInfo.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/serializer/JPAPrimitivePropertyInfo.java @@ -2,21 +2,4 @@ import org.apache.olingo.commons.api.data.Property; -class JPAPrimitivePropertyInfo { - private final String path; - private final Property property; - - public JPAPrimitivePropertyInfo(final String path, final Property property) { - super(); - this.path = path; - this.property = property; - } - - String getPath() { - return path; - } - - Property getProperty() { - return property; - } -} +record JPAPrimitivePropertyInfo(String path, Property property) {} diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/serializer/JPASerializeFunction.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/serializer/JPASerializeFunction.java index be1c0e4c2..17aee5ecc 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/serializer/JPASerializeFunction.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/serializer/JPASerializeFunction.java @@ -23,7 +23,7 @@ final class JPASerializeFunction implements JPAOperationSerializer { private final JPAOperationSerializer serializer; public JPASerializeFunction(final UriInfo uriInfo, final ContentType responseFormat, - final JPASerializerFactory jpaSerializerFactory, Optional> responseVersion) + final JPASerializerFactory jpaSerializerFactory, final Optional> responseVersion) throws ODataJPASerializerException, SerializerException { this.serializer = (JPAOperationSerializer) createSerializer(jpaSerializerFactory, responseFormat, uriInfo, @@ -58,8 +58,8 @@ private JPASerializer createSerializer(final JPASerializerFactory jpaSerializerF } private EdmTypeKind determineReturnEdmTypeKind(final UriResourcePartTyped operation) { - if (operation instanceof UriResourceFunction) - return ((UriResourceFunction) operation).getFunction().getReturnType().getType().getKind(); + if (operation instanceof final UriResourceFunction resourceFunction) + return resourceFunction.getFunction().getReturnType().getType().getKind(); else return ((UriResourceAction) operation).getAction().getReturnType().getType().getKind(); } diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/serializer/JPASerializePrimitive.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/serializer/JPASerializePrimitive.java index e2204fe73..97864513a 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/serializer/JPASerializePrimitive.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/serializer/JPASerializePrimitive.java @@ -75,14 +75,14 @@ public SerializerResult serialize(final ODataRequest request, final EntityCollec final ContextURL contextUrl = ContextURL.with() .serviceRoot(buildServiceRoot(request, serviceContext)) .entitySetOrSingletonOrType(targetEdmBindingTarget.getName()) - .navOrPropertyPath(property.getPath()) + .navOrPropertyPath(property.path()) .build(); final PrimitiveSerializerOptions options = PrimitiveSerializerOptions.with().contextURL(contextUrl).build(); if (uriProperty.getProperty().isCollection()) - return serializer.primitiveCollection(serviceMetadata, edmPropertyType, property.getProperty(), options); + return serializer.primitiveCollection(serviceMetadata, edmPropertyType, property.property(), options); else - return serializer.primitive(serviceMetadata, edmPropertyType, property.getProperty(), options); + return serializer.primitive(serviceMetadata, edmPropertyType, property.property(), options); } catch (final URISyntaxException e) { throw new ODataJPASerializerException(e, HttpStatusCode.BAD_REQUEST); } diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/serializer/JPASerializePrimitiveAbstract.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/serializer/JPASerializePrimitiveAbstract.java index 7e1e63f46..00de73e15 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/serializer/JPASerializePrimitiveAbstract.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/serializer/JPASerializePrimitiveAbstract.java @@ -49,8 +49,8 @@ protected final JPAPrimitivePropertyInfo determinePrimitiveProperty(final Entity private boolean partOfPath(final Property item, final List uriResources) { for (final UriResource resource : uriResources) - if (resource instanceof UriResourceProperty - && ((UriResourceProperty) resource).getProperty().getName().equals(item.getName())) + if (resource instanceof final UriResourceProperty resourceProperty + && resourceProperty.getProperty().getName().equals(item.getName())) return true; return false; } diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/serializer/JPASerializeValue.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/serializer/JPASerializeValue.java index 5003c13e2..173277cc9 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/serializer/JPASerializeValue.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/serializer/JPASerializeValue.java @@ -53,10 +53,10 @@ public SerializerResult serialize(final ODataRequest request, final EntityCollec if (isStream()) { final Entity et = result.getEntities().get(0); final EdmEntityType edmEt = serviceMetadata.getEdm().getEntityType(new FullQualifiedName(et.getType())); - final List p = edmEt.getKeyPropertyRefs(); + final List keyProperties = edmEt.getKeyPropertyRefs(); Property property = null; for (final Property item : result.getEntities().get(0).getProperties()) { - if (!isKey(p, item)) { + if (!isKey(keyProperties, item)) { property = item; break; } @@ -74,8 +74,8 @@ public SerializerResult serialize(final ODataRequest request, final EntityCollec final JPAPrimitivePropertyInfo info = determinePrimitiveProperty(result, uriInfo.getUriResourceParts()); final PrimitiveValueSerializerOptions options = PrimitiveValueSerializerOptions.with().build(); - if (!info.getProperty().isNull()) - serializerResult = serializer.primitiveValue(edmPropertyType, info.getProperty().getValue(), options); + if (!info.property().isNull()) + serializerResult = serializer.primitiveValue(edmPropertyType, info.property().getValue(), options); } return new JPAValueSerializerResult(serializerResult); } @@ -94,7 +94,7 @@ private boolean isStream() { final UriResource successor = uriInfo.getUriResourceParts().get(uriInfo.getUriResourceParts().size() - 2); return (successor instanceof UriResourceEntitySet - || successor instanceof UriResourceNavigation && ((UriResourceNavigation) successor) + || successor instanceof final UriResourceNavigation resourceNavigation && resourceNavigation .getType() instanceof EdmEntityType); } diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/serializer/JPASerializerFactory.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/serializer/JPASerializerFactory.java index 2a2d0c644..2b0487830 100644 --- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/serializer/JPASerializerFactory.java +++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/serializer/JPASerializerFactory.java @@ -93,16 +93,13 @@ JPASerializer createSerializer(final ContentType responseFormat, final UriInfo u throws SerializerException, ODataJPASerializerException { switch (uriResourceKind) { - case entitySet: - case navigationProperty: - case singleton: + case entitySet, navigationProperty, singleton: return createSerializerCollectionRequest(responseFormat, uriInfo, isCollection, responseVersion); case complexProperty: return createSerializerComplexPropertyRequest(responseFormat, uriInfo, responseVersion); case primitiveProperty: return createSerializerPrimitivePropertyRequest(responseFormat, uriInfo, responseVersion); - case action: - case function: + case action, function: return new JPASerializeFunction(uriInfo, responseFormat, this, responseVersion); case count: return new JPASerializeCount(odata.createFixedFormatSerializer()); @@ -143,8 +140,8 @@ private JPASerializer createSerializerPrimitivePropertyRequest(final ContentType } private boolean determineIsCollection(final UriResource lastItem) { - if (lastItem instanceof UriResourcePartTyped) - return ((UriResourcePartTyped) lastItem).isCollection(); + if (lastItem instanceof final UriResourcePartTyped lastTyped) + return lastTyped.isCollection(); return false; } } diff --git a/jpa/odata-jpa-processor/src/main/resources/processor-exceptions-i18n.properties b/jpa/odata-jpa-processor/src/main/resources/processor-exceptions-i18n.properties index b7f0e7b63..22b2cf211 100644 --- a/jpa/odata-jpa-processor/src/main/resources/processor-exceptions-i18n.properties +++ b/jpa/odata-jpa-processor/src/main/resources/processor-exceptions-i18n.properties @@ -52,14 +52,12 @@ ODataJPAProcessorException.FUNCTION_UNKNOWN = Function '%1$s' not found. ODataJPAProcessorException.ACTION_UNKNOWN = Action '%1$s' not found. ODataJPAProcessorException.ENTITY_TYPE_UNKNOWN = Entity type for '%1$s' not found. ODataJPAProcessorException.NO_METADATA_PROVIDER = Cloud not find metadata. -<<<<<<< HEAD -======= + ODataJPAProcessorException.ATTRIBUTE_RETRIEVAL_FAILED = Retrieval of attribute '%1$s' failed. ODataJPAProcessorException.EXPAND_NON_SUPPORTED_EXPAND = Expand of '%1$s' at '%2$s' is not supported. ODataJPAProcessorException.EXPAND_NON_SUPPORTED_AT_ALL = Expand not supported for '%1$s'; ODataJPAProcessorException.EXPAND_EXCEEDS_MAX_LEVEL = Expand for '%1$s' exceeds the maximum number of levels supported; ODataJPAProcessorException.COUNT_NON_SUPPORTED_COUNT = Count is not supported for '%1$s'. ->>>>>>> odata-v4-jpa-processor/master ODataJPAQueryException.QUERY_PREPARATION_ERROR = A metadata error occurred during query preparation ODataJPAQueryException.QUERY_RESULT_CONV_ERROR = A metadata error occurred during query result conversion @@ -85,13 +83,10 @@ ODataJPAQueryException.NOT_SUPPORTED_RESOURCE_TYPE = Resource type '%1$s' not su ODataJPAQueryException.MISSING_CLAIMS_PROVIDER = Authorization information missing ODataJPAQueryException.MISSING_CLAIM = Authorization information missing for at least one property ODataJPAQueryException.WILDCARD_UPPER_NOT_SUPPORTED = When denying access using wildcards, only a single value is supported. -<<<<<<< HEAD -======= ODataJPAQueryException.QUERY_CHECK_SORTING_NOT_SUPPORTED = For '%1$s' orderby is not supported ODataJPAQueryException.QUERY_CHECK_SORTING_NOT_SUPPORTED_FOR = '%1$s' does not support orderby for property '%2$s' ODataJPAQueryException.QUERY_CHECK_ASCENDING_REQUIRED_FOR = '%1$s' requires ascending ordering for '%2$s' ODataJPAQueryException.QUERY_CHECK_DESCENDING_REQUIRED_FOR = '%1$s' requires descending ordering for '%2$s' ->>>>>>> odata-v4-jpa-processor/master ODataJPAFilterException.NOT_SUPPORTED_OPERATOR = Operator '%1$s' not supported ODataJPAFilterException.NOT_SUPPORTED_FILTER = '%1$s' not supported @@ -100,12 +95,9 @@ ODataJPAFilterException.NOT_SUPPORTED_FUNCTION_COLLECTION = Functions with a col ODataJPAFilterException.NOT_SUPPORTED_FUNCTION_NOT_SCALAR = Function with non scalar return type are not supported ODataJPAFilterException.NOT_SUPPORTED_TRANSIENT = Filter on property '%1$s' not supported ODataJPAFilterException.NOT_ALLOWED_MEMBER = Not authorized to use '%1$s' as filter -<<<<<<< HEAD -======= ODataJPAFilterException.FILTERING_REQUIRED = '%1$s' requires to filter ODataJPAFilterException.FILTERING_NOT_SUPPORTED = A filter is not supported by '%1$s' ODataJPAFilterException.FILTERING_MISSING_PROPERTIES = Filter not found for required properties '%1$s' at '%2$s' ->>>>>>> odata-v4-jpa-processor/master ODataJPAUtilException.UNKNOWN_NAVI_PROPERTY = Unknown navigation property ODataJPAUtilException.UNKNOWN_ENTITY_TYPE = Unknown entity type diff --git a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/api/JPAODataBatchProcessorTest.java b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/api/JPAODataBatchProcessorTest.java index 440b0c7b8..56ecc5118 100644 --- a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/api/JPAODataBatchProcessorTest.java +++ b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/api/JPAODataBatchProcessorTest.java @@ -15,9 +15,9 @@ import java.util.ArrayList; import java.util.List; -import javax.persistence.EntityManager; -import javax.persistence.OptimisticLockException; -import javax.persistence.RollbackException; +import jakarta.persistence.EntityManager; +import jakarta.persistence.OptimisticLockException; +import jakarta.persistence.RollbackException; import org.apache.olingo.commons.api.format.PreferenceName; import org.apache.olingo.commons.api.http.HttpStatusCode; @@ -235,11 +235,11 @@ void whenContinueHeaderFalseContinueOnErrorReturnsFalse() { @Test void whenNotContinueOnErrorSecondNotPerformed() throws ODataApplicationException, ODataLibraryException { final List requestParts = createBatchRequest(); - final ODataResponsePart resp = mock(ODataResponsePart.class); + final ODataResponsePart response = mock(ODataResponsePart.class); final List responses = createBatchPartResponse(400); - when(facade.handleBatchRequest(requestParts.get(0))).thenReturn(resp); - when(resp.getResponses()).thenReturn(responses); + when(facade.handleBatchRequest(requestParts.get(0))).thenReturn(response); + when(response.getResponses()).thenReturn(responses); cut.executeBatchParts(facade, requestParts, false); @@ -249,15 +249,15 @@ void whenNotContinueOnErrorSecondNotPerformed() throws ODataApplicationException @Test void whenContinueOnErrorSecondPerformed() throws ODataApplicationException, ODataLibraryException { final List requestParts = createBatchRequest(); - final ODataResponsePart resp1 = mock(ODataResponsePart.class); - final ODataResponsePart resp2 = mock(ODataResponsePart.class); + final ODataResponsePart response1 = mock(ODataResponsePart.class); + final ODataResponsePart response2 = mock(ODataResponsePart.class); final List responses1 = createBatchPartResponse(400); final List responses2 = createBatchPartResponse(200); - when(facade.handleBatchRequest(requestParts.get(0))).thenReturn(resp1); - when(resp1.getResponses()).thenReturn(responses1); - when(facade.handleBatchRequest(requestParts.get(1))).thenReturn(resp2); - when(resp2.getResponses()).thenReturn(responses2); + when(facade.handleBatchRequest(requestParts.get(0))).thenReturn(response1); + when(response1.getResponses()).thenReturn(responses1); + when(facade.handleBatchRequest(requestParts.get(1))).thenReturn(response2); + when(response2.getResponses()).thenReturn(responses2); final List act = cut.executeBatchParts(facade, requestParts, true); @@ -268,15 +268,15 @@ void whenContinueOnErrorSecondPerformed() throws ODataApplicationException, ODat @Test void whenNotContinueOnErrorSecondPerformedNoFailure() throws ODataApplicationException, ODataLibraryException { final List requestParts = createBatchRequest(); - final ODataResponsePart resp1 = mock(ODataResponsePart.class); - final ODataResponsePart resp2 = mock(ODataResponsePart.class); + final ODataResponsePart response1 = mock(ODataResponsePart.class); + final ODataResponsePart response2 = mock(ODataResponsePart.class); final List responses1 = createBatchPartResponse(200); final List responses2 = createBatchPartResponse(200); - when(facade.handleBatchRequest(requestParts.get(0))).thenReturn(resp1); - when(resp1.getResponses()).thenReturn(responses1); - when(facade.handleBatchRequest(requestParts.get(1))).thenReturn(resp2); - when(resp2.getResponses()).thenReturn(responses2); + when(facade.handleBatchRequest(requestParts.get(0))).thenReturn(response1); + when(response1.getResponses()).thenReturn(responses1); + when(facade.handleBatchRequest(requestParts.get(1))).thenReturn(response2); + when(response2.getResponses()).thenReturn(responses2); final List act = cut.executeBatchParts(facade, requestParts, false); diff --git a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/api/JPAODataDefaultTransactionFactoryTest.java b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/api/JPAODataDefaultTransactionFactoryTest.java index d1ad101f7..0291ceb72 100644 --- a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/api/JPAODataDefaultTransactionFactoryTest.java +++ b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/api/JPAODataDefaultTransactionFactoryTest.java @@ -10,8 +10,8 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import javax.persistence.EntityManager; -import javax.persistence.EntityTransaction; +import jakarta.persistence.EntityManager; +import jakarta.persistence.EntityTransaction; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; diff --git a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/api/JPAODataExternalRequestContextTest.java b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/api/JPAODataExternalRequestContextTest.java index 7415de2da..044b9da30 100644 --- a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/api/JPAODataExternalRequestContextTest.java +++ b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/api/JPAODataExternalRequestContextTest.java @@ -9,7 +9,7 @@ import java.util.List; import java.util.Locale; -import javax.persistence.EntityManager; +import jakarta.persistence.EntityManager; import org.apache.olingo.server.api.debug.DebugSupport; import org.junit.jupiter.api.BeforeEach; @@ -76,7 +76,7 @@ void testSetTransactionFactory() { @Test void testSetOneParameter() { final String key = "MyKey"; - final Integer value = Integer.valueOf(10); + final Integer value = 10; assertEquals(cut, cut.setParameter(key, value)); final JPAODataRequestContext act = cut.build(); assertEquals(value, act.getRequestParameter().get(key)); @@ -86,10 +86,10 @@ void testSetOneParameter() { @Test void testSetTwoParameter() { final String key1 = "MyKey1"; - final Integer value1 = Integer.valueOf(10); + final Integer value1 = 10; assertEquals(cut, cut.setParameter(key1, value1)); final String key2 = "MyKey2"; - final Integer value2 = Integer.valueOf(50); + final Integer value2 = 50; assertEquals(cut, cut.setParameter(key2, value2)); final JPAODataRequestContext act = cut.build(); @@ -100,9 +100,9 @@ void testSetTwoParameter() { @Test void testReplaceParameter() { final String key1 = "MyKey1"; - final Integer value1 = Integer.valueOf(10); + final Integer value1 = 10; assertEquals(cut, cut.setParameter(key1, value1)); - final Integer value2 = Integer.valueOf(50); + final Integer value2 = 50; assertEquals(cut, cut.setParameter(key1, value2)); final JPAODataRequestContext act = cut.build(); diff --git a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/api/JPAODataRequestHandlerTest.java b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/api/JPAODataRequestHandlerTest.java index cb2b7c0bf..b15f730f1 100644 --- a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/api/JPAODataRequestHandlerTest.java +++ b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/api/JPAODataRequestHandlerTest.java @@ -4,7 +4,6 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.argThat; -import static org.mockito.ArgumentMatchers.isA; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; @@ -12,9 +11,9 @@ import java.io.IOException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletRequestWrapper; -import javax.servlet.http.HttpServletResponse; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletRequestWrapper; +import jakarta.servlet.http.HttpServletResponse; import org.apache.olingo.commons.api.ex.ODataException; import org.apache.olingo.server.api.OData; @@ -24,6 +23,7 @@ import org.mockito.ArgumentCaptor; import org.mockito.ArgumentMatcher; +import com.sap.olingo.jpa.processor.core.api.mapper.JakartaRequestMapper; import com.sap.olingo.jpa.processor.core.util.IntegrationTestHelper; import com.sap.olingo.jpa.processor.core.util.TestBase; @@ -43,7 +43,7 @@ void setup() throws IOException { @Test void testGetHandlerProvidingSessionContext() throws ODataException { final JPAODataSessionContextAccess sessionContext = JPAODataServiceContext.with() - .setDataSource(ds) + .setDataSource(dataSource) .setPUnit(PUNIT_NAME) .build(); cut = new JPAODataRequestHandler(sessionContext); @@ -54,7 +54,7 @@ void testGetHandlerProvidingSessionContext() throws ODataException { void testPropertiesInstanceProvidingSessionContext() throws ODataException { final JPAODataSessionContextAccess context = JPAODataServiceContext.with() - .setDataSource(ds).setPUnit(PUNIT_NAME).build(); + .setDataSource(dataSource).setPUnit(PUNIT_NAME).build(); cut = new JPAODataRequestHandler(context); assertNotNull(cut.odata); } @@ -63,7 +63,7 @@ void testPropertiesInstanceProvidingSessionContext() throws ODataException { void testProcessOnlyProvidingSessionContext() throws ODataException { final JPAODataSessionContextAccess context = JPAODataServiceContext.with() - .setDataSource(ds) + .setDataSource(dataSource) .setPUnit(PUNIT_NAME) .setTypePackage(enumPackages) .build(); @@ -75,7 +75,7 @@ void testProcessOnlyProvidingSessionContext() throws ODataException { void testProcessWithEntityManagerProvidingSessionContext() throws ODataException { final JPAODataSessionContextAccess sessionContext = JPAODataServiceContext.with() - .setDataSource(ds) + .setDataSource(dataSource) .setPUnit(PUNIT_NAME) .setTypePackage(enumPackages) .build(); @@ -106,13 +106,13 @@ void testMappingPathInSessionContextCreatesMapper() throws ODataException { final ODataHttpHandler handler = mock(ODataHttpHandler.class); when(odata.createHandler(any())).thenReturn(handler); final JPAODataSessionContextAccess context = JPAODataServiceContext.with() - .setDataSource(ds) + .setDataSource(dataSource) .setPUnit(PUNIT_NAME) .setRequestMappingPath("/test") .build(); cut = new JPAODataRequestHandler(context, odata); cut.process(request, response); - verify(handler, times(1)).process(isA(HttpServletRequestWrapper.class), any()); + verify(handler, times(1)).process(argThat(new WrappedHttpRequestMatcher()), any()); } @Test @@ -121,7 +121,7 @@ void testEmptyMappingPathInSessionContextNoMapper() throws ODataException { final ODataHttpHandler handler = mock(ODataHttpHandler.class); when(odata.createHandler(any())).thenReturn(handler); final JPAODataSessionContextAccess context = JPAODataServiceContext.with() - .setDataSource(ds) + .setDataSource(dataSource) .setPUnit(PUNIT_NAME) .build(); cut = new JPAODataRequestHandler(context, odata); @@ -135,7 +135,7 @@ void testEmptyMappingPathInSessionContextEmptyMapper() throws ODataException { final ODataHttpHandler handler = mock(ODataHttpHandler.class); when(odata.createHandler(any())).thenReturn(handler); final JPAODataSessionContextAccess context = JPAODataServiceContext.with() - .setDataSource(ds) + .setDataSource(dataSource) .setPUnit(PUNIT_NAME) .setRequestMappingPath("") .build(); @@ -144,10 +144,25 @@ void testEmptyMappingPathInSessionContextEmptyMapper() throws ODataException { verify(handler, times(1)).process(argThat(new HttpRequestMatcher()), any()); } - public static class HttpRequestMatcher implements ArgumentMatcher { + public static class HttpRequestMatcher implements ArgumentMatcher { @Override - public boolean matches(final HttpServletRequest argument) { - return argument instanceof HttpServletRequest && !(argument instanceof HttpServletRequestWrapper); + public boolean matches(final javax.servlet.http.HttpServletRequest argument) { + if (argument instanceof JakartaRequestMapper) { + final HttpServletRequest wrapped = ((JakartaRequestMapper) argument).getWrapped(); + return wrapped instanceof HttpServletRequest && !(wrapped instanceof HttpServletRequestWrapper); + } else + return false; + } + } + + public static class WrappedHttpRequestMatcher implements ArgumentMatcher { + @Override + public boolean matches(final javax.servlet.http.HttpServletRequest argument) { + if (argument instanceof JakartaRequestMapper) { + final HttpServletRequest wrapped = ((JakartaRequestMapper) argument).getWrapped(); + return wrapped instanceof HttpServletRequestWrapper; + } else + return false; } } diff --git a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/api/JPAODataRequestProcessorTest.java b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/api/JPAODataRequestProcessorTest.java index a47d616cb..7bfb125f8 100644 --- a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/api/JPAODataRequestProcessorTest.java +++ b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/api/JPAODataRequestProcessorTest.java @@ -23,9 +23,9 @@ import java.util.Optional; import java.util.stream.Stream; -import javax.persistence.EntityManager; -import javax.persistence.OptimisticLockException; -import javax.persistence.RollbackException; +import jakarta.persistence.EntityManager; +import jakarta.persistence.OptimisticLockException; +import jakarta.persistence.RollbackException; import org.apache.commons.lang3.tuple.ImmutablePair; import org.apache.commons.lang3.tuple.Pair; diff --git a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/api/JPAODataServiceContextBuilderTest.java b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/api/JPAODataServiceContextBuilderTest.java index df70461d1..e5ab06c25 100644 --- a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/api/JPAODataServiceContextBuilderTest.java +++ b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/api/JPAODataServiceContextBuilderTest.java @@ -334,7 +334,7 @@ void checkReturnAnnotationProviderList() throws ODataException { assertTrue(cut.getAnnotationProvider().contains(provider2)); } - private class TestEdmPostProcessor extends JPAEdmMetadataPostProcessor { + private class TestEdmPostProcessor implements JPAEdmMetadataPostProcessor { @Override public void processNavigationProperty(final IntermediateNavigationPropertyAccess property, diff --git a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/api/example/JPAExampleCUDRequestHandlerTest.java b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/api/example/JPAExampleCUDRequestHandlerTest.java index 461f19817..34a3d2748 100644 --- a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/api/example/JPAExampleCUDRequestHandlerTest.java +++ b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/api/example/JPAExampleCUDRequestHandlerTest.java @@ -31,11 +31,11 @@ import java.util.Optional; import java.util.Set; -import javax.persistence.EntityManager; -import javax.persistence.GeneratedValue; -import javax.persistence.metamodel.EntityType; -import javax.persistence.metamodel.Metamodel; -import javax.persistence.metamodel.SingularAttribute; +import jakarta.persistence.EntityManager; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.metamodel.EntityType; +import jakarta.persistence.metamodel.Metamodel; +import jakarta.persistence.metamodel.SingularAttribute; import org.apache.olingo.commons.api.ex.ODataException; import org.apache.olingo.commons.api.http.HttpMethod; @@ -110,7 +110,7 @@ void checkCreateEntity() throws ODataJPAProcessException, ODataJPAModelException } @Test - void checkCreateEntityWithPrimitiveCollcetion() throws ODataJPAProcessException, ODataJPAModelException { + void checkCreateEntityWithPrimitiveCollection() throws ODataJPAProcessException, ODataJPAModelException { doReturn(helper.getJPAEntityType("Organizations")).when(requestEntity).getEntityType(); @@ -477,7 +477,7 @@ void checkDeleteSimplePrimitiveProperty() throws ODataJPAProcessException, OData final JPAUpdateResult act = cut.updateEntity(requestEntity, em, HttpMethod.DELETE); assertFalse(act.wasCreate()); - assertNull(((Organization) act.getModifiedEntity()).getName1()); + assertNull(((Organization) act.modifiedEntity()).getName1()); } @Test @@ -495,7 +495,7 @@ void checkDeletePrimitiveCollectionProperty() throws ODataJPAProcessException, O final JPAUpdateResult act = cut.updateEntity(requestEntity, em, HttpMethod.DELETE); assertFalse(act.wasCreate()); - assertNull(((Organization) act.getModifiedEntity()).getComment()); + assertNull(((Organization) act.modifiedEntity()).getComment()); } @Test @@ -513,7 +513,7 @@ void checkDeleteSimpleComplexProperty() throws ODataJPAProcessException, ODataJP final JPAUpdateResult act = cut.updateEntity(requestEntity, em, HttpMethod.DELETE); assertFalse(act.wasCreate()); - assertNull(((Organization) act.getModifiedEntity()).getAddress()); + assertNull(((Organization) act.modifiedEntity()).getAddress()); } @Test @@ -533,7 +533,7 @@ void checkDeleteComplexCollectionProperty() throws ODataJPAProcessException, ODa final JPAUpdateResult act = cut.updateEntity(requestEntity, em, HttpMethod.DELETE); assertFalse(act.wasCreate()); - assertNull(((Person) act.getModifiedEntity()).getInhouseAddress()); + assertNull(((Person) act.modifiedEntity()).getInhouseAddress()); } @Test @@ -557,8 +557,8 @@ void checkDeleteSimplePrimitivePropertyDeep() throws ODataJPAProcessException, O final JPAUpdateResult act = cut.updateEntity(requestEntity, em, HttpMethod.DELETE); assertFalse(act.wasCreate()); - assertNull(((Organization) act.getModifiedEntity()).getAddress().getPOBox()); - assertEquals("Hamburg", ((Organization) act.getModifiedEntity()).getAddress().getCityName()); + assertNull(((Organization) act.modifiedEntity()).getAddress().getPOBox()); + assertEquals("Hamburg", ((Organization) act.modifiedEntity()).getAddress().getCityName()); } @Test @@ -590,7 +590,7 @@ void checkPatchOneSimplePrimitiveValue() throws ODataJPAModelException, ODataJPA final JPAUpdateResult act = updateSimplePrimitiveValue(); assertFalse(act.wasCreate()); - assertEquals("Example SE", ((Organization) act.getModifiedEntity()).getName1()); + assertEquals("Example SE", ((Organization) act.modifiedEntity()).getName1()); } @Test @@ -618,8 +618,8 @@ void checkPatchOneSimpleComplexValue() throws ODataJPAModelException, ODataJPAPr final JPAUpdateResult act = cut.updateEntity(requestEntity, em, HttpMethod.DELETE); assertFalse(act.wasCreate()); - assertNotNull(((Organization) act.getModifiedEntity()).getAddress()); - final PostalAddressData afterImage = ((Organization) act.getModifiedEntity()).getAddress(); + assertNotNull(((Organization) act.modifiedEntity()).getAddress()); + final PostalAddressData afterImage = ((Organization) act.modifiedEntity()).getAddress(); assertEquals("45", afterImage.getHouseNumber()); assertEquals("Test", afterImage.getCityName()); @@ -645,8 +645,8 @@ void checkPatchEmptyComplexCollectionProperty() throws ODataJPAProcessException, final JPAUpdateResult act = cut.updateEntity(requestEntity, em, HttpMethod.DELETE); assertFalse(act.wasCreate()); - assertNotNull(((Person) act.getModifiedEntity()).getInhouseAddress()); - assertTrue(((Person) act.getModifiedEntity()).getInhouseAddress().isEmpty()); + assertNotNull(((Person) act.modifiedEntity()).getInhouseAddress()); + assertTrue(((Person) act.modifiedEntity()).getInhouseAddress().isEmpty()); } @Test @@ -676,8 +676,8 @@ void checkPatchComplexCollectionProperty() throws ODataJPAProcessException, ODat final JPAUpdateResult act = cut.updateEntity(requestEntity, em, HttpMethod.PATCH); assertFalse(act.wasCreate()); - assertNotNull(((Person) act.getModifiedEntity()).getInhouseAddress()); - final List actInhouseAddrs = ((Person) act.getModifiedEntity()).getInhouseAddress(); + assertNotNull(((Person) act.modifiedEntity()).getInhouseAddress()); + final List actInhouseAddrs = ((Person) act.modifiedEntity()).getInhouseAddress(); assertEquals(2, actInhouseAddrs.size()); assertTrue(actInhouseAddrs.get(0).getBuilding() == null || actInhouseAddrs.get(0).getBuilding().isEmpty()); assertTrue(actInhouseAddrs.get(1).getBuilding() == null || actInhouseAddrs.get(1).getBuilding().isEmpty()); @@ -699,8 +699,8 @@ void checkPatchOnePrimitiveCollectionValue() throws ODataJPAModelException, ODat final JPAUpdateResult act = cut.updateEntity(requestEntity, em, HttpMethod.DELETE); assertFalse(act.wasCreate()); - assertNotNull(((Organization) act.getModifiedEntity()).getComment()); - final List actComments = ((Organization) act.getModifiedEntity()).getComment(); + assertNotNull(((Organization) act.modifiedEntity()).getComment()); + final List actComments = ((Organization) act.modifiedEntity()).getComment(); assertEquals(2, actComments.size()); assertTrue(actComments.contains("YAT")); assertTrue(actComments.contains("This is a test")); @@ -742,7 +742,7 @@ void checkPatchCreateBindingLinkBetweenTwoEntities() throws ODataJPAModelExcepti final JPAUpdateResult act = cut.updateEntity(requestEntity, em, HttpMethod.DELETE); assertNotNull(act); - assertEquals(parent, act.getModifiedEntity()); + assertEquals(parent, act.modifiedEntity()); assertEquals(1, parent.getChildren().size()); assertEquals("DE51", parent.getChildren().get(0).getDivisionCode()); } @@ -759,7 +759,7 @@ void checkAuditFieldsSetOnCreate() throws ODataJPAModelException, ODataJPAProces @Test void checkAuditFieldsSetOnUpdate() throws ODataJPAModelException, ODataJPAProcessException { - final OrganizationWithAudit act = (OrganizationWithAudit) updateOrganization().getModifiedEntity(); + final OrganizationWithAudit act = (OrganizationWithAudit) updateOrganization().modifiedEntity(); cut.validateChanges(em); assertNotNull(act.getUpdatedBy()); assertNotNull(act.getUpdatedAt()); @@ -796,7 +796,7 @@ void checkAuthorizationsCreateRejectsAttributeNotMatch() throws ODataJPAModelExc } @Test - void checkAuthorizationsCreateRejectedOnyOneProvided() throws ODataJPAModelException, + void checkAuthorizationsCreateRejectedOnlyOneProvided() throws ODataJPAModelException, ODataJPAProcessException { final JPAClaimsPair claim = new JPAClaimsPair<>("MID*"); final JPAODataClaimProvider claims = mock(JPAODataClaimProvider.class); @@ -851,7 +851,7 @@ void checkAuthorizationsCreateAllowedInRangeWildcard() throws ODataJPAModelExcep } @Test - void checkAuthorizationsCreateRejectRangeWilrdcardMin() throws ODataJPAModelException, + void checkAuthorizationsCreateRejectRangeWildcardMin() throws ODataJPAModelException, ODataJPAProcessException { final JPAClaimsPair claim = new JPAClaimsPair<>("MI+0*", "MID99"); final JPAExampleModifyException act = assertThrows(JPAExampleModifyException.class, @@ -860,7 +860,7 @@ void checkAuthorizationsCreateRejectRangeWilrdcardMin() throws ODataJPAModelExce } @Test - void checkAuthorizationsCreateRejectRangeWilrdcarMax() throws ODataJPAModelException, + void checkAuthorizationsCreateRejectRangeWildcardMax() throws ODataJPAModelException, ODataJPAProcessException { final JPAClaimsPair claim = new JPAClaimsPair<>("MID00", "MI*99"); final JPAExampleModifyException act = assertThrows(JPAExampleModifyException.class, diff --git a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/api/example/JPAExamplePagingProviderTest.java b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/api/example/JPAExamplePagingProviderTest.java index c520778ed..cfc243743 100644 --- a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/api/example/JPAExamplePagingProviderTest.java +++ b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/api/example/JPAExamplePagingProviderTest.java @@ -45,50 +45,50 @@ void setup() throws ODataApplicationException { @Test void testReturnDefaultTopSkipPageSize2() throws ODataApplicationException { final UriInfo info = buildUriInfo(); - final JPAExamplePagingProvider cut = createOrgCut(2); + final JPAExamplePagingProvider cut = createOrganizationCut(2); final JPAODataPage act = cut.getFirstPage(info, null, countQuery, null); - assertEquals(0, act.getSkip()); - assertEquals(2, act.getTop()); - assertNotNull(toODataString((String) act.getSkipToken())); - assertEquals(info, act.getUriInfo()); + assertEquals(0, act.skip()); + assertEquals(2, act.top()); + assertNotNull(toODataString((String) act.skipToken())); + assertEquals(info, act.uriInfo()); } @Test void testReturnDefaultTopSkipPageSize5() throws ODataApplicationException { final UriInfo info = buildUriInfo(); - final JPAExamplePagingProvider cut = createOrgCut(5); + final JPAExamplePagingProvider cut = createOrganizationCut(5); final JPAODataPage act = cut.getFirstPage(info, null, countQuery, null); - assertEquals(0, act.getSkip()); - assertEquals(5, act.getTop()); - assertNotNull(toODataString((String) act.getSkipToken())); - assertEquals(info, act.getUriInfo()); + assertEquals(0, act.skip()); + assertEquals(5, act.top()); + assertNotNull(toODataString((String) act.skipToken())); + assertEquals(info, act.uriInfo()); } @Test void testReturnDefaultTopSkipPageSizeOther() throws ODataApplicationException { final UriInfo info = buildUriInfo("AdministrativeDivisions", "AdministrativeDivision"); - final JPAExamplePagingProvider cut = createOrgCut(5); + final JPAExamplePagingProvider cut = createOrganizationCut(5); when(countQuery.countResults()).thenReturn(12L); final JPAODataPage act = cut.getFirstPage(info, null, countQuery, null); - assertEquals(0, act.getSkip()); - assertEquals(10, act.getTop()); - assertNotNull(toODataString((String) act.getSkipToken())); - assertEquals(info, act.getUriInfo()); + assertEquals(0, act.skip()); + assertEquals(10, act.top()); + assertNotNull(toODataString((String) act.skipToken())); + assertEquals(info, act.uriInfo()); } @Test void testReturnDefaultTopSkipPageSize5NextPage() throws ODataApplicationException { final UriInfo info = buildUriInfo(); - final JPAExamplePagingProvider cut = createOrgCut(5); + final JPAExamplePagingProvider cut = createOrganizationCut(5); JPAODataPage act = cut.getFirstPage(info, null, countQuery, null); - act = cut.getNextPage(toODataString((String) act.getSkipToken())); + act = cut.getNextPage(toODataString((String) act.skipToken())); - assertEquals(5, act.getSkip()); - assertEquals(5, act.getTop()); - assertEquals(info, act.getUriInfo()); + assertEquals(5, act.skip()); + assertEquals(5, act.top()); + assertEquals(info, act.uriInfo()); } @Test @@ -101,7 +101,7 @@ void testReturnNullIfEntitySetIsUnknown() throws ODataApplicationException { } @Test - void testReturnNullIfEntitySetIsUnknownButMaxpagesizeHeader() throws ODataApplicationException { + void testReturnNullIfEntitySetIsUnknownButMaxPageSizeHeader() throws ODataApplicationException { final UriInfo info = buildUriInfo(); final JPAExamplePagingProvider cut = createPersonCut(5); final JPAODataPage act = cut.getFirstPage(info, 3, countQuery, null); @@ -110,89 +110,89 @@ void testReturnNullIfEntitySetIsUnknownButMaxpagesizeHeader() throws ODataApplic } @Test - void testReturnRespectMaxPagesizeHeader() throws ODataApplicationException { + void testReturnRespectMaxPageSizeHeader() throws ODataApplicationException { final UriInfo info = buildUriInfo(); - final JPAExamplePagingProvider cut = createOrgCut(5); + final JPAExamplePagingProvider cut = createOrganizationCut(5); final JPAODataPage act = cut.getFirstPage(info, 3, countQuery, null); - assertEquals(0, act.getSkip()); - assertEquals(3, act.getTop()); - assertNotNull(toODataString((String) act.getSkipToken())); - assertEquals(info, act.getUriInfo()); + assertEquals(0, act.skip()); + assertEquals(3, act.top()); + assertNotNull(toODataString((String) act.skipToken())); + assertEquals(info, act.uriInfo()); } @Test void testReturnSkipTokenNullAtLastPage() throws ODataApplicationException { final UriInfo info = buildUriInfo(); - final JPAExamplePagingProvider cut = createOrgCut(5); + final JPAExamplePagingProvider cut = createOrganizationCut(5); JPAODataPage act = cut.getFirstPage(info, null, countQuery, null); - act = cut.getNextPage(toODataString((String) act.getSkipToken())); + act = cut.getNextPage(toODataString((String) act.skipToken())); - assertNull(act.getSkipToken()); + assertNull(act.skipToken()); } @Test void testReturnSkipTokenNullOnlyOnePage() throws ODataApplicationException { final UriInfo info = buildUriInfo("AdministrativeDivisions", "AdministrativeDivision"); - final JPAExamplePagingProvider cut = createOrgCut(5); + final JPAExamplePagingProvider cut = createOrganizationCut(5); final JPAODataPage act = cut.getFirstPage(info, null, countQuery, null); - assertNull(act.getSkipToken()); + assertNull(act.skipToken()); } @Test void testReturnSkipTokenIfNotLastPage() throws ODataApplicationException { final UriInfo info = buildUriInfo(); - final JPAExamplePagingProvider cut = createOrgCut(2); + final JPAExamplePagingProvider cut = createOrganizationCut(2); JPAODataPage act = cut.getFirstPage(info, null, countQuery, null); - act = cut.getNextPage(toODataString((String) act.getSkipToken())); + act = cut.getNextPage(toODataString((String) act.skipToken())); - assertNotNull(toODataString((String) act.getSkipToken())); + assertNotNull(toODataString((String) act.skipToken())); } @Test void testReturnThirdPage() throws ODataApplicationException { final UriInfo info = buildUriInfo(); - final JPAExamplePagingProvider cut = createOrgCut(2); + final JPAExamplePagingProvider cut = createOrganizationCut(2); JPAODataPage act = cut.getFirstPage(info, null, countQuery, null); - act = cut.getNextPage(toODataString((String) act.getSkipToken())); - act = cut.getNextPage(toODataString((String) act.getSkipToken())); + act = cut.getNextPage(toODataString((String) act.skipToken())); + act = cut.getNextPage(toODataString((String) act.skipToken())); - assertNotNull(toODataString((String) act.getSkipToken())); + assertNotNull(toODataString((String) act.skipToken())); } @Test void testRespectTopSkipOfUriFirstPageLowerMaxSize() throws ODataApplicationException { final UriInfo info = buildUriInfo(); addTopSkipToUri(info); - final JPAExamplePagingProvider cut = createOrgCut(10); + final JPAExamplePagingProvider cut = createOrganizationCut(10); final JPAODataPage act = cut.getFirstPage(info, null, countQuery, null); - assertEquals(2, act.getSkip()); - assertEquals(7, act.getTop()); + assertEquals(2, act.skip()); + assertEquals(7, act.top()); } @Test void testRespectTopSkipOfUriFirstPage() throws ODataApplicationException { final UriInfo info = buildUriInfo(); addTopSkipToUri(info); - final JPAExamplePagingProvider cut = createOrgCut(5); + final JPAExamplePagingProvider cut = createOrganizationCut(5); final JPAODataPage act = cut.getFirstPage(info, null, countQuery, null); - assertEquals(2, act.getSkip()); - assertEquals(5, act.getTop()); + assertEquals(2, act.skip()); + assertEquals(5, act.top()); } @Test void testRespectTopSkipOfUriNextPage() throws ODataApplicationException { final UriInfo info = buildUriInfo(); addTopSkipToUri(info); - final JPAExamplePagingProvider cut = createOrgCut(5); + final JPAExamplePagingProvider cut = createOrganizationCut(5); JPAODataPage act = cut.getFirstPage(info, null, countQuery, null); - act = cut.getNextPage(toODataString((String) act.getSkipToken())); + act = cut.getNextPage(toODataString((String) act.skipToken())); - assertEquals(7, act.getSkip()); - assertEquals(2, act.getTop()); + assertEquals(7, act.skip()); + assertEquals(2, act.top()); } @Test @@ -203,12 +203,12 @@ void testBufferFilled() throws ODataApplicationException { final JPAExamplePagingProvider cut = new JPAExamplePagingProvider(sizes, 2); final JPAODataPage first = cut.getFirstPage(info, null, countQuery, null); - assertNotNull(cut.getNextPage((String) first.getSkipToken())); - final JPAODataPage second = cut.getNextPage((String) first.getSkipToken()); - assertNotNull(cut.getNextPage((String) second.getSkipToken())); - final JPAODataPage third = cut.getNextPage((String) second.getSkipToken()); - assertNotNull(cut.getNextPage((String) third.getSkipToken())); - assertNull(cut.getNextPage((String) first.getSkipToken())); + assertNotNull(cut.getNextPage((String) first.skipToken())); + final JPAODataPage second = cut.getNextPage((String) first.skipToken()); + assertNotNull(cut.getNextPage((String) second.skipToken())); + final JPAODataPage third = cut.getNextPage((String) second.skipToken()); + assertNotNull(cut.getNextPage((String) third.skipToken())); + assertNull(cut.getNextPage((String) first.skipToken())); } @Test @@ -219,12 +219,12 @@ void testBufferNotFilled() throws ODataApplicationException { final JPAExamplePagingProvider cut = new JPAExamplePagingProvider(sizes, 10); final JPAODataPage first = cut.getFirstPage(info, null, countQuery, null); - assertNotNull(cut.getNextPage((String) first.getSkipToken())); - final JPAODataPage second = cut.getNextPage((String) first.getSkipToken()); - assertNotNull(cut.getNextPage((String) second.getSkipToken())); - final JPAODataPage third = cut.getNextPage((String) second.getSkipToken()); - assertNotNull(cut.getNextPage((String) third.getSkipToken())); - assertNotNull(cut.getNextPage((String) first.getSkipToken())); + assertNotNull(cut.getNextPage((String) first.skipToken())); + final JPAODataPage second = cut.getNextPage((String) first.skipToken()); + assertNotNull(cut.getNextPage((String) second.skipToken())); + final JPAODataPage third = cut.getNextPage((String) second.skipToken()); + assertNotNull(cut.getNextPage((String) third.skipToken())); + assertNotNull(cut.getNextPage((String) first.skipToken())); } private UriInfo buildUriInfo() { @@ -279,7 +279,7 @@ private void addTopSkipToUri(final UriInfo info) { } - private JPAExamplePagingProvider createOrgCut(final int size) { + private JPAExamplePagingProvider createOrganizationCut(final int size) { final Map sizes = new HashMap<>(); sizes.put("Organizations", size); sizes.put("AdministrativeDivisions", 10); diff --git a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/api/mapper/JakartaRequestMapperTest.java b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/api/mapper/JakartaRequestMapperTest.java new file mode 100644 index 000000000..4d31564f2 --- /dev/null +++ b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/api/mapper/JakartaRequestMapperTest.java @@ -0,0 +1,491 @@ +package com.sap.olingo.jpa.processor.core.api.mapper; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.mockito.Mockito.doThrow; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.security.Principal; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.Locale; +import java.util.Map; + +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; + +import jakarta.servlet.ServletException; +import jakarta.servlet.ServletInputStream; +import jakarta.servlet.http.Cookie; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +class JakartaRequestMapperTest { + private static final String PARAMETER_NAME = "Parameter Name"; + private static final String PATH = "test/path"; + private static final String HEADER_VALUE = "Header Value"; + private static final String DATE_HEADER = "DateHeader"; + private static final String COOKIE_PATH = "COOKIE_PATH"; + private static final String COOKIE_DOMAIN = "COOKIE_DOMAIN"; + private static final String COOKIE_COMMAND = "COOKIE_COMMAND"; + private static final String COOKIE_ATTRIBUTE_VALUE = "COOKIE_ATTRIBUTE_VALUE"; + private static final String COOKIE_ATTRIBUTE = "COOKIE_ATTRIBUTE"; + private static final String COOKIE_VALUE = "Watch You"; + private static final String COOKIE_NAME = "TestCookie"; + private static final String HEADER_NAME = "SingleHeader"; + private JakartaRequestMapper cut; + private HttpServletRequest jakartaRequest; + + @BeforeEach + void setup() { + jakartaRequest = mock(HttpServletRequest.class); + cut = new JakartaRequestMapper(jakartaRequest); + } + + @Test + void testJakartaRequestMapperThrowsNPE() { + assertThrows(NullPointerException.class, () -> new JakartaRequestMapper(null)); + } + + @Test + void testGetAuthType() { + when(jakartaRequest.getAuthType()).thenReturn("Basic"); + assertEquals("Basic", cut.getAuthType()); + } + + @Test + void testGetCookies() { + final Cookie cookie = buildCookie(); + when(jakartaRequest.getCookies()).thenReturn(new Cookie[] { cookie }); + final javax.servlet.http.Cookie[] acts = cut.getCookies(); + assertEquals(1, acts.length); + final javax.servlet.http.Cookie act = acts[0]; + assertEquals(COOKIE_NAME, act.getName()); + assertEquals(COOKIE_VALUE, act.getValue()); + assertEquals(0, act.getVersion()); // See getter command + assertNull(act.getComment()); // See getter command + assertEquals(COOKIE_DOMAIN.toLowerCase(), act.getDomain()); + assertEquals(300000, act.getMaxAge()); + assertEquals(COOKIE_PATH, act.getPath()); + assertTrue(act.getSecure()); + assertTrue(act.isHttpOnly()); + } + + @Test + void testGetDateHeader() { + when(jakartaRequest.getDateHeader(DATE_HEADER)).thenReturn(10L); + assertEquals(10L, cut.getDateHeader(DATE_HEADER)); + } + + @Test + void testGetHeader() { + when(jakartaRequest.getHeader(HEADER_NAME)).thenReturn(HEADER_VALUE); + assertEquals(HEADER_VALUE, cut.getHeader(HEADER_NAME)); + } + + @Test + void testGetHeaders() { + @SuppressWarnings("unchecked") + final Enumeration enumeration = mock(Enumeration.class); + when(jakartaRequest.getHeaders(HEADER_NAME)).thenReturn(enumeration); + assertEquals(enumeration, cut.getHeaders(HEADER_NAME)); + } + + @Test + void testGetHeaderNames() { + @SuppressWarnings("unchecked") + final Enumeration enumeration = mock(Enumeration.class); + when(jakartaRequest.getHeaderNames()).thenReturn(enumeration); + assertEquals(enumeration, cut.getHeaderNames()); + } + + @Test + void testGetIntHeader() { + when(jakartaRequest.getIntHeader(HEADER_NAME)).thenReturn(10); + assertEquals(10, cut.getIntHeader(HEADER_NAME)); + } + + @Test + void testGetMethod() { + when(jakartaRequest.getMethod()).thenReturn("POST"); + assertEquals("POST", cut.getMethod()); + } + + @Test + void testGetPathInfo() { + when(jakartaRequest.getPathInfo()).thenReturn(PATH); + assertEquals(PATH, cut.getPathInfo()); + } + + @Test + void testGetPathTranslated() { + when(jakartaRequest.getPathTranslated()).thenReturn(PATH); + assertEquals(PATH, cut.getPathTranslated()); + } + + @Test + void testGetContextPath() { + when(jakartaRequest.getContextPath()).thenReturn(PATH); + assertEquals(PATH, cut.getContextPath()); + } + + @Test + void testGetQueryString() { + when(jakartaRequest.getQueryString()).thenReturn(PATH); + assertEquals(PATH, cut.getQueryString()); + } + + @Test + void testGetRemoteUser() { + when(jakartaRequest.getRemoteUser()).thenReturn("Willi"); + assertEquals("Willi", cut.getRemoteUser()); + } + + @Test + void testIsUserInRole() { + when(jakartaRequest.isUserInRole("Manager")).thenReturn(true); + when(jakartaRequest.isUserInRole("Employee")).thenReturn(false); + assertTrue(cut.isUserInRole("Manager")); + assertFalse(cut.isUserInRole("Employee")); + } + + @Test + void testGetUserPrincipal() { + final Principal principal = mock(Principal.class); + when(jakartaRequest.getUserPrincipal()).thenReturn(principal); + assertEquals(principal, cut.getUserPrincipal()); + } + + @Test + void testGetRequestedSessionId() { + when(jakartaRequest.getRequestedSessionId()).thenReturn("123"); + assertNull(cut.getRequestedSessionId()); + } + + @Test + void testGetRequestURI() { + when(jakartaRequest.getRequestURI()).thenReturn("/test/hallo.html"); + assertEquals("/test/hallo.html", cut.getRequestURI()); + } + + @Test + void testGetRequestURL() { + final StringBuffer url = new StringBuffer(); + when(jakartaRequest.getRequestURL()).thenReturn(url); + assertEquals(url, cut.getRequestURL()); + } + + @Test + void testGetServletPath() { + when(jakartaRequest.getServletPath()).thenReturn(PATH + HEADER_VALUE); + assertEquals(PATH + HEADER_VALUE, cut.getServletPath()); + } + + @Test + void testGetSessionThrowsException() { + assertThrows(IllegalAccessError.class, () -> cut.getSession(true)); + assertThrows(IllegalAccessError.class, () -> cut.getSession()); + } + + @Test + void testIsRequestedSessionIdValid() { + when(jakartaRequest.isRequestedSessionIdValid()).thenReturn(true); + assertTrue(cut.isRequestedSessionIdValid()); + } + + @Test + void testIsRequestedSessionIdFromCookie() { + when(jakartaRequest.isRequestedSessionIdFromCookie()).thenReturn(true); + assertTrue(cut.isRequestedSessionIdFromCookie()); + } + + @Test + void testIsRequestedSessionIdFromURL() { + when(jakartaRequest.isRequestedSessionIdFromURL()).thenReturn(true); + assertTrue(cut.isRequestedSessionIdFromURL()); + } + + @Test + void testIsRequestedSessionIdFromUrl() { + when(jakartaRequest.isRequestedSessionIdFromURL()).thenReturn(true); + assertTrue(cut.isRequestedSessionIdFromUrl()); + } + + @Test + void testAuthenticate() throws IOException, ServletException, javax.servlet.ServletException { + final HttpServletResponse response = mock(HttpServletResponse.class); + final javax.servlet.http.HttpServletResponse responseOld = mock(javax.servlet.http.HttpServletResponse.class); + + when(jakartaRequest.authenticate(response)).thenReturn(true); + assertFalse(cut.authenticate(responseOld)); + } + + @Test + void testLogin() throws javax.servlet.ServletException, ServletException { + cut.login("Willi", "1234"); + verify(jakartaRequest).login("Willi", "1234"); + } + + @Test + void testLoginRethrowsException() throws javax.servlet.ServletException, ServletException { + doThrow(new ServletException()).when(jakartaRequest).login("Willi", "1234"); + assertThrows(javax.servlet.ServletException.class, () -> cut.login("Willi", "1234")); + } + + @Test + void testLogout() throws javax.servlet.ServletException, ServletException { + cut.logout(); + verify(jakartaRequest).logout(); + } + + @Test + void testLogoutRethrowsException() throws javax.servlet.ServletException, ServletException { + doThrow(new ServletException()).when(jakartaRequest).logout(); + assertThrows(javax.servlet.ServletException.class, () -> cut.logout()); + } + + @Test + void testGetPartThrowsException() { + assertThrows(IllegalAccessError.class, () -> cut.getPart(COOKIE_NAME)); + assertThrows(IllegalAccessError.class, () -> cut.getParts()); + } + + @Test + void testGetAttributeNames() { + @SuppressWarnings("unchecked") + final Enumeration enumeration = mock(Enumeration.class); + when(jakartaRequest.getAttributeNames()).thenReturn(enumeration); + assertEquals(enumeration, cut.getAttributeNames()); + } + + @Test + void testGetCharacterEncoding() { + when(jakartaRequest.getCharacterEncoding()).thenReturn("UTF-8"); + assertEquals("UTF-8", cut.getCharacterEncoding()); + } + + @Test + void testSetCharacterEncoding() throws UnsupportedEncodingException { + cut.setCharacterEncoding("UTF-8"); + verify(jakartaRequest).setCharacterEncoding("UTF-8"); + } + + @Test + void testGetContentLength() { + when(jakartaRequest.getContentLength()).thenReturn(356); + assertEquals(356, cut.getContentLength()); + } + + @Test + void testGetContentType() { + when(jakartaRequest.getContentType()).thenReturn("HTML"); + assertEquals("HTML", cut.getContentType()); + } + + @Test + void testGetInputStream() throws IOException { + final ServletInputStream inputStream = mock(ServletInputStream.class); + when(jakartaRequest.getInputStream()).thenReturn(inputStream); + assertTrue(cut.getInputStream() instanceof JakartaServletInputStream); + } + + @Test + void testGetParameter() throws UnsupportedEncodingException { + when(jakartaRequest.getParameter(PARAMETER_NAME)).thenReturn("HTML"); + assertEquals("HTML", cut.getParameter(PARAMETER_NAME)); + } + + @Test + void testGetParameterNames() throws UnsupportedEncodingException { + @SuppressWarnings("unchecked") + final Enumeration enumeration = mock(Enumeration.class); + when(jakartaRequest.getParameterNames()).thenReturn(enumeration); + assertEquals(enumeration, cut.getParameterNames()); + } + + @Test + void testGetParameterValues() throws UnsupportedEncodingException { + final String[] values = new String[] { "A", "B" }; + when(jakartaRequest.getParameterValues(PARAMETER_NAME)).thenReturn(values); + assertEquals(values, cut.getParameterValues(PARAMETER_NAME)); + } + + @Test + void testGetParameterMap() throws UnsupportedEncodingException { + final Map parameters = new HashMap<>(); + when(jakartaRequest.getParameterMap()).thenReturn(parameters); + assertEquals(parameters, cut.getParameterMap()); + } + + @Test + void testGetScheme() throws UnsupportedEncodingException { + when(jakartaRequest.getScheme()).thenReturn("http"); + assertEquals("http", cut.getScheme()); + } + + @Test + void testGetServerName() throws UnsupportedEncodingException { + when(jakartaRequest.getServerName()).thenReturn("localhost"); + assertEquals("localhost", cut.getServerName()); + } + + @Test + void testGetServerPort() throws UnsupportedEncodingException { + when(jakartaRequest.getServerPort()).thenReturn(1234); + assertEquals(1234, cut.getServerPort()); + } + + @Test + void testGetReader() throws IOException { + final BufferedReader reader = mock(BufferedReader.class); + when(jakartaRequest.getReader()).thenReturn(reader); + assertEquals(reader, cut.getReader()); + } + + @Test + void testGetRemoteAddr() throws IOException { + when(jakartaRequest.getRemoteAddr()).thenReturn("Test"); + assertEquals("Test", cut.getRemoteAddr()); + } + + @Test + void testGetRemoteHost() throws IOException { + when(jakartaRequest.getRemoteHost()).thenReturn("remotehost"); + assertEquals("remotehost", cut.getRemoteHost()); + } + + @Test + void testGetRemotePort() throws IOException { + when(jakartaRequest.getRemotePort()).thenReturn(80); + assertEquals(80, cut.getRemotePort()); + } + + @Test + void testRemoveAttribute() throws IOException { + cut.removeAttribute("Attribute Name"); + verify(jakartaRequest).removeAttribute("Attribute Name"); + } + + @Test + void testSetAttribute() { + cut.setAttribute("Attribute Name", 110); + verify(jakartaRequest).setAttribute("Attribute Name", 110); + } + + @Test + void testGetLocale() throws IOException { + when(jakartaRequest.getLocale()).thenReturn(Locale.FRENCH); + assertEquals(Locale.FRENCH, cut.getLocale()); + } + + @Test + void testGetLocales() throws IOException { + @SuppressWarnings("unchecked") + final Enumeration enumeration = mock(Enumeration.class); + when(jakartaRequest.getLocales()).thenReturn(enumeration); + assertEquals(enumeration, cut.getLocales()); + } + + @Test + void testIsSecure() throws IOException { + when(jakartaRequest.isSecure()).thenReturn(true); + assertEquals(true, cut.isSecure()); + } + + @Test + void testGetLocalName() throws IOException { + when(jakartaRequest.getLocalName()).thenReturn("Local Name"); + assertEquals("Local Name", cut.getLocalName()); + } + + @Test + void testGetLocalAddr() throws IOException { + when(jakartaRequest.getLocalAddr()).thenReturn("Local Addresse"); + assertEquals("Local Addresse", cut.getLocalAddr()); + } + + @Test + void testGetLocalPort() throws IOException { + when(jakartaRequest.getLocalPort()).thenReturn(9009); + assertEquals(9009, cut.getLocalPort()); + } + + @Test + void testGetRealPath() throws IOException { + assertThrows(IllegalAccessError.class, () -> cut.getRealPath(PATH)); + } + + @Test + void testGetRequestDispatcherThrows() throws IOException { + assertThrows(IllegalAccessError.class, () -> cut.getRequestDispatcher(PATH)); + } + + @Test + void testGetServletContextThrows() throws IOException { + assertThrows(IllegalAccessError.class, () -> cut.getServletContext()); + } + + @Test + void testStartAsyncThrows() throws IOException { + assertThrows(IllegalAccessError.class, () -> cut.startAsync()); + } + + @Test + void testStartAsyncParameterThrows() throws IOException { + final ServletRequest servletRequest = mock(ServletRequest.class); + final ServletResponse servletResponse = mock(ServletResponse.class); + assertThrows(IllegalAccessError.class, () -> cut.startAsync(servletRequest, servletResponse)); + } + + @Test + void testIsAsyncStarted() { + when(jakartaRequest.isAsyncStarted()).thenReturn(true); + assertTrue(cut.isAsyncStarted()); + } + + @Test + void testIsAsyncSupported() { + when(jakartaRequest.isAsyncSupported()).thenReturn(true); + assertTrue(cut.isAsyncSupported()); + } + + @Test + void testGetAsyncContextThrows() throws IOException { + assertThrows(IllegalAccessError.class, () -> cut.getAsyncContext()); + } + + @Test + void testGetDispatcherTypeThrows() throws IOException { + assertThrows(IllegalAccessError.class, () -> cut.getDispatcherType()); + } + + @Test + void testGetWrapper() { + assertEquals(jakartaRequest, cut.getWrapped()); + } + + @SuppressWarnings("removal") + private Cookie buildCookie() { + final Cookie cookie = new Cookie(COOKIE_NAME, COOKIE_VALUE); + cookie.setAttribute(COOKIE_ATTRIBUTE, COOKIE_ATTRIBUTE_VALUE); + cookie.setComment(COOKIE_COMMAND); + cookie.setDomain(COOKIE_DOMAIN); + cookie.setHttpOnly(true); + cookie.setMaxAge(300000); + cookie.setPath(COOKIE_PATH); + cookie.setSecure(true); + cookie.setVersion(3); + return cookie; + } +} diff --git a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/api/mapper/JakartaResponseMapperTest.java b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/api/mapper/JakartaResponseMapperTest.java new file mode 100644 index 000000000..01ef28798 --- /dev/null +++ b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/api/mapper/JakartaResponseMapperTest.java @@ -0,0 +1,292 @@ +package com.sap.olingo.jpa.processor.core.api.mapper; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import java.io.IOException; +import java.io.PrintWriter; +import java.io.UnsupportedEncodingException; +import java.util.Collection; +import java.util.Locale; + +import javax.servlet.http.Cookie; + +import jakarta.servlet.ServletOutputStream; +import jakarta.servlet.http.HttpServletResponse; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.mockito.ArgumentCaptor; + +class JakartaResponseMapperTest { + private static final String HEADER_VALUE = "HeaderValue"; + private static final String HEADER_NAME2 = "HeaderName2"; + private static final String HEADER_NAME = "HeaderName"; + private static final String COOKIE_PATH = "COOKIE_PATH"; + private static final String COOKIE_DOMAIN = "COOKIE_DOMAIN"; + private static final String COOKIE_COMMAND = "COOKIE_COMMAND"; + private static final String COOKIE_VALUE = "Watch You"; + private static final String COOKIE_NAME = "TestCookie"; + private HttpServletResponse jakartaResponse; + private JakartaResponseMapper cut; + + @BeforeEach + void setup() { + jakartaResponse = mock(HttpServletResponse.class); + cut = new JakartaResponseMapper(jakartaResponse); + } + + @Test + void testGetCharacterEncoding() { + when(jakartaResponse.getCharacterEncoding()).thenReturn("UTF-8"); + assertEquals("UTF-8", cut.getCharacterEncoding()); + } + + @Test + void testGetContentType() { + when(jakartaResponse.getContentType()).thenReturn("HTML"); + assertEquals("HTML", cut.getContentType()); + } + + @Test + void testGetOutputStream() throws IOException { + final ServletOutputStream outputStream = mock(ServletOutputStream.class); + when(jakartaResponse.getOutputStream()).thenReturn(outputStream); + assertTrue(cut.getOutputStream() instanceof JakartaServletOutputStream); + } + + @Test + void testGetWriter() throws IOException { + final PrintWriter writer = mock(PrintWriter.class); + when(jakartaResponse.getWriter()).thenReturn(writer); + assertEquals(writer, cut.getWriter()); + } + + @Test + void testSetCharacterEncoding() throws UnsupportedEncodingException { + cut.setCharacterEncoding("UTF-8"); + verify(jakartaResponse).setCharacterEncoding("UTF-8"); + } + + @Test + void testSetContentLength() throws UnsupportedEncodingException { + cut.setContentLength(654); + verify(jakartaResponse).setContentLength(654); + } + + @Test + void testSetContentType() throws UnsupportedEncodingException { + cut.setContentType("Test"); + verify(jakartaResponse).setContentType("Test"); + } + + @Test + void testSetBufferSize() throws UnsupportedEncodingException { + cut.setBufferSize(654); + verify(jakartaResponse).setBufferSize(654); + } + + @Test + void testBufferSize() throws IOException { + when(jakartaResponse.getBufferSize()).thenReturn(1000); + assertEquals(1000, cut.getBufferSize()); + } + + @Test + void testFlushBuffer() throws IOException { + cut.flushBuffer(); + verify(jakartaResponse).flushBuffer(); + } + + @Test + void testResetBuffer() throws IOException { + cut.resetBuffer(); + verify(jakartaResponse).resetBuffer(); + } + + @Test + void testIsCommitted() throws IOException { + when(jakartaResponse.isCommitted()).thenReturn(true); + assertEquals(true, cut.isCommitted()); + } + + @Test + void testReset() throws IOException { + cut.reset(); + verify(jakartaResponse).reset(); + } + + @Test + void testSetLocale() throws UnsupportedEncodingException { + cut.setLocale(Locale.CANADA_FRENCH); + verify(jakartaResponse).setLocale(Locale.CANADA_FRENCH); + } + + @Test + void testGetLocale() { + when(jakartaResponse.getLocale()).thenReturn(Locale.GERMANY); + assertEquals(Locale.GERMANY, cut.getLocale()); + } + + @SuppressWarnings("removal") + @Test + void testAddCookies() { + final Cookie cookie = buildCookie(); + cut.addCookie(cookie); + + final ArgumentCaptor argument = ArgumentCaptor.forClass( + jakarta.servlet.http.Cookie.class); + verify(jakartaResponse).addCookie(argument.capture()); + + final jakarta.servlet.http.Cookie act = argument.getValue(); + + assertEquals(COOKIE_NAME, act.getName()); + assertEquals(COOKIE_VALUE, act.getValue()); + assertEquals(0, act.getVersion()); // See getter command + assertNull(act.getComment()); // See getter command + assertEquals(COOKIE_DOMAIN.toLowerCase(), act.getDomain()); + assertEquals(300000, act.getMaxAge()); + assertEquals(COOKIE_PATH, act.getPath()); + assertTrue(act.getSecure()); + assertTrue(act.isHttpOnly()); + } + + @Test + void testContainsHeader() { + when(jakartaResponse.containsHeader("Header")).thenReturn(true); + assertTrue(cut.containsHeader("Header")); + when(jakartaResponse.containsHeader("NoHeader")).thenReturn(false); + assertFalse(cut.containsHeader("NoHeader")); + } + + @Test + void testEncodeURL() { + when(jakartaResponse.encodeURL("test/test")).thenReturn("test/test"); + assertEquals("test/test", cut.encodeURL("test/test")); + } + + @Test + void testEncodeRedirectURL() { + when(jakartaResponse.encodeRedirectURL("test/test")).thenReturn("test/test"); + assertEquals("test/test", cut.encodeRedirectURL("test/test")); + } + + @Test + void testEncodeUrl() { + when(jakartaResponse.encodeURL("test/test")).thenReturn("test/test"); + assertEquals("test/test", cut.encodeUrl("test/test")); + } + + @Test + void testEncodeRedirectUrl() { + when(jakartaResponse.encodeRedirectURL("test/test")).thenReturn("test/test"); + assertEquals("test/test", cut.encodeRedirectUrl("test/test")); + } + + @Test + void testSendError() throws IOException { + cut.sendError(400); + verify(jakartaResponse).sendError(400); + cut.sendError(404, "Not Found"); + verify(jakartaResponse).sendError(404, "Not Found"); + } + + @Test + void testSendRedirect() throws IOException { + cut.sendRedirect("Redirect"); + verify(jakartaResponse).sendRedirect("Redirect"); + } + + @Test + void testSetDateHeader() throws IOException { + cut.setDateHeader(HEADER_NAME, 123); + verify(jakartaResponse).setDateHeader(HEADER_NAME, 123); + } + + @Test + void testAddDateHeader() throws IOException { + cut.addDateHeader(HEADER_NAME, 321); + verify(jakartaResponse).addDateHeader(HEADER_NAME, 321); + } + + @Test + void testSetHeader() throws IOException { + cut.setHeader(HEADER_NAME, "Hello"); + verify(jakartaResponse).setHeader(HEADER_NAME, "Hello"); + } + + @Test + void testAddHeader() throws IOException { + cut.addHeader(HEADER_NAME, "Test"); + verify(jakartaResponse).addHeader(HEADER_NAME, "Test"); + } + + @Test + void testSetIntHeader() throws IOException { + cut.setIntHeader(HEADER_NAME, 789); + verify(jakartaResponse).setIntHeader(HEADER_NAME, 789); + } + + @Test + void testAddIntHeader() throws IOException { + cut.addIntHeader(HEADER_NAME, 987); + verify(jakartaResponse).addIntHeader(HEADER_NAME, 987); + } + + @Test + void testSetStatus() throws IOException { + cut.setStatus(200); + verify(jakartaResponse).setStatus(200); + } + + @Test + void testSetStatusMessage() throws IOException { + cut.setStatus(201, "Created"); + verify(jakartaResponse).setStatus(201); + } + + @Test + void testGetStatus() { + when(jakartaResponse.getStatus()).thenReturn(258); + assertEquals(258, cut.getStatus()); + } + + @Test + void testGetHeader() { + when(jakartaResponse.getHeader(HEADER_NAME2)).thenReturn(HEADER_VALUE); + assertEquals(HEADER_VALUE, cut.getHeader(HEADER_NAME2)); + } + + @Test + void testGetHeaders() { + @SuppressWarnings("unchecked") + final Collection collection = mock(Collection.class); + when(jakartaResponse.getHeaders(HEADER_NAME)).thenReturn(collection); + assertEquals(collection, cut.getHeaders(HEADER_NAME)); + } + + @Test + void testGetHeaderNames() { + @SuppressWarnings("unchecked") + final Collection collection = mock(Collection.class); + when(jakartaResponse.getHeaderNames()).thenReturn(collection); + assertEquals(collection, cut.getHeaderNames()); + } + + private Cookie buildCookie() { + final Cookie cookie = new Cookie(COOKIE_NAME, COOKIE_VALUE); + cookie.setComment(COOKIE_COMMAND); + cookie.setDomain(COOKIE_DOMAIN); + cookie.setHttpOnly(true); + cookie.setMaxAge(300000); + cookie.setPath(COOKIE_PATH); + cookie.setSecure(true); + cookie.setVersion(3); + return cookie; + } +} diff --git a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/database/JPADefaultDatabaseProcessorTest.java b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/database/JPADefaultDatabaseProcessorTest.java index fe9c628a3..450df27d6 100644 --- a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/database/JPADefaultDatabaseProcessorTest.java +++ b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/database/JPADefaultDatabaseProcessorTest.java @@ -5,9 +5,9 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.Expression; -import javax.persistence.criteria.Predicate; +import jakarta.persistence.criteria.CriteriaBuilder; +import jakarta.persistence.criteria.Expression; +import jakarta.persistence.criteria.Predicate; import org.apache.olingo.server.api.ODataApplicationException; import org.apache.olingo.server.api.uri.queryoption.expression.BinaryOperatorKind; @@ -29,7 +29,7 @@ class JPADefaultDatabaseProcessorTest extends JPA_XXX_DatabaseProcessorTest { @BeforeEach - void setup() { + void setup() { initEach(); oneParameterResult = "SELECT * FROM Example(?1)"; twoParameterResult = "SELECT * FROM Example(?1,?2)"; @@ -38,42 +38,42 @@ void setup() { } @Test - void testNotSupportedConvertBooleanOperator() throws ODataApplicationException { + void testNotSupportedConvertBooleanOperator() throws ODataApplicationException { final JPABooleanOperator operator = mock(JPABooleanOperator.class); assertThrows(ODataJPAFilterException.class, () -> ((JPAODataDatabaseOperations) cut).convert(operator)); } @Test - void testNotSupportedConvertAggregationOperator() throws ODataApplicationException { + void testNotSupportedConvertAggregationOperator() throws ODataApplicationException { final JPAAggregationOperation operator = mock(JPAAggregationOperation.class); assertThrows(ODataJPAFilterException.class, () -> ((JPAODataDatabaseOperations) cut).convert(operator)); } @Test - void testNotSupportedConvertArithmeticOperator() throws ODataApplicationException { + void testNotSupportedConvertArithmeticOperator() throws ODataApplicationException { final JPAArithmeticOperator operator = mock(JPAArithmeticOperator.class); assertThrows(ODataJPAFilterException.class, () -> ((JPAODataDatabaseOperations) cut).convert(operator)); } @Test - void testNotSupportedConvertMethodCall() throws ODataApplicationException { + void testNotSupportedConvertMethodCall() throws ODataApplicationException { final JPAMethodCall operator = mock(JPAMethodCall.class); assertThrows(ODataJPAFilterException.class, () -> ((JPAODataDatabaseOperations) cut).convert(operator)); } @Test - void testNotSupportedConvertUnaryBooleanOperator() throws ODataApplicationException { + void testNotSupportedConvertUnaryBooleanOperator() throws ODataApplicationException { final JPAUnaryBooleanOperator operator = mock(JPAUnaryBooleanOperator.class); assertThrows(ODataJPAFilterException.class, () -> ((JPAODataDatabaseOperations) cut).convert(operator)); } @Test - void testNotSupportedConvertComparisonOperatorOthersThenHAS() throws ODataApplicationException { + void testNotSupportedConvertComparisonOperatorOthersThenHAS() throws ODataApplicationException { @SuppressWarnings("unchecked") final JPAComparisonOperator operator = mock(JPAComparisonOperator.class); when(operator.getOperator()).then(new Answer() { @Override - public BinaryOperatorKind answer(InvocationOnMock invocation) throws Throwable { + public BinaryOperatorKind answer(final InvocationOnMock invocation) throws Throwable { return BinaryOperatorKind.SUB; } }); @@ -82,17 +82,17 @@ public BinaryOperatorKind answer(InvocationOnMock invocation) throws Throwable { @SuppressWarnings("unchecked") @Test - void testSupportedConvertComparisonOperatorOperatorHAS() throws ODataApplicationException { + void testSupportedConvertComparisonOperatorOperatorHAS() throws ODataApplicationException { final CriteriaBuilder cb = mock(CriteriaBuilder.class); - Expression cbResult = mock(Expression.class); - Predicate cbPredicate = mock(Predicate.class); + final Expression cbResult = mock(Expression.class); + final Predicate cbPredicate = mock(Predicate.class); final JPAComparisonOperator operator = mock(JPAComparisonOperator.class); final Expression left = mock(Expression.class); final JPAEnumerationBasedOperator right = mock(JPAEnumerationBasedOperator.class); when(operator.getOperator()).then(new Answer() { @Override - public BinaryOperatorKind answer(InvocationOnMock invocation) throws Throwable { + public BinaryOperatorKind answer(final InvocationOnMock invocation) throws Throwable { return BinaryOperatorKind.HAS; } }); @@ -102,7 +102,7 @@ public BinaryOperatorKind answer(InvocationOnMock invocation) throws Throwable { when(cb.quot(left, 5L)).thenAnswer(new Answer>() { @Override - public Expression answer(InvocationOnMock invocation) throws Throwable { + public Expression answer(final InvocationOnMock invocation) throws Throwable { return cbResult; } }); @@ -114,7 +114,7 @@ public Expression answer(InvocationOnMock invocation) throws Throwable } @Test - void testNotSupportedSearch() throws ODataApplicationException { + void testNotSupportedSearch() throws ODataApplicationException { assertThrows(ODataJPADBAdaptorException.class, () -> { cut.createSearchWhereClause(null, null, null, null, null); }); diff --git a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/database/JPA_DERBY_DatabaseProcessorTest.java b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/database/JPA_DERBY_DatabaseProcessorTest.java index eb7f361a9..12aab6f15 100644 --- a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/database/JPA_DERBY_DatabaseProcessorTest.java +++ b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/database/JPA_DERBY_DatabaseProcessorTest.java @@ -4,9 +4,9 @@ import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.Mockito.mock; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.CriteriaQuery; -import javax.persistence.criteria.Root; +import jakarta.persistence.criteria.CriteriaBuilder; +import jakarta.persistence.criteria.CriteriaQuery; +import jakarta.persistence.criteria.Root; import org.apache.olingo.commons.api.http.HttpStatusCode; import org.apache.olingo.server.api.ODataApplicationException; diff --git a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/database/JPA_HSQLDB_DatabaseProcessorTest.java b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/database/JPA_HSQLDB_DatabaseProcessorTest.java index ce05dc02c..50e765c47 100644 --- a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/database/JPA_HSQLDB_DatabaseProcessorTest.java +++ b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/database/JPA_HSQLDB_DatabaseProcessorTest.java @@ -4,9 +4,9 @@ import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.Mockito.mock; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.CriteriaQuery; -import javax.persistence.criteria.Root; +import jakarta.persistence.criteria.CriteriaBuilder; +import jakarta.persistence.criteria.CriteriaQuery; +import jakarta.persistence.criteria.Root; import org.apache.olingo.commons.api.http.HttpStatusCode; import org.apache.olingo.server.api.ODataApplicationException; diff --git a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/database/JPA_POSTSQL_DatabaseProcessorTest.java b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/database/JPA_POSTSQL_DatabaseProcessorTest.java index 4d9d476d6..e5615c903 100644 --- a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/database/JPA_POSTSQL_DatabaseProcessorTest.java +++ b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/database/JPA_POSTSQL_DatabaseProcessorTest.java @@ -4,9 +4,9 @@ import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.Mockito.mock; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.CriteriaQuery; -import javax.persistence.criteria.Root; +import jakarta.persistence.criteria.CriteriaBuilder; +import jakarta.persistence.criteria.CriteriaQuery; +import jakarta.persistence.criteria.Root; import org.apache.olingo.commons.api.http.HttpStatusCode; import org.apache.olingo.server.api.ODataApplicationException; diff --git a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/database/JPA_XXX_DatabaseProcessorTest.java b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/database/JPA_XXX_DatabaseProcessorTest.java index 6d977ad02..fdf048584 100644 --- a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/database/JPA_XXX_DatabaseProcessorTest.java +++ b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/database/JPA_XXX_DatabaseProcessorTest.java @@ -15,8 +15,8 @@ import java.util.Arrays; import java.util.List; -import javax.persistence.EntityManager; -import javax.persistence.Query; +import jakarta.persistence.EntityManager; +import jakarta.persistence.Query; import org.apache.olingo.commons.api.edm.EdmEntityType; import org.apache.olingo.commons.api.edm.EdmFunction; diff --git a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/filter/JPADBFunctionOperatorTest.java b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/filter/JPADBFunctionOperatorTest.java index 139ada17e..d48ff9900 100644 --- a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/filter/JPADBFunctionOperatorTest.java +++ b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/filter/JPADBFunctionOperatorTest.java @@ -10,8 +10,8 @@ import java.util.ArrayList; import java.util.List; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.Expression; +import jakarta.persistence.criteria.CriteriaBuilder; +import jakarta.persistence.criteria.Expression; import org.apache.olingo.server.api.ODataApplicationException; import org.apache.olingo.server.api.uri.UriParameter; diff --git a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/filter/JPAFilterRestrictionsWatchDogTest.java b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/filter/JPAFilterRestrictionsWatchDogTest.java index de69f1b8f..e6f55deab 100644 --- a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/filter/JPAFilterRestrictionsWatchDogTest.java +++ b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/filter/JPAFilterRestrictionsWatchDogTest.java @@ -12,7 +12,7 @@ import java.util.List; import java.util.stream.Stream; -import javax.persistence.criteria.Expression; +import jakarta.persistence.criteria.Expression; import org.apache.olingo.commons.api.edm.provider.CsdlAnnotation; import org.apache.olingo.commons.api.edm.provider.annotation.CsdlCollection; diff --git a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/filter/JPAJavaFunctionOperatorTest.java b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/filter/JPAJavaFunctionOperatorTest.java index 4aa5af566..54bc6451c 100644 --- a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/filter/JPAJavaFunctionOperatorTest.java +++ b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/filter/JPAJavaFunctionOperatorTest.java @@ -13,8 +13,8 @@ import java.util.ArrayList; import java.util.List; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.From; +import jakarta.persistence.criteria.CriteriaBuilder; +import jakarta.persistence.criteria.From; import org.apache.olingo.commons.api.edm.EdmFunction; import org.apache.olingo.commons.api.edm.EdmParameter; diff --git a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/filter/JPAVisitorTest.java b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/filter/JPAVisitorTest.java index 1ceeb5ea3..a50c5657d 100644 --- a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/filter/JPAVisitorTest.java +++ b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/filter/JPAVisitorTest.java @@ -11,13 +11,12 @@ import java.util.Collections; import java.util.List; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.From; +import jakarta.persistence.criteria.CriteriaBuilder; +import jakarta.persistence.criteria.From; import org.apache.olingo.commons.api.edm.EdmFunction; import org.apache.olingo.server.api.ODataApplicationException; import org.apache.olingo.server.api.uri.UriInfoResource; -import org.apache.olingo.server.api.uri.UriParameter; import org.apache.olingo.server.api.uri.UriResource; import org.apache.olingo.server.api.uri.UriResourceFunction; import org.apache.olingo.server.api.uri.queryoption.expression.BinaryOperatorKind; @@ -38,7 +37,6 @@ class JPAVisitorTest { private JPAEntityType et; private From from; - private CriteriaBuilder cb; private JPAFilterComplierAccess compiler; private JPAAbstractQuery query; private JPAExpressionVisitor cut; @@ -53,7 +51,6 @@ public void setUp() { query = mock(JPAAbstractQuery.class); from = mock(From.class); et = mock(JPAEntityType.class); - cb = mock(CriteriaBuilder.class); doReturn(from).when(compiler).getRoot(); when(compiler.getJpaEntityType()).thenReturn(et); @@ -117,7 +114,7 @@ void createFunctionOperation() throws ExpressionVisitException, ODataApplication when(uriFunction.getFunction()).thenReturn(edmFunction); when(compiler.getSd()).thenReturn(sd); when(sd.getFunction(edmFunction)).thenReturn(jpaFunction); - when(uriFunction.getParameters()).thenReturn(new ArrayList()); + when(uriFunction.getParameters()).thenReturn(new ArrayList<>()); assertTrue(cut.visitMember(member) instanceof JPADBFunctionOperator); } diff --git a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/filter/ODataJPAQueryContextTest.java b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/filter/ODataJPAQueryContextTest.java index c9a8a07d3..f2c118f93 100644 --- a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/filter/ODataJPAQueryContextTest.java +++ b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/filter/ODataJPAQueryContextTest.java @@ -5,8 +5,8 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.From; +import jakarta.persistence.criteria.CriteriaBuilder; +import jakarta.persistence.criteria.From; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; diff --git a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/filter/TestJPAArithmeticOperator.java b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/filter/TestJPAArithmeticOperator.java index 55c1b742f..d0f7570f9 100644 --- a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/filter/TestJPAArithmeticOperator.java +++ b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/filter/TestJPAArithmeticOperator.java @@ -7,9 +7,9 @@ import java.math.BigDecimal; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.Expression; -import javax.persistence.criteria.Path; +import jakarta.persistence.criteria.CriteriaBuilder; +import jakarta.persistence.criteria.Expression; +import jakarta.persistence.criteria.Path; import org.apache.olingo.server.api.ODataApplicationException; import org.apache.olingo.server.api.uri.queryoption.expression.BinaryOperatorKind; diff --git a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/filter/TestJPACustomScalarFunctions.java b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/filter/TestJPACustomScalarFunctions.java index 55af7675c..6f5a55546 100644 --- a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/filter/TestJPACustomScalarFunctions.java +++ b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/filter/TestJPACustomScalarFunctions.java @@ -6,12 +6,13 @@ import java.util.List; import java.util.Map; -import javax.persistence.EntityManager; -import javax.persistence.EntityManagerFactory; -import javax.persistence.EntityTransaction; -import javax.persistence.Query; import javax.sql.DataSource; +import jakarta.persistence.EntityManager; +import jakarta.persistence.EntityManagerFactory; +import jakarta.persistence.EntityTransaction; +import jakarta.persistence.Query; + import org.apache.olingo.commons.api.ex.ODataException; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; diff --git a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/filter/TestJPAOperationConverter.java b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/filter/TestJPAOperationConverter.java index 485b4936a..ce8221710 100644 --- a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/filter/TestJPAOperationConverter.java +++ b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/filter/TestJPAOperationConverter.java @@ -5,9 +5,9 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.Expression; -import javax.persistence.criteria.Path; +import jakarta.persistence.criteria.CriteriaBuilder; +import jakarta.persistence.criteria.Expression; +import jakarta.persistence.criteria.Path; import org.apache.olingo.commons.api.http.HttpStatusCode; import org.apache.olingo.server.api.ODataApplicationException; diff --git a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/filter/TestJavaFunctions.java b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/filter/TestJavaFunctions.java index c1747c0bd..1ea687fe1 100644 --- a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/filter/TestJavaFunctions.java +++ b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/filter/TestJavaFunctions.java @@ -6,9 +6,10 @@ import java.util.List; import java.util.Map; -import javax.persistence.EntityManagerFactory; import javax.sql.DataSource; +import jakarta.persistence.EntityManagerFactory; + import org.apache.olingo.commons.api.ex.ODataException; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; diff --git a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/modify/TestJPACUDRequestHelper.java b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/modify/TestJPACUDRequestHelper.java index 40458daea..26e4f1995 100644 --- a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/modify/TestJPACUDRequestHelper.java +++ b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/modify/TestJPACUDRequestHelper.java @@ -19,7 +19,7 @@ import java.util.Optional; import java.util.stream.Stream; -import javax.persistence.AttributeConverter; +import jakarta.persistence.AttributeConverter; import org.apache.olingo.commons.api.data.ComplexValue; import org.apache.olingo.commons.api.data.Entity; diff --git a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/modify/TestJPACreateResult.java b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/modify/TestJPACreateResult.java index 0abd82912..e678905c7 100644 --- a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/modify/TestJPACreateResult.java +++ b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/modify/TestJPACreateResult.java @@ -11,8 +11,8 @@ import java.util.Map; import java.util.Map.Entry; -import javax.persistence.Tuple; -import javax.persistence.TupleElement; +import jakarta.persistence.Tuple; +import jakarta.persistence.TupleElement; import org.apache.olingo.commons.api.data.ComplexValue; import org.apache.olingo.server.api.OData; diff --git a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/processor/JPAActionRequestProcessorTest.java b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/processor/JPAActionRequestProcessorTest.java index 5d4d68cae..dfcba1542 100644 --- a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/processor/JPAActionRequestProcessorTest.java +++ b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/processor/JPAActionRequestProcessorTest.java @@ -19,8 +19,8 @@ import java.util.Map; import java.util.Optional; -import javax.persistence.EntityManager; -import javax.persistence.criteria.CriteriaBuilder; +import jakarta.persistence.EntityManager; +import jakarta.persistence.criteria.CriteriaBuilder; import org.apache.olingo.commons.api.data.Annotatable; import org.apache.olingo.commons.api.data.Parameter; diff --git a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/processor/JPAClearProcessorTest.java b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/processor/JPAClearProcessorTest.java index 8c947e2fb..b1c01a65a 100644 --- a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/processor/JPAClearProcessorTest.java +++ b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/processor/JPAClearProcessorTest.java @@ -20,7 +20,7 @@ import java.util.Map; import java.util.Optional; -import javax.persistence.EntityManager; +import jakarta.persistence.EntityManager; import org.apache.olingo.commons.api.edm.EdmProperty; import org.apache.olingo.commons.api.ex.ODataException; @@ -342,7 +342,7 @@ void testErrorReturnCodeWithOutRollback() throws ODataJPATransactionException { } @Test - void testReraiseWithRollback() throws ODataJPATransactionException { + void testReRaiseWithRollback() throws ODataJPATransactionException { // .../Organizations('35')/Name2 final ODataResponse response = new ODataResponse(); @@ -357,7 +357,7 @@ void testReraiseWithRollback() throws ODataJPATransactionException { } @Test - void testReraiseReturnCodeWithOutRollback() throws ODataJPAProcessException { + void testReRaiseReturnCodeWithOutRollback() throws ODataJPAProcessException { // .../Organizations('35')/Name2 final ODataResponse response = new ODataResponse(); @@ -514,12 +514,12 @@ private RequestHandleSpy prepareDeleteAdminInfo() { when(uriProperty.getProperty()).thenReturn(property); when(property.getName()).thenReturn("Updated"); - UriResourcePrimitiveProperty uriPrimProperty; - uriPrimProperty = mock(UriResourcePrimitiveProperty.class); + UriResourcePrimitiveProperty uriPrimitiveProperty; + uriPrimitiveProperty = mock(UriResourcePrimitiveProperty.class); property = mock(EdmProperty.class); - pathParts.add(uriPrimProperty); - when(uriPrimProperty.getProperty()).thenReturn(property); + pathParts.add(uriPrimitiveProperty); + when(uriPrimitiveProperty.getProperty()).thenReturn(property); when(property.getName()).thenReturn("By"); final RequestHandleSpy spy = new RequestHandleSpy(); diff --git a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/processor/JPACoreDebuggerTest.java b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/processor/JPACoreDebuggerTest.java index 094fbb982..58d62c738 100644 --- a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/processor/JPACoreDebuggerTest.java +++ b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/processor/JPACoreDebuggerTest.java @@ -68,20 +68,20 @@ void teardown() { @Test void testMeassumentCreated() throws Exception { - try (JPARuntimeMeasurement meassument = cutDebugOn.newMeasurement(cutDebugOn, "firstTest")) {} + try (JPARuntimeMeasurement measurement = cutDebugOn.newMeasurement(cutDebugOn, "firstTest")) {} assertFalse(cutDebugOn.getRuntimeInformation().isEmpty()); } @Test void testNoMeassumentDebugFalls() throws Exception { cutDebugOn = new JPACoreDebugger(false); - try (JPARuntimeMeasurement meassument = cutDebugOn.newMeasurement(cutDebugOn, "firstTest")) {} + try (JPARuntimeMeasurement measurement = cutDebugOn.newMeasurement(cutDebugOn, "firstTest")) {} assertTrue(cutDebugOn.getRuntimeInformation().isEmpty()); } @Test void testMeassumentCreateMeassument() throws Exception { - try (JPARuntimeMeasurement meassument = cutDebugOn.newMeasurement(cutDebugOn, "firstTest")) { + try (JPARuntimeMeasurement measurement = cutDebugOn.newMeasurement(cutDebugOn, "firstTest")) { TimeUnit.MILLISECONDS.sleep(100); } assertFalse(cutDebugOn.getRuntimeInformation().isEmpty()); @@ -95,7 +95,7 @@ void testMeassumentCreateMeassument() throws Exception { @Test void testRuntimeMeasurementEmptyAfterStopWhenOff() throws InterruptedException { System.setErr(printOut); - try (JPARuntimeMeasurement meassument = cutDebugOn.newMeasurement(cutDebugOn, "firstTest")) { + try (JPARuntimeMeasurement measurement = cutDebugOn.newMeasurement(cutDebugOn, "firstTest")) { TimeUnit.MILLISECONDS.sleep(10); } final String act = output.toString(); diff --git a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/processor/JPADebugSupportWrapperTest.java b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/processor/JPADebugSupportWrapperTest.java index 648dd8d80..ab8234c32 100644 --- a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/processor/JPADebugSupportWrapperTest.java +++ b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/processor/JPADebugSupportWrapperTest.java @@ -53,7 +53,7 @@ void testCreateDebugResponse() { final RuntimeMeasurement first = newRuntimeMeasurement(); final RuntimeMeasurement second = newRuntimeMeasurement(); final RuntimeMeasurement third = newRuntimeMeasurement(); - final List debugInfoList = new ArrayList( + final List debugInfoList = new ArrayList<>( Arrays.asList(first, third)); final List debuggerList = Arrays.asList(second); diff --git a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/processor/JPAEmptyDebuggerTest.java b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/processor/JPAEmptyDebuggerTest.java index 9c652ca3d..58f192f0c 100644 --- a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/processor/JPAEmptyDebuggerTest.java +++ b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/processor/JPAEmptyDebuggerTest.java @@ -17,8 +17,8 @@ void setup() { } @Test - void testMeassumentCreated() throws Exception { - try (JPARuntimeMeasurement meassument = cut.newMeasurement(cut, "firstTest")) { + void testMeasurementCreated() throws Exception { + try (JPARuntimeMeasurement measurement = cut.newMeasurement(cut, "firstTest")) { } assertTrue(cut.getRuntimeInformation().isEmpty()); diff --git a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/processor/JPAFunctionRequestProcessorTest.java b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/processor/JPAFunctionRequestProcessorTest.java index a29405a0d..93604ab8b 100644 --- a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/processor/JPAFunctionRequestProcessorTest.java +++ b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/processor/JPAFunctionRequestProcessorTest.java @@ -14,8 +14,8 @@ import java.util.ArrayList; import java.util.List; -import javax.persistence.EntityManager; -import javax.persistence.criteria.CriteriaBuilder; +import jakarta.persistence.EntityManager; +import jakarta.persistence.criteria.CriteriaBuilder; import org.apache.commons.lang3.tuple.ImmutableTriple; import org.apache.commons.lang3.tuple.Triple; diff --git a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/processor/JPAHookFactoryTest.java b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/processor/JPAHookFactoryTest.java index 9a60c8b5f..ecd677e7e 100644 --- a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/processor/JPAHookFactoryTest.java +++ b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/processor/JPAHookFactoryTest.java @@ -13,10 +13,10 @@ import java.util.Map; import java.util.Optional; -import javax.persistence.EntityManager; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.Expression; -import javax.persistence.criteria.From; +import jakarta.persistence.EntityManager; +import jakarta.persistence.criteria.CriteriaBuilder; +import jakarta.persistence.criteria.Expression; +import jakarta.persistence.criteria.From; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; diff --git a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/processor/JPAJavaFunctionProcessorTest.java b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/processor/JPAJavaFunctionProcessorTest.java index b9f3a575d..c2bbf2b3c 100644 --- a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/processor/JPAJavaFunctionProcessorTest.java +++ b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/processor/JPAJavaFunctionProcessorTest.java @@ -14,7 +14,7 @@ import java.util.ArrayList; import java.util.List; -import javax.persistence.EntityManager; +import jakarta.persistence.EntityManager; import org.apache.commons.lang3.tuple.ImmutableTriple; import org.apache.commons.lang3.tuple.Triple; diff --git a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/processor/JPAODataInternalRequestContextTest.java b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/processor/JPAODataInternalRequestContextTest.java index 0f9f14cbb..78c77812b 100644 --- a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/processor/JPAODataInternalRequestContextTest.java +++ b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/processor/JPAODataInternalRequestContextTest.java @@ -16,7 +16,7 @@ import java.util.Map; import java.util.Optional; -import javax.persistence.EntityManager; +import jakarta.persistence.EntityManager; import org.apache.olingo.commons.api.ex.ODataException; import org.apache.olingo.server.api.debug.DebugSupport; @@ -81,7 +81,6 @@ void setup() throws ODataException { contextAccess = mock(JPAODataRequestContextAccess.class); requestContext = mock(JPAODataRequestContext.class); sessionContext = mock(JPAODataSessionContextAccess.class); - page = mock(JPAODataPage.class); uriInfoResource = mock(UriInfoResource.class); header = new HashMap<>(); @@ -98,6 +97,7 @@ void setup() throws ODataException { dbProcessor = mock(JPAODataDatabaseProcessor.class); edmProvider = mock(JPAEdmProvider.class); operationConverter = mock(JPAODataDatabaseOperations.class); + page = new JPAODataPage(uriInfo, 0, 0, claims); when(contextAccess.getTransactionFactory()).thenReturn(transactionFactory); when(contextAccess.getRequestParameter()).thenReturn(customParameter); @@ -106,7 +106,6 @@ void setup() throws ODataException { when(contextAccess.getGroupsProvider()).thenReturn(groups); when(contextAccess.getProvidedLocale()).thenReturn(locales); when(contextAccess.getDebugger()).thenReturn(debugger); - when(page.getUriInfo()).thenReturn(uriInfo); when(requestContext.getClaimsProvider()).thenReturn(claims); when(requestContext.getCUDRequestHandler()).thenReturn(cudHandler); diff --git a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/processor/JPAODataRequestContextBuilderTest.java b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/processor/JPAODataRequestContextBuilderTest.java index 44f37af6f..5dd91feb2 100644 --- a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/processor/JPAODataRequestContextBuilderTest.java +++ b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/processor/JPAODataRequestContextBuilderTest.java @@ -5,7 +5,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.Mockito.mock; -import javax.persistence.EntityManager; +import jakarta.persistence.EntityManager; import org.apache.olingo.server.api.debug.DefaultDebugSupport; import org.junit.jupiter.api.BeforeEach; diff --git a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/processor/TestCreateRequestEntity.java b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/processor/TestCreateRequestEntity.java index 8d23984c0..6fed6af53 100644 --- a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/processor/TestCreateRequestEntity.java +++ b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/processor/TestCreateRequestEntity.java @@ -14,11 +14,12 @@ import java.util.Map; import java.util.Map.Entry; -import javax.persistence.EntityManager; -import javax.persistence.EntityManagerFactory; -import javax.persistence.EntityTransaction; import javax.sql.DataSource; +import jakarta.persistence.EntityManager; +import jakarta.persistence.EntityManagerFactory; +import jakarta.persistence.EntityTransaction; + import org.apache.olingo.commons.api.data.ComplexValue; import org.apache.olingo.commons.api.data.Entity; import org.apache.olingo.commons.api.data.EntityCollection; diff --git a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/processor/TestJPACreateProcessor.java b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/processor/TestJPACreateProcessor.java index 31ae62fe3..841ea901c 100644 --- a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/processor/TestJPACreateProcessor.java +++ b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/processor/TestJPACreateProcessor.java @@ -24,7 +24,7 @@ import java.util.Map.Entry; import java.util.Optional; -import javax.persistence.EntityManager; +import jakarta.persistence.EntityManager; import org.apache.olingo.commons.api.data.EntityCollection; import org.apache.olingo.commons.api.edm.Edm; diff --git a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/processor/TestJPADeleteProcessor.java b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/processor/TestJPADeleteProcessor.java index 6a58a6f3b..b94a512fa 100644 --- a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/processor/TestJPADeleteProcessor.java +++ b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/processor/TestJPADeleteProcessor.java @@ -19,7 +19,7 @@ import java.util.Map; import java.util.Optional; -import javax.persistence.EntityManager; +import jakarta.persistence.EntityManager; import org.apache.olingo.commons.api.ex.ODataException; import org.apache.olingo.commons.api.http.HttpStatusCode; diff --git a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/processor/TestJPAModifyProcessor.java b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/processor/TestJPAModifyProcessor.java index 63d7c7dd7..c9e495fb3 100644 --- a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/processor/TestJPAModifyProcessor.java +++ b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/processor/TestJPAModifyProcessor.java @@ -9,11 +9,12 @@ import java.util.ArrayList; import java.util.List; -import javax.persistence.EntityManager; -import javax.persistence.EntityManagerFactory; -import javax.persistence.EntityTransaction; import javax.sql.DataSource; +import jakarta.persistence.EntityManager; +import jakarta.persistence.EntityManagerFactory; +import jakarta.persistence.EntityTransaction; + import org.apache.olingo.commons.api.data.Entity; import org.apache.olingo.commons.api.data.EntityCollection; import org.apache.olingo.commons.api.edm.Edm; diff --git a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/processor/TestJPAODataRequestContextImpl.java b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/processor/TestJPAODataRequestContextImpl.java index c92185d38..cfd7180a1 100644 --- a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/processor/TestJPAODataRequestContextImpl.java +++ b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/processor/TestJPAODataRequestContextImpl.java @@ -16,7 +16,7 @@ import java.util.Map; import java.util.Optional; -import javax.persistence.EntityManager; +import jakarta.persistence.EntityManager; import org.apache.olingo.commons.api.ex.ODataException; import org.apache.olingo.server.api.uri.UriInfo; diff --git a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/processor/TestJPAUpdateProcessor.java b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/processor/TestJPAUpdateProcessor.java index e1c76f8a0..9d233a120 100644 --- a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/processor/TestJPAUpdateProcessor.java +++ b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/processor/TestJPAUpdateProcessor.java @@ -24,7 +24,7 @@ import java.util.Map; import java.util.Optional; -import javax.persistence.EntityManager; +import jakarta.persistence.EntityManager; import org.apache.olingo.commons.api.edm.EdmProperty; import org.apache.olingo.commons.api.ex.ODataException; @@ -61,7 +61,7 @@ class TestJPAUpdateProcessor extends TestJPAModifyProcessor { @Test - void testHockIsCalled() throws ODataJPAModelException, ODataException { + void testHookIsCalled() throws ODataJPAModelException, ODataException { final ODataResponse response = new ODataResponse(); final ODataRequest request = prepareSimpleRequest(); @@ -510,7 +510,7 @@ void testDoesRollbackIfUpdateRaisesError() throws ODataException { } @Test - void testDoesRollbackIfUpdateRaisesAbitaryError() throws ODataException { + void testDoesRollbackIfUpdateRaisesArbitraryError() throws ODataException { final ODataResponse response = new ODataResponse(); final ODataRequest request = prepareSimpleRequest(); diff --git a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/JPAAbstractQueryTest.java b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/JPAAbstractQueryTest.java new file mode 100644 index 000000000..194adbc6c --- /dev/null +++ b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/JPAAbstractQueryTest.java @@ -0,0 +1,106 @@ +package com.sap.olingo.jpa.processor.core.query; + +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import java.util.Collections; +import java.util.Locale; +import java.util.Optional; +import java.util.stream.Stream; + +import jakarta.persistence.EntityManager; +import jakarta.persistence.criteria.AbstractQuery; +import jakarta.persistence.criteria.From; + +import org.apache.olingo.commons.api.ex.ODataException; +import org.apache.olingo.server.api.OData; +import org.apache.olingo.server.api.uri.queryoption.OrderByItem; +import org.apache.olingo.server.api.uri.queryoption.OrderByOption; +import org.apache.olingo.server.api.uri.queryoption.apply.AggregateExpression; +import org.apache.olingo.server.api.uri.queryoption.expression.Alias; +import org.apache.olingo.server.api.uri.queryoption.expression.Binary; +import org.apache.olingo.server.api.uri.queryoption.expression.Enumeration; +import org.apache.olingo.server.api.uri.queryoption.expression.Expression; +import org.apache.olingo.server.api.uri.queryoption.expression.LambdaRef; +import org.apache.olingo.server.api.uri.queryoption.expression.Literal; +import org.apache.olingo.server.api.uri.queryoption.expression.Method; +import org.apache.olingo.server.api.uri.queryoption.expression.TypeLiteral; +import org.apache.olingo.server.api.uri.queryoption.expression.Unary; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + +import com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAEntityType; +import com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAServiceDocument; +import com.sap.olingo.jpa.processor.core.api.JPAODataClaimProvider; +import com.sap.olingo.jpa.processor.core.api.JPAODataRequestContextAccess; +import com.sap.olingo.jpa.processor.core.exception.ODataJPAIllegalAccessException; +import com.sap.olingo.jpa.processor.core.exception.ODataJPAQueryException; +import com.sap.olingo.jpa.processor.core.util.TestQueryBase; + +class JPAAbstractQueryTest extends TestQueryBase { + + private JPAAbstractQuery cut; + private EntityManager em; + + @Override + @BeforeEach + public void setup() throws ODataException, ODataJPAIllegalAccessException { + super.setup(); + em = mock(EntityManager.class); + cut = new Query(null, helper.sd, jpaEntityType, em, Optional.empty()); + } + + static Stream expressionProvider() { + return Stream.of( + mock(Method.class), + mock(Literal.class), + mock(TypeLiteral.class), + mock(Unary.class), + mock(LambdaRef.class), + mock(Enumeration.class), + mock(Binary.class), + mock(Alias.class), + mock(AggregateExpression.class)); + } + + @MethodSource("expressionProvider") + @ParameterizedTest + void testExtractOrderByNavigationAttributesThrowsExceptionIfNotSupported(final Expression orderByExpression) { + final OrderByOption orderBy = mock(OrderByOption.class); + final OrderByItem item = mock(OrderByItem.class); + when(orderBy.getOrders()).thenReturn(Collections.singletonList(item)); + when(item.getExpression()).thenReturn(orderByExpression); + assertThrows(ODataJPAQueryException.class, () -> cut.extractOrderByNavigationAttributes(orderBy)); + } + + private static class Query extends JPAAbstractQuery { + + Query(final OData odata, final JPAServiceDocument sd, final JPAEntityType jpaEntityType, final EntityManager em, + final Optional claimsProvider) { + super(odata, sd, jpaEntityType, em, claimsProvider); + } + + @Override + public AbstractQuery getQuery() { + throw new IllegalAccessError(); + } + + @Override + public From getRoot() { + throw new IllegalAccessError(); + } + + @Override + protected Locale getLocale() { + throw new IllegalAccessError(); + } + + @Override + JPAODataRequestContextAccess getContext() { + throw new IllegalAccessError(); + } + + } +} diff --git a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/JPAExpandJoinCountQueryTest.java b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/JPAExpandJoinCountQueryTest.java index de74fc025..5fe2d2559 100644 --- a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/JPAExpandJoinCountQueryTest.java +++ b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/JPAExpandJoinCountQueryTest.java @@ -12,7 +12,7 @@ import java.util.Map; import java.util.Optional; -import javax.persistence.Tuple; +import jakarta.persistence.Tuple; import org.apache.olingo.commons.api.ex.ODataException; import org.apache.olingo.server.api.OData; @@ -113,7 +113,7 @@ void testConvertCountResultCanHandleLong() throws ODataException { assertEquals(1, act.size()); assertEquals(5L, act.get("")); } - + private JPANavigationPropertyInfo createHop(final JPAAssociationPath exp) { final UriInfoResource uriInfo = mock(UriInfoResource.class); return new JPANavigationPropertyInfo(sd, exp, uriInfo, et); diff --git a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/JPAExpandJoinQueryTest.java b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/JPAExpandJoinQueryTest.java index 076e3846b..c5d40fbbc 100644 --- a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/JPAExpandJoinQueryTest.java +++ b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/JPAExpandJoinQueryTest.java @@ -12,8 +12,8 @@ import java.util.Map; import java.util.Optional; -import javax.persistence.EntityManager; -import javax.persistence.criteria.Expression; +import jakarta.persistence.EntityManager; +import jakarta.persistence.criteria.Expression; import org.apache.olingo.commons.api.edm.EdmEntitySet; import org.apache.olingo.commons.api.edm.EdmEntityType; diff --git a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/JPAExpandQueryResultTest.java b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/JPAExpandQueryResultTest.java index 47b161e28..2519b4856 100644 --- a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/JPAExpandQueryResultTest.java +++ b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/JPAExpandQueryResultTest.java @@ -16,7 +16,7 @@ import java.util.Map; import java.util.Optional; -import javax.persistence.Tuple; +import jakarta.persistence.Tuple; import org.apache.olingo.commons.api.ex.ODataException; import org.apache.olingo.server.api.ODataApplicationException; diff --git a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/JPAExpandSubCountQueryTest.java b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/JPAExpandSubCountQueryTest.java index 0b1e488f9..0ff748f99 100644 --- a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/JPAExpandSubCountQueryTest.java +++ b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/JPAExpandSubCountQueryTest.java @@ -9,7 +9,7 @@ import java.util.List; import java.util.Map; -import javax.persistence.Tuple; +import jakarta.persistence.Tuple; import org.apache.olingo.commons.api.ex.ODataException; import org.apache.olingo.server.api.OData; diff --git a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/JPAJoinQueryTest.java b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/JPAJoinQueryTest.java index 4596d7ee1..74109dc3c 100644 --- a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/JPAJoinQueryTest.java +++ b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/JPAJoinQueryTest.java @@ -7,11 +7,11 @@ import static org.mockito.Mockito.spy; import static org.mockito.Mockito.when; -import javax.persistence.EntityManager; -import javax.persistence.TypedQuery; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.CriteriaQuery; -import javax.persistence.criteria.Expression; +import jakarta.persistence.EntityManager; +import jakarta.persistence.TypedQuery; +import jakarta.persistence.criteria.CriteriaBuilder; +import jakarta.persistence.criteria.CriteriaQuery; +import jakarta.persistence.criteria.Expression; import org.apache.olingo.commons.api.ex.ODataException; import org.apache.olingo.server.api.ODataApplicationException; diff --git a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/JPAKeyPairTest.java b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/JPAKeyPairTest.java index b40b6d2bb..81bd9140c 100644 --- a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/JPAKeyPairTest.java +++ b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/JPAKeyPairTest.java @@ -17,7 +17,7 @@ import java.util.Map; import java.util.UUID; -import javax.persistence.AttributeConverter; +import jakarta.persistence.AttributeConverter; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; diff --git a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/JPANavigationCountQueryTest.java b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/JPANavigationCountQueryTest.java index 951c9f7c6..cb53b1278 100644 --- a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/JPANavigationCountQueryTest.java +++ b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/JPANavigationCountQueryTest.java @@ -11,16 +11,16 @@ import java.util.Collections; import java.util.Optional; -import javax.persistence.EntityManager; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.CriteriaQuery; -import javax.persistence.criteria.From; -import javax.persistence.criteria.Join; -import javax.persistence.criteria.JoinType; -import javax.persistence.criteria.Path; -import javax.persistence.criteria.Predicate; -import javax.persistence.criteria.Root; -import javax.persistence.criteria.Subquery; +import jakarta.persistence.EntityManager; +import jakarta.persistence.criteria.CriteriaBuilder; +import jakarta.persistence.criteria.CriteriaQuery; +import jakarta.persistence.criteria.From; +import jakarta.persistence.criteria.Join; +import jakarta.persistence.criteria.JoinType; +import jakarta.persistence.criteria.Path; +import jakarta.persistence.criteria.Predicate; +import jakarta.persistence.criteria.Root; +import jakarta.persistence.criteria.Subquery; import org.apache.olingo.commons.api.edm.EdmEntityType; import org.apache.olingo.commons.api.edm.EdmPrimitiveType; diff --git a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/JPANavigationFilterQueryBuilderTest.java b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/JPANavigationFilterQueryBuilderTest.java index 1b23f475e..9016c2461 100644 --- a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/JPANavigationFilterQueryBuilderTest.java +++ b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/JPANavigationFilterQueryBuilderTest.java @@ -12,11 +12,11 @@ import java.util.Locale; import java.util.stream.Stream; -import javax.persistence.EntityManager; -import javax.persistence.criteria.AbstractQuery; -import javax.persistence.criteria.From; -import javax.persistence.criteria.Root; -import javax.persistence.criteria.Subquery; +import jakarta.persistence.EntityManager; +import jakarta.persistence.criteria.AbstractQuery; +import jakarta.persistence.criteria.From; +import jakarta.persistence.criteria.Root; +import jakarta.persistence.criteria.Subquery; import org.apache.olingo.commons.api.edm.EdmEntityType; import org.apache.olingo.server.api.OData; @@ -60,7 +60,7 @@ class JPANavigationFilterQueryBuilderTest { private JPAODataDatabaseOperations dbOperations; private JPAEntityType et; private EdmEntityType type; - private AbstractQuery query; + private AbstractQuery query; private Subquery subQuery; private Root queryRoot; @@ -95,7 +95,7 @@ void setup() throws ODataJPAModelException { when(context.getOperationConverter()).thenReturn(dbOperations); when(parent.getContext()).thenReturn(context); when(parent.getLocale()).thenReturn(Locale.GERMANY); - when(parent.getQuery()).thenReturn(query); + doReturn(query).when(parent).getQuery(); when(query.subquery(Integer.class)).thenReturn(subQuery); when(subQuery.from(Person.class)).thenReturn(queryRoot); } diff --git a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/JPANavigationFilterQueryTest.java b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/JPANavigationFilterQueryTest.java index 32961ee20..a7640319f 100644 --- a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/JPANavigationFilterQueryTest.java +++ b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/JPANavigationFilterQueryTest.java @@ -10,14 +10,14 @@ import java.util.Collections; import java.util.Optional; -import javax.persistence.EntityManager; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.CriteriaQuery; -import javax.persistence.criteria.From; -import javax.persistence.criteria.Path; -import javax.persistence.criteria.Predicate; -import javax.persistence.criteria.Root; -import javax.persistence.criteria.Subquery; +import jakarta.persistence.EntityManager; +import jakarta.persistence.criteria.CriteriaBuilder; +import jakarta.persistence.criteria.CriteriaQuery; +import jakarta.persistence.criteria.From; +import jakarta.persistence.criteria.Path; +import jakarta.persistence.criteria.Predicate; +import jakarta.persistence.criteria.Root; +import jakarta.persistence.criteria.Subquery; import org.apache.olingo.commons.api.edm.EdmEntityType; import org.apache.olingo.commons.api.ex.ODataException; @@ -31,7 +31,6 @@ import com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAAssociationPath; import com.sap.olingo.jpa.processor.core.api.JPAClaimsPair; import com.sap.olingo.jpa.processor.core.api.JPAODataClaimProvider; -import com.sap.olingo.jpa.processor.core.api.JPAODataRequestContextAccess; import com.sap.olingo.jpa.processor.core.exception.ODataJPAIllegalAccessException; import com.sap.olingo.jpa.processor.core.testmodel.BusinessPartnerProtected; import com.sap.olingo.jpa.processor.core.testmodel.BusinessPartnerRoleProtected; @@ -50,14 +49,12 @@ class JPANavigationFilterQueryTest extends TestBase { private From from; private Root queryJoinTable; private Root queryRoot; - private Root parentRoot; private JPAODataClaimProvider claimsProvider; private EdmEntityType edmEntityType; @SuppressWarnings("rawtypes") private CriteriaQuery cq; private CriteriaBuilder cb; private Subquery subQuery; - private JPAODataRequestContextAccess requestContext; @SuppressWarnings("unchecked") @BeforeEach @@ -75,9 +72,7 @@ public void setup() throws ODataException, ODataJPAIllegalAccessException { subQuery = mock(Subquery.class); queryJoinTable = mock(Root.class); queryRoot = mock(Root.class); - parentRoot = mock(Root.class); from = mock(From.class); - requestContext = mock(JPAODataRequestContextAccess.class); final UriParameter key = mock(UriParameter.class); diff --git a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/JPANavigationNullQueryTest.java b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/JPANavigationNullQueryTest.java index e18cec691..9ca1addc9 100644 --- a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/JPANavigationNullQueryTest.java +++ b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/JPANavigationNullQueryTest.java @@ -11,14 +11,14 @@ import java.util.Collections; import java.util.Optional; -import javax.persistence.EntityManager; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.CriteriaQuery; -import javax.persistence.criteria.From; -import javax.persistence.criteria.Path; -import javax.persistence.criteria.Predicate; -import javax.persistence.criteria.Root; -import javax.persistence.criteria.Subquery; +import jakarta.persistence.EntityManager; +import jakarta.persistence.criteria.CriteriaBuilder; +import jakarta.persistence.criteria.CriteriaQuery; +import jakarta.persistence.criteria.From; +import jakarta.persistence.criteria.Path; +import jakarta.persistence.criteria.Predicate; +import jakarta.persistence.criteria.Root; +import jakarta.persistence.criteria.Subquery; import org.apache.olingo.commons.api.edm.EdmEntityType; import org.apache.olingo.commons.api.edm.EdmPrimitiveType; @@ -46,7 +46,6 @@ import com.sap.olingo.jpa.processor.core.filter.JPAFilterExpression; import com.sap.olingo.jpa.processor.core.testmodel.BusinessPartnerProtected; import com.sap.olingo.jpa.processor.core.testmodel.BusinessPartnerRoleProtected; -import com.sap.olingo.jpa.processor.core.testmodel.JoinPartnerRoleRelation; import com.sap.olingo.jpa.processor.core.util.TestBase; import com.sap.olingo.jpa.processor.core.util.TestHelper; @@ -59,9 +58,7 @@ class JPANavigationNullQueryTest extends TestBase { private JPAAbstractQuery parent; private JPAAssociationPath association; private From from; - private Root queryJoinTable; private Root queryRoot; - private Root parentRoot; private JPAODataClaimProvider claimsProvider; private EdmEntityType edmEntityType; @SuppressWarnings("rawtypes") @@ -84,9 +81,7 @@ public void setup() throws ODataException, ODataJPAIllegalAccessException { cq = mock(CriteriaQuery.class); cb = mock(CriteriaBuilder.class); // emf.getCriteriaBuilder(); subQuery = mock(Subquery.class); - queryJoinTable = mock(Root.class); queryRoot = mock(Root.class); - parentRoot = mock(Root.class); from = mock(From.class); requestContext = mock(JPAODataRequestContextAccess.class); diff --git a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/JPAOrderByBuilderWatchDogTest.java b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/JPAOrderByBuilderWatchDogTest.java index 66bea2202..509085eb3 100644 --- a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/JPAOrderByBuilderWatchDogTest.java +++ b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/JPAOrderByBuilderWatchDogTest.java @@ -13,8 +13,8 @@ import java.util.List; import java.util.stream.Stream; -import javax.persistence.criteria.Expression; -import javax.persistence.criteria.Order; +import jakarta.persistence.criteria.Expression; +import jakarta.persistence.criteria.Order; import org.apache.olingo.commons.api.edm.provider.CsdlAnnotation; import org.apache.olingo.commons.api.edm.provider.annotation.CsdlCollection; diff --git a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/TestJPAExpandQueryCreateResult.java b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/TestJPAExpandQueryCreateResult.java index 5253bafd1..6e4d2bed3 100644 --- a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/TestJPAExpandQueryCreateResult.java +++ b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/TestJPAExpandQueryCreateResult.java @@ -10,7 +10,7 @@ import java.util.List; import java.util.Map; -import javax.persistence.Tuple; +import jakarta.persistence.Tuple; import org.apache.olingo.commons.api.edm.EdmEntityType; import org.apache.olingo.commons.api.ex.ODataException; @@ -44,7 +44,7 @@ void setup() throws ODataException, ODataJPAIllegalAccessException { createHeaders(); final EdmEntityType targetEntity = new EdmEntityTypeDouble(nameBuilder, "BusinessPartnerRole"); sessionContext = new JPAODataContextAccessDouble(new JPAEdmProvider(PUNIT_NAME, emf, null, - TestBase.enumPackages), ds, null, null); + TestBase.enumPackages), dataSource, null, null); final JPAODataRequestContext externalContext = mock(JPAODataRequestContext.class); when(externalContext.getEntityManager()).thenReturn(emf.createEntityManager()); diff --git a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/TestJPAFunction.java b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/TestJPAFunction.java index 5c697ee5f..9631cdb6e 100644 --- a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/TestJPAFunction.java +++ b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/TestJPAFunction.java @@ -6,13 +6,14 @@ import java.util.List; import java.util.Map; -import javax.persistence.EntityManager; -import javax.persistence.EntityManagerFactory; -import javax.persistence.EntityTransaction; -import javax.persistence.Persistence; -import javax.persistence.Query; import javax.sql.DataSource; +import jakarta.persistence.EntityManager; +import jakarta.persistence.EntityManagerFactory; +import jakarta.persistence.EntityTransaction; +import jakarta.persistence.Persistence; +import jakarta.persistence.Query; + import org.apache.olingo.commons.api.ex.ODataException; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Disabled; @@ -35,7 +36,7 @@ class TestJPAFunction { void setup() { ds = DataSourceHelper.createDataSource(DataSourceHelper.DB_HSQLDB); final Map properties = new HashMap<>(); - properties.put("javax.persistence.nonJtaDataSource", ds); + properties.put("jakarta.persistence.nonJtaDataSource", ds); emf = Persistence.createEntityManagerFactory(PUNIT_NAME, properties); emf.getProperties(); createFunction(); diff --git a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/TestJPAFunctionDB.java b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/TestJPAFunctionDB.java index ee7784988..fdf24f272 100644 --- a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/TestJPAFunctionDB.java +++ b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/TestJPAFunctionDB.java @@ -9,7 +9,7 @@ import java.util.ArrayList; import java.util.List; -import javax.persistence.EntityManager; +import jakarta.persistence.EntityManager; import org.apache.olingo.commons.api.data.Annotatable; import org.apache.olingo.commons.api.edm.EdmFunction; diff --git a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/TestJPAFunctionJava.java b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/TestJPAFunctionJava.java index 366a45b5e..5d63cfff1 100644 --- a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/TestJPAFunctionJava.java +++ b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/TestJPAFunctionJava.java @@ -11,11 +11,12 @@ import java.util.List; import java.util.Map; -import javax.persistence.EntityManager; -import javax.persistence.EntityManagerFactory; -import javax.persistence.Persistence; import javax.sql.DataSource; +import jakarta.persistence.EntityManager; +import jakarta.persistence.EntityManagerFactory; +import jakarta.persistence.Persistence; + import org.apache.olingo.commons.api.data.Annotatable; import org.apache.olingo.commons.api.edm.EdmFunction; import org.apache.olingo.commons.api.edm.EdmParameter; @@ -72,7 +73,7 @@ void setup() throws ODataException { final DataSource ds = DataSourceHelper.createDataSource(DataSourceHelper.DB_HSQLDB); final Map properties = new HashMap<>(); - properties.put("javax.persistence.nonJtaDataSource", ds); + properties.put("jakarta.persistence.nonJtaDataSource", ds); final EntityManagerFactory emf = Persistence.createEntityManagerFactory(PUNIT_NAME, properties); uriResources = new ArrayList<>(); when(uriInfo.getUriResourceParts()).thenReturn(uriResources); diff --git a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/TestJPAFunctionSerializer.java b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/TestJPAFunctionSerializer.java index 16e160a40..a7d343f16 100644 --- a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/TestJPAFunctionSerializer.java +++ b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/TestJPAFunctionSerializer.java @@ -9,10 +9,11 @@ import java.util.List; import java.util.Map; -import javax.persistence.EntityManagerFactory; -import javax.persistence.Persistence; import javax.sql.DataSource; +import jakarta.persistence.EntityManagerFactory; +import jakarta.persistence.Persistence; + import org.apache.olingo.commons.api.ex.ODataException; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -35,7 +36,7 @@ class TestJPAFunctionSerializer { void setup() { ds = DataSourceHelper.createDataSource(DataSourceHelper.DB_HSQLDB); final Map properties = new HashMap<>(); - properties.put("javax.persistence.nonJtaDataSource", ds); + properties.put("jakarta.persistence.nonJtaDataSource", ds); emf = Persistence.createEntityManagerFactory(PUNIT_NAME, properties); emf.getProperties(); } diff --git a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/TestJPAOrderByBuilder.java b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/TestJPAOrderByBuilder.java index dd0b416f0..f71f6e578 100644 --- a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/TestJPAOrderByBuilder.java +++ b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/TestJPAOrderByBuilder.java @@ -15,9 +15,9 @@ import java.util.Map; import java.util.stream.Collectors; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.From; -import javax.persistence.criteria.Order; +import jakarta.persistence.criteria.CriteriaBuilder; +import jakarta.persistence.criteria.From; +import jakarta.persistence.criteria.Order; import org.apache.olingo.commons.api.edm.EdmNavigationProperty; import org.apache.olingo.commons.api.edm.EdmProperty; @@ -323,8 +323,7 @@ void testThrowExceptionOrderByTransientPrimitiveSimpleProperty() throws IOExcept @Test void testPagePresentOnlyTopValue() throws IOException, ODataException { - page = mock(JPAODataPage.class); - when(page.getTop()).thenReturn(10); + page = new JPAODataPage(null, 0, 10, skip); final List act = cut.createOrderByList(joinTables, uriResource, page); @@ -337,8 +336,7 @@ void testPagePresentOnlyTopValue() throws IOException, ODataException { @Test void testPagePresentMaxTopValueNoOrdering() throws IOException, ODataException { - page = mock(JPAODataPage.class); - when(page.getTop()).thenReturn(Integer.MAX_VALUE); + page = new JPAODataPage(null, 0, Integer.MAX_VALUE, skip); final List act = cut.createOrderByList(joinTables, uriResource, page); @@ -347,8 +345,7 @@ void testPagePresentMaxTopValueNoOrdering() throws IOException, ODataException { @Test void testPagePresentOnlySkipValue() throws IOException, ODataException { - page = mock(JPAODataPage.class); - when(page.getSkip()).thenReturn(10); + page = new JPAODataPage(null, 10, 0, null); final List act = cut.createOrderByList(joinTables, uriResource, page); @@ -361,8 +358,7 @@ void testPagePresentOnlySkipValue() throws IOException, ODataException { @Test void testPageAndTopPresent() throws IOException, ODataException { - page = mock(JPAODataPage.class); - when(page.getSkip()).thenReturn(10); + page = new JPAODataPage(null, 10, 0, null); when(top.getValue()).thenReturn(5); when(uriResource.getTopOption()).thenReturn(top); @@ -377,8 +373,7 @@ void testPageAndTopPresent() throws IOException, ODataException { @Test void testPageMaxTopValueAndTopPresent() throws IOException, ODataException { - page = mock(JPAODataPage.class); - when(page.getSkip()).thenReturn(Integer.MAX_VALUE); + page = new JPAODataPage(null, Integer.MAX_VALUE, 0, null); when(top.getValue()).thenReturn(5); when(uriResource.getTopOption()).thenReturn(top); @@ -394,8 +389,7 @@ void testPageMaxTopValueAndTopPresent() throws IOException, ODataException { @Test void testOrderByPropertyAndPage() throws IOException, ODataException { createOrderByItem("DivisionCode"); - page = mock(JPAODataPage.class); - when(page.getSkip()).thenReturn(10); + page = new JPAODataPage(null, 10, 0, null); when(uriResource.getOrderByOption()).thenReturn(orderBy); final List act = cut.createOrderByList(joinTables, uriResource, page); diff --git a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/TestJPAQueryBuildSelectionPathList.java b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/TestJPAQueryBuildSelectionPathList.java index 107634ae3..421951d62 100644 --- a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/TestJPAQueryBuildSelectionPathList.java +++ b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/TestJPAQueryBuildSelectionPathList.java @@ -54,7 +54,7 @@ void setup() throws ODataException, ODataJPAIllegalAccessException { nameBuilder = new JPADefaultEdmNameBuilder(PUNIT_NAME); createHeaders(); sessionContext = new JPAODataContextAccessDouble(new JPAEdmProvider(PUNIT_NAME, emf, null, TestBase.enumPackages), - ds, null, null); + dataSource, null, null); final JPAODataRequestContext externalContext = mock(JPAODataRequestContext.class); when(externalContext.getEntityManager()).thenReturn(emf.createEntityManager()); requestContext = new JPAODataInternalRequestContext(externalContext, sessionContext); diff --git a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/TestJPAQueryFromClause.java b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/TestJPAQueryFromClause.java index ada0005b9..f04e12b31 100644 --- a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/TestJPAQueryFromClause.java +++ b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/TestJPAQueryFromClause.java @@ -14,10 +14,10 @@ import java.util.Optional; import java.util.Set; -import javax.persistence.criteria.From; -import javax.persistence.criteria.Join; -import javax.persistence.criteria.JoinType; -import javax.persistence.criteria.Root; +import jakarta.persistence.criteria.From; +import jakarta.persistence.criteria.Join; +import jakarta.persistence.criteria.JoinType; +import jakarta.persistence.criteria.Root; import org.apache.olingo.commons.api.edm.EdmEntitySet; import org.apache.olingo.commons.api.edm.EdmEntityType; @@ -75,7 +75,7 @@ void setup() throws ODataException, ODataJPAIllegalAccessException { helper = new TestHelper(emf, PUNIT_NAME); jpaEntityType = helper.getJPAEntityType("Organizations"); sessionContext = new JPAODataContextAccessDouble(new JPAEdmProvider(PUNIT_NAME, emf, null, TestBase.enumPackages), - ds, null, null); + dataSource, null, null); createHeaders(); final JPAODataRequestContext externalContext = mock(JPAODataRequestContext.class); when(externalContext.getEntityManager()).thenReturn(emf.createEntityManager()); @@ -100,7 +100,7 @@ void checkFromListOrderByContainsOne() throws ODataJPAModelException, ODataAppli final List orderBy = new ArrayList<>(); final JPAAssociationPath exp = buildRoleAssociationPath(orderBy); - final Map> act = cut.createFromClause(orderBy, new ArrayList(), cut.cq, null); + final Map> act = cut.createFromClause(orderBy, new ArrayList<>(), cut.cq, null); assertNotNull(act.get(exp.getAlias())); } diff --git a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/TestJPAQueryPair.java b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/TestJPAQueryPair.java index 0db41a3f9..38c5e4766 100644 --- a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/TestJPAQueryPair.java +++ b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/TestJPAQueryPair.java @@ -21,12 +21,12 @@ void setup() { @Test void testGetOuter() { - assertEquals(outer, cut.getOuter()); + assertEquals(outer, cut.outer()); } @Test void testGetInner() { - assertEquals(inner, cut.getInner()); + assertEquals(inner, cut.inner()); } @Test diff --git a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/TestJPAQuerySelectClause.java b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/TestJPAQuerySelectClause.java index 53bec0e33..23ccec1e0 100644 --- a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/TestJPAQuerySelectClause.java +++ b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/TestJPAQuerySelectClause.java @@ -15,9 +15,9 @@ import java.util.List; import java.util.Optional; -import javax.persistence.criteria.Join; -import javax.persistence.criteria.JoinType; -import javax.persistence.criteria.Selection; +import jakarta.persistence.criteria.Join; +import jakarta.persistence.criteria.JoinType; +import jakarta.persistence.criteria.Selection; import org.apache.olingo.commons.api.edm.EdmComplexType; import org.apache.olingo.commons.api.edm.EdmEntitySet; diff --git a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/TestJPAQuerySelectWithGroupClause.java b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/TestJPAQuerySelectWithGroupClause.java index 5d5878ee2..9261ba69e 100644 --- a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/TestJPAQuerySelectWithGroupClause.java +++ b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/TestJPAQuerySelectWithGroupClause.java @@ -6,7 +6,7 @@ import java.util.Collections; import java.util.List; -import javax.persistence.criteria.Selection; +import jakarta.persistence.criteria.Selection; import org.apache.olingo.commons.api.ex.ODataException; import org.apache.olingo.server.api.ODataApplicationException; diff --git a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/TestJPAQueryWithProtection.java b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/TestJPAQueryWithProtection.java index 34481fa2a..bfd6f3fc3 100644 --- a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/TestJPAQueryWithProtection.java +++ b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/TestJPAQueryWithProtection.java @@ -21,11 +21,11 @@ import java.util.Optional; import java.util.Set; -import javax.persistence.EntityManager; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.Expression; -import javax.persistence.criteria.Predicate; -import javax.persistence.criteria.Predicate.BooleanOperator; +import jakarta.persistence.EntityManager; +import jakarta.persistence.criteria.CriteriaBuilder; +import jakarta.persistence.criteria.Expression; +import jakarta.persistence.criteria.Predicate; +import jakarta.persistence.criteria.Predicate.BooleanOperator; import org.apache.olingo.commons.api.edm.EdmType; import org.apache.olingo.commons.api.ex.ODataException; diff --git a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/TestJPAServerDrivenPaging.java b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/TestJPAServerDrivenPaging.java index d7f9cfbaa..bc98bc6f9 100644 --- a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/TestJPAServerDrivenPaging.java +++ b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/TestJPAServerDrivenPaging.java @@ -4,7 +4,7 @@ import static org.junit.jupiter.api.Assertions.assertNull; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.argThat; -import static org.mockito.ArgumentMatchers.isNotNull; +import static org.mockito.ArgumentMatchers.notNull; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -135,7 +135,7 @@ void testEntityManagerProvided() throws IOException, ODataException { final IntegrationTestHelper helper = new IntegrationTestHelper(emf, "Organizations?$orderby=ID desc", provider); helper.assertStatus(200); - verify(provider).getFirstPage(any(), any(), any(), isNotNull()); + verify(provider).getFirstPage(any(), any(), any(), notNull()); } @Test @@ -147,7 +147,7 @@ void testCountQueryProvided() throws IOException, ODataException { final IntegrationTestHelper helper = new IntegrationTestHelper(emf, "Organizations?$orderby=ID desc", provider); helper.assertStatus(200); - verify(provider).getFirstPage(any(), any(), isNotNull(), any()); + verify(provider).getFirstPage(any(), any(), notNull(), any()); } @Test @@ -170,7 +170,6 @@ void testMaxPageSizeHeaderProvided() throws IOException, ODataException { headers = new HashMap<>(); final List headerValues = new ArrayList<>(0); final JPAODataPagingProvider provider = mock(JPAODataPagingProvider.class); - when(provider.getFirstPage(any(), any(), any(), any())).thenAnswer(i -> new JPAODataPage((UriInfo) i .getArguments()[0], 0, 5, "Hugo")); headerValues.add("odata.maxpagesize=50"); @@ -180,7 +179,7 @@ void testMaxPageSizeHeaderProvided() throws IOException, ODataException { headers); helper.assertStatus(200); - verify(provider).getFirstPage(any(), isNotNull(), any(), any()); + verify(provider).getFirstPage(any(), notNull(), any(), any()); } @Test @@ -197,7 +196,7 @@ void testMaxPageSizeHeaderProvidedInLowerCase() throws IOException, ODataExcepti headers); helper.assertStatus(200); - verify(provider).getFirstPage(any(), isNotNull(), any(), any()); + verify(provider).getFirstPage(any(), notNull(), any(), any()); } @Test @@ -211,7 +210,7 @@ void testUriInfoProvided() throws IOException, ODataException { final IntegrationTestHelper helper = new IntegrationTestHelper(emf, "Organizations?$orderby=ID desc", provider); helper.assertStatus(200); - verify(provider).getFirstPage(isNotNull(), any(), any(), any()); + verify(provider).getFirstPage(notNull(), any(), any(), any()); } @Test diff --git a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/TestJPATupleChildConverter.java b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/TestJPATupleChildConverter.java index f5f9b1fba..43cce74fe 100644 --- a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/TestJPATupleChildConverter.java +++ b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/TestJPATupleChildConverter.java @@ -13,7 +13,7 @@ import java.util.Map; import java.util.Set; -import javax.persistence.Tuple; +import jakarta.persistence.Tuple; import org.apache.olingo.commons.api.data.ComplexValue; import org.apache.olingo.commons.api.data.EntityCollection; diff --git a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/TestJPATupleChildConverterCompoundKey.java b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/TestJPATupleChildConverterCompoundKey.java index 6ff743050..3b45edf1c 100644 --- a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/TestJPATupleChildConverterCompoundKey.java +++ b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/query/TestJPATupleChildConverterCompoundKey.java @@ -10,7 +10,7 @@ import java.util.List; import java.util.Map; -import javax.persistence.Tuple; +import jakarta.persistence.Tuple; import org.apache.olingo.commons.api.data.EntityCollection; import org.apache.olingo.commons.api.ex.ODataException; diff --git a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/testobjects/ClassWithIdClassConstructor.java b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/testobjects/ClassWithIdClassConstructor.java index c1467e3d2..aab702f65 100644 --- a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/testobjects/ClassWithIdClassConstructor.java +++ b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/testobjects/ClassWithIdClassConstructor.java @@ -1,7 +1,7 @@ package com.sap.olingo.jpa.processor.core.testobjects; public class ClassWithIdClassConstructor { - @SuppressWarnings("unused") + private final ClassWithMultipleKeysSetter key; public ClassWithIdClassConstructor(final ClassWithMultipleKeysSetter key) { diff --git a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/testobjects/FileAccessConverter.java b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/testobjects/FileAccessConverter.java index ba8b2147f..af07d4e80 100644 --- a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/testobjects/FileAccessConverter.java +++ b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/testobjects/FileAccessConverter.java @@ -4,21 +4,21 @@ import java.util.Arrays; import java.util.List; -import javax.persistence.AttributeConverter; +import jakarta.persistence.AttributeConverter; public class FileAccessConverter implements AttributeConverter { @Override - public Short convertToDatabaseColumn(FileAccess[] attribute) { + public Short convertToDatabaseColumn(final FileAccess[] attribute) { return attribute[0].getValue(); } @Override - public FileAccess[] convertToEntityAttribute(Short dbData) { + public FileAccess[] convertToEntityAttribute(final Short dbData) { if (dbData == null) return null; final List accesses = new ArrayList<>(); - for (FileAccess e : Arrays.asList(FileAccess.values())) { + for (final FileAccess e : Arrays.asList(FileAccess.values())) { if (e.getValue() == dbData) accesses.add(e); } diff --git a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/testobjects/OrganizationWithAudit.java b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/testobjects/OrganizationWithAudit.java index 571cfabcb..e3af05206 100644 --- a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/testobjects/OrganizationWithAudit.java +++ b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/testobjects/OrganizationWithAudit.java @@ -2,8 +2,8 @@ import java.time.LocalDateTime; -import javax.persistence.Column; -import javax.persistence.Id; +import jakarta.persistence.Column; +import jakarta.persistence.Id; import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmProtectedBy; import com.sap.olingo.jpa.processor.core.api.example.JPAExampleAuditable; diff --git a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/testobjects/TestFunctionActionConstructor.java b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/testobjects/TestFunctionActionConstructor.java index a6edfdc2d..f61e7e58a 100644 --- a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/testobjects/TestFunctionActionConstructor.java +++ b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/testobjects/TestFunctionActionConstructor.java @@ -2,7 +2,7 @@ import java.time.LocalDate; -import javax.persistence.EntityManager; +import jakarta.persistence.EntityManager; import com.sap.olingo.jpa.metadata.api.JPAHttpHeaderMap; import com.sap.olingo.jpa.metadata.api.JPARequestParameterMap; diff --git a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/testobjects/TestFunctionForFilter.java b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/testobjects/TestFunctionForFilter.java index 9df212ec6..9ac8edb0c 100644 --- a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/testobjects/TestFunctionForFilter.java +++ b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/testobjects/TestFunctionForFilter.java @@ -2,8 +2,8 @@ import java.time.LocalDate; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.From; +import jakarta.persistence.criteria.CriteriaBuilder; +import jakarta.persistence.criteria.From; import com.sap.olingo.jpa.metadata.api.JPAODataQueryContext; import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmFunction; diff --git a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/testobjects/TestFunctionParameter.java b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/testobjects/TestFunctionParameter.java index 5ad72d1af..da6b5347c 100644 --- a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/testobjects/TestFunctionParameter.java +++ b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/testobjects/TestFunctionParameter.java @@ -2,7 +2,7 @@ import java.util.Locale; -import javax.persistence.EntityManager; +import jakarta.persistence.EntityManager; import org.apache.olingo.commons.api.http.HttpStatusCode; import org.apache.olingo.server.api.ODataApplicationException; diff --git a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/testobjects/TestJavaActions.java b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/testobjects/TestJavaActions.java index 233e2d4b7..2016f3b0d 100644 --- a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/testobjects/TestJavaActions.java +++ b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/testobjects/TestJavaActions.java @@ -5,15 +5,15 @@ import java.util.Arrays; import java.util.List; -import javax.persistence.EntityManager; +import jakarta.persistence.EntityManager; import org.apache.olingo.commons.api.edm.geo.Geospatial.Dimension; import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmAction; import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmFunction.ReturnType; -import com.sap.olingo.jpa.metadata.core.edm.mapper.extension.ODataAction; import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmGeospatial; import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmParameter; +import com.sap.olingo.jpa.metadata.core.edm.mapper.extension.ODataAction; import com.sap.olingo.jpa.processor.core.testmodel.BusinessPartnerRole; import com.sap.olingo.jpa.processor.core.testmodel.ChangeInformation; import com.sap.olingo.jpa.processor.core.testmodel.Person; @@ -24,7 +24,7 @@ public class TestJavaActions implements ODataAction { @SuppressWarnings("unused") private final EntityManager em; - public TestJavaActions(EntityManager em) { + public TestJavaActions(final EntityManager em) { super(); this.em = em; assert em != null; @@ -33,14 +33,14 @@ public TestJavaActions(EntityManager em) { @EdmAction() public Integer unboundWithImport( - @EdmParameter(name = "A") short a, @EdmParameter(name = "B") int b) { + @EdmParameter(name = "A") final short a, @EdmParameter(name = "B") final int b) { return a + b; } @EdmAction(name = "BoundNoImport", isBound = true) public void boundNoImport( - @EdmParameter(name = "Person") Person person, - @EdmParameter(name = "A", precision = 34, scale = 10) BigDecimal a) { + @EdmParameter(name = "Person") final Person person, + @EdmParameter(name = "A", precision = 34, scale = 10) final BigDecimal a) { // Do nothing } @@ -51,13 +51,13 @@ public BigDecimal unboundReturnFacetNoParameter() { @EdmAction(returnType = @ReturnType(isNullable = false, precision = 20, scale = 5)) public BigDecimal unboundReturnFacet( - @EdmParameter(name = "A") short a, @EdmParameter(name = "B") int b) { + @EdmParameter(name = "A") final short a, @EdmParameter(name = "B") final int b) { return new BigDecimal(a).add(new BigDecimal(b)); } @EdmAction(isBound = true, entitySetPath = "Person/Roles") public BusinessPartnerRole boundWithEntitySetPath( - @EdmParameter(name = "Person") Person person) { + @EdmParameter(name = "Person") final Person person) { return null; } @@ -78,14 +78,14 @@ public List returnCollection() { @EdmAction(returnType = @ReturnType(type = ChangeInformation.class)) public List returnEmbeddableCollection() { - return Arrays.asList(new ChangeInformation[] { new ChangeInformation() }); + return Arrays.asList(new ChangeInformation()); } @EdmAction(returnType = @ReturnType(maxLength = 60, srid = @EdmGeospatial(dimension = Dimension.GEOGRAPHY, srid = "4326"))) public String calculateLocation( @EdmParameter(name = "String", maxLength = 100, - srid = @EdmGeospatial(dimension = Dimension.GEOGRAPHY, srid = "4326")) String a) { + srid = @EdmGeospatial(dimension = Dimension.GEOGRAPHY, srid = "4326")) final String a) { return ""; } diff --git a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/testobjects/ThreeParameterTransientPropertyConverter.java b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/testobjects/ThreeParameterTransientPropertyConverter.java index 4ca528026..bb164e6e2 100644 --- a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/testobjects/ThreeParameterTransientPropertyConverter.java +++ b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/testobjects/ThreeParameterTransientPropertyConverter.java @@ -3,7 +3,7 @@ */ package com.sap.olingo.jpa.processor.core.testobjects; -import javax.persistence.EntityManager; +import jakarta.persistence.EntityManager; import com.sap.olingo.jpa.metadata.api.JPAHttpHeaderMap; import com.sap.olingo.jpa.metadata.api.JPARequestParameterMap; diff --git a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/testobjects/TwoParameterTransientPropertyConverter.java b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/testobjects/TwoParameterTransientPropertyConverter.java index ec84b143e..40663d1de 100644 --- a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/testobjects/TwoParameterTransientPropertyConverter.java +++ b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/testobjects/TwoParameterTransientPropertyConverter.java @@ -6,7 +6,7 @@ import java.util.List; import java.util.Map; -import javax.persistence.EntityManager; +import jakarta.persistence.EntityManager; import com.sap.olingo.jpa.metadata.api.JPAHttpHeaderMap; import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmTransientPropertyCalculator; diff --git a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/util/AbstractWatchDogTest.java b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/util/AbstractWatchDogTest.java index c93f6c864..ae7a299a8 100644 --- a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/util/AbstractWatchDogTest.java +++ b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/util/AbstractWatchDogTest.java @@ -5,7 +5,6 @@ import java.util.Arrays; import java.util.List; -import java.util.stream.Collectors; import org.apache.olingo.commons.api.edm.provider.annotation.CsdlCollection; import org.apache.olingo.commons.api.edm.provider.annotation.CsdlConstantExpression; @@ -54,6 +53,6 @@ protected static List asExpression(final List paths) { .stream() .map(string -> createAnnotationNavigationPath(string)) .map(path -> (CsdlExpression) path) - .collect(Collectors.toList()); + .toList(); } } diff --git a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/util/IntegrationTestHelper.java b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/util/IntegrationTestHelper.java index ae97a50b8..f33f9a2ed 100644 --- a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/util/IntegrationTestHelper.java +++ b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/util/IntegrationTestHelper.java @@ -20,15 +20,16 @@ import java.util.Optional; import javax.annotation.Nonnull; -import javax.persistence.EntityManager; -import javax.persistence.EntityManagerFactory; -import javax.servlet.ServletOutputStream; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; import javax.sql.DataSource; +import jakarta.persistence.EntityManager; +import jakarta.persistence.EntityManagerFactory; +import jakarta.servlet.ServletOutputStream; +import jakarta.servlet.WriteListener; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; + import org.apache.commons.lang3.ArrayUtils; -import org.apache.olingo.commons.api.edmx.EdmxReference; import org.apache.olingo.commons.api.ex.ODataException; import org.apache.olingo.commons.api.http.HttpMethod; import org.apache.olingo.server.api.OData; @@ -55,6 +56,8 @@ import com.sap.olingo.jpa.processor.core.api.JPAODataRequestContext; import com.sap.olingo.jpa.processor.core.api.JPAODataRequestProcessor; import com.sap.olingo.jpa.processor.core.api.JPAODataSessionContextAccess; +import com.sap.olingo.jpa.processor.core.api.mapper.JakartaRequestMapper; +import com.sap.olingo.jpa.processor.core.api.mapper.JakartaResponseMapper; import com.sap.olingo.jpa.processor.core.processor.JPAODataInternalRequestContext; public class IntegrationTestHelper { @@ -159,7 +162,7 @@ public IntegrationTestHelper(final EntityManagerFactory localEmf, final DataSour pagingProvider, annotationsProvider, functionPackage); final ODataHttpHandler handler = odata.createHandler(odata.createServiceMetadata(sessionContext.getEdmProvider(), - new ArrayList())); + new ArrayList<>())); final JPAODataRequestContext externalContext = mock(JPAODataRequestContext.class); when(externalContext.getEntityManager()).thenReturn(em); @@ -172,7 +175,7 @@ public IntegrationTestHelper(final EntityManagerFactory localEmf, final DataSour handler.register(new JPAODataRequestProcessor(sessionContext, requestContext)); handler.register(new JPAODataBatchProcessor(sessionContext, requestContext)); - handler.process(request, response); + handler.process(new JakartaRequestMapper(request), new JakartaResponseMapper(response)); } @@ -375,6 +378,16 @@ public Iterator getBuffer() { public int getSize() { return buffer.size(); } + + @Override + public boolean isReady() { + return true; + } + + @Override + public void setWriteListener(final WriteListener writeListener) { + + } } // diff --git a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/util/TestBase.java b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/util/TestBase.java index 8f09d3123..30da97fa5 100644 --- a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/util/TestBase.java +++ b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/util/TestBase.java @@ -5,9 +5,10 @@ import java.util.List; import java.util.Map; -import javax.persistence.EntityManagerFactory; import javax.sql.DataSource; +import jakarta.persistence.EntityManagerFactory; + import org.apache.olingo.commons.api.ex.ODataException; import org.junit.jupiter.api.BeforeAll; @@ -25,12 +26,12 @@ public class TestBase { protected TestHelper helper; protected Map> headers; protected static JPAEdmNameBuilder nameBuilder; - protected static DataSource ds; + protected static DataSource dataSource; @BeforeAll public static void setupClass() throws ODataJPAModelException { - ds = DataSourceHelper.createDataSource(DataSourceHelper.DB_H2); - emf = JPAEntityManagerFactory.getEntityManagerFactory(PUNIT_NAME, ds); + dataSource = DataSourceHelper.createDataSource(DataSourceHelper.DB_H2); + emf = JPAEntityManagerFactory.getEntityManagerFactory(PUNIT_NAME, dataSource); nameBuilder = new JPADefaultEdmNameBuilder(PUNIT_NAME); } diff --git a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/util/TestGroupBase.java b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/util/TestGroupBase.java index e838300d8..ab1ff0ba5 100644 --- a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/util/TestGroupBase.java +++ b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/util/TestGroupBase.java @@ -7,10 +7,10 @@ import java.util.HashMap; import java.util.List; -import javax.persistence.criteria.From; -import javax.persistence.criteria.Join; -import javax.persistence.criteria.JoinType; -import javax.persistence.criteria.Root; +import jakarta.persistence.criteria.From; +import jakarta.persistence.criteria.Join; +import jakarta.persistence.criteria.JoinType; +import jakarta.persistence.criteria.Root; import org.apache.olingo.commons.api.edm.EdmEntitySet; import org.apache.olingo.commons.api.edm.EdmEntityType; @@ -54,7 +54,8 @@ public void setup() throws ODataException, ODataJPAIllegalAccessException { nameBuilder = new JPADefaultEdmNameBuilder(PUNIT_NAME); jpaEntityType = helper.getJPAEntityType("BusinessPartnerWithGroupss"); createHeaders(); - context = new JPAODataContextAccessDouble(new JPAEdmProvider(PUNIT_NAME, emf, null, TestBase.enumPackages), ds, + context = new JPAODataContextAccessDouble(new JPAEdmProvider(PUNIT_NAME, emf, null, TestBase.enumPackages), + dataSource, null, null); final JPAODataRequestContext externalContext = mock(JPAODataRequestContext.class); when(externalContext.getEntityManager()).thenReturn(emf.createEntityManager()); diff --git a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/util/TestHelper.java b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/util/TestHelper.java index 9f105f26b..153cf6876 100644 --- a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/util/TestHelper.java +++ b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/util/TestHelper.java @@ -3,13 +3,13 @@ import java.lang.reflect.AnnotatedElement; import java.util.Optional; -import javax.persistence.EntityManagerFactory; -import javax.persistence.metamodel.Attribute; -import javax.persistence.metamodel.EmbeddableType; -import javax.persistence.metamodel.EntityType; -import javax.persistence.metamodel.ManagedType; -import javax.persistence.metamodel.Metamodel; -import javax.persistence.metamodel.SingularAttribute; +import jakarta.persistence.EntityManagerFactory; +import jakarta.persistence.metamodel.Attribute; +import jakarta.persistence.metamodel.EmbeddableType; +import jakarta.persistence.metamodel.EntityType; +import jakarta.persistence.metamodel.ManagedType; +import jakarta.persistence.metamodel.Metamodel; +import jakarta.persistence.metamodel.SingularAttribute; import org.apache.olingo.commons.api.ex.ODataException; @@ -51,28 +51,28 @@ public JPAEntityType getJPAEntityType(final Class clazz) throws ODataJPAModel return sd.getEntity(clazz); } - public JPAAssociationPath getJPAAssociationPath(final String entitySetName, final String attributeExtName) + public JPAAssociationPath getJPAAssociationPath(final String entitySetName, final String attributeExternalName) throws ODataJPAModelException { final JPAEntityType jpaEntity = sd.getEntity(entitySetName); - return jpaEntity.getAssociationPath(attributeExtName); + return jpaEntity.getAssociationPath(attributeExternalName); } - public JPAAssociationPath getJPAAssociationPath(final Class clazz, final String attributeExtName) + public JPAAssociationPath getJPAAssociationPath(final Class clazz, final String attributeExternalName) throws ODataJPAModelException { final JPAEntityType jpaEntity = sd.getEntity(clazz); - return jpaEntity.getAssociationPath(attributeExtName); + return jpaEntity.getAssociationPath(attributeExternalName); } - public JPAAttribute getJPAAssociation(final String entitySetName, final String attributeIntName) + public JPAAttribute getJPAAssociation(final String entitySetName, final String attributeInternalName) throws ODataJPAModelException { final JPAEntityType jpaEntity = sd.getEntity(entitySetName); - return jpaEntity.getAssociation(attributeIntName); + return jpaEntity.getAssociation(attributeInternalName); } - public Optional getJPAAttribute(final String entitySetName, final String attributeIntName) + public Optional getJPAAttribute(final String entitySetName, final String attributeInternalName) throws ODataJPAModelException { final JPAEntityType jpaEntity = sd.getEntity(entitySetName); - return jpaEntity.getAttribute(attributeIntName); + return jpaEntity.getAttribute(attributeInternalName); } public EdmFunction getStoredProcedure(final EntityType jpaEntityType, final String string) { diff --git a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/util/TestQueryBase.java b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/util/TestQueryBase.java index c4980df94..26658fbcc 100644 --- a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/util/TestQueryBase.java +++ b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/util/TestQueryBase.java @@ -7,10 +7,10 @@ import java.util.HashMap; import java.util.List; -import javax.persistence.criteria.From; -import javax.persistence.criteria.Join; -import javax.persistence.criteria.JoinType; -import javax.persistence.criteria.Root; +import jakarta.persistence.criteria.From; +import jakarta.persistence.criteria.Join; +import jakarta.persistence.criteria.JoinType; +import jakarta.persistence.criteria.Root; import org.apache.olingo.commons.api.edm.EdmEntitySet; import org.apache.olingo.commons.api.edm.EdmEntityType; @@ -55,7 +55,8 @@ public void setup() throws ODataException, ODataJPAIllegalAccessException { nameBuilder = new JPADefaultEdmNameBuilder(PUNIT_NAME); jpaEntityType = helper.getJPAEntityType("BusinessPartners"); createHeaders(); - context = new JPAODataContextAccessDouble(new JPAEdmProvider(PUNIT_NAME, emf, null, TestBase.enumPackages), ds, + context = new JPAODataContextAccessDouble(new JPAEdmProvider(PUNIT_NAME, emf, null, TestBase.enumPackages), + dataSource, null, null); externalContext = mock(JPAODataRequestContext.class); when(externalContext.getEntityManager()).thenReturn(emf.createEntityManager()); diff --git a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/util/TupleDouble.java b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/util/TupleDouble.java index f259a827d..d3a6d82de 100644 --- a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/util/TupleDouble.java +++ b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/util/TupleDouble.java @@ -4,8 +4,8 @@ import java.util.List; import java.util.Map; -import javax.persistence.Tuple; -import javax.persistence.TupleElement; +import jakarta.persistence.Tuple; +import jakarta.persistence.TupleElement; public class TupleDouble implements Tuple { public final Map elementMap; @@ -21,37 +21,37 @@ public X get(final TupleElement tupleElement) { } @Override - public Object get(String alias) { + public Object get(final String alias) { return elementMap.get(alias); } @Override - public Object get(int i) { + public Object get(final int i) { return null; } @Override - public X get(String alias, Class type) { + public X get(final String alias, final Class type) { return null; } @Override - public X get(int i, Class type) { + public X get(final int i, final Class type) { return null; } @Override public List> getElements() { - List> elementList = new ArrayList<>(); - for (String alias : elementMap.keySet()) + final List> elementList = new ArrayList<>(); + for (final String alias : elementMap.keySet()) elementList.add(new TupleElementDouble(alias, elementMap.get(alias))); return elementList; } @Override public Object[] toArray() { - List elementList = new ArrayList<>(); - for (String alias : elementMap.keySet()) + final List elementList = new ArrayList<>(); + for (final String alias : elementMap.keySet()) elementList.add(elementMap.get(alias)); return elementList.toArray(); } diff --git a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/util/TupleElementDouble.java b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/util/TupleElementDouble.java index b724ce4b5..25ab0f0fb 100644 --- a/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/util/TupleElementDouble.java +++ b/jpa/odata-jpa-processor/src/test/java/com/sap/olingo/jpa/processor/core/util/TupleElementDouble.java @@ -1,13 +1,13 @@ package com.sap.olingo.jpa.processor.core.util; -import javax.persistence.TupleElement; +import jakarta.persistence.TupleElement; public class TupleElementDouble implements TupleElement { // alias private final String alias; private final Object value; - public TupleElementDouble(String alias, Object value) { + public TupleElementDouble(final String alias, final Object value) { super(); this.alias = alias; this.value = value; diff --git a/jpa/odata-jpa-spring-support/pom.xml b/jpa/odata-jpa-spring-support/pom.xml index 94c7080d3..dbc5f794d 100644 --- a/jpa/odata-jpa-spring-support/pom.xml +++ b/jpa/odata-jpa-spring-support/pom.xml @@ -5,7 +5,7 @@ com.sap.olingo odata-jpa - 1.1.1 + 2.0.0 odata-jpa-spring-support diff --git a/jpa/odata-jpa-test/.settings/org.eclipse.jdt.core.prefs b/jpa/odata-jpa-test/.settings/org.eclipse.jdt.core.prefs index 4b2b852b9..df8166838 100644 --- a/jpa/odata-jpa-test/.settings/org.eclipse.jdt.core.prefs +++ b/jpa/odata-jpa-test/.settings/org.eclipse.jdt.core.prefs @@ -1,12 +1,9 @@ -=\=\=\=\=\=\= -<<<<<<<=HEAD ->>>>>>>=odata-v4-jpa-processor/feature/release-1.0.3 eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.compliance=17 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate @@ -17,4 +14,4 @@ org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning org.eclipse.jdt.core.compiler.processAnnotations=disabled org.eclipse.jdt.core.compiler.release=disabled -org.eclipse.jdt.core.compiler.source=1.8 +org.eclipse.jdt.core.compiler.source=17 diff --git a/jpa/odata-jpa-test/.settings/org.eclipse.wst.common.project.facet.core.xml b/jpa/odata-jpa-test/.settings/org.eclipse.wst.common.project.facet.core.xml index bfd553c1e..25ef3837d 100644 --- a/jpa/odata-jpa-test/.settings/org.eclipse.wst.common.project.facet.core.xml +++ b/jpa/odata-jpa-test/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -1,7 +1,5 @@ + - - - diff --git a/jpa/odata-jpa-test/pom.xml b/jpa/odata-jpa-test/pom.xml index 9d13c960a..82e29b20f 100644 --- a/jpa/odata-jpa-test/pom.xml +++ b/jpa/odata-jpa-test/pom.xml @@ -4,30 +4,30 @@ com.sap.olingo odata-jpa - 1.1.1 + 2.0.0 odata-jpa-test odata-jpa-test https://github.com/SAP/olingo-jpa-processor-v4 UTF-8 - 2.5 + 6.0.0 org.junit.jupiter junit-jupiter - 5.9.1 + ${junit.version} org.junit.platform junit-platform-launcher - 1.9.1 + ${junit-platform.version} org.mockito mockito-core - 3.6.0 + ${mockito.version} com.tngtech.archunit @@ -45,15 +45,14 @@ ${project.version} - org.eclipse.persistence - javax.persistence + jakarta.persistence + jakarta.persistence-api ${jpa.version} org.hsqldb hsqldb - 2.7.1 - jdk8 + 2.7.2 com.h2database @@ -63,7 +62,7 @@ org.flywaydb flyway-core - 9.16.3 + 9.22.0 com.fasterxml.jackson.core @@ -76,8 +75,8 @@ 3.3.2 - javax.servlet - servlet-api + jakarta.servlet + jakarta.servlet-api ${javax.version} @@ -101,7 +100,7 @@ org.eclipse.persistence org.eclipse.persistence.jpa - 2.7.1 + 4.0.1 org.eclipse.persistence diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/errormodel/AdministrativeInformation.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/errormodel/AdministrativeInformation.java index a6a4e3e59..4994e4df9 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/errormodel/AdministrativeInformation.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/errormodel/AdministrativeInformation.java @@ -3,12 +3,12 @@ import java.sql.Timestamp; import java.util.Date; -import javax.persistence.AttributeOverride; -import javax.persistence.Column; -import javax.persistence.Embeddable; -import javax.persistence.Embedded; -import javax.persistence.PrePersist; -import javax.persistence.PreUpdate; +import jakarta.persistence.AttributeOverride; +import jakarta.persistence.Column; +import jakarta.persistence.Embeddable; +import jakarta.persistence.Embedded; +import jakarta.persistence.PrePersist; +import jakarta.persistence.PreUpdate; @Embeddable public class AdministrativeInformation { diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/errormodel/ChangeInformation.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/errormodel/ChangeInformation.java index 077ee2331..cf88dc1b0 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/errormodel/ChangeInformation.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/errormodel/ChangeInformation.java @@ -2,10 +2,10 @@ import java.util.Date; -import javax.persistence.Column; -import javax.persistence.Embeddable; -import javax.persistence.Temporal; -import javax.persistence.TemporalType; +import jakarta.persistence.Column; +import jakarta.persistence.Embeddable; +import jakarta.persistence.Temporal; +import jakarta.persistence.TemporalType; @Embeddable public class ChangeInformation { diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/errormodel/CollectionAttributeProtected.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/errormodel/CollectionAttributeProtected.java index 31c391d47..dfea5377d 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/errormodel/CollectionAttributeProtected.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/errormodel/CollectionAttributeProtected.java @@ -3,15 +3,15 @@ import java.util.ArrayList; import java.util.List; -import javax.persistence.CollectionTable; -import javax.persistence.Column; -import javax.persistence.DiscriminatorValue; -import javax.persistence.ElementCollection; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.Version; +import jakarta.persistence.CollectionTable; +import jakarta.persistence.Column; +import jakarta.persistence.DiscriminatorValue; +import jakarta.persistence.ElementCollection; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.Version; import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmProtectedBy; import com.sap.olingo.jpa.processor.core.testmodel.InhouseAddress; diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/errormodel/ComplexProtectedNoPath.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/errormodel/ComplexProtectedNoPath.java index c6564895b..9a26b1f59 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/errormodel/ComplexProtectedNoPath.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/errormodel/ComplexProtectedNoPath.java @@ -1,11 +1,11 @@ package com.sap.olingo.jpa.processor.core.errormodel; -import javax.persistence.Column; -import javax.persistence.Embedded; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.Table; -import javax.persistence.Version; +import jakarta.persistence.Column; +import jakarta.persistence.Embedded; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.Table; +import jakarta.persistence.Version; import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmProtectedBy; @@ -23,7 +23,7 @@ public class ComplexProtectedNoPath { @Embedded @EdmProtectedBy(name = "UserId") - private AdministrativeInformation administrativeInformation = new AdministrativeInformation(); + private final AdministrativeInformation administrativeInformation = new AdministrativeInformation(); @Override public int hashCode() { @@ -34,11 +34,11 @@ public int hashCode() { } @Override - public boolean equals(Object obj) { + public boolean equals(final Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; - ComplexProtectedNoPath other = (ComplexProtectedNoPath) obj; + final ComplexProtectedNoPath other = (ComplexProtectedNoPath) obj; if (iD == null) { if (other.iD != null) return false; } else if (!iD.equals(other.iD)) return false; @@ -53,11 +53,11 @@ public long getETag() { return eTag; } - public void setID(String iD) { + public void setID(final String iD) { this.iD = iD; } - public void setETag(long eTag) { + public void setETag(final long eTag) { this.eTag = eTag; } diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/errormodel/ComplexProtectedWrongPath.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/errormodel/ComplexProtectedWrongPath.java index 6ec14dc3e..2c7ca9388 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/errormodel/ComplexProtectedWrongPath.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/errormodel/ComplexProtectedWrongPath.java @@ -1,11 +1,11 @@ package com.sap.olingo.jpa.processor.core.errormodel; -import javax.persistence.Column; -import javax.persistence.Embedded; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.Table; -import javax.persistence.Version; +import jakarta.persistence.Column; +import jakarta.persistence.Embedded; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.Table; +import jakarta.persistence.Version; import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmProtectedBy; @@ -23,7 +23,7 @@ public class ComplexProtectedWrongPath { @Embedded @EdmProtectedBy(name = "UserId", path = "created/wrong") - private AdministrativeInformation administrativeInformation = new AdministrativeInformation(); + private final AdministrativeInformation administrativeInformation = new AdministrativeInformation(); @Override public int hashCode() { @@ -34,11 +34,11 @@ public int hashCode() { } @Override - public boolean equals(Object obj) { + public boolean equals(final Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; - ComplexProtectedWrongPath other = (ComplexProtectedWrongPath) obj; + final ComplexProtectedWrongPath other = (ComplexProtectedWrongPath) obj; if (iD == null) { if (other.iD != null) return false; } else if (!iD.equals(other.iD)) return false; @@ -49,7 +49,7 @@ public String getID() { return iD; } - public void setID(String iD) { + public void setID(final String iD) { this.iD = iD; } @@ -57,7 +57,7 @@ public long getETag() { return eTag; } - public void setETag(long eTag) { + public void setETag(final long eTag) { this.eTag = eTag; } } diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/errormodel/CompoundKey.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/errormodel/CompoundKey.java index a353ffdb9..aaa22f1cc 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/errormodel/CompoundKey.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/errormodel/CompoundKey.java @@ -3,8 +3,8 @@ import java.io.Serializable; import java.util.Objects; -import javax.persistence.Column; -import javax.persistence.Embeddable; +import jakarta.persistence.Column; +import jakarta.persistence.Embeddable; @Embeddable public class CompoundKey implements Serializable { diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/errormodel/DummyPropertyCalculator.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/errormodel/DummyPropertyCalculator.java index b023675e6..32bd9a658 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/errormodel/DummyPropertyCalculator.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/errormodel/DummyPropertyCalculator.java @@ -1,13 +1,13 @@ /** - * + * */ package com.sap.olingo.jpa.processor.core.errormodel; import java.util.Arrays; import java.util.List; -import javax.persistence.EntityManager; -import javax.persistence.Tuple; +import jakarta.persistence.EntityManager; +import jakarta.persistence.Tuple; import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmTransientPropertyCalculator; @@ -16,7 +16,7 @@ * Created: 17.03.2020 * */ -public class DummyPropertyCalculator implements EdmTransientPropertyCalculator { +public class DummyPropertyCalculator implements EdmTransientPropertyCalculator { private final EntityManager em; @@ -30,8 +30,8 @@ public EntityManager getEntityManager() { } @Override - public List calculateCollectionProperty(Tuple row) { - return Arrays.asList("Hello","World"); + public List calculateCollectionProperty(final Tuple row) { + return Arrays.asList("Hello", "World"); } } diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/errormodel/EmbeddedKeyPartOfGroup.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/errormodel/EmbeddedKeyPartOfGroup.java index d6e44a7a8..72cf3d007 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/errormodel/EmbeddedKeyPartOfGroup.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/errormodel/EmbeddedKeyPartOfGroup.java @@ -1,12 +1,12 @@ /** - * + * */ package com.sap.olingo.jpa.processor.core.errormodel; -import javax.persistence.Column; -import javax.persistence.EmbeddedId; -import javax.persistence.Entity; -import javax.persistence.Version; +import jakarta.persistence.Column; +import jakarta.persistence.EmbeddedId; +import jakarta.persistence.Entity; +import jakarta.persistence.Version; import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmVisibleFor; import com.sap.olingo.jpa.processor.core.testmodel.CountryKey; diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/errormodel/KeyPartOfGroup.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/errormodel/KeyPartOfGroup.java index eced2f024..daa61639d 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/errormodel/KeyPartOfGroup.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/errormodel/KeyPartOfGroup.java @@ -5,10 +5,10 @@ import java.util.Objects; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.Version; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.Version; import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmVisibleFor; diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/errormodel/MandatoryPartOfGroup.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/errormodel/MandatoryPartOfGroup.java index c2669dbeb..ac37398e9 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/errormodel/MandatoryPartOfGroup.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/errormodel/MandatoryPartOfGroup.java @@ -1,20 +1,20 @@ /** - * + * */ package com.sap.olingo.jpa.processor.core.errormodel; import java.util.List; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.JoinTable; -import javax.persistence.ManyToMany; -import javax.persistence.Version; - import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmVisibleFor; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.JoinTable; +import jakarta.persistence.ManyToMany; +import jakarta.persistence.Version; + /** * @author Oliver Grande * Created: 29.06.2019 diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/errormodel/MissingCardinalityAnnotation.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/errormodel/MissingCardinalityAnnotation.java index b65786f95..c886b2642 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/errormodel/MissingCardinalityAnnotation.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/errormodel/MissingCardinalityAnnotation.java @@ -2,11 +2,11 @@ import java.util.List; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.JoinTable; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.JoinTable; @Entity() public class MissingCardinalityAnnotation { @@ -24,4 +24,3 @@ public class MissingCardinalityAnnotation { private Team oneTeam; } - diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/errormodel/NavigationAttributeProtected.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/errormodel/NavigationAttributeProtected.java index 7141f7585..62c657882 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/errormodel/NavigationAttributeProtected.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/errormodel/NavigationAttributeProtected.java @@ -2,14 +2,14 @@ import java.util.List; -import javax.persistence.Column; -import javax.persistence.DiscriminatorValue; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.JoinTable; -import javax.persistence.ManyToMany; -import javax.persistence.Version; +import jakarta.persistence.Column; +import jakarta.persistence.DiscriminatorValue; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.JoinTable; +import jakarta.persistence.ManyToMany; +import jakarta.persistence.Version; import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmProtectedBy; @@ -53,7 +53,7 @@ public boolean equals(final Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; - NavigationAttributeProtected other = (NavigationAttributeProtected) obj; + final NavigationAttributeProtected other = (NavigationAttributeProtected) obj; if (iD == null) { if (other.iD != null) return false; } else if (!iD.equals(other.iD)) return false; diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/errormodel/NavigationPropertyPartOfGroup.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/errormodel/NavigationPropertyPartOfGroup.java index 4a8bfdd2e..1f1cccb70 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/errormodel/NavigationPropertyPartOfGroup.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/errormodel/NavigationPropertyPartOfGroup.java @@ -1,17 +1,17 @@ /** - * + * */ package com.sap.olingo.jpa.processor.core.errormodel; import java.util.List; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.JoinTable; -import javax.persistence.ManyToMany; -import javax.persistence.Version; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.JoinTable; +import jakarta.persistence.ManyToMany; +import jakarta.persistence.Version; import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmVisibleFor; diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/errormodel/PersonDeepCollectionProtected.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/errormodel/PersonDeepCollectionProtected.java index f0dad8b43..8974c5457 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/errormodel/PersonDeepCollectionProtected.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/errormodel/PersonDeepCollectionProtected.java @@ -3,14 +3,14 @@ import java.util.List; import java.util.Objects; -import javax.persistence.CollectionTable; -import javax.persistence.Column; -import javax.persistence.ElementCollection; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.Version; +import jakarta.persistence.CollectionTable; +import jakarta.persistence.Column; +import jakarta.persistence.ElementCollection; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.Version; import com.sap.olingo.jpa.processor.core.testmodel.AddressDeepProtected; diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/errormodel/SingletonAsEntitySet.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/errormodel/SingletonAsEntitySet.java deleted file mode 100644 index e9580c84c..000000000 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/errormodel/SingletonAsEntitySet.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.sap.olingo.jpa.processor.core.errormodel; - -import static com.sap.olingo.jpa.metadata.core.edm.annotation.EdmTopLevelElementRepresentation.AS_SINGLETON; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.Table; - -import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmAsEntitySet; -import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmEntityType; - -@Table(schema = "\"OLINGO\"", name = "\"GeneralSettings\"") -@Entity(name = "SingletonAsEntitySet") -@EdmEntityType(as = AS_SINGLETON) -@EdmAsEntitySet -public class SingletonAsEntitySet { - @Id - @Column(name = "\"Name\"", length = 255, insertable = true, updatable = false) - private String name; -} diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/errormodel/Team.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/errormodel/Team.java index fe7d10454..76d3ec1e8 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/errormodel/Team.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/errormodel/Team.java @@ -3,11 +3,11 @@ import java.util.List; import java.util.Objects; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.ManyToMany; -import javax.persistence.Table; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.ManyToMany; +import jakarta.persistence.Table; @Entity(name = "ErrorTeam") @Table(schema = "\"OLINGO\"", name = "\"Team\"") diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/errormodel/TeamWithTransientCalculatorConstructorError.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/errormodel/TeamWithTransientCalculatorConstructorError.java index d054cd230..a6430bc1e 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/errormodel/TeamWithTransientCalculatorConstructorError.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/errormodel/TeamWithTransientCalculatorConstructorError.java @@ -1,9 +1,9 @@ package com.sap.olingo.jpa.processor.core.errormodel; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.Table; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.Table; import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmTransient; diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/errormodel/TeamWithTransientCalculatorError.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/errormodel/TeamWithTransientCalculatorError.java index b79ebf9a2..dbdd3e953 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/errormodel/TeamWithTransientCalculatorError.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/errormodel/TeamWithTransientCalculatorError.java @@ -1,9 +1,9 @@ package com.sap.olingo.jpa.processor.core.errormodel; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.Table; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.Table; import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmTransient; diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/errormodel/TeamWithTransientEmbeddableKey.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/errormodel/TeamWithTransientEmbeddableKey.java index 91cb81e03..09d4e1f05 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/errormodel/TeamWithTransientEmbeddableKey.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/errormodel/TeamWithTransientEmbeddableKey.java @@ -1,8 +1,8 @@ package com.sap.olingo.jpa.processor.core.errormodel; -import javax.persistence.EmbeddedId; -import javax.persistence.Entity; -import javax.persistence.Table; +import jakarta.persistence.EmbeddedId; +import jakarta.persistence.Entity; +import jakarta.persistence.Table; import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmTransient; diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/errormodel/TeamWithTransientError.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/errormodel/TeamWithTransientError.java index 95ad4d650..cd1e493e6 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/errormodel/TeamWithTransientError.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/errormodel/TeamWithTransientError.java @@ -1,9 +1,9 @@ package com.sap.olingo.jpa.processor.core.errormodel; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.Table; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.Table; import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmTransient; diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/errormodel/TeamWithTransientKey.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/errormodel/TeamWithTransientKey.java index 439918797..ee06bacd3 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/errormodel/TeamWithTransientKey.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/errormodel/TeamWithTransientKey.java @@ -2,12 +2,12 @@ import java.util.Objects; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.IdClass; -import javax.persistence.Table; -import javax.persistence.Transient; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.IdClass; +import jakarta.persistence.Table; +import jakarta.persistence.Transient; import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmTransient; diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/errormodel/TransientPropertyCalculatorTwoConstructors.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/errormodel/TransientPropertyCalculatorTwoConstructors.java index 21611ced6..03e707296 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/errormodel/TransientPropertyCalculatorTwoConstructors.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/errormodel/TransientPropertyCalculatorTwoConstructors.java @@ -1,9 +1,9 @@ -/** - * +/** + * */ package com.sap.olingo.jpa.processor.core.errormodel; -import javax.persistence.EntityManager; +import jakarta.persistence.EntityManager; import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmTransientPropertyCalculator; diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/errormodel/TransientPropertyCalculatorWrongConstructor.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/errormodel/TransientPropertyCalculatorWrongConstructor.java index 2e269e2b0..0446130f9 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/errormodel/TransientPropertyCalculatorWrongConstructor.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/errormodel/TransientPropertyCalculatorWrongConstructor.java @@ -2,8 +2,8 @@ * */ package com.sap.olingo.jpa.processor.core.errormodel; - -import javax.persistence.EntityManager; + +import jakarta.persistence.EntityManager; import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmTransientPropertyCalculator; diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/AbstractGroup.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/AbstractGroup.java index 3ce02c799..e7a6c7d0c 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/AbstractGroup.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/AbstractGroup.java @@ -2,9 +2,9 @@ import java.util.Objects; -import javax.persistence.Column; -import javax.persistence.Id; -import javax.persistence.MappedSuperclass; +import jakarta.persistence.Column; +import jakarta.persistence.Id; +import jakarta.persistence.MappedSuperclass; @MappedSuperclass public abstract class AbstractGroup { diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/AccessRightsConverter.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/AccessRightsConverter.java index bca04020a..b66c2366b 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/AccessRightsConverter.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/AccessRightsConverter.java @@ -3,8 +3,8 @@ import java.util.ArrayList; import java.util.List; -import javax.persistence.AttributeConverter; -import javax.persistence.Converter; +import jakarta.persistence.AttributeConverter; +import jakarta.persistence.Converter; @Converter(autoApply = false) public class AccessRightsConverter implements AttributeConverter { diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/AddressDeepProtected.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/AddressDeepProtected.java index 1d7266177..0845c347d 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/AddressDeepProtected.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/AddressDeepProtected.java @@ -1,8 +1,8 @@ package com.sap.olingo.jpa.processor.core.testmodel; -import javax.persistence.Column; -import javax.persistence.Embeddable; -import javax.persistence.Embedded; +import jakarta.persistence.Column; +import jakarta.persistence.Embeddable; +import jakarta.persistence.Embedded; //Only for Unit Tests @Embeddable diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/AddressDeepThreeProtections.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/AddressDeepThreeProtections.java index 0a92820f9..0c3da6075 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/AddressDeepThreeProtections.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/AddressDeepThreeProtections.java @@ -1,8 +1,8 @@ package com.sap.olingo.jpa.processor.core.testmodel; -import javax.persistence.Column; -import javax.persistence.Embeddable; -import javax.persistence.Embedded; +import jakarta.persistence.Column; +import jakarta.persistence.Embeddable; +import jakarta.persistence.Embedded; import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmIgnore; diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/AdministrativeDivision.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/AdministrativeDivision.java index 5068c31a7..07fc20ab3 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/AdministrativeDivision.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/AdministrativeDivision.java @@ -3,20 +3,20 @@ import java.util.ArrayList; import java.util.List; -import javax.persistence.Access; -import javax.persistence.AccessType; -import javax.persistence.CascadeType; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.Id; -import javax.persistence.IdClass; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; -import javax.persistence.OneToMany; -import javax.persistence.PostPersist; -import javax.persistence.PostUpdate; -import javax.persistence.Table; +import jakarta.persistence.Access; +import jakarta.persistence.AccessType; +import jakarta.persistence.CascadeType; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.Id; +import jakarta.persistence.IdClass; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.OneToMany; +import jakarta.persistence.PostPersist; +import jakarta.persistence.PostUpdate; +import jakarta.persistence.Table; import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmFunction; import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmParameter; diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/AdministrativeDivisionDescription.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/AdministrativeDivisionDescription.java index 2a0daba6d..0c39b196b 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/AdministrativeDivisionDescription.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/AdministrativeDivisionDescription.java @@ -1,9 +1,9 @@ package com.sap.olingo.jpa.processor.core.testmodel; -import javax.persistence.Column; -import javax.persistence.EmbeddedId; -import javax.persistence.Entity; -import javax.persistence.Table; +import jakarta.persistence.Column; +import jakarta.persistence.EmbeddedId; +import jakarta.persistence.Entity; +import jakarta.persistence.Table; import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmSearchable; @@ -22,7 +22,7 @@ public String getName() { return name; } - public void setName(String name) { + public void setName(final String name) { this.name = name; } @@ -31,7 +31,7 @@ public AdministrativeDivisionDescriptionKey getKey() { return key; } - public void setKey(AdministrativeDivisionDescriptionKey key) { + public void setKey(final AdministrativeDivisionDescriptionKey key) { this.key = key; } } diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/AdministrativeDivisionDescriptionKey.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/AdministrativeDivisionDescriptionKey.java index f80113a86..3021cc689 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/AdministrativeDivisionDescriptionKey.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/AdministrativeDivisionDescriptionKey.java @@ -2,13 +2,13 @@ import java.io.Serializable; -import javax.persistence.Column; -import javax.persistence.Embeddable; +import jakarta.persistence.Column; +import jakarta.persistence.Embeddable; @Embeddable public class AdministrativeDivisionDescriptionKey implements Serializable { /** - * + * */ private static final long serialVersionUID = 4843041820527005995L; @@ -45,7 +45,7 @@ public String getCodePublisher() { return codePublisher; } - public void setCodePublisher(String codePublisher) { + public void setCodePublisher(final String codePublisher) { this.codePublisher = codePublisher; } @@ -53,7 +53,7 @@ public String getCodeID() { return codeID; } - public void setCodeID(String codeID) { + public void setCodeID(final String codeID) { this.codeID = codeID; } @@ -61,11 +61,11 @@ public String getDivisionCode() { return divisionCode; } - public void setDivisionCode(String divisionCode) { + public void setDivisionCode(final String divisionCode) { this.divisionCode = divisionCode; } - public void setLanguage(String language) { + public void setLanguage(final String language) { this.language = language; } @@ -81,11 +81,11 @@ public int hashCode() { } @Override - public boolean equals(Object obj) { // NOSONAR + public boolean equals(final Object obj) { // NOSONAR if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; - AdministrativeDivisionDescriptionKey other = (AdministrativeDivisionDescriptionKey) obj; + final AdministrativeDivisionDescriptionKey other = (AdministrativeDivisionDescriptionKey) obj; if (codeID == null) { if (other.codeID != null) return false; } else if (!codeID.equals(other.codeID)) return false; diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/AdministrativeDivisionKey.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/AdministrativeDivisionKey.java index 2b5733759..795e24034 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/AdministrativeDivisionKey.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/AdministrativeDivisionKey.java @@ -3,8 +3,8 @@ import java.io.Serializable; import java.util.Objects; -import javax.persistence.Column; -import javax.persistence.Id; +import jakarta.persistence.Column; +import jakarta.persistence.Id; public class AdministrativeDivisionKey implements Serializable, Comparable { @@ -23,7 +23,7 @@ public AdministrativeDivisionKey() { // Needed to be used as IdClass } - public AdministrativeDivisionKey(String codePublisher, String codeID, String divisionCode) { + public AdministrativeDivisionKey(final String codePublisher, final String codeID, final String divisionCode) { this.codePublisher = codePublisher; this.codeID = codeID; this.divisionCode = divisionCode; @@ -33,7 +33,7 @@ public String getCodePublisher() { return codePublisher; } - public void setCodePublisher(String codePublisher) { + public void setCodePublisher(final String codePublisher) { this.codePublisher = codePublisher; } @@ -41,7 +41,7 @@ public String getCodeID() { return codeID; } - public void setCodeID(String codeID) { + public void setCodeID(final String codeID) { this.codeID = codeID; } @@ -49,7 +49,7 @@ public String getDivisionCode() { return divisionCode; } - public void setDivisionCode(String divisionCode) { + public void setDivisionCode(final String divisionCode) { this.divisionCode = divisionCode; } @@ -79,11 +79,11 @@ public int compareTo(final AdministrativeDivisionKey o) { } @Override - public boolean equals(Object obj) { + public boolean equals(final Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; - AdministrativeDivisionKey other = (AdministrativeDivisionKey) obj; + final AdministrativeDivisionKey other = (AdministrativeDivisionKey) obj; if (codeID == null) { if (other.codeID != null) return false; } else if (!codeID.equals(other.codeID)) return false; diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/AdministrativeInformation.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/AdministrativeInformation.java index 25fec26bf..3fa52b04d 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/AdministrativeInformation.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/AdministrativeInformation.java @@ -3,14 +3,14 @@ import java.sql.Date; import java.time.LocalDate; -import javax.persistence.AssociationOverride; -import javax.persistence.AttributeOverride; -import javax.persistence.Column; -import javax.persistence.Embeddable; -import javax.persistence.Embedded; -import javax.persistence.JoinColumn; -import javax.persistence.PrePersist; -import javax.persistence.PreUpdate; +import jakarta.persistence.AssociationOverride; +import jakarta.persistence.AttributeOverride; +import jakarta.persistence.Column; +import jakarta.persistence.Embeddable; +import jakarta.persistence.Embedded; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.PrePersist; +import jakarta.persistence.PreUpdate; @Embeddable public class AdministrativeInformation { diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/AnnotationsParent.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/AnnotationsParent.java index 5886f186b..e6bf6803a 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/AnnotationsParent.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/AnnotationsParent.java @@ -3,16 +3,16 @@ import java.util.ArrayList; import java.util.List; -import javax.persistence.CascadeType; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.Id; -import javax.persistence.IdClass; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; -import javax.persistence.OneToMany; -import javax.persistence.Table; +import jakarta.persistence.CascadeType; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.Id; +import jakarta.persistence.IdClass; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.OneToMany; +import jakarta.persistence.Table; import com.sap.olingo.jpa.metadata.odata.v4.capabilities.terms.CountRestrictions; import com.sap.olingo.jpa.metadata.odata.v4.capabilities.terms.ExpandRestrictions; @@ -56,7 +56,7 @@ public class AnnotationsParent { private String alternativeCode; @ComputedDefaultValue @Column(name = "\"Area\"") // , precision = 34, scale = 0) - private final Integer area = 0; + private Integer area; @Column(name = "\"Population\"", precision = 34, scale = 0) private long population; diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/AnnotationsSingleton.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/AnnotationsSingleton.java index 2f9ed51a1..668c1f9a4 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/AnnotationsSingleton.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/AnnotationsSingleton.java @@ -4,15 +4,15 @@ import java.util.List; -import javax.persistence.CollectionTable; -import javax.persistence.Column; -import javax.persistence.ElementCollection; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.OneToMany; -import javax.persistence.Table; +import jakarta.persistence.CollectionTable; +import jakarta.persistence.Column; +import jakarta.persistence.ElementCollection; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.OneToMany; +import jakarta.persistence.Table; import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmEntityType; import com.sap.olingo.jpa.metadata.odata.v4.capabilities.terms.CountRestrictions; diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/AssociationOneToManySource.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/AssociationOneToManySource.java index d169a3d63..3fbbfa289 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/AssociationOneToManySource.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/AssociationOneToManySource.java @@ -2,12 +2,12 @@ import java.util.List; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.Id; -import javax.persistence.OneToMany; -import javax.persistence.Table; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.Id; +import jakarta.persistence.OneToMany; +import jakarta.persistence.Table; @Entity(name = "OneToManySource") @Table(schema = "\"OLINGO\"", name = "\"AssociationOneToOneSource\"") diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/AssociationOneToManyTarget.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/AssociationOneToManyTarget.java index 5aa117602..b48270cbf 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/AssociationOneToManyTarget.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/AssociationOneToManyTarget.java @@ -1,11 +1,11 @@ package com.sap.olingo.jpa.processor.core.testmodel; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.Id; -import javax.persistence.ManyToOne; -import javax.persistence.Table; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.Id; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Table; @Entity(name = "OneToManyTarget") @Table(schema = "\"OLINGO\"", name = "\"AssociationOneToManyTarget\"") diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/AssociationOneToOneSource.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/AssociationOneToOneSource.java index ae9b7dd10..db5ab4083 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/AssociationOneToOneSource.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/AssociationOneToOneSource.java @@ -1,12 +1,12 @@ package com.sap.olingo.jpa.processor.core.testmodel; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.OneToOne; -import javax.persistence.Table; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.OneToOne; +import jakarta.persistence.Table; @Entity(name = "AssociationOneToOneSource") @Table(schema = "\"OLINGO\"", name = "\"AssociationOneToOneSource\"") diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/AssociationOneToOneTarget.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/AssociationOneToOneTarget.java index e9c2fb324..e0eb96985 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/AssociationOneToOneTarget.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/AssociationOneToOneTarget.java @@ -1,11 +1,11 @@ package com.sap.olingo.jpa.processor.core.testmodel; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.Id; -import javax.persistence.OneToOne; -import javax.persistence.Table; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.Id; +import jakarta.persistence.OneToOne; +import jakarta.persistence.Table; @Entity(name = "AssociationOneToOneTarget") @Table(schema = "\"OLINGO\"", name = "\"AssociationOneToOneTarget\"") diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/BestOrganization.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/BestOrganization.java index e0de2afab..6332db2c3 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/BestOrganization.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/BestOrganization.java @@ -1,13 +1,14 @@ package com.sap.olingo.jpa.processor.core.testmodel; -import javax.persistence.DiscriminatorValue; -import javax.persistence.Entity; +import jakarta.persistence.DiscriminatorValue; +import jakarta.persistence.Entity; -import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmAsEntitySet; +import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmEntityType; +import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmTopLevelElementRepresentation; -//Problem with multi-level inheritance hierarchy Inheritance Type SINGLE_TABLE. Therefore inherit also from +//Problem with multi-level inheritance hierarchy Inheritance Type SINGLE_TABLE. Therefore inherit also from //Business Partner @Entity(name = "BestOrganization") @DiscriminatorValue(value = "2") -@EdmAsEntitySet +@EdmEntityType(as = EdmTopLevelElementRepresentation.AS_ENTITY_SET_ONLY) public class BestOrganization extends BusinessPartner {} diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/BusinessPartner.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/BusinessPartner.java index e0a941ac8..1bd44b976 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/BusinessPartner.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/BusinessPartner.java @@ -7,21 +7,21 @@ import java.util.ArrayList; import java.util.Collection; -import javax.persistence.AssociationOverride; -import javax.persistence.CascadeType; -import javax.persistence.Column; -import javax.persistence.Convert; -import javax.persistence.DiscriminatorColumn; -import javax.persistence.Embedded; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.Id; -import javax.persistence.Inheritance; -import javax.persistence.JoinColumn; -import javax.persistence.OneToMany; -import javax.persistence.PrePersist; -import javax.persistence.Table; -import javax.persistence.Version; +import jakarta.persistence.AssociationOverride; +import jakarta.persistence.CascadeType; +import jakarta.persistence.Column; +import jakarta.persistence.Convert; +import jakarta.persistence.DiscriminatorColumn; +import jakarta.persistence.Embedded; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.Id; +import jakarta.persistence.Inheritance; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.OneToMany; +import jakarta.persistence.PrePersist; +import jakarta.persistence.Table; +import jakarta.persistence.Version; import org.apache.olingo.commons.api.edm.provider.annotation.CsdlConstantExpression.ConstantExpressionType; diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/BusinessPartnerProtected.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/BusinessPartnerProtected.java index 1c24a0dc7..1a83f16e0 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/BusinessPartnerProtected.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/BusinessPartnerProtected.java @@ -3,19 +3,19 @@ import java.util.Collection; import java.util.List; -import javax.persistence.CascadeType; -import javax.persistence.Column; -import javax.persistence.DiscriminatorColumn; -import javax.persistence.Embedded; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.Id; -import javax.persistence.Inheritance; -import javax.persistence.JoinColumn; -import javax.persistence.JoinTable; -import javax.persistence.OneToMany; -import javax.persistence.Table; -import javax.persistence.Version; +import jakarta.persistence.CascadeType; +import jakarta.persistence.Column; +import jakarta.persistence.DiscriminatorColumn; +import jakarta.persistence.Embedded; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.Id; +import jakarta.persistence.Inheritance; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.JoinTable; +import jakarta.persistence.OneToMany; +import jakarta.persistence.Table; +import jakarta.persistence.Version; import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmIgnore; import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmProtectedBy; diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/BusinessPartnerRole.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/BusinessPartnerRole.java index ea18a3f50..4a0c90e2b 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/BusinessPartnerRole.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/BusinessPartnerRole.java @@ -1,14 +1,14 @@ package com.sap.olingo.jpa.processor.core.testmodel; -import javax.persistence.CascadeType; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.Id; -import javax.persistence.IdClass; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; -import javax.persistence.Table; +import jakarta.persistence.CascadeType; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.Id; +import jakarta.persistence.IdClass; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Table; @IdClass(BusinessPartnerRoleKey.class) //@ReadOnly @@ -59,7 +59,7 @@ public BusinessPartner getBusinessPartner() { return businessPartner; } - public void setBusinessPartnerID(String businessPartnerID) { + public void setBusinessPartnerID(final String businessPartnerID) { this.businessPartnerID = businessPartnerID; } @@ -91,11 +91,11 @@ public int hashCode() { } @Override - public boolean equals(Object obj) { + public boolean equals(final Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; - BusinessPartnerRole other = (BusinessPartnerRole) obj; + final BusinessPartnerRole other = (BusinessPartnerRole) obj; if (businessPartnerID == null) { if (other.businessPartnerID != null) return false; } else if (!businessPartnerID.equals(other.businessPartnerID)) return false; diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/BusinessPartnerRoleKey.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/BusinessPartnerRoleKey.java index a0a9f6252..b11fc044f 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/BusinessPartnerRoleKey.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/BusinessPartnerRoleKey.java @@ -2,12 +2,12 @@ import java.io.Serializable; -import javax.persistence.Id; +import jakarta.persistence.Id; public class BusinessPartnerRoleKey implements Serializable { /** - * + * */ private static final long serialVersionUID = -2350388598203342905L; @@ -27,11 +27,11 @@ public BusinessPartnerRoleKey(final String businessPartnerID, final String roleC } @Override - public boolean equals(Object obj) { + public boolean equals(final Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; - BusinessPartnerRoleKey other = (BusinessPartnerRoleKey) obj; + final BusinessPartnerRoleKey other = (BusinessPartnerRoleKey) obj; if (businessPartnerID == null) { if (other.businessPartnerID != null) return false; } else if (!businessPartnerID.equals(other.businessPartnerID)) return false; @@ -54,7 +54,7 @@ public String getBusinessPartnerID() { return businessPartnerID; } - public void setBusinessPartnerID(String businessPartnerID) { + public void setBusinessPartnerID(final String businessPartnerID) { this.businessPartnerID = businessPartnerID; } @@ -62,7 +62,7 @@ public String getRoleCategory() { return roleCategory; } - public void setRoleCategory(String roleCategory) { + public void setRoleCategory(final String roleCategory) { this.roleCategory = roleCategory; } } diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/BusinessPartnerRoleProtected.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/BusinessPartnerRoleProtected.java index 9f5c8398c..ea6287cb5 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/BusinessPartnerRoleProtected.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/BusinessPartnerRoleProtected.java @@ -1,13 +1,13 @@ package com.sap.olingo.jpa.processor.core.testmodel; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.Id; -import javax.persistence.IdClass; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; -import javax.persistence.Table; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.Id; +import jakarta.persistence.IdClass; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Table; import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmProtectedBy; @@ -48,7 +48,7 @@ public String getRoleCategory() { return roleCategory; } - public void setBusinessPartnerID(String businessPartnerID) { + public void setBusinessPartnerID(final String businessPartnerID) { this.businessPartnerID = businessPartnerID; } @@ -66,11 +66,11 @@ public int hashCode() { } @Override - public boolean equals(Object obj) { + public boolean equals(final Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; - BusinessPartnerRoleProtected other = (BusinessPartnerRoleProtected) obj; + final BusinessPartnerRoleProtected other = (BusinessPartnerRoleProtected) obj; if (businessPartnerID == null) { if (other.businessPartnerID != null) return false; } else if (!businessPartnerID.equals(other.businessPartnerID)) return false; diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/BusinessPartnerRoleWithGroup.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/BusinessPartnerRoleWithGroup.java index 63853c4c3..7e93012a0 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/BusinessPartnerRoleWithGroup.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/BusinessPartnerRoleWithGroup.java @@ -1,13 +1,13 @@ package com.sap.olingo.jpa.processor.core.testmodel; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.Id; -import javax.persistence.IdClass; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; -import javax.persistence.Table; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.Id; +import jakarta.persistence.IdClass; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Table; import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmVisibleFor; @@ -60,7 +60,7 @@ public BusinessPartnerWithGroups getBusinessPartner() { return businessPartner; } - public void setBusinessPartnerID(String businessPartnerID) { + public void setBusinessPartnerID(final String businessPartnerID) { this.businessPartnerID = businessPartnerID; } @@ -84,11 +84,11 @@ public int hashCode() { } @Override - public boolean equals(Object obj) { + public boolean equals(final Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; - BusinessPartnerRoleWithGroup other = (BusinessPartnerRoleWithGroup) obj; + final BusinessPartnerRoleWithGroup other = (BusinessPartnerRoleWithGroup) obj; if (businessPartnerID == null) { if (other.businessPartnerID != null) return false; } else if (!businessPartnerID.equals(other.businessPartnerID)) return false; diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/BusinessPartnerWithGroups.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/BusinessPartnerWithGroups.java index 4b2cc757e..6e1f6988c 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/BusinessPartnerWithGroups.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/BusinessPartnerWithGroups.java @@ -8,23 +8,23 @@ import java.util.Collection; import java.util.List; -import javax.persistence.AssociationOverride; -import javax.persistence.AssociationOverrides; -import javax.persistence.CascadeType; -import javax.persistence.CollectionTable; -import javax.persistence.Column; -import javax.persistence.Convert; -import javax.persistence.ElementCollection; -import javax.persistence.Embedded; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.OneToMany; -import javax.persistence.OrderColumn; -import javax.persistence.PrePersist; -import javax.persistence.Table; -import javax.persistence.Version; +import jakarta.persistence.AssociationOverride; +import jakarta.persistence.AssociationOverrides; +import jakarta.persistence.CascadeType; +import jakarta.persistence.CollectionTable; +import jakarta.persistence.Column; +import jakarta.persistence.Convert; +import jakarta.persistence.ElementCollection; +import jakarta.persistence.Embedded; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.OneToMany; +import jakarta.persistence.OrderColumn; +import jakarta.persistence.PrePersist; +import jakarta.persistence.Table; +import jakarta.persistence.Version; import org.apache.olingo.commons.api.edm.provider.annotation.CsdlConstantExpression.ConstantExpressionType; diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/ByteConverter.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/ByteConverter.java index 30cb28117..5cead180b 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/ByteConverter.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/ByteConverter.java @@ -1,19 +1,19 @@ package com.sap.olingo.jpa.processor.core.testmodel; -import javax.persistence.AttributeConverter; -import javax.persistence.Converter; +import jakarta.persistence.AttributeConverter; +import jakarta.persistence.Converter; //This converter has to be mentioned at all columns it is applicable @Converter(autoApply = false) public class ByteConverter implements AttributeConverter { @Override - public byte[] convertToDatabaseColumn(String entityString) { + public byte[] convertToDatabaseColumn(final String entityString) { return entityString.getBytes(); } @Override - public String convertToEntityAttribute(byte[] dbString) { + public String convertToEntityAttribute(final byte[] dbString) { return new String(dbString); } diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/ChangeInformation.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/ChangeInformation.java index dd4cfefcc..ae8c58090 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/ChangeInformation.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/ChangeInformation.java @@ -3,13 +3,13 @@ import java.util.Date; import java.util.Objects; -import javax.persistence.Column; -import javax.persistence.Embeddable; -import javax.persistence.FetchType; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; -import javax.persistence.Temporal; -import javax.persistence.TemporalType; +import jakarta.persistence.Column; +import jakarta.persistence.Embeddable; +import jakarta.persistence.FetchType; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Temporal; +import jakarta.persistence.TemporalType; @Embeddable public class ChangeInformation { diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/Collection.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/Collection.java index 0f3042e3c..2bcee7bcb 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/Collection.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/Collection.java @@ -4,16 +4,16 @@ import java.time.LocalDateTime; import java.util.List; -import javax.persistence.CollectionTable; -import javax.persistence.Column; -import javax.persistence.Convert; -import javax.persistence.ElementCollection; -import javax.persistence.Embedded; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.Table; +import jakarta.persistence.CollectionTable; +import jakarta.persistence.Column; +import jakarta.persistence.Convert; +import jakarta.persistence.ElementCollection; +import jakarta.persistence.Embedded; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.Table; @Entity @Table(schema = "\"OLINGO\"", name = "\"Collections\"") diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/CollectionDeep.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/CollectionDeep.java index 3ac6dbf6b..5b6977258 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/CollectionDeep.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/CollectionDeep.java @@ -1,10 +1,10 @@ package com.sap.olingo.jpa.processor.core.testmodel; -import javax.persistence.Column; -import javax.persistence.Embedded; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.Table; +import jakarta.persistence.Column; +import jakarta.persistence.Embedded; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.Table; @Entity @Table(schema = "\"OLINGO\"", name = "\"CollectionsDeep\"") @@ -18,11 +18,11 @@ public class CollectionDeep { @Embedded private CollectionFirstLevelComplex firstLevel; - public void setID(String iD) { + public void setID(final String iD) { this.iD = iD; } - public void setFirstLevel(CollectionFirstLevelComplex firstLevel) { + public void setFirstLevel(final CollectionFirstLevelComplex firstLevel) { this.firstLevel = firstLevel; } @@ -43,11 +43,11 @@ public int hashCode() { } @Override - public boolean equals(Object obj) { + public boolean equals(final Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; - CollectionDeep other = (CollectionDeep) obj; + final CollectionDeep other = (CollectionDeep) obj; if (iD == null) { if (other.iD != null) return false; } else if (!iD.equals(other.iD)) return false; diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/CollectionFirstLevelComplex.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/CollectionFirstLevelComplex.java index e3913aca0..664bd8adc 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/CollectionFirstLevelComplex.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/CollectionFirstLevelComplex.java @@ -3,10 +3,10 @@ import java.util.ArrayList; import java.util.List; -import javax.persistence.Column; -import javax.persistence.Embeddable; -import javax.persistence.Embedded; -import javax.persistence.Transient; +import jakarta.persistence.Column; +import jakarta.persistence.Embeddable; +import jakarta.persistence.Embedded; +import jakarta.persistence.Transient; import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmTransient; import com.sap.olingo.jpa.processor.core.errormodel.DummyPropertyCalculator; @@ -22,13 +22,13 @@ public class CollectionFirstLevelComplex { @Transient @EdmTransient(requiredAttributes = { "levelID" }, calculator = DummyPropertyCalculator.class) - private List transientCollection = new ArrayList<>(); + private final List transientCollection = new ArrayList<>(); - public void setLevelID(Integer levelID) { + public void setLevelID(final Integer levelID) { this.levelID = levelID; } - public void setSecondLevel(CollectionSecondLevelComplex secondLevel) { + public void setSecondLevel(final CollectionSecondLevelComplex secondLevel) { this.secondLevel = secondLevel; } diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/CollectionInnerComplex.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/CollectionInnerComplex.java index 58dee4aac..20c00f8a7 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/CollectionInnerComplex.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/CollectionInnerComplex.java @@ -3,9 +3,9 @@ import java.math.BigInteger; import java.time.Instant; -import javax.persistence.Column; -import javax.persistence.Convert; -import javax.persistence.Embeddable; +import jakarta.persistence.Column; +import jakarta.persistence.Convert; +import jakarta.persistence.Embeddable; import com.sap.olingo.jpa.metadata.converter.TimeInstantLongConverter; diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/CollectionNestedComplex.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/CollectionNestedComplex.java index 7dd9e11d7..2216ecc48 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/CollectionNestedComplex.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/CollectionNestedComplex.java @@ -1,8 +1,8 @@ package com.sap.olingo.jpa.processor.core.testmodel; -import javax.persistence.Column; -import javax.persistence.Embeddable; -import javax.persistence.Embedded; +import jakarta.persistence.Column; +import jakarta.persistence.Embeddable; +import jakarta.persistence.Embedded; import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmIgnore; diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/CollectionNestedComplexWithTransient.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/CollectionNestedComplexWithTransient.java index 902986255..ef0bf41b3 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/CollectionNestedComplexWithTransient.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/CollectionNestedComplexWithTransient.java @@ -1,9 +1,9 @@ package com.sap.olingo.jpa.processor.core.testmodel; -import javax.persistence.Column; -import javax.persistence.Embeddable; -import javax.persistence.Embedded; -import javax.persistence.Transient; +import jakarta.persistence.Column; +import jakarta.persistence.Embeddable; +import jakarta.persistence.Embedded; +import jakarta.persistence.Transient; import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmIgnore; import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmTransient; diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/CollectionPartOfComplex.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/CollectionPartOfComplex.java index 7f79497bf..823af3ac9 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/CollectionPartOfComplex.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/CollectionPartOfComplex.java @@ -3,13 +3,13 @@ import java.util.ArrayList; import java.util.List; -import javax.persistence.CollectionTable; -import javax.persistence.Column; -import javax.persistence.ElementCollection; -import javax.persistence.Embeddable; -import javax.persistence.FetchType; -import javax.persistence.JoinColumn; -import javax.persistence.OrderColumn; +import jakarta.persistence.CollectionTable; +import jakarta.persistence.Column; +import jakarta.persistence.ElementCollection; +import jakarta.persistence.Embeddable; +import jakarta.persistence.FetchType; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.OrderColumn; @Embeddable public class CollectionPartOfComplex { diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/CollectionSecondLevelComplex.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/CollectionSecondLevelComplex.java index 288093e0c..f2e2b14ea 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/CollectionSecondLevelComplex.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/CollectionSecondLevelComplex.java @@ -3,13 +3,13 @@ import java.util.ArrayList; import java.util.List; -import javax.persistence.CollectionTable; -import javax.persistence.Column; -import javax.persistence.ElementCollection; -import javax.persistence.Embeddable; -import javax.persistence.FetchType; -import javax.persistence.JoinColumn; -import javax.persistence.OrderColumn; +import jakarta.persistence.CollectionTable; +import jakarta.persistence.Column; +import jakarta.persistence.ElementCollection; +import jakarta.persistence.Embeddable; +import jakarta.persistence.FetchType; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.OrderColumn; @Embeddable public class CollectionSecondLevelComplex { diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/CollectionWithTransient.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/CollectionWithTransient.java index 8cd1d1853..1dafde8ae 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/CollectionWithTransient.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/CollectionWithTransient.java @@ -2,20 +2,20 @@ import java.util.List; -import javax.persistence.CollectionTable; -import javax.persistence.Column; -import javax.persistence.ElementCollection; -import javax.persistence.Embedded; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.Table; -import javax.persistence.Transient; - import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmTransient; import com.sap.olingo.jpa.processor.core.errormodel.DummyPropertyCalculator; +import jakarta.persistence.CollectionTable; +import jakarta.persistence.Column; +import jakarta.persistence.ElementCollection; +import jakarta.persistence.Embedded; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.Table; +import jakarta.persistence.Transient; + @Entity @Table(schema = "\"OLINGO\"", name = "\"Collections\"") public class CollectionWithTransient { @@ -41,7 +41,7 @@ public String getID() { return iD; } - public void setID(String iD) { + public void setID(final String iD) { this.iD = iD; } @@ -49,7 +49,7 @@ public CollectionPartOfComplex getComplex() { return complex; } - public void setComplex(CollectionPartOfComplex complex) { + public void setComplex(final CollectionPartOfComplex complex) { this.complex = complex; } @@ -57,7 +57,7 @@ public List getNested() { return nested; } - public void setNested(List nested) { + public void setNested(final List nested) { this.nested = nested; } @@ -70,11 +70,11 @@ public int hashCode() { } @Override - public boolean equals(Object obj) { + public boolean equals(final Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; - CollectionWithTransient other = (CollectionWithTransient) obj; + final CollectionWithTransient other = (CollectionWithTransient) obj; if (iD == null) { if (other.iD != null) return false; } else if (!iD.equals(other.iD)) return false; diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/Comment.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/Comment.java index f19ec1562..b9788bdf4 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/Comment.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/Comment.java @@ -2,13 +2,13 @@ import java.sql.Clob; -import javax.persistence.Basic; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.Id; -import javax.persistence.Lob; -import javax.persistence.Table; +import jakarta.persistence.Basic; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.Id; +import jakarta.persistence.Lob; +import jakarta.persistence.Table; import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmIgnore; diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/CommunicationData.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/CommunicationData.java index c7f37f1a2..71978537e 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/CommunicationData.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/CommunicationData.java @@ -1,7 +1,7 @@ package com.sap.olingo.jpa.processor.core.testmodel; -import javax.persistence.Column; -import javax.persistence.Embeddable; +import jakarta.persistence.Column; +import jakarta.persistence.Embeddable; @Embeddable public class CommunicationData { @@ -31,19 +31,19 @@ public String getMobilePhoneNumber() { return mobilePhoneNumber; } - public void setLandlinePhoneNumber(String landlinePhoneNumber) { + public void setLandlinePhoneNumber(final String landlinePhoneNumber) { this.landlinePhoneNumber = landlinePhoneNumber; } - public void setMobilePhoneNumber(String mobilePhoneNumber) { + public void setMobilePhoneNumber(final String mobilePhoneNumber) { this.mobilePhoneNumber = mobilePhoneNumber; } - public void setFax(String fax) { + public void setFax(final String fax) { this.fax = fax; } - public void setEmail(String email) { + public void setEmail(final String email) { this.email = email; } } diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/ComplexBaseType.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/ComplexBaseType.java index e35537270..190550792 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/ComplexBaseType.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/ComplexBaseType.java @@ -1,7 +1,7 @@ package com.sap.olingo.jpa.processor.core.testmodel; -import javax.persistence.Column; -import javax.persistence.Embeddable; +import jakarta.persistence.Column; +import jakarta.persistence.Embeddable; @Embeddable public class ComplexBaseType { diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/ComplexSubType.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/ComplexSubType.java index cf060ca47..7511de657 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/ComplexSubType.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/ComplexSubType.java @@ -1,7 +1,7 @@ package com.sap.olingo.jpa.processor.core.testmodel; -import javax.persistence.Column; -import javax.persistence.Embeddable; +import jakarta.persistence.Column; +import jakarta.persistence.Embeddable; @Embeddable public class ComplexSubType extends ComplexBaseType { diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/ComplexWithTransientComplexCollection.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/ComplexWithTransientComplexCollection.java index 356b1660e..e799570d3 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/ComplexWithTransientComplexCollection.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/ComplexWithTransientComplexCollection.java @@ -1,14 +1,14 @@ /** - * + * */ package com.sap.olingo.jpa.processor.core.testmodel; import java.util.ArrayList; import java.util.List; -import javax.persistence.Column; -import javax.persistence.Embeddable; -import javax.persistence.Transient; +import jakarta.persistence.Column; +import jakarta.persistence.Embeddable; +import jakarta.persistence.Transient; import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmTransient; import com.sap.olingo.jpa.processor.core.errormodel.DummyPropertyCalculator; @@ -26,5 +26,5 @@ public class ComplexWithTransientComplexCollection { @Transient @EdmTransient(calculator = DummyPropertyCalculator.class) - private List transientCollection = new ArrayList<>(); + private final List transientCollection = new ArrayList<>(); } diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/Country.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/Country.java index 94dead5a1..18e47afba 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/Country.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/Country.java @@ -1,10 +1,10 @@ package com.sap.olingo.jpa.processor.core.testmodel; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.IdClass; -import javax.persistence.Table; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.IdClass; +import jakarta.persistence.Table; @Entity @IdClass(CountryKey.class) diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/CountryKey.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/CountryKey.java index 58257b8a9..cf0ab5592 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/CountryKey.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/CountryKey.java @@ -2,13 +2,13 @@ import java.io.Serializable; -import javax.persistence.Column; -import javax.persistence.Embeddable; +import jakarta.persistence.Column; +import jakarta.persistence.Embeddable; @Embeddable public class CountryKey implements Serializable { /** - * + * */ private static final long serialVersionUID = 229175464207091262L; @@ -22,7 +22,7 @@ public String getCode() { return code; } - public void setCode(String code) { + public void setCode(final String code) { this.code = code; } @@ -30,16 +30,16 @@ public String getLanguage() { return language; } - public void setLanguage(String language) { + public void setLanguage(final String language) { this.language = language; } @Override - public boolean equals(Object obj) { + public boolean equals(final Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; - CountryKey other = (CountryKey) obj; + final CountryKey other = (CountryKey) obj; if (code == null) { if (other.code != null) return false; } else if (!code.equals(other.code)) return false; diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/CountryRestriction.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/CountryRestriction.java index 99eb73d96..f9d589cb1 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/CountryRestriction.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/CountryRestriction.java @@ -1,9 +1,9 @@ package com.sap.olingo.jpa.processor.core.testmodel; -import javax.persistence.Column; -import javax.persistence.EmbeddedId; -import javax.persistence.Entity; -import javax.persistence.Table; +import jakarta.persistence.Column; +import jakarta.persistence.EmbeddedId; +import jakarta.persistence.Entity; +import jakarta.persistence.Table; @Entity @Table(schema = "\"OLINGO\"", name = "\"CountryRestriction\"") @@ -22,7 +22,7 @@ public CountryRestriction() { // Needed for JPA } - public CountryRestriction(InstanceRestrictionKey id) { + public CountryRestriction(final InstanceRestrictionKey id) { super(); this.id = id; } @@ -35,11 +35,11 @@ public String getToCountry() { return toCountry; } - public void setFromCountry(String fromCountry) { + public void setFromCountry(final String fromCountry) { this.fromCountry = fromCountry; } - public void setToCountry(String toCountry) { + public void setToCountry(final String toCountry) { this.toCountry = toCountry; } } diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/CurrentUser.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/CurrentUser.java index 0a0003770..8e4931bc2 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/CurrentUser.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/CurrentUser.java @@ -1,11 +1,11 @@ package com.sap.olingo.jpa.processor.core.testmodel; -import javax.persistence.DiscriminatorValue; -import javax.persistence.Entity; - import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmEntityType; import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmTopLevelElementRepresentation; +import jakarta.persistence.DiscriminatorValue; +import jakarta.persistence.Entity; + //Problem with multi-level inheritance hierarchy Inheritance Type SINGLE_TABLE. Therefore inherit also from //Business Partner @Entity(name = "CurrentUser") diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/CurrentUserQueryExtension.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/CurrentUserQueryExtension.java index f47ece2d2..1f5793b7f 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/CurrentUserQueryExtension.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/CurrentUserQueryExtension.java @@ -1,11 +1,11 @@ package com.sap.olingo.jpa.processor.core.testmodel; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.Expression; -import javax.persistence.criteria.From; - import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmQueryExtensionProvider; +import jakarta.persistence.criteria.CriteriaBuilder; +import jakarta.persistence.criteria.Expression; +import jakarta.persistence.criteria.From; + public class CurrentUserQueryExtension implements EdmQueryExtensionProvider { @Override diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/DateConverter.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/DateConverter.java index 4ffb9c374..6f397a6f5 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/DateConverter.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/DateConverter.java @@ -3,18 +3,20 @@ import java.sql.Date; import java.time.LocalDate; -import javax.persistence.AttributeConverter; -import javax.persistence.Converter; +import jakarta.persistence.AttributeConverter; +import jakarta.persistence.Converter; //This converter has to be mentioned at all columns it is applicable @Converter(autoApply = false) public class DateConverter implements AttributeConverter { - public Date convertToDatabaseColumn(LocalDate locDate) { + @Override + public Date convertToDatabaseColumn(final LocalDate locDate) { return (locDate == null ? null : Date.valueOf(locDate)); } - public LocalDate convertToEntityAttribute(Date sqlDate) { + @Override + public LocalDate convertToEntityAttribute(final Date sqlDate) { return (sqlDate == null ? null : sqlDate.toLocalDate()); } diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/DateTimeConverter.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/DateTimeConverter.java index e89add8ea..d1ae11263 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/DateTimeConverter.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/DateTimeConverter.java @@ -4,20 +4,20 @@ import java.time.LocalDateTime; import java.time.ZoneOffset; -import javax.persistence.AttributeConverter; -import javax.persistence.Converter; +import jakarta.persistence.AttributeConverter; +import jakarta.persistence.Converter; //This converter has to be mentioned at all columns it is applicable @Converter(autoApply = false) public class DateTimeConverter implements AttributeConverter { @Override - public Timestamp convertToDatabaseColumn(LocalDateTime locDateTime) { + public Timestamp convertToDatabaseColumn(final LocalDateTime locDateTime) { return (locDateTime == null ? null : Timestamp.from(locDateTime.toInstant(ZoneOffset.UTC))); } @Override - public LocalDateTime convertToEntityAttribute(Timestamp sqlTimestamp) { + public LocalDateTime convertToEntityAttribute(final Timestamp sqlTimestamp) { return (sqlTimestamp == null ? null : sqlTimestamp.toLocalDateTime()); } diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/DateTimeTest.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/DateTimeTest.java index 2b87aeebc..d2a763593 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/DateTimeTest.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/DateTimeTest.java @@ -4,13 +4,13 @@ import java.time.LocalDateTime; import java.util.Date; -import javax.persistence.Column; -import javax.persistence.Convert; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.Table; -import javax.persistence.Temporal; -import javax.persistence.TemporalType; +import jakarta.persistence.Column; +import jakarta.persistence.Convert; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.Table; +import jakarta.persistence.Temporal; +import jakarta.persistence.TemporalType; /** * Test for time conversion diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/DeepProtectedExample.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/DeepProtectedExample.java index 6fb52a009..f55d3524b 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/DeepProtectedExample.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/DeepProtectedExample.java @@ -1,14 +1,14 @@ package com.sap.olingo.jpa.processor.core.testmodel; -import javax.persistence.Column; -import javax.persistence.Embedded; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.Table; -import javax.persistence.Version; - import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmIgnore; +import jakarta.persistence.Column; +import jakarta.persistence.Embedded; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.Table; +import jakarta.persistence.Version; + @EdmIgnore @Entity(name = "ProtectionExample") @Table(schema = "\"OLINGO\"", name = "\"BusinessPartner\"") diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/DetailSettings.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/DetailSettings.java index 3523d6c3b..73fa5a9be 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/DetailSettings.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/DetailSettings.java @@ -1,10 +1,10 @@ package com.sap.olingo.jpa.processor.core.testmodel; -import javax.persistence.Column; -import javax.persistence.Embeddable; - import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmIgnore; +import jakarta.persistence.Column; +import jakarta.persistence.Embeddable; + @Embeddable public class DetailSettings { diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/DummyEmbeddedToIgnore.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/DummyEmbeddedToIgnore.java index 91903d2f7..5f4cc1a60 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/DummyEmbeddedToIgnore.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/DummyEmbeddedToIgnore.java @@ -3,11 +3,11 @@ import java.sql.Blob; import java.sql.Clob; -import javax.persistence.Basic; -import javax.persistence.Column; -import javax.persistence.Embeddable; -import javax.persistence.FetchType; -import javax.persistence.Lob; +import jakarta.persistence.Basic; +import jakarta.persistence.Column; +import jakarta.persistence.Embeddable; +import jakarta.persistence.FetchType; +import jakarta.persistence.Lob; import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmIgnore; diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/DummyToBeIgnored.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/DummyToBeIgnored.java index cc9d7c553..7ba8c69bb 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/DummyToBeIgnored.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/DummyToBeIgnored.java @@ -3,20 +3,20 @@ import java.math.BigDecimal; import java.util.UUID; -import javax.persistence.Column; -import javax.persistence.Convert; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.OneToOne; -import javax.persistence.Table; - import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmFunction; import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmFunctions; import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmIgnore; import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmParameter; +import jakarta.persistence.Column; +import jakarta.persistence.Convert; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.OneToOne; +import jakarta.persistence.Table; + /** * Entity implementation class for Entity: DummyToBeIgnored * diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/EmptyQueryExtensionProvider.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/EmptyQueryExtensionProvider.java index ca4a743ad..232c90dc7 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/EmptyQueryExtensionProvider.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/EmptyQueryExtensionProvider.java @@ -1,11 +1,11 @@ package com.sap.olingo.jpa.processor.core.testmodel; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.Expression; -import javax.persistence.criteria.From; - import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmQueryExtensionProvider; +import jakarta.persistence.criteria.CriteriaBuilder; +import jakarta.persistence.criteria.Expression; +import jakarta.persistence.criteria.From; + /** * Empty implementation to check inheritance of query provider. * @author Oliver Grande diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/EntityTypeOnly.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/EntityTypeOnly.java index 5790446d9..278e3970f 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/EntityTypeOnly.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/EntityTypeOnly.java @@ -2,17 +2,17 @@ import static com.sap.olingo.jpa.metadata.core.edm.annotation.EdmTopLevelElementRepresentation.AS_ENTITY_TYPE; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; -import javax.persistence.Table; - import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmEntityType; import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmIgnore; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Table; + @Table(schema = "\"OLINGO\"", name = "\"DetailSettings\"") @Entity(name = "AsEntityType") @EdmEntityType(as = AS_ENTITY_TYPE) diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/FullNameCalculator.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/FullNameCalculator.java index 4a171bb7b..3410ca1cb 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/FullNameCalculator.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/FullNameCalculator.java @@ -1,12 +1,12 @@ /** - * + * */ package com.sap.olingo.jpa.processor.core.testmodel; -import javax.persistence.Tuple; - import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmTransientPropertyCalculator; +import jakarta.persistence.Tuple; + /** * @author Oliver Grande * Created: 17.03.2020 diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/Group.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/Group.java index 82ca8f229..a9bf8193a 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/Group.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/Group.java @@ -1,12 +1,12 @@ package com.sap.olingo.jpa.processor.core.testmodel; -import javax.persistence.CascadeType; -import javax.persistence.Column; -import javax.persistence.FetchType; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; -import javax.persistence.MappedSuperclass; -import javax.persistence.Transient; +import jakarta.persistence.CascadeType; +import jakarta.persistence.Column; +import jakarta.persistence.FetchType; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.MappedSuperclass; +import jakarta.persistence.Transient; import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmIgnore; import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmTransient; diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/GroupNameCalculator.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/GroupNameCalculator.java index 098076daf..1b0ac63bd 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/GroupNameCalculator.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/GroupNameCalculator.java @@ -2,8 +2,8 @@ * */ package com.sap.olingo.jpa.processor.core.testmodel; - -import javax.persistence.Tuple; + +import jakarta.persistence.Tuple; import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmTransientPropertyCalculator; diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/ImageLoader.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/ImageLoader.java index 33b72acfa..888756c05 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/ImageLoader.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/ImageLoader.java @@ -11,55 +11,58 @@ import java.util.List; import java.util.Map; -import javax.persistence.EntityManager; -import javax.persistence.EntityManagerFactory; -import javax.persistence.Persistence; -import javax.persistence.Query; +import jakarta.persistence.EntityManager; +import jakarta.persistence.EntityManagerFactory; +import jakarta.persistence.Persistence; +import jakarta.persistence.Query; public class ImageLoader { /** - * + * */ private static final String SELECT_PERSON_IMAGE = "SELECT * FROM \"OLINGO\".\"PersonImage\" WHERE ID = '$&1'"; private static final String SELECT_ORGANIZATION_IMAGE = "SELECT * FROM \"OLINGO\".\"OrganizationImage\" WHERE ID = '$&1'"; private static final String PATH = "images/"; - private static final String ENTITY_MANAGER_DATA_SOURCE = "javax.persistence.nonJtaDataSource"; + private static final String ENTITY_MANAGER_DATA_SOURCE = "jakarta.persistence.nonJtaDataSource"; private static final String PUNIT_NAME = "com.sap.olingo.jpa"; - public static void main(String[] args) throws IOException { + public static void main(final String[] args) throws IOException { final ImageLoader i = new ImageLoader(); final EntityManager em = createEntityManager(); i.loadPerson(em, "OlingoOrangeTM.png", "99"); } - public void loadPerson(EntityManager em, String imageName, String businessPartnerID) throws IOException { + public void loadPerson(final EntityManager em, final String imageName, final String businessPartnerID) + throws IOException { final byte[] image = loadImage(imageName); storePersonImageDB(em, image, businessPartnerID, SELECT_PERSON_IMAGE); } - public void loadPerson(String imageName, String businessPartnerID) throws IOException { + public void loadPerson(final String imageName, final String businessPartnerID) throws IOException { final byte[] image = loadImage(imageName); storePersonImageDB(createEntityManager(), image, businessPartnerID, SELECT_PERSON_IMAGE); } - public void loadOrg(EntityManager em, String imageName, String businessPartnerID) throws IOException { + public void loadOrg(final EntityManager em, final String imageName, final String businessPartnerID) + throws IOException { final byte[] image = loadImage(imageName); storeOrgImageDB(em, image, businessPartnerID, SELECT_ORGANIZATION_IMAGE); } - public void loadOrg(String imageName, String businessPartnerID) throws IOException { + public void loadOrg(final String imageName, final String businessPartnerID) throws IOException { final byte[] image = loadImage(imageName); storeOrgImageDB(createEntityManager(), image, businessPartnerID, SELECT_ORGANIZATION_IMAGE); } - private void storePersonImageDB(EntityManager em, byte[] image, String businessPartnerID, String query) { + private void storePersonImageDB(final EntityManager em, final byte[] image, final String businessPartnerID, + final String query) { final String s = query.replace("$&1", businessPartnerID); final Query q = em.createNativeQuery(s, PersonImage.class); @@ -75,7 +78,8 @@ private void storePersonImageDB(EntityManager em, byte[] image, String businessP compareImage(image, storedImage); } - private void storeOrgImageDB(EntityManager em, byte[] image, String businessPartnerID, String query) { + private void storeOrgImageDB(final EntityManager em, final byte[] image, final String businessPartnerID, + final String query) { final String s = query.replace("$&1", businessPartnerID); final Query q = em.createNativeQuery(s, OrganizationImage.class); @@ -91,7 +95,7 @@ private void storeOrgImageDB(EntityManager em, byte[] image, String businessPart compareImage(image, storedImage); } - private void updateDB(EntityManager em, List result) { + private void updateDB(final EntityManager em, final List result) { em.getTransaction().begin(); em.persist(result.get(0)); em.getTransaction().commit(); @@ -100,11 +104,12 @@ private void updateDB(EntityManager em, List result) { private static EntityManager createEntityManager() { final Map properties = new HashMap<>(); properties.put(ENTITY_MANAGER_DATA_SOURCE, DataSourceHelper.createDataSource(DataSourceHelper.DB_H2)); - final EntityManagerFactory emf = Persistence.createEntityManagerFactory(PUNIT_NAME, properties); - return emf.createEntityManager(); + try (EntityManagerFactory emf = Persistence.createEntityManagerFactory(PUNIT_NAME, properties)) { + return emf.createEntityManager(); + } } - private void compareImage(byte[] image, byte[] storedImage) { + private void compareImage(final byte[] image, final byte[] storedImage) { if (image.length != storedImage.length) fail("[Image]: length miss match"); else { diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/InhouseAddress.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/InhouseAddress.java index 8e41dc9ba..6fa8414a0 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/InhouseAddress.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/InhouseAddress.java @@ -1,7 +1,7 @@ package com.sap.olingo.jpa.processor.core.testmodel; -import javax.persistence.Column; -import javax.persistence.Embeddable; +import jakarta.persistence.Column; +import jakarta.persistence.Embeddable; @Embeddable public class InhouseAddress { @@ -28,7 +28,7 @@ public String getBuilding() { return building; } - public void setBuilding(String building) { + public void setBuilding(final String building) { this.building = building; } @@ -36,7 +36,7 @@ public Short getFloor() { return floor; } - public void setFloor(Short floor) { + public void setFloor(final Short floor) { this.floor = floor; } @@ -44,7 +44,7 @@ public Integer getRoomNumber() { return roomNumber; } - public void setRoomNumber(Integer roomNumber) { + public void setRoomNumber(final Integer roomNumber) { this.roomNumber = roomNumber; } @@ -52,7 +52,7 @@ public String getTaskID() { return taskID; } - public void setTaskID(String taskID) { + public void setTaskID(final String taskID) { this.taskID = taskID; } diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/InhouseAddressTable.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/InhouseAddressTable.java index b5e0dbd7c..43a58de94 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/InhouseAddressTable.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/InhouseAddressTable.java @@ -1,9 +1,9 @@ package com.sap.olingo.jpa.processor.core.testmodel; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.Table; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.Table; import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmIgnore; diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/InhouseAddressWithGroup.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/InhouseAddressWithGroup.java index 38d2a376a..16982fb97 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/InhouseAddressWithGroup.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/InhouseAddressWithGroup.java @@ -1,7 +1,7 @@ package com.sap.olingo.jpa.processor.core.testmodel; -import javax.persistence.Column; -import javax.persistence.Embeddable; +import jakarta.persistence.Column; +import jakarta.persistence.Embeddable; import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmVisibleFor; @@ -34,7 +34,7 @@ public String getBuilding() { return building; } - public void setBuilding(String building) { + public void setBuilding(final String building) { this.building = building; } @@ -42,7 +42,7 @@ public Short getFloor() { return floor; } - public void setFloor(Short floor) { + public void setFloor(final Short floor) { this.floor = floor; } @@ -50,7 +50,7 @@ public Integer getRoomNumber() { return roomNumber; } - public void setRoomNumber(Integer roomNumber) { + public void setRoomNumber(final Integer roomNumber) { this.roomNumber = roomNumber; } @@ -58,7 +58,7 @@ public String getTaskID() { return taskID; } - public void setTaskID(String taskID) { + public void setTaskID(final String taskID) { this.taskID = taskID; } diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/InhouseAddressWithProtection.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/InhouseAddressWithProtection.java index ca3f35822..3423e6da1 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/InhouseAddressWithProtection.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/InhouseAddressWithProtection.java @@ -1,7 +1,7 @@ package com.sap.olingo.jpa.processor.core.testmodel; -import javax.persistence.Column; -import javax.persistence.Embeddable; +import jakarta.persistence.Column; +import jakarta.persistence.Embeddable; import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmProtectedBy; diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/InhouseAddressWithThreeProtections.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/InhouseAddressWithThreeProtections.java index d53916362..9de2cd302 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/InhouseAddressWithThreeProtections.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/InhouseAddressWithThreeProtections.java @@ -1,7 +1,7 @@ package com.sap.olingo.jpa.processor.core.testmodel; -import javax.persistence.Column; -import javax.persistence.Embeddable; +import jakarta.persistence.Column; +import jakarta.persistence.Embeddable; import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmProtectedBy; diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/InstanceRestrictionKey.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/InstanceRestrictionKey.java index 8a3d532de..33c403532 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/InstanceRestrictionKey.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/InstanceRestrictionKey.java @@ -2,8 +2,8 @@ import java.io.Serializable; -import javax.persistence.Column; -import javax.persistence.Embeddable; +import jakarta.persistence.Column; +import jakarta.persistence.Embeddable; @Embeddable public class InstanceRestrictionKey implements Serializable { diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/JoinComplex.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/JoinComplex.java index 3710b951d..c31fcfbf7 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/JoinComplex.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/JoinComplex.java @@ -2,11 +2,11 @@ import java.util.List; -import javax.persistence.Column; -import javax.persistence.Embeddable; -import javax.persistence.JoinColumn; -import javax.persistence.JoinTable; -import javax.persistence.OneToMany; +import jakarta.persistence.Column; +import jakarta.persistence.Embeddable; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.JoinTable; +import jakarta.persistence.OneToMany; @Embeddable public class JoinComplex { diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/JoinPartnerRoleRelation.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/JoinPartnerRoleRelation.java index be1a0bdd2..2ca4be4a2 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/JoinPartnerRoleRelation.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/JoinPartnerRoleRelation.java @@ -1,8 +1,8 @@ package com.sap.olingo.jpa.processor.core.testmodel; -import javax.persistence.EmbeddedId; -import javax.persistence.Entity; -import javax.persistence.Table; +import jakarta.persistence.EmbeddedId; +import jakarta.persistence.Entity; +import jakarta.persistence.Table; import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmIgnore; diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/JoinPartnerRoleRelationKey.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/JoinPartnerRoleRelationKey.java index 8db9f6c71..1261d262b 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/JoinPartnerRoleRelationKey.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/JoinPartnerRoleRelationKey.java @@ -3,11 +3,11 @@ import java.io.Serializable; import java.util.Objects; -import javax.persistence.Column; -import javax.persistence.Embeddable; +import jakarta.persistence.Column; +import jakarta.persistence.Embeddable; @Embeddable -public class JoinPartnerRoleRelationKey implements Serializable{ +public class JoinPartnerRoleRelationKey implements Serializable { private static final long serialVersionUID = 336967410352659606L; diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/JoinRelation.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/JoinRelation.java index 5d7528537..0f3a8c091 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/JoinRelation.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/JoinRelation.java @@ -1,8 +1,8 @@ package com.sap.olingo.jpa.processor.core.testmodel; -import javax.persistence.EmbeddedId; -import javax.persistence.Entity; -import javax.persistence.Table; +import jakarta.persistence.EmbeddedId; +import jakarta.persistence.Entity; +import jakarta.persistence.Table; @Entity(name = "JoinRelation") @Table(schema = "\"OLINGO\"", name = "\"JoinRelation\"") diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/JoinRelationKey.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/JoinRelationKey.java index a8b3ddac6..2b7b84b04 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/JoinRelationKey.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/JoinRelationKey.java @@ -2,14 +2,14 @@ import java.io.Serializable; -import javax.persistence.Column; -import javax.persistence.Embeddable; +import jakarta.persistence.Column; +import jakarta.persistence.Embeddable; @Embeddable public class JoinRelationKey implements Serializable { /** - * + * */ private static final long serialVersionUID = 5206755977104102088L; @@ -23,7 +23,7 @@ public Integer getSourceID() { return sourceID; } - public void setSourceID(Integer sourceID) { + public void setSourceID(final Integer sourceID) { this.sourceID = sourceID; } @@ -31,7 +31,7 @@ public Integer getTargetID() { return targetID; } - public void setTargetID(Integer targetID) { + public void setTargetID(final Integer targetID) { this.targetID = targetID; } @@ -45,11 +45,11 @@ public int hashCode() { } @Override - public boolean equals(Object obj) { + public boolean equals(final Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; - JoinRelationKey other = (JoinRelationKey) obj; + final JoinRelationKey other = (JoinRelationKey) obj; if (sourceID == null) { if (other.sourceID != null) return false; } else if (!sourceID.equals(other.sourceID)) return false; diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/JoinSource.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/JoinSource.java index 6cd7d451e..84223504a 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/JoinSource.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/JoinSource.java @@ -2,14 +2,14 @@ import java.util.List; -import javax.persistence.Column; -import javax.persistence.Embedded; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.JoinTable; -import javax.persistence.OneToMany; -import javax.persistence.Table; +import jakarta.persistence.Column; +import jakarta.persistence.Embedded; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.JoinTable; +import jakarta.persistence.OneToMany; +import jakarta.persistence.Table; @Entity(name = "JoinSource") @Table(schema = "\"OLINGO\"", name = "\"JoinSource\"") diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/JoinTarget.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/JoinTarget.java index d7eba1c83..df345ec55 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/JoinTarget.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/JoinTarget.java @@ -1,12 +1,12 @@ package com.sap.olingo.jpa.processor.core.testmodel; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.JoinTable; -import javax.persistence.ManyToOne; -import javax.persistence.Table; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.JoinTable; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Table; @Entity(name = "JoinTarget") @Table(schema = "\"OLINGO\"", name = "\"JoinTarget\"") diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/LauFilter.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/LauFilter.java index 7270d2f32..ee634cf23 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/LauFilter.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/LauFilter.java @@ -1,8 +1,8 @@ package com.sap.olingo.jpa.processor.core.testmodel; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.Expression; -import javax.persistence.criteria.From; +import jakarta.persistence.criteria.CriteriaBuilder; +import jakarta.persistence.criteria.Expression; +import jakarta.persistence.criteria.From; import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmQueryExtensionProvider; diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/LocalDateTimeConverter.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/LocalDateTimeConverter.java index 52dbda5ce..f6d2e7a9a 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/LocalDateTimeConverter.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/LocalDateTimeConverter.java @@ -5,8 +5,8 @@ import java.time.ZoneOffset; import java.util.Date; -import javax.persistence.AttributeConverter; -import javax.persistence.Converter; +import jakarta.persistence.AttributeConverter; +import jakarta.persistence.Converter; @Converter public class LocalDateTimeConverter implements AttributeConverter { diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/LogarithmCalculator.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/LogarithmCalculator.java index 53039f75c..6c4a98da1 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/LogarithmCalculator.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/LogarithmCalculator.java @@ -1,12 +1,12 @@ /** - * + * */ package com.sap.olingo.jpa.processor.core.testmodel; import java.util.Optional; -import javax.persistence.Tuple; -import javax.persistence.TupleElement; +import jakarta.persistence.Tuple; +import jakarta.persistence.TupleElement; import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmTransientPropertyCalculator; diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/Membership.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/Membership.java index 5946aa77f..dcb4c8730 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/Membership.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/Membership.java @@ -1,10 +1,10 @@ package com.sap.olingo.jpa.processor.core.testmodel; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.IdClass; -import javax.persistence.Table; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.IdClass; +import jakarta.persistence.Table; import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmIgnore; diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/MembershipKey.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/MembershipKey.java index d191f0135..90d3d42f2 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/MembershipKey.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/MembershipKey.java @@ -2,13 +2,13 @@ import java.io.Serializable; -import javax.persistence.Column; -import javax.persistence.Id; +import jakarta.persistence.Column; +import jakarta.persistence.Id; public class MembershipKey implements Serializable { /** - * + * */ private static final long serialVersionUID = -2197928070426048826L; @@ -39,11 +39,11 @@ public int hashCode() { } @Override - public boolean equals(Object obj) { + public boolean equals(final Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; - MembershipKey other = (MembershipKey) obj; + final MembershipKey other = (MembershipKey) obj; if (personID == null) { if (other.personID != null) return false; } else if (!personID.equals(other.personID)) return false; diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/Organization.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/Organization.java index 875b92f50..968e2d15e 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/Organization.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/Organization.java @@ -3,16 +3,16 @@ import java.util.ArrayList; import java.util.List; -import javax.persistence.CollectionTable; -import javax.persistence.Column; -import javax.persistence.DiscriminatorValue; -import javax.persistence.ElementCollection; -import javax.persistence.Entity; -import javax.persistence.Enumerated; -import javax.persistence.FetchType; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToMany; -import javax.persistence.OrderColumn; +import jakarta.persistence.CollectionTable; +import jakarta.persistence.Column; +import jakarta.persistence.DiscriminatorValue; +import jakarta.persistence.ElementCollection; +import jakarta.persistence.Entity; +import jakarta.persistence.Enumerated; +import jakarta.persistence.FetchType; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToMany; +import jakarta.persistence.OrderColumn; import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmFunction; import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmFunction.ReturnType; @@ -61,7 +61,7 @@ public String getName1() { return name1; } - public void setName1(String name1) { + public void setName1(final String name1) { this.name1 = name1; } @@ -69,7 +69,7 @@ public String getName2() { return name2; } - public void setName2(String name2) { + public void setName2(final String name2) { this.name2 = name2; } @@ -77,7 +77,7 @@ public ABCClassification getABCClass() { return aBCClass; } - public void setABCClass(ABCClassification aBCClass) { + public void setABCClass(final ABCClassification aBCClass) { this.aBCClass = aBCClass; } @@ -85,7 +85,7 @@ public List getComment() { return comment; } - public void setComment(List comment) { + public void setComment(final List comment) { this.comment = comment; } } diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/OrganizationImage.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/OrganizationImage.java index 5f0ea3f5b..7b3bcc300 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/OrganizationImage.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/OrganizationImage.java @@ -1,10 +1,10 @@ package com.sap.olingo.jpa.processor.core.testmodel; -import javax.persistence.Column; -import javax.persistence.Embedded; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.Table; +import jakarta.persistence.Column; +import jakarta.persistence.Embedded; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.Table; import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmIgnore; import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmMediaStream; diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/Person.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/Person.java index ec35138a5..c24771dd6 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/Person.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/Person.java @@ -6,20 +6,20 @@ import java.util.Collections; import java.util.List; -import javax.persistence.CascadeType; -import javax.persistence.CollectionTable; -import javax.persistence.Column; -import javax.persistence.Convert; -import javax.persistence.DiscriminatorValue; -import javax.persistence.ElementCollection; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.JoinColumn; -import javax.persistence.JoinTable; -import javax.persistence.ManyToMany; -import javax.persistence.OneToMany; -import javax.persistence.OneToOne; -import javax.persistence.Transient; +import jakarta.persistence.CascadeType; +import jakarta.persistence.CollectionTable; +import jakarta.persistence.Column; +import jakarta.persistence.Convert; +import jakarta.persistence.DiscriminatorValue; +import jakarta.persistence.ElementCollection; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.JoinTable; +import jakarta.persistence.ManyToMany; +import jakarta.persistence.OneToMany; +import jakarta.persistence.OneToOne; +import jakarta.persistence.Transient; import org.apache.olingo.commons.api.edm.provider.annotation.CsdlConstantExpression.ConstantExpressionType; diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/PersonDeepProtected.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/PersonDeepProtected.java index de986669e..243f68302 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/PersonDeepProtected.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/PersonDeepProtected.java @@ -4,16 +4,16 @@ import java.util.ArrayList; import java.util.List; -import javax.persistence.CollectionTable; -import javax.persistence.Column; -import javax.persistence.ElementCollection; -import javax.persistence.Embedded; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.Table; -import javax.persistence.Version; +import jakarta.persistence.CollectionTable; +import jakarta.persistence.Column; +import jakarta.persistence.ElementCollection; +import jakarta.persistence.Embedded; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.Table; +import jakarta.persistence.Version; import org.apache.olingo.commons.api.edm.provider.annotation.CsdlConstantExpression.ConstantExpressionType; diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/PersonDeepProtectedHidden.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/PersonDeepProtectedHidden.java index 7461557a2..76b7e935a 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/PersonDeepProtectedHidden.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/PersonDeepProtectedHidden.java @@ -5,11 +5,11 @@ import java.util.Collections; import java.util.List; -import javax.persistence.Column; -import javax.persistence.Convert; -import javax.persistence.DiscriminatorValue; -import javax.persistence.Embedded; -import javax.persistence.Entity; +import jakarta.persistence.Column; +import jakarta.persistence.Convert; +import jakarta.persistence.DiscriminatorValue; +import jakarta.persistence.Embedded; +import jakarta.persistence.Entity; import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmIgnore; import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmProtectedBy; diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/PersonImage.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/PersonImage.java index bbe23d608..78a4c057b 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/PersonImage.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/PersonImage.java @@ -1,10 +1,10 @@ package com.sap.olingo.jpa.processor.core.testmodel; -import javax.persistence.Column; -import javax.persistence.Embedded; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.Table; +import jakarta.persistence.Column; +import jakarta.persistence.Embedded; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.Table; import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmMediaStream; diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/PostalAddressData.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/PostalAddressData.java index d09837da3..ca9bdb264 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/PostalAddressData.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/PostalAddressData.java @@ -2,13 +2,13 @@ import java.util.Collection; -import javax.persistence.Column; -import javax.persistence.Embeddable; -import javax.persistence.FetchType; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; -import javax.persistence.OneToMany; -import javax.persistence.Transient; +import jakarta.persistence.Column; +import jakarta.persistence.Embeddable; +import jakarta.persistence.FetchType; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.OneToMany; +import jakarta.persistence.Transient; import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmDescriptionAssociation; import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmIgnore; @@ -88,27 +88,27 @@ public String getRegion() { return region; } - public void setStreetName(String streetName) { + public void setStreetName(final String streetName) { this.streetName = streetName; } - public void setHouseNumber(String houseNumber) { + public void setHouseNumber(final String houseNumber) { this.houseNumber = houseNumber; } - public void setPOBox(String pOBox) { + public void setPOBox(final String pOBox) { this.pOBox = pOBox; } - public void setCityName(String cityName) { + public void setCityName(final String cityName) { this.cityName = cityName; } - public void setPostalCode(String postalCode) { + public void setPostalCode(final String postalCode) { this.postalCode = postalCode; } - public void setRegion(String region) { + public void setRegion(final String region) { this.region = region; } @@ -129,4 +129,20 @@ public String toString() { return "PostalAddressData [streetName=" + streetName + ", houseNumber=" + houseNumber + ", pOBox=" + pOBox + ", postalCode=" + postalCode + ", cityName=" + cityName + ", country=" + country + ", region=" + region + "]"; } + + public String getRegionCodePublisher() { + return regionCodePublisher; + } + + public void setRegionCodePublisher(final String regionCodePublisher) { + this.regionCodePublisher = regionCodePublisher; + } + + public String getRegionCodeID() { + return regionCodeID; + } + + public void setRegionCodeID(final String regionCodeID) { + this.regionCodeID = regionCodeID; + } } diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/PostalAddressDataWithGroup.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/PostalAddressDataWithGroup.java index cb846db92..faadf14dc 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/PostalAddressDataWithGroup.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/PostalAddressDataWithGroup.java @@ -2,12 +2,12 @@ import java.util.Collection; -import javax.persistence.Column; -import javax.persistence.Embeddable; -import javax.persistence.FetchType; -import javax.persistence.JoinColumn; -import javax.persistence.JoinColumns; -import javax.persistence.OneToMany; +import jakarta.persistence.Column; +import jakarta.persistence.Embeddable; +import jakarta.persistence.FetchType; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.JoinColumns; +import jakarta.persistence.OneToMany; import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmDescriptionAssociation; import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmIgnore; @@ -78,27 +78,27 @@ public String getRegion() { return region; } - public void setStreetName(String streetName) { + public void setStreetName(final String streetName) { this.streetName = streetName; } - public void setHouseNumber(String houseNumber) { + public void setHouseNumber(final String houseNumber) { this.houseNumber = houseNumber; } - public void setPOBox(String pOBox) { + public void setPOBox(final String pOBox) { this.pOBox = pOBox; } - public void setCityName(String cityName) { + public void setCityName(final String cityName) { this.cityName = cityName; } - public void setPostalCode(String postalCode) { + public void setPostalCode(final String postalCode) { this.postalCode = postalCode; } - public void setRegion(String region) { + public void setRegion(final String region) { this.region = region; } @@ -111,4 +111,20 @@ public String toString() { return "PostalAddressData [streetName=" + streetName + ", houseNumber=" + houseNumber + ", pOBox=" + pOBox + ", postalCode=" + postalCode + ", cityName=" + cityName + ", country=" + country + ", region=" + region + "]"; } + + public String getRegionCodePublisher() { + return regionCodePublisher; + } + + public void setRegionCodePublisher(final String regionCodePublisher) { + this.regionCodePublisher = regionCodePublisher; + } + + public String getRegionCodeID() { + return regionCodeID; + } + + public void setRegionCodeID(final String regionCodeID) { + this.regionCodeID = regionCodeID; + } } diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/SalesTeam.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/SalesTeam.java index ce93f0ebd..742b6608a 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/SalesTeam.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/SalesTeam.java @@ -1,8 +1,8 @@ package com.sap.olingo.jpa.processor.core.testmodel; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Table; + +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Table; @Entity(name = "SalesTeam") @Table(schema = "\"OLINGO\"", name = "\"SalesTeam\"") diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/Singleton.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/Singleton.java index 2a5e6f537..3710ae143 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/Singleton.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/Singleton.java @@ -3,13 +3,13 @@ import static com.sap.olingo.jpa.metadata.core.edm.annotation.EdmTopLevelElementRepresentation.AS_SINGLETON; import java.util.List; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.Id; -import javax.persistence.OneToMany; -import javax.persistence.Table; + +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.Id; +import jakarta.persistence.OneToMany; +import jakarta.persistence.Table; import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmEntityType; diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/StreetPropertyCalculator.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/StreetPropertyCalculator.java index 2eba01b33..e8753ba4f 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/StreetPropertyCalculator.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/StreetPropertyCalculator.java @@ -1,9 +1,9 @@ -/** - * +/** + * */ package com.sap.olingo.jpa.processor.core.testmodel; -import javax.persistence.Tuple; +import jakarta.persistence.Tuple; import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmTransientPropertyCalculator; diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/StringConverter.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/StringConverter.java index d75c50603..2203c76e0 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/StringConverter.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/StringConverter.java @@ -1,19 +1,19 @@ package com.sap.olingo.jpa.processor.core.testmodel; -import javax.persistence.AttributeConverter; -import javax.persistence.Converter; +import jakarta.persistence.AttributeConverter; +import jakarta.persistence.Converter; //This converter has to be mentioned at all columns it is applicable @Converter(autoApply = false) public class StringConverter implements AttributeConverter { @Override - public String convertToDatabaseColumn(String entityString) { + public String convertToDatabaseColumn(final String entityString) { return entityString; } @Override - public String convertToEntityAttribute(String dbString) { + public String convertToEntityAttribute(final String dbString) { return dbString; } diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/SupportRelationship.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/SupportRelationship.java index efdad6cd9..598072d60 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/SupportRelationship.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/SupportRelationship.java @@ -1,9 +1,9 @@ package com.sap.olingo.jpa.processor.core.testmodel; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.Table; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.Table; import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmIgnore; diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/Team.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/Team.java index af4f0168e..27d460466 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/Team.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/Team.java @@ -2,11 +2,11 @@ import java.util.List; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.ManyToMany; -import javax.persistence.Table; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.ManyToMany; +import jakarta.persistence.Table; @Entity(name = "Team") @Table(schema = "\"OLINGO\"", name = "\"Team\"") diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/TemporalWithValidityPeriod.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/TemporalWithValidityPeriod.java index 63ba2a287..34b22b8d9 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/TemporalWithValidityPeriod.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/TemporalWithValidityPeriod.java @@ -3,11 +3,11 @@ import java.time.LocalDate; import java.util.Objects; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.IdClass; -import javax.persistence.Table; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.IdClass; +import jakarta.persistence.Table; @Entity() @IdClass(TemporalWithValidityPeriodKey.class) diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/TemporalWithValidityPeriodKey.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/TemporalWithValidityPeriodKey.java index 2a6b09d3f..129c5ee9b 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/TemporalWithValidityPeriodKey.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/TemporalWithValidityPeriodKey.java @@ -4,8 +4,8 @@ import java.time.LocalDate; import java.util.Objects; -import javax.persistence.Column; -import javax.persistence.Id; +import jakarta.persistence.Column; +import jakarta.persistence.Id; public class TemporalWithValidityPeriodKey implements Serializable { diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/TestDataConstants.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/TestDataConstants.java deleted file mode 100644 index c34966fdc..000000000 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/TestDataConstants.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.sap.olingo.jpa.processor.core.testmodel; - -public interface TestDataConstants { - public static final int NO_ATTRIBUTES_POSTAL_ADDRESS = 10; - public static final int NO_ATTRIBUTES_POSTAL_ADDRESS_T = 1; - public static final int NO_ATTRIBUTES_COMMUNICATION_DATA = 4; - public static final int NO_ATTRIBUTES_CHANGE_INFO = 2; - public static final int NO_ATTRIBUTES_BUSINESS_PARTNER = 6; - public static final int NO_ATTRIBUTES_BUSINESS_PARTNER_T = 1; - public static final int NO_ATTRIBUTES_ORGANIZATION = 4; - public static final int NO_ATTRIBUTES_PERSON = 2; - public static final int NO_DEC_ATTRIBUTES_BUSINESS_PARTNER = 9; - public static final int NO_ENTITY_TYPES = 26; - public static final int NO_ENTITY_SETS = 25; - public static final int NO_SINGLETONS = 2; -} diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/TransientRefComplex.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/TransientRefComplex.java index 9a2a34430..df2d204c6 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/TransientRefComplex.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/TransientRefComplex.java @@ -3,12 +3,12 @@ */ package com.sap.olingo.jpa.processor.core.testmodel; -import javax.persistence.Column; -import javax.persistence.Embedded; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.Table; -import javax.persistence.Transient; +import jakarta.persistence.Column; +import jakarta.persistence.Embedded; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.Table; +import jakarta.persistence.Transient; import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmTransient; diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/TransientRefIgnore.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/TransientRefIgnore.java index ecbc06475..125b1fcaa 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/TransientRefIgnore.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/TransientRefIgnore.java @@ -3,11 +3,11 @@ */ package com.sap.olingo.jpa.processor.core.testmodel; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.Table; -import javax.persistence.Transient; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.Table; +import jakarta.persistence.Transient; import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmIgnore; import com.sap.olingo.jpa.metadata.core.edm.annotation.EdmTransient; diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/UUIDToBinaryConverter.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/UUIDToBinaryConverter.java index 0bb0e02ca..9a720a26a 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/UUIDToBinaryConverter.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/UUIDToBinaryConverter.java @@ -3,8 +3,8 @@ import java.nio.ByteBuffer; import java.util.UUID; -import javax.persistence.AttributeConverter; -import javax.persistence.Converter; +import jakarta.persistence.AttributeConverter; +import jakarta.persistence.Converter; /** * Default converter to convert from {@link java.util.UUID} to a byte array. @@ -20,8 +20,8 @@ public byte[] convertToDatabaseColumn(final UUID uuid) { } private byte[] convertToBytes(final UUID uuid) { - byte[] buffer = new byte[16]; - ByteBuffer bb = ByteBuffer.wrap(buffer); + final byte[] buffer = new byte[16]; + final ByteBuffer bb = ByteBuffer.wrap(buffer); bb.putLong(uuid.getMostSignificantBits()); bb.putLong(uuid.getLeastSignificantBits()); return buffer; @@ -31,11 +31,11 @@ private byte[] convertToBytes(final UUID uuid) { public UUID convertToEntityAttribute(final byte[] bytes) { return bytes == null ? null : convertToUUID(bytes); } - - private UUID convertToUUID(byte[] bytes) { - ByteBuffer bb = ByteBuffer.wrap(bytes); - long high = bb.getLong(); - long low = bb.getLong(); + + private UUID convertToUUID(final byte[] bytes) { + final ByteBuffer bb = ByteBuffer.wrap(bytes); + final long high = bb.getLong(); + final long low = bb.getLong(); return new UUID(high, low); } } diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/UUIDToStringConverter.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/UUIDToStringConverter.java index 143f54ffd..b8d46467e 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/UUIDToStringConverter.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/UUIDToStringConverter.java @@ -2,8 +2,8 @@ import java.util.UUID; -import javax.persistence.AttributeConverter; -import javax.persistence.Converter; +import jakarta.persistence.AttributeConverter; +import jakarta.persistence.Converter; /** * Default converter to convert from {@link java.util.UUID} to a byte array. diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/User.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/User.java index 1d5789c04..10008883e 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/User.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/testmodel/User.java @@ -1,9 +1,9 @@ package com.sap.olingo.jpa.processor.core.testmodel; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.Table; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.Table; @Entity @Table(schema = "\"OLINGO\"", name = "\"User\"") diff --git a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/util/ServletInputStreamDouble.java b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/util/ServletInputStreamDouble.java index 95d4302bd..81baaecf6 100644 --- a/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/util/ServletInputStreamDouble.java +++ b/jpa/odata-jpa-test/src/main/java/com/sap/olingo/jpa/processor/core/util/ServletInputStreamDouble.java @@ -4,8 +4,9 @@ import java.io.IOException; import java.io.InputStream; import java.nio.charset.StandardCharsets; - -import javax.servlet.ServletInputStream; + +import jakarta.servlet.ReadListener; +import jakarta.servlet.ServletInputStream; public class ServletInputStreamDouble extends ServletInputStream { private final InputStream stream; @@ -27,5 +28,20 @@ public ServletInputStreamDouble(final StringBuilder stream) { public int read() throws IOException { return stream.read(); } + + @Override + public boolean isFinished() { + return false; + } + + @Override + public boolean isReady() { + return true; + } + @Override + public void setReadListener(final ReadListener readListener) { + throw new IllegalAccessError(); + } + } diff --git a/jpa/odata-jpa-test/src/main/resources/META-INF/persistence.xml b/jpa/odata-jpa-test/src/main/resources/META-INF/persistence.xml index b647c14d3..d26268c0f 100644 --- a/jpa/odata-jpa-test/src/main/resources/META-INF/persistence.xml +++ b/jpa/odata-jpa-test/src/main/resources/META-INF/persistence.xml @@ -1,8 +1,8 @@ - + xsi:schemaLocation="https://jakarta.ee/xml/ns/persistence https://jakarta.ee/xml/ns/persistence/persistence_3_0.xsd" > @@ -93,7 +93,7 @@ com.sap.olingo.jpa.processor.core.testmodel.DetailSettings true - + @@ -138,7 +138,7 @@ com.sap.olingo.jpa.processor.core.errormodel.TeamWithTransientEmbeddableKey com.sap.olingo.jpa.processor.core.errormodel.SingletonAsEntitySet com.sap.olingo.jpa.processor.core.testmodel.LocalDateTimeConverter - com.sap.olingo.jpa.processor.core.errormodel.MissingCardinalityAnnotation + com.sap.olingo.jpa.processor.core.errormodel.MissingCardinalityAnnotation true diff --git a/jpa/odata-jpa-test/src/test/java/com/sap/olingo/jpa/processor/test/AbstractConverterTest.java b/jpa/odata-jpa-test/src/test/java/com/sap/olingo/jpa/processor/test/AbstractConverterTest.java index 850e6bed7..76420f106 100644 --- a/jpa/odata-jpa-test/src/test/java/com/sap/olingo/jpa/processor/test/AbstractConverterTest.java +++ b/jpa/odata-jpa-test/src/test/java/com/sap/olingo/jpa/processor/test/AbstractConverterTest.java @@ -3,7 +3,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNull; -import javax.persistence.AttributeConverter; +import jakarta.persistence.AttributeConverter; import org.junit.jupiter.api.Test; diff --git a/jpa/odata-jpa-test/src/test/java/com/sap/olingo/jpa/processor/test/TestAssociations.java b/jpa/odata-jpa-test/src/test/java/com/sap/olingo/jpa/processor/test/TestAssociations.java index 6f4940658..0f1b35c42 100644 --- a/jpa/odata-jpa-test/src/test/java/com/sap/olingo/jpa/processor/test/TestAssociations.java +++ b/jpa/odata-jpa-test/src/test/java/com/sap/olingo/jpa/processor/test/TestAssociations.java @@ -7,14 +7,14 @@ import java.util.List; import java.util.Map; -import javax.persistence.EntityManager; -import javax.persistence.EntityManagerFactory; -import javax.persistence.Persistence; -import javax.persistence.Tuple; -import javax.persistence.TypedQuery; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.CriteriaQuery; -import javax.persistence.criteria.Root; +import jakarta.persistence.EntityManager; +import jakarta.persistence.EntityManagerFactory; +import jakarta.persistence.Persistence; +import jakarta.persistence.Tuple; +import jakarta.persistence.TypedQuery; +import jakarta.persistence.criteria.CriteriaBuilder; +import jakarta.persistence.criteria.CriteriaQuery; +import jakarta.persistence.criteria.Root; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; @@ -29,7 +29,7 @@ class TestAssociations { protected static final String PUNIT_NAME = "com.sap.olingo.jpa"; - private static final String ENTITY_MANAGER_DATA_SOURCE = "javax.persistence.nonJtaDataSource"; + private static final String ENTITY_MANAGER_DATA_SOURCE = "jakarta.persistence.nonJtaDataSource"; private static EntityManagerFactory emf; private EntityManager em; private CriteriaBuilder cb; diff --git a/jpa/odata-jpa-test/src/test/java/com/sap/olingo/jpa/processor/test/TestCriteriaBuilder.java b/jpa/odata-jpa-test/src/test/java/com/sap/olingo/jpa/processor/test/TestCriteriaBuilder.java index 760760e7f..9c2bf4f6d 100644 --- a/jpa/odata-jpa-test/src/test/java/com/sap/olingo/jpa/processor/test/TestCriteriaBuilder.java +++ b/jpa/odata-jpa-test/src/test/java/com/sap/olingo/jpa/processor/test/TestCriteriaBuilder.java @@ -10,20 +10,20 @@ import java.util.List; import java.util.Map; -import javax.persistence.EntityManager; -import javax.persistence.EntityManagerFactory; -import javax.persistence.Persistence; -import javax.persistence.Tuple; -import javax.persistence.TypedQuery; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.CriteriaBuilder.In; -import javax.persistence.criteria.CriteriaQuery; -import javax.persistence.criteria.Expression; -import javax.persistence.criteria.Join; -import javax.persistence.criteria.Path; -import javax.persistence.criteria.Predicate; -import javax.persistence.criteria.Root; -import javax.persistence.criteria.Subquery; +import jakarta.persistence.EntityManager; +import jakarta.persistence.EntityManagerFactory; +import jakarta.persistence.Persistence; +import jakarta.persistence.Tuple; +import jakarta.persistence.TypedQuery; +import jakarta.persistence.criteria.CriteriaBuilder; +import jakarta.persistence.criteria.CriteriaBuilder.In; +import jakarta.persistence.criteria.CriteriaQuery; +import jakarta.persistence.criteria.Expression; +import jakarta.persistence.criteria.Join; +import jakarta.persistence.criteria.Path; +import jakarta.persistence.criteria.Predicate; +import jakarta.persistence.criteria.Root; +import jakarta.persistence.criteria.Subquery; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; @@ -44,7 +44,7 @@ class TestCriteriaBuilder { protected static final String PUNIT_NAME = "com.sap.olingo.jpa"; - private static final String ENTITY_MANAGER_DATA_SOURCE = "javax.persistence.nonJtaDataSource"; + private static final String ENTITY_MANAGER_DATA_SOURCE = "jakarta.persistence.nonJtaDataSource"; private static EntityManagerFactory emf; private EntityManager em; private CriteriaBuilder cb; @@ -289,8 +289,8 @@ void testInClauseComplexKey() { if ("org.apache.openjpa.persistence.criteria.CriteriaBuilderImpl".equals(cb.getClass().getCanonicalName())) assertEquals(1, act.size()); else - // Ensure EclipseLink problem still exists: ("WHERE ((NULL, NULL, NULL, NULL) IN ")); - assertEquals(0, act.size()); + // EclipseLink problem has been solved: ("WHERE ((NULL, NULL, NULL, NULL) IN ")); + assertEquals(1, act.size()); } @Test diff --git a/jpa/odata-jpa-test/src/test/java/com/sap/olingo/jpa/processor/test/TestEqualHashCodeMethods.java b/jpa/odata-jpa-test/src/test/java/com/sap/olingo/jpa/processor/test/TestEqualHashCodeMethods.java index 5a02c8ed4..9b66306d7 100644 --- a/jpa/odata-jpa-test/src/test/java/com/sap/olingo/jpa/processor/test/TestEqualHashCodeMethods.java +++ b/jpa/odata-jpa-test/src/test/java/com/sap/olingo/jpa/processor/test/TestEqualHashCodeMethods.java @@ -22,10 +22,10 @@ import java.util.Set; import java.util.stream.Stream; -import javax.persistence.metamodel.EntityType; -import javax.persistence.metamodel.Metamodel; -import javax.persistence.metamodel.SingularAttribute; -import javax.persistence.metamodel.Type.PersistenceType; +import jakarta.persistence.metamodel.EntityType; +import jakarta.persistence.metamodel.Metamodel; +import jakarta.persistence.metamodel.SingularAttribute; +import jakarta.persistence.metamodel.Type.PersistenceType; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.MethodSource; @@ -36,7 +36,7 @@ * */ abstract class TestEqualHashCodeMethods { - + protected static final String ENTITY_MANAGER_DATA_SOURCE = "jakarta.persistence.nonJtaDataSource"; protected static Metamodel model; @SuppressWarnings({ "rawtypes" }) diff --git a/jpa/odata-jpa-test/src/test/java/com/sap/olingo/jpa/processor/test/TestEqualHashCodeMethodsErrorModel.java b/jpa/odata-jpa-test/src/test/java/com/sap/olingo/jpa/processor/test/TestEqualHashCodeMethodsErrorModel.java index 22d45064e..202ff7865 100644 --- a/jpa/odata-jpa-test/src/test/java/com/sap/olingo/jpa/processor/test/TestEqualHashCodeMethodsErrorModel.java +++ b/jpa/odata-jpa-test/src/test/java/com/sap/olingo/jpa/processor/test/TestEqualHashCodeMethodsErrorModel.java @@ -1,13 +1,13 @@ /** - * + * */ package com.sap.olingo.jpa.processor.test; import java.util.HashMap; import java.util.Map; -import javax.persistence.EntityManagerFactory; -import javax.persistence.Persistence; +import jakarta.persistence.EntityManagerFactory; +import jakarta.persistence.Persistence; import org.junit.jupiter.api.BeforeAll; @@ -20,11 +20,10 @@ */ public class TestEqualHashCodeMethodsErrorModel extends TestEqualHashCodeMethods { private static final String PUNIT_NAME = "error"; - private static final String ENTITY_MANAGER_DATA_SOURCE = "javax.persistence.nonJtaDataSource"; @BeforeAll public static void setupClass() { - Map properties = new HashMap<>(); + final Map properties = new HashMap<>(); properties.put(ENTITY_MANAGER_DATA_SOURCE, DataSourceHelper.createDataSource( DataSourceHelper.DB_HSQLDB)); final EntityManagerFactory emf = Persistence.createEntityManagerFactory(PUNIT_NAME, properties); diff --git a/jpa/odata-jpa-test/src/test/java/com/sap/olingo/jpa/processor/test/TestEqualHashCodeMethodsTestModel.java b/jpa/odata-jpa-test/src/test/java/com/sap/olingo/jpa/processor/test/TestEqualHashCodeMethodsTestModel.java index 5c56bacc4..9349cad29 100644 --- a/jpa/odata-jpa-test/src/test/java/com/sap/olingo/jpa/processor/test/TestEqualHashCodeMethodsTestModel.java +++ b/jpa/odata-jpa-test/src/test/java/com/sap/olingo/jpa/processor/test/TestEqualHashCodeMethodsTestModel.java @@ -8,9 +8,6 @@ import java.util.HashMap; import java.util.Map; -import javax.persistence.EntityManagerFactory; -import javax.persistence.Persistence; - import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; @@ -21,6 +18,9 @@ import com.sap.olingo.jpa.processor.core.testmodel.MembershipKey; import com.sap.olingo.jpa.processor.core.testmodel.TemporalWithValidityPeriodKey; +import jakarta.persistence.EntityManagerFactory; +import jakarta.persistence.Persistence; + /** * @author Oliver Grande * Created: 11.11.2019 @@ -28,7 +28,6 @@ */ class TestEqualHashCodeMethodsTestModel extends TestEqualHashCodeMethods { private static final String PUNIT_NAME = "com.sap.olingo.jpa"; - private static final String ENTITY_MANAGER_DATA_SOURCE = "javax.persistence.nonJtaDataSource"; @BeforeAll public static void setupClass() { diff --git a/jpa/odata-jpa-test/src/test/java/com/sap/olingo/jpa/processor/test/TestFunctions.java b/jpa/odata-jpa-test/src/test/java/com/sap/olingo/jpa/processor/test/TestFunctions.java index edc5490f1..a8deebfd9 100644 --- a/jpa/odata-jpa-test/src/test/java/com/sap/olingo/jpa/processor/test/TestFunctions.java +++ b/jpa/odata-jpa-test/src/test/java/com/sap/olingo/jpa/processor/test/TestFunctions.java @@ -10,20 +10,21 @@ import java.util.List; import java.util.Map; -import javax.persistence.EntityManager; -import javax.persistence.EntityManagerFactory; -import javax.persistence.EntityTransaction; -import javax.persistence.ParameterMode; -import javax.persistence.Persistence; -import javax.persistence.Query; -import javax.persistence.StoredProcedureQuery; -import javax.persistence.Tuple; -import javax.persistence.TypedQuery; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.CriteriaQuery; -import javax.persistence.criteria.Root; import javax.sql.DataSource; +import jakarta.persistence.EntityManager; +import jakarta.persistence.EntityManagerFactory; +import jakarta.persistence.EntityTransaction; +import jakarta.persistence.ParameterMode; +import jakarta.persistence.Persistence; +import jakarta.persistence.Query; +import jakarta.persistence.StoredProcedureQuery; +import jakarta.persistence.Tuple; +import jakarta.persistence.TypedQuery; +import jakarta.persistence.criteria.CriteriaBuilder; +import jakarta.persistence.criteria.CriteriaQuery; +import jakarta.persistence.criteria.Root; + import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Disabled; @@ -34,7 +35,7 @@ class TestFunctions { protected static final String PUNIT_NAME = "com.sap.olingo.jpa"; - private static final String ENTITY_MANAGER_DATA_SOURCE = "javax.persistence.nonJtaDataSource"; + private static final String ENTITY_MANAGER_DATA_SOURCE = "jakarta.persistence.nonJtaDataSource"; private static EntityManagerFactory emf; private static DataSource ds; diff --git a/jpa/odata-jpa-test/src/test/java/com/sap/olingo/jpa/processor/test/TestFunctionsHSQLDB.java b/jpa/odata-jpa-test/src/test/java/com/sap/olingo/jpa/processor/test/TestFunctionsHSQLDB.java index 94448e13b..0e3cfefdb 100644 --- a/jpa/odata-jpa-test/src/test/java/com/sap/olingo/jpa/processor/test/TestFunctionsHSQLDB.java +++ b/jpa/odata-jpa-test/src/test/java/com/sap/olingo/jpa/processor/test/TestFunctionsHSQLDB.java @@ -6,18 +6,19 @@ import java.util.List; import java.util.Map; -import javax.persistence.EntityManager; -import javax.persistence.EntityManagerFactory; -import javax.persistence.EntityTransaction; -import javax.persistence.Persistence; -import javax.persistence.Query; -import javax.persistence.Tuple; -import javax.persistence.TypedQuery; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.CriteriaQuery; -import javax.persistence.criteria.Root; import javax.sql.DataSource; +import jakarta.persistence.EntityManager; +import jakarta.persistence.EntityManagerFactory; +import jakarta.persistence.EntityTransaction; +import jakarta.persistence.Persistence; +import jakarta.persistence.Query; +import jakarta.persistence.Tuple; +import jakarta.persistence.TypedQuery; +import jakarta.persistence.criteria.CriteriaBuilder; +import jakarta.persistence.criteria.CriteriaQuery; +import jakarta.persistence.criteria.Root; + import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -27,7 +28,7 @@ class TestFunctionsHSQLDB { protected static final String PUNIT_NAME = "com.sap.olingo.jpa"; - private static final String ENTITY_MANAGER_DATA_SOURCE = "javax.persistence.nonJtaDataSource"; + private static final String ENTITY_MANAGER_DATA_SOURCE = "jakarta.persistence.nonJtaDataSource"; private static EntityManagerFactory emf; private static DataSource ds; diff --git a/jpa/odata-jpa-test/src/test/java/com/sap/olingo/jpa/processor/test/TransientPropertyCalculatorTwoConstructorsTest.java b/jpa/odata-jpa-test/src/test/java/com/sap/olingo/jpa/processor/test/TransientPropertyCalculatorTwoConstructorsTest.java index 81df07724..c0de2fa4e 100644 --- a/jpa/odata-jpa-test/src/test/java/com/sap/olingo/jpa/processor/test/TransientPropertyCalculatorTwoConstructorsTest.java +++ b/jpa/odata-jpa-test/src/test/java/com/sap/olingo/jpa/processor/test/TransientPropertyCalculatorTwoConstructorsTest.java @@ -4,7 +4,7 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.mockito.Mockito.mock; -import javax.persistence.EntityManager; +import jakarta.persistence.EntityManager; import org.junit.jupiter.api.Test; diff --git a/jpa/odata-jpa-test/src/test/java/com/sap/olingo/jpa/processor/test/TransientPropertyCalculatorWrongConstructorTest.java b/jpa/odata-jpa-test/src/test/java/com/sap/olingo/jpa/processor/test/TransientPropertyCalculatorWrongConstructorTest.java index 4458e0598..843b09fac 100644 --- a/jpa/odata-jpa-test/src/test/java/com/sap/olingo/jpa/processor/test/TransientPropertyCalculatorWrongConstructorTest.java +++ b/jpa/odata-jpa-test/src/test/java/com/sap/olingo/jpa/processor/test/TransientPropertyCalculatorWrongConstructorTest.java @@ -4,7 +4,7 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.mockito.Mockito.mock; -import javax.persistence.EntityManager; +import jakarta.persistence.EntityManager; import org.junit.jupiter.api.Test; diff --git a/jpa/odata-jpa-vocabularies/pom.xml b/jpa/odata-jpa-vocabularies/pom.xml index 7a3b6ac15..2897b1120 100644 --- a/jpa/odata-jpa-vocabularies/pom.xml +++ b/jpa/odata-jpa-vocabularies/pom.xml @@ -3,7 +3,7 @@ com.sap.olingo odata-jpa - 1.1.1 + 2.0.0 odata-jpa-vocabularies odata-jpa-vocabularies @@ -35,19 +35,19 @@ org.junit.jupiter junit-jupiter - 5.9.1 + ${junit.version} test org.junit.platform junit-platform-launcher - 1.9.1 + ${junit-platform.version} test org.mockito mockito-core - 3.6.0 + ${mockito.version} test diff --git a/jpa/odata-jpa-vocabularies/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/vocabularies/Action.java b/jpa/odata-jpa-vocabularies/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/vocabularies/Action.java index a806fa2e5..2718e0c0d 100644 --- a/jpa/odata-jpa-vocabularies/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/vocabularies/Action.java +++ b/jpa/odata-jpa-vocabularies/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/vocabularies/Action.java @@ -1,43 +1,43 @@ -package com.sap.olingo.jpa.metadata.core.edm.mapper.vocabularies; - -import java.util.Arrays; -import java.util.Objects; - -import org.apache.olingo.commons.api.edm.provider.CsdlAction; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; - -@JsonIgnoreProperties(ignoreUnknown = true) -public class Action extends CsdlAction { - - @Override - @JacksonXmlProperty(localName = "Name") - public CsdlAction setName(final String name) { - Objects.requireNonNull(name, "Name is a required attribute of actions"); - return super.setName(name); - } - - @Override - @JacksonXmlProperty(localName = "IsBound") - public CsdlAction setBound(final boolean isBound) { - return super.setBound(isBound); - } - - @Override - @JacksonXmlProperty(localName = "EntitySetPath") - public CsdlAction setEntitySetPath(String entitySetPath) { - return super.setEntitySetPath(entitySetPath); - } - - @JacksonXmlProperty(localName = "Parameter") - public void setParameters(final Parameter[] parameters) { - this.parameters.addAll(Arrays.asList(parameters)); - } - - @JacksonXmlProperty(localName = "ReturnType") - public void setReturnType(final ReturnType returnType) { - super.setReturnType(returnType); - } - -} +package com.sap.olingo.jpa.metadata.core.edm.mapper.vocabularies; + +import java.util.Arrays; +import java.util.Objects; + +import org.apache.olingo.commons.api.edm.provider.CsdlAction; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class Action extends CsdlAction { + + @Override + @JacksonXmlProperty(localName = "Name") + public CsdlAction setName(final String name) { + Objects.requireNonNull(name, "Name is a required attribute of actions"); + return super.setName(name); + } + + @Override + @JacksonXmlProperty(localName = "IsBound") + public CsdlAction setBound(final boolean isBound) { + return super.setBound(isBound); + } + + @Override + @JacksonXmlProperty(localName = "EntitySetPath") + public CsdlAction setEntitySetPath(String entitySetPath) { + return super.setEntitySetPath(entitySetPath); + } + + @JacksonXmlProperty(localName = "Parameter") + public void setParameters(final Parameter[] parameters) { + this.parameters.addAll(Arrays.asList(parameters)); + } + + @JacksonXmlProperty(localName = "ReturnType") + public void setReturnType(final ReturnType returnType) { + super.setReturnType(returnType); + } + +} diff --git a/jpa/odata-jpa-vocabularies/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/vocabularies/CsdlDocumentReader.java b/jpa/odata-jpa-vocabularies/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/vocabularies/CsdlDocumentReader.java index 97ee84d07..dcf110846 100644 --- a/jpa/odata-jpa-vocabularies/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/vocabularies/CsdlDocumentReader.java +++ b/jpa/odata-jpa-vocabularies/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/vocabularies/CsdlDocumentReader.java @@ -1,89 +1,89 @@ -package com.sap.olingo.jpa.metadata.core.edm.mapper.vocabularies; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.net.URI; -import java.nio.charset.Charset; -import java.util.Objects; -import java.util.Optional; - -import javax.annotation.Nonnull; - -import com.fasterxml.jackson.dataformat.xml.JacksonXmlModule; -import com.fasterxml.jackson.dataformat.xml.XmlMapper; -import com.sap.olingo.jpa.metadata.core.edm.mapper.vocabularies.ODataJPAVocabulariesException.MessageKeys; - -/** - * - * @author Oliver Grande - * @since 15.12.2019 - * @version 0.3.8 - * - */ -public class CsdlDocumentReader { - final JacksonXmlModule module; - final XmlMapper xmlMapper; - - /** - * - */ - public CsdlDocumentReader() { - super(); - module = new JacksonXmlModule(); - module.setDefaultUseWrapper(false); - xmlMapper = new XmlMapper(module); - } - -//vocabularies - String loadXML(@Nonnull final String path, @Nonnull final Charset charset) throws IOException, - ODataJPAVocabulariesException { - - final Optional reader = Optional.ofNullable(this.getClass().getClassLoader() - .getResourceAsStream(path)); - final StringBuilder content = new StringBuilder(); - - try ( - final InputStreamReader input = new InputStreamReader(reader.orElseThrow( - () -> new ODataJPAVocabulariesException(MessageKeys.FILE_NOT_FOUND, path)), charset); - final BufferedReader br = new BufferedReader(input)) { - String line; - while ((line = br.readLine()) != null) { - content.append(line); - } - return content.toString(); - } - } - - /** - * - * @param path - * @param charset - * @return - * @throws IOException - * @throws ODataJPAVocabulariesException - * @throws ODataJPAModelException - * @throws NullPointerException - */ - public CsdlDocument readFromResource(@Nonnull final String path, @Nonnull final Charset charset) - throws IOException, ODataJPAVocabulariesException { - - if (Objects.requireNonNull(path).isEmpty()) - return null; - return xmlMapper.readValue(loadXML(path, Objects.requireNonNull(charset)), - CsdlDocument.class); - } - - /** - * - * @param uri - * @return - * @throws IOException - * @throws NullPointerException - */ - public CsdlDocument readFromURI(@Nonnull final URI uri) throws IOException { - - return xmlMapper.readValue(Objects.requireNonNull(uri).toURL(), CsdlDocument.class); - } +package com.sap.olingo.jpa.metadata.core.edm.mapper.vocabularies; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.net.URI; +import java.nio.charset.Charset; +import java.util.Objects; +import java.util.Optional; + +import javax.annotation.Nonnull; + +import com.fasterxml.jackson.dataformat.xml.JacksonXmlModule; +import com.fasterxml.jackson.dataformat.xml.XmlMapper; +import com.sap.olingo.jpa.metadata.core.edm.mapper.vocabularies.ODataJPAVocabulariesException.MessageKeys; + +/** + * + * @author Oliver Grande + * @since 15.12.2019 + * @version 0.3.8 + * + */ +public class CsdlDocumentReader { + final JacksonXmlModule module; + final XmlMapper xmlMapper; + + /** + * + */ + public CsdlDocumentReader() { + super(); + module = new JacksonXmlModule(); + module.setDefaultUseWrapper(false); + xmlMapper = new XmlMapper(module); + } + +//vocabularies + String loadXML(@Nonnull final String path, @Nonnull final Charset charset) throws IOException, + ODataJPAVocabulariesException { + + final Optional reader = Optional.ofNullable(this.getClass().getClassLoader() + .getResourceAsStream(path)); + final StringBuilder content = new StringBuilder(); + + try ( + final InputStreamReader input = new InputStreamReader(reader.orElseThrow( + () -> new ODataJPAVocabulariesException(MessageKeys.FILE_NOT_FOUND, path)), charset); + final BufferedReader br = new BufferedReader(input)) { + String line; + while ((line = br.readLine()) != null) { + content.append(line); + } + return content.toString(); + } + } + + /** + * + * @param path + * @param charset + * @return + * @throws IOException + * @throws ODataJPAVocabulariesException + * @throws ODataJPAModelException + * @throws NullPointerException + */ + public CsdlDocument readFromResource(@Nonnull final String path, @Nonnull final Charset charset) + throws IOException, ODataJPAVocabulariesException { + + if (Objects.requireNonNull(path).isEmpty()) + return null; + return xmlMapper.readValue(loadXML(path, Objects.requireNonNull(charset)), + CsdlDocument.class); + } + + /** + * + * @param uri + * @return + * @throws IOException + * @throws NullPointerException + */ + public CsdlDocument readFromURI(@Nonnull final URI uri) throws IOException { + + return xmlMapper.readValue(Objects.requireNonNull(uri).toURL(), CsdlDocument.class); + } } \ No newline at end of file diff --git a/jpa/odata-jpa-vocabularies/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/vocabularies/EdmxReference.java b/jpa/odata-jpa-vocabularies/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/vocabularies/EdmxReference.java index eb53521c5..6ae36b15e 100644 --- a/jpa/odata-jpa-vocabularies/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/vocabularies/EdmxReference.java +++ b/jpa/odata-jpa-vocabularies/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/vocabularies/EdmxReference.java @@ -1,29 +1,29 @@ -package com.sap.olingo.jpa.metadata.core.edm.mapper.vocabularies; - -import java.net.URI; -import java.util.Arrays; -import java.util.List; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; -import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; - -@JsonIgnoreProperties(ignoreUnknown = true) -@JacksonXmlRootElement(localName = "Reference", namespace = "edmx") -public class EdmxReference { - - @JacksonXmlProperty(localName = "Uri") - private String uri; - - @JacksonXmlProperty(localName = "Include") - private EdmxReferenceInclude[] includes; - - public URI getUri() { - return URI.create(uri); - } - - public List getIncludes() { - return Arrays.asList(includes); - } - -} +package com.sap.olingo.jpa.metadata.core.edm.mapper.vocabularies; + +import java.net.URI; +import java.util.Arrays; +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; + +@JsonIgnoreProperties(ignoreUnknown = true) +@JacksonXmlRootElement(localName = "Reference", namespace = "edmx") +public class EdmxReference { + + @JacksonXmlProperty(localName = "Uri") + private String uri; + + @JacksonXmlProperty(localName = "Include") + private EdmxReferenceInclude[] includes; + + public URI getUri() { + return URI.create(uri); + } + + public List getIncludes() { + return Arrays.asList(includes); + } + +} diff --git a/jpa/odata-jpa-vocabularies/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/vocabularies/EdmxReferenceInclude.java b/jpa/odata-jpa-vocabularies/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/vocabularies/EdmxReferenceInclude.java index 8e942a3cb..d4501a9bd 100644 --- a/jpa/odata-jpa-vocabularies/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/vocabularies/EdmxReferenceInclude.java +++ b/jpa/odata-jpa-vocabularies/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/vocabularies/EdmxReferenceInclude.java @@ -1,25 +1,25 @@ -package com.sap.olingo.jpa.metadata.core.edm.mapper.vocabularies; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; -import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; - -@JsonIgnoreProperties(ignoreUnknown = true) -@JacksonXmlRootElement(localName = "Reference", namespace = "edmx") -public class EdmxReferenceInclude { - - @JacksonXmlProperty(localName = "Namespace") - private String namespace; - - @JacksonXmlProperty(localName = "Alias") - private String alias; - - public String getNamespace() { - return namespace; - } - - public String getAlias() { - return alias; - } - -} +package com.sap.olingo.jpa.metadata.core.edm.mapper.vocabularies; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; + +@JsonIgnoreProperties(ignoreUnknown = true) +@JacksonXmlRootElement(localName = "Reference", namespace = "edmx") +public class EdmxReferenceInclude { + + @JacksonXmlProperty(localName = "Namespace") + private String namespace; + + @JacksonXmlProperty(localName = "Alias") + private String alias; + + public String getNamespace() { + return namespace; + } + + public String getAlias() { + return alias; + } + +} diff --git a/jpa/odata-jpa-vocabularies/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/vocabularies/Function.java b/jpa/odata-jpa-vocabularies/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/vocabularies/Function.java index 552dafa1d..ae86dc7bd 100644 --- a/jpa/odata-jpa-vocabularies/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/vocabularies/Function.java +++ b/jpa/odata-jpa-vocabularies/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/vocabularies/Function.java @@ -1,53 +1,53 @@ -package com.sap.olingo.jpa.metadata.core.edm.mapper.vocabularies; - -import java.util.Arrays; -import java.util.Objects; - -import org.apache.olingo.commons.api.edm.provider.CsdlFunction; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; - -/** - * Function as part of a OData vocabulary.
            - * @author Oliver Grande - * - */ -@JsonIgnoreProperties(ignoreUnknown = true) -public class Function extends CsdlFunction { - - @Override - @JacksonXmlProperty(localName = "IsBound") - public CsdlFunction setBound(final boolean isBound) { - return super.setBound(isBound); - } - - @Override - @JacksonXmlProperty(localName = "IsComposable") - public CsdlFunction setComposable(final boolean isComposable) { - return super.setComposable(isComposable); - } - - @Override - @JacksonXmlProperty(localName = "EntitySetPath") - public CsdlFunction setEntitySetPath(String entitySetPath) { - return super.setEntitySetPath(entitySetPath); - } - - @Override - @JacksonXmlProperty(localName = "Name") - public CsdlFunction setName(final String name) { - Objects.requireNonNull(name, "Name is a required attribute of functions"); - return super.setName(name); - } - - @JacksonXmlProperty(localName = "Parameter") - public void setParameters(final Parameter[] parameters) { - this.parameters.addAll(Arrays.asList(parameters)); - } - - @JacksonXmlProperty(localName = "ReturnType") - public void setReturnType(final ReturnType returnType) { - super.setReturnType(returnType); - } -} \ No newline at end of file +package com.sap.olingo.jpa.metadata.core.edm.mapper.vocabularies; + +import java.util.Arrays; +import java.util.Objects; + +import org.apache.olingo.commons.api.edm.provider.CsdlFunction; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; + +/** + * Function as part of a OData vocabulary.
            + * @author Oliver Grande + * + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class Function extends CsdlFunction { + + @Override + @JacksonXmlProperty(localName = "IsBound") + public CsdlFunction setBound(final boolean isBound) { + return super.setBound(isBound); + } + + @Override + @JacksonXmlProperty(localName = "IsComposable") + public CsdlFunction setComposable(final boolean isComposable) { + return super.setComposable(isComposable); + } + + @Override + @JacksonXmlProperty(localName = "EntitySetPath") + public CsdlFunction setEntitySetPath(String entitySetPath) { + return super.setEntitySetPath(entitySetPath); + } + + @Override + @JacksonXmlProperty(localName = "Name") + public CsdlFunction setName(final String name) { + Objects.requireNonNull(name, "Name is a required attribute of functions"); + return super.setName(name); + } + + @JacksonXmlProperty(localName = "Parameter") + public void setParameters(final Parameter[] parameters) { + this.parameters.addAll(Arrays.asList(parameters)); + } + + @JacksonXmlProperty(localName = "ReturnType") + public void setReturnType(final ReturnType returnType) { + super.setReturnType(returnType); + } +} diff --git a/jpa/odata-jpa-vocabularies/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/vocabularies/Parameter.java b/jpa/odata-jpa-vocabularies/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/vocabularies/Parameter.java index dfa9bb6a3..3b7e6d3cf 100644 --- a/jpa/odata-jpa-vocabularies/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/vocabularies/Parameter.java +++ b/jpa/odata-jpa-vocabularies/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/vocabularies/Parameter.java @@ -1,62 +1,62 @@ -package com.sap.olingo.jpa.metadata.core.edm.mapper.vocabularies; - -import java.util.Objects; - -import org.apache.olingo.commons.api.edm.FullQualifiedName; -import org.apache.olingo.commons.api.edm.geo.SRID; -import org.apache.olingo.commons.api.edm.provider.CsdlParameter; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; - -@JsonIgnoreProperties(ignoreUnknown = true) -public class Parameter extends CsdlParameter { - - @Override - @JacksonXmlProperty(localName = "Name") - public CsdlParameter setName(final String name) { - Objects.requireNonNull(name, "Name is a required attribute of parameter"); - return super.setName(name); - } - - @Override - @JacksonXmlProperty(localName = "Type") - public CsdlParameter setType(final String type) { - Objects.requireNonNull(type, "Type is a required attribute of parameters"); - if (type.startsWith("Collection")) { - setCollection(true); - return super.setType(new FullQualifiedName(type.split("[()]")[1])); - } - return super.setType(new FullQualifiedName(type)); - } - - @Override - @JacksonXmlProperty(localName = "Nullable") - public CsdlParameter setNullable(final boolean nullable) { - return super.setNullable(nullable); - } - - @Override - @JacksonXmlProperty(localName = "MaxLength", isAttribute = true) - public CsdlParameter setMaxLength(Integer maxLength) { - return super.setMaxLength(maxLength); - } - - @Override - @JacksonXmlProperty(localName = "Precision", isAttribute = true) - public CsdlParameter setPrecision(final Integer precision) { - return super.setPrecision(precision); - } - - @Override - @JacksonXmlProperty(localName = "Scale", isAttribute = true) - public CsdlParameter setScale(final Integer scale) { - return super.setScale(scale); - } - - @JacksonXmlProperty(localName = "SRID", isAttribute = true) - void setSrid(final String srid) { - Objects.requireNonNull(srid); - super.setSrid(SRID.valueOf(srid)); - } -} \ No newline at end of file +package com.sap.olingo.jpa.metadata.core.edm.mapper.vocabularies; + +import java.util.Objects; + +import org.apache.olingo.commons.api.edm.FullQualifiedName; +import org.apache.olingo.commons.api.edm.geo.SRID; +import org.apache.olingo.commons.api.edm.provider.CsdlParameter; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class Parameter extends CsdlParameter { + + @Override + @JacksonXmlProperty(localName = "Name") + public CsdlParameter setName(final String name) { + Objects.requireNonNull(name, "Name is a required attribute of parameter"); + return super.setName(name); + } + + @Override + @JacksonXmlProperty(localName = "Type") + public CsdlParameter setType(final String type) { + Objects.requireNonNull(type, "Type is a required attribute of parameters"); + if (type.startsWith("Collection")) { + setCollection(true); + return super.setType(new FullQualifiedName(type.split("[()]")[1])); + } + return super.setType(new FullQualifiedName(type)); + } + + @Override + @JacksonXmlProperty(localName = "Nullable") + public CsdlParameter setNullable(final boolean nullable) { + return super.setNullable(nullable); + } + + @Override + @JacksonXmlProperty(localName = "MaxLength", isAttribute = true) + public CsdlParameter setMaxLength(Integer maxLength) { + return super.setMaxLength(maxLength); + } + + @Override + @JacksonXmlProperty(localName = "Precision", isAttribute = true) + public CsdlParameter setPrecision(final Integer precision) { + return super.setPrecision(precision); + } + + @Override + @JacksonXmlProperty(localName = "Scale", isAttribute = true) + public CsdlParameter setScale(final Integer scale) { + return super.setScale(scale); + } + + @JacksonXmlProperty(localName = "SRID", isAttribute = true) + void setSrid(final String srid) { + Objects.requireNonNull(srid); + super.setSrid(SRID.valueOf(srid)); + } +} diff --git a/jpa/odata-jpa-vocabularies/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/vocabularies/ReturnType.java b/jpa/odata-jpa-vocabularies/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/vocabularies/ReturnType.java index 8004a9cd1..4def7d563 100644 --- a/jpa/odata-jpa-vocabularies/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/vocabularies/ReturnType.java +++ b/jpa/odata-jpa-vocabularies/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/vocabularies/ReturnType.java @@ -1,56 +1,56 @@ -package com.sap.olingo.jpa.metadata.core.edm.mapper.vocabularies; - -import java.util.Objects; - -import org.apache.olingo.commons.api.edm.FullQualifiedName; -import org.apache.olingo.commons.api.edm.geo.SRID; -import org.apache.olingo.commons.api.edm.provider.CsdlReturnType; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; - -@JsonIgnoreProperties(ignoreUnknown = true) -public class ReturnType extends CsdlReturnType { - - @Override - @JacksonXmlProperty(localName = "Type") - public CsdlReturnType setType(final String type) { - Objects.requireNonNull(type, "Type is a required attribute of return type"); - if (type.startsWith("Collection")) { - setCollection(true); - return super.setType(new FullQualifiedName(type.split("[()]")[1])); - } - return super.setType(new FullQualifiedName(type)); - } - - @Override - @JacksonXmlProperty(localName = "Nullable") - public CsdlReturnType setNullable(final boolean nullable) { - return super.setNullable(nullable); - } - - @Override - @JacksonXmlProperty(localName = "MaxLength", isAttribute = true) - public CsdlReturnType setMaxLength(final Integer maxLength) { - return super.setMaxLength(maxLength); - } - - @Override - @JacksonXmlProperty(localName = "Precision", isAttribute = true) - public CsdlReturnType setPrecision(final Integer precision) { - return super.setPrecision(precision); - } - - @Override - @JacksonXmlProperty(localName = "Scale", isAttribute = true) - public CsdlReturnType setScale(final Integer scale) { - return super.setScale(scale); - } - - @JacksonXmlProperty(localName = "SRID", isAttribute = true) - void setSrid(final String srid) { - Objects.requireNonNull(srid); - super.setSrid(SRID.valueOf(srid)); - } - -} \ No newline at end of file +package com.sap.olingo.jpa.metadata.core.edm.mapper.vocabularies; + +import java.util.Objects; + +import org.apache.olingo.commons.api.edm.FullQualifiedName; +import org.apache.olingo.commons.api.edm.geo.SRID; +import org.apache.olingo.commons.api.edm.provider.CsdlReturnType; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class ReturnType extends CsdlReturnType { + + @Override + @JacksonXmlProperty(localName = "Type") + public CsdlReturnType setType(final String type) { + Objects.requireNonNull(type, "Type is a required attribute of return type"); + if (type.startsWith("Collection")) { + setCollection(true); + return super.setType(new FullQualifiedName(type.split("[()]")[1])); + } + return super.setType(new FullQualifiedName(type)); + } + + @Override + @JacksonXmlProperty(localName = "Nullable") + public CsdlReturnType setNullable(final boolean nullable) { + return super.setNullable(nullable); + } + + @Override + @JacksonXmlProperty(localName = "MaxLength", isAttribute = true) + public CsdlReturnType setMaxLength(final Integer maxLength) { + return super.setMaxLength(maxLength); + } + + @Override + @JacksonXmlProperty(localName = "Precision", isAttribute = true) + public CsdlReturnType setPrecision(final Integer precision) { + return super.setPrecision(precision); + } + + @Override + @JacksonXmlProperty(localName = "Scale", isAttribute = true) + public CsdlReturnType setScale(final Integer scale) { + return super.setScale(scale); + } + + @JacksonXmlProperty(localName = "SRID", isAttribute = true) + void setSrid(final String srid) { + Objects.requireNonNull(srid); + super.setSrid(SRID.valueOf(srid)); + } + +} diff --git a/jpa/odata-jpa-vocabularies/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/vocabularies/TermTest.java b/jpa/odata-jpa-vocabularies/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/vocabularies/TermTest.java index cd1289f9e..56870f5e6 100644 --- a/jpa/odata-jpa-vocabularies/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/vocabularies/TermTest.java +++ b/jpa/odata-jpa-vocabularies/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/vocabularies/TermTest.java @@ -1,116 +1,116 @@ -package com.sap.olingo.jpa.metadata.core.edm.mapper.vocabularies; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.junit.jupiter.api.Assertions.assertTrue; - -import java.io.IOException; -import java.nio.charset.Charset; -import java.util.Map; - -import org.apache.olingo.commons.api.edm.geo.SRID; -import org.apache.olingo.commons.api.edm.provider.CsdlTerm; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.databind.JsonMappingException; - -class TermTest { - private static final String TEST_ANNOTATIONS = "annotations/Org.Olingo.Test.V1.xml"; - private static final String CORE_ANNOTATIONS = "annotations/Org.OData.Core.V1.xml"; - private CsdlDocument cutCore; - private CsdlDocument cutTest; - private Charset charset; - - @BeforeEach - void setup() throws ODataJPAVocabulariesException, IOException { - final CsdlDocumentReader reader = new CsdlDocumentReader(); - charset = Charset.defaultCharset(); - cutCore = reader.readFromResource(CORE_ANNOTATIONS, charset); - cutTest = reader.readFromResource(TEST_ANNOTATIONS, charset); - } - - @Test - void testGetTermsOneSchemaFromPath() throws JsonParseException, JsonMappingException, IOException, - ODataJPAVocabulariesException { - - final Map> act = cutCore.getTerms(); - assertNotNull(act.get("Org.OData.Core.V1")); - final Map terms = act.get("Org.OData.Core.V1"); - assertEquals(40, terms.size()); - } - - @Test - void testGetAppliesTo() throws JsonParseException, JsonMappingException, IOException, ODataJPAVocabulariesException { - final Map> act = cutCore.getTerms(); - assertNotNull(act.get("Org.OData.Core.V1")); - final Map terms = act.get("Org.OData.Core.V1"); - final CsdlTerm term = terms.get("IsLanguageDependent"); - assertEquals(2, term.getAppliesTo().size()); - assertTrue("Term".equals(term.getAppliesTo().get(0)) || "Term".equals(term.getAppliesTo().get(1))); - assertTrue("Property".equals(term.getAppliesTo().get(0)) || "Property".equals(term.getAppliesTo().get(1))); - assertEquals("true", term.getDefaultValue()); - } - - @Test - void testGetTermsTwoSchemaFromPath() throws JsonParseException, JsonMappingException, IOException, - ODataJPAVocabulariesException { - final Map> act = cutTest.getTerms(); - assertNotNull(act.get("Org.OData.Measures.V1")); - assertNotNull(act.get("Org.OData.Capabilities.V1")); - } - - @Test - void testGetTermWithScalePrecision() throws JsonParseException, JsonMappingException, IOException, - ODataJPAVocabulariesException { - final Map> act = cutTest.getTerms(); - - final Map terms = act.get("Org.OData.Measures.V1"); - final CsdlTerm term = terms.get("MultipleOf"); - assertNotNull(term); - assertEquals(10, term.getScale()); - assertEquals(5, term.getPrecision()); - } - - @Test - void testGetTermWithBaseTypeMaxLength() throws JsonParseException, JsonMappingException, IOException, - ODataJPAVocabulariesException { - final Map> act = cutTest.getTerms(); - - final Map terms = act.get("Org.OData.Measures.V1"); - final CsdlTerm term = terms.get("Unit2"); - assertNotNull(term); - assertEquals("Unit", term.getBaseTerm()); - assertEquals(2, term.getMaxLength()); - } - - @Test - void testGetTermWithSrid() throws JsonParseException, JsonMappingException, IOException, - ODataJPAVocabulariesException { - final Map> act = cutTest.getTerms(); - - final Map terms = act.get("Org.OData.Measures.V1"); - final CsdlTerm term = terms.get("Geo"); - assertNotNull(term); - assertEquals(SRID.valueOf("1234"), term.getSrid()); - } - - @Test - void testGetTermWithSridVariableNotSupported() throws JsonParseException, JsonMappingException, IOException, - ODataJPAVocabulariesException { - - final Term cut = new Term(); - cut.setSrid("variable"); - assertTrue(cut.getSrid().toString().contains("variable")); - } - - @Test - void testGetTermWithScaleVariableNotSupported() throws JsonParseException, JsonMappingException, IOException, - ODataJPAVocabulariesException { - - final Term cut = new Term(); - assertThrows(ODataJPAVocabulariesException.class, () -> cut.setScale("variable")); - } -} +package com.sap.olingo.jpa.metadata.core.edm.mapper.vocabularies; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.io.IOException; +import java.nio.charset.Charset; +import java.util.Map; + +import org.apache.olingo.commons.api.edm.geo.SRID; +import org.apache.olingo.commons.api.edm.provider.CsdlTerm; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.databind.JsonMappingException; + +class TermTest { + private static final String TEST_ANNOTATIONS = "annotations/Org.Olingo.Test.V1.xml"; + private static final String CORE_ANNOTATIONS = "annotations/Org.OData.Core.V1.xml"; + private CsdlDocument cutCore; + private CsdlDocument cutTest; + private Charset charset; + + @BeforeEach + void setup() throws ODataJPAVocabulariesException, IOException { + final CsdlDocumentReader reader = new CsdlDocumentReader(); + charset = Charset.defaultCharset(); + cutCore = reader.readFromResource(CORE_ANNOTATIONS, charset); + cutTest = reader.readFromResource(TEST_ANNOTATIONS, charset); + } + + @Test + void testGetTermsOneSchemaFromPath() throws JsonParseException, JsonMappingException, IOException, + ODataJPAVocabulariesException { + + final Map> act = cutCore.getTerms(); + assertNotNull(act.get("Org.OData.Core.V1")); + final Map terms = act.get("Org.OData.Core.V1"); + assertEquals(40, terms.size()); + } + + @Test + void testGetAppliesTo() throws JsonParseException, JsonMappingException, IOException, ODataJPAVocabulariesException { + final Map> act = cutCore.getTerms(); + assertNotNull(act.get("Org.OData.Core.V1")); + final Map terms = act.get("Org.OData.Core.V1"); + final CsdlTerm term = terms.get("IsLanguageDependent"); + assertEquals(2, term.getAppliesTo().size()); + assertTrue("Term".equals(term.getAppliesTo().get(0)) || "Term".equals(term.getAppliesTo().get(1))); + assertTrue("Property".equals(term.getAppliesTo().get(0)) || "Property".equals(term.getAppliesTo().get(1))); + assertEquals("true", term.getDefaultValue()); + } + + @Test + void testGetTermsTwoSchemaFromPath() throws JsonParseException, JsonMappingException, IOException, + ODataJPAVocabulariesException { + final Map> act = cutTest.getTerms(); + assertNotNull(act.get("Org.OData.Measures.V1")); + assertNotNull(act.get("Org.OData.Capabilities.V1")); + } + + @Test + void testGetTermWithScalePrecision() throws JsonParseException, JsonMappingException, IOException, + ODataJPAVocabulariesException { + final Map> act = cutTest.getTerms(); + + final Map terms = act.get("Org.OData.Measures.V1"); + final CsdlTerm term = terms.get("MultipleOf"); + assertNotNull(term); + assertEquals(10, term.getScale()); + assertEquals(5, term.getPrecision()); + } + + @Test + void testGetTermWithBaseTypeMaxLength() throws JsonParseException, JsonMappingException, IOException, + ODataJPAVocabulariesException { + final Map> act = cutTest.getTerms(); + + final Map terms = act.get("Org.OData.Measures.V1"); + final CsdlTerm term = terms.get("Unit2"); + assertNotNull(term); + assertEquals("Unit", term.getBaseTerm()); + assertEquals(2, term.getMaxLength()); + } + + @Test + void testGetTermWithSrid() throws JsonParseException, JsonMappingException, IOException, + ODataJPAVocabulariesException { + final Map> act = cutTest.getTerms(); + + final Map terms = act.get("Org.OData.Measures.V1"); + final CsdlTerm term = terms.get("Geo"); + assertNotNull(term); + assertEquals(SRID.valueOf("1234"), term.getSrid()); + } + + @Test + void testGetTermWithSridVariableNotSupported() throws JsonParseException, JsonMappingException, IOException, + ODataJPAVocabulariesException { + + final Term cut = new Term(); + cut.setSrid("variable"); + assertTrue(cut.getSrid().toString().contains("variable")); + } + + @Test + void testGetTermWithScaleVariableNotSupported() throws JsonParseException, JsonMappingException, IOException, + ODataJPAVocabulariesException { + + final Term cut = new Term(); + assertThrows(ODataJPAVocabulariesException.class, () -> cut.setScale("variable")); + } +} diff --git a/jpa/odata-jpa-vocabularies/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/vocabularies/TestAnnotationSchema.java b/jpa/odata-jpa-vocabularies/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/vocabularies/TestAnnotationSchema.java index 7723d47fd..c2b1f6f6d 100644 --- a/jpa/odata-jpa-vocabularies/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/vocabularies/TestAnnotationSchema.java +++ b/jpa/odata-jpa-vocabularies/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/vocabularies/TestAnnotationSchema.java @@ -1,388 +1,388 @@ -package com.sap.olingo.jpa.metadata.core.edm.mapper.vocabularies; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertNull; -import static org.junit.jupiter.api.Assertions.assertTrue; - -import java.io.IOException; -import java.nio.charset.Charset; -import java.util.List; -import java.util.Map; - -import org.apache.olingo.commons.api.edm.geo.SRID; -import org.apache.olingo.commons.api.edm.provider.CsdlAction; -import org.apache.olingo.commons.api.edm.provider.CsdlComplexType; -import org.apache.olingo.commons.api.edm.provider.CsdlEnumMember; -import org.apache.olingo.commons.api.edm.provider.CsdlEnumType; -import org.apache.olingo.commons.api.edm.provider.CsdlFunction; -import org.apache.olingo.commons.api.edm.provider.CsdlParameter; -import org.apache.olingo.commons.api.edm.provider.CsdlProperty; -import org.apache.olingo.commons.api.edm.provider.CsdlReturnType; -import org.apache.olingo.commons.api.edm.provider.CsdlSchema; -import org.apache.olingo.commons.api.edm.provider.CsdlTypeDefinition; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -class TestAnnotationSchema { - private static final String AGGREGATION_ANNOTATIONS = "annotations/Org.OData.Aggregation.V1.xml"; - private static final String CAPABILITIES_ANNOTATIONS = "annotations/Org.OData.Capabilities.V1.xml"; - private static final String TEST_ANNOTATIONS = "annotations/Org.Olingo.Test.V1.xml"; - private static final String CORE_ANNOTATIONS = "annotations/Org.OData.Core.V1.xml"; - private CsdlDocument cutCore; - private CsdlDocument cutTest; - private CsdlDocument cutCapabilities; - private CsdlDocument cutAggregation; - private Charset charset; - - @BeforeEach - void setup() throws ODataJPAVocabulariesException, IOException { - final CsdlDocumentReader reader = new CsdlDocumentReader(); - charset = Charset.defaultCharset(); - cutCore = reader.readFromResource(CORE_ANNOTATIONS, charset); - cutTest = reader.readFromResource(TEST_ANNOTATIONS, charset); - cutCapabilities = reader.readFromResource(CAPABILITIES_ANNOTATIONS, charset); - cutAggregation = reader.readFromResource(AGGREGATION_ANNOTATIONS, charset); - } - - @Test - void testGetAliasFromPath() throws IOException, ODataJPAVocabulariesException { - - final Map act = cutCore.getSchemas(); - assertNotNull(act.get("Org.OData.Core.V1")); - final CsdlSchema schema = act.get("Org.OData.Core.V1"); - assertEquals("Core", schema.getAlias()); - } - - @Test - void testGetTermsFromPath() throws IOException, ODataJPAVocabulariesException { - - final Map act = cutCore.getSchemas(); - assertNotNull(act.get("Org.OData.Core.V1")); - final CsdlSchema schema = act.get("Org.OData.Core.V1"); - assertEquals(40, schema.getTerms().size()); - } - - @Test - void testGetTypeDefinitionFromPath() throws IOException, ODataJPAVocabulariesException { - - final Map act = cutCore.getSchemas(); - assertNotNull(act.get("Org.OData.Core.V1")); - final CsdlSchema schema = act.get("Org.OData.Core.V1"); - assertEquals(7, schema.getTypeDefinitions().size()); - assertNotNull(schema.getTypeDefinition("Tag")); - assertEquals("Edm.Boolean", schema.getTypeDefinition("Tag").getUnderlyingType()); - } - - @Test - void testGetTypeDefinitions() throws IOException, ODataJPAVocabulariesException { - - final CsdlSchema act = cutTest.getSchemas().get("Org.OData.Capabilities.V1"); - assertEquals(3, act.getTypeDefinitions().size()); - - assertNotNull(act.getTypeDefinition("TestTypeDecimal")); - CsdlTypeDefinition actType = act.getTypeDefinition("TestTypeDecimal"); - assertEquals(10, actType.getPrecision()); - assertEquals(5, actType.getScale()); - assertNull(actType.getSrid()); - assertNull(actType.getMaxLength()); - - actType = act.getTypeDefinition("TestTypeGeo"); - assertNull(actType.getPrecision()); - assertNull(actType.getScale()); - assertEquals(SRID.valueOf("variable"), actType.getSrid()); - assertNull(actType.getMaxLength()); - assertTrue(actType.isUnicode()); - - actType = act.getTypeDefinition("TestTypeString"); - assertNull(actType.getPrecision()); - assertNull(actType.getScale()); - assertNull(actType.getSrid()); - assertEquals(256, actType.getMaxLength()); - assertFalse(actType.isUnicode()); - } - - @Test - void testGetEnumSchemaFromPath() throws IOException, ODataJPAVocabulariesException { - - final Map act = cutCore.getSchemas(); - assertNotNull(act.get("Org.OData.Core.V1")); - final CsdlSchema schema = act.get("Org.OData.Core.V1"); - assertEquals(3, schema.getEnumTypes().size()); - assertNotNull(schema.getEnumType("Permission")); - assertEquals(5, schema.getEnumType("Permission").getMembers().size()); - assertEquals("3", schema.getEnumType("Permission").getMember("ReadWrite").getValue()); - } - - @Test - void testGetSimpleComplexTypes() throws IOException, ODataJPAVocabulariesException { - - final Map act = cutTest.getSchemas(); - assertEquals(2, act.size()); - assertTrue(act.containsKey("Org.OData.Capabilities.V1")); - final CsdlSchema actSchema = act.get("Org.OData.Capabilities.V1"); - final CsdlComplexType actCt = actSchema.getComplexType("UpdateRestrictionsType"); - assertNotNull(actCt); - assertNull(actCt.getBaseType()); - assertNull(actCt.getBaseTypeFQN()); - assertFalse(actCt.isAbstract()); - assertFalse(actCt.isOpenType()); - assertEquals("UpdateRestrictionsType", actCt.getName()); - assertEquals(2, actCt.getProperties().size()); - assertEquals(0, actCt.getNavigationProperties().size()); - assertEquals(0, actCt.getAnnotations().size()); - } - - @Test - void testGetDeepComplexTypes() throws IOException, ODataJPAVocabulariesException { - final CsdlComplexType actCt = cutTest.getSchemas() - .get("Org.OData.Capabilities.V1").getComplexType("TestType"); - assertNotNull(actCt); - assertEquals(5, actCt.getProperties().size()); - assertTrue(actCt.isAbstract()); - assertTrue(actCt.isOpenType()); - assertNotNull(actCt.getBaseType()); - assertEquals("Core.Unknown", actCt.getBaseType()); - assertEquals("Core.Unknown", actCt.getBaseTypeFQN().getFullQualifiedNameAsString()); - assertEquals(0, actCt.getAnnotations().size()); // Annotations are ignored - } - - @Test - void testGetSimpleProperty() throws IOException, ODataJPAVocabulariesException { - final CsdlComplexType actCt = cutTest.getSchemas() - .get("Org.OData.Capabilities.V1").getComplexType("TestType"); - final CsdlProperty actProperty = actCt.getProperty("Deletable"); - assertNotNull(actProperty); - assertEquals("Deletable", actProperty.getName()); - assertEquals("Edm.Boolean", actProperty.getType()); - assertEquals("true", actProperty.getDefaultValue()); - assertNull(actProperty.getMaxLength()); - assertNull(actProperty.getScale()); - assertNull(actProperty.getSrid()); - assertNull(actProperty.getPrecision()); - assertTrue(actProperty.isUnicode()); - } - - @Test - void testGetDecimalProperty() throws IOException, ODataJPAVocabulariesException { - final CsdlComplexType actCt = cutTest.getSchemas() - .get("Org.OData.Capabilities.V1").getComplexType("TestType"); - final CsdlProperty actProperty = actCt.getProperty("TestDecimals"); - assertNotNull(actProperty); - assertEquals("TestDecimals", actProperty.getName()); - assertEquals("Edm.Decimal", actProperty.getType()); - assertNull(actProperty.getDefaultValue()); - assertNull(actProperty.getMaxLength()); - assertEquals(5, actProperty.getScale()); - assertNull(actProperty.getSrid()); - assertEquals(10, actProperty.getPrecision()); - assertTrue(actProperty.isUnicode()); - } - - @Test - void testGetStringProperty() throws IOException, ODataJPAVocabulariesException { - final CsdlComplexType actCt = cutTest.getSchemas() - .get("Org.OData.Capabilities.V1").getComplexType("TestType"); - final CsdlProperty actProperty = actCt.getProperty("TestString"); - assertNotNull(actProperty); - assertEquals("TestString", actProperty.getName()); - assertEquals("Edm.String", actProperty.getType()); - assertNull(actProperty.getDefaultValue()); - assertEquals(256, actProperty.getMaxLength()); - assertNull(actProperty.getScale()); - assertNull(actProperty.getSrid()); - assertNull(actProperty.getPrecision()); - assertFalse(actProperty.isUnicode()); - } - - @Test - void testGetGeoProperty() throws IOException, ODataJPAVocabulariesException { - final CsdlComplexType actCt = cutTest.getSchemas() - .get("Org.OData.Capabilities.V1").getComplexType("TestType"); - final CsdlProperty actProperty = actCt.getProperty("TestGeo"); - assertNotNull(actProperty); - assertEquals("TestGeo", actProperty.getName()); - assertEquals("Edm.GeometryPoint", actProperty.getType()); - assertNull(actProperty.getDefaultValue()); - assertNull(actProperty.getMaxLength()); - assertNull(actProperty.getScale()); - assertEquals(SRID.valueOf("3857"), actProperty.getSrid()); - assertNull(actProperty.getPrecision()); - assertTrue(actProperty.isUnicode()); - assertFalse(actProperty.isCollection()); - } - - @Test - void testGetCollectionProperty() throws IOException, ODataJPAVocabulariesException { - final CsdlComplexType actCt = cutTest.getSchemas() - .get("Org.OData.Capabilities.V1").getComplexType("TestType"); - final CsdlProperty actProperty = actCt.getProperty("NonDeletableNavigationProperties"); - assertNotNull(actProperty); - assertEquals("NonDeletableNavigationProperties", actProperty.getName()); - assertEquals("Edm.NavigationPropertyPath", actProperty.getType()); - assertTrue(actProperty.isCollection()); - } - - @Test - void testGetEnum() throws IOException, ODataJPAVocabulariesException { - final CsdlSchema act = cutCapabilities.getSchemas() - .get("Org.OData.Capabilities.V1"); - assertEquals(5, act.getEnumTypes().size()); - } - - @Test - void testGetEnumNotAsFlags() throws IOException, ODataJPAVocabulariesException { - final CsdlEnumType actEnum = cutAggregation.getSchemas() - .get("Org.OData.Aggregation.V1").getEnumType("RollupType"); - assertNotNull(actEnum); - assertEquals(3, actEnum.getMembers().size()); - assertNotNull(actEnum.getMember("MultipleHierarchies")); - assertNull(actEnum.getUnderlyingType()); - assertFalse(actEnum.isFlags()); - } - - @Test - void testGetEnumAsFlags() throws IOException, ODataJPAVocabulariesException { - final CsdlEnumType actEnum = cutCapabilities.getSchemas() - .get("Org.OData.Capabilities.V1").getEnumType("IsolationLevel"); - assertNotNull(actEnum); - assertEquals(1, actEnum.getMembers().size()); - assertNotNull(actEnum.getMember(1)); - assertNull(actEnum.getUnderlyingType()); - assertTrue(actEnum.isFlags()); - final CsdlEnumMember actMember = actEnum.getMember(1); - assertEquals("Snapshot", actMember.getName()); - assertEquals("1", actMember.getValue()); - } - - @Test - void testGetFunctions() throws IOException, ODataJPAVocabulariesException { - final CsdlSchema act = cutAggregation.getSchemas() - .get("Org.OData.Aggregation.V1"); - assertEquals(5, act.getFunctions().size()); - } - - @Test - void testGetFunctionAttributes() throws IOException, ODataJPAVocabulariesException { - final List act = cutAggregation.getSchemas() - .get("Org.OData.Aggregation.V1").getFunctions("isleaf"); - assertEquals(1, act.size()); - final CsdlFunction actFunc = act.get(0); - assertEquals("isleaf", actFunc.getName()); - assertEquals(2, actFunc.getParameters().size()); - assertTrue(actFunc.isBound()); - assertFalse(actFunc.isComposable()); - assertNotNull(actFunc.getReturnType()); - } - - @Test - void testGetFunctionParameter() throws IOException, ODataJPAVocabulariesException { - final List act = cutAggregation.getSchemas() - .get("Org.OData.Aggregation.V1").getFunctions("isancestor"); - - final CsdlFunction actFunc = act.get(0); - assertEquals(4, actFunc.getParameters().size()); - final CsdlParameter actMandatory = actFunc.getParameter("Entity"); - assertNotNull(actMandatory); - assertEquals("Entity", actMandatory.getName()); - assertEquals("Edm.EntityType", actMandatory.getType()); - assertFalse(actMandatory.isNullable()); - - final CsdlParameter actNullable = actFunc.getParameter("MaxDistance"); - assertTrue(actNullable.isNullable()); - } - - @Test - void testGetFunctionParameterFacet() throws IOException, ODataJPAVocabulariesException { - final List act = cutTest.getSchemas() - .get("Org.OData.Capabilities.V1").getFunctions("TestTheRest1"); - - final CsdlFunction actFunc = act.get(0); - final CsdlParameter actDecimal = actFunc.getParameter("Dec"); - assertEquals("Edm.Decimal", actDecimal.getTypeFQN().getFullQualifiedNameAsString()); - assertEquals(10, actDecimal.getPrecision()); - assertEquals(5, actDecimal.getScale()); - assertTrue(actDecimal.isNullable()); - - final CsdlParameter actGeo = actFunc.getParameter("Geo"); - assertEquals(SRID.valueOf("3857"), actGeo.getSrid()); - assertTrue(actGeo.isNullable()); - assertFalse(actGeo.isCollection()); - - final CsdlParameter actString = actFunc.getParameter("Text"); - assertEquals("Edm.String", actString.getType()); - assertTrue(actString.isCollection()); - assertEquals(512, actString.getMaxLength()); - } - - @Test - void testGetFunctionReturnType() throws IOException, ODataJPAVocabulariesException { - final List act = cutAggregation.getSchemas() - .get("Org.OData.Aggregation.V1").getFunctions("isancestor"); - - final CsdlFunction actFunc = act.get(0); - final CsdlReturnType actReturn = actFunc.getReturnType(); - assertNotNull(actReturn); - assertEquals("Edm.Boolean", actReturn.getType()); - assertFalse(actReturn.isNullable()); - assertNull(actReturn.getMaxLength()); - assertNull(actReturn.getScale()); - assertNull(actReturn.getSrid()); - assertNull(actReturn.getPrecision()); - assertFalse(actReturn.isCollection()); - } - - @Test - void testGetFunctionReturnTypeFacet() throws IOException, ODataJPAVocabulariesException { - final List act = cutTest.getSchemas() - .get("Org.OData.Capabilities.V1").getFunctions("TestTheRest1"); - - final CsdlFunction actFunc = act.get(0); - assertEquals("timeslices", actFunc.getEntitySetPath()); - final CsdlReturnType actReturn = actFunc.getReturnType(); - assertNotNull(actReturn); - assertEquals("Edm.Decimal", actReturn.getTypeFQN().getFullQualifiedNameAsString()); - assertEquals(10, actReturn.getPrecision()); - assertEquals(5, actReturn.getScale()); - assertTrue(actReturn.isNullable()); - assertTrue(actReturn.isCollection()); - assertEquals(20, actReturn.getMaxLength()); - assertEquals(SRID.valueOf("3857"), actReturn.getSrid()); - } - - @Test - void testGetActions() throws IOException, ODataJPAVocabulariesException { - final List act = cutTest.getSchemas() - .get("Org.OData.Capabilities.V1").getActions(); - assertEquals(2, act.size()); - } - - @Test - void testGetActionParameter() throws IOException, ODataJPAVocabulariesException { - final List act = cutTest.getSchemas() - .get("Org.OData.Capabilities.V1").getActions("UpsertTimeExample"); - - final CsdlAction actAction = act.get(0); - assertEquals(3, actAction.getParameters().size()); - assertTrue(actAction.isBound()); - assertEquals("UpsertTimeExample", actAction.getName()); - assertEquals("timeslices", actAction.getEntitySetPath()); - final CsdlParameter actParam = actAction.getParameter("timeslices"); - assertEquals("Edm.EntityType", actParam.getTypeFQN().getFullQualifiedNameAsString()); - assertTrue(actParam.isCollection()); - assertFalse(actParam.isNullable()); - } - - @Test - void testGetActionReturnType() throws IOException, ODataJPAVocabulariesException { - final List act = cutTest.getSchemas() - .get("Org.OData.Capabilities.V1").getActions("UpsertTimeExample"); - - final CsdlAction actAction = act.get(0); - assertNotNull(actAction.getReturnType()); - final CsdlReturnType actReturn = actAction.getReturnType(); - assertFalse(actReturn.isNullable()); - assertTrue(actReturn.isCollection()); - } +package com.sap.olingo.jpa.metadata.core.edm.mapper.vocabularies; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.io.IOException; +import java.nio.charset.Charset; +import java.util.List; +import java.util.Map; + +import org.apache.olingo.commons.api.edm.geo.SRID; +import org.apache.olingo.commons.api.edm.provider.CsdlAction; +import org.apache.olingo.commons.api.edm.provider.CsdlComplexType; +import org.apache.olingo.commons.api.edm.provider.CsdlEnumMember; +import org.apache.olingo.commons.api.edm.provider.CsdlEnumType; +import org.apache.olingo.commons.api.edm.provider.CsdlFunction; +import org.apache.olingo.commons.api.edm.provider.CsdlParameter; +import org.apache.olingo.commons.api.edm.provider.CsdlProperty; +import org.apache.olingo.commons.api.edm.provider.CsdlReturnType; +import org.apache.olingo.commons.api.edm.provider.CsdlSchema; +import org.apache.olingo.commons.api.edm.provider.CsdlTypeDefinition; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +class TestAnnotationSchema { + private static final String AGGREGATION_ANNOTATIONS = "annotations/Org.OData.Aggregation.V1.xml"; + private static final String CAPABILITIES_ANNOTATIONS = "annotations/Org.OData.Capabilities.V1.xml"; + private static final String TEST_ANNOTATIONS = "annotations/Org.Olingo.Test.V1.xml"; + private static final String CORE_ANNOTATIONS = "annotations/Org.OData.Core.V1.xml"; + private CsdlDocument cutCore; + private CsdlDocument cutTest; + private CsdlDocument cutCapabilities; + private CsdlDocument cutAggregation; + private Charset charset; + + @BeforeEach + void setup() throws ODataJPAVocabulariesException, IOException { + final CsdlDocumentReader reader = new CsdlDocumentReader(); + charset = Charset.defaultCharset(); + cutCore = reader.readFromResource(CORE_ANNOTATIONS, charset); + cutTest = reader.readFromResource(TEST_ANNOTATIONS, charset); + cutCapabilities = reader.readFromResource(CAPABILITIES_ANNOTATIONS, charset); + cutAggregation = reader.readFromResource(AGGREGATION_ANNOTATIONS, charset); + } + + @Test + void testGetAliasFromPath() throws IOException, ODataJPAVocabulariesException { + + final Map act = cutCore.getSchemas(); + assertNotNull(act.get("Org.OData.Core.V1")); + final CsdlSchema schema = act.get("Org.OData.Core.V1"); + assertEquals("Core", schema.getAlias()); + } + + @Test + void testGetTermsFromPath() throws IOException, ODataJPAVocabulariesException { + + final Map act = cutCore.getSchemas(); + assertNotNull(act.get("Org.OData.Core.V1")); + final CsdlSchema schema = act.get("Org.OData.Core.V1"); + assertEquals(40, schema.getTerms().size()); + } + + @Test + void testGetTypeDefinitionFromPath() throws IOException, ODataJPAVocabulariesException { + + final Map act = cutCore.getSchemas(); + assertNotNull(act.get("Org.OData.Core.V1")); + final CsdlSchema schema = act.get("Org.OData.Core.V1"); + assertEquals(7, schema.getTypeDefinitions().size()); + assertNotNull(schema.getTypeDefinition("Tag")); + assertEquals("Edm.Boolean", schema.getTypeDefinition("Tag").getUnderlyingType()); + } + + @Test + void testGetTypeDefinitions() throws IOException, ODataJPAVocabulariesException { + + final CsdlSchema act = cutTest.getSchemas().get("Org.OData.Capabilities.V1"); + assertEquals(3, act.getTypeDefinitions().size()); + + assertNotNull(act.getTypeDefinition("TestTypeDecimal")); + CsdlTypeDefinition actType = act.getTypeDefinition("TestTypeDecimal"); + assertEquals(10, actType.getPrecision()); + assertEquals(5, actType.getScale()); + assertNull(actType.getSrid()); + assertNull(actType.getMaxLength()); + + actType = act.getTypeDefinition("TestTypeGeo"); + assertNull(actType.getPrecision()); + assertNull(actType.getScale()); + assertEquals(SRID.valueOf("variable"), actType.getSrid()); + assertNull(actType.getMaxLength()); + assertTrue(actType.isUnicode()); + + actType = act.getTypeDefinition("TestTypeString"); + assertNull(actType.getPrecision()); + assertNull(actType.getScale()); + assertNull(actType.getSrid()); + assertEquals(256, actType.getMaxLength()); + assertFalse(actType.isUnicode()); + } + + @Test + void testGetEnumSchemaFromPath() throws IOException, ODataJPAVocabulariesException { + + final Map act = cutCore.getSchemas(); + assertNotNull(act.get("Org.OData.Core.V1")); + final CsdlSchema schema = act.get("Org.OData.Core.V1"); + assertEquals(3, schema.getEnumTypes().size()); + assertNotNull(schema.getEnumType("Permission")); + assertEquals(5, schema.getEnumType("Permission").getMembers().size()); + assertEquals("3", schema.getEnumType("Permission").getMember("ReadWrite").getValue()); + } + + @Test + void testGetSimpleComplexTypes() throws IOException, ODataJPAVocabulariesException { + + final Map act = cutTest.getSchemas(); + assertEquals(2, act.size()); + assertTrue(act.containsKey("Org.OData.Capabilities.V1")); + final CsdlSchema actSchema = act.get("Org.OData.Capabilities.V1"); + final CsdlComplexType actCt = actSchema.getComplexType("UpdateRestrictionsType"); + assertNotNull(actCt); + assertNull(actCt.getBaseType()); + assertNull(actCt.getBaseTypeFQN()); + assertFalse(actCt.isAbstract()); + assertFalse(actCt.isOpenType()); + assertEquals("UpdateRestrictionsType", actCt.getName()); + assertEquals(2, actCt.getProperties().size()); + assertEquals(0, actCt.getNavigationProperties().size()); + assertEquals(0, actCt.getAnnotations().size()); + } + + @Test + void testGetDeepComplexTypes() throws IOException, ODataJPAVocabulariesException { + final CsdlComplexType actCt = cutTest.getSchemas() + .get("Org.OData.Capabilities.V1").getComplexType("TestType"); + assertNotNull(actCt); + assertEquals(5, actCt.getProperties().size()); + assertTrue(actCt.isAbstract()); + assertTrue(actCt.isOpenType()); + assertNotNull(actCt.getBaseType()); + assertEquals("Core.Unknown", actCt.getBaseType()); + assertEquals("Core.Unknown", actCt.getBaseTypeFQN().getFullQualifiedNameAsString()); + assertEquals(0, actCt.getAnnotations().size()); // Annotations are ignored + } + + @Test + void testGetSimpleProperty() throws IOException, ODataJPAVocabulariesException { + final CsdlComplexType actCt = cutTest.getSchemas() + .get("Org.OData.Capabilities.V1").getComplexType("TestType"); + final CsdlProperty actProperty = actCt.getProperty("Deletable"); + assertNotNull(actProperty); + assertEquals("Deletable", actProperty.getName()); + assertEquals("Edm.Boolean", actProperty.getType()); + assertEquals("true", actProperty.getDefaultValue()); + assertNull(actProperty.getMaxLength()); + assertNull(actProperty.getScale()); + assertNull(actProperty.getSrid()); + assertNull(actProperty.getPrecision()); + assertTrue(actProperty.isUnicode()); + } + + @Test + void testGetDecimalProperty() throws IOException, ODataJPAVocabulariesException { + final CsdlComplexType actCt = cutTest.getSchemas() + .get("Org.OData.Capabilities.V1").getComplexType("TestType"); + final CsdlProperty actProperty = actCt.getProperty("TestDecimals"); + assertNotNull(actProperty); + assertEquals("TestDecimals", actProperty.getName()); + assertEquals("Edm.Decimal", actProperty.getType()); + assertNull(actProperty.getDefaultValue()); + assertNull(actProperty.getMaxLength()); + assertEquals(5, actProperty.getScale()); + assertNull(actProperty.getSrid()); + assertEquals(10, actProperty.getPrecision()); + assertTrue(actProperty.isUnicode()); + } + + @Test + void testGetStringProperty() throws IOException, ODataJPAVocabulariesException { + final CsdlComplexType actCt = cutTest.getSchemas() + .get("Org.OData.Capabilities.V1").getComplexType("TestType"); + final CsdlProperty actProperty = actCt.getProperty("TestString"); + assertNotNull(actProperty); + assertEquals("TestString", actProperty.getName()); + assertEquals("Edm.String", actProperty.getType()); + assertNull(actProperty.getDefaultValue()); + assertEquals(256, actProperty.getMaxLength()); + assertNull(actProperty.getScale()); + assertNull(actProperty.getSrid()); + assertNull(actProperty.getPrecision()); + assertFalse(actProperty.isUnicode()); + } + + @Test + void testGetGeoProperty() throws IOException, ODataJPAVocabulariesException { + final CsdlComplexType actCt = cutTest.getSchemas() + .get("Org.OData.Capabilities.V1").getComplexType("TestType"); + final CsdlProperty actProperty = actCt.getProperty("TestGeo"); + assertNotNull(actProperty); + assertEquals("TestGeo", actProperty.getName()); + assertEquals("Edm.GeometryPoint", actProperty.getType()); + assertNull(actProperty.getDefaultValue()); + assertNull(actProperty.getMaxLength()); + assertNull(actProperty.getScale()); + assertEquals(SRID.valueOf("3857"), actProperty.getSrid()); + assertNull(actProperty.getPrecision()); + assertTrue(actProperty.isUnicode()); + assertFalse(actProperty.isCollection()); + } + + @Test + void testGetCollectionProperty() throws IOException, ODataJPAVocabulariesException { + final CsdlComplexType actCt = cutTest.getSchemas() + .get("Org.OData.Capabilities.V1").getComplexType("TestType"); + final CsdlProperty actProperty = actCt.getProperty("NonDeletableNavigationProperties"); + assertNotNull(actProperty); + assertEquals("NonDeletableNavigationProperties", actProperty.getName()); + assertEquals("Edm.NavigationPropertyPath", actProperty.getType()); + assertTrue(actProperty.isCollection()); + } + + @Test + void testGetEnum() throws IOException, ODataJPAVocabulariesException { + final CsdlSchema act = cutCapabilities.getSchemas() + .get("Org.OData.Capabilities.V1"); + assertEquals(5, act.getEnumTypes().size()); + } + + @Test + void testGetEnumNotAsFlags() throws IOException, ODataJPAVocabulariesException { + final CsdlEnumType actEnum = cutAggregation.getSchemas() + .get("Org.OData.Aggregation.V1").getEnumType("RollupType"); + assertNotNull(actEnum); + assertEquals(3, actEnum.getMembers().size()); + assertNotNull(actEnum.getMember("MultipleHierarchies")); + assertNull(actEnum.getUnderlyingType()); + assertFalse(actEnum.isFlags()); + } + + @Test + void testGetEnumAsFlags() throws IOException, ODataJPAVocabulariesException { + final CsdlEnumType actEnum = cutCapabilities.getSchemas() + .get("Org.OData.Capabilities.V1").getEnumType("IsolationLevel"); + assertNotNull(actEnum); + assertEquals(1, actEnum.getMembers().size()); + assertNotNull(actEnum.getMember(1)); + assertNull(actEnum.getUnderlyingType()); + assertTrue(actEnum.isFlags()); + final CsdlEnumMember actMember = actEnum.getMember(1); + assertEquals("Snapshot", actMember.getName()); + assertEquals("1", actMember.getValue()); + } + + @Test + void testGetFunctions() throws IOException, ODataJPAVocabulariesException { + final CsdlSchema act = cutAggregation.getSchemas() + .get("Org.OData.Aggregation.V1"); + assertEquals(5, act.getFunctions().size()); + } + + @Test + void testGetFunctionAttributes() throws IOException, ODataJPAVocabulariesException { + final List act = cutAggregation.getSchemas() + .get("Org.OData.Aggregation.V1").getFunctions("isleaf"); + assertEquals(1, act.size()); + final CsdlFunction actFunc = act.get(0); + assertEquals("isleaf", actFunc.getName()); + assertEquals(2, actFunc.getParameters().size()); + assertTrue(actFunc.isBound()); + assertFalse(actFunc.isComposable()); + assertNotNull(actFunc.getReturnType()); + } + + @Test + void testGetFunctionParameter() throws IOException, ODataJPAVocabulariesException { + final List act = cutAggregation.getSchemas() + .get("Org.OData.Aggregation.V1").getFunctions("isancestor"); + + final CsdlFunction actFunc = act.get(0); + assertEquals(4, actFunc.getParameters().size()); + final CsdlParameter actMandatory = actFunc.getParameter("Entity"); + assertNotNull(actMandatory); + assertEquals("Entity", actMandatory.getName()); + assertEquals("Edm.EntityType", actMandatory.getType()); + assertFalse(actMandatory.isNullable()); + + final CsdlParameter actNullable = actFunc.getParameter("MaxDistance"); + assertTrue(actNullable.isNullable()); + } + + @Test + void testGetFunctionParameterFacet() throws IOException, ODataJPAVocabulariesException { + final List act = cutTest.getSchemas() + .get("Org.OData.Capabilities.V1").getFunctions("TestTheRest1"); + + final CsdlFunction actFunc = act.get(0); + final CsdlParameter actDecimal = actFunc.getParameter("Dec"); + assertEquals("Edm.Decimal", actDecimal.getTypeFQN().getFullQualifiedNameAsString()); + assertEquals(10, actDecimal.getPrecision()); + assertEquals(5, actDecimal.getScale()); + assertTrue(actDecimal.isNullable()); + + final CsdlParameter actGeo = actFunc.getParameter("Geo"); + assertEquals(SRID.valueOf("3857"), actGeo.getSrid()); + assertTrue(actGeo.isNullable()); + assertFalse(actGeo.isCollection()); + + final CsdlParameter actString = actFunc.getParameter("Text"); + assertEquals("Edm.String", actString.getType()); + assertTrue(actString.isCollection()); + assertEquals(512, actString.getMaxLength()); + } + + @Test + void testGetFunctionReturnType() throws IOException, ODataJPAVocabulariesException { + final List act = cutAggregation.getSchemas() + .get("Org.OData.Aggregation.V1").getFunctions("isancestor"); + + final CsdlFunction actFunc = act.get(0); + final CsdlReturnType actReturn = actFunc.getReturnType(); + assertNotNull(actReturn); + assertEquals("Edm.Boolean", actReturn.getType()); + assertFalse(actReturn.isNullable()); + assertNull(actReturn.getMaxLength()); + assertNull(actReturn.getScale()); + assertNull(actReturn.getSrid()); + assertNull(actReturn.getPrecision()); + assertFalse(actReturn.isCollection()); + } + + @Test + void testGetFunctionReturnTypeFacet() throws IOException, ODataJPAVocabulariesException { + final List act = cutTest.getSchemas() + .get("Org.OData.Capabilities.V1").getFunctions("TestTheRest1"); + + final CsdlFunction actFunc = act.get(0); + assertEquals("timeslices", actFunc.getEntitySetPath()); + final CsdlReturnType actReturn = actFunc.getReturnType(); + assertNotNull(actReturn); + assertEquals("Edm.Decimal", actReturn.getTypeFQN().getFullQualifiedNameAsString()); + assertEquals(10, actReturn.getPrecision()); + assertEquals(5, actReturn.getScale()); + assertTrue(actReturn.isNullable()); + assertTrue(actReturn.isCollection()); + assertEquals(20, actReturn.getMaxLength()); + assertEquals(SRID.valueOf("3857"), actReturn.getSrid()); + } + + @Test + void testGetActions() throws IOException, ODataJPAVocabulariesException { + final List act = cutTest.getSchemas() + .get("Org.OData.Capabilities.V1").getActions(); + assertEquals(2, act.size()); + } + + @Test + void testGetActionParameter() throws IOException, ODataJPAVocabulariesException { + final List act = cutTest.getSchemas() + .get("Org.OData.Capabilities.V1").getActions("UpsertTimeExample"); + + final CsdlAction actAction = act.get(0); + assertEquals(3, actAction.getParameters().size()); + assertTrue(actAction.isBound()); + assertEquals("UpsertTimeExample", actAction.getName()); + assertEquals("timeslices", actAction.getEntitySetPath()); + final CsdlParameter actParam = actAction.getParameter("timeslices"); + assertEquals("Edm.EntityType", actParam.getTypeFQN().getFullQualifiedNameAsString()); + assertTrue(actParam.isCollection()); + assertFalse(actParam.isNullable()); + } + + @Test + void testGetActionReturnType() throws IOException, ODataJPAVocabulariesException { + final List act = cutTest.getSchemas() + .get("Org.OData.Capabilities.V1").getActions("UpsertTimeExample"); + + final CsdlAction actAction = act.get(0); + assertNotNull(actAction.getReturnType()); + final CsdlReturnType actReturn = actAction.getReturnType(); + assertFalse(actReturn.isNullable()); + assertTrue(actReturn.isCollection()); + } } \ No newline at end of file diff --git a/jpa/odata-jpa-vocabularies/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/vocabularies/TestCsdlDocumentReader.java b/jpa/odata-jpa-vocabularies/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/vocabularies/TestCsdlDocumentReader.java index 8bc5f3a57..6f90921d6 100644 --- a/jpa/odata-jpa-vocabularies/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/vocabularies/TestCsdlDocumentReader.java +++ b/jpa/odata-jpa-vocabularies/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/vocabularies/TestCsdlDocumentReader.java @@ -1,103 +1,103 @@ -package com.sap.olingo.jpa.metadata.core.edm.mapper.vocabularies; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertNull; -import static org.junit.jupiter.api.Assertions.assertThrows; - -import java.io.IOException; -import java.net.MalformedURLException; -import java.net.URI; -import java.net.URISyntaxException; -import java.nio.charset.Charset; -import java.util.List; - -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; - -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.databind.JsonMappingException; - -class TestCsdlDocumentReader { - private static final String CORE_ANNOTATIONS = "annotations/Org.OData.Core.V1.xml"; - private CsdlDocumentReader cut; - private Charset charset; - - @BeforeEach - void setup() { - cut = new CsdlDocumentReader(); - charset = Charset.defaultCharset(); - } - - @Test - void testReadFromURIThrowsNullPointerOnNull() throws ODataJPAVocabulariesException, IOException { - assertThrows(NullPointerException.class, () -> cut.readFromURI(null)); - } - - @Test - void testReadFromResourceThrowsNullPointerOnNull() throws ODataJPAVocabulariesException, IOException { - assertThrows(NullPointerException.class, () -> cut.readFromResource(null, charset)); - assertThrows(NullPointerException.class, () -> cut.readFromResource(CORE_ANNOTATIONS, null)); - } - - @Test - void testReadFromResourceReturnsNullOnEmptyPath() throws ODataJPAVocabulariesException, IOException { - assertNull(cut.readFromResource("", charset)); - } - - @Test - void testReadFromResourceReturnsVocabulary() throws IOException, ODataJPAVocabulariesException { - - final CsdlDocument act = cut.readFromResource(CORE_ANNOTATIONS, charset); - assertNotNull(act); - assertFalse(act.getSchemas().isEmpty()); - assertNotNull(act.getSchemas().get("Org.OData.Core.V1")); - } - - @Test - void testReadFromResourceThrowsExceptionOnUnknownPath() throws IOException { - assertThrows(ODataJPAVocabulariesException.class, () -> { - cut.readFromResource("annotations/Org.OData.Core.V2.xml", charset); - }); - } - - @Test - void testReadFromResourceThrowsExceptionOnEmptyXML() throws IOException, ODataJPAVocabulariesException { - - assertThrows(IOException.class, () -> { - cut.readFromResource("annotations/empty.xml", charset); - }); - } - - @Test - void testReadDocumentContainsReferences() throws IOException, ODataJPAVocabulariesException { -// -// -// - final CsdlDocument act = cut.readFromResource(CORE_ANNOTATIONS, charset); - assertNotNull(act.getReference()); - assertEquals(1, act.getReference().size()); - final EdmxReference ref = act.getReference().get(0); - assertNotNull(ref.getIncludes()); - assertEquals(1, ref.getIncludes().size()); - final EdmxReferenceInclude include = ref.getIncludes().get(0); - assertEquals("Validation", include.getAlias()); - assertEquals("Org.OData.Validation.V1", include.getNamespace()); - } - - @Disabled("This test may not run because of proxy setting problems!! -> find alternative for Integration tests") - @Test - void testReadFromURI() throws URISyntaxException, JsonParseException, JsonMappingException, - MalformedURLException, IOException { - final URI uri = new URI("http://docs.oasis-open.org/odata/odata/v4.0/os/vocabularies/Org.OData.Core.V1.xml"); - final CsdlDocument actVocabulary = cut.readFromURI(uri); - assertNotNull(actVocabulary); - assertNotNull(actVocabulary.getDataService()); - - final List actSchemas = actVocabulary.getDataService().getSchemas(); - assertEquals(1, actSchemas.size()); - assertEquals("Org.OData.Core.V1", actSchemas.get(0).getNamespace()); - } -} +package com.sap.olingo.jpa.metadata.core.edm.mapper.vocabularies; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertThrows; + +import java.io.IOException; +import java.net.MalformedURLException; +import java.net.URI; +import java.net.URISyntaxException; +import java.nio.charset.Charset; +import java.util.List; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.databind.JsonMappingException; + +class TestCsdlDocumentReader { + private static final String CORE_ANNOTATIONS = "annotations/Org.OData.Core.V1.xml"; + private CsdlDocumentReader cut; + private Charset charset; + + @BeforeEach + void setup() { + cut = new CsdlDocumentReader(); + charset = Charset.defaultCharset(); + } + + @Test + void testReadFromURIThrowsNullPointerOnNull() throws ODataJPAVocabulariesException, IOException { + assertThrows(NullPointerException.class, () -> cut.readFromURI(null)); + } + + @Test + void testReadFromResourceThrowsNullPointerOnNull() throws ODataJPAVocabulariesException, IOException { + assertThrows(NullPointerException.class, () -> cut.readFromResource(null, charset)); + assertThrows(NullPointerException.class, () -> cut.readFromResource(CORE_ANNOTATIONS, null)); + } + + @Test + void testReadFromResourceReturnsNullOnEmptyPath() throws ODataJPAVocabulariesException, IOException { + assertNull(cut.readFromResource("", charset)); + } + + @Test + void testReadFromResourceReturnsVocabulary() throws IOException, ODataJPAVocabulariesException { + + final CsdlDocument act = cut.readFromResource(CORE_ANNOTATIONS, charset); + assertNotNull(act); + assertFalse(act.getSchemas().isEmpty()); + assertNotNull(act.getSchemas().get("Org.OData.Core.V1")); + } + + @Test + void testReadFromResourceThrowsExceptionOnUnknownPath() throws IOException { + assertThrows(ODataJPAVocabulariesException.class, () -> { + cut.readFromResource("annotations/Org.OData.Core.V2.xml", charset); + }); + } + + @Test + void testReadFromResourceThrowsExceptionOnEmptyXML() throws IOException, ODataJPAVocabulariesException { + + assertThrows(IOException.class, () -> { + cut.readFromResource("annotations/empty.xml", charset); + }); + } + + @Test + void testReadDocumentContainsReferences() throws IOException, ODataJPAVocabulariesException { +// +// +// + final CsdlDocument act = cut.readFromResource(CORE_ANNOTATIONS, charset); + assertNotNull(act.getReference()); + assertEquals(1, act.getReference().size()); + final EdmxReference ref = act.getReference().get(0); + assertNotNull(ref.getIncludes()); + assertEquals(1, ref.getIncludes().size()); + final EdmxReferenceInclude include = ref.getIncludes().get(0); + assertEquals("Validation", include.getAlias()); + assertEquals("Org.OData.Validation.V1", include.getNamespace()); + } + + @Disabled("This test may not run because of proxy setting problems!! -> find alternative for Integration tests") + @Test + void testReadFromURI() throws URISyntaxException, JsonParseException, JsonMappingException, + MalformedURLException, IOException { + final URI uri = new URI("http://docs.oasis-open.org/odata/odata/v4.0/os/vocabularies/Org.OData.Core.V1.xml"); + final CsdlDocument actVocabulary = cut.readFromURI(uri); + assertNotNull(actVocabulary); + assertNotNull(actVocabulary.getDataService()); + + final List actSchemas = actVocabulary.getDataService().getSchemas(); + assertEquals(1, actSchemas.size()); + assertEquals("Org.OData.Core.V1", actSchemas.get(0).getNamespace()); + } +} diff --git a/jpa/pom.xml b/jpa/pom.xml index e549a52a0..a9fddea91 100644 --- a/jpa/pom.xml +++ b/jpa/pom.xml @@ -4,23 +4,26 @@ 4.0.0 com.sap.olingo odata-jpa - 1.1.1 + 2.0.0 pom odata-jpa https://github.com/SAP/olingo-jpa-processor-v4 UTF-8 - 1.8 - 1.8 + 17 + 17 3.8.0 4.9.0 - 2.14.0 + 2.14.1 1.7.1 4.3.0 - 2.2.1 - 1.1.1 - 5.3.10 - 0.8.7 + 3.1.0 + 2.0.0 + 6.0.11 + 5.9.1 + 1.9.1 + 5.5.0 + 0.8.10 ${project.basedir}/odata-jpa-coverage/target/site/jacoco-aggregate/jacoco.xml, ${project.basedir}/../odata-jpa-coverage/target/site/jacoco-aggregate/jacoco.xml @@ -94,7 +97,7 @@ org.basepom.maven duplicate-finder-maven-plugin - 1.5.1 + 2.0.1