Class UIMetadataImportService


  • @Component
    public class UIMetadataImportService
    extends java.lang.Object
    UI service to handle importing metadata files, so they can be saved to the session.
    • Method Detail

      • createProjectSampleMetadata

        public SampleMetadataStorage createProjectSampleMetadata​(javax.servlet.http.HttpSession session,
                                                                 java.lang.Long projectId,
                                                                 org.springframework.web.multipart.MultipartFile file)
                                                          throws java.lang.Exception
        Upload CSV or Excel file containing sample metadata and extract the headers. The file is stored in the session until the column that corresponds to a Sample identifier has been sent.
        Parameters:
        session - HttpSession
        projectId - Long identifier for the current Project
        file - MultipartFile The csv or excel file containing the metadata.
        Returns:
        Map of headers and rows from the csv or excel file for the user to select the header corresponding the Sample identifier.
        Throws:
        java.lang.Exception - if there is an error reading the file
      • setProjectSampleMetadataSampleId

        public java.lang.String setProjectSampleMetadataSampleId​(javax.servlet.http.HttpSession session,
                                                                 java.lang.Long projectId,
                                                                 java.lang.String sampleNameColumn)
        Add the metadata to specific Sample based on the selected column to correspond to the Sample id.
        Parameters:
        session - HttpSession.
        projectId - Long identifier for the current Project.
        sampleNameColumn - String the header to used to represent the Sample identifier.
        Returns:
        String containing a complete message.
      • saveProjectSampleMetadata

        public java.lang.String saveProjectSampleMetadata​(java.util.Locale locale,
                                                          javax.servlet.http.HttpSession session,
                                                          java.lang.Long projectId,
                                                          java.util.List<java.lang.String> sampleNames)
                                                   throws SavedMetadataException
        Save uploaded metadata
        Parameters:
        locale - Locale of the current user.
        session - HttpSession
        projectId - Long identifier for the current project
        sampleNames - List of String sample names
        Returns:
        String that returns a message and potential errors.
        Throws:
        SavedMetadataException - if there is an error saving the metadata
      • clearProjectSampleMetadata

        public void clearProjectSampleMetadata​(javax.servlet.http.HttpSession session,
                                               java.lang.Long projectId)
        Clear any uploaded sample metadata stored into the session.
        Parameters:
        session - HttpSession
        projectId - identifier for the Project currently uploaded metadata to.
      • getProjectSampleMetadata

        public SampleMetadataStorage getProjectSampleMetadata​(javax.servlet.http.HttpSession session,
                                                              java.lang.Long projectId)
        Get the currently stored metadata.
        Parameters:
        session - HttpSession
        projectId - Long identifier for the current Project
        Returns:
        the currently stored SampleMetadataStorage