Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PUT and PATCH APIs #244

Merged
merged 85 commits into from
May 18, 2023
Merged

PUT and PATCH APIs #244

merged 85 commits into from
May 18, 2023

Conversation

bglamadrid
Copy link
Collaborator

@bglamadrid bglamadrid commented May 10, 2023

PR Checklist

  • Read the contribution guidelines
  • Added a brief description of these changes to the top of the changelog
  • Changes in code meet test criteria (running mvn test returns exit code 0, without errors)

PR Type

  • Feature
  • Refactoring (changes that do not affect API nor functionality)

Summary

Resolve issue #232

Gives this backend the ability to perform partial and full updates, using the analogues REST API methods, PATCH and PUT, respectively.

To successfully enable such a feature, a good measure of refactoring had to be done. These changes are more thoroughly explained in the CHANGELOG.md file.

At the center of everything, method signatures from the CrudService and PatchService interfaces were altered.

- rename `update` methods to `partialUpdate`
- wrap return types in `Optional`s
- introduce new `update` methods
- implementations now declare `Map`
  as first parameter type of `patchExistingEntity`
- deprecate old `patchExistingEntity` signature
  (with the `P`-type parameter)
adds 8 sonar issues regarding the deprecated signature
provide failsafes for cases where some data is sometimes nullable
wherever an entity class has relationships to other entities,
a javadoc comment is created for its copy constructor
stating said constructor will not include relationships in the resulting object
there are two exceptions for this, `Customer` and `Salesperson`
two entities which are completely tied to `Person`
… services

include unit tests
introduce 2 temporary sonar issues
…y service

include unit tests
introduce 1 temporary sonar issue
include unit tests
introduce 1 temporary sonar issue
rename `persistEntityWithUpdatesFromPojo` to `flushPartialChanges`

introduce two abstract methods
to allow full data updates
without altering ids
refactor `GenericEntity` and `GenericPojo`
as inner static classes of the test class
set as base type in `org.trebol.jpa.Repository`
`extractIdFrom` and `injectIdInto`
have been superseded by usage of `DBEntity` id getter/setter
just use the converter method to pojo
as it is now meant to include entity relationships (see `657da582`)
avoids possible inaccuracy when using `Predicate` to match a record
if the affected records amount to more than one, do not update
to keep data safe and consistent
this now resides in the converter service
because currently it has a method that is called
both for Creation and Update operations
follow similar guidelines to those of the `ProductCategory` services

products' relationships to images are still only tied after
said product is beforehand persisted into the database
@sonarcloud
Copy link

sonarcloud bot commented May 17, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug C 2 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 38 Code Smells

85.6% 85.6% Coverage
0.0% 0.0% Duplication

@bglamadrid bglamadrid changed the title Feature/put and patch api PUT and PATCH APIs May 18, 2023
@bglamadrid bglamadrid linked an issue May 18, 2023 that may be closed by this pull request
@bglamadrid bglamadrid merged commit 931c11e into main May 18, 2023
3 checks passed
@bglamadrid bglamadrid mentioned this pull request May 19, 2023
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PUT APIs behave as if they were PATCH APIs
1 participant