Class UserAccountDao


  • public class UserAccountDao
    extends AbstractDao
    Provides a DAO for the UserAccount entity.
    See Also:
    UserAccount
    • Constructor Detail

      • UserAccountDao

        public UserAccountDao()
    • Method Detail

      • clearThreadLocalCache

        public static void clearThreadLocalCache()
        Clear the thread local user account cache.
        Since:
        4.3.2
      • invalidateCache

        public static void invalidateCache()
        Invalidate the user results cache.
        Since:
        4.3.2
      • getUserAccountForPK

        public UserAccount getUserAccountForPK​(Object id)
        Return the user account with the specified OID
        Parameters:
        id - the OID
        Returns:
        the matching user account, or null if not found
      • getUserAccountForUserKey

        public UserAccount getUserAccountForUserKey​(String userKey)
        Return the user account for the given user surrogate key
        Parameters:
        userKey - the user surrogate key
        Returns:
        the matching user account
      • getUserAccountForLogin

        public UserAccount getUserAccountForLogin​(String loginName)
        Return the user account with the given login name
        Parameters:
        loginName - the login name
        Returns:
        the matching user account
      • getUserAccountForEmail

        public UserAccount getUserAccountForEmail​(String emailAddress)
        Return the user account for the given email address, or null if not found
        Parameters:
        emailAddress - the user account email address
        Returns:
        the user account if found or null otherwise
        Since:
        4.0.0
      • doesLocalUserAccountExistForLogin

        public boolean doesLocalUserAccountExistForLogin​(String loginName)
        Return true if a Local user type exists for the given login name.
        Parameters:
        loginName - the login name
        Returns:
        true if a Local user type exists for the given login name
      • getActiveUserAccountForLogin

        public UserAccount getActiveUserAccountForLogin​(String loginName)
        Return the active user account with the given login name
        Parameters:
        loginName - the login name
        Returns:
        the matching user account
      • getActiveAdminAccountForLogin

        public UserAccount getActiveAdminAccountForLogin​(String loginName)
        Return the active user account with the given login name. This method is similar to getActiveUserAccountForLogin(String) but does an additional prefetch on the clientUsers property. No filtering is done on portal associations, so non-admin users will still be found and returned.
        Parameters:
        loginName - the login name
        Returns:
        the matching user account
        Since:
        4.0.0
      • getUsersWithLoginNameOrEmail

        public List<UserAccount> getUsersWithLoginNameOrEmail​(String userIdentifier)
        Return the list of users whose login name or email matches the specified identifier
        Parameters:
        userIdentifier - the login name or email address to look for
        Returns:
        the list of matching users
      • getActiveUserForLoginAndPortal

        public UserAccount getActiveUserForLoginAndPortal​(String loginName,
                                                          Portal portal)
        Return the active user account for the given login name and portal
        Parameters:
        loginName - the login name
        portal - the portal the user is associated with
        Returns:
        the matching user account
      • getActiveClients

        public List<Client> getActiveClients​(UserAccount userAccount)
        Return the list of clients associated with the administrative user, will return empty list for global clients.
        Parameters:
        userAccount - the administrative user account
        Returns:
        the list of clients associated with the administrative user, will return empty list for global clients.
        Since:
        4.0.0
      • isClientSuperset

        public boolean isClientSuperset​(UserAccount userAccount,
                                        UserAccount targetUserAccount)
        Return whether a user is associated with a superset of the clients of another target user. If this is the case, the user may be allowed to view/edit the target user (based on additional conditions); otherwise access must not be granted. Note that if the user is a global administrator, this method returns true.
        Parameters:
        userAccount - the user account (required)
        targetUserAccount - the target user account (required)
        Returns:
        true if userAccount has global access, or the clients associated with userAccount are a superset of the clients associated with targetUserAccount
        Since:
        4.0.0
      • getUserForLoginAndPortal

        public UserAccount getUserForLoginAndPortal​(String loginName,
                                                    Portal portal)
        Return the user account for the given login name and portal.
        Parameters:
        loginName - the login name
        portal - the portal the user is associated with
        Returns:
        the matching user account
      • getUserClientIdSet

        public Set<Long> getUserClientIdSet​(UserAccount userAccount)
        Return the users set of client IDs.
        Parameters:
        userAccount - the user account (required)
        Returns:
        the users set of client IDs
        Since:
        4.3.2
      • getPermissionNames

        public Set<String> getPermissionNames​(String userOid,
                                              String portalName)
        Return the set of permissions for a user on a given portal
        Parameters:
        userOid - the OID of a SmartForm Manager user
        portalName - the name o a portal
        Returns:
        the set of permission names that are assigned to the user for the given portal
      • getPermissionNamesForLogin

        public Set<String> getPermissionNamesForLogin​(String loginName,
                                                      String portalName)
        Return the set of permissions for a user loginName on a given portal portalName.
        Parameters:
        loginName - the user login name
        portalName - the name o a portal
        Returns:
        the set of permission names that are assigned to the user for the given portal
        Since:
        4.0.0
      • getUserAccountList

        public List<UserAccount> getUserAccountList()
        Return all user accounts, including inactive users, ordered by login name
        Returns:
        the list of user accounts
      • getUserAccountList

        public List<UserAccount> getUserAccountList​(String clientId,
                                                    String keyword,
                                                    String portalId,
                                                    String userType,
                                                    String accountStatus)
        Return the list of user accounts matching the specified search criteria
        Parameters:
        clientId - the OID of the client associated with the user (optional)
        keyword - the search keyword
        portalId - the OID of a portal associated with the user (optional)
        userType - the user type, one of UserAccount.USER_TYPES (optional)
        accountStatus - the user account status, one of UserAccount.ACCOUNT_STATUSES (optional)
        Returns:
        the list of matching user accounts
      • getActiveUsersInGroup

        public List<UserAccount> getActiveUsersInGroup​(String groupName)
        Return all active user accounts who are members of a specific group, ordered by login name
        Parameters:
        groupName - the non-empty name of the group (required)
        Returns:
        the list of users belonging to the group
      • getActiveUsersInGroupWithClientAccess

        public List<UserAccount> getActiveUsersInGroupWithClientAccess​(String groupName,
                                                                       Client client)
        Return all active user accounts who are members of a specific group, ordered by login name. Only users associated with the specified client (as well as users with the global access flag) will be considered; if no client is specified, only users with the global access flag are considered. If you do not want to filter by client, use getActiveUsersInGroup(String).
        Parameters:
        groupName - the non-empty name of the group (required)
        client - the organization to filter on (if null, only global administrators are considered)
        Returns:
        the list of users belonging to the group
        Since:
        4.1.13
      • getActiveUsersInGroups

        public List<UserAccount> getActiveUsersInGroups​(Set<String> groupNameSet)
        Return all active user accounts who are members of a set of groups, ordered by login name
        Parameters:
        groupNameSet - the set of group names to filter on
        Returns:
        the list of matching users
        Since:
        4.1.0
      • getAdminsWithPermission

        public List<UserAccount> getAdminsWithPermission​(String clientId,
                                                         String permissionName)
        Return all user accounts for the given client, who also have the specified permission
        Parameters:
        clientId - the OID of an existing client
        permissionName - the non-empty name of the permission
        Returns:
        the list of matching user accounts
      • getUserSearch

        public List<UserAccount> getUserSearch​(String clientId,
                                               String value)
        Return a list of users whose given name, family name, login name or email address contain the search string, or whose OID matches the search string if it is numeric
        Parameters:
        clientId - the OID of the client associated with the user account
        value - the non-empty search string
        Returns:
        the list of matching user accounts
      • getActiveUserAccountsForClient

        public List<UserAccount> getActiveUserAccountsForClient​(String clientId)
        Return the list of active user accounts associated with a client, ordered by login name
        Parameters:
        clientId - the OID of the client (optional)
        Returns:
        the list of matching user accounts
      • getActiveUsersSubscribedToSubmissionAlerts

        public List<UserAccount> getActiveUsersSubscribedToSubmissionAlerts​(String clientId)
        Return the list of active users subscribed to the Group.RECEIVE_DELIVERY_ESCALATION_ALERTS group for the specified client
        Parameters:
        clientId - the OID of the client associated with the user (global users are also returned)
        Returns:
        the list of matching users
      • setReceiveSubmissionUpdates

        public void setReceiveSubmissionUpdates​(UserAccount userAccount,
                                                boolean receive)
        Add the user to / remove the user from the Group.RECEIVE_SUBMISSION_UPDATES group
        Parameters:
        userAccount - the non-null user account
        receive - whether to add (true) or remove (false) the user from the group
      • getUnverifiedAccountsToPurge

        public List<UserAccount> getUnverifiedAccountsToPurge()
        Return a list of user accounts requiring email verification that are ready to purge, sorted ascending by creation date. Default fetch limits apply.
        Returns:
        the list of matching user accounts
      • isClientAccessibleToUser

        public boolean isClientAccessibleToUser​(UserAccount userAccount,
                                                Client client)
        Checks if is user accessible to client.
        Parameters:
        userAccount - the user account
        client - the client
        Returns:
        true, if is user accessible to client
        Since:
        4.0.0
      • isSubmissionAccessibleToAdministrator

        public boolean isSubmissionAccessibleToAdministrator​(Submission submission,
                                                             UserAccount userAccount)
        Return true if the submission is accessible to the given administrator user.
        Parameters:
        submission - the submission record
        userAccount - the administrative user
        Returns:
        true if the submission is accessible to the given administrator user
        Since:
        4.0.0
      • getAdministratorClients

        public List<Client> getAdministratorClients​(String loginName)
        Return a list of clients the administrator has access to.
        Parameters:
        loginName - the administrator login name
        Returns:
        a list of clients the administrator has access to
        Since:
        4.0.0
      • normalizeLogin

        public static String normalizeLogin​(String loginName)
        Return the normalized login name.
        Parameters:
        loginName - the login name
        Returns:
        the normalized login name.
        Since:
        3.6.1