Interface ProfileRepository
-
- All Superinterfaces:
org.craftercms.commons.mongo.CrudRepository<Profile>
- All Known Implementing Classes:
ProfileRepositoryImpl
public interface ProfileRepository extends org.craftercms.commons.mongo.CrudRepository<Profile>
DB repository forProfile
s.- Author:
- avasquez
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description long
countByTenant(String tenantName)
Returns the count of profiles for the given tenant.Profile
findById(String id, String... attributesToReturn)
Returns the profile with the given ID.Iterable<Profile>
findByIds(List<String> ids, String sortBy, SortOrder sortOrder, String... attributesToReturn)
Returns the profiles with the given IDs.Iterable<Profile>
findByQuery(String query, String sortBy, SortOrder sortOrder, Integer start, Integer count, String... attributesToReturn)
Returns the profiles that match the specified query.Iterable<Profile>
findByTenantAndAttributeValue(String tenantName, String attributeName, String attributeValue, String sortBy, SortOrder sortOrder, String... attributesToReturn)
Returns the profiles that have the given attribute with the given value for the given tenant.Iterable<Profile>
findByTenantAndExistingAttribute(String tenantName, String attributeName, String sortBy, SortOrder sortOrder, String... attributesToReturn)
Returns the profiles that have the given attribute, with any value, for the given tenant.Iterable<Profile>
findByTenantAndRole(String tenantName, String role, String sortBy, SortOrder sortOrder, String... attributesToReturn)
Returns the profiles with the given roles for the given tenant.Profile
findByTenantAndUsername(String tenantName, String username, String... attributesToReturn)
Returns the profile for the given tenant name and username.Profile
findOneByQuery(String query, String... attributesToReturn)
Returns the single profile that matches the specified queryIterable<Profile>
findRange(String tenantName, String sortBy, SortOrder sortOrder, Integer start, Integer count, String... attributesToReturn)
Returns a range of profiles for the given tenant.void
removeAll(String tenantName)
Removes all the profiles associated to the given tenant.void
removeAttributeFromAll(String tenantName, String attributeName)
Removes the attribute of all profiles of to the given tenant.void
removeRoleFromAll(String tenantName, String role)
Removes the role of all profiles of to the given tenant.void
updateAllWithDefaultValue(String tenantName, String attributeName, Object defaultValue)
Updates all the profiles of a given tenant with the default value of an attribute, only if they don't have the attribute value set yet.-
Methods inherited from interface org.craftercms.commons.mongo.CrudRepository
count, count, count, deleteFile, deleteFile, find, find, findAll, findById, findByStringId, findOne, findOne, getFileInfo, getFileInfo, insert, insert, listFilesByName, readFile, readFile, remove, remove, removeById, removeByStringId, save, save, saveFile, saveFile, update, update, update, update, updateFile, updateFile, updateFile
-
-
-
-
Method Detail
-
findOneByQuery
Profile findOneByQuery(String query, String... attributesToReturn) throws org.craftercms.commons.mongo.MongoDataException
Returns the single profile that matches the specified query- Parameters:
query
- the Mongo query used to search for the profilesattributesToReturn
- the names of the attributes to return with the profile (null to return all attributes)- Returns:
- the profile, or null if not found
- Throws:
org.craftercms.commons.mongo.MongoDataException
-
findById
Profile findById(String id, String... attributesToReturn) throws org.craftercms.commons.mongo.MongoDataException
Returns the profile with the given ID.- Parameters:
id
- the profile's IDattributesToReturn
- the name of the attributes to return (null to return all)- Returns:
- the profile found, or null if not found
- Throws:
org.craftercms.commons.mongo.MongoDataException
-
findByTenantAndUsername
Profile findByTenantAndUsername(String tenantName, String username, String... attributesToReturn) throws org.craftercms.commons.mongo.MongoDataException
Returns the profile for the given tenant name and username.- Parameters:
tenantName
- the tenant's nameusername
- the profile's usernameattributesToReturn
- the name of the attributes to return (null to return all)- Returns:
- the profile found, or null if not found
- Throws:
org.craftercms.commons.mongo.MongoDataException
-
findByQuery
Iterable<Profile> findByQuery(String query, String sortBy, SortOrder sortOrder, Integer start, Integer count, String... attributesToReturn) throws org.craftercms.commons.mongo.MongoDataException
Returns the profiles that match the specified query.- Parameters:
query
- the Mongo query used to search for the profiles. Must not contain the $where operator, the tenant's name (already specified) or any non-readable attribute by the applicationattributesToReturn
- the names of the attributes to return with the profile (null to return all attributes)- Returns:
- the list of profiles found, or null if none match the query
- Throws:
org.craftercms.commons.mongo.MongoDataException
-
findByIds
Iterable<Profile> findByIds(List<String> ids, String sortBy, SortOrder sortOrder, String... attributesToReturn) throws org.craftercms.commons.mongo.MongoDataException
Returns the profiles with the given IDs.- Parameters:
ids
- the IDs of the profiles to returnsortBy
- profile attribute to sort the list by (optional)sortOrder
- the sort order (either ASC or DESC) (optional)attributesToReturn
- the name of the attributes to return (null to return all)- Returns:
- the profiles for the given IDs
- Throws:
org.craftercms.commons.mongo.MongoDataException
-
findRange
Iterable<Profile> findRange(String tenantName, String sortBy, SortOrder sortOrder, Integer start, Integer count, String... attributesToReturn) throws org.craftercms.commons.mongo.MongoDataException
Returns a range of profiles for the given tenant.- Parameters:
tenantName
- the tenant's namesortBy
- profile attribute to sort the list by (optional)sortOrder
- the sort order (either ASC or DESC) (optional)start
- from the entire list of results, the position where the actual results should start (useful for pagination) (optional)count
- the number of profiles to return (optional)attributesToReturn
- the names of the attributes to return for each profile (null to return all)- Returns:
- the range of profiles
- Throws:
org.craftercms.commons.mongo.MongoDataException
-
findByTenantAndRole
Iterable<Profile> findByTenantAndRole(String tenantName, String role, String sortBy, SortOrder sortOrder, String... attributesToReturn) throws org.craftercms.commons.mongo.MongoDataException
Returns the profiles with the given roles for the given tenant.- Parameters:
tenantName
- the tenant's namerole
- the role the profile's must havesortBy
- profile attribute to sort the list by (optional)sortOrder
- the sort order (either ASC or DESC) (optional)attributesToReturn
- the names of the attributes to return for each profile (null to return all)- Returns:
- the matching profiles
- Throws:
org.craftercms.commons.mongo.MongoDataException
-
findByTenantAndExistingAttribute
Iterable<Profile> findByTenantAndExistingAttribute(String tenantName, String attributeName, String sortBy, SortOrder sortOrder, String... attributesToReturn) throws org.craftercms.commons.mongo.MongoDataException
Returns the profiles that have the given attribute, with any value, for the given tenant.- Parameters:
tenantName
- the tenant's nameattributeName
- the name of the attribute profiles must havesortBy
- profile attribute to sort the list by (optional)sortOrder
- the sort order (either ASC or DESC) (optional)attributesToReturn
- the names of the attributes to return for each profile (null to return all)- Returns:
- the matching profiles
- Throws:
org.craftercms.commons.mongo.MongoDataException
-
findByTenantAndAttributeValue
Iterable<Profile> findByTenantAndAttributeValue(String tenantName, String attributeName, String attributeValue, String sortBy, SortOrder sortOrder, String... attributesToReturn) throws org.craftercms.commons.mongo.MongoDataException
Returns the profiles that have the given attribute with the given value for the given tenant.- Parameters:
tenantName
- the tenant's nameattributeName
- the name of the attribute profiles must haveattributeValue
- the value of the attribute profiles must havesortBy
- profile attribute to sort the list by (optional)sortOrder
- the sort order (either ASC or DESC) (optional)attributesToReturn
- the names of the attributes to return for each profile (null to return all)- Returns:
- the matching profiles
- Throws:
org.craftercms.commons.mongo.MongoDataException
-
countByTenant
long countByTenant(String tenantName) throws org.craftercms.commons.mongo.MongoDataException
Returns the count of profiles for the given tenant.- Parameters:
tenantName
- the tenant's name- Returns:
- the count of profiles for the tenant
- Throws:
org.craftercms.commons.mongo.MongoDataException
-
removeAll
void removeAll(String tenantName) throws org.craftercms.commons.mongo.MongoDataException
Removes all the profiles associated to the given tenant.- Parameters:
tenantName
- the tenant's name- Throws:
org.craftercms.commons.mongo.MongoDataException
-
removeRoleFromAll
void removeRoleFromAll(String tenantName, String role) throws org.craftercms.commons.mongo.MongoDataException
Removes the role of all profiles of to the given tenant.- Parameters:
tenantName
- the tenant's namerole
- the name of the role to remove- Throws:
org.craftercms.commons.mongo.MongoDataException
-
removeAttributeFromAll
void removeAttributeFromAll(String tenantName, String attributeName) throws org.craftercms.commons.mongo.MongoDataException
Removes the attribute of all profiles of to the given tenant.- Parameters:
tenantName
- the tenant's nameattributeName
- the name of the attribute to remove- Throws:
org.craftercms.commons.mongo.MongoDataException
-
updateAllWithDefaultValue
void updateAllWithDefaultValue(String tenantName, String attributeName, Object defaultValue) throws org.craftercms.commons.mongo.MongoDataException
Updates all the profiles of a given tenant with the default value of an attribute, only if they don't have the attribute value set yet.- Parameters:
tenantName
- the tenant's nameattributeName
- the attribute's namedefaultValue
- the default attribute value- Throws:
org.craftercms.commons.mongo.MongoDataException
-
-