Search in sources :

Example 36 with Project

use of ca.corefacility.bioinformatics.irida.model.project.Project in project irida by phac-nml.

the class ProjectSamplesMetadataTemplateController method getMetadataTemplateListPage.

/**
 * Get the page to create a new {@link MetadataTemplate}
 *
 * @param projectId
 * 		{@link Long} identifier for a {@link Project}
 * @param model
 * 		{@link Model} spring page model
 * @param principal
 * 		{@link Principal} currently logged in user
 *
 * @return {@link String} path to the new template page
 */
@RequestMapping("/new")
public String getMetadataTemplateListPage(@PathVariable Long projectId, Model model, Principal principal) {
    Project project = projectService.read(projectId);
    // Add an empty MetadataTemplate. This facilitates code reuse for this page
    // since it is used for both creation and updating a template, and the html
    // is looking for a template object.
    model.addAttribute("template", new UIMetadataTemplate());
    projectControllerUtils.getProjectTemplateDetails(model, principal, project);
    return "projects/project_samples_metadata_template";
}
Also used : Project(ca.corefacility.bioinformatics.irida.model.project.Project) UIMetadataTemplate(ca.corefacility.bioinformatics.irida.ria.web.models.UIMetadataTemplate) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 37 with Project

use of ca.corefacility.bioinformatics.irida.model.project.Project in project irida by phac-nml.

the class ProjectSamplesMetadataTemplateController method deleteMetadataTemplate.

/**
 * Delete a {@link MetadataTemplate} within a {@link Project}
 *
 * @param projectId
 * 		{@link Long} identifier for a {@link Project}
 * @param templateId
 * 		{@link Long} identifier for a {@link MetadataTemplate}
 *
 * @return {@link String} redirects to project - settings - metadata templates
 */
@RequestMapping(value = "/delete/{templateId}", method = RequestMethod.POST)
public String deleteMetadataTemplate(@PathVariable Long projectId, @PathVariable Long templateId) {
    Project project = projectService.read(projectId);
    metadataTemplateService.deleteMetadataTemplateFromProject(project, templateId);
    return "redirect:/projects/" + projectId + "/settings/metadata-templates";
}
Also used : Project(ca.corefacility.bioinformatics.irida.model.project.Project) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 38 with Project

use of ca.corefacility.bioinformatics.irida.model.project.Project in project irida by phac-nml.

the class ProjectSamplesMetadataTemplateController method saveMetadataTemplate.

/**
 * Save or update a {@link MetadataTemplate} within a {@link Project}
 *
 * @param projectId
 * 		{@link Long} identifier for a {@link Project}
 * @param template
 * 		A {@link UIMetadataTemplate} to save to a {@link Project}
 *
 * @return {@link String} redirects to the template page.
 */
@RequestMapping(value = "/save", method = RequestMethod.POST)
public String saveMetadataTemplate(@PathVariable Long projectId, UIMetadataTemplate template) {
    Project project = projectService.read(projectId);
    List<MetadataTemplateField> metadataFields = new ArrayList<>();
    for (String field : template.getFields()) {
        MetadataTemplateField metadataTemplateField = metadataTemplateService.readMetadataFieldByLabel(field);
        if (metadataTemplateField == null) {
            metadataTemplateField = new MetadataTemplateField(field, "text");
            metadataTemplateService.saveMetadataField(metadataTemplateField);
        }
        metadataFields.add(metadataTemplateField);
    }
    MetadataTemplate metadataTemplate;
    if (template.getId() != null) {
        metadataTemplate = metadataTemplateService.read(template.getId());
        metadataTemplate.setName(template.getName());
        metadataTemplate.setFields(metadataFields);
        metadataTemplateService.updateMetadataTemplateInProject(metadataTemplate);
    } else {
        ProjectMetadataTemplateJoin projectMetadataTemplateJoin = metadataTemplateService.createMetadataTemplateInProject(new MetadataTemplate(template.getName(), metadataFields), project);
        metadataTemplate = projectMetadataTemplateJoin.getObject();
    }
    return "redirect:/projects/" + projectId + "/metadata-templates/" + metadataTemplate.getId();
}
Also used : Project(ca.corefacility.bioinformatics.irida.model.project.Project) MetadataTemplate(ca.corefacility.bioinformatics.irida.model.sample.MetadataTemplate) UIMetadataTemplate(ca.corefacility.bioinformatics.irida.ria.web.models.UIMetadataTemplate) ArrayList(java.util.ArrayList) ProjectMetadataTemplateJoin(ca.corefacility.bioinformatics.irida.model.joins.impl.ProjectMetadataTemplateJoin) MetadataTemplateField(ca.corefacility.bioinformatics.irida.model.sample.MetadataTemplateField) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 39 with Project

use of ca.corefacility.bioinformatics.irida.model.project.Project in project irida by phac-nml.

the class CartController method removeProjectSamples.

/**
 * Delete a {@link Sample} from the cart from a given {@link Project}
 *
 * @param projectId
 *            The {@link Project} ID
 * @param sampleIds
 *            The {@link Sample} ID
 * @return a map stating success
 */
@RequestMapping(value = "/project/{projectId}/samples", method = RequestMethod.DELETE, consumes = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
public Map<String, Object> removeProjectSamples(@PathVariable Long projectId, @RequestBody Set<Long> sampleIds) {
    Project project = projectService.read(projectId);
    Set<Sample> samples = loadSamplesForProject(project, sampleIds);
    Set<Sample> selectedSamplesForProject = getSelectedSamplesForProject(project);
    selectedSamplesForProject.removeAll(samples);
    if (selectedSamplesForProject.isEmpty()) {
        selected.remove(project);
    }
    return ImmutableMap.of("success", true);
}
Also used : Project(ca.corefacility.bioinformatics.irida.model.project.Project) Sample(ca.corefacility.bioinformatics.irida.model.sample.Sample) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 40 with Project

use of ca.corefacility.bioinformatics.irida.model.project.Project in project irida by phac-nml.

the class CartController method getProjectsAsList.

/**
 * Get the {@link Project}s in the cart as a List for JSON serialization
 *
 * @return A List<Map<String,Object>> containing the relevant Project and
 *         Sample information
 */
private List<Map<String, Object>> getProjectsAsList() {
    Set<Project> projects = selected.keySet();
    List<Map<String, Object>> projectList = new ArrayList<>();
    for (Project p : projects) {
        Set<Sample> selectedSamplesForProject = selected.get(p);
        List<Map<String, Object>> samples = getSamplesAsList(selectedSamplesForProject, p.getId());
        Map<String, Object> projectMap = ImmutableMap.of("id", p.getId(), "label", p.getLabel(), "samples", samples);
        projectList.add(projectMap);
    }
    return projectList;
}
Also used : Project(ca.corefacility.bioinformatics.irida.model.project.Project) Sample(ca.corefacility.bioinformatics.irida.model.sample.Sample) ArrayList(java.util.ArrayList) HashMap(java.util.HashMap) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap)

Aggregations

Project (ca.corefacility.bioinformatics.irida.model.project.Project)331 Test (org.junit.Test)190 Sample (ca.corefacility.bioinformatics.irida.model.sample.Sample)120 User (ca.corefacility.bioinformatics.irida.model.user.User)88 WithMockUser (org.springframework.security.test.context.support.WithMockUser)80 ProjectSampleJoin (ca.corefacility.bioinformatics.irida.model.joins.impl.ProjectSampleJoin)71 Join (ca.corefacility.bioinformatics.irida.model.joins.Join)62 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)51 RelatedProjectJoin (ca.corefacility.bioinformatics.irida.model.joins.impl.RelatedProjectJoin)37 ArrayList (java.util.ArrayList)34 ProjectUserJoin (ca.corefacility.bioinformatics.irida.model.joins.impl.ProjectUserJoin)30 SampleSequencingObjectJoin (ca.corefacility.bioinformatics.irida.model.sample.SampleSequencingObjectJoin)30 AnalysisSubmission (ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission)27 ProjectRole (ca.corefacility.bioinformatics.irida.model.enums.ProjectRole)25 ReferenceFile (ca.corefacility.bioinformatics.irida.model.project.ReferenceFile)23 ProjectEvent (ca.corefacility.bioinformatics.irida.model.event.ProjectEvent)22 ProjectAnalysisSubmissionJoin (ca.corefacility.bioinformatics.irida.model.workflow.submission.ProjectAnalysisSubmissionJoin)22 List (java.util.List)22 UserRoleSetProjectEvent (ca.corefacility.bioinformatics.irida.model.event.UserRoleSetProjectEvent)21 ImmutableMap (com.google.common.collect.ImmutableMap)21