Skip to content

Commit

Permalink
More doc + code clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelkain committed Oct 20, 2023
1 parent 2dbb0e7 commit 86d5849
Showing 1 changed file with 10 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,6 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.ByteArrayResource;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.springframework.http.HttpStatusCode;
import org.springframework.http.MediaType;
Expand All @@ -87,7 +85,6 @@
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.multipart.MultipartFile;

import com.fasterxml.jackson.databind.ObjectMapper;
Expand Down Expand Up @@ -145,9 +142,6 @@ public class ImporterApiController implements ImporterApi {
@Value("${shanoir.import.directory}")
private String importDir;

@Autowired
private RestTemplate restTemplate;

@Autowired
private DicomDirGeneratorService dicomDirGeneratorService;

Expand Down Expand Up @@ -279,6 +273,15 @@ public ResponseEntity<Void> startImportJob(
}
}

/**
* cleanSeries is important here for import-from-zip file: when the ImagesCreatorAndDicomFileAnalyzer
* has declared some series as e.g. erroneous, we have to remove them from the import. For import-from
* pacs or from-sh-up it is different, as the ImagesCreatorAndDicomFileAnalyzer is called afterwards.
* Same here for multi-exam-imports: it calls uploadDicomZipFile method, where series could be classed
* as erroneous and when startImportJob is called, we want them to be removed from the import.
*
* @param importJob
*/
private void cleanSeries(final ImportJob importJob) {
for (Iterator<Patient> patientIt = importJob.getPatients().iterator(); patientIt.hasNext();) {
Patient patient = patientIt.next();
Expand Down Expand Up @@ -309,7 +312,6 @@ public ResponseEntity<ImportJob> queryPACS(
importJob.setWorkFolder("");
importJob.setFromPacs(true);
importJob.setUserId(KeycloakUtil.getTokenUserId());

} catch (ShanoirException e) {
throw new RestServiceException(
new ErrorModel(HttpStatus.UNPROCESSABLE_ENTITY.value(), e.getMessage(), null));
Expand All @@ -332,12 +334,11 @@ public ResponseEntity<ImportJob> importDicomZipFile(
MockMultipartFile multiPartFile;
try {
multiPartFile = new MockMultipartFile(tempFile.getName(), tempFile.getName(), APPLICATION_ZIP, new FileInputStream(tempFile.getAbsolutePath()));

// Import dicomfile
return uploadDicomZipFile(multiPartFile);
} catch (IOException e) {
LOG.error("ERROR while loading zip fiole, please contact an administrator");
e.printStackTrace();
LOG.error(e.getMessage(), e);
return new ResponseEntity<>(HttpStatus.NOT_ACCEPTABLE);
} finally {
// Delete temp file which is useless now
Expand Down Expand Up @@ -374,12 +375,9 @@ public ResponseEntity<EegImportJob> uploadEEGZipFile(
if (!userImportDir.exists()) {
userImportDir.mkdirs(); // create if not yet existing
}

// Unzip the file and get the elements
File tempFile = ImportUtils.saveTempFile(userImportDir, eegFile);

File importJobDir = ImportUtils.saveTempFileCreateFolderAndUnzip(tempFile, eegFile, false);

EegImportJob importJob = new EegImportJob();
importJob.setUserId(userId);
importJob.setArchive(eegFile.getOriginalFilename());
Expand Down

0 comments on commit 86d5849

Please sign in to comment.