public class SurveyManager
extends java.lang.Object
Constructor and Description |
---|
SurveyManager() |
Modifier and Type | Method and Description |
---|---|
static Folder |
createFolder(User user,
long parentFolderId,
java.lang.String folderName,
java.lang.String folderDescription)
Creates a folder.
|
static Respondent |
createRespondent(long surveyId)
Create a new respondent object.
|
static Survey |
createSurvey(User user,
long folderId)
Creates a survey.
|
static void |
deleteFolder(User user,
long folderId)
Delete a folder by id.
|
static void |
deleteIncompleteRespondents(User user,
long surveyId)
Removes all incomplete respondents for the survey permanently.
|
static void |
deleteRespondent(User user,
long respondentId,
long surveyId)
Removes a respondent permanently.
|
static void |
deleteRespondentFromCache(User user,
long surveyId,
long respondentId)
Removes a respondent from cache.
|
static void |
deleteRespondents(User user,
long surveyId)
Removes all respondents for the survey permanently.
|
static void |
deleteSurvey(User user,
long surveyId)
Delete a survey by survey id.
|
static void |
exportCSV(CSVExportParameters parameters)
Exports survey data to a CSV file.
|
static Folder |
getFolder(User user,
long folderId)
Get a folder by id.
|
static Respondent |
getNotCachedRespondent(long respondentId,
long surveyId)
Get a respondent without adding it to the cache
|
static Respondent |
getRespondentForAdmin(long respondentId,
long surveyId)
Get a respondent by id.
|
static Respondent |
getRespondentForSurvey(long respondentId,
long surveyId)
Get a respondent by id.
|
static java.util.ArrayList |
getRespondentIds(User user,
long surveyId,
boolean incompleted)
Get all respondent ids for this survey.
|
static Survey |
getSurvey(User user,
long surveyId)
Gets the survey by id.
|
static Survey |
getSurvey(User user,
long surveyId,
java.lang.String languageCode)
Get a survey, by survey id and language code.
|
static Survey |
getSurvey(User user,
java.lang.String surveyId)
Gets a survey by custom survey id.
|
static java.lang.String |
getSurveyPreviewKey(long surveyId)
Get preview key for the survey
|
static long |
getSurveysCreatedCount(long userId,
long fromDate)
Gets the number of surveys created by a user from a specified fromDate to now
|
static long |
getSurveysCreatedCount(long userId,
long fromDate,
long toDate)
Gets the number of surveys created by a user from a specified fromDate to a specified toDate
|
static void |
releaseLock(long surveyId)
Releases a lock on a survey.
|
static void |
reloadSurvey(long surveyId)
Reloads the survey from cache.
|
static void |
removeSurveyFromCache(long surveyId)
This method will remove the survey from cache if survey has been loaded and cached in the
system.
|
static void |
storeRespondent(long respondentId,
long surveyId)
Save respondent to the storage.
|
static void |
updateSurvey(User user,
long surveyId)
Updates a survey in the storage.
|
public static Folder getFolder(User user, long folderId) throws SurveySystemException, SurveySecurityException
user
- UserfolderId
- Folder id to getSurveySystemException
- If an error occurs in the system.SurveySecurityException
- Thrown if the user doesn't have read access to the folder.public static Respondent getNotCachedRespondent(long respondentId, long surveyId) throws SurveySystemException
data.getSurveyProxy()
- Survey proxy associated with respondentrespondentId
- Respondent idSurveySystemException
- Survey System Exceptionpublic static java.lang.String getSurveyPreviewKey(long surveyId) throws SurveySystemException
surveyId
- SurveySystemException
- If an error occurs in the system.public static Respondent getRespondentForAdmin(long respondentId, long surveyId) throws SurveySystemException
getRespondentForSurvey()
and
getRespondentForAdmin()
is that in the first case the respondent will be
processed by 'cleaner-thread', which saves timed-out respondents to the storage and removes
them from the cache. In the second case, the respondent will be ignored by the cleaner.respondentId
- Respondent idsurveyId
- Survey idSurveySystemException
- If an error occurs in the system.public static Respondent getRespondentForSurvey(long respondentId, long surveyId) throws SurveySystemException
getRespondentForSurvey()
and
getRespondentForAdmin()
is that in the first case the respondent will be
processed by 'cleaner-thread', which saves timed-out respondents to the storage and removes
them from the cache. In the second case, the respondent will be ignored by the cleaner.respondentId
- Respondent idsurveyId
- Survey idSurveySystemException
- If an error occurs in the system.public static java.util.ArrayList getRespondentIds(User user, long surveyId, boolean incompleted) throws SurveySystemException, SurveySecurityException
user
- UsersurveyId
- Survey idincompleted
- False if uncompleted responses are not includedSurveySystemException
- If an error occurs in the system.SurveySecurityException
- If no accesspublic static Survey getSurvey(User user, long surveyId) throws SurveySecurityException, SurveySystemException
user
- UsersurveyId
- Survey idSurveySecurityException
- Thrown if the user doesn't have read access to the survey.SurveySystemException
- If an error occurs in the system.public static Survey getSurvey(User user, java.lang.String surveyId) throws SurveySecurityException, SurveySystemException
user
- UsersurveyId
- The custom survey idSurveySecurityException
- Thrown if the user doesn't have read access to the survey.SurveySystemException
- If error occurs.public static void reloadSurvey(long surveyId)
surveyId
- The survey id.public static Survey getSurvey(User user, long surveyId, java.lang.String languageCode) throws SurveySecurityException, SurveySystemException
null
.user
- UsersurveyId
- Id of survey to getsurveyId
- The language codecom.objectplanet.survey.persistence.PersistenceException
- Persistence exceptionSurveySecurityException
- If unauthorizedSurveySystemException
public static long getSurveysCreatedCount(long userId, long fromDate, long toDate) throws SurveySystemException
userId
- The user idfromDate
- The specified fromDatetoDate
- The specified toDateSurveySystemException
- If any error occurs in the system.public static long getSurveysCreatedCount(long userId, long fromDate) throws SurveySystemException
userId
- The user idfromDate
- The specified fromDateSurveySystemException
- If any error occurs in the system.public static Folder createFolder(User user, long parentFolderId, java.lang.String folderName, java.lang.String folderDescription) throws SurveySecurityException, SurveySystemException
user
- Current userparentFolderId
- Folder id where the new folder will be placed (parent folder)folderName
- New folder namefolderDescription
- New folder descriptionSurveySecurityException
- If the user is unauthorized to create folders in the
parent folder.SurveySystemException
- If any error occurs in the system.public static Respondent createRespondent(long surveyId) throws LockException, SurveySystemException
surveyId
- Survey idLockException
- If the survey is lockedSurveySystemException
- If an error occurs in the system.public static Survey createSurvey(User user, long folderId) throws SurveySecurityException, SurveySystemException
user
- UserfolderId
- Id of the folder where the new survey will be placed (parent folder). Main
folder has id -1.SurveySecurityException
- If the user is unauthorized to create surveys in this
folderSurveySystemException
- If any error occurs in the system.public static void deleteFolder(User user, long folderId) throws java.lang.IllegalArgumentException, SurveySecurityException, SurveySystemException
user
- Current userfolderId
- Id of folder to be deleted.SurveySecurityException
- If the user is not authorized to delete the folder.java.lang.IllegalArgumentException
- If the folder contains surveys or sub-folders and can't
be deleted.SurveySystemException
- If any error occurs in the system.public static void deleteIncompleteRespondents(User user, long surveyId) throws SurveySecurityException, SurveySystemException
surveyId
- Survey iduser
- UserSurveySecurityException
- If the user is unauthorized to delete respondents in the
surveySurveySystemException
- If any error occurs in the system.public static void deleteRespondent(User user, long respondentId, long surveyId) throws SurveySecurityException, SurveySystemException
respondentId
- Respondent iduser
- UsersurveyId
- Survey idSurveySystemException
- If any error occurs in the system.SurveySecurityException
- If the user is unauthorized to delete respondents in the
surveypublic static void deleteRespondentFromCache(User user, long surveyId, long respondentId) throws SurveySystemException
respondentId
- id of respondent to be removeduser
- UsersurveyId
- Survey idSurveySystemException
- If any error occurs in the system.SurveySecurityException
- If the user is unauthorized to delete respondents in the
cachepublic static void deleteRespondents(User user, long surveyId) throws SurveySecurityException, SurveySystemException
user
- UsersurveyId
- Survey idSurveySecurityException
- If the user is unauthorized to delete respondents in the
surveySurveySystemException
- If any error occurs in the system.public static void deleteSurvey(User user, long surveyId) throws LockException, SurveySecurityException, RespondentsExistException, SurveySystemException
deleteAllRespondents()
method. Require permission to delete the survey.user
- Current usersurveyId
- Id of survey to be deleted.RespondentsExistException
- If respondents existSurveySecurityException
- If the user is unauthorized to delete the survey.LockException
- If object is locked by another userSurveySystemException
- If an error occurs in the system.public static void removeSurveyFromCache(long surveyId)
surveyId
- public static void storeRespondent(long respondentId, long surveyId) throws SurveySystemException
Question.validate()
method).respondentId
- Respondent idsurveyId
- Survey idSurveySystemException
- If any error occurs in the system.public static void updateSurvey(User user, long surveyId) throws SurveySystemException, SurveySecurityException
user
- Current usersurveyId
- Id of the survey to updateSurveySystemException
- If any error occurs in the system.SurveySecurityException
- If the user is unauthorized to update the surveypublic static void releaseLock(long surveyId) throws SurveySystemException
surveyId
- Id of the survey to release the lock on.SurveySystemException
- If any error occurs in the system.public static void exportCSV(CSVExportParameters parameters) throws SurveySystemException
parameters
- The additional settings used for the report. SeeSurveySystemException
for details of available parameters.
Built on January 16 2019