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

Repository abstraction API #197

Closed
12 tasks done
kaizimmerm opened this issue May 31, 2016 · 0 comments
Closed
12 tasks done

Repository abstraction API #197

kaizimmerm opened this issue May 31, 2016 · 0 comments
Assignees
Milestone

Comments

@kaizimmerm
Copy link
Contributor

kaizimmerm commented May 31, 2016

Refactoring:

  • Provide interface on top of *management implementations.
  • Make entities immutable and create proper update methods that state by signature what can be updated.
  • Introduce builder pattern for EntityFactory create methods and repository update methods.
  • Use IDs in signatures for searches, not complete entities
  • Consistent usage of Java 8 Optional in the interfaces (Repo shall never return null!)
  • Remove TargetInfo interfaces as this does not belong into the API. The very existence of this object is very Spring Data/JPA specific.
  • Consistent usage of paging (make sure that we never query everything)
  • Fix DMF model name clashes by means of renaming DMF model in similar pattern to the other APIs.
  • Check if we really always ned Page or is Slice sufficient
  • Split management services (e.g. DS and DS type)
  • Consistent naming of methods (see below)

Remove boiler plate

  • Remove external artifact (concept was never finished anyway and does not fit to hawkBit as of today)

Method naming concept (example target management)

// Count all targets
Long count()

// Count by filter parameter (example)
Long countByTargetFilterQuery(@NotEmpty String targetFilterQuery);

//Create entity
List<Target> create(@NotEmpty Collection<TargetCreate> create)
Target create(@NotNull TargetCreate create)

//Delete entities (throws EntityNotFoundException if one element does not exist (at least one not found in collection case))
void delete(@NotEmpty Collection<Long> targetIDs);
void delete(@NotNull Long targetID);
void deleteByControllerId(@NotEmpty String controllerId);
void deleteByControllerId(@NotEmpty Collection<String> controllerId);

//Update Target (throws EntityNotFoundException if one element does not exist (at least one not found in collection case))
List<Target> update(@NotEmpty Collection<TargetUpdate> update);
Target update(@NotNull TargetUpdate update);

//Exist
boolean exists(@NotNull Long targetId)
boolean existsByAssignedDistributionSet(@NotNull Long distributionSetID);

// Read methods
// Find one on technical ID (Optional, no EntityNotFoundException)
Optional<Target> get(@NotNull Long targetId);
List<Target> get(@NotEmpty Collection<Long> targetId);

// Find one on non-ID but unique constraint (Optional, no EntityNotFoundException)
Optional<Target> getByControllerID(@NotEmpty String controllerId);
List<Target> getByControllerID(@NotEmpty Collection<String> controllerId);

// Find one on non-ID but and non unique constraint (Optional, no EntityNotFoundException)
Optional<Target> findFirstByDescription(@NotEmpty String description);

// Query/search repository (page might be empty, no EntityNotFoundException) (note: pageReq always first in signature)
Page<Target> findByAssignedDistributionSet(@NotNull Pageable pageReq, @NotNull Long distributionSetID);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant