Class BTDataCollectionTemplateVisibleForUserSearch
java.lang.Object
overit.geocall.bl.BusinessTask<DataCollectionTemplateVisibleForUserSearchEvent>
overit.geocallapp.wfm.core.bl.datacollection.template.visibilityrules.task.BTDataCollectionTemplateVisibleForUserSearch
- All Implemented Interfaces:
Serializable,Tool
@Event(DataCollectionTemplateVisibleForUserSearchEvent.class)
public class BTDataCollectionTemplateVisibleForUserSearch
extends BusinessTask<DataCollectionTemplateVisibleForUserSearchEvent>
Business task for searching generable templates on mobile.
This task returns all the DC template IDs that the mobile user can use for generating Data Collections. A template is generable if:
- There isn't any visibility rule configured for the template, OR
- There is a rule row that matches the user profile
The matching logic for a rule is:
if ( (userTypeList is empty OR userTypeList contains the userType) AND (operationCenterList is empty OR operationCenterList contains the operationCenter) AND (structuresList is empty OR structuresList contains the structure) AND (areaList is empty OR areaList contains the area) ) then rule is valid
- Since:
- 22.0
- See Also:
- GCApi:
- task
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Longprotected overit.geocallapp.wfm.users.UserVisibilitySettings -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidbody(DataCollectionTemplateVisibleForUserSearchEvent event, PoolKit poolKit) Implements this method to write the specific task logic to handle the input parameter.protected List<BODCTemplateVisibilityRuleRow> collectMatchingRows(PoolKit poolKit) Collects all the rows that match the user profile.getAreasFromOperationCenter(Long operationCenterId, PoolKit poolKit) getMatchingRulesTemplates(PoolKit poolKit) Gets all the templates with visibility rules that match the user profile.protected LonggetStructureFromOperationCenter(Long operationCenterId, PoolKit poolKit) getTemplateIdsFromRuleHeaders(Set<Long> validRuleHeaders, PoolKit poolKit) Retrieves the template IDs associated with the given rule headers.getTemplatesWithoutRules(PoolKit poolKit) Gets all the templates without visibility rules.getValidRuleHeaders(Map<Long, List<BODCTemplateVisibilityRuleRow>> groupedRows) Finds the valid rule headers for the user organizational structures.protected booleanhasIntersection(Set<Long> ruleSet, Set<Long> userSet) Checks if there is an intersection between the rule set and the user set.protected voidloadUserOrganizationalStructures(Long userId, PoolKit poolKit) Loads the user organizational structures that will be used for filtering the rules.protected overit.geocallapp.wfm.users.UserVisibilitySettingsloadUserVisibilitySettings(Long userId, PooledConnection conn) Loads the user visibility settings.searchRulesByArea(PoolKit poolKit) Gets the rule headers that have a row that match the user areassearchRulesByOperationCenter(PoolKit poolKit) Gets the rule headers that have a row that match the user operation centerssearchRulesByStructure(PoolKit poolKit) Gets the rule headers that have a row that match the user structuressearchRulesByUserType(PoolKit poolKit) Gets the rule headers that have a row that match the user typeprotected voidvalidateUser(Long userId, PoolKit poolKit) Validate the user id.Methods inherited from class overit.geocall.bl.BusinessTask
start, start, startAlone, startInBackground
-
Field Details
-
userOperationCenters
-
userStructures
-
userAreas
-
userType
-
visibilitySettings
protected overit.geocallapp.wfm.users.UserVisibilitySettings visibilitySettings
-
-
Constructor Details
-
BTDataCollectionTemplateVisibleForUserSearch
public BTDataCollectionTemplateVisibleForUserSearch()
-
-
Method Details
-
body
protected void body(DataCollectionTemplateVisibleForUserSearchEvent event, PoolKit poolKit) throws DAException, DAValidateException Description copied from class:BusinessTaskImplements this method to write the specific task logic to handle the input parameter.- Specified by:
bodyin classBusinessTask<DataCollectionTemplateVisibleForUserSearchEvent>- Parameters:
event- the object upon which the task will works onpoolKit- the poolkit containing the reference to the database connection that can be used- Throws:
DAException- in case of database errorDAValidateException- in case of database validation error
-
validateUser
Validate the user id.- Parameters:
userId- the user id- Throws:
DAValidateException- if the user id is not validDAException
-
loadUserOrganizationalStructures
protected void loadUserOrganizationalStructures(Long userId, PoolKit poolKit) throws DAException, DAValidateException Loads the user organizational structures that will be used for filtering the rules.- Parameters:
userId- the user IDpoolKit- thePoolKit- Throws:
DAException- if a database error occursDAValidateException- if a validation error occurs
-
getStructureFromOperationCenter
protected Long getStructureFromOperationCenter(Long operationCenterId, PoolKit poolKit) throws DAException, DAValidateException - Throws:
DAExceptionDAValidateException
-
getAreasFromOperationCenter
protected Set<Long> getAreasFromOperationCenter(Long operationCenterId, PoolKit poolKit) throws DAException - Throws:
DAException
-
loadUserVisibilitySettings
protected overit.geocallapp.wfm.users.UserVisibilitySettings loadUserVisibilitySettings(Long userId, PooledConnection conn) throws DAException, DAValidateException Loads the user visibility settings.- Parameters:
userId- the user ID- Returns:
- the user visibility settings
- Throws:
DAExceptionDAValidateException
-
getTemplatesWithoutRules
protected Set<Long> getTemplatesWithoutRules(PoolKit poolKit) throws DAException, DAValidateException Gets all the templates without visibility rules.- Parameters:
poolKit- the pool kit- Returns:
- the of templates id without rules
- Throws:
DAExceptionDAValidateException
-
getMatchingRulesTemplates
protected Set<Long> getMatchingRulesTemplates(PoolKit poolKit) throws DAException, DAValidateException Gets all the templates with visibility rules that match the user profile.- Parameters:
poolKit- thePoolKit- Returns:
- the set of templates id with matching rules
- Throws:
DAExceptionDAValidateException
-
collectMatchingRows
protected List<BODCTemplateVisibilityRuleRow> collectMatchingRows(PoolKit poolKit) throws DAException, DAValidateException Collects all the rows that match the user profile.- Parameters:
poolKit- thePoolKit- Returns:
- the list of matching rows
- Throws:
DAExceptionDAValidateException
-
getValidRuleHeaders
Finds the valid rule headers for the user organizational structures.- Parameters:
groupedRows- the grouped rows- Returns:
- the set of valid rule headers
-
hasIntersection
Checks if there is an intersection between the rule set and the user set.- Parameters:
ruleSet- the rule setuserSet- the user set- Returns:
- true if there is an intersection, false otherwise
-
getTemplateIdsFromRuleHeaders
protected Set<Long> getTemplateIdsFromRuleHeaders(Set<Long> validRuleHeaders, PoolKit poolKit) throws DAException, DAValidateException Retrieves the template IDs associated with the given rule headers.- Parameters:
validRuleHeaders- the set of valid rule headerspoolKit- the pool kit for database operations- Returns:
- the set of template IDs
- Throws:
DAException- if a database access error occursDAValidateException
-
searchRulesByUserType
Gets the rule headers that have a row that match the user type- Parameters:
poolKit- thePoolKit- Returns:
- the set of valid rules headers
- Throws:
DAExceptionDAValidateException
-
searchRulesByOperationCenter
protected Set<Long> searchRulesByOperationCenter(PoolKit poolKit) throws DAException, DAValidateException Gets the rule headers that have a row that match the user operation centers- Parameters:
poolKit- thePoolKit- Returns:
- the set of valid rules headers
- Throws:
DAExceptionDAValidateException
-
searchRulesByStructure
Gets the rule headers that have a row that match the user structures- Parameters:
poolKit- thePoolKit- Returns:
- the set of valid rules headers
- Throws:
DAExceptionDAValidateException
-
searchRulesByArea
Gets the rule headers that have a row that match the user areas- Parameters:
poolKit- thePoolKit- Returns:
- the set of valid rules headers
- Throws:
DAExceptionDAValidateException
-