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();
}
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");
}
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();
}
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());
}
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;
}
Aggregations