Package services.gui

Class StudyService


  • @Singleton
    public class StudyService
    extends java.lang.Object
    Service class for everthing Study related. Used by controllers
    • Method Detail

      • clone

        public Study clone​(Study study)
                    throws java.io.IOException
        Clones the given Study. Does not clone id, uuid, or date. Generates a new UUID for the clone. Copies the corresponding study assets. Does NOT persist the clone.
        Throws:
        java.io.IOException
      • changeUserMember

        public void changeUserMember​(Study study,
                                     User userToChange,
                                     boolean isMember)
                              throws ForbiddenException
        Changes the member user in the study. Additionally changes the user's worker in all of the study's batches. Persisting.
        Throws:
        ForbiddenException
      • addAllUserMembers

        public void addAllUserMembers​(Study study)
        Adds all users as members to the given study. Additionally adds all user's Jatos workers to the study's batches.
      • removeAllUserMembers

        public void removeAllUserMembers​(Study study)
        Removes all member users from the given study except the signed-in user. Additionally, removes all user's Jatos workers from the study's batches (except the signed-in user's workers).
      • changeComponentPosition

        public void changeComponentPosition​(java.lang.String newPosition,
                                            Study study,
                                            Component component)
                                     throws BadRequestException
        Changes the position of the given component within the given study to the new position given in newPosition. Remember the first position is 1 (and not 0). Throws BadRequestException if number has wrong format or number isn't within the studies positions.
        Throws:
        BadRequestException
      • createAndPersistStudy

        public Study createAndPersistStudy​(User signedinUser,
                                           Study study)
        Persists the given Study. Creates and persists the default Batch. If the study has components already it persists them too. Adds the given user to the users of this study.
      • updateStudyAndRenameAssets

        public void updateStudyAndRenameAssets​(Study study,
                                               Study updatedStudy,
                                               User signedinUser)
        Update properties of study with properties of updatedStudy.
      • updateStudyWithoutDirName

        public void updateStudyWithoutDirName​(Study study,
                                              Study updatedStudy,
                                              User signedinUser)
        Update properties of study with properties of updatedStudy but not Study's field dirName.
      • updateStudyAndRenameAssets

        public void updateStudyAndRenameAssets​(Study study,
                                               StudyProperties studyProperties,
                                               User signedinUser)
                                        throws java.io.IOException
        Update Study with given properties and persist. It doesn't update Study's dirName field.
        Throws:
        java.io.IOException
      • updateDescription

        public void updateDescription​(Study study,
                                      java.lang.String description,
                                      User signedinUser)
        Update Study's description and store new description hash in the study log
      • bindToStudy

        public void bindToStudy​(Study study,
                                StudyProperties studyProperties)
        Binds a study with values of study properties
      • renameStudyAssetsDir

        public void renameStudyAssetsDir​(Study study,
                                         java.lang.String newDirName)
                                  throws java.io.IOException
        Renames the directory in the file system and persists the study's property.
        Throws:
        java.io.IOException
      • bindToProperties

        public StudyProperties bindToProperties​(Study study)
        Fills a new StudyProperties with values from the given Study.
      • validate

        public void validate​(Study study)
                      throws ValidationException
        Validates the study by converting it to StudyProperties and uses its validate method. Throws ValidationException in case of an error.
        Throws:
        ValidationException
      • removeStudyInclAssets

        public void removeStudyInclAssets​(Study study,
                                          User signedinUser)
                                   throws java.io.IOException
        Removes the given study, its components, component results, study results, group results and batches and persists the changes to the database. It also deletes the study's assets from the disk.
        Throws:
        java.io.IOException
      • getStudyFromIdOrUuid

        public Study getStudyFromIdOrUuid​(java.lang.String idOrUuid)