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

Merge from BI Server #2

Open
wants to merge 66 commits into
base: brapi-server-v2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
aa958f9
[BI-1771] - performance experiments
mlm483 Aug 1, 2023
d370995
[BI-1771] - added germplasm-related indexes
jloux-brapi Dec 17, 2024
853c4b6
[BI-1771] - reverted index annotation
mlm483 Aug 3, 2023
1bafb97
[BI-1771] - reverted whitespace changes
mlm483 Aug 3, 2023
511744a
[BI-1771] - made create_indexes.sql idempotent
mlm483 Aug 14, 2023
17f208b
[BI-1909] Exploring converting *ToOne relationships to lazy loading a…
timparsons Sep 13, 2023
65f41bb
[BI-1909] NPE fix, converting sysouts to use Logger
timparsons Sep 15, 2023
f213636
[BI-1909] Updating GermplasmService to eagerly fetch related date for…
timparsons Sep 19, 2023
444ac44
[BI-1909] suggested changes
timparsons Sep 22, 2023
7ae834a
Create pull.yml
timparsons Nov 9, 2023
f3963b0
[BI-1945] - saving work in progress
mlm483 Oct 24, 2023
14347ea
[BI-1945] - store additionalInfo on primary entities as JSONB
mlm483 Oct 25, 2023
0a6c1c6
[BI-1945] - optimized imports
mlm483 Oct 25, 2023
dfe5e82
[BI-1945] - updated template, readme
jloux-brapi Dec 17, 2024
32a1c91
[BI-1945] - cleaned up SQL dummy data migrations
mlm483 Oct 26, 2023
c31973b
[BI-1945] - updated template
mlm483 Oct 26, 2023
3d73553
[BI-1945] - removed unused class
mlm483 Oct 26, 2023
213d51b
[BI-1945] - renamed method
mlm483 Oct 26, 2023
ea38550
[BI-1945] - handled null case
mlm483 Oct 27, 2023
14d780c
[BI-1945] - added stringtype=unspecified to template
mlm483 Oct 27, 2023
027eff8
[BI-1945] - removed debug log
mlm483 Nov 6, 2023
2e57478
[BI-1945] - optimized imports
mlm483 Nov 6, 2023
246e6a1
[BI-1945] - removed additionalInfo joins
mlm483 Nov 6, 2023
44c6a6a
[BI-1945] - updated README.md
mlm483 Nov 6, 2023
4d25468
[BI-1945] - added ON DELETE CASCADE to xref linking tables
mlm483 Nov 14, 2023
530ae23
[BI-2051] - batched inserts for efficiency
mlm483 Feb 6, 2024
1777923
[BI-2051] - removed comment
mlm483 Feb 8, 2024
9bb3096
[BI-2040] The fetchScaleValidValueCategories() method was causing the…
davedrp Feb 5, 2024
dc3aa96
[BI-2040] removed all calls to fetchXXXXX(page) and the methods thems…
davedrp Feb 5, 2024
f3c8871
[BI-2040] removed unused import-statements from ObservationVariableSe…
davedrp Feb 5, 2024
b850578
[BI-2078] - made performance improvements (thanks BrapiCoordinatorSelby)
mlm483 Mar 11, 2024
0c226fb
Filter out pedigree nodes with null germplasm
nickpalladino Apr 17, 2024
af5e584
Updated comment
nickpalladino Apr 19, 2024
f02603a
[BI-2109] - added migration for datasets
mlm483 Jun 28, 2024
df79493
[BI-2109] - made migration safer
mlm483 Jul 2, 2024
d2c9401
[BI-2304] - added migrations for list position
mlm483 Sep 18, 2024
ad9ae52
[BI-2304] - fixed migration
mlm483 Sep 19, 2024
38978d3
[BI-2304] - preserve list order without changing API
mlm483 Sep 20, 2024
1409352
[BI-2304] - used zero-indexing in migration
mlm483 Sep 20, 2024
e2548a7
[BI-2304] - changes based on review
mlm483 Oct 2, 2024
8281201
create batch entity and controller endpoints
dmeidlin Oct 21, 2024
92aa47f
json deserialize searchrequest sub-types
dmeidlin Oct 22, 2024
7b6b61a
return batchDbID in POST batches response results
dmeidlin Oct 23, 2024
e74184b
refactor
dmeidlin Oct 24, 2024
5c00c3d
add constraint to cascade on delete for list_item
dmeidlin Oct 25, 2024
beb95c4
add soft_deleted column to list tables
dmeidlin Oct 26, 2024
9ebbfb1
modify list repository to include clause softDelete=falsee
dmeidlin Oct 26, 2024
ed8ee46
use where clause and transactional annotations
dmeidlin Oct 27, 2024
0c38c55
soft-delete batch lists
dmeidlin Oct 28, 2024
0191666
add hard delete of single trial
dmeidlin Oct 28, 2024
0547cbc
create hard-delete endpoint for single sample
dmeidlin Oct 29, 2024
d659040
cascade delete for trial and sample
dmeidlin Oct 29, 2024
0d4ac86
add soft_delete columns to trial and sample related tables
dmeidlin Oct 29, 2024
fc10679
create sample service soft-delete method
dmeidlin Oct 29, 2024
aa8b86f
add soft-delete method to trial service
dmeidlin Oct 29, 2024
a5d8656
create Trial and Sample components
dmeidlin Oct 29, 2024
b96e1c9
optimize imports
dmeidlin Nov 5, 2024
f2036bf
respond with 204 for successful delete
dmeidlin Dec 3, 2024
cbdd0f3
return entity dbids in response for POST deleteBatch
dmeidlin Dec 3, 2024
493f88f
add batchDeleteDbId query param to GET endpoints for lists, trials, s…
dmeidlin Dec 3, 2024
6fa2c21
create new exception class for wrong batch delete type
dmeidlin Dec 3, 2024
71cdbb1
delete batch entity when deleting batch contents
dmeidlin Dec 4, 2024
bd2b039
add cascade delete constraints for study foreign keys
dmeidlin Dec 9, 2024
0efca81
rename batch to batch delete
dmeidlin Dec 13, 2024
b57a17d
Solve dummy data migration issues
jloux-brapi Dec 17, 2024
b7ecfda
Merge pull request #75 from plantbreeding/keycloak-dev-docker
jloux-brapi Dec 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ public ResponseEntity<TrialSingleResponse> trialsTrialDbIdDelete(
return responseOK(new TrialSingleResponse(), null);
}

return null;
trialService.softDeleteTrial(trialDbId);
return responseOK(new TrialSingleResponse(), null);
}

@CrossOrigin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@
import org.brapi.test.BrAPITestServer.model.entity.BrAPIPrimaryEntity;
import org.brapi.test.BrAPITestServer.model.entity.pheno.ObservationEntity;
import org.brapi.test.BrAPITestServer.model.entity.pheno.ObservationUnitEntity;
import org.hibernate.annotations.Where;

@Entity
@Table(name = "trial")
@Where(clause = "soft_deleted = false")
public class TrialEntity extends BrAPIPrimaryEntity {
@Column
private Boolean active;
Expand All @@ -35,6 +37,8 @@ public class TrialEntity extends BrAPIPrimaryEntity {
private String trialName;
@Column
private String trialPUI;
@Column(name = "soft_deleted")
private boolean softDeleted;

@ManyToOne(fetch = FetchType.LAZY)
private CropEntity crop;
Expand Down Expand Up @@ -140,5 +144,6 @@ public List<StudyEntity> getStudies() {
public void setStudies(List<StudyEntity> studies) {
this.studies = studies;
}

public boolean getSoftDeleted() { return softDeleted; }
public void setSoftDeleted(boolean sofDeleted) { this.softDeleted = sofDeleted; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.brapi.test.BrAPITestServer.model.entity.core.TrialEntity;
import org.brapi.test.BrAPITestServer.repository.BrAPIRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

public interface TrialRepository extends BrAPIRepository<TrialEntity, String> {

Expand All @@ -21,4 +25,14 @@ Page<TrialEntity> findBySearch(
@Param("applyActiveFilter") boolean applyActiveFilter,
@Param("active") boolean active, Pageable pageReq);

@Modifying
@Transactional
@Query("UPDATE TrialEntity t SET t.softDeleted = :softDeleted WHERE t.id = :trialId")
int updateSoftDeletedStatus(@Param("trialId") String trialId, @Param("softDeleted") boolean softDeleted);
Comment on lines +30 to +31
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm starting to get the feeling these soft queries could be generified. Not sure why we need to define them in every entity that needs them. I suppose maybe it's bc not every entity necessarily has this column, but I think we could employ some kind of repo inheritance for entities that need deletion, this repo could extend from BrAPIRepository, and it contains these soft deleted methods generified for any entity that needs them.


@Modifying
@Transactional
@Query("UPDATE TrialEntity t SET t.softDeleted = :softDeleted WHERE t.id IN :trialIds")
int updateSoftDeletedStatusBatch(@Param("trialIds") List<String> trialIds, @Param("softDeleted") boolean softDeleted);

}
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,13 @@ public List<Trial> saveTrials(@Valid List<TrialNewRequest> body) throws BrAPISer
return savedTrials;
}

public void softDeleteTrial(String trialDbId) throws BrAPIServerDbIdNotFoundException {
int updatedCount = trialRepository.updateSoftDeletedStatus(trialDbId, true);
if (updatedCount == 0) {
throw new BrAPIServerDbIdNotFoundException("Trial with id " + trialDbId + " not found", HttpStatus.NOT_FOUND);
}
}

public void deleteTrial(String trialDbId) throws BrAPIServerException {
trialRepository.deleteAllByIdInBatch(Arrays.asList(trialDbId));
}
Expand Down