Skip to content

Commit

Permalink
Merge pull request #950 from tom114/hotfix-copy-sample-ownership-rest
Browse files Browse the repository at this point in the history
HOTFIX: Added ownership flag to copying sample to project in REST API
  • Loading branch information
deepsidhu85 committed Feb 24, 2021
2 parents c0d816f + 9f4f81a commit 261d27a
Show file tree
Hide file tree
Showing 5 changed files with 171 additions and 61 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Expand Up @@ -3,7 +3,8 @@ Changes

21.01 to 20.05
--------------
*[UI]: Fixed bug which was preventing a user from viewing more than 5 rows of a tabular result file. (21.01.1)
* [UI]: Fixed bug which was preventing a user from viewing more than 5 rows of a tabular result file. (21.01.1)
* [REST]: Added `ownership` option when copying sample to project in REST API (21.01.2)

20.09 to 21.01
--------------
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Expand Up @@ -4,7 +4,7 @@
<groupId>ca.corefacility.bioinformatics</groupId>
<artifactId>irida</artifactId>
<packaging>war</packaging>
<version>21.01.1</version>
<version>21.01.2</version>
<name>irida</name>
<url>http://www.irida.ca</url>

Expand Down
Expand Up @@ -14,10 +14,7 @@
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.view.RedirectView;

Expand Down Expand Up @@ -91,14 +88,16 @@ public RESTProjectSamplesController(ProjectService projectService, SampleService
*
* @param projectId the project to copy the sample to.
* @param sampleIds the collection of sample IDs to copy.
* @param ownership Whether the receiving project should have ownership of the sample
* @param response a reference to the servlet response.
* @param locale The user's in case a warning message is needed
* @param locale The user's in case a warning message is needed
* @return the response indicating that the sample was joined to the
* project.
*/
@RequestMapping(value = "/api/projects/{projectId}/samples", method = RequestMethod.POST, consumes = "application/idcollection+json")
public ModelMap copySampleToProject(final @PathVariable Long projectId, final @RequestBody List<Long> sampleIds,
HttpServletResponse response, Locale locale) {
@RequestParam(name = "ownership", defaultValue = "false") boolean ownership, HttpServletResponse response,
Locale locale) {

ModelMap modelMap = new ModelMap();

Expand All @@ -112,7 +111,7 @@ public ModelMap copySampleToProject(final @PathVariable Long projectId, final @R
Sample sample = sampleService.read(sampleId);
Join<Project, Sample> join = null;
try {
join = projectService.addSampleToProject(p, sample, false);
join = projectService.addSampleToProject(p, sample, ownership);
} catch (ExistingSampleNameException e) {
logger.error(
"Could not add sample to project because another sample exists with this name :" + e.getSample()
Expand Down

0 comments on commit 261d27a

Please sign in to comment.