Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 8
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
e38b1866725e4e28fd730f004f0fd1ca647695f178d88e32924903b3ffde407474265f74a339d1aea68014b79b7117ae63d9a3ea6368beb8File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| 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); | ||
ContributorAuthor 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)"); | ||
| 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; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| ALTER TABLE study.study ADD FailForUndefinedTimepoints BIT NOT NULL DEFAULT 0; |
Uh oh!
There was an error while loading. Please reload this page.
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.