Search in sources :

Example 1 with File

use of org.icgc.dcc.song.server.model.entity.File in project SONG by overture-stack.

the class FileServiceTest method testCreateAndDeleteFile.

@Test
public void testCreateAndDeleteFile() {
    val studyId = DEFAULT_STUDY_ID;
    val analysisId = DEFAULT_ANALYSIS_ID;
    val metadata = JsonUtils.fromSingleQuoted("{'species': 'human'}");
    val f = new File();
    f.setObjectId("");
    f.setFileName("ABC-TC285G87-A5-sqrl.bai");
    f.setStudyId(studyId);
    f.setFileSize(0L);
    f.setFileType("FAI");
    f.setFileMd5sum("6bb8ee7218e96a59e0ad898b4f5360f1");
    f.setInfo(metadata);
    f.setFileAccess(OPEN);
    val status = fileService.create(analysisId, studyId, f);
    val id = f.getObjectId();
    assertThat(status).isEqualTo(id);
    File check = fileService.read(id);
    assertThat(check).isEqualToComparingFieldByField(f);
    fileService.delete(id);
    assertThat(fileService.isFileExist(id)).isFalse();
}
Also used : lombok.val(lombok.val) File(org.icgc.dcc.song.server.model.entity.File) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 2 with File

use of org.icgc.dcc.song.server.model.entity.File in project SONG by overture-stack.

the class SerializationTest method testListFile.

@Test
public void testListFile() throws IOException {
    val singleQuotedJson = "{'file':[ { 'objectId': 'FI12345', 'fileName':'dna3.bam', 'fileMd5':'A1B2C3D4E5F6'}," + "{'objectId': 'FI34567', 'fileName': 'dna7.fasta', 'fileType':'BAM', 'fileSize':1234, 'fileMd5': 'F1E2D3'}]}";
    val json = JsonUtils.fromSingleQuoted(singleQuotedJson);
    val root = JsonUtils.readTree(json);
    val files = root.get("file");
    String fileJson = JsonUtils.toJson(files);
    List<File> f = Arrays.asList(JsonUtils.fromJson(fileJson, File[].class));
    assertThat(f.size()).isEqualTo(2);
    assertThat(f.get(0).getFileName()).isEqualTo("dna3.bam");
}
Also used : lombok.val(lombok.val) File(org.icgc.dcc.song.server.model.entity.File) Test(org.junit.Test)

Example 3 with File

use of org.icgc.dcc.song.server.model.entity.File in project SONG by overture-stack.

the class FileConverter method convertToFiles.

private static Set<File> convertToFiles(PortalFileMetadata portalFileMetadata) {
    val files = ImmutableSet.<File>builder();
    val mainFile = File.create(getFileId(portalFileMetadata), getAnalysisId(portalFileMetadata), getFileName(portalFileMetadata), getStudyId(portalFileMetadata), getFileSize(portalFileMetadata), getFileType(portalFileMetadata), getFileMd5sum(portalFileMetadata), getFileAccess(portalFileMetadata));
    files.add(mainFile);
    if (portalFileMetadata.isIndexFileComplete()) {
        val indexFile = File.create(getIndexFileObjectId(portalFileMetadata), getIndexAnalysisId(portalFileMetadata), getIndexFileName(portalFileMetadata), getIndexStudyId(portalFileMetadata), getIndexFileSize(portalFileMetadata), getIndexFileType(portalFileMetadata), getIndexFileMd5sum(portalFileMetadata), getIndexFileAccess(portalFileMetadata));
        files.add(indexFile);
    }
    return files.build();
}
Also used : lombok.val(lombok.val) File(org.icgc.dcc.song.server.model.entity.File)

Example 4 with File

use of org.icgc.dcc.song.server.model.entity.File in project SONG by overture-stack.

the class DccMetadataFetcher method processDccMetadata.

private Set<File> processDccMetadata(DccMetadata dccMetadata, Map<String, List<PortalFileMetadata>> objectIdMap) {
    val objectId = dccMetadata.getId();
    val portalFileMetadatasForObjectId = objectIdMap.get(objectId);
    val file = simpleDccStorageClient.getFile(objectId, "N/A", dccMetadata.getFileName());
    return portalFileMetadatasForObjectId.stream().map(x -> buildFile(dccMetadata, file, x)).collect(toImmutableSet());
}
Also used : lombok.val(lombok.val) PortalFileMetadata(org.icgc.dcc.song.importer.model.PortalFileMetadata) Collectors.toImmutableSet(org.icgc.dcc.common.core.util.stream.Collectors.toImmutableSet) DccMetadataDao(org.icgc.dcc.song.importer.dao.dcc.DccMetadataDao) File(org.icgc.dcc.song.server.model.entity.File) SneakyThrows(lombok.SneakyThrows) Files(java.nio.file.Files) NonNull(lombok.NonNull) FileConverter.convertToFile(org.icgc.dcc.song.importer.convert.FileConverter.convertToFile) Collection(java.util.Collection) lombok.val(lombok.val) Collectors.groupingBy(java.util.stream.Collectors.groupingBy) Set(java.util.Set) DccMetadata(org.icgc.dcc.song.importer.model.DccMetadata) List(java.util.List) CounterMonitor.newMonitor(org.icgc.dcc.song.importer.measurement.CounterMonitor.newMonitor) SimpleDccStorageClient.calcMd5Sum(org.icgc.dcc.song.importer.storage.SimpleDccStorageClient.calcMd5Sum) Map(java.util.Map) DccMetadataConverter(org.icgc.dcc.song.importer.convert.DccMetadataConverter) SimpleDccStorageClient(org.icgc.dcc.song.importer.storage.SimpleDccStorageClient)

Example 5 with File

use of org.icgc.dcc.song.server.model.entity.File in project SONG by overture-stack.

the class DccMetadataFetcher method fetchDccMetadataFiles.

public Set<File> fetchDccMetadataFiles(List<PortalFileMetadata> portalFileMetadatas) {
    val objectIdMap = groupDccMetadataIds(portalFileMetadatas);
    val dccMetadatas = dccMetadataDao.findByMultiObjectIds(objectIdMap.keySet());
    val counterMonitor = newMonitor("dccMetadataFiles", 1000);
    counterMonitor.start();
    val set = dccMetadatas.stream().map(x -> processDccMetadata(x, objectIdMap)).map(counterMonitor::streamCollectionCount).flatMap(Collection::stream).collect(toImmutableSet());
    counterMonitor.stop();
    counterMonitor.displaySummary();
    return set;
}
Also used : lombok.val(lombok.val) PortalFileMetadata(org.icgc.dcc.song.importer.model.PortalFileMetadata) Collectors.toImmutableSet(org.icgc.dcc.common.core.util.stream.Collectors.toImmutableSet) DccMetadataDao(org.icgc.dcc.song.importer.dao.dcc.DccMetadataDao) File(org.icgc.dcc.song.server.model.entity.File) SneakyThrows(lombok.SneakyThrows) Files(java.nio.file.Files) NonNull(lombok.NonNull) FileConverter.convertToFile(org.icgc.dcc.song.importer.convert.FileConverter.convertToFile) Collection(java.util.Collection) lombok.val(lombok.val) Collectors.groupingBy(java.util.stream.Collectors.groupingBy) Set(java.util.Set) DccMetadata(org.icgc.dcc.song.importer.model.DccMetadata) List(java.util.List) CounterMonitor.newMonitor(org.icgc.dcc.song.importer.measurement.CounterMonitor.newMonitor) SimpleDccStorageClient.calcMd5Sum(org.icgc.dcc.song.importer.storage.SimpleDccStorageClient.calcMd5Sum) Map(java.util.Map) DccMetadataConverter(org.icgc.dcc.song.importer.convert.DccMetadataConverter) SimpleDccStorageClient(org.icgc.dcc.song.importer.storage.SimpleDccStorageClient)

Aggregations

lombok.val (lombok.val)9 File (org.icgc.dcc.song.server.model.entity.File)9 Test (org.junit.Test)5 Collection (java.util.Collection)3 List (java.util.List)3 NonNull (lombok.NonNull)3 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)3 Files (java.nio.file.Files)2 Map (java.util.Map)2 Set (java.util.Set)2 Collectors.groupingBy (java.util.stream.Collectors.groupingBy)2 SneakyThrows (lombok.SneakyThrows)2 Collectors.toImmutableSet (org.icgc.dcc.common.core.util.stream.Collectors.toImmutableSet)2 DccMetadataConverter (org.icgc.dcc.song.importer.convert.DccMetadataConverter)2 FileConverter.convertToFile (org.icgc.dcc.song.importer.convert.FileConverter.convertToFile)2 DccMetadataDao (org.icgc.dcc.song.importer.dao.dcc.DccMetadataDao)2 CounterMonitor.newMonitor (org.icgc.dcc.song.importer.measurement.CounterMonitor.newMonitor)2 DccMetadata (org.icgc.dcc.song.importer.model.DccMetadata)2 SequencingReadAnalysis (org.icgc.dcc.song.server.model.analysis.SequencingReadAnalysis)2 CompositeEntity (org.icgc.dcc.song.server.model.entity.composites.CompositeEntity)2