-
Notifications
You must be signed in to change notification settings - Fork 1
BI-2848 - New Genotyping Page Backend: linkage to sample submission #523
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
10 commits
Select commit
Hold shift + click to select a range
47f808a
[autocommit] bumping build number
rob-ouser-bi 9f8b35e
BI-2848: Committing initial code changes.
humsika f145612
BI-2848: Committing additional code changes and test cases.
humsika f01a8e1
Merge remote-tracking branch 'origin/develop' into feature/BI-2848
humsika a2fbc40
BI-2848: Committing latest code changes.
humsika 9b23ee9
Merge remote-tracking branch 'origin/develop' into feature/BI-2848
humsika 00b1d08
Merge branch 'develop' into feature/BI-2848
nickpalladino e0d3d37
BI-2848: Addressing PR comments.
humsika a67ff51
Merge branch 'develop' into feature/BI-2848
nickpalladino a88a712
BI-2848: Added GenotypeImportDAO and also Rebased with develop branch…
humsika 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
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
69 changes: 69 additions & 0 deletions
69
src/main/java/org/breedinginsight/api/model/v1/request/query/GenotypeImportQuery.java
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,69 @@ | ||
| /* | ||
| * See the NOTICE file distributed with this work for additional information | ||
| * regarding copyright ownership. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package org.breedinginsight.api.model.v1.request.query; | ||
|
|
||
| import io.micronaut.core.annotation.Introspected; | ||
| import lombok.Getter; | ||
| import org.apache.commons.lang3.StringUtils; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
|
|
||
| @Getter | ||
| @Introspected | ||
| public class GenotypeImportQuery extends QueryParams { | ||
|
|
||
| private String sampleSubmissionId; | ||
| private String projectNameForSampleSubmission; | ||
| private String sampleSubmissionCreatedBy; | ||
| private String genotypingFileName; | ||
| private String genotypingImportDate; | ||
| private String genotypingImportBy; | ||
|
|
||
| public SearchRequest constructSearchRequest() { | ||
| List<FilterRequest> filters = new ArrayList<>(); | ||
|
|
||
| if (!StringUtils.isBlank(getSampleSubmissionId())) { | ||
| filters.add(constructFilterRequest("sampleSubmissionId", getSampleSubmissionId())); | ||
| } | ||
| if (!StringUtils.isBlank(getProjectNameForSampleSubmission())) { | ||
| filters.add(constructFilterRequest("projectNameForSampleSubmission", getProjectNameForSampleSubmission())); | ||
| } | ||
| if (!StringUtils.isBlank(getSampleSubmissionCreatedBy())) { | ||
| filters.add(constructFilterRequest("sampleSubmissionCreatedBy", getSampleSubmissionCreatedBy())); | ||
| } | ||
| if (!StringUtils.isBlank(getGenotypingFileName())) { | ||
| filters.add(constructFilterRequest("genotypingFileName", getGenotypingFileName())); | ||
| } | ||
| if (!StringUtils.isBlank(getGenotypingImportDate())) { | ||
| filters.add(constructFilterRequest("genotypingImportDate", getGenotypingImportDate())); | ||
| } | ||
| if (!StringUtils.isBlank(getGenotypingImportBy())) { | ||
| filters.add(constructFilterRequest("genotypingImportBy", getGenotypingImportBy())); | ||
| } | ||
|
|
||
| return new SearchRequest(filters); | ||
| } | ||
|
|
||
| private FilterRequest constructFilterRequest(String field, String value) { | ||
| return FilterRequest.builder() | ||
| .field(field) | ||
| .value(value) | ||
| .build(); | ||
| } | ||
| } | ||
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
85 changes: 85 additions & 0 deletions
85
src/main/java/org/breedinginsight/daos/GenotypeImportDAO.java
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,85 @@ | ||
| /* | ||
| * See the NOTICE file distributed with this work for additional information | ||
| * regarding copyright ownership. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package org.breedinginsight.daos; | ||
|
|
||
| import io.micronaut.http.HttpStatus; | ||
| import org.breedinginsight.dao.db.tables.BiUserTable; | ||
| import org.breedinginsight.dao.db.tables.daos.GenotypeImportDao; | ||
| import org.breedinginsight.dao.db.tables.pojos.GenotypeImportEntity; | ||
| import org.breedinginsight.model.GenotypeImportDetails; | ||
| import org.jooq.Configuration; | ||
| import org.jooq.DSLContext; | ||
|
|
||
| import javax.inject.Inject; | ||
| import javax.inject.Singleton; | ||
| import java.time.OffsetDateTime; | ||
| import java.util.List; | ||
| import java.util.UUID; | ||
|
|
||
| import static org.breedinginsight.dao.db.Tables.*; | ||
|
|
||
| @Singleton | ||
| public class GenotypeImportDAO extends GenotypeImportDao { | ||
|
|
||
| private final DSLContext dsl; | ||
|
|
||
| @Inject | ||
| public GenotypeImportDAO(Configuration config, DSLContext dsl) { | ||
| super(config); | ||
| this.dsl = dsl; | ||
| } | ||
|
|
||
| public void createGenotypeImportLink(UUID submissionId, UUID importerImportId, UUID userId) { | ||
| OffsetDateTime now = OffsetDateTime.now(); | ||
|
|
||
| insert(GenotypeImportEntity.builder() | ||
| .id(UUID.randomUUID()) | ||
| .sampleSubmissionId(submissionId) | ||
| .importerImportId(importerImportId) | ||
| .createdAt(now) | ||
| .updatedAt(now) | ||
| .createdBy(userId) | ||
| .updatedBy(userId) | ||
| .build()); | ||
| } | ||
|
|
||
| public List<GenotypeImportDetails> getGenotypeImportsByProgramId(UUID programId) { | ||
| BiUserTable sampleSubmissionCreatedByUser = BI_USER.as("sampleSubmissionCreatedByUser"); | ||
| BiUserTable genotypingImportByUser = BI_USER.as("genotypingImportByUser"); | ||
|
|
||
| return dsl.select( | ||
| SAMPLE_SUBMISSION.ID, | ||
| SAMPLE_SUBMISSION.NAME, | ||
| sampleSubmissionCreatedByUser.NAME, | ||
| IMPORTER_IMPORT.UPLOAD_FILE_NAME, | ||
| IMPORTER_IMPORT.CREATED_AT, | ||
| genotypingImportByUser.NAME) | ||
| .from(GENOTYPE_IMPORT) | ||
| .join(SAMPLE_SUBMISSION).on(GENOTYPE_IMPORT.SAMPLE_SUBMISSION_ID.eq(SAMPLE_SUBMISSION.ID)) | ||
| .join(sampleSubmissionCreatedByUser).on(SAMPLE_SUBMISSION.CREATED_BY.eq(sampleSubmissionCreatedByUser.ID)) | ||
| .join(IMPORTER_IMPORT).on(GENOTYPE_IMPORT.IMPORTER_IMPORT_ID.eq(IMPORTER_IMPORT.ID)) | ||
| .join(IMPORTER_PROGRESS).on(IMPORTER_IMPORT.IMPORTER_PROGRESS_ID.eq(IMPORTER_PROGRESS.ID)) | ||
| .join(genotypingImportByUser).on(IMPORTER_IMPORT.USER_ID.eq(genotypingImportByUser.ID)) | ||
| .where(SAMPLE_SUBMISSION.PROGRAM_ID.eq(programId)) | ||
| .and(IMPORTER_IMPORT.PROGRAM_ID.eq(programId)) | ||
| .and(IMPORTER_PROGRESS.STATUSCODE.eq((short) HttpStatus.OK.getCode())) | ||
| .orderBy(IMPORTER_IMPORT.CREATED_AT.desc()) | ||
| .fetch(record -> GenotypeImportDetails | ||
| .parseSqlRecord(record, sampleSubmissionCreatedByUser, genotypingImportByUser)); | ||
| } | ||
|
|
||
| } |
65 changes: 65 additions & 0 deletions
65
src/main/java/org/breedinginsight/model/GenotypeImportDetails.java
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,65 @@ | ||
| /* | ||
| * See the NOTICE file distributed with this work for additional information | ||
| * regarding copyright ownership. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package org.breedinginsight.model; | ||
|
nickpalladino marked this conversation as resolved.
|
||
|
|
||
| import io.micronaut.core.annotation.Introspected; | ||
| import lombok.Getter; | ||
| import lombok.NoArgsConstructor; | ||
| import lombok.Setter; | ||
| import lombok.ToString; | ||
| import lombok.experimental.Accessors; | ||
| import lombok.experimental.SuperBuilder; | ||
| import lombok.extern.jackson.Jacksonized; | ||
| import org.breedinginsight.dao.db.tables.BiUserTable; | ||
| import org.jooq.Record; | ||
|
|
||
| import java.time.OffsetDateTime; | ||
| import java.util.UUID; | ||
|
|
||
| import static org.breedinginsight.dao.db.Tables.IMPORTER_IMPORT; | ||
| import static org.breedinginsight.dao.db.Tables.SAMPLE_SUBMISSION; | ||
|
|
||
| @Getter | ||
| @Setter | ||
| @Accessors(chain = true) | ||
| @ToString | ||
| @SuperBuilder | ||
| @NoArgsConstructor | ||
| @Introspected | ||
| @Jacksonized | ||
| public class GenotypeImportDetails { | ||
| private UUID sampleSubmissionId; | ||
| private String projectNameForSampleSubmission; | ||
| private String sampleSubmissionCreatedBy; | ||
| private String genotypingFileName; | ||
| private OffsetDateTime genotypingImportDate; | ||
| private String genotypingImportBy; | ||
|
|
||
| public static GenotypeImportDetails parseSqlRecord(Record record, | ||
| BiUserTable sampleSubmissionCreatedByUser, | ||
| BiUserTable genotypingImportByUser) { | ||
| return GenotypeImportDetails.builder() | ||
| .sampleSubmissionId(record.get(SAMPLE_SUBMISSION.ID)) | ||
| .projectNameForSampleSubmission(record.get(SAMPLE_SUBMISSION.NAME)) | ||
| .sampleSubmissionCreatedBy(record.get(sampleSubmissionCreatedByUser.NAME)) | ||
| .genotypingFileName(record.get(IMPORTER_IMPORT.UPLOAD_FILE_NAME)) | ||
| .genotypingImportDate(record.get(IMPORTER_IMPORT.CREATED_AT)) | ||
| .genotypingImportBy(record.get(genotypingImportByUser.NAME)) | ||
| .build(); | ||
| } | ||
| } | ||
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.
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.
Uh oh!
There was an error while loading. Please reload this page.