NdsBeisEsb/src/main/java/com/northgateps/nds/beis/esb/statistics/StatisticsPersistenceAdapter.java
/**
     * Prepare the stats for the email request
     * 
     * @param exchange
     */
Prepare the stats for the email request

@param exchange
Prepare the stats for the email request @param exchange
public void prepareStatsForEmailRequest(Exchange exchange) {
        NdsSoapRequestAdapterExchangeProxy ndsExchange = new NdsSoapRequestAdapterExchangeProxyImpl(exchange);
        UserAccountStatisticsNdsResponse userAccountStatisticsNdsResponse = (UserAccountStatisticsNdsResponse) ndsExchange.getAnExchangeProperty(
                USER_STATS_RESPONSE);
        StatisticsNdsRequest statisticsNdsRequest = null;
        try {
            statisticsNdsRequest = (StatisticsNdsRequest) ndsExchange.getRequestMessageBody(StatisticsNdsRequest.class);
        } catch (ClassNotFoundException e) {
            logger.error("prepareStatsForEmailRequest StatisticsNdsRequest failed due to " + e.getMessage());
        }
        statisticsNdsRequest.setNumberOfSuccessfulLogins(userAccountStatisticsNdsResponse.getLoginSuccessCount());
        statisticsNdsRequest.setNumberOfFailedLogins(userAccountStatisticsNdsResponse.getLoginFailedCount());
        statisticsNdsRequest.setNumberOfChangePassword(userAccountStatisticsNdsResponse.getChangePasswordCount());
        statisticsNdsRequest.setNumberOfRegistration(userAccountStatisticsNdsResponse.getRegistrationCount());
        statisticsNdsRequest.setNumberOfResetPassword(userAccountStatisticsNdsResponse.getResetPasswordCount());
        NdsBatchJobMetaData batchJobMetadata = (NdsBatchJobMetaData) ndsExchange.getAnExchangeProperty(
                BatchJobPersistenceAdapter.BATCH_JOB_META_DATA);
        if (batchJobMetadata != null) {
            batchJobMetadata.setEndTimestamp(LocalDateTime.now().atZone(ZoneOffset.UTC));
            batchJobMetadata.setNotes(" Succesful logins count: " + statisticsNdsRequest.getNumberOfSuccessfulLogins()
                    + " Failed logins count: " + statisticsNdsRequest.getNumberOfFailedLogins()
                    + " Number of registrations: " + statisticsNdsRequest.getNumberOfRegistration()
                    + " Number of change password: "+ statisticsNdsRequest.getNumberOfChangePassword()
                    + " Number of reset password: "+ statisticsNdsRequest.getNumberOfResetPassword()
                    + " Successfully submitted exemptions: "+ statisticsNdsRequest.getNumberOfRegisteredExemptions()                  
                    + " Domestic Exemptions: "+ statisticsNdsRequest.getNumberOfDomesticExemptions()
                    + " Nondomestic Exemptions: "+ statisticsNdsRequest.getNumberOfNonDomesticExemptions());
        }
        ndsExchange.setAnExchangeProperty(BatchJobPersistenceAdapter.BATCH_JOB_META_DATA, batchJobMetadata);
        ndsExchange.setResponseMessageBody(statisticsNdsRequest);
    }
public void prepareStatsForEmailRequest ( Exchange exchange ) { NdsSoapRequestAdapterExchangeProxy ndsExchange = new NdsSoapRequestAdapterExchangeProxyImpl ( exchange ) ; UserAccountStatisticsNdsResponse userAccountStatisticsNdsResponse = ( UserAccountStatisticsNdsResponse ) ndsExchange . getAnExchangeProperty ( USER_STATS_RESPONSE ) ; StatisticsNdsRequest statisticsNdsRequest = null ; try { statisticsNdsRequest = ( StatisticsNdsRequest ) ndsExchange . getRequestMessageBody ( StatisticsNdsRequest . class ) ; } catch ( ClassNotFoundException e ) { logger . error ( "prepareStatsForEmailRequest StatisticsNdsRequest failed due to " + e . getMessage ( ) ) ; } statisticsNdsRequest . setNumberOfSuccessfulLogins ( userAccountStatisticsNdsResponse . getLoginSuccessCount ( ) ) ; statisticsNdsRequest . setNumberOfFailedLogins ( userAccountStatisticsNdsResponse . getLoginFailedCount ( ) ) ; statisticsNdsRequest . setNumberOfChangePassword ( userAccountStatisticsNdsResponse . getChangePasswordCount ( ) ) ; statisticsNdsRequest . setNumberOfRegistration ( userAccountStatisticsNdsResponse . getRegistrationCount ( ) ) ; statisticsNdsRequest . setNumberOfResetPassword ( userAccountStatisticsNdsResponse . getResetPasswordCount ( ) ) ; NdsBatchJobMetaData batchJobMetadata = ( NdsBatchJobMetaData ) ndsExchange . getAnExchangeProperty ( BatchJobPersistenceAdapter . BATCH_JOB_META_DATA ) ; if ( batchJobMetadata != null ) { batchJobMetadata . setEndTimestamp ( LocalDateTime . now ( ) . atZone ( ZoneOffset . UTC ) ) ; batchJobMetadata . setNotes ( " Succesful logins count: " + statisticsNdsRequest . getNumberOfSuccessfulLogins ( ) + " Failed logins count: " + statisticsNdsRequest . getNumberOfFailedLogins ( ) + " Number of registrations: " + statisticsNdsRequest . getNumberOfRegistration ( ) + " Number of change password: " + statisticsNdsRequest . getNumberOfChangePassword ( ) + " Number of reset password: " + statisticsNdsRequest . getNumberOfResetPassword ( ) + " Successfully submitted exemptions: " + statisticsNdsRequest . getNumberOfRegisteredExemptions ( ) + " Domestic Exemptions: " + statisticsNdsRequest . getNumberOfDomesticExemptions ( ) + " Nondomestic Exemptions: " + statisticsNdsRequest . getNumberOfNonDomesticExemptions ( ) ) ; } ndsExchange . setAnExchangeProperty ( BatchJobPersistenceAdapter . BATCH_JOB_META_DATA , batchJobMetadata ) ; ndsExchange . setResponseMessageBody ( statisticsNdsRequest ) ; }
Prepare the stats for the email request
Prepare the stats for the email request
// NB: not setting the batchJobMetadata.RecordCount, as no records were actually affected and we've already set the individual counts in the notes