This is an automated email from the ASF dual-hosted git repository. myrle pushed a commit to branch develop in repository https://gitbox.apache.org/repos/asf/fineract-cn-notifications.git
commit 71d5c3ed920006f6557279ec02054f8100b3f761 Author: Ebenezer Graham <egraha...@alustudent.com> AuthorDate: Sun Jun 10 18:46:58 2018 +0400 improved the repositories and entities for the configurations --- .../notification/api/v1/domain/Notification.class | Bin 1782 -> 1820 bytes .../cn/notification/api/v1/domain/SampleTest.class | Bin 3710 -> 0 bytes .../api/v1/domain/EmailConfiguration.java | 162 +++++++++++++++++++++ .../api/v1/domain/SMSConfiguration.java | 122 ++++++++++++++++ .../cn/notification/SuiteTestEnvironment.class | Bin 1528 -> 0 bytes .../TestSample$TestConfiguration.class | Bin 1398 -> 0 bytes .../fineract/cn/notification/TestSample.class | Bin 5890 -> 0 bytes .../fineract/cn/notification/TestSuite.class | Bin 695 -> 0 bytes .../listener/MigrationEventListener.class | Bin 1482 -> 0 bytes .../listener/SampleEventListener.class | Bin 1473 -> 0 bytes service/out/production/resources/application.yml | 18 --- .../internal/command/handler/SampleAggregate.java | 2 + .../internal/mapper/EmailConfigurationMapper.java | 49 +++++++ .../internal/mapper/SMSConfigurationMapper.java | 47 ++++++ .../service/internal/mapper/SampleMapper.java | 1 + .../repository/EmailGatewayConfiguration.java | 10 ++ ...ewayConfiguration.java => SampleJpaEntity.java} | 68 ++------- .../SampleJpaEntityRepository.java} | 32 +--- .../service/internal/service/EmailSender.java | 18 ++- .../service/internal/service/SampleService.java | 1 + .../service/listener/AccountingEventListener.java | 14 +- .../service/listener/ChequeEventListener.java | 7 +- .../service/listener/CustomerEventListener.java | 1 - .../service/listener/DepositEventListener.java | 7 +- .../service/listener/PortfolioEventListener.java | 3 - 25 files changed, 440 insertions(+), 122 deletions(-) diff --git a/api/out/production/classes/org/apache/fineract/cn/notification/api/v1/domain/Notification.class b/api/out/production/classes/org/apache/fineract/cn/notification/api/v1/domain/Notification.class index 16602d7..afe7f46 100644 Binary files a/api/out/production/classes/org/apache/fineract/cn/notification/api/v1/domain/Notification.class and b/api/out/production/classes/org/apache/fineract/cn/notification/api/v1/domain/Notification.class differ diff --git a/api/out/test/classes/org/apache/fineract/cn/notification/api/v1/domain/SampleTest.class b/api/out/test/classes/org/apache/fineract/cn/notification/api/v1/domain/SampleTest.class deleted file mode 100644 index 8013bfa..0000000 Binary files a/api/out/test/classes/org/apache/fineract/cn/notification/api/v1/domain/SampleTest.class and /dev/null differ diff --git a/api/src/main/java/org/apache/fineract/cn/notification/api/v1/domain/EmailConfiguration.java b/api/src/main/java/org/apache/fineract/cn/notification/api/v1/domain/EmailConfiguration.java new file mode 100644 index 0000000..24aa0dc --- /dev/null +++ b/api/src/main/java/org/apache/fineract/cn/notification/api/v1/domain/EmailConfiguration.java @@ -0,0 +1,162 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.cn.notification.api.v1.domain; + +import org.apache.fineract.cn.lang.validation.constraints.ValidIdentifier; +import org.hibernate.validator.constraints.Length; + +import java.util.Objects; + +@SuppressWarnings({"WeakerAccess", "unused"}) +public class EmailConfiguration { + @ValidIdentifier + private String identifier; + @Length(max = 512) + private String payload; + @Length(max = 512) + private String host; + @Length(max = 512) + private String port; + @Length(max = 512) + private String username; + @Length(max = 512) + private String app_id; + @Length(max = 512) + private String smtp_auth; + @Length(max = 512) + private String start_tls; + @Length(max = 512) + private String option; + + public EmailConfiguration(){ + super(); + } + + public static EmailConfiguration create (String identifier, String payload, + String host, String port, + String username, String app_id, + String smtp_auth, String start_tls, + String option) { + EmailConfiguration emailConfiguration = new EmailConfiguration(); + emailConfiguration.setIdentifier(identifier); + emailConfiguration.setPayload(payload); + emailConfiguration.setHost(host); + emailConfiguration.setPort(port); + emailConfiguration.setUsername(username); + emailConfiguration.setApp_id(app_id); + emailConfiguration.setSmtp_auth(smtp_auth); + emailConfiguration.setStart_tls(start_tls); + emailConfiguration.setOption(option); + return emailConfiguration; + } + + public String getIdentifier() { + return identifier; + } + + public void setIdentifier(String identifier) { + this.identifier = identifier; + } + + public String getPayload() { + return payload; + } + + public void setPayload(String payload) { + this.payload = payload; + } + + public String getHost() { + return host; + } + + public void setHost(String host) { + this.host = host; + } + + public String getPort() { + return port; + } + + public void setPort(String port) { + this.port = port; + } + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getApp_id() { + return app_id; + } + + public void setApp_id(String app_id) { + this.app_id = app_id; + } + + public String getSmtp_auth() { + return smtp_auth; + } + + public void setSmtp_auth(String smtp_auth) { + this.smtp_auth = smtp_auth; + } + + public String getStart_tls() { + return start_tls; + } + + public void setStart_tls(String start_tls) { + this.start_tls = start_tls; + } + + public String getOption() { + return option; + } + + public void setOption(String option) { + this.option = option; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + EmailConfiguration that = (EmailConfiguration) o; + return Objects.equals(identifier, that.identifier) && + Objects.equals(payload, that.payload) && + Objects.equals(host, that.host) && + Objects.equals(port, that.port) && + Objects.equals(username, that.username) && + Objects.equals(app_id, that.app_id) && + Objects.equals(smtp_auth, that.smtp_auth) && + Objects.equals(start_tls, that.start_tls) && + Objects.equals(option, that.option); + } + + @Override + public int hashCode() { + return Objects.hash(identifier, payload, host, port, username, + app_id, smtp_auth, start_tls, option); + } +} diff --git a/api/src/main/java/org/apache/fineract/cn/notification/api/v1/domain/SMSConfiguration.java b/api/src/main/java/org/apache/fineract/cn/notification/api/v1/domain/SMSConfiguration.java new file mode 100644 index 0000000..cef7f57 --- /dev/null +++ b/api/src/main/java/org/apache/fineract/cn/notification/api/v1/domain/SMSConfiguration.java @@ -0,0 +1,122 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.cn.notification.api.v1.domain; + +import org.apache.fineract.cn.lang.validation.constraints.ValidIdentifier; +import org.hibernate.validator.constraints.Length; + +import java.util.Objects; + +@SuppressWarnings({"WeakerAccess", "unused"}) +public class SMSConfiguration { + @ValidIdentifier + private String identifier; + @Length(max = 512) + private String payload; + @Length(max = 512) + private String organisation; + @Length(max = 512) + private String auth_token; + @Length(max = 512) + private String accountid; + @Length(max = 256) + private String option; + + public SMSConfiguration() { + super(); + } + + public static SMSConfiguration create(String identifier, String payload, String organisation, String auth_token, String accountid, String option) { + SMSConfiguration smsconfiguration = new SMSConfiguration(); + smsconfiguration.setIdentifier(identifier); + smsconfiguration.setPayload(payload); + smsconfiguration.setOrganisation(organisation); + smsconfiguration.setAuth_token(auth_token); + smsconfiguration.setAccountid(accountid); + smsconfiguration.setOption(option); + return smsconfiguration; + } + + public String getIdentifier() { + return identifier; + } + + public void setIdentifier(String identifier) { + this.identifier = identifier; + } + + public String getPayload() { + return payload; + } + + public void setPayload(String payload) { + this.payload = payload; + } + + public String getOrganisation() { + return organisation; + } + + public void setOrganisation(String organisation) { + this.organisation = organisation; + } + + public String getAuth_token() { + return auth_token; + } + + public void setAuth_token(String auth_token) { + this.auth_token = auth_token; + } + + public String getAccountid() { + return accountid; + } + + public void setAccountid(String accountid) { + this.accountid = accountid; + } + + public String getOption() { + return option; + } + + public void setOption(String option) { + this.option = option; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + SMSConfiguration that = (SMSConfiguration) o; + return Objects.equals(identifier, that.identifier) && + Objects.equals(payload, that.payload) && + Objects.equals(organisation, that.organisation) && + Objects.equals(auth_token, that.auth_token) && + Objects.equals(accountid, that.accountid) && + Objects.equals(option, that.option); + } + + @Override + public int hashCode() { + + return Objects.hash(identifier, payload, organisation, auth_token, accountid, option); + } +} diff --git a/component-test/out/production/classes/org/apache/fineract/cn/notification/SuiteTestEnvironment.class b/component-test/out/production/classes/org/apache/fineract/cn/notification/SuiteTestEnvironment.class deleted file mode 100644 index d098f6e..0000000 Binary files a/component-test/out/production/classes/org/apache/fineract/cn/notification/SuiteTestEnvironment.class and /dev/null differ diff --git a/component-test/out/production/classes/org/apache/fineract/cn/notification/TestSample$TestConfiguration.class b/component-test/out/production/classes/org/apache/fineract/cn/notification/TestSample$TestConfiguration.class deleted file mode 100644 index b125463..0000000 Binary files a/component-test/out/production/classes/org/apache/fineract/cn/notification/TestSample$TestConfiguration.class and /dev/null differ diff --git a/component-test/out/production/classes/org/apache/fineract/cn/notification/TestSample.class b/component-test/out/production/classes/org/apache/fineract/cn/notification/TestSample.class deleted file mode 100644 index 5962f3a..0000000 Binary files a/component-test/out/production/classes/org/apache/fineract/cn/notification/TestSample.class and /dev/null differ diff --git a/component-test/out/production/classes/org/apache/fineract/cn/notification/TestSuite.class b/component-test/out/production/classes/org/apache/fineract/cn/notification/TestSuite.class deleted file mode 100644 index f083d51..0000000 Binary files a/component-test/out/production/classes/org/apache/fineract/cn/notification/TestSuite.class and /dev/null differ diff --git a/component-test/out/production/classes/org/apache/fineract/cn/notification/listener/MigrationEventListener.class b/component-test/out/production/classes/org/apache/fineract/cn/notification/listener/MigrationEventListener.class deleted file mode 100644 index 6a70e37..0000000 Binary files a/component-test/out/production/classes/org/apache/fineract/cn/notification/listener/MigrationEventListener.class and /dev/null differ diff --git a/component-test/out/production/classes/org/apache/fineract/cn/notification/listener/SampleEventListener.class b/component-test/out/production/classes/org/apache/fineract/cn/notification/listener/SampleEventListener.class deleted file mode 100644 index 917edfc..0000000 Binary files a/component-test/out/production/classes/org/apache/fineract/cn/notification/listener/SampleEventListener.class and /dev/null differ diff --git a/service/out/production/resources/application.yml b/service/out/production/resources/application.yml index 17d03bc..37acaaf 100644 --- a/service/out/production/resources/application.yml +++ b/service/out/production/resources/application.yml @@ -23,17 +23,6 @@ spring: enabled: false config: enabled: false - mail: - host: smtp.gmail.com - port: 587 - username: ebenezergraha...@gmail.com - password: fdzmzbhbmtkafzvq - properties: - mail: - smtpauth: true - smtp: - starttls: - enable: true eureka: client: @@ -79,13 +68,6 @@ async: flyway: enabled: false -mfi: - senderNumber: +15109441898 - -smssender: - accountSID: AC1fde2c6f26f367b93231c5fdb944c908 - authtoken: bc9a53e41745b8471e0ecafc859d86aa - fineract: customer: accountcreated: diff --git a/service/src/main/java/org/apache/fineract/cn/notification/service/internal/command/handler/SampleAggregate.java b/service/src/main/java/org/apache/fineract/cn/notification/service/internal/command/handler/SampleAggregate.java index cf09aca..a21589d 100644 --- a/service/src/main/java/org/apache/fineract/cn/notification/service/internal/command/handler/SampleAggregate.java +++ b/service/src/main/java/org/apache/fineract/cn/notification/service/internal/command/handler/SampleAggregate.java @@ -24,6 +24,8 @@ import org.apache.fineract.cn.command.annotation.Aggregate; import org.apache.fineract.cn.command.annotation.CommandHandler; import org.apache.fineract.cn.command.annotation.CommandLogLevel; import org.apache.fineract.cn.command.annotation.EventEmitter; +import org.apache.fineract.cn.notification.service.internal.repository.SampleJpaEntity; +import org.apache.fineract.cn.notification.service.internal.repository.SampleJpaEntityRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; diff --git a/service/src/main/java/org/apache/fineract/cn/notification/service/internal/mapper/EmailConfigurationMapper.java b/service/src/main/java/org/apache/fineract/cn/notification/service/internal/mapper/EmailConfigurationMapper.java new file mode 100644 index 0000000..10e4a86 --- /dev/null +++ b/service/src/main/java/org/apache/fineract/cn/notification/service/internal/mapper/EmailConfigurationMapper.java @@ -0,0 +1,49 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.cn.notification.service.internal.mapper; + +import org.apache.fineract.cn.notification.api.v1.domain.EmailConfiguration; +import org.apache.fineract.cn.notification.service.internal.repository.EmailGatewayConfiguration; + +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +public class EmailConfigurationMapper { + + private EmailConfigurationMapper() { + super(); + } + + public static EmailConfiguration map(final EmailGatewayConfiguration emailGatewayConfiguration) { + final EmailConfiguration emailConfiguration = new EmailConfiguration(); + emailConfiguration.setIdentifier(emailGatewayConfiguration.getIdentifier()); + emailConfiguration.setHost(emailGatewayConfiguration.getHost()); + emailConfiguration.setPort(emailGatewayConfiguration.getPort()); + emailConfiguration.setUsername(emailGatewayConfiguration.getUsername()); + emailConfiguration.setApp_id(emailGatewayConfiguration.getApp_id()); + return emailConfiguration; + } + +// public static List<EmailGatewayConfiguration> map(final List<EmailGatewayConfiguration> emailGatewayConfiguration) { +// final ArrayList<EmailGatewayConfiguration> entities = new ArrayList<>(emailGatewayConfiguration.size()); +// entities.addAll(emailGatewayConfiguration.stream().map(EmailGatewayConfiguration::map).collect(Collectors.toList())); +// return entities; +// } +} diff --git a/service/src/main/java/org/apache/fineract/cn/notification/service/internal/mapper/SMSConfigurationMapper.java b/service/src/main/java/org/apache/fineract/cn/notification/service/internal/mapper/SMSConfigurationMapper.java new file mode 100644 index 0000000..43e6c1c --- /dev/null +++ b/service/src/main/java/org/apache/fineract/cn/notification/service/internal/mapper/SMSConfigurationMapper.java @@ -0,0 +1,47 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.cn.notification.service.internal.mapper; + +import org.apache.fineract.cn.notification.api.v1.domain.SMSConfiguration; +import org.apache.fineract.cn.notification.service.internal.repository.SMSGatewayConfiguration; + +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +public class SMSConfigurationMapper { + + private SMSConfigurationMapper() { + super(); + } + + public static SMSConfiguration map(final SMSGatewayConfiguration smsGatewayConfiguration) { + final SMSConfiguration smsConfiguration = new SMSConfiguration(); + smsConfiguration.setIdentifier(smsGatewayConfiguration.getIdentifier()); + smsConfiguration.setAccountid(smsGatewayConfiguration.getAccountid()); + smsConfiguration.setAuth_token(smsGatewayConfiguration.getAuth_token()); + return smsConfiguration; + } + +// public static List<SMSGatewayConfiguration> map(final List<SMSGatewayConfiguration> smsGatewayConfiguration) { +// final ArrayList<SMSGatewayConfiguration> entities = new ArrayList<>(smsGatewayConfiguration.size()); +// entities.addAll(smsGatewayConfiguration.stream().map(SMSConfigurationMapper::map).collect(Collectors.toList())); +// return entities; +// } +} diff --git a/service/src/main/java/org/apache/fineract/cn/notification/service/internal/mapper/SampleMapper.java b/service/src/main/java/org/apache/fineract/cn/notification/service/internal/mapper/SampleMapper.java index 973adee..a56b7aa 100644 --- a/service/src/main/java/org/apache/fineract/cn/notification/service/internal/mapper/SampleMapper.java +++ b/service/src/main/java/org/apache/fineract/cn/notification/service/internal/mapper/SampleMapper.java @@ -19,6 +19,7 @@ package org.apache.fineract.cn.notification.service.internal.mapper; import org.apache.fineract.cn.notification.api.v1.domain.Sample; +import org.apache.fineract.cn.notification.service.internal.repository.SampleJpaEntity; import java.util.ArrayList; import java.util.List; diff --git a/service/src/main/java/org/apache/fineract/cn/notification/service/internal/repository/EmailGatewayConfiguration.java b/service/src/main/java/org/apache/fineract/cn/notification/service/internal/repository/EmailGatewayConfiguration.java index e0c6d89..c344708 100644 --- a/service/src/main/java/org/apache/fineract/cn/notification/service/internal/repository/EmailGatewayConfiguration.java +++ b/service/src/main/java/org/apache/fineract/cn/notification/service/internal/repository/EmailGatewayConfiguration.java @@ -43,6 +43,8 @@ public class EmailGatewayConfiguration { private String smtp_auth; @Column(name = "start_tls") private String start_tls; + @Column(name = "option") + private String option; public EmailGatewayConfiguration() { super(); @@ -111,4 +113,12 @@ public class EmailGatewayConfiguration { public void setStart_tls(String start_tls) { this.start_tls = start_tls; } + + public String getOption() { + return option; + } + + public void setOption(String option) { + this.option = option; + } } diff --git a/service/src/main/java/org/apache/fineract/cn/notification/service/internal/repository/EmailGatewayConfiguration.java b/service/src/main/java/org/apache/fineract/cn/notification/service/internal/repository/SampleJpaEntity.java similarity index 53% copy from service/src/main/java/org/apache/fineract/cn/notification/service/internal/repository/EmailGatewayConfiguration.java copy to service/src/main/java/org/apache/fineract/cn/notification/service/internal/repository/SampleJpaEntity.java index e0c6d89..f740d85 100644 --- a/service/src/main/java/org/apache/fineract/cn/notification/service/internal/repository/EmailGatewayConfiguration.java +++ b/service/src/main/java/org/apache/fineract/cn/notification/service/internal/repository/SampleJpaEntity.java @@ -22,8 +22,8 @@ import javax.persistence.*; @SuppressWarnings("unused") @Entity -@Table(name = "email_gateway_configuration") -public class EmailGatewayConfiguration { +@Table(name = "template_samples") +public class SampleJpaEntity { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @@ -31,20 +31,10 @@ public class EmailGatewayConfiguration { private Long id; @Column(name = "identifier") private String identifier; - @Column(name = "host") - private String host; - @Column(name = "port") - private String port; - @Column(name = "username") - private String username; - @Column(name = "app_id") - private String app_id; - @Column(name = "smtp_auth") - private String smtp_auth; - @Column(name = "start_tls") - private String start_tls; + @Column(name = "payload") + private String payload; - public EmailGatewayConfiguration() { + public SampleJpaEntity() { super(); } @@ -64,51 +54,11 @@ public class EmailGatewayConfiguration { this.identifier = identifier; } - public String getHost() { - return host; + public String getPayload() { + return payload; } - public void setHost(String host) { - this.host = host; - } - - public String getPort() { - return port; - } - - public void setPort(String port) { - this.port = port; - } - - public String getUsername() { - return username; - } - - public void setUsername(String username) { - this.username = username; - } - - public String getApp_id() { - return app_id; - } - - public void setApp_id(String app_id) { - this.app_id = app_id; - } - - public String getSmtp_auth() { - return smtp_auth; - } - - public void setSmtp_auth(String smtp_auth) { - this.smtp_auth = smtp_auth; - } - - public String getStart_tls() { - return start_tls; - } - - public void setStart_tls(String start_tls) { - this.start_tls = start_tls; + public void setPayload(String payload) { + this.payload = payload; } } diff --git a/service/src/main/java/org/apache/fineract/cn/notification/service/internal/service/EmailSender.java b/service/src/main/java/org/apache/fineract/cn/notification/service/internal/repository/SampleJpaEntityRepository.java similarity index 51% copy from service/src/main/java/org/apache/fineract/cn/notification/service/internal/service/EmailSender.java copy to service/src/main/java/org/apache/fineract/cn/notification/service/internal/repository/SampleJpaEntityRepository.java index e9cc516..b4d8abd 100644 --- a/service/src/main/java/org/apache/fineract/cn/notification/service/internal/service/EmailSender.java +++ b/service/src/main/java/org/apache/fineract/cn/notification/service/internal/repository/SampleJpaEntityRepository.java @@ -16,29 +16,13 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.fineract.cn.notification.service.internal.service; +package org.apache.fineract.cn.notification.service.internal.repository; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.context.annotation.Bean; -import org.springframework.mail.SimpleMailMessage; -import org.springframework.mail.javamail.JavaMailSender; -import org.springframework.stereotype.Service; +import java.util.Optional; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; - -@Service -public class EmailSender { - - @Autowired - @Qualifier("gmail") - private JavaMailSender sender; - - public void sendEmail(String to, String subject, String message) { - SimpleMailMessage mail = new SimpleMailMessage(); - mail.setTo(to); - mail.setSubject(subject); - mail.setText(message); - sender.send(mail); - } - -} \ No newline at end of file +@Repository +public interface SampleJpaEntityRepository extends JpaRepository<SampleJpaEntity, Long> { + Optional<SampleJpaEntity> findByIdentifier(String identifier); +} diff --git a/service/src/main/java/org/apache/fineract/cn/notification/service/internal/service/EmailSender.java b/service/src/main/java/org/apache/fineract/cn/notification/service/internal/service/EmailSender.java index e9cc516..bebb3c9 100644 --- a/service/src/main/java/org/apache/fineract/cn/notification/service/internal/service/EmailSender.java +++ b/service/src/main/java/org/apache/fineract/cn/notification/service/internal/service/EmailSender.java @@ -18,13 +18,17 @@ */ package org.apache.fineract.cn.notification.service.internal.service; + +import org.apache.fineract.cn.notification.service.internal.mapper.EmailConfigurationMapper; +import org.apache.fineract.cn.notification.service.internal.repository.EmailGatewayConfiguration; +import org.apache.fineract.cn.notification.service.internal.repository.EmailGatewayConfigurationRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.context.annotation.Bean; import org.springframework.mail.SimpleMailMessage; import org.springframework.mail.javamail.JavaMailSender; import org.springframework.stereotype.Service; +import java.util.Optional; @Service public class EmailSender { @@ -33,6 +37,18 @@ public class EmailSender { @Qualifier("gmail") private JavaMailSender sender; + private final EmailGatewayConfigurationRepository emailGatewayConfigurationRepository; + + @Autowired + public EmailSender(final EmailGatewayConfigurationRepository emailGatewayConfigurationRepository) { + super(); + this.emailGatewayConfigurationRepository = emailGatewayConfigurationRepository; + } + +// public Optional<EmailGatewayConfiguration> findByIdentifier(final String identifier) { +// return this.emailGatewayConfigurationRepository.findByIdentifier(identifier).map(EmailGatewayConfiguration::map); +// } + public void sendEmail(String to, String subject, String message) { SimpleMailMessage mail = new SimpleMailMessage(); mail.setTo(to); diff --git a/service/src/main/java/org/apache/fineract/cn/notification/service/internal/service/SampleService.java b/service/src/main/java/org/apache/fineract/cn/notification/service/internal/service/SampleService.java index bc2d5a8..a0e4f71 100644 --- a/service/src/main/java/org/apache/fineract/cn/notification/service/internal/service/SampleService.java +++ b/service/src/main/java/org/apache/fineract/cn/notification/service/internal/service/SampleService.java @@ -20,6 +20,7 @@ package org.apache.fineract.cn.notification.service.internal.service; import org.apache.fineract.cn.notification.api.v1.domain.Sample; import org.apache.fineract.cn.notification.service.internal.mapper.SampleMapper; +import org.apache.fineract.cn.notification.service.internal.repository.SampleJpaEntityRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; diff --git a/service/src/main/java/org/apache/fineract/cn/notification/service/listener/AccountingEventListener.java b/service/src/main/java/org/apache/fineract/cn/notification/service/listener/AccountingEventListener.java index a061b1a..9266b89 100644 --- a/service/src/main/java/org/apache/fineract/cn/notification/service/listener/AccountingEventListener.java +++ b/service/src/main/java/org/apache/fineract/cn/notification/service/listener/AccountingEventListener.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ - +/* package org.apache.fineract.cn.notification.service.listener; import org.apache.fineract.cn.lang.config.TenantHeaderFilter; @@ -34,13 +34,6 @@ @Component public class AccountingEventListener { - AccountService accountService; - - @Autowired - SMSSender smsSender; - - @Autowired - EmailSender emailSender; @Autowired public AccountingEventListener( final AccountService accountingManager) { @@ -60,7 +53,7 @@ public class AccountingEventListener { emailSender.sendEmail(receiver,"Hello", "You account has been created"); } - /* + @JmsListener( destination = EventConstants.DESTINATION, selector = EventConstants.SELECTOR_PUT_ACCOUNT, @@ -126,5 +119,6 @@ public class AccountingEventListener { this.logger.debug("Account deleted."); this.eventRecorder.event(tenant, EventConstants.DELETE_ACCOUNT, payload, String.class); } - */ + } + */ \ No newline at end of file diff --git a/service/src/main/java/org/apache/fineract/cn/notification/service/listener/ChequeEventListener.java b/service/src/main/java/org/apache/fineract/cn/notification/service/listener/ChequeEventListener.java index 2c6c2cf..97dd5e2 100644 --- a/service/src/main/java/org/apache/fineract/cn/notification/service/listener/ChequeEventListener.java +++ b/service/src/main/java/org/apache/fineract/cn/notification/service/listener/ChequeEventListener.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ - +/* package org.apache.fineract.cn.notification.service.listener; import org.apache.fineract.cn.cheque.AbstractChequeTest; @@ -47,7 +47,7 @@ public class ChequeEventListener { final String payload) { this.logger.debug("Cheques issued."); } -/* + @JmsListener( destination = EventConstants.DESTINATION, selector = EventConstants.SELECTOR_CHEQUE_TRANSACTION, @@ -80,5 +80,6 @@ public class ChequeEventListener { this.logger.debug("Cheque transaction canceled."); this.eventRecorder.event(tenant, EventConstants.CHEQUE_TRANSACTION_CANCELED, payload, String.class); } -*/ + } +*/ \ No newline at end of file diff --git a/service/src/main/java/org/apache/fineract/cn/notification/service/listener/CustomerEventListener.java b/service/src/main/java/org/apache/fineract/cn/notification/service/listener/CustomerEventListener.java index a28d83a..73d3d1d 100644 --- a/service/src/main/java/org/apache/fineract/cn/notification/service/listener/CustomerEventListener.java +++ b/service/src/main/java/org/apache/fineract/cn/notification/service/listener/CustomerEventListener.java @@ -24,7 +24,6 @@ import org.apache.fineract.cn.lang.config.TenantHeaderFilter; import org.apache.fineract.cn.customer.api.v1.client.CustomerManager; import org.apache.fineract.cn.customer.api.v1.domain.ContactDetail; import org.apache.fineract.cn.customer.api.v1.domain.Customer; -import org.apache.fineract.cn.notification.api.v1.events.NotificationEventConstants; import org.apache.fineract.cn.notification.service.internal.service.EmailSender; import org.apache.fineract.cn.notification.service.internal.service.SMSSender; import org.springframework.beans.factory.annotation.Autowired; diff --git a/service/src/main/java/org/apache/fineract/cn/notification/service/listener/DepositEventListener.java b/service/src/main/java/org/apache/fineract/cn/notification/service/listener/DepositEventListener.java index bcde220..fa66ace 100644 --- a/service/src/main/java/org/apache/fineract/cn/notification/service/listener/DepositEventListener.java +++ b/service/src/main/java/org/apache/fineract/cn/notification/service/listener/DepositEventListener.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ - +/* package org.apache.fineract.cn.deposit.listener; import org.apache.fineract.cn.deposit.api.v1.EventConstants; @@ -45,7 +45,7 @@ public class DepositEventListener { public void onAccrual(@Header(TenantHeaderFilter.TENANT_HEADER) final String tenant, final String payload) { } -/* + @JmsListener( destination = EventConstants.DESTINATION, selector = EventConstants.SELECTOR_DIVIDEND_DISTRIBUTION, @@ -56,5 +56,6 @@ public class DepositEventListener { this.logger.debug("Dividend distributed for product {}.", payload); this.eventRecorder.event(tenant, EventConstants.DIVIDEND_DISTRIBUTION, payload, String.class); } -*/ + } +*/ diff --git a/service/src/main/java/org/apache/fineract/cn/notification/service/listener/PortfolioEventListener.java b/service/src/main/java/org/apache/fineract/cn/notification/service/listener/PortfolioEventListener.java index 88109a7..afbe490 100644 --- a/service/src/main/java/org/apache/fineract/cn/notification/service/listener/PortfolioEventListener.java +++ b/service/src/main/java/org/apache/fineract/cn/notification/service/listener/PortfolioEventListener.java @@ -17,14 +17,11 @@ package org.apache.fineract.cn.notification.service.listener;/* * under the License. */ -import org.apache.fineract.cn.individuallending.api.v1.events.IndividualLoanCommandEvent; import org.apache.fineract.cn.individuallending.api.v1.events.IndividualLoanEventConstants; import org.apache.fineract.cn.lang.config.TenantHeaderFilter; -import org.apache.fineract.cn.reporting.api.v1.domain.Header; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.jms.annotation.JmsListener; import org.springframework.stereotype.Component; -import org.apache.fineract.cn.group.api.v1.EventConstants; import org.apache.fineract.cn.portfolio.api.v1.client.PortfolioManager; @SuppressWarnings("unused")