Package services.gui
Class StudyService
- java.lang.Object
-
- services.gui.StudyService
-
@Singleton public class StudyService extends java.lang.ObjectService class for everthing Study related. Used by controllers
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddAllUserMembers(Study study)Adds all users as members to the given study.StudyPropertiesbindToProperties(Study study)Fills a new StudyProperties with values from the given Study.voidbindToStudy(Study study, StudyProperties studyProperties)Binds a study with values of study propertiesvoidchangeComponentPosition(java.lang.String newPosition, Study study, Component component)Changes the position of the given component within the given study to the new position given in newPosition.voidchangeUserMember(Study study, User userToChange, boolean isMember)Changes the member user in the study.Studyclone(Study study)Clones the given Study.StudycreateAndPersistStudy(User signedinUser, Study study)Persists the given Study.StudycreateAndPersistStudyAndAssetsDir(User signedinUser, StudyProperties props, boolean renameAssets)StudygetStudyFromIdOrUuid(java.lang.String idOrUuid)voidremoveAllUserMembers(Study study)Removes all member users from the given study except the signed-in user.voidremoveStudyInclAssets(Study study, User signedinUser)Removes the given study, its components, component results, study results, group results and batches and persists the changes to the database.voidrenameStudyAssetsDir(Study study, java.lang.String newDirName)Renames the directory in the file system and persists the study's property.voidupdateDescription(Study study, java.lang.String description, User signedinUser)Update Study's description and store new description hash in the study logvoidupdateStudyAndRenameAssets(Study study, Study updatedStudy, User signedinUser)Update properties of study with properties of updatedStudy.voidupdateStudyAndRenameAssets(Study study, StudyProperties studyProperties, User signedinUser)Update Study with given properties and persist.voidupdateStudyWithoutDirName(Study study, Study updatedStudy, User signedinUser)Update properties of study with properties of updatedStudy but not Study's field dirName.voidvalidate(Study study)Validates the study by converting it to StudyProperties and uses its validate method.
-
-
-
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 BadRequestExceptionChanges 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
-
createAndPersistStudyAndAssetsDir
public Study createAndPersistStudyAndAssetsDir(User signedinUser, StudyProperties props, boolean renameAssets) throws java.io.IOException, ForbiddenException
- Throws:
java.io.IOExceptionForbiddenException
-
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)
-
-