-
Notifications
You must be signed in to change notification settings - Fork 4
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
Feature/refactor delete #1397
Draft
kcinay055679
wants to merge
12
commits into
main
Choose a base branch
from
feature/refactor-delete
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Feature/refactor delete #1397
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
81b5219
create generic structure for new delete strategie and implement it in…
kcinay055679 bcd676f
create abstract delete method classes
kcinay055679 d930dea
abstraction now supports default delete strategie and override
kcinay055679 e442d4a
implement delete abstraction for all required entities
kcinay055679 2804d75
find all should always return the visible entities
kcinay055679 2741735
add columns to h2 db
kcinay055679 417613f
fix failing quarterPersistenceIT
kcinay055679 904780f
add delete team test function for team persistence service
kcinay055679 3682886
add delete user and unit test function for persistence services
kcinay055679 5391279
fix failing persistence tests
kcinay055679 23c8805
update overview view to only show values without is_default ture
kcinay055679 08a3231
fix tests by fixing view
kcinay055679 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package ch.puzzle.okr.models; | ||
|
||
import jakarta.persistence.*; | ||
import org.hibernate.annotations.ColumnDefault; | ||
|
||
@MappedSuperclass | ||
public abstract class Deletable { | ||
@Column(name = "is_deleted", nullable = false) | ||
@ColumnDefault("false") | ||
private boolean isDeleted = false; | ||
|
||
public boolean isDeleted() { | ||
return isDeleted; | ||
} | ||
|
||
public void setDeleted(boolean deleted) { | ||
isDeleted = deleted; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
backend/src/main/java/ch/puzzle/okr/repository/DeleteRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package ch.puzzle.okr.repository; | ||
|
||
import ch.puzzle.okr.models.Deletable; | ||
import java.util.List; | ||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor; | ||
import org.springframework.data.jpa.repository.Modifying; | ||
import org.springframework.data.jpa.repository.Query; | ||
import org.springframework.data.repository.CrudRepository; | ||
import org.springframework.data.repository.NoRepositoryBean; | ||
import org.springframework.data.repository.query.Param; | ||
|
||
@NoRepositoryBean | ||
public interface DeleteRepository<E extends Deletable, I> extends CrudRepository<E, I>, JpaSpecificationExecutor<E> { | ||
// @Query("select #{#entityName} e set e.isDeleted = true where e.id = :id") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove comment seems unnecessary to me |
||
// List<E> isDeleted(boolean isDeleted); | ||
|
||
@Query("select e from #{#entityName} e where e.isDeleted = false ") | ||
List<E> findAllVisible(); | ||
|
||
@Modifying | ||
@Query("update #{#entityName} e set e.isDeleted = true where e.id = :id") | ||
void markAsDeleted(@Param("id") I id); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,13 +4,12 @@ | |
import ch.puzzle.okr.models.Quarter; | ||
import ch.puzzle.okr.models.Team; | ||
import java.util.List; | ||
import org.springframework.data.repository.CrudRepository; | ||
import org.springframework.stereotype.Repository; | ||
|
||
@Repository | ||
public interface ObjectiveRepository extends CrudRepository<Objective, Long> { | ||
public interface ObjectiveRepository extends DeleteRepository<Objective, Long> { | ||
|
||
Integer countByTeamAndQuarter(Team team, Quarter quarter); | ||
Integer countByTeamAndQuarterAndIsDeletedFalse(Team team, Quarter quarter); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is only used for testing, remove and remove tests or make separate task, up to you |
||
|
||
List<Objective> findObjectivesByTeamId(Long id); | ||
List<Objective> findObjectivesByTeamIdAndIsDeletedFalse(Long id); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why? maybe sdkman works best for all