-
Notifications
You must be signed in to change notification settings - Fork 7
Allow studies to prevent new timepoint creation on data import. #5075
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
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
e38b186
layout fix
labkey-klum 6725e4e
placeholder upgrade scripts
labkey-klum 28fd730
Merge branch 'develop' into fb_issue_49069
labkey-klum f004f0f
refactor methods which call ensureVisits to support preventing the cr…
labkey-klum d1ca647
Round trip undefined visits setting.
labkey-klum 695f178
don't leak a server exception
labkey-klum d88e329
consolidate previous checks for undefined visits in specimen and data…
labkey-klum 24903b3
Improve description
labkey-klum ffde407
Merge branch 'develop' into fb_issue_49069
labkey-klum 474265f
automated test fixes
labkey-klum 74a339d
Support for date based studies, handle errors in folder import more c…
labkey-klum 1aea680
clarify javadoc
labkey-klum 14b79b7
merge from develop
labkey-klum 117ae63
Merge remote-tracking branch 'origin/develop' into fb_issue_49069
labkey-tchad d9a3ea6
Fix pluralization in error message
labkey-tchad 368beb8
Bug fixes from manual testing
labkey-klum 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -256,7 +256,7 @@ public SpecimenImporter(Container container, User user) | |
| SpecimenSchema.get().getTableInfoSpecimenPrimaryType(getContainer()).getSelectName(), SpecimenColumns.PRIMARYTYPE_COLUMNS); | ||
| } | ||
|
|
||
| private void resyncStudy(boolean syncParticipantVisit) | ||
| private void resyncStudy(boolean syncParticipantVisit, boolean failForUndefinedVisits) throws ValidationException | ||
| { | ||
| TableInfo tableParticipant = SpecimenSchema.get().getTableInfoParticipant(); | ||
| TableInfo tableSpecimen = getTableInfoSpecimen(); | ||
|
|
@@ -271,7 +271,9 @@ private void resyncStudy(boolean syncParticipantVisit) | |
| { | ||
| Study study = StudyService.get().getStudy(getContainer()); | ||
| info("Updating study-wide subject/visit information..."); | ||
| VisitService.get().updateParticipantVisitsWithCohortUpdate(study, getUser(), _logger); | ||
| ValidationException errors = VisitService.get().updateParticipantVisitsWithCohortUpdate(study, getUser(), failForUndefinedVisits, _logger); | ||
| if (errors.hasErrors()) | ||
| throw errors; | ||
| info("Subject/visit update complete."); | ||
| } | ||
|
|
||
|
|
@@ -302,14 +304,16 @@ public void process(VirtualFile specimensDir, boolean merge, SimpleStudyImportCo | |
| throws IOException, ValidationException | ||
| { | ||
| Map<SpecimenTableType, SpecimenImportFile> sifMap = populateFileMap(specimensDir, new HashMap<>()); | ||
| process(sifMap, merge, ctx.getLogger(), job, syncParticipantVisit, false, ctx.isFailForUndefinedVisits()); | ||
| Study study = StudyService.get().getStudy(getContainer()); | ||
| process(sifMap, merge, ctx.getLogger(), job, syncParticipantVisit, false, ctx.isFailForUndefinedVisits() || study.isFailForUndefinedTimepoints()); | ||
| } | ||
|
|
||
| protected void process(Map<SpecimenTableType, SpecimenImportFile> sifMap, boolean merge, Logger logger, @Nullable PipelineJob job, | ||
| boolean syncParticipantVisit, boolean editingSpecimens) | ||
| throws IOException, ValidationException | ||
| { | ||
| process(sifMap, merge, logger, job, syncParticipantVisit, editingSpecimens, false); | ||
| Study study = StudyService.get().getStudy(getContainer()); | ||
| process(sifMap, merge, logger, job, syncParticipantVisit, editingSpecimens, study.isFailForUndefinedTimepoints()); | ||
| } | ||
|
|
||
| private void process(Map<SpecimenTableType, SpecimenImportFile> sifMap, boolean merge, Logger logger, @Nullable PipelineJob job, | ||
|
|
@@ -367,10 +371,6 @@ private void process(Map<SpecimenTableType, SpecimenImportFile> sifMap, boolean | |
| SpecimenImportFile specimenFile = sifMap.get(_specimensTableType); | ||
| SpecimenLoadInfo loadInfo = populateTempSpecimensTable(specimenFile, merge); | ||
|
|
||
| Study study = StudyService.get().getStudy(getContainer()); | ||
| if (loadInfo.getRowCount() > 0 && failForUndefinedVisits && study.getTimepointType() == TimepointType.VISIT) | ||
| checkForUndefinedVisits(loadInfo, study); | ||
|
|
||
|
Contributor
Author
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. This is the legacy folder import check, the new check is below in |
||
| // NOTE: if no rows were loaded in the temp table, don't remove existing materials/specimens/vials/events. | ||
| if (loadInfo.getRowCount() > 0) | ||
| populateSpecimenTables(loadInfo, merge); | ||
|
|
@@ -390,7 +390,7 @@ private void process(Map<SpecimenTableType, SpecimenImportFile> sifMap, boolean | |
|
|
||
| setStatus(GENERAL_JOB_STATUS_MSG + " (update study)"); | ||
| _iTimer.setPhase(ImportPhases.ResyncStudy); | ||
| resyncStudy(syncParticipantVisit); | ||
| resyncStudy(syncParticipantVisit, failForUndefinedVisits); | ||
|
|
||
| ensureNotCanceled(); | ||
| _iTimer.setPhase(ImportPhases.SetLastSpecimenLoad); | ||
|
|
@@ -452,29 +452,6 @@ private SpecimenLoadInfo populateTempSpecimensTable(SpecimenImportFile file, boo | |
| return new SpecimenLoadInfo(getUser(), getContainer(), DbSchema.getTemp(), columns, rowCount, tempTablesHolder.getTempTableInfo()); | ||
| } | ||
|
|
||
| private void checkForUndefinedVisits(SpecimenLoadInfo info, Study study) throws ValidationException | ||
| { | ||
| SQLFragment sql = new SQLFragment() | ||
| .append("SELECT DISTINCT VisitValue FROM ") | ||
| .append(info.getTempTableName()) | ||
| .append(" tt ") | ||
| .append("\nLEFT JOIN study.Visit v") | ||
| .append("\nON tt.VisitValue >= v.SequenceNumMin AND tt.VisitValue <=v.SequenceNumMax AND v.Container = ?") | ||
| .append("\nWHERE tt.VisitValue IS NOT NULL AND v.RowId IS NULL"); | ||
|
|
||
| // shared visit container | ||
| Study visitStudy = StudyService.get().getStudyForVisits(study); | ||
| sql.add(visitStudy.getContainer().getId()); | ||
|
|
||
| SqlSelector selector = new SqlSelector(SpecimenSchema.get().getSchema(), sql); | ||
| List<Double> undefinedVisits = selector.getArrayList(Double.class); | ||
| if (!undefinedVisits.isEmpty()) | ||
| { | ||
| Collections.sort(undefinedVisits); | ||
| throw new ValidationException("The following undefined visits exist in the specimen data: " + StringUtils.join(undefinedVisits, ", ")); | ||
| } | ||
| } | ||
|
|
||
| private void populateSpecimenTables(SpecimenLoadInfo info, boolean merge) throws ValidationException | ||
| { | ||
| setStatus(GENERAL_JOB_STATUS_MSG + " (populate tables)"); | ||
|
|
||
This file contains hidden or 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
1 change: 1 addition & 0 deletions
1
study/resources/schemas/dbscripts/postgresql/study-23.001-23.002.sql
This file contains hidden or 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 @@ | ||
| ALTER TABLE study.study ADD COLUMN FailForUndefinedTimepoints BOOLEAN NOT NULL DEFAULT FALSE; |
1 change: 1 addition & 0 deletions
1
study/resources/schemas/dbscripts/sqlserver/study-23.001-23.002.sql
This file contains hidden or 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 @@ | ||
| ALTER TABLE study.study ADD FailForUndefinedTimepoints BIT NOT NULL DEFAULT 0; |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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.
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.
This hides the legacy advanced folder import UI to fail for undefined visits if this is already configured at the study level.