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

Remove FileTypes Enum and Update References #867

Merged
merged 2 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import bio.overture.song.core.model.FileData;
import bio.overture.song.core.model.Metadata;
import bio.overture.song.core.model.enums.AccessTypes;
import bio.overture.song.core.model.enums.FileTypes;
import bio.overture.song.server.model.enums.TableAttributeNames;
import bio.overture.song.server.model.enums.TableNames;
import com.fasterxml.jackson.annotation.JsonInclude;
Expand Down Expand Up @@ -81,10 +80,6 @@ public void setFileType(@NonNull String fileType) {
this.fileType = fileType;
}

public void setFileType(@NonNull FileTypes type) {
this.fileType = type.toString();
}

public void setFileAccess(@NonNull String fileAccess) {
this.fileAccess = fileAccess;
}
Expand Down
13 changes: 1 addition & 12 deletions song-server/src/main/resources/schemas/fileUpdateRequest.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,7 @@
"pattern": "^[A-Za-z0-9_\\.\\-\\[\\]\\(\\)]+$"
},
"fileType": {
"type": "string",
"enum": [
"FASTA",
"FAI",
"FASTQ",
"BAM",
"BAI",
"VCF",
"TBI",
"IDX",
"XML"
]
"type": "string"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,6 @@
import static bio.overture.song.core.model.enums.AnalysisStates.PUBLISHED;
import static bio.overture.song.core.model.enums.AnalysisStates.SUPPRESSED;
import static bio.overture.song.core.model.enums.AnalysisStates.UNPUBLISHED;
import static bio.overture.song.core.model.enums.FileTypes.BAI;
import static bio.overture.song.core.model.enums.FileTypes.BAM;
import static bio.overture.song.core.model.enums.FileTypes.FAI;
import static bio.overture.song.core.model.enums.FileTypes.FASTA;
import static bio.overture.song.core.model.enums.FileTypes.FASTQ;
import static bio.overture.song.core.model.enums.FileTypes.IDX;
import static bio.overture.song.core.model.enums.FileTypes.TBI;
import static bio.overture.song.core.model.enums.FileTypes.TGZ;
import static bio.overture.song.core.model.enums.FileTypes.VCF;
import static bio.overture.song.core.model.enums.FileTypes.XML;
import static bio.overture.song.core.model.enums.FileTypes.resolveFileType;
import static bio.overture.song.core.model.enums.FileTypes.values;
import static bio.overture.song.core.testing.SongErrorAssertions.assertExceptionThrownBy;
import static bio.overture.song.server.model.enums.InfoSearchResponseColumns.ANALYSIS_ID;
import static bio.overture.song.server.model.enums.InfoSearchResponseColumns.INFO;
Expand Down Expand Up @@ -91,47 +79,6 @@ public void testAccessTypes() {
IllegalStateException.class, () -> resolveAccessType("somethingNotAccessType"));
}

@Test
public void testFileTypes() {
assertEquals(FASTA.toString(), "FASTA");
assertEquals(FAI.toString(), "FAI");
assertEquals(FASTQ.toString(), "FASTQ");
assertEquals(BAM.toString(), "BAM");
assertEquals(BAI.toString(), "BAI");
assertEquals(VCF.toString(), "VCF");
assertEquals(TBI.toString(), "TBI");
assertEquals(IDX.toString(), "IDX");
assertEquals(XML.toString(), "XML");
assertEquals(TGZ.toString(), "TGZ");

assertEquals(FASTA.getExtension(), "fasta");
assertEquals(FAI.getExtension(), "fai");
assertEquals(FASTQ.getExtension(), "fastq");
assertEquals(BAM.getExtension(), "bam");
assertEquals(BAI.getExtension(), "bai");
assertEquals(VCF.getExtension(), "vcf");
assertEquals(TBI.getExtension(), "tbi");
assertEquals(IDX.getExtension(), "idx");
assertEquals(XML.getExtension(), "xml");
assertEquals(TGZ.getExtension(), "tgz");

assertEquals(values().length, 10);

assertEquals(resolveFileType("FASTA"), FASTA);
assertEquals(resolveFileType("FAI"), FAI);
assertEquals(resolveFileType("FASTQ"), FASTQ);
assertEquals(resolveFileType("BAM"), BAM);
assertEquals(resolveFileType("BAI"), BAI);
assertEquals(resolveFileType("VCF"), VCF);
assertEquals(resolveFileType("TBI"), TBI);
assertEquals(resolveFileType("IDX"), IDX);
assertEquals(resolveFileType("XML"), XML);
assertEquals(resolveFileType("TGZ"), TGZ);

assertExceptionThrownBy(
IllegalStateException.class, () -> resolveFileType("somethingThatsNotAFileType"));
}

@Test
public void testInfoTypes() {
assertEquals(STUDY.toString(), "Study");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
package bio.overture.song.server.service;

import static bio.overture.song.core.model.enums.AnalysisStates.UNPUBLISHED;
import static bio.overture.song.core.model.enums.FileTypes.BAM;
import static bio.overture.song.core.utils.JsonUtils.fromJson;
import static bio.overture.song.core.utils.JsonUtils.objectToTree;
import static bio.overture.song.core.utils.JsonUtils.readTree;
Expand Down Expand Up @@ -123,7 +122,7 @@ public void nonEmptyInfoFields_allEmpty_success() {
.objectId("sfdsdfsdf")
.studyId("ABC123")
.fileName("something.bam")
.fileType(BAM.toString())
.fileType("BAM")
.build();
val fileList = List.of(f1);
val fff = new ObjectMapper().valueToTree(f1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,13 @@
import static bio.overture.song.server.utils.TestConstants.TUMOUR_NORMAL_DESIGNATION;
import static bio.overture.song.server.utils.TestFiles.assertInfoKVPair;
import static com.google.common.collect.Lists.newArrayList;
import static java.util.Arrays.stream;
import static java.util.stream.Collectors.toList;
import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;

import bio.overture.song.core.model.Metadata;
import bio.overture.song.core.model.enums.FileTypes;
import bio.overture.song.server.model.Upload;
import bio.overture.song.server.model.entity.Donor;
import bio.overture.song.server.model.entity.FileEntity;
Expand All @@ -53,15 +50,15 @@
import bio.overture.song.server.model.legacy.LegacyEntity;
import com.fasterxml.jackson.databind.JsonNode;
import java.time.LocalDateTime;
import java.util.Arrays;
import java.util.List;
import lombok.val;
import org.junit.Test;

public class EntityTest {
private static final String DEFAULT_STUDY_ID = "ABC123";
private static final List<String> SAMPLE_TYPES = newArrayList(SAMPLE_TYPE);
private static final List<String> FILE_TYPES =
stream(FileTypes.values()).map(FileTypes::toString).collect(toList());
private static final List<String> FILE_TYPES = Arrays.asList("mp3", "mp4", "BAM");

@Test
public void testNullMetadata() {
Expand Down Expand Up @@ -634,7 +631,7 @@ public void testFile() {
file1.setFileMd5sum("b1");
file1.setFileName("c1");
file1.setFileSize(13L);
file1.setFileType(FILE_TYPES.get(0));
file1.setFileType("mp4");
file1.setObjectId("d1");
file1.setStudyId("e1");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import static bio.overture.song.core.exceptions.ServerErrors.STUDY_ID_DOES_NOT_EXIST;
import static bio.overture.song.core.model.enums.AccessTypes.CONTROLLED;
import static bio.overture.song.core.model.enums.AccessTypes.OPEN;
import static bio.overture.song.core.model.enums.FileTypes.FAI;
import static bio.overture.song.core.testing.SongErrorAssertions.assertSongError;
import static bio.overture.song.core.utils.RandomGenerator.createRandomGenerator;
import static bio.overture.song.server.utils.TestConstants.DEFAULT_ANALYSIS_ID;
Expand Down Expand Up @@ -109,7 +108,7 @@ public void testCreateAndDeleteFile() {

f.setFileSize(0L);
f.setDataType(randomGenerator.generateRandomAsciiString(10));
f.setFileType(FAI);
f.setFileType("FAI");
f.setFileMd5sum("6bb8ee7218e96a59e0ad898b4f5360f1");
f.setInfo(metadata);
f.setFileAccess(OPEN);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
import static bio.overture.song.core.exceptions.ServerErrors.MISSING_STORAGE_OBJECTS;
import static bio.overture.song.core.model.enums.AnalysisStates.PUBLISHED;
import static bio.overture.song.core.model.enums.AnalysisStates.UNPUBLISHED;
import static bio.overture.song.core.model.enums.FileTypes.BAM;
import static bio.overture.song.core.model.enums.FileTypes.VCF;
import static bio.overture.song.core.utils.RandomGenerator.createRandomGenerator;
import static bio.overture.song.core.utils.RandomGenerator.randomList;
import static bio.overture.song.server.service.PublishAnalysisTest.RangeType.ALL;
Expand Down Expand Up @@ -356,11 +354,11 @@ public FileEntity generateFile(Analysis a) {
String fileName = randomGenerator.generateRandomUUIDAsString() + ".";

if (legacyAnalysisTypeName == LegacyAnalysisTypeName.SEQUENCING_READ) {
fileType = BAM.toString();
fileName += BAM.getExtension();
fileType = "BAM";
fileName += "BAM";
} else if (legacyAnalysisTypeName == LegacyAnalysisTypeName.VARIANT_CALL) {
fileType = VCF.toString();
fileName += VCF.getExtension() + ".gz";
fileType = "VCF";
fileName += "VCF" + ".gz";
}
val file =
FileEntity.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import static java.lang.String.format;

import bio.overture.song.core.model.enums.AccessTypes;
import bio.overture.song.core.model.enums.FileTypes;
import bio.overture.song.core.utils.RandomGenerator;
import bio.overture.song.server.model.entity.FileEntity;
import bio.overture.song.server.service.FileService;
Expand Down Expand Up @@ -64,7 +63,7 @@ protected String createId(String existingStudyId, Object context) {
analysisService.checkAnalysisExists(analysisData.getExistingId());
val existingAnalysisId = analysisData.getExistingId();

val type = getRandomGenerator().randomEnum(FileTypes.class).toString();
val type = "mp4";
val file =
FileEntity.builder()
.fileAccess(getRandomGenerator().randomEnum(AccessTypes.class).toString())
Expand Down