Package org.cyclos.impl.banking
Class ARateTypeHandlerImpl
- java.lang.Object
-
- org.cyclos.impl.AbstractServerComponent
-
- org.cyclos.impl.AbstractNetworkedServerComponent
-
- org.cyclos.impl.BaseNetworkedHandlerImpl
-
- org.cyclos.impl.banking.BaseRateTypeHandlerImpl<Date,R,D>
-
- org.cyclos.impl.banking.TimeBasedRateTypeHandlerImpl<ARateParameters,ARateParametersDTO>
-
- org.cyclos.impl.banking.ARateTypeHandlerImpl
-
- All Implemented Interfaces:
ARateTypeHandler,ARateTypeHandlerTestable,RateTypeHandler<Date,ARateParameters,ARateParametersDTO>,TimeBasedRateTypeHandler<ARateParameters,ARateParametersDTO>
@Component public class ARateTypeHandlerImpl extends TimeBasedRateTypeHandlerImpl<ARateParameters,ARateParametersDTO> implements ARateTypeHandlerTestable
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.cyclos.impl.banking.BaseRateTypeHandlerImpl
BaseRateTypeHandlerImpl.RateParametersChangeAction
-
-
Field Summary
-
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.RateTypeHandler
RATE_SCALE
-
-
Constructor Summary
Constructors Constructor Description ARateTypeHandlerImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidassignEntityToCurrency(ARateParameters entity, Currency currency)Assigns the RateParameters entity to the currency, so that the RateParameters entity becomes the new active RateParameters for this currency.protected voidassignValidator(Validator currencyValidator, Validator rateParametersValidator)sets specific checks to the RateParametersValidator, and assigns it as nested Validator to the currencyValidator.protected BigDecimalcalculateRateChange(BigDecimal oldRate, Date oldDate, Date newDate)Defines the business logic of rates developing over time.voidcomplete(RatesData rates)Completes the ratesData by calculating all missing fields of the rate (aRate, raw rate field).Dateconvert(BigDecimal rate, Date date)Converts the nominal rate (as a BigDecimal) to the raw valuevoidcopy(HasRates source, HasRates destination)Copies the rate field from source to destinationprotected com.querydsl.core.types.PathgetAccountRatesFieldPath()gets the path for the relevant field of the QAccountRates query.protected ARateParametersgetCurrentRateParameters(Currency currency)protected Class<ARateParameters>getEntityClass()gets the RateParameters classDategetNullSafeRawRate(RatedEntity entity, Currency currency, Date date)Gets the rawRate from the entity in a null-safe way.protected List<ARateParameters>getParametersList()protected QRateParametersgetQuery()gets the QXRateParameters.xRateParameters of QueryDSL as a view of itself as the parent type.ARateParametersgetRateParameters(Currency currency)Gets the RateParameters from the Currency by simply calling the getter.ARateParametersDTOgetRateParametersDTO(CurrencyDTO currencyDTO)Gets the RateParametersDTO of the CurrencyDTORateTypegetRateType()Returns the rate type being handledvoidsetRate(HasRates destination, BigDecimal rate)Sets the rate to the destination objectvoidsetRawRate(RatedEntity destination, Date rawRate)Sets the rawRate to the desitnation object.-
Methods inherited from class org.cyclos.impl.banking.TimeBasedRateTypeHandlerImpl
adjustIncomingRawRateInTransfer, convert, convert, convert, getInitValue, hasEqualProperties
-
Methods inherited from class org.cyclos.impl.banking.BaseRateTypeHandlerImpl
applyIncomingTransfer, calculateFromRates, convert, getCreationValue, getEnableDate, getRateParameters, immediateDisableActions, inverseMerge, isEnabled, isVisible, isVisibleToUser, merge, nullAllAccountRates, resolveValidator, toEntity
-
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, toDate, toDateTime, validate
-
Methods inherited from class org.cyclos.impl.AbstractServerComponent
dataTranslationProxy, delete, detach, find, flush, from, getApplicationContext, getFormatter, getFormatter, getFormatter, getLogger, getRemoteAddress, getSessionData, mailContentBuilder, message, message, persist, processBatch, processBatch, refresh, remove, selectFrom, subQuery, update
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.cyclos.impl.banking.ARateTypeHandlerTestable
merge
-
Methods inherited from interface org.cyclos.impl.banking.RateTypeHandler
applyIncomingTransfer, calculateFromRates, convert, getCreationValue, getEnableDate, getRateParameters, isEnabled, isVisible, isVisibleToUser, nullAllAccountRates, resolveValidator, toEntity
-
Methods inherited from interface org.cyclos.impl.banking.TimeBasedRateTypeHandler
convert, convert, getInitValue
-
-
-
-
Method Detail
-
complete
public void complete(RatesData rates)
Description copied from interface:RateTypeHandlerCompletes the ratesData by calculating all missing fields of the rate (aRate, raw rate field). If both a rate and its raw value are present, the rate is overwritten with the value belonging to the raw value. So if ARate and EmissionDate are both present, A-rate is set to the value corresponding with EmissionDate.- Specified by:
completein interfaceRateTypeHandler<Date,ARateParameters,ARateParametersDTO>
-
convert
public Date convert(BigDecimal rate, Date date)
Description copied from interface:RateTypeHandlerConverts the nominal rate (as a BigDecimal) to the raw value- Specified by:
convertin interfaceRateTypeHandler<Date,ARateParameters,ARateParametersDTO>- Parameters:
rate- the input rate as a BigDecimaldate- the date at which this rate is valid. If null, current date/time is used.- Returns:
- the raw rate as a java.util.Date.
-
copy
public void copy(HasRates source, HasRates destination)
Description copied from interface:RateTypeHandlerCopies the rate field from source to destination- Specified by:
copyin interfaceRateTypeHandler<Date,ARateParameters,ARateParametersDTO>
-
getNullSafeRawRate
public Date getNullSafeRawRate(RatedEntity entity, Currency currency, Date date)
Description copied from interface:RateTypeHandlerGets the rawRate from the entity in a null-safe way. That means: if the raw rate appears to be null, it checks if the rate is enabled, and if so, it gets the init value, if applicable.- Specified by:
getNullSafeRawRatein interfaceRateTypeHandler<Date,ARateParameters,ARateParametersDTO>- Parameters:
entity- the entity from which the raw rate is readcurrency- is only used in case the entity has a null rate. In that case the init value is looked up on the entity.date- is only used in case the entity has a null rate. If null, the present date is used (now).
-
getRateParameters
public ARateParameters getRateParameters(Currency currency)
Description copied from interface:RateTypeHandlerGets the RateParameters from the Currency by simply calling the getter.- Specified by:
getRateParametersin interfaceRateTypeHandler<Date,ARateParameters,ARateParametersDTO>
-
getRateParametersDTO
public ARateParametersDTO getRateParametersDTO(CurrencyDTO currencyDTO)
Description copied from interface:RateTypeHandlerGets the RateParametersDTO of the CurrencyDTO- Specified by:
getRateParametersDTOin interfaceRateTypeHandler<Date,ARateParameters,ARateParametersDTO>
-
getRateType
public RateType getRateType()
Description copied from interface:RateTypeHandlerReturns the rate type being handled- Specified by:
getRateTypein interfaceRateTypeHandler<Date,ARateParameters,ARateParametersDTO>
-
setRate
public void setRate(HasRates destination, BigDecimal rate)
Description copied from interface:RateTypeHandlerSets the rate to the destination object- Specified by:
setRatein interfaceRateTypeHandler<Date,ARateParameters,ARateParametersDTO>
-
setRawRate
public void setRawRate(RatedEntity destination, Date rawRate)
Description copied from interface:RateTypeHandlerSets the rawRate to the desitnation object.- Specified by:
setRawRatein interfaceRateTypeHandler<Date,ARateParameters,ARateParametersDTO>
-
assignEntityToCurrency
protected void assignEntityToCurrency(ARateParameters entity, Currency currency)
Description copied from class:BaseRateTypeHandlerImplAssigns the RateParameters entity to the currency, so that the RateParameters entity becomes the new active RateParameters for this currency. Note that the method only calls the currency's setter. SeeBaseRateTypeHandlerImpl.appendToRateParametersHistory(D,org.cyclos.entities.banking.Currency)for other actions to be taken.- Specified by:
assignEntityToCurrencyin classBaseRateTypeHandlerImpl<Date,ARateParameters,ARateParametersDTO>
-
assignValidator
protected void assignValidator(Validator currencyValidator, Validator rateParametersValidator)
Description copied from class:BaseRateTypeHandlerImplsets specific checks to the RateParametersValidator, and assigns it as nested Validator to the currencyValidator.- Specified by:
assignValidatorin classBaseRateTypeHandlerImpl<Date,ARateParameters,ARateParametersDTO>
-
calculateRateChange
protected BigDecimal calculateRateChange(BigDecimal oldRate, Date oldDate, Date newDate)
Defines the business logic of rates developing over time. Gives the new rate, on basis of the old rate, the old date, and the new date.
To calculate the rate from the stored emission date, useactualARate = calculateRateChange(BigDecimal.ZERO, emissionDate, actualDate);
- Specified by:
calculateRateChangein classTimeBasedRateTypeHandlerImpl<ARateParameters,ARateParametersDTO>- Parameters:
oldRate- a BigDecimal representing the old rate.oldDate- the java.util.Date belonging to oldRatenewDate- the java.util.Date for which the new Rate is requested- Returns:
- the new rate belonging to newDate.
-
getAccountRatesFieldPath
protected com.querydsl.core.types.Path getAccountRatesFieldPath()
Description copied from class:BaseRateTypeHandlerImplgets the path for the relevant field of the QAccountRates query. For example, returns for A-rate the QAccountRates.emissionDate field path.- Specified by:
getAccountRatesFieldPathin classBaseRateTypeHandlerImpl<Date,ARateParameters,ARateParametersDTO>- Returns:
-
getCurrentRateParameters
protected ARateParameters getCurrentRateParameters(Currency currency)
- Specified by:
getCurrentRateParametersin classBaseRateTypeHandlerImpl<Date,ARateParameters,ARateParametersDTO>
-
getEntityClass
protected Class<ARateParameters> getEntityClass()
Description copied from class:BaseRateTypeHandlerImplgets the RateParameters class- Specified by:
getEntityClassin classBaseRateTypeHandlerImpl<Date,ARateParameters,ARateParametersDTO>
-
getParametersList
protected List<ARateParameters> getParametersList()
- Specified by:
getParametersListin classBaseRateTypeHandlerImpl<Date,ARateParameters,ARateParametersDTO>
-
getQuery
protected QRateParameters getQuery()
Description copied from class:BaseRateTypeHandlerImplgets the QXRateParameters.xRateParameters of QueryDSL as a view of itself as the parent type. So for A-Rate, it gets QARateParametes.aRateParameters as QRateParameters. This is useful for queries on RateParameters for fields which are general for all rate types.- Specified by:
getQueryin classBaseRateTypeHandlerImpl<Date,ARateParameters,ARateParametersDTO>
-
-