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

Fix for updating sample modified date when metadata is deleted #1457

Merged
merged 3 commits into from
Feb 2, 2023
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* [UI]: Fixed bug where the `User` column was named `User Group` on the admin User Groups page. [See PR 1450](https://github.com/phac-nml/irida/pull/1450)
* [Developer]: Replaced Apache OLTU with Nimbusds for performing OAuth2 authentication flow during syncing and Galaxy exporting. See [PR 1432](https://github.com/phac-nml/irida/pull/1432)
* [Developer/UI]: Performance enhancements to the metadata uploader. See [PR 1445](https://github.com/phac-nml/irida/pull/1445).
* [Developer/UI]: Fix for updating sample modified date when metadata is deleted. See [PR 1457](https://github.com/phac-nml/irida/pull/1457).

## [22.09.7] - 2022/01/24
* [UI]: Fixed bugs on NCBI Export page preventing the NCBI `submission.xml` file from being properly written. See [PR 1451](https://github.com/phac-nml/irida/pull/1451)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,14 @@

import java.io.IOException;
import java.security.Principal;
import java.util.*;
import java.util.List;
import java.util.Locale;
import java.util.Set;

import javax.servlet.http.HttpServletResponse;
import javax.validation.ConstraintViolation;
import javax.validation.ConstraintViolationException;

import ca.corefacility.bioinformatics.irida.exceptions.ConcatenateException;
import ca.corefacility.bioinformatics.irida.exceptions.EntityExistsException;
import ca.corefacility.bioinformatics.irida.exceptions.EntityNotFoundException;
import ca.corefacility.bioinformatics.irida.model.sequenceFile.SequencingObject;
import ca.corefacility.bioinformatics.irida.ria.web.samples.dto.*;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
Expand All @@ -22,16 +18,17 @@
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;

import ca.corefacility.bioinformatics.irida.exceptions.ConcatenateException;
import ca.corefacility.bioinformatics.irida.exceptions.EntityExistsException;
import ca.corefacility.bioinformatics.irida.exceptions.EntityNotFoundException;
import ca.corefacility.bioinformatics.irida.model.sample.Sample;
import ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFile;

import ca.corefacility.bioinformatics.irida.model.sequenceFile.SequencingObject;
import ca.corefacility.bioinformatics.irida.ria.web.ajax.dto.ajax.AjaxErrorResponse;
import ca.corefacility.bioinformatics.irida.ria.web.ajax.dto.ajax.AjaxResponse;
import ca.corefacility.bioinformatics.irida.ria.web.ajax.dto.ajax.AjaxSuccessResponse;
import ca.corefacility.bioinformatics.irida.ria.web.samples.dto.*;
import ca.corefacility.bioinformatics.irida.ria.web.services.UIAnalysesService;

import ca.corefacility.bioinformatics.irida.ria.web.samples.dto.SampleDetails;

import ca.corefacility.bioinformatics.irida.ria.web.services.UISampleService;

/**
Expand Down Expand Up @@ -62,8 +59,7 @@ public ResponseEntity<List<SampleSequencingObjectFileModel>> uploadSequenceFiles
try {
return ResponseEntity.ok(uiSampleService.uploadSequenceFiles(sampleId, request));
} catch (IOException e) {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
.body(null);
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
}
}

Expand All @@ -80,8 +76,7 @@ public ResponseEntity<List<SampleSequencingObjectFileModel>> uploadFast5Files(@P
try {
return ResponseEntity.ok(uiSampleService.uploadFast5Files(sampleId, request));
} catch (IOException e) {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
.body(null);
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
}
}

Expand All @@ -98,8 +93,7 @@ public ResponseEntity<List<SampleGenomeAssemblyFileModel>> uploadAssemblies(@Pat
try {
return ResponseEntity.ok(uiSampleService.uploadAssemblies(sampleId, request));
} catch (IOException e) {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
.body(null);
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
}
}

Expand Down Expand Up @@ -145,8 +139,7 @@ public ResponseEntity<AjaxResponse> updateSampleDetails(@PathVariable Long id,
for (ConstraintViolation a : e.getConstraintViolations()) {
constraintViolations += a.getMessage() + "\n";
}
return ResponseEntity.status(HttpStatus.BAD_REQUEST)
.body(new AjaxErrorResponse(constraintViolations));
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new AjaxErrorResponse(constraintViolations));
}
}

Expand All @@ -165,17 +158,16 @@ public ResponseEntity<AjaxResponse> updateDefaultSequencingObjectForSample(@Path
return ResponseEntity.ok(new AjaxSuccessResponse(
uiSampleService.updateDefaultSequencingObjectForSample(id, sequencingObjectId, locale)));
} catch (EntityNotFoundException e) {
return ResponseEntity.status(HttpStatus.BAD_REQUEST)
.body(new AjaxErrorResponse(e.getMessage()));
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new AjaxErrorResponse(e.getMessage()));
}
}

/**
* Update the default genome assembly for the sample
*
* @param id {@link Long} identifier for the sample
* @param id {@link Long} identifier for the sample
* @param genomeAssemblyId The genome assembly identifier
* @param locale {@link Locale} for the currently logged in user
* @param locale {@link Locale} for the currently logged in user
* @return {@link ResponseEntity} explaining to the user the results of the update.
*/
@PutMapping(value = "/{id}/default-genome-assembly")
Expand All @@ -185,8 +177,7 @@ public ResponseEntity<AjaxResponse> updateDefaultGenomeAssemblyForSample(@PathVa
return ResponseEntity.ok(new AjaxSuccessResponse(
uiSampleService.updateDefaultGenomeAssemblyForSample(id, genomeAssemblyId, locale)));
} catch (EntityNotFoundException e) {
return ResponseEntity.status(HttpStatus.BAD_REQUEST)
.body(new AjaxErrorResponse(e.getMessage()));
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new AjaxErrorResponse(e.getMessage()));
}
}

Expand All @@ -204,8 +195,7 @@ public ResponseEntity<List<SampleAnalyses>> getSampleAnalyses(@PathVariable Long
try {
return ResponseEntity.ok(uiAnalysesService.getSampleAnalyses(sampleId, principal, locale));
} catch (Exception e) {
return ResponseEntity.status(HttpStatus.BAD_REQUEST)
.body(null);
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(null);
}
}

Expand All @@ -227,16 +217,17 @@ public ResponseEntity<AddSampleMetadataResponse> addSampleMetadata(@PathVariable
* Remove metadata field and entry from {@link Sample}
*
* @param projectId The project identifier
* @param metadataFieldId The metadata field id
* @param sampleId The sample identifier
* @param metadataFieldId The metadata field id
* @param metadataEntryId The metadata entry identifier
* @param locale {@link Locale} for the currently logged in user
* @return {@link ResponseEntity} explaining to the user the results of the deletion.
*/
@DeleteMapping(value = "/metadata")
public ResponseEntity<AjaxResponse> removeSampleMetadata(@RequestParam Long projectId,
public ResponseEntity<AjaxResponse> removeSampleMetadata(@RequestParam Long projectId, @RequestParam Long sampleId,
@RequestParam Long metadataFieldId, @RequestParam Long metadataEntryId, Locale locale) {
return ResponseEntity.ok(new AjaxSuccessResponse(
uiSampleService.removeSampleMetadata(projectId, metadataFieldId, metadataEntryId, locale)));
uiSampleService.removeSampleMetadata(projectId, sampleId, metadataFieldId, metadataEntryId, locale)));
}

/**
Expand All @@ -254,8 +245,7 @@ public ResponseEntity<AjaxResponse> updateSampleMetadata(@PathVariable Long id,
return ResponseEntity.ok(new AjaxSuccessResponse(
uiSampleService.updateSampleMetadata(id, updateSampleMetadataRequest, locale)));
} catch (EntityExistsException e) {
return ResponseEntity.status(HttpStatus.BAD_REQUEST)
.body(new AjaxErrorResponse(e.getMessage()));
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new AjaxErrorResponse(e.getMessage()));
}
}

Expand All @@ -273,7 +263,6 @@ public ResponseEntity<AjaxResponse> getFilesForSample(@PathVariable Long id,
}

/**

* Get updated sample sequencing objects for given sequencing object ids
*
* @param id Identifier for a sample
Expand Down Expand Up @@ -341,8 +330,7 @@ public ResponseEntity<List<SampleSequencingObjectFileModel>> concatenateSequence
return ResponseEntity.ok(uiSampleService.concatenateSequenceFiles(sampleId, sequenceObjectIds, newFileName,
removeOriginals));
} catch (ConcatenateException e) {
return ResponseEntity.status(HttpStatus.BAD_REQUEST)
.body(null);
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(null);
}
}

Expand Down
Loading