All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.bonitasoft.engine.profile.ProfileService Maven / Gradle / Ivy

/**
 * Copyright (C) 2012-2013 BonitaSoft S.A.
 * BonitaSoft, 32 rue Gustave Eiffel - 38000 Grenoble
 * This library is free software; you can redistribute it and/or modify it under the terms
 * of the GNU Lesser General Public License as published by the Free Software Foundation
 * version 2.1 of the License.
 * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU Lesser General Public License for more details.
 * You should have received a copy of the GNU Lesser General Public License along with this
 * program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
 * Floor, Boston, MA 02110-1301, USA.
 **/
package org.bonitasoft.engine.profile;

import java.util.List;

import org.bonitasoft.engine.persistence.OrderByType;
import org.bonitasoft.engine.persistence.QueryOptions;
import org.bonitasoft.engine.persistence.SBonitaSearchException;
import org.bonitasoft.engine.profile.builder.SProfileBuilderAccessor;
import org.bonitasoft.engine.profile.model.SProfile;
import org.bonitasoft.engine.profile.model.SProfileEntry;
import org.bonitasoft.engine.profile.model.SProfileMember;
import org.bonitasoft.engine.recorder.model.EntityUpdateDescriptor;

/**
 * @author Matthieu Chaffotte
 * @author Elias Ricken de Medeiros
 */
public interface ProfileService {

    String PROFILE = "PROFILE";

    String ENTRY_PROFILE = "ENTRY_PROFILE";

    String PROFILE_MEMBER = "PROFILE_MEMBER";

    SProfileBuilderAccessor getSProfileBuilderAccessor();

    /**
     * Get profile by its id
     * 
     * @param profileId
     * @return sProfile
     * @throws SProfileNotFoundException
     *             occurs when the identifier does not refer to an existing sProfile
     * @since 6.0
     */
    SProfile getProfile(long profileId) throws SProfileNotFoundException;

    /**
     * Get all profiles by given ids
     * 
     * @param profileIds
     *            a list contains many profile id
     * @return
     * @throws SProfileNotFoundException
     *             occurs when the identifier does not refer to an existing sProfile
     * @since 6.0
     */
    List getProfiles(List profileIds) throws SProfileNotFoundException;

    /**
     * Add a new profile
     * 
     * @param profile
     * @return sProfile
     * @throws SProfileAlreadyExistsException
     *             occurs when the sProfile has already been taken
     * @throws SProfileCreationException
     *             occurs when an exception is thrown during sProfile creation
     * @since 6.0
     */
    SProfile createProfile(SProfile profile) throws SProfileAlreadyExistsException, SProfileCreationException;

    /**
     * Update profile by given profile and new content
     * 
     * @param profile
     * @param descriptor
     * @throws SProfileNotFoundException
     *             occurs when the identifier does not refer to an existing sProfile
     * @throws SProfileUpdateException
     *             occurs when an exception is thrown during sProfile update
     * @since 6.0
     */
    void updateProfile(SProfile profile, EntityUpdateDescriptor descriptor) throws SProfileNotFoundException, SProfileUpdateException;

    /**
     * Delete profile by given sProfile
     * 
     * @param profile
     * @throws SProfileNotFoundException
     *             occurs when the identifier does not refer to an existing sProfile
     * @throws SProfileDeletionException
     *             occurs when an exception is thrown during sProfile deletion
     * @since 6.0
     */
    void deleteProfile(SProfile profile) throws SProfileNotFoundException, SProfileDeletionException;

    /**
     * Delete profile by its id
     * 
     * @param profileId
     * @throws SProfileNotFoundException
     *             occurs when the identifier does not refer to an existing sProfile
     * @throws SProfileDeletionException
     *             occurs when an exception is thrown during sProfile deletion
     * @since 6.0
     */
    void deleteProfile(long profileId) throws SProfileNotFoundException, SProfileDeletionException;

    /**
     * Get all profiles of the user by userId
     * 
     * @param userId
     * @return a list of sProfile
     * @throws SProfileMemberNotFoundException
     *             occurs when the identifier does not refer to an existing sProfile
     * @since 6.0
     */
    List getProfilesOfUser(long userId) throws SProfileMemberNotFoundException;

    /**
     * Get profile entry by its id
     * 
     * @param profileEntryId
     * @return sProfileEntry
     * @throws SProfileEntryNotFoundException
     *             occurs when the identifier does not refer to an existing sProfileEntry
     * @since 6.0
     */
    SProfileEntry getProfileEntry(long profileEntryId) throws SProfileEntryNotFoundException;

    /**
     * Get all profile entries having the given value for the given int index
     * 
     * @param fromIndex
     *            first result to be considered(>=0)
     * @param numberOfProfileEntry
     *            the max number of profileEntry to be returned (>=0)
     * @param numberOfProfileEntry
     * @return all profile entries having the given value for the given int index
     * @throws SProfileNotFoundException
     *             occurs when the identifier does not refer to an existing sProfileEntry
     * @since 6.0
     */
    List getEntriesOfProfile(long profileId, int fromIndex, int numberOfProfileEntry) throws SProfileNotFoundException;

    /**
     * Get all profile entries having the given value for the given int index by profileId
     * 
     * @param profileId
     * @param fromIndex
     *            first result to be considered(>=0)
     * @param numberOfProfileEntry
     *            the max number of profileEntry to be returned (>=0)
     * @param field
     * @param order
     * @return all profile entries having the given value for the given int index by profileId
     * @throws SProfileNotFoundException
     *             occurs when the identifier does not refer to an existing sProfileEntry
     * @since 6.0
     */
    List getEntriesOfProfile(long profileId, int fromIndex, int numberOfProfileEntry, String field, OrderByType order)
            throws SProfileNotFoundException;

    /**
     * Add new profile entry
     * 
     * @param profileEntry
     * @return the new created sProfileEntry
     * @throws SProfileEntryAlreadyExistsException
     * @throws SProfileEntryCreationException
     *             occurs when an exception is thrown during sProfileEntry creation
     * @since 6.0
     */
    SProfileEntry createProfileEntry(SProfileEntry profileEntry) throws SProfileEntryAlreadyExistsException, SProfileEntryCreationException;

    /**
     * Update a profileEntry by given profileEntry and new content
     * 
     * @param profileEntry
     * @param descriptor
     * @throws SProfileEntryUpdateException
     *             occurs when an exception is thrown during sProfileEntry update
     * @since 6.0
     */
    void updateProfileEntry(SProfileEntry profileEntry, EntityUpdateDescriptor descriptor) throws SProfileEntryUpdateException;

    /**
     * Delete a profileEntry by given profileEntry
     * 
     * @param profileEntry
     * @throws SProfileEntryDeletionException
     *             occurs when an exception is thrown during sProfileEntry deletion
     * @since 6.0
     */
    void deleteProfileEntry(SProfileEntry profileEntry) throws SProfileEntryDeletionException;

    /**
     * Delete a profile entry by its id
     * 
     * @param profileEntryId
     * @throws SProfileEntryNotFoundException
     *             occurs when the identifier does not refer to an existing sProfileEntry
     * @throws SProfileEntryDeletionException
     *             occurs when an exception is thrown during sProfileEntry deletion
     * @since 6.0
     */
    void deleteProfileEntry(long profileEntryId) throws SProfileEntryNotFoundException, SProfileEntryDeletionException;

    /**
     * Add a user to exist profile
     * 
     * @param profileId
     *            the identifier of profile
     * @param userId
     *            the identifier of user
     * @param firstName
     * @param lastName
     * @param userName
     * @return sProfileMember
     * @throws SProfileNotFoundException
     *             occurs when the identifier does not refer to an existing sProfileMember
     * @throws SProfileCreationException
     *             occurs when an exception is thrown during sProfileMember creation
     * @since 6.0
     */
    SProfileMember addUserToProfile(long profileId, long userId, String firstName, String lastName, String userName) throws SProfileNotFoundException,
            SProfileCreationException;

    /**
     * Add a group to exist profile
     * 
     * @param profileId
     *            the identifier of profile
     * @param groupId
     *            the identifier of group
     * @param groupName
     * @param parentPath
     * @return sProfileMember
     * @throws SProfileNotFoundException
     *             occurs when the identifier does not refer to an existing sProfileMember
     * @throws SProfileCreationException
     *             occurs when an exception is thrown during sProfileMember creation
     * @since 6.0
     */
    SProfileMember addGroupToProfile(long profileId, long groupId, String groupName, String parentPath) throws SProfileNotFoundException,
            SProfileCreationException;

    /**
     * Add a role to exist profile
     * 
     * @param profileId
     *            the identifier of profile
     * @param roleId
     *            the identifier of role
     * @param roleName
     * @return sProfileMember
     * @throws SProfileNotFoundException
     *             occurs when the identifier does not refer to an existing sProfileMember
     * @throws SProfileCreationException
     *             occurs when an exception is thrown during sProfileMember creation
     * @since 6.0
     */
    SProfileMember addRoleToProfile(long profileId, long roleId, String roleName) throws SProfileNotFoundException, SProfileCreationException;

    /**
     * Add a role and a group to exist profile
     * 
     * @param profileId
     *            the identifier of profile
     * @param roleId
     *            the identifier of role
     * @param groupId
     *            the identifier of group
     * @param roleName
     * @param groupName
     * @param groupParentPath
     * @return sProfileMember
     * @throws SProfileNotFoundException
     *             occurs when the identifier does not refer to an existing sProfileMember
     * @throws SProfileCreationException
     *             occurs when an exception is thrown during sProfileMember creation
     * @since 6.0
     */
    SProfileMember addRoleAndGroupToProfile(long profileId, long roleId, long groupId, String roleName, String groupName, String groupParentPath)
            throws SProfileNotFoundException, SProfileCreationException;

    /**
     * Get all sProfileMembers with same user having the given value for the given int index
     * 
     * @param userId
     *            the identifier of user
     * @param fromIndex
     *            first result to be considered(>=0)
     * @param numberOfProfileEntry
     *            the max number of profileEntry to be returned (>=0)
     * @param field
     * @param order
     * @return sProfileMember
     * @throws SProfileMemberReadException
     *             occurs when an exception is thrown during sProfileMember creation
     * @since 6.0
     */
    List getProfileMembersOfUser(final long userId, int fromIndex, int numberOfElements, String field, OrderByType order)
            throws SProfileMemberReadException;

    /**
     * Get all sProfileMembers with same group having the given value for the given int index
     * 
     * @param groupId
     *            the identifier of group
     * @param fromIndex
     *            first result to be considered(>=0)
     * @param numberOfProfileEntry
     *            the max number of profileEntry to be returned (>=0)
     * @param field
     * @param order
     * @return sProfileMember
     * @throws SProfileMemberReadException
     *             occurs when an exception is thrown during sProfileMember creation
     * @since 6.0
     */
    List getProfileMembersOfGroup(final long groupId, int fromIndex, int numberOfElements, String field, OrderByType order)
            throws SProfileMemberReadException;

    /**
     * Get all sProfileMembers with same group having the given value for the given int index
     * 
     * @param roleId
     *            the identifier of role
     * @param fromIndex
     *            first result to be considered(>=0)
     * @param numberOfProfileEntry
     *            the max number of profileEntry to be returned (>=0)
     * @param field
     * @param order
     * @return sProfileMember
     * @throws SProfileMemberReadException
     *             occurs when an exception is thrown during sProfileMember creation
     * @since 6.0
     */
    List getProfileMembersOfRole(final long roleId, int fromIndex, int numberOfElements, String field, OrderByType order)
            throws SProfileMemberReadException;

    /**
     * Delete a profile member by its id
     * 
     * @param profileMemberId
     * @throws SProfileMemberDeletionException
     *             occurs when an exception is thrown during sProfileMember deletion
     * @throws SProfileMemberNotFoundException
     *             occurs when the identifier does not refer to an existing sProfileMember
     * @since 6.0
     */
    void deleteProfileMember(long profileMemberId) throws SProfileMemberDeletionException, SProfileMemberNotFoundException;

    /**
     * Delete a profile member by given sProfile member
     * 
     * @param profileMember
     * @throws SProfileMemberDeletionException
     *             occurs when an exception is thrown during sProfileMember deletion
     * @since 6.0
     */
    void deleteProfileMember(SProfileMember profileMember) throws SProfileMemberDeletionException;

    /**
     * Get the total number of profile members
     * 
     * @param querySuffix
     *            the suffix of query string
     * @param countOptions
     *            The criterion used to search profileMembers
     * @return the total number of profile members
     * @throws SBonitaSearchException
     * @since 6.0
     */
    long getNumberOfProfileMembers(String querySuffix, final QueryOptions countOptions) throws SBonitaSearchException;

    /**
     * Get all sProfileMember by profileId and queryOptions
     * 
     * @param querySuffix
     *            the suffix of query string
     * @param countOptions
     *            The criterion used to search profileMembers
     * @return all sProfileMember by profileId and queryOptions
     * @throws SBonitaSearchException
     * @since 6.0
     */
    List searchProfileMembers(String querySuffix, final QueryOptions searchOptions) throws SBonitaSearchException;

    /**
     * Get the total number of sProfileMember by a list contains profileIds
     * 
     * @param profileIds
     * @return A list of 
     * @throws SBonitaSearchException
     * @since 6.0
     */
    List getNumberOfProfileMembers(List profileIds) throws SBonitaSearchException;

    /**
     * Get profile by given name
     * 
     * @param profileName
     * @return sProfile
     * @throws SProfileNotFoundException
     *             occurs when the identifier does not refer to an existing sProfile
     * @since 6.0
     */
    SProfile getProfileByName(String profileName) throws SProfileNotFoundException;

    /**
     * Get a list of profileMembers by the given profileId
     * 
     * @param profileId
     * @return a list of profileMembers
     * @throws SProfileNotFoundException
     */
    List getSProfileMembers(long profileId) throws SProfileNotFoundException;

    /**
     * Get a list of profileEntries by the given profileId and parentId
     * 
     * @param profileId
     * @param parentId
     * @param fromIndex
     * @param numberOfProfileEntries
     * @param field
     * @param order
     * @return a list of profileEntries
     * @throws SProfileNotFoundException
     */
    List getEntriesOfProfileByParentId(long profileId, long parentId, int fromIndex, int numberOfProfileEntries, String field, OrderByType order)
            throws SProfileNotFoundException;

    /**
     * 
     */
    void deleteAllProfileMembers() throws SProfileMemberDeletionException;

    /**
     * @param queryOptions
     * @return
     */
    long getNumberOfProfiles(QueryOptions queryOptions) throws SBonitaSearchException;

    /**
     * @param queryOptions
     * @return
     */
    List searchProfiles(QueryOptions queryOptions) throws SBonitaSearchException;

    /**
     * @param queryOptions
     * @return
     * @throws SBonitaSearchException
     */
    long getNumberOfProfileEntries(QueryOptions queryOptions) throws SBonitaSearchException;

    /**
     * @param queryOptions
     * @return
     * @throws SBonitaSearchException
     */
    List searchProfileEntries(QueryOptions queryOptions) throws SBonitaSearchException;

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy