Class FormsOnlineDAOJdbc
- java.lang.Object
-
- org.silverpeas.components.formsonline.model.FormsOnlineDAOJdbc
-
- All Implemented Interfaces:
FormsOnlineDAO
public class FormsOnlineDAOJdbc extends Object implements FormsOnlineDAO
-
-
Constructor Summary
Constructors Constructor Description FormsOnlineDAOJdbc()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description FormDetail
createForm(FormDetail formDetail)
Save new form in databaseFormDetail
deleteForm(FormPK pk)
Delete Form from databasevoid
deleteRequest(RequestPK pk)
List<FormDetail>
findAllForms(String instanceId)
Get all forms that has been created in given instanceorg.silverpeas.core.util.SilverpeasList<FormInstance>
getAllRequests(FormPK pk)
protected Connection
getConnection()
Get a new connection.FormDetail
getForm(FormPK pk)
Load forms from database with given instance Id and form idList<FormDetail>
getForms(Collection<String> formIds)
Map<Integer,Integer>
getNumberOfRequestsByForm(String instanceId)
Map<String,Set<FormInstanceValidationType>>
getPossibleValidationTypesByFormId(Collection<String> formIds)
Gets the possibleFormInstanceValidationType
instances mapped by form identifiers.org.silverpeas.core.util.SilverpeasList<FormInstance>
getReceivedRequests(FormDetail form, List<Integer> states, RequestValidationCriteria validationCriteria, org.silverpeas.core.admin.PaginationPage paginationPage)
Get all requests associated to given form ordered from the newest to the older.List<String>
getReceiversAsGroups(FormPK pk, String rightType)
Get the form's receivers list where groups has been declared directly.List<String>
getReceiversAsUsers(FormPK pk, String rightType)
Get the form's receivers list where users has been declared directly.FormInstance
getRequest(RequestPK pk)
List<String>
getSendersAsGroups(FormPK pk)
Get the form's senders list where groups has been declared directly.List<String>
getSendersAsUsers(FormPK pk)
Get the form's senders list where users has been declared directly.org.silverpeas.core.util.SilverpeasList<FormInstance>
getSentFormInstances(FormPK pk, String userId, List<Integer> states, org.silverpeas.core.admin.PaginationPage paginationPage)
Get all form instances that have been sent by given user (excepted the ones that have been archived.List<FormDetail>
getUserAvailableForms(Collection<String> instanceIds, String userId, String[] userGroupIds)
Get the form available to be sent for given user or given groupsMap<String,Set<FormInstanceValidationType>>
getValidatorFormIdsWithValidationTypes(String instanceId, String validatorId, String[] validatorGroupIds, Collection<String> formIds)
Gets theFormInstanceValidationType
instances mapped by form identifiers of the the validator represented by given validator id and validator group ids on the given component instance.FormInstance
saveRequest(FormInstance request)
Inserts or updates the given request (also called a form instance).void
saveRequestState(FormInstance request)
Saves the state of the given request without updating anything else.void
updateForm(FormDetail formDetail)
Update form in databasevoid
updateReceivers(FormPK pk, Map<String,org.silverpeas.core.util.Pair<List<String>,List<String>>> userAndGroupIdsByRightTypes)
Updates the form rights from given parameters.void
updateSenders(FormPK pk, Map<String,org.silverpeas.core.util.Pair<List<String>,List<String>>> userAndGroupIdsByRightTypes)
Update form senders list.
-
-
-
Method Detail
-
createForm
public FormDetail createForm(FormDetail formDetail) throws FormsOnlineException
Description copied from interface:FormsOnlineDAO
Save new form in database- Specified by:
createForm
in interfaceFormsOnlineDAO
- Parameters:
formDetail
- the form detail- Returns:
- the created FormDetail
- Throws:
FormsOnlineException
-
deleteForm
public FormDetail deleteForm(FormPK pk) throws FormsOnlineException
Description copied from interface:FormsOnlineDAO
Delete Form from database- Specified by:
deleteForm
in interfaceFormsOnlineDAO
- Parameters:
pk
- the pk of form to be deleted- Returns:
- the deleted FormDetail
- Throws:
FormsOnlineException
-
getForm
public FormDetail getForm(FormPK pk) throws FormsOnlineException
Description copied from interface:FormsOnlineDAO
Load forms from database with given instance Id and form id- Specified by:
getForm
in interfaceFormsOnlineDAO
- Parameters:
pk
- the form primary key- Returns:
- a FormDetail object
- Throws:
FormsOnlineException
-
findAllForms
public List<FormDetail> findAllForms(String instanceId) throws FormsOnlineException
Description copied from interface:FormsOnlineDAO
Get all forms that has been created in given instance- Specified by:
findAllForms
in interfaceFormsOnlineDAO
- Parameters:
instanceId
- the instance id- Returns:
- a List of FormDetail object
- Throws:
FormsOnlineException
-
updateForm
public void updateForm(FormDetail formDetail) throws FormsOnlineException
Description copied from interface:FormsOnlineDAO
Update form in database- Specified by:
updateForm
in interfaceFormsOnlineDAO
- Parameters:
formDetail
- the form detail- Throws:
FormsOnlineException
-
getReceiversAsGroups
public List<String> getReceiversAsGroups(FormPK pk, String rightType) throws FormsOnlineException
Description copied from interface:FormsOnlineDAO
Get the form's receivers list where groups has been declared directly.- Specified by:
getReceiversAsGroups
in interfaceFormsOnlineDAO
- Parameters:
pk
- the form primary key- Returns:
- group ids as a list of String
- Throws:
FormsOnlineException
-
getReceiversAsUsers
public List<String> getReceiversAsUsers(FormPK pk, String rightType) throws FormsOnlineException
Description copied from interface:FormsOnlineDAO
Get the form's receivers list where users has been declared directly.- Specified by:
getReceiversAsUsers
in interfaceFormsOnlineDAO
- Parameters:
pk
- the form primary key- Returns:
- user ids as a list of String
- Throws:
FormsOnlineException
-
getSendersAsGroups
public List<String> getSendersAsGroups(FormPK pk) throws FormsOnlineException
Description copied from interface:FormsOnlineDAO
Get the form's senders list where groups has been declared directly.- Specified by:
getSendersAsGroups
in interfaceFormsOnlineDAO
- Parameters:
pk
- the form primary key- Returns:
- group ids as a list of String
- Throws:
FormsOnlineException
-
getSendersAsUsers
public List<String> getSendersAsUsers(FormPK pk) throws FormsOnlineException
Description copied from interface:FormsOnlineDAO
Get the form's senders list where users has been declared directly.- Specified by:
getSendersAsUsers
in interfaceFormsOnlineDAO
- Parameters:
pk
- the form primary key- Returns:
- user ids as a list of String
- Throws:
FormsOnlineException
-
updateReceivers
public void updateReceivers(FormPK pk, Map<String,org.silverpeas.core.util.Pair<List<String>,List<String>>> userAndGroupIdsByRightTypes) throws FormsOnlineException
Description copied from interface:FormsOnlineDAO
Updates the form rights from given parameters.- Specified by:
updateReceivers
in interfaceFormsOnlineDAO
- Parameters:
pk
- the unique identifier of a form.userAndGroupIdsByRightTypes
- the user and group rights to update indexed by right types. Users and groups are represented by aPair
containing on left the user identifiers and on right the group identifiers.- Throws:
FormsOnlineException
- on technical error.
-
updateSenders
public void updateSenders(FormPK pk, Map<String,org.silverpeas.core.util.Pair<List<String>,List<String>>> userAndGroupIdsByRightTypes) throws FormsOnlineException
Description copied from interface:FormsOnlineDAO
Update form senders list.- Specified by:
updateSenders
in interfaceFormsOnlineDAO
- Parameters:
pk
- the form primary keyuserAndGroupIdsByRightTypes
- the new sender list as user ids- Throws:
FormsOnlineException
-
getUserAvailableForms
public List<FormDetail> getUserAvailableForms(Collection<String> instanceIds, String userId, String[] userGroupIds) throws FormsOnlineException
Description copied from interface:FormsOnlineDAO
Get the form available to be sent for given user or given groups- Specified by:
getUserAvailableForms
in interfaceFormsOnlineDAO
- Parameters:
instanceIds
- the component instance iduserId
- the user iduserGroupIds
- the user's groups id list- Returns:
- a list of FormDetail objects
- Throws:
FormsOnlineException
-
getForms
public List<FormDetail> getForms(Collection<String> formIds) throws FormsOnlineException
- Specified by:
getForms
in interfaceFormsOnlineDAO
- Throws:
FormsOnlineException
-
getSentFormInstances
public org.silverpeas.core.util.SilverpeasList<FormInstance> getSentFormInstances(FormPK pk, String userId, List<Integer> states, org.silverpeas.core.admin.PaginationPage paginationPage) throws FormsOnlineException
Description copied from interface:FormsOnlineDAO
Get all form instances that have been sent by given user (excepted the ones that have been archived.- Specified by:
getSentFormInstances
in interfaceFormsOnlineDAO
- Parameters:
pk
- the form primary keyuserId
- the user idstates
- the states to filter on if anypaginationPage
- pagination which can be null if no pagination is requested.- Returns:
- a list of FormInstance objects
- Throws:
FormsOnlineException
-
getReceivedRequests
public org.silverpeas.core.util.SilverpeasList<FormInstance> getReceivedRequests(FormDetail form, List<Integer> states, RequestValidationCriteria validationCriteria, org.silverpeas.core.admin.PaginationPage paginationPage) throws FormsOnlineException
Description copied from interface:FormsOnlineDAO
Get all requests associated to given form ordered from the newest to the older.- Specified by:
getReceivedRequests
in interfaceFormsOnlineDAO
- Parameters:
form
- the form primary keystates
- the states to filter on if anyvalidationCriteria
- the validation criteriapaginationPage
- pagination which can be null if no pagination is requested.- Returns:
- if allRequests is false only requests to validate and requests validated by given user are returned. If true, all requests (validated or not) are returned.
- Throws:
FormsOnlineException
-
getValidatorFormIdsWithValidationTypes
public Map<String,Set<FormInstanceValidationType>> getValidatorFormIdsWithValidationTypes(String instanceId, String validatorId, String[] validatorGroupIds, Collection<String> formIds) throws FormsOnlineException
Description copied from interface:FormsOnlineDAO
Gets theFormInstanceValidationType
instances mapped by form identifiers of the the validator represented by given validator id and validator group ids on the given component instance.- Specified by:
getValidatorFormIdsWithValidationTypes
in interfaceFormsOnlineDAO
- Parameters:
instanceId
- the identifier of the component instance.validatorId
- the identifier of the validator.validatorGroupIds
- identifiers of the group of the validator.formIds
- optional filter about form identifiers in order to reduce the search load.- Returns:
FormInstanceValidationType
instances mapped by form identifiers.- Throws:
FormsOnlineException
-
getPossibleValidationTypesByFormId
public Map<String,Set<FormInstanceValidationType>> getPossibleValidationTypesByFormId(Collection<String> formIds) throws FormsOnlineException
Description copied from interface:FormsOnlineDAO
Gets the possibleFormInstanceValidationType
instances mapped by form identifiers.- Specified by:
getPossibleValidationTypesByFormId
in interfaceFormsOnlineDAO
- Parameters:
formIds
- form identifiers to search for.- Returns:
FormInstanceValidationType
instances mapped by form identifiers.- Throws:
FormsOnlineException
-
saveRequest
public FormInstance saveRequest(FormInstance request) throws FormsOnlineException
Description copied from interface:FormsOnlineDAO
Inserts or updates the given request (also called a form instance).All validation data contained into
FormInstance.getValidations()
are also inserted or updated.- Specified by:
saveRequest
in interfaceFormsOnlineDAO
- Parameters:
request
- the request to insert or update.- Returns:
- the
FormInstance
itself. - Throws:
FormsOnlineException
- on database integrity error.
-
saveRequestState
public void saveRequestState(FormInstance request) throws FormsOnlineException
Description copied from interface:FormsOnlineDAO
Saves the state of the given request without updating anything else.- Specified by:
saveRequestState
in interfaceFormsOnlineDAO
- Parameters:
request
- the request which the state MUST be updated.- Throws:
FormsOnlineException
- if the form instance id does not exist.
-
getRequest
public FormInstance getRequest(RequestPK pk) throws FormsOnlineException
- Specified by:
getRequest
in interfaceFormsOnlineDAO
- Throws:
FormsOnlineException
-
deleteRequest
public void deleteRequest(RequestPK pk) throws FormsOnlineException
- Specified by:
deleteRequest
in interfaceFormsOnlineDAO
- Throws:
FormsOnlineException
-
getNumberOfRequestsByForm
public Map<Integer,Integer> getNumberOfRequestsByForm(String instanceId) throws FormsOnlineException
- Specified by:
getNumberOfRequestsByForm
in interfaceFormsOnlineDAO
- Throws:
FormsOnlineException
-
getAllRequests
public org.silverpeas.core.util.SilverpeasList<FormInstance> getAllRequests(FormPK pk) throws FormsOnlineException
- Specified by:
getAllRequests
in interfaceFormsOnlineDAO
- Throws:
FormsOnlineException
-
getConnection
protected Connection getConnection() throws SQLException
Get a new connection.- Returns:
- the initialized connection.
- Throws:
SQLException
-
-