Package services.gui
Class ImportExportService
- java.lang.Object
-
- services.gui.ImportExportService
-
@Singleton public class ImportExportService extends java.lang.ObjectService class for JATOS Controllers (not Publix).
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringSESSION_UNZIPPED_STUDY_DIR
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcleanupAfterStudyImport()java.nio.file.PathcreateStudyExportZipFile(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)StudyimportStudyConfirmed(User signedinUser, boolean keepProperties, boolean keepAssets, boolean keepCurrentAssetsName, boolean renameAssets)
-
-
-
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.IOExceptionForbiddenExceptionValidationExceptionImportExportException
-
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.IOExceptionForbiddenExceptionNotFoundExceptionValidationException
-
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
-
-