FINERACT-1932: Add custom Configuration class for shareproduct services
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/service/ShareProductCommandsServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/service/ShareProductCommandsServiceImpl.java
index 52c6bf3..fcc54c4 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/service/ShareProductCommandsServiceImpl.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/service/ShareProductCommandsServiceImpl.java
@@ -19,24 +19,18 @@
package org.apache.fineract.portfolio.shareproducts.service;
import com.google.gson.JsonElement;
+import lombok.RequiredArgsConstructor;
import org.apache.fineract.infrastructure.core.api.JsonCommand;
import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
import org.apache.fineract.infrastructure.core.serialization.FromJsonHelper;
import org.apache.fineract.portfolio.products.service.ProductCommandsService;
import org.apache.fineract.portfolio.shareproducts.constants.ShareProductApiConstants;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-@Service(value = "SHAREPRODUCT_COMMANDSERVICE")
+@RequiredArgsConstructor
public class ShareProductCommandsServiceImpl implements ProductCommandsService {
private final FromJsonHelper fromApiJsonHelper;
- @Autowired
- public ShareProductCommandsServiceImpl(final FromJsonHelper fromApiJsonHelper) {
- this.fromApiJsonHelper = fromApiJsonHelper;
- }
-
public CommandProcessingResult postDividends(Long productId, JsonCommand jsonCommand) {
return null;
}
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/service/ShareProductDividendAssembler.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/service/ShareProductDividendAssembler.java
index 30625c2..57e444b 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/service/ShareProductDividendAssembler.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/service/ShareProductDividendAssembler.java
@@ -24,6 +24,7 @@
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
+import lombok.RequiredArgsConstructor;
import org.apache.fineract.infrastructure.core.service.DateUtils;
import org.apache.fineract.organisation.monetary.domain.MonetaryCurrency;
import org.apache.fineract.organisation.monetary.domain.Money;
@@ -36,22 +37,13 @@
import org.apache.fineract.portfolio.shareproducts.data.ShareProductData;
import org.apache.fineract.portfolio.shareproducts.domain.ShareProductDividendPayOutDetails;
import org.apache.fineract.portfolio.shareproducts.exception.ShareAccountsNotFoundException;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-@Component
+@RequiredArgsConstructor
public class ShareProductDividendAssembler {
private final ShareProductReadPlatformService shareProductReadPlatformService;
private final ShareAccountReadPlatformService shareAccountReadPlatformService;
- @Autowired
- public ShareProductDividendAssembler(final ShareProductReadPlatformService shareProductReadPlatformService,
- final ShareAccountReadPlatformService shareAccountReadPlatformService) {
- this.shareProductReadPlatformService = shareProductReadPlatformService;
- this.shareAccountReadPlatformService = shareAccountReadPlatformService;
- }
-
public ShareProductDividendPayOutDetails calculateDividends(final Long productId, final BigDecimal amount,
final LocalDate dividendPeriodStartDate, final LocalDate dividendPeriodEndDate) {
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/service/ShareProductDividendReadPlatformServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/service/ShareProductDividendReadPlatformServiceImpl.java
index 2c7fc77..2e8bc0b 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/service/ShareProductDividendReadPlatformServiceImpl.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/service/ShareProductDividendReadPlatformServiceImpl.java
@@ -25,6 +25,7 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
+import lombok.RequiredArgsConstructor;
import org.apache.fineract.infrastructure.core.data.EnumOptionData;
import org.apache.fineract.infrastructure.core.domain.JdbcSupport;
import org.apache.fineract.infrastructure.core.service.Page;
@@ -36,12 +37,10 @@
import org.apache.fineract.portfolio.shareaccounts.service.SharesEnumerations;
import org.apache.fineract.portfolio.shareproducts.data.ShareProductData;
import org.apache.fineract.portfolio.shareproducts.data.ShareProductDividendPayOutData;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
-import org.springframework.stereotype.Service;
-@Service
+@RequiredArgsConstructor
public class ShareProductDividendReadPlatformServiceImpl implements ShareProductDividendReadPlatformService {
private final JdbcTemplate jdbcTemplate;
@@ -49,15 +48,6 @@
private final PaginationHelper paginationHelper;
private final DatabaseSpecificSQLGenerator sqlGenerator;
- @Autowired
- public ShareProductDividendReadPlatformServiceImpl(final JdbcTemplate jdbcTemplate, final ColumnValidator columnValidator,
- DatabaseSpecificSQLGenerator sqlGenerator, PaginationHelper paginationHelper) {
- this.jdbcTemplate = jdbcTemplate;
- this.columnValidator = columnValidator;
- this.paginationHelper = paginationHelper;
- this.sqlGenerator = sqlGenerator;
- }
-
@Override
public Page<ShareProductDividendPayOutData> retriveAll(final Long productId, final Integer status,
final SearchParameters searchParameters) {
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/service/ShareProductDropdownReadPlatformServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/service/ShareProductDropdownReadPlatformServiceImpl.java
index e2800e9..620ea3a 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/service/ShareProductDropdownReadPlatformServiceImpl.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/service/ShareProductDropdownReadPlatformServiceImpl.java
@@ -21,12 +21,12 @@
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
+import lombok.NoArgsConstructor;
import org.apache.fineract.infrastructure.core.data.EnumOptionData;
import org.apache.fineract.portfolio.shareaccounts.service.SharesEnumerations;
import org.apache.fineract.portfolio.shareproducts.SharePeriodFrequencyType;
-import org.springframework.stereotype.Service;
-@Service
+@NoArgsConstructor
public class ShareProductDropdownReadPlatformServiceImpl implements ShareProductDropdownReadPlatformService {
@Override
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/service/ShareProductReadPlatformServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/service/ShareProductReadPlatformServiceImpl.java
index 2e2d5b9..7b3ac12 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/service/ShareProductReadPlatformServiceImpl.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/service/ShareProductReadPlatformServiceImpl.java
@@ -52,9 +52,7 @@
import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
-import org.springframework.stereotype.Service;
-@Service(value = "shareReadPlatformService")
@RequiredArgsConstructor
public class ShareProductReadPlatformServiceImpl implements ShareProductReadPlatformService {
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/service/ShareProductWritePlatformServiceJpaRepositoryImpl.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/service/ShareProductWritePlatformServiceJpaRepositoryImpl.java
index e22aed9..fa7e3ba 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/service/ShareProductWritePlatformServiceJpaRepositoryImpl.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/service/ShareProductWritePlatformServiceJpaRepositoryImpl.java
@@ -43,9 +43,7 @@
import org.apache.fineract.portfolio.shareproducts.serialization.ShareProductDataSerializer;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.orm.jpa.JpaSystemException;
-import org.springframework.stereotype.Service;
-@Service
@Slf4j
@RequiredArgsConstructor
public class ShareProductWritePlatformServiceJpaRepositoryImpl implements ShareProductWritePlatformService {
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/starter/ShareProductsConfiguration.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/starter/ShareProductsConfiguration.java
new file mode 100644
index 0000000..2cbe646
--- /dev/null
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/starter/ShareProductsConfiguration.java
@@ -0,0 +1,108 @@
+/**
+ * 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.portfolio.shareproducts.starter;
+
+import org.apache.fineract.accounting.common.AccountingDropdownReadPlatformService;
+import org.apache.fineract.accounting.producttoaccountmapping.service.ProductToGLAccountMappingReadPlatformService;
+import org.apache.fineract.accounting.producttoaccountmapping.service.ProductToGLAccountMappingWritePlatformService;
+import org.apache.fineract.infrastructure.core.serialization.FromJsonHelper;
+import org.apache.fineract.infrastructure.core.service.PaginationHelper;
+import org.apache.fineract.infrastructure.core.service.database.DatabaseSpecificSQLGenerator;
+import org.apache.fineract.infrastructure.event.business.service.BusinessEventNotifierService;
+import org.apache.fineract.infrastructure.security.utils.ColumnValidator;
+import org.apache.fineract.organisation.monetary.service.CurrencyReadPlatformService;
+import org.apache.fineract.portfolio.charge.service.ChargeReadPlatformService;
+import org.apache.fineract.portfolio.products.service.ShareProductReadPlatformService;
+import org.apache.fineract.portfolio.shareaccounts.service.ShareAccountReadPlatformService;
+import org.apache.fineract.portfolio.shareproducts.domain.ShareProductDividentPayOutDetailsRepositoryWrapper;
+import org.apache.fineract.portfolio.shareproducts.domain.ShareProductRepositoryWrapper;
+import org.apache.fineract.portfolio.shareproducts.serialization.ShareProductDataSerializer;
+import org.apache.fineract.portfolio.shareproducts.service.ShareProductCommandsServiceImpl;
+import org.apache.fineract.portfolio.shareproducts.service.ShareProductDividendAssembler;
+import org.apache.fineract.portfolio.shareproducts.service.ShareProductDividendReadPlatformService;
+import org.apache.fineract.portfolio.shareproducts.service.ShareProductDividendReadPlatformServiceImpl;
+import org.apache.fineract.portfolio.shareproducts.service.ShareProductDropdownReadPlatformService;
+import org.apache.fineract.portfolio.shareproducts.service.ShareProductDropdownReadPlatformServiceImpl;
+import org.apache.fineract.portfolio.shareproducts.service.ShareProductReadPlatformServiceImpl;
+import org.apache.fineract.portfolio.shareproducts.service.ShareProductWritePlatformService;
+import org.apache.fineract.portfolio.shareproducts.service.ShareProductWritePlatformServiceJpaRepositoryImpl;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.jdbc.core.JdbcTemplate;
+
+@Configuration
+public class ShareProductsConfiguration {
+
+ @Bean(value = "SHAREPRODUCT_COMMANDSERVICE")
+ @ConditionalOnMissingBean(ShareProductCommandsServiceImpl.class)
+ public ShareProductCommandsServiceImpl shareProductCommandsService(FromJsonHelper fromApiJsonHelper) {
+ return new ShareProductCommandsServiceImpl(fromApiJsonHelper);
+
+ }
+
+ @Bean
+ @ConditionalOnMissingBean(ShareProductDividendAssembler.class)
+ public ShareProductDividendAssembler shareProductDividendAssembler(ShareProductReadPlatformService shareProductReadPlatformService,
+ ShareAccountReadPlatformService shareAccountReadPlatformService) {
+ return new ShareProductDividendAssembler(shareProductReadPlatformService, shareAccountReadPlatformService);
+
+ }
+
+ @Bean
+ @ConditionalOnMissingBean(ShareProductDividendReadPlatformService.class)
+ public ShareProductDividendReadPlatformService shareProductDividendReadPlatformService(JdbcTemplate jdbcTemplate,
+ ColumnValidator columnValidator, PaginationHelper paginationHelper, DatabaseSpecificSQLGenerator sqlGenerator) {
+ return new ShareProductDividendReadPlatformServiceImpl(jdbcTemplate, columnValidator, paginationHelper, sqlGenerator);
+
+ }
+
+ @Bean
+ @ConditionalOnMissingBean(ShareProductDropdownReadPlatformService.class)
+ public ShareProductDropdownReadPlatformService shareProductDropdownReadPlatformService() {
+ return new ShareProductDropdownReadPlatformServiceImpl();
+ }
+
+ @Bean(value = "shareReadPlatformService")
+ @ConditionalOnMissingBean(ShareProductReadPlatformService.class)
+ public ShareProductReadPlatformService shareProductReadPlatformService(JdbcTemplate jdbcTemplate,
+ CurrencyReadPlatformService currencyReadPlatformService, ChargeReadPlatformService chargeReadPlatformService,
+ ShareProductDropdownReadPlatformService shareProductDropdownReadPlatformService,
+ AccountingDropdownReadPlatformService accountingDropdownReadPlatformService,
+ ProductToGLAccountMappingReadPlatformService accountMappingReadPlatformService,
+ PaginationHelper shareProductDataPaginationHelper, DatabaseSpecificSQLGenerator sqlGenerator) {
+ return new ShareProductReadPlatformServiceImpl(jdbcTemplate, currencyReadPlatformService, chargeReadPlatformService,
+ shareProductDropdownReadPlatformService, accountingDropdownReadPlatformService, accountMappingReadPlatformService,
+ shareProductDataPaginationHelper, sqlGenerator);
+ }
+
+ @Bean
+ @ConditionalOnMissingBean(ShareProductWritePlatformService.class)
+ public ShareProductWritePlatformService shareProductWritePlatformService(ShareProductRepositoryWrapper repository,
+ ShareProductDataSerializer serializer, FromJsonHelper fromApiJsonHelper,
+ ShareProductDividentPayOutDetailsRepositoryWrapper shareProductDividentPayOutDetailsRepository,
+ ShareProductDividendAssembler shareProductDividendAssembler,
+ ProductToGLAccountMappingWritePlatformService accountMappingWritePlatformService,
+ BusinessEventNotifierService businessEventNotifierService) {
+ return new ShareProductWritePlatformServiceJpaRepositoryImpl(repository, serializer, fromApiJsonHelper,
+ shareProductDividentPayOutDetailsRepository, shareProductDividendAssembler, accountMappingWritePlatformService,
+ businessEventNotifierService);
+ }
+
+}