Skip to content

Commit

Permalink
Merge pull request #1408 from phac-nml/metadata-uploader-batch-endpoints
Browse files Browse the repository at this point in the history
Metadata uploader batch endpoints
  • Loading branch information
ericenns authored Jan 10, 2023
2 parents 463e7d9 + 7fd0d33 commit 32b31f7
Show file tree
Hide file tree
Showing 63 changed files with 1,565 additions and 2,095 deletions.
Binary file added doc/user/user/sample-metadata/images/loading.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file modified doc/user/user/sample-metadata/images/upload-preview-errors.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified doc/user/user/sample-metadata/images/upload-preview-success.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified doc/user/user/sample-metadata/images/upload-preview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified doc/user/user/sample-metadata/images/upload-selection.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 14 additions & 6 deletions doc/user/user/sample-metadata/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,23 +37,31 @@ Links to the upload page can be found:

Any CSV or Excel spreadsheet containing metadata for samples in a project can be uploaded through the IRIDA web interface. One of the column in the table __must__ correspond to the sample name within the project. In this example spreadsheet, the `NLEP #` column is the sample name.

The first step is to select the CSV or Excel file containing the data. Either click on the square label `Click or drop Excel/CSV file containing metadata for samples in this project.` or drag and drop the file from your file browser.
The first step is to select the CSV or Excel file containing the data. Either click or drag the file into the drop zone from your file browser.

![Select spreadsheet](images/upload-selection.png)

After uploading a spreadsheet, the column corresponding to the sample name must be selected. After selecting the column header, press the `Preview the data` button.
After uploading a spreadsheet, you will be brought to the `Map Columns` step. The column corresponding to the sample name must be selected.

![Select name column.](images/upload-column.png)
![Select name column.](images/upload-column-before.png)

Rows that do not match an existing sample name are identified with the `New` tag. If selected, these samples will automatically be created. Rows that do match an existing sample name will be updated. Only select the rows that are to be uploaded and press the `Upload the data` button.
Once the sample name column is selected, a table will be displayed listing all the metadata fields. You can review the existing and target metadata field restrictions here. Press the `Review the data` button to continue.

![Select name column.](images/upload-column-after.png)

You may select the rows that are to be uploaded on the `Review Data` step. Rows that do not match an existing sample name are identified with the `New` tag. If selected, these samples will automatically be created. Rows that match an existing sample name will be updated.

![Preview Upload](images/upload-preview.png)

Rows that have an invalid sample name will be highlighted in red. These errors should be fixed within the spreadsheet and re-imported.
Rows that have an invalid sample name will be highlighted in red. These errors should be fixed within the spreadsheet and re-imported. Press the `Upload the data` button to continue.

![Upload Preview Errors](images/upload-preview-errors.png)

The complete page will be displayed on a successful upload. Clicking on the `Upload another file` button will redirect to the beginning of a new upload.
Progress will be displayed while uploading. Please be patient while uploading large data sets. Do not close the window or leave the page.

![Upload Preview Errors](images/loading.png)

On a successful upload, you will be brought to the `Complete` step. Clicking on the `Upload another file` button will redirect to the beginning of a new upload.

![Upload Preview Success](images/upload-preview-success.png)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
package ca.corefacility.bioinformatics.irida.model.sample;

import ca.corefacility.bioinformatics.irida.model.sample.metadata.MetadataEntry;
import org.hibernate.envers.Audited;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import java.util.List;
import java.util.Objects;

import javax.persistence.*;
import javax.validation.constraints.NotNull;
import java.util.List;
import java.util.Objects;

import org.hibernate.envers.Audited;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import ca.corefacility.bioinformatics.irida.model.sample.metadata.MetadataEntry;

/**
* Describes an individual field in a {@link MetadataTemplate}.
*/
@Entity
@Table(name = "metadata_field")
@Table(name = "metadata_field",
uniqueConstraints = @UniqueConstraint(columnNames = { "label" }, name = "UK_METADATA_FIELD_LABEL"))
@Audited
@EntityListeners(AuditingEntityListener.class)
public class MetadataTemplateField {
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package ca.corefacility.bioinformatics.irida.ria.web.ajax.dto;

/**
* UI response to create a new sample
*/
public class CreateSampleResponse extends UpdateSampleResponse {
private Long sampleId;

public CreateSampleResponse(String errorMessage) {
super(true, errorMessage);
}

public CreateSampleResponse(Long sampleId) {
super(false);
this.sampleId = sampleId;
}

public Long getSampleId() {
return sampleId;
}

public void setSampleId(Long sampleId) {
this.sampleId = sampleId;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,19 @@
* UI Request to update an existing sample
*/
public class UpdateSampleRequest extends CreateSampleRequest {
public UpdateSampleRequest(String name, String organism, String description, List<MetadataEntryModel> metadata) {
private Long sampleId;

public UpdateSampleRequest(Long sampleID, String name, String organism, String description,
List<MetadataEntryModel> metadata) {
super(name, organism, description, metadata);
this.sampleId = sampleID;
}

public Long getSampleId() {
return sampleId;
}

public void setSampleId(Long sampleId) {
this.sampleId = sampleId;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package ca.corefacility.bioinformatics.irida.ria.web.ajax.dto;

/**
* UI response to update an existing sample
*/
public class UpdateSampleResponse {
private boolean error;
private String errorMessage;

public UpdateSampleResponse() {
}

public UpdateSampleResponse(boolean error) {
this.error = error;
}

public UpdateSampleResponse(boolean error, String errorMessage) {
this.error = error;
this.errorMessage = errorMessage;
}

public boolean isError() {
return error;
}

public void setError(boolean error) {
this.error = error;
}

public String getErrorMessage() {
return errorMessage;
}

public void setErrorMessage(String errorMessage) {
this.errorMessage = errorMessage;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package ca.corefacility.bioinformatics.irida.ria.web.ajax.dto.ajax;

import java.util.Map;

/**
* AJAX response to return multiple responses to the client
*/
public class AjaxMultipleResponse extends AjaxResponse {
private Map<String, Object> responses;

public AjaxMultipleResponse(Map<String, Object> responses) {
this.responses = responses;
}

public Map<String, Object> getResponses() {
return responses;
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,12 @@ public List<ProjectMetadataField> getMetadataFieldsForProject(@RequestParam Long
@PostMapping("/fields")
public ResponseEntity<AjaxResponse> createMetadataFieldsForProject(@RequestParam Long projectId,
@RequestBody List<ProjectMetadataField> fields, Locale locale) {
return ResponseEntity.ok(
new AjaxSuccessResponse(service.createMetadataFieldsForProject(projectId, fields, locale)));
try {
return ResponseEntity.ok(
new AjaxSuccessResponse(service.createMetadataFieldsForProject(projectId, fields, locale)));
} catch (Exception e) {
return ResponseEntity.status(HttpStatus.CONFLICT).body(new AjaxErrorResponse(e.getMessage()));
}
}

/**
Expand Down
Loading

0 comments on commit 32b31f7

Please sign in to comment.