Class RealizationServiceImpl
java.lang.Object
io.meeds.gamification.service.impl.RealizationServiceImpl
- All Implemented Interfaces:
RealizationService,org.picocontainer.Startable
public class RealizationServiceImpl
extends Object
implements RealizationService, org.picocontainer.Startable
-
Constructor Summary
ConstructorsConstructorDescriptionRealizationServiceImpl(ProgramService programService, RuleService ruleService, org.exoplatform.services.resources.ResourceBundleService resourceBundleService, EventService eventService, org.exoplatform.social.core.manager.IdentityManager identityManager, org.exoplatform.social.core.space.spi.SpaceService spaceService, RealizationStorage realizationStorage, org.exoplatform.services.listener.ListenerService listenerService, org.exoplatform.container.xml.InitParams initParams) -
Method Summary
Modifier and TypeMethodDescriptioncancelRealizations(String event, String earnerIdentityId, String receiverIdentityId, String objectId, String objectType) Cancels an existing Realization with an event name for a given object identified by its id and typelongcountParticipantsBetweenDates(Date fromDate, Date toDate) intcountRealizationsByFilter(RealizationFilter realizationFilter) Count realizations by filterintcountRealizationsByFilter(RealizationFilter realizationFilter, org.exoplatform.services.security.Identity userAclIdentity) Count realizations by filtercreateRealizations(String event, String eventDetails, String earnerIdentityId, String receiverIdentityId, String objectId, String objectType) Creates new Realizations switch an event name for a given object identified by its id and typevoidcreateRealizationsAsync(String event, String eventDetails, String earnerIdentityId, String receiverIdentityId, String objectId, String objectType) Creates new Realizations asynchronously switch an event name for a given object identified by its id and typevoidcreateRealizationsAsyncInternal(String event, String eventDetails, String earnerIdentityId, String receiverIdentityId, String objectId, String objectType) deleteRealizations(String objectId, String objectType) Marks all realizations of a given object, generally due to deletion of originating objectexportXlsx(RealizationFilter filter, org.exoplatform.services.security.Identity identity, String fileName, Locale locale) Export realizations found switch filter into anInputStreamcontaining a file of format XLSfindRealizationsByObjectIdAndObjectType(String objectId, String objectType) Retrieves the list of realizations identified by object Id and object Type.getLeaderboard(LeaderboardFilter filter, String currentUser) Retrieves Leaderboard switch designated filterintgetLeaderboardRank(long earnerIdentityId, Date fromDate, Date toDate, Long spaceId, Long programId) Retrieves Leaderboard rank of an earnerIdentityid andProgramDTOid for the given dategetLeaderboardStatsByIdentityId(String earnerIdentityId, Long spaceId, String period, Date startDate, Date endDate) Retrieves scores per doamin of a givenIdentitygetParticipantsBetweenDates(Date fromDate, Date toDate) getRealizationById(long realizationId) Retrieves a realization identified by its technical identifier.getRealizationById(long realizationId, org.exoplatform.services.security.Identity userAclIdentity) Retrieves a realization identified by its technical identifier.getRealizationsByFilter(RealizationFilter realizationFilter, int offset, int limit) Retrieves all Realizations by Filter.getRealizationsByFilter(RealizationFilter realizationFilter, org.exoplatform.services.security.Identity userAclIdentity, int offset, int limit) Retrieves all Realizations by Filter.getRealizationValidityContext(RuleDTO rule, long earnerIdentityId) Checks whether earner can create a realization on a designated rule at this moment or notlonggetScoreByIdentityId(String earnerIdentityId) RetrievesIdentitytotal scorelonggetScoreByIdentityIdAndBetweenDates(String earnerIdentityId, Date fromDate, Date toDate, Long spaceId, Long programId) Retrieves identities total score between designated datesgetScorePerProgramByIdentityId(String earnerIdentityId) Compute User reputation score by programgetScoresByIdentityIdsAndBetweenDates(List<String> earnersId, Date fromDate, Date toDate) Retrieves identities total score between designated datesbooleanhasPendingRealization(long ruleId, String earnerIdentityId) Makes a check whether a given user has a pending realization for a given rule or not.booleanisRealizationManager(String username) Checks whether the user can manage realizations of one or multiple programs, even deleted ones.voidstart()voidstop()voidupdateRealizationStatus(long realizationId, RealizationStatus status) Updates an existing realization statusvoidupdateRealizationStatus(long realizationId, RealizationStatus status, String username) Updates an existing realization statusMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.meeds.gamification.service.RealizationService
getLeaderboardStatsByIdentityId, getScoreByIdentityIdAndBetweenDates
-
Constructor Details
-
RealizationServiceImpl
public RealizationServiceImpl(ProgramService programService, RuleService ruleService, org.exoplatform.services.resources.ResourceBundleService resourceBundleService, EventService eventService, org.exoplatform.social.core.manager.IdentityManager identityManager, org.exoplatform.social.core.space.spi.SpaceService spaceService, RealizationStorage realizationStorage, org.exoplatform.services.listener.ListenerService listenerService, org.exoplatform.container.xml.InitParams initParams)
-
-
Method Details
-
start
public void start()- Specified by:
startin interfaceorg.picocontainer.Startable
-
stop
public void stop()- Specified by:
stopin interfaceorg.picocontainer.Startable
-
getRealizationsByFilter
public List<RealizationDTO> getRealizationsByFilter(RealizationFilter realizationFilter, org.exoplatform.services.security.Identity userAclIdentity, int offset, int limit) throws IllegalAccessException Description copied from interface:RealizationServiceRetrieves all Realizations by Filter.- Specified by:
getRealizationsByFilterin interfaceRealizationService- Parameters:
realizationFilter- used to filter realizations usingRealizationFilteruserAclIdentity- current identityIdentityoffset- Offsetlimit- Limit- Returns:
- A
<RealizationDTO>object - Throws:
IllegalAccessException- when User doesn't have enough privileges to access achievements of user
-
getRealizationsByFilter
public List<RealizationDTO> getRealizationsByFilter(RealizationFilter realizationFilter, int offset, int limit) Description copied from interface:RealizationServiceRetrieves all Realizations by Filter.- Specified by:
getRealizationsByFilterin interfaceRealizationService- Parameters:
realizationFilter- used to filter realizations usingRealizationFilteroffset- Offsetlimit- Limit- Returns:
- A
<RealizationDTO>object
-
countRealizationsByFilter
public int countRealizationsByFilter(RealizationFilter realizationFilter, org.exoplatform.services.security.Identity userAclIdentity) throws IllegalAccessException Description copied from interface:RealizationServiceCount realizations by filter- Specified by:
countRealizationsByFilterin interfaceRealizationService- Parameters:
realizationFilter- used to filter realizations usingRealizationFilteruserAclIdentity- currentIdentity- Returns:
- realizations count
- Throws:
IllegalAccessException- when User doesn't have enough privileges to access achievements of user
-
countRealizationsByFilter
Description copied from interface:RealizationServiceCount realizations by filter- Specified by:
countRealizationsByFilterin interfaceRealizationService- Parameters:
realizationFilter- used to filter realizations usingRealizationFilter- Returns:
- realizations count
-
getLeaderboardRank
public int getLeaderboardRank(long earnerIdentityId, Date fromDate, Date toDate, Long spaceId, Long programId) Description copied from interface:RealizationServiceRetrieves Leaderboard rank of an earnerIdentityid andProgramDTOid for the given date- Specified by:
getLeaderboardRankin interfaceRealizationService- Parameters:
earnerIdentityId- earnerIdentityidfromDate- From datetoDate- End DatespaceId- audience space IdprogramId- program Id- Returns:
- identity leaderboard rank in
Integer
-
getScoreByIdentityId
Description copied from interface:RealizationServiceRetrievesIdentitytotal score- Specified by:
getScoreByIdentityIdin interfaceRealizationService- Parameters:
earnerIdentityId-Identityid- Returns:
- total score
-
getScorePerProgramByIdentityId
Description copied from interface:RealizationServiceCompute User reputation score by program- Specified by:
getScorePerProgramByIdentityIdin interfaceRealizationService- Parameters:
earnerIdentityId- earnerIdentityid- Returns:
- list of objects of type
ProfileReputation
-
createRealizationsAsync
public void createRealizationsAsync(String event, String eventDetails, String earnerIdentityId, String receiverIdentityId, String objectId, String objectType) Description copied from interface:RealizationServiceCreates new Realizations asynchronously switch an event name for a given object identified by its id and type- Specified by:
createRealizationsAsyncin interfaceRealizationService- Parameters:
event-RuleDTOevent nameeventDetails-earnerIdentityId-IdentityidreceiverIdentityId-IdentityidobjectId- the designated object type identifierobjectType- an object type, like 'activity', 'kudos' ...
-
createRealizations
public List<RealizationDTO> createRealizations(String event, String eventDetails, String earnerIdentityId, String receiverIdentityId, String objectId, String objectType) Description copied from interface:RealizationServiceCreates new Realizations switch an event name for a given object identified by its id and type- Specified by:
createRealizationsin interfaceRealizationService- Parameters:
event-RuleDTOevent nameeventDetails-earnerIdentityId-IdentityidreceiverIdentityId-IdentityidobjectId- the designated object type identifierobjectType- an object type, like 'activity', 'kudos' ...- Returns:
- list of created
RealizationDTO
-
updateRealizationStatus
public void updateRealizationStatus(long realizationId, RealizationStatus status) throws org.exoplatform.commons.exception.ObjectNotFoundException Description copied from interface:RealizationServiceUpdates an existing realization status- Specified by:
updateRealizationStatusin interfaceRealizationService- Parameters:
realizationId-RealizationDTOtechnical identifierstatus- newRealizationStatusto set- Throws:
org.exoplatform.commons.exception.ObjectNotFoundException- when the realization identified by its technical identifier is not found
-
updateRealizationStatus
public void updateRealizationStatus(long realizationId, RealizationStatus status, String username) throws IllegalAccessException, org.exoplatform.commons.exception.ObjectNotFoundException Description copied from interface:RealizationServiceUpdates an existing realization status- Specified by:
updateRealizationStatusin interfaceRealizationService- Parameters:
realizationId-RealizationDTOtechnical identifierstatus- newRealizationStatusto setusername- user name of modifier- Throws:
IllegalAccessException- when user is not authorized to update the realizationorg.exoplatform.commons.exception.ObjectNotFoundException- when the realization identified by its technical identifier is not found
-
cancelRealizations
public List<RealizationDTO> cancelRealizations(String event, String earnerIdentityId, String receiverIdentityId, String objectId, String objectType) Description copied from interface:RealizationServiceCancels an existing Realization with an event name for a given object identified by its id and type- Specified by:
cancelRealizationsin interfaceRealizationService- Parameters:
event-RuleDTOevent nameearnerIdentityId-IdentityidreceiverIdentityId-IdentityidobjectId- the designated object type identifierobjectType- an object type, like 'activity', 'kudos' ...- Returns:
- list of cancelled
RealizationDTO
-
deleteRealizations
Description copied from interface:RealizationServiceMarks all realizations of a given object, generally due to deletion of originating object- Specified by:
deleteRealizationsin interfaceRealizationService- Parameters:
objectId- the designated object type identifierobjectType- an object type, like 'activity', 'kudos' ...- Returns:
- list of marked as deleted
RealizationDTO
-
getRealizationValidityContext
public RealizationValidityContext getRealizationValidityContext(RuleDTO rule, long earnerIdentityId) Description copied from interface:RealizationServiceChecks whether earner can create a realization on a designated rule at this moment or not- Specified by:
getRealizationValidityContextin interfaceRealizationService- Parameters:
rule-RuleDTOearnerIdentityId-Identityid- Returns:
RealizationValidityContextif can not create a realization, else null
-
getLeaderboard
public List<StandardLeaderboard> getLeaderboard(LeaderboardFilter filter, String currentUser) throws IllegalAccessException Description copied from interface:RealizationServiceRetrieves Leaderboard switch designated filter- Specified by:
getLeaderboardin interfaceRealizationService- Parameters:
filter- of typeLeaderboardFilter, used to filter querycurrentUser- Currrent user name- Returns:
Listof objects of type StandardLeaderboard- Throws:
IllegalAccessException- when space board and anonymous access
-
getLeaderboardStatsByIdentityId
public List<PiechartLeaderboard> getLeaderboardStatsByIdentityId(String earnerIdentityId, Long spaceId, String period, Date startDate, Date endDate) Description copied from interface:RealizationServiceRetrieves scores per doamin of a givenIdentity- Specified by:
getLeaderboardStatsByIdentityIdin interfaceRealizationService- Parameters:
earnerIdentityId- earner identity idspaceId- Program Audience Space Identifierperiod- Period TypestartDate- Start DateendDate- End Date- Returns:
- a list of object of type PiechartLeaderboard
-
getScoreByIdentityIdAndBetweenDates
public long getScoreByIdentityIdAndBetweenDates(String earnerIdentityId, Date fromDate, Date toDate, Long spaceId, Long programId) Description copied from interface:RealizationServiceRetrieves identities total score between designated dates- Specified by:
getScoreByIdentityIdAndBetweenDatesin interfaceRealizationService- Parameters:
earnerIdentityId-IdentityidfromDate- From datetoDate- End datespaceId- Space IdprogramId- Program Id- Returns:
- total score
-
getScoresByIdentityIdsAndBetweenDates
public Map<Long,Long> getScoresByIdentityIdsAndBetweenDates(List<String> earnersId, Date fromDate, Date toDate) Description copied from interface:RealizationServiceRetrieves identities total score between designated dates- Specified by:
getScoresByIdentityIdsAndBetweenDatesin interfaceRealizationService- Parameters:
earnersId-fromDate-toDate-- Returns:
MapwithIdentityid as key and score as value
-
getParticipantsBetweenDates
- Specified by:
getParticipantsBetweenDatesin interfaceRealizationService- Parameters:
fromDate- start of periodtoDate- end of period- Returns:
- List of participant users in a period of time
-
countParticipantsBetweenDates
- Specified by:
countParticipantsBetweenDatesin interfaceRealizationService- Parameters:
fromDate- start of periodtoDate- end of period- Returns:
- Count participant users in a period of time
-
getRealizationById
Description copied from interface:RealizationServiceRetrieves a realization identified by its technical identifier.- Specified by:
getRealizationByIdin interfaceRealizationService- Parameters:
realizationId- technical identifier of a realization- Returns:
- A
RealizationDTOobject
-
isRealizationManager
Description copied from interface:RealizationServiceChecks whether the user can manage realizations of one or multiple programs, even deleted ones.- Specified by:
isRealizationManagerin interfaceRealizationService- Parameters:
username- User name- Returns:
- true if can manage realizations, else false
-
getRealizationById
public RealizationDTO getRealizationById(long realizationId, org.exoplatform.services.security.Identity userAclIdentity) throws IllegalAccessException, org.exoplatform.commons.exception.ObjectNotFoundException Description copied from interface:RealizationServiceRetrieves a realization identified by its technical identifier.- Specified by:
getRealizationByIdin interfaceRealizationService- Parameters:
realizationId- technical identifier of a realizationuserAclIdentity- current identityIdentity- Returns:
- A
RealizationDTOobject - Throws:
IllegalAccessException- when user is not authorized to access realizationorg.exoplatform.commons.exception.ObjectNotFoundException- when the realization identified by its technical identifier is not found
-
findRealizationsByObjectIdAndObjectType
public List<RealizationDTO> findRealizationsByObjectIdAndObjectType(String objectId, String objectType) Description copied from interface:RealizationServiceRetrieves the list of realizations identified by object Id and object Type.- Specified by:
findRealizationsByObjectIdAndObjectTypein interfaceRealizationService- Parameters:
objectId- object IdobjectType- object Type- Returns:
- A
<RealizationDTO>object
-
hasPendingRealization
Description copied from interface:RealizationServiceMakes a check whether a given user has a pending realization for a given rule or not.- Specified by:
hasPendingRealizationin interfaceRealizationService- Parameters:
ruleId-RuleDTOidentifierearnerIdentityId-Identityid- Returns:
- true if has a pending realization, else false
-
exportXlsx
public InputStream exportXlsx(RealizationFilter filter, org.exoplatform.services.security.Identity identity, String fileName, Locale locale) throws IllegalAccessException Description copied from interface:RealizationServiceExport realizations found switch filter into anInputStreamcontaining a file of format XLS- Specified by:
exportXlsxin interfaceRealizationService- Parameters:
filter- used to filter realizations usingRealizationFilteridentity- currentIdentityfileName- fileName to exportlocale- usedLocalefor XLS header labels- Returns:
InputStreamof a file of format XLS- Throws:
IllegalAccessException- when User doesn't have enough privileges to access achievements of user
-
createRealizationsAsyncInternal
-