use of com.odysseusinc.arachne.portal.model.Analysis in project ArachneCentralAPI by OHDSI.
the class BaseAnalysisServiceImpl method getAnalysisAllFiles.
@Override
public void getAnalysisAllFiles(Long analysisId, String archiveName, OutputStream os) throws IOException {
Analysis analysis = analysisRepository.findOne(analysisId);
Path storeFilesPath = analysisHelper.getAnalysisFolder(analysis);
try (ZipOutputStream zos = new ZipOutputStream(os)) {
for (AnalysisFile analysisFile : analysis.getFiles()) {
String realName = analysisFile.getRealName();
Path file = storeFilesPath.resolve(analysisFile.getUuid());
ZipUtil.addZipEntry(zos, realName, file);
}
}
}
use of com.odysseusinc.arachne.portal.model.Analysis in project ArachneCentralAPI by OHDSI.
the class BaseArachneSecureServiceImpl method getRolesByAnalysis.
@Override
public List<ParticipantRole> getRolesByAnalysis(ArachneUser user, Analysis analysis) {
List<ParticipantRole> result = new LinkedList<>();
if (analysis != null) {
if (analysis.getStudy() != null) {
result = getRolesByStudy(user, analysis.getStudy());
} else {
Analysis byId = analysisRepository.findOne(analysis.getId());
result = byId != null ? getRolesByStudy(user, byId.getStudy()) : result;
}
if (analysis.getAuthor().getId().equals(user.getId())) {
result.add(ParticipantRole.ANALYSIS_OWNER);
}
}
return result;
}
use of com.odysseusinc.arachne.portal.model.Analysis in project ArachneCentralAPI by OHDSI.
the class BaseArachneSecureServiceImpl method getRolesBySubmissionGroup.
@Override
public List<ParticipantRole> getRolesBySubmissionGroup(ArachneUser user, SubmissionGroup submissionGroup) {
List<ParticipantRole> result = new LinkedList<>();
Optional.ofNullable(submissionGroup).ifPresent(sg -> {
Analysis analysis = submissionGroup.getAnalysis();
if (analysis != null && analysis.getStudy() != null) {
result.addAll(getRolesByStudy(user, analysis.getStudy()));
}
});
return result;
}
use of com.odysseusinc.arachne.portal.model.Analysis in project ArachneCentralAPI by OHDSI.
the class BaseAnalysisServiceImpl method writeToFile.
@Override
@PreAuthorize("hasPermission(#analysisFile, " + "T(com.odysseusinc.arachne.portal.security.ArachnePermission).DELETE_ANALYSIS_FILES)")
public void writeToFile(AnalysisFile analysisFile, FileDTO fileContentDTO, IUser updatedBy) throws IOException {
Analysis analysis = analysisFile.getAnalysis();
throwAccessDeniedExceptionIfLocked(analysis);
Study study = analysis.getStudy();
try {
Path analysisFolder = analysisHelper.getAnalysisFolder(analysis);
if (Files.notExists(analysisFolder)) {
Files.createDirectories(analysisFolder);
}
Path targetPath = analysisFolder.resolve(analysisFile.getUuid());
byte[] content = fileContentDTO.getContent().getBytes(StandardCharsets.UTF_8);
try (final InputStream stream = new ByteArrayInputStream(content)) {
Files.copy(stream, targetPath, REPLACE_EXISTING);
}
analysisFile.setUpdated(new Date());
analysisFile.setEntryPoint(analysisFile.getEntryPoint());
analysisFile.setUpdatedBy(updatedBy);
analysisFile.setContentType(CommonFileUtils.getContentType(analysisFile.getRealName(), targetPath.toString()));
analysisFile.incrementVersion();
analysisFile.setAntivirusStatus(AntivirusStatus.SCANNING);
analysisFile.setAntivirusDescription(null);
final AnalysisFile saved = analysisFileRepository.save(analysisFile);
eventPublisher.publishEvent(new AntivirusJobEvent(this, new AntivirusJob(saved.getId(), saved.getRealName(), new FileInputStream(targetPath.toString()), AntivirusJobFileType.ANALYSIS_FILE)));
} catch (IOException | RuntimeException ex) {
String message = "error save file to disk, filename=" + analysisFile.getUuid() + " ex=" + ex.toString();
LOGGER.error(message, ex);
throw new IOException(message);
}
}
use of com.odysseusinc.arachne.portal.model.Analysis in project ArachneCentralAPI by OHDSI.
the class BaseAnalysisServiceImpl method moveAnalysis.
@Override
public Boolean moveAnalysis(Long id, Integer index) {
A analysis = analysisRepository.findOne(id);
Study study = analysis.getStudy();
List<A> list = list(study);
list.remove(analysis);
list.add(index, analysis);
int ind = 0;
for (Analysis an : list) {
an.setOrd(ind++);
}
return true;
}
Aggregations