Package services.gui

Class ImportExportService


  • @Singleton
    public class ImportExportService
    extends java.lang.Object
    Service class for JATOS Controllers (not Publix).
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void cleanupAfterStudyImport()  
      java.nio.file.Path createStudyExportZipFile​(Study study)
      Returns a JATOS study archive packed as ZIP.
      java.util.Map<java.lang.String,​java.lang.Object> importStudy​(User signedinUser, java.nio.file.Path file)
      Import a uploaded JATOS study archive There are 5 possible cases: (udir - name of uploaded study asset dir, cdir - name of current study asset dir)
      Study importStudyConfirmed​(User signedinUser, boolean keepProperties, boolean keepAssets, boolean keepCurrentAssetsName, boolean renameAssets)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • SESSION_UNZIPPED_STUDY_DIR

        public static final java.lang.String SESSION_UNZIPPED_STUDY_DIR
        See Also:
        Constant Field Values
    • Method Detail

      • importStudy

        public java.util.Map<java.lang.String,​java.lang.Object> importStudy​(User signedinUser,
                                                                                  java.nio.file.Path file)
                                                                           throws java.io.IOException,
                                                                                  ForbiddenException,
                                                                                  ValidationException,
                                                                                  ImportExportException
        Import a uploaded JATOS study archive There are 5 possible cases: (udir - name of uploaded study asset dir, cdir - name of current study asset dir)

        1) study exists - udir exists - udir == cdir : ask confirmation to overwrite study and/or dir 2) study exists - udir exists - udir != cdir : ask confirmation to overwrite study and/or (dir && rename to cdir) 3) study exists - !udir exists : shouldn't happen, ask confirmation to overwrite study 4) !study exists - udir exists : ask to rename dir (generate new dir name) 5) !study exists - !udir exists : new study - write both

        Throws:
        java.io.IOException
        ForbiddenException
        ValidationException
        ImportExportException
      • importStudyConfirmed

        public Study importStudyConfirmed​(User signedinUser,
                                          boolean keepProperties,
                                          boolean keepAssets,
                                          boolean keepCurrentAssetsName,
                                          boolean renameAssets)
                                   throws java.io.IOException,
                                          ForbiddenException,
                                          NotFoundException,
                                          ValidationException
        Parameters:
        signedinUser - The signed-in user.
        keepProperties - If true and the study exists already in JATOS the current properties are kept. Default is `false` (properties are overwritten by default). If the study doesn't already exist, this parameter has no effect.
        keepAssets - If true and the study exists already in JATOS the current study assets directory is kept. Default is `false` (assets are overwritten by default). If the study doesn't already exist, this parameter has no effect.
        keepCurrentAssetsName - If the assets are going to be overwritten (`keepAssets=false`), this flag indicates if the name of the currently installed assets directory should be kept. A `false` indicates that the name should be taken from the uploaded one. Default is `true`.
        renameAssets - If the study assets directory already exists in JATOS but belongs to a different study, it cannot be overwritten. In this case you can set `renameAssets=true` to let JATOS add a suffix to the assets directory name (original name + "_" + a number). Default is `true`.
        Throws:
        java.io.IOException
        ForbiddenException
        NotFoundException
        ValidationException
      • cleanupAfterStudyImport

        public void cleanupAfterStudyImport()
      • createStudyExportZipFile

        public java.nio.file.Path createStudyExportZipFile​(Study study)
                                                    throws java.io.IOException
        Returns a JATOS study archive packed as ZIP. It returns the File object located in the system's temp directory. The JATOS study archive will contain the study assets' directory and the study's JSON data (a .jas file).
        Throws:
        java.io.IOException