Package org.cyclos.impl.banking
Class AccountFeeLogServiceImpl
- java.lang.Object
-
- org.cyclos.impl.AbstractServerComponent
-
- org.cyclos.impl.AbstractNetworkedServerComponent
-
- org.cyclos.impl.BaseServiceImpl
-
- org.cyclos.impl.banking.AccountFeeLogServiceImpl
-
- All Implemented Interfaces:
AccountFeeLogServiceLocal,AccountFeeLogService,Service
@Service public class AccountFeeLogServiceImpl extends BaseServiceImpl implements AccountFeeLogServiceLocal
Implementation forAccountFeeLogService
-
-
Field Summary
Fields Modifier and Type Field Description protected JdbcTemplatejdbcTemplate-
Fields inherited from class org.cyclos.impl.AbstractNetworkedServerComponent
authHandler, conversionHandler, customFieldValueHandler, entityManagerHandler, groupsHandler, productsHandler, restBeanPropertyMapping, userLocatorHandler
-
Fields inherited from class org.cyclos.impl.AbstractServerComponent
accountHandler, configurationHandler, dataTranslationHandler, notificationHandler, profileFieldHandler, transactionHandler, translationHandler
-
Fields inherited from interface org.cyclos.impl.banking.AccountFeeLogServiceLocal
ATTR_ACCOUNT, ATTR_EXECUTION_DATE, ATTR_FEE
-
-
Constructor Summary
Constructors Constructor Description AccountFeeLogServiceImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longarchiveAccountFee(long id)Archives the account fee log with the given id, returning the number of removedUserAccountFeeLogsBigDecimalcalculateAmount(AccountFeeLog execution, UserAccount account)Calculates the amount to be charged for the given user account on the given fee execution.BigDecimalcalculateReservedAmount(AccountFee accountFee, UserAccount account)Returns the reserved amount for an account fee over a given accountvoidchargeBatch(List<Long> uaflIds)Changes a batch ofUserAccountFeeLogs.AccountFeeLogDatagetData(Long id)Returns data about an account fee executionAccountFeeExecutionSearchDatagetFeeExecutionsSearchData()Returns data for searching account fee executionsAccountFeeLoggetLastExecution(AccountFee accountFee)Returns the last execution log for a given fee, or null if it was never chargedDategetNextExecutionDate(AccountFee accountFee, AccountFeeLog lastExecution)Returns the next date the given fee should be executed, or null if the fee is disabled or manualAccountFeeLogsSearchDatagetSearchData(AccountFeeVO accountFeeVO)Returns data to search account fee logs of the given account feecom.mysema.commons.lang.CloseableIterator<Long>getUserAFLIdsToCharge(AccountFeeLog log)Returns the identifiers ofUserAccountFeeLogs that should be charged for this log.booleanhasUsers(AccountFeeLog accountFeeLog)Returns whether there areUserAccountFeeLogs for the given fee executionlonginsertMissingScheduledExecutions()For each enabled scheduled fee, inserts all missingAccountFeeLogsvoidmarkFinished(AccountFeeLog log)Marks the given account fee log as finished.voidrechargeFailed(Long id)Starts recharging a fee which has finished and some failed usersprotected voidregisterNetworkMappings(NetworkPathRegistry networkPathRegistry)Needs to be overridden by subclasses to register the path up to the networkUserAccountresolveAccount(AccountFeeLog accountFeeLog, User user)Returns theUserAccountfor the given user involved in the given fee log.LongrunNow(AccountFeeVO accountFeeVO)Starts charging a manual fee, returning the resulting account fee log idPage<AccountFeeLogVO>search(AccountFeeLogQuery query)Searches for account fee logs according to the given criteriaPage<AccountFeeExecutionVO>searchFeeExecutions(AccountFeeQuery query)Search for visible account fees, together with the previous and next execution data-
Methods inherited from class org.cyclos.impl.BaseServiceImpl
initializeNetworkMappings
-
Methods inherited from class org.cyclos.impl.AbstractNetworkedServerComponent
canManage, checkManagesUser, checkPermission, checkRelatesToUser, checkValue, clearAlreadyValidated, getBaseEntityManagerHandler, getConfiguration, getLoggedBasicUser, getLoggedUser, getProducts, getTranslatedName, getTranslatedValue, hasPermission, hasValue, inSameNetwork, inSameNetworkOrGlobal, isAdmin, isAlreadyValidated, isBroker, isGlobalAdmin, isGlobalAdminInNetwork, isGuest, isLoggedIn, isMember, isMemberOnly, isNetworkAdmin, isOperator, isRelatedToUser, isSystem, isUserManager, isUserManagerOf, message, message, permission, permission, permissionOptionalValue, permissionOptionalValue, setAlreadyValidated, toDate, toDateTime, validate
-
Methods inherited from class org.cyclos.impl.AbstractServerComponent
dataTranslationProxy, dataTranslationProxy, delete, detach, doDataTranslationProxy, find, flush, from, getApplicationContext, getFormatter, getFormatter, getFormatter, getLogger, getRemoteAddress, getSessionData, mailContentBuilder, message, message, persist, processBatch, processBatch, refresh, remove, selectFrom, subQuery, update
-
-
-
-
Field Detail
-
jdbcTemplate
@Autowired protected JdbcTemplate jdbcTemplate
-
-
Method Detail
-
archiveAccountFee
public long archiveAccountFee(long id)
Description copied from interface:AccountFeeLogServiceLocalArchives the account fee log with the given id, returning the number of removedUserAccountFeeLogs- Specified by:
archiveAccountFeein interfaceAccountFeeLogServiceLocal
-
calculateAmount
public BigDecimal calculateAmount(AccountFeeLog execution, UserAccount account) throws FrameworkException
Description copied from interface:AccountFeeLogServiceLocalCalculates the amount to be charged for the given user account on the given fee execution. Returns null when nothing should be charged (for example, because of the freebase)- Specified by:
calculateAmountin interfaceAccountFeeLogServiceLocal- Throws:
FrameworkException
-
calculateReservedAmount
public BigDecimal calculateReservedAmount(AccountFee accountFee, UserAccount account)
Description copied from interface:AccountFeeLogServiceLocalReturns the reserved amount for an account fee over a given account- Specified by:
calculateReservedAmountin interfaceAccountFeeLogServiceLocal
-
chargeBatch
public void chargeBatch(List<Long> uaflIds)
Description copied from interface:AccountFeeLogServiceLocalChanges a batch ofUserAccountFeeLogs.- Specified by:
chargeBatchin interfaceAccountFeeLogServiceLocal
-
getData
public AccountFeeLogData getData(Long id) throws FrameworkException
Description copied from interface:AccountFeeLogServiceReturns data about an account fee execution- Specified by:
getDatain interfaceAccountFeeLogService- Throws:
FrameworkException
-
getFeeExecutionsSearchData
public AccountFeeExecutionSearchData getFeeExecutionsSearchData() throws FrameworkException
Description copied from interface:AccountFeeLogServiceReturns data for searching account fee executions- Specified by:
getFeeExecutionsSearchDatain interfaceAccountFeeLogService- Throws:
FrameworkException
-
getLastExecution
public AccountFeeLog getLastExecution(AccountFee accountFee)
Description copied from interface:AccountFeeLogServiceLocalReturns the last execution log for a given fee, or null if it was never charged- Specified by:
getLastExecutionin interfaceAccountFeeLogServiceLocal
-
getNextExecutionDate
public Date getNextExecutionDate(AccountFee accountFee, AccountFeeLog lastExecution)
Description copied from interface:AccountFeeLogServiceLocalReturns the next date the given fee should be executed, or null if the fee is disabled or manual- Specified by:
getNextExecutionDatein interfaceAccountFeeLogServiceLocal
-
getSearchData
public AccountFeeLogsSearchData getSearchData(AccountFeeVO accountFeeVO) throws FrameworkException
Description copied from interface:AccountFeeLogServiceReturns data to search account fee logs of the given account fee- Specified by:
getSearchDatain interfaceAccountFeeLogService- Throws:
FrameworkException
-
getUserAFLIdsToCharge
public com.mysema.commons.lang.CloseableIterator<Long> getUserAFLIdsToCharge(AccountFeeLog log)
Description copied from interface:AccountFeeLogServiceLocalReturns the identifiers ofUserAccountFeeLogs that should be charged for this log. If the log is in statusAccountFeeLogStatus.RUNNING, returns ids of UAFLs with statusUserAccountFeeStatus.PENDING. However, if the status isAccountFeeLogStatus.RECHARGING_FAILED, returns UAFLs with statusUserAccountFeeStatus.FAILEDand recharge attempt < account fee log's recharge attempt.- Specified by:
getUserAFLIdsToChargein interfaceAccountFeeLogServiceLocal
-
hasUsers
public boolean hasUsers(AccountFeeLog accountFeeLog)
Description copied from interface:AccountFeeLogServiceLocalReturns whether there areUserAccountFeeLogs for the given fee execution- Specified by:
hasUsersin interfaceAccountFeeLogServiceLocal
-
insertMissingScheduledExecutions
public long insertMissingScheduledExecutions() throws FrameworkExceptionDescription copied from interface:AccountFeeLogServiceLocalFor each enabled scheduled fee, inserts all missingAccountFeeLogs- Specified by:
insertMissingScheduledExecutionsin interfaceAccountFeeLogServiceLocal- Throws:
FrameworkException
-
markFinished
public void markFinished(AccountFeeLog log)
Description copied from interface:AccountFeeLogServiceLocalMarks the given account fee log as finished.- Specified by:
markFinishedin interfaceAccountFeeLogServiceLocal
-
rechargeFailed
public void rechargeFailed(Long id) throws FrameworkException
Description copied from interface:AccountFeeLogServiceStarts recharging a fee which has finished and some failed users- Specified by:
rechargeFailedin interfaceAccountFeeLogService- Throws:
IllegalActionException- If the given account fee log is not finished or doesn't have any failed usersFrameworkException
-
resolveAccount
public UserAccount resolveAccount(AccountFeeLog accountFeeLog, User user)
Description copied from interface:AccountFeeLogServiceLocalReturns theUserAccountfor the given user involved in the given fee log. Account fees may be paid from or to system.- Specified by:
resolveAccountin interfaceAccountFeeLogServiceLocal
-
runNow
public Long runNow(AccountFeeVO accountFeeVO) throws FrameworkException
Description copied from interface:AccountFeeLogServiceStarts charging a manual fee, returning the resulting account fee log id- Specified by:
runNowin interfaceAccountFeeLogService- Throws:
IllegalActionException- If the given fee is disabled or not manualFrameworkException
-
search
public Page<AccountFeeLogVO> search(AccountFeeLogQuery query) throws FrameworkException
Description copied from interface:AccountFeeLogServiceSearches for account fee logs according to the given criteria- Specified by:
searchin interfaceAccountFeeLogService- Throws:
FrameworkException
-
searchFeeExecutions
public Page<AccountFeeExecutionVO> searchFeeExecutions(AccountFeeQuery query) throws FrameworkException
Description copied from interface:AccountFeeLogServiceSearch for visible account fees, together with the previous and next execution data- Specified by:
searchFeeExecutionsin interfaceAccountFeeLogService- Throws:
FrameworkException
-
registerNetworkMappings
protected void registerNetworkMappings(NetworkPathRegistry networkPathRegistry)
Description copied from class:BaseServiceImplNeeds to be overridden by subclasses to register the path up to the network- Specified by:
registerNetworkMappingsin classBaseServiceImpl
-
-