<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.springframework.org/schema/beans"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd">

    <bean id="notificationService" class="com.armedia.acm.services.notification.service.NotificationServiceImpl">
        <property name="notificationDao" ref="notificationDao"/>
        <property name="notificationEventPublisher" ref="notificationEventPublisher"/>
        <property name="auditPropertyEntityAdapter" ref="auditPropertyEntityAdapter"/>
        <property name="notificationConfig" ref="notificationConfig"/>
        <property name="notificationBuilder" ref="notificationBuilder"/>
        <property name="sendExecutor" ref="notificationSendExecutor"/>
    </bean>

    <bean id ="notificationBuilder" class="com.armedia.acm.services.notification.service.NotificationBuilder">
        <property name="notificationUtils" ref="notificationUtils"/>
        <property name="notificationFormatter" ref="notificationFormatter"/>
    </bean>

    <bean id="notificationDao" class="com.armedia.acm.services.notification.dao.NotificationDao"/>

    <bean id="notificationJobDescriptor" class="com.armedia.acm.services.notification.service.NotificationJobDescriptor"
          parent="acmJobDescriptor">
        <property name="notificationService" ref="notificationService"/>
    </bean>

    <bean id="notificationEventPublisher" class="com.armedia.acm.services.notification.service.NotificationEventPublisher"/>

    <bean id="notificationToSolrTransformer" class="com.armedia.acm.services.notification.service.NotificationToSolrTransformer">
        <property name="notificationDao" ref="notificationDao"/>
        <property name="userDao" ref="userJpaDao"/>
        <property name="notificationUtils" ref="notificationUtils"/>
    </bean>

    <!-- Executors -->
    <bean id="acmEntityTemplateModelProvider" class="com.armedia.acm.services.notification.service.provider.AcmEntityTemplateModelProvider">
        <property name="dataService" ref="acmDataService"/>
    </bean>

    <bean id="acmUserTemplateModelProvider" class="com.armedia.acm.services.notification.service.provider.AcmUserTemplateModelProvider">
        <property name="userDao" ref="userJpaDao"/>
    </bean>
    
    <bean id="documentLinkedTemplateModelProvider" class="com.armedia.acm.services.notification.service.provider.DocumentLinkedTemplateModelProvider" scope="refresh">
        <aop:scoped-proxy/>
        <property name="authenticationTokenService" ref="authenticationTokenService"/>
        <property name="applicationConfig" ref="applicationProperties"/>
    </bean>

    <bean id="billingTemplateModelProvider" class="com.armedia.acm.services.notification.service.provider.BillingTemplateModelProvider" scope="refresh">
        <aop:scoped-proxy/>
        <property name="authenticationTokenService" ref="authenticationTokenService"/>
        <property name="auditPropertyEntityAdapter" ref="auditPropertyEntityAdapter"/>
        <property name="applicationConfig" ref="applicationProperties"/>
    </bean>

    <bean id="forgotUserNameTemplateModelProvider"
          class="com.armedia.acm.services.notification.service.provider.ForgotUsernameTemplateModelProvider">
        <property name="userDao" ref="userJpaDao"/>
    </bean>

    <bean id="notificationTemplateModelProvider"
          class="com.armedia.acm.services.notification.service.provider.NotificationTemplateModelProvider">
        <property name="notificationUtils" ref="notificationUtils"/>
        <property name="notificationConfig" ref="notificationConfig"/>
    </bean>

    <bean id="notificationGroupTemplateModelProvider"
          class="com.armedia.acm.services.notification.service.provider.NotificationGroupTemplateModelProvider">
        <property name="dataService" ref="acmDataService"/>
        <property name="userInfoHelper" ref="userInfoHelper"/>
    </bean>

    <bean id="dueDateReminderModelProvider" class="com.armedia.acm.services.notification.service.provider.DueDateReminderModelProvider">
    </bean>

    <bean id="requestDownloadedModelProvider" class="com.armedia.acm.services.notification.service.provider.RequestDownloadedModelProvider">
    </bean>

    <bean id="acmEntityTemplateNoUserPrefixModelProvider"
          class="com.armedia.acm.services.notification.service.provider.AcmEntityTemplateNoUserPrefixModelProvider">
        <property name="dataService" ref="acmDataService"/>
        <property name="userInfoHelper" ref="userInfoHelper"/>
        <property name="objectTitleConfigurationService" ref="objectTitleConfigurationService"/>
        <property name="userDao" ref="userJpaDao"/>
    </bean>


    <bean id="notificationSendExecutor" class="com.armedia.acm.services.notification.service.SendExecutor">
        <property name="springContextHolder" ref="acmContextHolder"/>
        <property name="templateConfigurationManager" ref="templateConfigurationManager"/>
        <property name="notificationSenderFactory" ref="notificationSenderFactory"/>
    </bean>

    <bean id="acmNotificationPlugin" class="com.armedia.acm.pluginmanager.model.AcmPlugin">
        <property name="pluginName" value="Save Notification Service Plugin"/>
        <property name="configurationPropertyService" ref="configurationPropertyService"/>
    </bean>

    <!-- Senders Definition -->

    <bean id="baseNotificationSender" class="com.armedia.acm.services.notification.service.NotificationSender" abstract="true">
        <property name="auditPropertyEntityAdapter" ref="auditPropertyEntityAdapter"/>
        <property name="notificationUtils" ref="notificationUtils"/>
        <property name="notificationTemplate" value="file:#{notificationConfig.emailTemplatePath}"/>
        <property name="userDao" ref="userJpaDao"/>
        <property name="dataService" ref="acmDataService"/>
        <property name="templatingEngine" ref="templatingEngine"/>
        <property name="templateService" ref="filesystemTemplateConfigurationService"/>
        <property name="notificationConfig" ref="notificationConfig"/>
        <property name="templateConfigurationManager" ref="templateConfigurationManager"/>
    </bean>

    <bean id="smtpNotificationSender" class="com.armedia.acm.services.notification.service.SmtpNotificationSender"
          parent="baseNotificationSender">
        <property name="emailSenderService" ref="smtpService"/>
    </bean>

    <bean id="microsoftExchangeNotificationSender" class="com.armedia.acm.services.notification.service.MicrosoftExchangeNotificationSender"
          parent="baseNotificationSender">
        <property name="emailSenderService" ref="outlookService"/>
    </bean>

    <bean id="notificationSenderFactory" class="com.armedia.acm.services.notification.service.NotificationSenderFactory">
        <property name="notificationSenderMap">
            <map>
                <entry key="smtp" value-ref="smtpNotificationSender"/>
                <entry key="outlook" value-ref="microsoftExchangeNotificationSender"/>
            </map>
        </property>
        <property name="emailSenderConfig" ref="emailSenderConfig"/>
    </bean>

    <bean id="notificationSender" factory-bean="notificationSenderFactory" factory-method="getNotificationSender"/>

    <bean id="notificationUtils" class="com.armedia.acm.services.notification.service.NotificationUtils">
        <property name="acmAppConfiguration" ref="acmApplication"/>
        <property name="acmDataService" ref="acmDataService"/>
        <property name="userDao" ref="userJpaDao"/>
        <property name="groupDao" ref="groupDao"/>
        <property name="portalConfig" ref="arkcasePortalConfig"/>
    </bean>

    <bean id="notificationFormatter" class="com.armedia.acm.services.notification.service.NotificationFormatter">
        <property name="translationService" ref="translationService"/>
        <property name="objectLabelConfig" ref="objectLabelConfig" />
    </bean>

    <bean id="notificationConfig" class="com.armedia.acm.services.notification.model.NotificationConfig" scope="refresh">
        <aop:scoped-proxy/>
    </bean>

    <bean id="onForgotPassword" class="com.armedia.acm.services.notification.service.OnForgotPassword">
        <property name="resetPasswordService" ref="resetPassword"/>
    </bean>

    <bean id="onSetPassword" class="com.armedia.acm.services.notification.service.OnSetPasswordEmail">
        <property name="resetPasswordService" ref="resetPassword"/>
    </bean>

    <bean id="resetPassword" class="com.armedia.acm.services.notification.service.ResetPasswordService">
        <property name="userDao" ref="userJpaDao"/>
        <property name="acmSpringActiveProfile" ref="acmSpringActiveProfile"/>
        <property name="notificationService" ref="notificationService"/>
        <property name="auditPropertyEntityAdapter" ref="auditPropertyEntityAdapter"/>
        <property name="templateManager" ref="correspondenceTemplateManager"/>
    </bean>

    <bean id="onForgotUsername" class="com.armedia.acm.services.notification.service.OnForgotUsername">
        <property name="acmSpringActiveProfile" ref="acmSpringActiveProfile"/>
        <property name="notificationService" ref="notificationService"/>
        <property name="auditPropertyEntityAdapter" ref="auditPropertyEntityAdapter"/>
        <property name="templateManager" ref="correspondenceTemplateManager"/>
    </bean>

    <bean id="onLoginCheckPasswordExpiration" class="com.armedia.acm.services.notification.service.OnLoginCheckPasswordExpiration">
        <property name="resetPasswordService" ref="resetPassword"/>
        <property name="userDao" ref="userJpaDao"/>
    </bean>

    <bean id="acmEmailMentionsService" class="com.armedia.acm.services.notification.service.AcmEmailMentionsService">
        <property name="acmAppConfiguration" ref="acmApplication"/>
        <property name="applicationConfig" ref="applicationProperties"/>
        <property name="notificationService" ref="notificationService"/>
        <property name="templateManager" ref="correspondenceTemplateManager"/>
    </bean>

    <bean id="userInfoHelper" class="com.armedia.acm.services.notification.helper.UserInfoHelper">
        <property name="userDao" ref="userJpaDao"/>
        <property name="contextHolder" ref="acmContextHolder"/>
        <property name="acmGroupDao" ref="groupDao"/>
    </bean>

    <bean id="assignmentNotifier" class="com.armedia.acm.services.notification.service.AssignmentNotifier">
        <property name="notificationService" ref="notificationService"/>
        <property name="templateManager" ref="correspondenceTemplateManager"/>
    </bean>

    <bean id="calendarEventAddedNotifier" class="com.armedia.acm.services.notification.service.CalendarEventAddedNotifier">
        <property name="notificationService" ref="notificationService"/>
        <property name="notificationUtils" ref="notificationUtils"/>
        <property name="templateManager" ref="correspondenceTemplateManager"/>
    </bean>
</beans>
