Merge pull request #450 from pramodn02/MIFOSX-506_2
batch job changes for load and save
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
CREATE TABLE `scheduled_jobs` (
|
||||
`id` BIGINT(20) NOT NULL AUTO_INCREMENT,
|
||||
`job_name` VARCHAR(50) NOT NULL COLLATE 'latin1_swedish_ci',
|
||||
`job_display_name` VARCHAR(50) NOT NULL COLLATE 'latin1_swedish_ci',
|
||||
`cron_expression` VARCHAR(20) NOT NULL COLLATE 'latin1_swedish_ci',
|
||||
`create_time` DATETIME NOT NULL,
|
||||
`task_priority` SMALLINT(6) NOT NULL DEFAULT '5',
|
||||
`group_name` VARCHAR(50) NULL DEFAULT NULL COLLATE 'latin1_swedish_ci',
|
||||
`previous_run_start_time` DATETIME NULL DEFAULT NULL,
|
||||
`next_run_time` DATETIME NULL DEFAULT NULL,
|
||||
`trigger_key` VARCHAR(500) NULL DEFAULT NULL COLLATE 'latin1_swedish_ci',
|
||||
`job_initializing_errorlog` TEXT NULL COLLATE 'latin1_swedish_ci',
|
||||
`is_active` TINYINT(1) NOT NULL DEFAULT '1',
|
||||
PRIMARY KEY (`id`)
|
||||
)
|
||||
COLLATE='utf8_general_ci'
|
||||
ENGINE=InnoDB;
|
||||
|
||||
CREATE TABLE `scheduled_job_runhistory` (
|
||||
`id` BIGINT(20) NOT NULL AUTO_INCREMENT,
|
||||
`job_id` BIGINT(20) NOT NULL,
|
||||
`version` BIGINT(20) NOT NULL,
|
||||
`start_time` DATETIME NOT NULL,
|
||||
`end_time` DATETIME NOT NULL,
|
||||
`status` VARCHAR(10) NOT NULL COLLATE 'latin1_swedish_ci',
|
||||
`errormessage` VARCHAR(500) NULL DEFAULT NULL COLLATE 'latin1_swedish_ci',
|
||||
`triggertype` VARCHAR(25) NOT NULL COLLATE 'latin1_swedish_ci',
|
||||
`errorlog` TEXT NULL COLLATE 'latin1_swedish_ci',
|
||||
PRIMARY KEY (`id`),
|
||||
INDEX `scheduledjobsFK` (`job_id`),
|
||||
CONSTRAINT `scheduledjobsFK` FOREIGN KEY (`job_id`) REFERENCES `scheduled_jobs` (`id`)
|
||||
)
|
||||
COLLATE='utf8_general_ci'
|
||||
ENGINE=InnoDB;
|
||||
|
||||
|
||||
INSERT INTO `scheduled_jobs` (`job_name`, `job_display_name`, `cron_expression`, `create_time`, `task_priority`, `group_name`, `previous_run_start_time`, `next_run_time`, `trigger_key`, `job_initializing_errorlog`, `is_active`) VALUES ('Update loan Summary', 'Update loan Summary', '0 0 22 1/1 * ? *', now(), 5, NULL, NULL, NULL, NULL, NULL, 1);
|
||||
INSERT INTO `scheduled_jobs` (`job_name`, `job_display_name`, `cron_expression`, `create_time`, `task_priority`, `group_name`, `previous_run_start_time`, `next_run_time`, `trigger_key`, `job_initializing_errorlog`, `is_active`) VALUES ('Update Loan Arrears Ageing', 'Update Loan Arrears Ageing', '0 1 0 1/1 * ? *', now(), 5, NULL, NULL, NULL, NULL, NULL, 1);
|
||||
INSERT INTO `scheduled_jobs` (`job_name`, `job_display_name`, `cron_expression`, `create_time`, `task_priority`, `group_name`, `previous_run_start_time`, `next_run_time`, `trigger_key`, `job_initializing_errorlog`, `is_active`) VALUES ('Update Loan Paid In Advance', 'Update Loan Paid In Advance', '0 5 0 1/1 * ? *', now(), 5, NULL, NULL, NULL, NULL, NULL, 1);
|
||||
INSERT INTO `scheduled_jobs` (`job_name`, `job_display_name`, `cron_expression`, `create_time`, `task_priority`, `group_name`, `previous_run_start_time`, `next_run_time`, `trigger_key`, `job_initializing_errorlog`, `is_active`) VALUES ('Apply Annual Fee For Savings', 'Apply Annual Fee For Savings', '0 20 22 1/1 * ? *', now(), 5, NULL, NULL, NULL, NULL, NULL, 1);
|
||||
INSERT INTO `scheduled_jobs` (`job_name`, `job_display_name`, `cron_expression`, `create_time`, `task_priority`, `group_name`, `previous_run_start_time`, `next_run_time`, `trigger_key`, `job_initializing_errorlog`, `is_active`) VALUES ('Apply Holidays To Loans', 'Apply Holidays To Loans', '0 0 12 * * ?', now(), 5, NULL, NULL, NULL, NULL, NULL, 1);
|
||||
|
||||
|
||||
|
||||
|
||||
+2
-2
@@ -14,7 +14,7 @@ import org.joda.time.LocalDate;
|
||||
import org.mifosplatform.accounting.closure.data.GLClosureData;
|
||||
import org.mifosplatform.accounting.closure.exception.GLClosureNotFoundException;
|
||||
import org.mifosplatform.infrastructure.core.domain.JdbcSupport;
|
||||
import org.mifosplatform.infrastructure.core.service.TenantAwareRoutingDataSource;
|
||||
import org.mifosplatform.infrastructure.core.service.RoutingDataSource;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.dao.EmptyResultDataAccessException;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
@@ -27,7 +27,7 @@ public class GLClosureReadPlatformServiceImpl implements GLClosureReadPlatformSe
|
||||
private final JdbcTemplate jdbcTemplate;
|
||||
|
||||
@Autowired
|
||||
public GLClosureReadPlatformServiceImpl(final TenantAwareRoutingDataSource dataSource) {
|
||||
public GLClosureReadPlatformServiceImpl(final RoutingDataSource dataSource) {
|
||||
this.jdbcTemplate = new JdbcTemplate(dataSource);
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -21,7 +21,7 @@ import org.mifosplatform.accounting.glaccount.exception.GLAccountNotFoundExcepti
|
||||
import org.mifosplatform.infrastructure.codes.data.CodeValueData;
|
||||
import org.mifosplatform.infrastructure.core.data.EnumOptionData;
|
||||
import org.mifosplatform.infrastructure.core.domain.JdbcSupport;
|
||||
import org.mifosplatform.infrastructure.core.service.TenantAwareRoutingDataSource;
|
||||
import org.mifosplatform.infrastructure.core.service.RoutingDataSource;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.dao.EmptyResultDataAccessException;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
@@ -35,7 +35,7 @@ public class GLAccountReadPlatformServiceImpl implements GLAccountReadPlatformSe
|
||||
private final static String nameDecoratedBaseOnHierarchy = "concat(substring('........................................', 1, ((LENGTH(hierarchy) - LENGTH(REPLACE(hierarchy, '.', '')) - 1) * 4)), name)";
|
||||
|
||||
@Autowired
|
||||
public GLAccountReadPlatformServiceImpl(final TenantAwareRoutingDataSource dataSource) {
|
||||
public GLAccountReadPlatformServiceImpl(final RoutingDataSource dataSource) {
|
||||
this.jdbcTemplate = new JdbcTemplate(dataSource);
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -22,7 +22,7 @@ import org.mifosplatform.infrastructure.core.data.EnumOptionData;
|
||||
import org.mifosplatform.infrastructure.core.domain.JdbcSupport;
|
||||
import org.mifosplatform.infrastructure.core.service.Page;
|
||||
import org.mifosplatform.infrastructure.core.service.PaginationHelper;
|
||||
import org.mifosplatform.infrastructure.core.service.TenantAwareRoutingDataSource;
|
||||
import org.mifosplatform.infrastructure.core.service.RoutingDataSource;
|
||||
import org.mifosplatform.portfolio.group.service.SearchParameters;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.dao.EmptyResultDataAccessException;
|
||||
@@ -39,7 +39,7 @@ public class JournalEntryReadPlatformServiceImpl implements JournalEntryReadPlat
|
||||
private final PaginationHelper<JournalEntryData> paginationHelper = new PaginationHelper<JournalEntryData>();
|
||||
|
||||
@Autowired
|
||||
public JournalEntryReadPlatformServiceImpl(final TenantAwareRoutingDataSource dataSource) {
|
||||
public JournalEntryReadPlatformServiceImpl(final RoutingDataSource dataSource) {
|
||||
this.jdbcTemplate = new JdbcTemplate(dataSource);
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -22,7 +22,7 @@ import org.mifosplatform.accounting.producttoaccountmapping.data.ChargeToGLAccou
|
||||
import org.mifosplatform.accounting.producttoaccountmapping.data.PaymentTypeToGLAccountMapper;
|
||||
import org.mifosplatform.accounting.producttoaccountmapping.domain.PortfolioProductType;
|
||||
import org.mifosplatform.infrastructure.core.domain.JdbcSupport;
|
||||
import org.mifosplatform.infrastructure.core.service.TenantAwareRoutingDataSource;
|
||||
import org.mifosplatform.infrastructure.core.service.RoutingDataSource;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.jdbc.core.RowMapper;
|
||||
@@ -34,7 +34,7 @@ public class ProductToGLAccountMappingReadPlatformServiceImpl implements Product
|
||||
private final JdbcTemplate jdbcTemplate;
|
||||
|
||||
@Autowired
|
||||
public ProductToGLAccountMappingReadPlatformServiceImpl(final TenantAwareRoutingDataSource dataSource) {
|
||||
public ProductToGLAccountMappingReadPlatformServiceImpl(final RoutingDataSource dataSource) {
|
||||
this.jdbcTemplate = new JdbcTemplate(dataSource);
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -23,7 +23,7 @@ import org.mifosplatform.accounting.rule.exception.AccountingRuleNotFoundExcepti
|
||||
import org.mifosplatform.infrastructure.codes.data.CodeValueData;
|
||||
import org.mifosplatform.infrastructure.core.data.EnumOptionData;
|
||||
import org.mifosplatform.infrastructure.core.domain.JdbcSupport;
|
||||
import org.mifosplatform.infrastructure.core.service.TenantAwareRoutingDataSource;
|
||||
import org.mifosplatform.infrastructure.core.service.RoutingDataSource;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.dao.EmptyResultDataAccessException;
|
||||
@@ -39,7 +39,7 @@ public class AccountingRuleReadPlatformServiceImpl implements AccountingRuleRead
|
||||
private final GLAccountReadPlatformService glAccountReadPlatformService;
|
||||
|
||||
@Autowired
|
||||
public AccountingRuleReadPlatformServiceImpl(final TenantAwareRoutingDataSource dataSource,
|
||||
public AccountingRuleReadPlatformServiceImpl(final RoutingDataSource dataSource,
|
||||
final GLAccountReadPlatformService glAccountReadPlatformService) {
|
||||
this.jdbcTemplate = new JdbcTemplate(dataSource);
|
||||
this.glAccountReadPlatformService = glAccountReadPlatformService;
|
||||
|
||||
+2
-2
@@ -20,7 +20,7 @@ import org.mifosplatform.commands.data.ProcessingResultLookup;
|
||||
import org.mifosplatform.infrastructure.core.domain.JdbcSupport;
|
||||
import org.mifosplatform.infrastructure.core.exception.PlatformDataIntegrityException;
|
||||
import org.mifosplatform.infrastructure.core.serialization.FromJsonHelper;
|
||||
import org.mifosplatform.infrastructure.core.service.TenantAwareRoutingDataSource;
|
||||
import org.mifosplatform.infrastructure.core.service.RoutingDataSource;
|
||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||
import org.mifosplatform.organisation.office.data.OfficeData;
|
||||
import org.mifosplatform.organisation.office.service.OfficeReadPlatformService;
|
||||
@@ -60,7 +60,7 @@ public class AuditReadPlatformServiceImpl implements AuditReadPlatformService {
|
||||
private final StaffReadPlatformService staffReadPlatformService;
|
||||
|
||||
@Autowired
|
||||
public AuditReadPlatformServiceImpl(final PlatformSecurityContext context, final TenantAwareRoutingDataSource dataSource,
|
||||
public AuditReadPlatformServiceImpl(final PlatformSecurityContext context, final RoutingDataSource dataSource,
|
||||
final FromJsonHelper fromApiJsonHelper, final AppUserReadPlatformService appUserReadPlatformService,
|
||||
final OfficeReadPlatformService officeReadPlatformService, final ClientReadPlatformService clientReadPlatformService,
|
||||
final LoanProductReadPlatformService loanProductReadPlatformService, final StaffReadPlatformService staffReadPlatformService) {
|
||||
|
||||
+2
-2
@@ -11,7 +11,7 @@ import java.util.Collection;
|
||||
|
||||
import org.mifosplatform.infrastructure.codes.data.CodeData;
|
||||
import org.mifosplatform.infrastructure.codes.exception.CodeNotFoundException;
|
||||
import org.mifosplatform.infrastructure.core.service.TenantAwareRoutingDataSource;
|
||||
import org.mifosplatform.infrastructure.core.service.RoutingDataSource;
|
||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.dao.EmptyResultDataAccessException;
|
||||
@@ -26,7 +26,7 @@ public class CodeReadPlatformServiceImpl implements CodeReadPlatformService {
|
||||
private final PlatformSecurityContext context;
|
||||
|
||||
@Autowired
|
||||
public CodeReadPlatformServiceImpl(final PlatformSecurityContext context, final TenantAwareRoutingDataSource dataSource) {
|
||||
public CodeReadPlatformServiceImpl(final PlatformSecurityContext context, final RoutingDataSource dataSource) {
|
||||
this.context = context;
|
||||
this.jdbcTemplate = new JdbcTemplate(dataSource);
|
||||
}
|
||||
|
||||
+2
-2
@@ -10,7 +10,7 @@ import java.sql.SQLException;
|
||||
import java.util.Collection;
|
||||
|
||||
import org.mifosplatform.infrastructure.codes.data.CodeValueData;
|
||||
import org.mifosplatform.infrastructure.core.service.TenantAwareRoutingDataSource;
|
||||
import org.mifosplatform.infrastructure.core.service.RoutingDataSource;
|
||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
@@ -24,7 +24,7 @@ public class CodeValueReadPlatformServiceImpl implements CodeValueReadPlatformSe
|
||||
private final PlatformSecurityContext context;
|
||||
|
||||
@Autowired
|
||||
public CodeValueReadPlatformServiceImpl(final PlatformSecurityContext context, final TenantAwareRoutingDataSource dataSource) {
|
||||
public CodeValueReadPlatformServiceImpl(final PlatformSecurityContext context, final RoutingDataSource dataSource) {
|
||||
this.context = context;
|
||||
this.jdbcTemplate = new JdbcTemplate(dataSource);
|
||||
}
|
||||
|
||||
+2
-2
@@ -11,7 +11,7 @@ import java.util.List;
|
||||
|
||||
import org.mifosplatform.infrastructure.configuration.data.GlobalConfigurationData;
|
||||
import org.mifosplatform.infrastructure.configuration.data.GlobalConfigurationPropertyData;
|
||||
import org.mifosplatform.infrastructure.core.service.TenantAwareRoutingDataSource;
|
||||
import org.mifosplatform.infrastructure.core.service.RoutingDataSource;
|
||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
@@ -26,7 +26,7 @@ public class ConfigurationReadPlatformServiceImpl implements ConfigurationReadPl
|
||||
private final RowMapper<GlobalConfigurationPropertyData> rm;
|
||||
|
||||
@Autowired
|
||||
public ConfigurationReadPlatformServiceImpl(final PlatformSecurityContext context, final TenantAwareRoutingDataSource dataSource) {
|
||||
public ConfigurationReadPlatformServiceImpl(final PlatformSecurityContext context, final RoutingDataSource dataSource) {
|
||||
this.context = context;
|
||||
this.jdbcTemplate = new JdbcTemplate(dataSource);
|
||||
|
||||
|
||||
+2
-2
@@ -4,7 +4,7 @@ import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.mifosplatform.infrastructure.configuration.data.S3CredentialsData;
|
||||
import org.mifosplatform.infrastructure.core.service.TenantAwareRoutingDataSource;
|
||||
import org.mifosplatform.infrastructure.core.service.RoutingDataSource;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
@@ -17,7 +17,7 @@ public class ExternalServicesReadPlatformServiceImpl implements ExternalServices
|
||||
private final JdbcTemplate jdbcTemplate;
|
||||
|
||||
@Autowired
|
||||
public ExternalServicesReadPlatformServiceImpl(final TenantAwareRoutingDataSource dataSource) {
|
||||
public ExternalServicesReadPlatformServiceImpl(final RoutingDataSource dataSource) {
|
||||
this.jdbcTemplate = new JdbcTemplate(dataSource);
|
||||
}
|
||||
|
||||
|
||||
+47
-14
@@ -5,22 +5,54 @@
|
||||
*/
|
||||
package org.mifosplatform.infrastructure.core.domain;
|
||||
|
||||
public class MifosPlatformTenant {
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
|
||||
private final Long id;
|
||||
private final String name;
|
||||
private final String schemaName;
|
||||
private final String schemaServer;
|
||||
private final String schemaServerPort;
|
||||
private final String schemaUsername;
|
||||
private final String schemaPassword;
|
||||
private final String timezoneId;
|
||||
private final boolean autoUpdateEnabled;
|
||||
import org.springframework.data.jpa.domain.AbstractPersistable;
|
||||
|
||||
public MifosPlatformTenant(final Long id, final String name, final String schemaName, final String schemaServer,
|
||||
|
||||
@Entity
|
||||
@Table(name = "tenants")
|
||||
public class MifosPlatformTenant extends AbstractPersistable<Long>{
|
||||
|
||||
@Column(name="identifier")
|
||||
private String tenantIdentifier;
|
||||
|
||||
@Column(name = "name")
|
||||
private String name;
|
||||
|
||||
@Column(name = "schema_name")
|
||||
private String schemaName;
|
||||
|
||||
@Column(name = "schema_server")
|
||||
private String schemaServer;
|
||||
|
||||
@Column(name = "schema_server_port")
|
||||
private String schemaServerPort;
|
||||
|
||||
@Column(name = "schema_username")
|
||||
private String schemaUsername;
|
||||
|
||||
@Column(name = "schema_password")
|
||||
private String schemaPassword;
|
||||
|
||||
@Column(name = "timezone_id")
|
||||
private String timezoneId;
|
||||
|
||||
@Column(name = "auto_update")
|
||||
private boolean autoUpdateEnabled;
|
||||
|
||||
|
||||
public MifosPlatformTenant() {
|
||||
|
||||
}
|
||||
|
||||
public MifosPlatformTenant(final Long id,final String tenantIdentifier, final String name, final String schemaName, final String schemaServer,
|
||||
final String schemaServerPort, final String schemaUsername, final String schemaPassword, String timezoneId,
|
||||
final boolean autoUpdateEnabled) {
|
||||
this.id = id;
|
||||
setId(id);
|
||||
this.tenantIdentifier = tenantIdentifier;
|
||||
this.name = name;
|
||||
this.schemaName = schemaName;
|
||||
this.schemaServer = schemaServer;
|
||||
@@ -38,8 +70,9 @@ public class MifosPlatformTenant {
|
||||
return url;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
|
||||
public String getTenantIdentifier() {
|
||||
return this.tenantIdentifier;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
package org.mifosplatform.infrastructure.core.service;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* Implementation that returns connection pool datasource for tenants database
|
||||
*/
|
||||
@Service
|
||||
public class DataSourceForTenants implements RoutingDataSourceService {
|
||||
|
||||
private final DataSource tenantDataSource;
|
||||
|
||||
@Autowired
|
||||
public DataSourceForTenants(final @Qualifier("tenantDataSourceJndi") DataSource tenantDataSource) {
|
||||
this.tenantDataSource = tenantDataSource;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataSource retrieveDataSource() {
|
||||
return this.tenantDataSource;
|
||||
}
|
||||
|
||||
}
|
||||
+5
-5
@@ -22,14 +22,14 @@ import org.springframework.stereotype.Service;
|
||||
*
|
||||
* The tenant details are process earlier and stored in a {@link ThreadLocal}.
|
||||
*
|
||||
* The {@link DataSourcePerTenantService} is responsible for returning the
|
||||
* The {@link RoutingDataSourceService} is responsible for returning the
|
||||
* appropriate {@link DataSource} for the tenant of this request.
|
||||
*/
|
||||
@Service(value = "tenantAwareDataSource")
|
||||
public class TenantAwareRoutingDataSource extends AbstractDataSource {
|
||||
@Service(value = "routingDataSource")
|
||||
public class RoutingDataSource extends AbstractDataSource {
|
||||
|
||||
@Autowired
|
||||
private DataSourcePerTenantService dataSourcePerTenantService;
|
||||
private RoutingDataSourceServiceFactory dataSourceServiceFactory;
|
||||
|
||||
@Override
|
||||
public Connection getConnection() throws SQLException {
|
||||
@@ -37,7 +37,7 @@ public class TenantAwareRoutingDataSource extends AbstractDataSource {
|
||||
}
|
||||
|
||||
private DataSource determineTargetDataSource() {
|
||||
return dataSourcePerTenantService.retrieveTenantAwareDataSource();
|
||||
return dataSourceServiceFactory.determineDataSourceService().retrieveDataSource();
|
||||
}
|
||||
|
||||
@Override
|
||||
+3
-3
@@ -9,9 +9,9 @@ import javax.sql.DataSource;
|
||||
|
||||
/**
|
||||
* A service for getting hold of the appropriate {@link DataSource} connection
|
||||
* pool for the given tenant.
|
||||
* pool.
|
||||
*/
|
||||
public interface DataSourcePerTenantService {
|
||||
public interface RoutingDataSourceService {
|
||||
|
||||
DataSource retrieveTenantAwareDataSource();
|
||||
DataSource retrieveDataSource();
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
package org.mifosplatform.infrastructure.core.service;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* Factory class to get data source service based on the details stored in
|
||||
* {@link ThreadLocal} variable for this request
|
||||
*
|
||||
* {@link ThreadLocalContextUtil} is used to retrieve the Context
|
||||
*
|
||||
*/
|
||||
@Component
|
||||
public class RoutingDataSourceServiceFactory {
|
||||
|
||||
@Autowired
|
||||
private ApplicationContext applicationContext;
|
||||
|
||||
public RoutingDataSourceService determineDataSourceService() {
|
||||
String serviceName = "tomcatJdbcDataSourcePerTenantService";
|
||||
if (ThreadLocalContextUtil.CONTEXT_TENANTS.equalsIgnoreCase(ThreadLocalContextUtil.getDataSourceContext())) {
|
||||
serviceName = "dataSourceForTenants";
|
||||
}
|
||||
return applicationContext.getBean(serviceName, RoutingDataSourceService.class);
|
||||
|
||||
}
|
||||
}
|
||||
+20
-3
@@ -13,18 +13,35 @@ import org.springframework.util.Assert;
|
||||
*/
|
||||
public class ThreadLocalContextUtil {
|
||||
|
||||
private static final ThreadLocal<MifosPlatformTenant> contextHolder = new ThreadLocal<MifosPlatformTenant>();
|
||||
public static final String CONTEXT_TENANTS = "tenants";
|
||||
|
||||
private static final ThreadLocal<String> contextHolder = new ThreadLocal<String>();
|
||||
|
||||
private static final ThreadLocal<MifosPlatformTenant> tenantcontext = new ThreadLocal<MifosPlatformTenant>();
|
||||
|
||||
public static void setTenant(final MifosPlatformTenant tenant) {
|
||||
Assert.notNull(tenant, "tenant cannot be null");
|
||||
contextHolder.set(tenant);
|
||||
tenantcontext.set(tenant);
|
||||
}
|
||||
|
||||
public static MifosPlatformTenant getTenant() {
|
||||
return contextHolder.get();
|
||||
return tenantcontext.get();
|
||||
}
|
||||
|
||||
public static void clearTenant() {
|
||||
tenantcontext.remove();
|
||||
}
|
||||
|
||||
public static String getDataSourceContext() {
|
||||
return contextHolder.get();
|
||||
}
|
||||
|
||||
public static void setDataSourceContext(final String dataSourceContext) {
|
||||
contextHolder.set(dataSourceContext);
|
||||
}
|
||||
|
||||
public static void clearDataSourceContext() {
|
||||
contextHolder.remove();
|
||||
}
|
||||
|
||||
}
|
||||
+2
-2
@@ -26,7 +26,7 @@ import org.springframework.stereotype.Service;
|
||||
* {@link MifosPlatformTenant} for the request.
|
||||
*/
|
||||
@Service
|
||||
public class TomcatJdbcDataSourcePerTenantService implements DataSourcePerTenantService {
|
||||
public class TomcatJdbcDataSourcePerTenantService implements RoutingDataSourceService {
|
||||
|
||||
private final Map<Long, DataSource> tenantToDataSourceMap = new HashMap<Long, DataSource>(1);
|
||||
private final DataSource tenantDataSource;
|
||||
@@ -37,7 +37,7 @@ public class TomcatJdbcDataSourcePerTenantService implements DataSourcePerTenant
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataSource retrieveTenantAwareDataSource() {
|
||||
public DataSource retrieveDataSource() {
|
||||
|
||||
// default to tenant database datasource
|
||||
DataSource tenantDataSource = this.tenantDataSource;
|
||||
|
||||
+2
-2
@@ -11,7 +11,7 @@ import java.util.List;
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.joda.time.LocalDate;
|
||||
import org.mifosplatform.infrastructure.core.service.TenantAwareRoutingDataSource;
|
||||
import org.mifosplatform.infrastructure.core.service.RoutingDataSource;
|
||||
import org.mifosplatform.infrastructure.dataqueries.data.GenericResultsetData;
|
||||
import org.mifosplatform.infrastructure.dataqueries.data.ResultsetColumnHeaderData;
|
||||
import org.mifosplatform.infrastructure.dataqueries.data.ResultsetColumnValueData;
|
||||
@@ -30,7 +30,7 @@ public class GenericDataServiceImpl implements GenericDataService {
|
||||
private final DataSource dataSource;
|
||||
|
||||
@Autowired
|
||||
public GenericDataServiceImpl(final TenantAwareRoutingDataSource dataSource) {
|
||||
public GenericDataServiceImpl(final RoutingDataSource dataSource) {
|
||||
this.dataSource = dataSource;
|
||||
this.jdbcTemplate = new JdbcTemplate(this.dataSource);
|
||||
}
|
||||
|
||||
+2
-2
@@ -30,7 +30,7 @@ import javax.ws.rs.core.StreamingOutput;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.mifosplatform.infrastructure.core.domain.JdbcSupport;
|
||||
import org.mifosplatform.infrastructure.core.exception.PlatformDataIntegrityException;
|
||||
import org.mifosplatform.infrastructure.core.service.TenantAwareRoutingDataSource;
|
||||
import org.mifosplatform.infrastructure.core.service.RoutingDataSource;
|
||||
import org.mifosplatform.infrastructure.dataqueries.data.GenericResultsetData;
|
||||
import org.mifosplatform.infrastructure.dataqueries.data.ReportData;
|
||||
import org.mifosplatform.infrastructure.dataqueries.data.ReportParameterData;
|
||||
@@ -80,7 +80,7 @@ public class ReadReportingServiceImpl implements ReadReportingService {
|
||||
private boolean noPentaho = false;
|
||||
|
||||
@Autowired
|
||||
public ReadReportingServiceImpl(final PlatformSecurityContext context, final TenantAwareRoutingDataSource dataSource,
|
||||
public ReadReportingServiceImpl(final PlatformSecurityContext context, final RoutingDataSource dataSource,
|
||||
final GenericDataService genericDataService) {
|
||||
// kick off pentaho reports server
|
||||
ClassicEngineBoot.getInstance().start();
|
||||
|
||||
+2
-2
@@ -30,7 +30,7 @@ import org.mifosplatform.infrastructure.core.exception.PlatformDataIntegrityExce
|
||||
import org.mifosplatform.infrastructure.core.serialization.DatatableCommandFromApiJsonDeserializer;
|
||||
import org.mifosplatform.infrastructure.core.serialization.FromJsonHelper;
|
||||
import org.mifosplatform.infrastructure.core.serialization.JsonParserHelper;
|
||||
import org.mifosplatform.infrastructure.core.service.TenantAwareRoutingDataSource;
|
||||
import org.mifosplatform.infrastructure.core.service.RoutingDataSource;
|
||||
import org.mifosplatform.infrastructure.dataqueries.data.DatatableData;
|
||||
import org.mifosplatform.infrastructure.dataqueries.data.GenericResultsetData;
|
||||
import org.mifosplatform.infrastructure.dataqueries.data.ResultsetColumnHeaderData;
|
||||
@@ -82,7 +82,7 @@ public class ReadWriteNonCoreDataServiceImpl implements ReadWriteNonCoreDataServ
|
||||
private final DatatableCommandFromApiJsonDeserializer fromApiJsonDeserializer;
|
||||
|
||||
@Autowired
|
||||
public ReadWriteNonCoreDataServiceImpl(final TenantAwareRoutingDataSource dataSource, final PlatformSecurityContext context,
|
||||
public ReadWriteNonCoreDataServiceImpl(final RoutingDataSource dataSource, final PlatformSecurityContext context,
|
||||
final FromJsonHelper fromJsonHelper, final GenericDataService genericDataService,
|
||||
final DatatableCommandFromApiJsonDeserializer fromApiJsonDeserializer) {
|
||||
this.dataSource = dataSource;
|
||||
|
||||
+2
-2
@@ -6,7 +6,7 @@
|
||||
package org.mifosplatform.infrastructure.documentmanagement.service;
|
||||
|
||||
import org.mifosplatform.infrastructure.core.domain.JdbcSupport;
|
||||
import org.mifosplatform.infrastructure.core.service.TenantAwareRoutingDataSource;
|
||||
import org.mifosplatform.infrastructure.core.service.RoutingDataSource;
|
||||
import org.mifosplatform.infrastructure.documentmanagement.contentrepository.ContentRepository;
|
||||
import org.mifosplatform.infrastructure.documentmanagement.contentrepository.ContentRepositoryFactory;
|
||||
import org.mifosplatform.infrastructure.documentmanagement.data.DocumentData;
|
||||
@@ -31,7 +31,7 @@ public class DocumentReadPlatformServiceImpl implements DocumentReadPlatformServ
|
||||
private final ContentRepositoryFactory contentRepositoryFactory;
|
||||
|
||||
@Autowired
|
||||
public DocumentReadPlatformServiceImpl(final PlatformSecurityContext context, final TenantAwareRoutingDataSource dataSource,
|
||||
public DocumentReadPlatformServiceImpl(final PlatformSecurityContext context, final RoutingDataSource dataSource,
|
||||
final ContentRepositoryFactory documentStoreFactory) {
|
||||
this.context = context;
|
||||
this.jdbcTemplate = new JdbcTemplate(dataSource);
|
||||
|
||||
+2
-2
@@ -9,7 +9,7 @@ import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.mifosplatform.infrastructure.core.domain.JdbcSupport;
|
||||
import org.mifosplatform.infrastructure.core.service.TenantAwareRoutingDataSource;
|
||||
import org.mifosplatform.infrastructure.core.service.RoutingDataSource;
|
||||
import org.mifosplatform.infrastructure.documentmanagement.contentrepository.ContentRepository;
|
||||
import org.mifosplatform.infrastructure.documentmanagement.contentrepository.ContentRepositoryFactory;
|
||||
import org.mifosplatform.infrastructure.documentmanagement.data.ImageData;
|
||||
@@ -30,7 +30,7 @@ public class ImageReadPlatformServiceImpl implements ImageReadPlatformService {
|
||||
private final ClientRepositoryWrapper clientRepositoryWrapper;
|
||||
|
||||
@Autowired
|
||||
public ImageReadPlatformServiceImpl(final TenantAwareRoutingDataSource dataSource, final ContentRepositoryFactory documentStoreFactory,
|
||||
public ImageReadPlatformServiceImpl(final RoutingDataSource dataSource, final ContentRepositoryFactory documentStoreFactory,
|
||||
final ClientRepositoryWrapper clientRepositoryWrapper) {
|
||||
this.jdbcTemplate = new JdbcTemplate(dataSource);
|
||||
this.contentRepositoryFactory = documentStoreFactory;
|
||||
|
||||
+3
-2
@@ -37,7 +37,7 @@ public class JdbcTenantDetailsService implements TenantDetailsService {
|
||||
private static final class TenantMapper implements RowMapper<MifosPlatformTenant> {
|
||||
|
||||
private StringBuilder sqlBuilder = new StringBuilder(
|
||||
"id, name, schema_name as schemaName, schema_server as schemaServer, schema_server_port as schemaServerPort, auto_update as autoUpdate, ")//
|
||||
"id, name,identifier, schema_name as schemaName, schema_server as schemaServer, schema_server_port as schemaServerPort, auto_update as autoUpdate, ")//
|
||||
.append(" schema_username as schemaUsername, schema_password as schemaPassword , timezone_id as timezoneId ")//
|
||||
.append(" from tenants t");//
|
||||
|
||||
@@ -49,6 +49,7 @@ public class JdbcTenantDetailsService implements TenantDetailsService {
|
||||
public MifosPlatformTenant mapRow(final ResultSet rs, @SuppressWarnings("unused") final int rowNum) throws SQLException {
|
||||
|
||||
Long id = rs.getLong("id");
|
||||
String tenantIdentifier = rs.getString("identifier");
|
||||
String name = rs.getString("name");
|
||||
String schemaName = rs.getString("schemaName");
|
||||
String schemaServer = rs.getString("schemaServer");
|
||||
@@ -58,7 +59,7 @@ public class JdbcTenantDetailsService implements TenantDetailsService {
|
||||
String timezoneId = rs.getString("timezoneId");
|
||||
boolean autoUpdateEnabled = rs.getBoolean("autoUpdate");
|
||||
|
||||
return new MifosPlatformTenant(id, name, schemaName, schemaServer, schemaServerPort, schemaUsername, schemaPassword,
|
||||
return new MifosPlatformTenant(id, tenantIdentifier,name, schemaName, schemaServer, schemaServerPort, schemaUsername, schemaPassword,
|
||||
timezoneId, autoUpdateEnabled);
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -10,7 +10,7 @@ import java.sql.SQLException;
|
||||
import java.util.Collection;
|
||||
|
||||
import org.mifosplatform.infrastructure.core.domain.JdbcSupport;
|
||||
import org.mifosplatform.infrastructure.core.service.TenantAwareRoutingDataSource;
|
||||
import org.mifosplatform.infrastructure.core.service.RoutingDataSource;
|
||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||
import org.mifosplatform.organisation.monetary.data.CurrencyData;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -26,7 +26,7 @@ public class CurrencyReadPlatformServiceImpl implements CurrencyReadPlatformServ
|
||||
private final CurrencyMapper currencyRowMapper;
|
||||
|
||||
@Autowired
|
||||
public CurrencyReadPlatformServiceImpl(final PlatformSecurityContext context, final TenantAwareRoutingDataSource dataSource) {
|
||||
public CurrencyReadPlatformServiceImpl(final PlatformSecurityContext context, final RoutingDataSource dataSource) {
|
||||
this.context = context;
|
||||
this.jdbcTemplate = new JdbcTemplate(dataSource);
|
||||
this.currencyRowMapper = new CurrencyMapper();
|
||||
|
||||
+2
-2
@@ -13,7 +13,7 @@ import java.util.Collection;
|
||||
|
||||
import org.joda.time.LocalDate;
|
||||
import org.mifosplatform.infrastructure.core.domain.JdbcSupport;
|
||||
import org.mifosplatform.infrastructure.core.service.TenantAwareRoutingDataSource;
|
||||
import org.mifosplatform.infrastructure.core.service.RoutingDataSource;
|
||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||
import org.mifosplatform.organisation.monetary.data.CurrencyData;
|
||||
import org.mifosplatform.organisation.monetary.service.CurrencyReadPlatformService;
|
||||
@@ -37,7 +37,7 @@ public class OfficeReadPlatformServiceImpl implements OfficeReadPlatformService
|
||||
|
||||
@Autowired
|
||||
public OfficeReadPlatformServiceImpl(final PlatformSecurityContext context,
|
||||
final CurrencyReadPlatformService currencyReadPlatformService, final TenantAwareRoutingDataSource dataSource) {
|
||||
final CurrencyReadPlatformService currencyReadPlatformService, final RoutingDataSource dataSource) {
|
||||
this.context = context;
|
||||
this.currencyReadPlatformService = currencyReadPlatformService;
|
||||
this.jdbcTemplate = new JdbcTemplate(dataSource);
|
||||
|
||||
+2
-2
@@ -10,7 +10,7 @@ import java.sql.SQLException;
|
||||
import java.util.Collection;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.mifosplatform.infrastructure.core.service.TenantAwareRoutingDataSource;
|
||||
import org.mifosplatform.infrastructure.core.service.RoutingDataSource;
|
||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||
import org.mifosplatform.organisation.staff.data.StaffData;
|
||||
import org.mifosplatform.organisation.staff.exception.StaffNotFoundException;
|
||||
@@ -29,7 +29,7 @@ public class StaffReadPlatformServiceImpl implements StaffReadPlatformService {
|
||||
private final StaffInOfficeHierarchyMapper staffInOfficeHierarchyMapper = new StaffInOfficeHierarchyMapper();
|
||||
|
||||
@Autowired
|
||||
public StaffReadPlatformServiceImpl(final PlatformSecurityContext context, final TenantAwareRoutingDataSource dataSource) {
|
||||
public StaffReadPlatformServiceImpl(final PlatformSecurityContext context, final RoutingDataSource dataSource) {
|
||||
this.context = context;
|
||||
this.jdbcTemplate = new JdbcTemplate(dataSource);
|
||||
}
|
||||
|
||||
+2
-2
@@ -15,7 +15,7 @@ import org.joda.time.LocalDate;
|
||||
import org.mifosplatform.infrastructure.core.data.EnumOptionData;
|
||||
import org.mifosplatform.infrastructure.core.domain.JdbcSupport;
|
||||
import org.mifosplatform.infrastructure.core.service.DateUtils;
|
||||
import org.mifosplatform.infrastructure.core.service.TenantAwareRoutingDataSource;
|
||||
import org.mifosplatform.infrastructure.core.service.RoutingDataSource;
|
||||
import org.mifosplatform.portfolio.calendar.data.CalendarData;
|
||||
import org.mifosplatform.portfolio.calendar.domain.CalendarEntityType;
|
||||
import org.mifosplatform.portfolio.calendar.exception.CalendarNotFoundException;
|
||||
@@ -32,7 +32,7 @@ public class CalendarReadPlatformServiceImpl implements CalendarReadPlatformServ
|
||||
private final JdbcTemplate jdbcTemplate;
|
||||
|
||||
@Autowired
|
||||
public CalendarReadPlatformServiceImpl(final TenantAwareRoutingDataSource dataSource) {
|
||||
public CalendarReadPlatformServiceImpl(final RoutingDataSource dataSource) {
|
||||
this.jdbcTemplate = new JdbcTemplate(dataSource);
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -13,7 +13,7 @@ import java.util.List;
|
||||
|
||||
import org.mifosplatform.infrastructure.core.data.EnumOptionData;
|
||||
import org.mifosplatform.infrastructure.core.domain.JdbcSupport;
|
||||
import org.mifosplatform.infrastructure.core.service.TenantAwareRoutingDataSource;
|
||||
import org.mifosplatform.infrastructure.core.service.RoutingDataSource;
|
||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||
import org.mifosplatform.organisation.monetary.data.CurrencyData;
|
||||
import org.mifosplatform.organisation.monetary.service.CurrencyReadPlatformService;
|
||||
@@ -37,7 +37,7 @@ public class ChargeReadPlatformServiceImpl implements ChargeReadPlatformService
|
||||
@Autowired
|
||||
public ChargeReadPlatformServiceImpl(final PlatformSecurityContext context,
|
||||
final CurrencyReadPlatformService currencyReadPlatformService,
|
||||
final ChargeDropdownReadPlatformService chargeDropdownReadPlatformService, final TenantAwareRoutingDataSource dataSource) {
|
||||
final ChargeDropdownReadPlatformService chargeDropdownReadPlatformService, final RoutingDataSource dataSource) {
|
||||
this.context = context;
|
||||
this.chargeDropdownReadPlatformService = chargeDropdownReadPlatformService;
|
||||
this.jdbcTemplate = new JdbcTemplate(dataSource);
|
||||
|
||||
+2
-2
@@ -11,7 +11,7 @@ import java.util.Collection;
|
||||
|
||||
import org.mifosplatform.infrastructure.codes.data.CodeValueData;
|
||||
import org.mifosplatform.infrastructure.core.domain.JdbcSupport;
|
||||
import org.mifosplatform.infrastructure.core.service.TenantAwareRoutingDataSource;
|
||||
import org.mifosplatform.infrastructure.core.service.RoutingDataSource;
|
||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||
import org.mifosplatform.portfolio.client.data.ClientIdentifierData;
|
||||
import org.mifosplatform.portfolio.client.exception.ClientIdentifierNotFoundException;
|
||||
@@ -29,7 +29,7 @@ public class ClientIdentifierReadPlatformServiceImpl implements ClientIdentifier
|
||||
private final PlatformSecurityContext context;
|
||||
|
||||
@Autowired
|
||||
public ClientIdentifierReadPlatformServiceImpl(final PlatformSecurityContext context, final TenantAwareRoutingDataSource dataSource) {
|
||||
public ClientIdentifierReadPlatformServiceImpl(final PlatformSecurityContext context, final RoutingDataSource dataSource) {
|
||||
this.context = context;
|
||||
this.jdbcTemplate = new JdbcTemplate(dataSource);
|
||||
}
|
||||
|
||||
+2
-2
@@ -20,7 +20,7 @@ import org.mifosplatform.infrastructure.core.data.EnumOptionData;
|
||||
import org.mifosplatform.infrastructure.core.domain.JdbcSupport;
|
||||
import org.mifosplatform.infrastructure.core.service.Page;
|
||||
import org.mifosplatform.infrastructure.core.service.PaginationHelper;
|
||||
import org.mifosplatform.infrastructure.core.service.TenantAwareRoutingDataSource;
|
||||
import org.mifosplatform.infrastructure.core.service.RoutingDataSource;
|
||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||
import org.mifosplatform.organisation.office.data.OfficeData;
|
||||
import org.mifosplatform.organisation.office.service.OfficeReadPlatformService;
|
||||
@@ -63,7 +63,7 @@ public class ClientReadPlatformServiceImpl implements ClientReadPlatformService
|
||||
private final ParentGroupsMapper clientGroupsMapper = new ParentGroupsMapper();
|
||||
|
||||
@Autowired
|
||||
public ClientReadPlatformServiceImpl(final PlatformSecurityContext context, final TenantAwareRoutingDataSource dataSource,
|
||||
public ClientReadPlatformServiceImpl(final PlatformSecurityContext context, final RoutingDataSource dataSource,
|
||||
final OfficeReadPlatformService officeReadPlatformService, final StaffReadPlatformService staffReadPlatformService,
|
||||
final CodeValueReadPlatformService codeValueReadPlatformService) {
|
||||
this.context = context;
|
||||
|
||||
+2
-2
@@ -12,7 +12,7 @@ import java.util.List;
|
||||
|
||||
import org.mifosplatform.infrastructure.codes.data.CodeValueData;
|
||||
import org.mifosplatform.infrastructure.core.domain.JdbcSupport;
|
||||
import org.mifosplatform.infrastructure.core.service.TenantAwareRoutingDataSource;
|
||||
import org.mifosplatform.infrastructure.core.service.RoutingDataSource;
|
||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||
import org.mifosplatform.organisation.monetary.data.CurrencyData;
|
||||
import org.mifosplatform.portfolio.collateral.data.CollateralData;
|
||||
@@ -34,7 +34,7 @@ public class CollateralReadPlatformServiceImpl implements CollateralReadPlatform
|
||||
private final LoanRepository loanRepository;
|
||||
|
||||
@Autowired
|
||||
public CollateralReadPlatformServiceImpl(final PlatformSecurityContext context, final TenantAwareRoutingDataSource dataSource,
|
||||
public CollateralReadPlatformServiceImpl(final PlatformSecurityContext context, final RoutingDataSource dataSource,
|
||||
final LoanRepository loanRepository) {
|
||||
this.context = context;
|
||||
this.jdbcTemplate = new JdbcTemplate(dataSource);
|
||||
|
||||
+2
-2
@@ -19,7 +19,7 @@ import java.util.Set;
|
||||
import org.joda.time.LocalDate;
|
||||
import org.mifosplatform.infrastructure.core.api.JsonQuery;
|
||||
import org.mifosplatform.infrastructure.core.domain.JdbcSupport;
|
||||
import org.mifosplatform.infrastructure.core.service.TenantAwareRoutingDataSource;
|
||||
import org.mifosplatform.infrastructure.core.service.RoutingDataSource;
|
||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||
import org.mifosplatform.organisation.monetary.data.CurrencyData;
|
||||
import org.mifosplatform.portfolio.collectionsheet.data.ClientLoansData;
|
||||
@@ -51,7 +51,7 @@ public class CollectionSheetReadPlatformServiceImpl implements CollectionSheetRe
|
||||
private final CollectionSheetGenerateCommandFromApiJsonDeserializer collectionSheetGenerateCommandFromApiJsonDeserializer;
|
||||
|
||||
@Autowired
|
||||
public CollectionSheetReadPlatformServiceImpl(final PlatformSecurityContext context, final TenantAwareRoutingDataSource dataSource,
|
||||
public CollectionSheetReadPlatformServiceImpl(final PlatformSecurityContext context, final RoutingDataSource dataSource,
|
||||
final CenterReadPlatformService centerReadPlatformService, final GroupReadPlatformService groupReadPlatformService, final CollectionSheetGenerateCommandFromApiJsonDeserializer collectionSheetGenerateCommandFromApiJsonDeserializer) {
|
||||
this.context = context;
|
||||
this.centerReadPlatformService = centerReadPlatformService;
|
||||
|
||||
+2
-2
@@ -9,7 +9,7 @@ import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Collection;
|
||||
|
||||
import org.mifosplatform.infrastructure.core.service.TenantAwareRoutingDataSource;
|
||||
import org.mifosplatform.infrastructure.core.service.RoutingDataSource;
|
||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||
import org.mifosplatform.portfolio.fund.data.FundData;
|
||||
import org.mifosplatform.portfolio.fund.exception.FundNotFoundException;
|
||||
@@ -26,7 +26,7 @@ public class FundReadPlatformServiceImpl implements FundReadPlatformService {
|
||||
private final PlatformSecurityContext context;
|
||||
|
||||
@Autowired
|
||||
public FundReadPlatformServiceImpl(final PlatformSecurityContext context, final TenantAwareRoutingDataSource dataSource) {
|
||||
public FundReadPlatformServiceImpl(final PlatformSecurityContext context, final RoutingDataSource dataSource) {
|
||||
this.context = context;
|
||||
this.jdbcTemplate = new JdbcTemplate(dataSource);
|
||||
}
|
||||
|
||||
+2
-2
@@ -17,7 +17,7 @@ import org.mifosplatform.infrastructure.core.data.EnumOptionData;
|
||||
import org.mifosplatform.infrastructure.core.domain.JdbcSupport;
|
||||
import org.mifosplatform.infrastructure.core.service.Page;
|
||||
import org.mifosplatform.infrastructure.core.service.PaginationHelper;
|
||||
import org.mifosplatform.infrastructure.core.service.TenantAwareRoutingDataSource;
|
||||
import org.mifosplatform.infrastructure.core.service.RoutingDataSource;
|
||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||
import org.mifosplatform.organisation.office.data.OfficeData;
|
||||
import org.mifosplatform.organisation.office.service.OfficeReadPlatformService;
|
||||
@@ -58,7 +58,7 @@ public class CenterReadPlatformServiceImpl implements CenterReadPlatformService
|
||||
private final PaginationHelper<CenterData> paginationHelper = new PaginationHelper<CenterData>();
|
||||
|
||||
@Autowired
|
||||
public CenterReadPlatformServiceImpl(final PlatformSecurityContext context, final TenantAwareRoutingDataSource dataSource,
|
||||
public CenterReadPlatformServiceImpl(final PlatformSecurityContext context, final RoutingDataSource dataSource,
|
||||
final ClientReadPlatformService clientReadPlatformService, final OfficeReadPlatformService officeReadPlatformService,
|
||||
final StaffReadPlatformService staffReadPlatformService) {
|
||||
this.context = context;
|
||||
|
||||
+2
-2
@@ -10,7 +10,7 @@ import java.sql.SQLException;
|
||||
import java.util.Collection;
|
||||
|
||||
import org.mifosplatform.infrastructure.core.domain.JdbcSupport;
|
||||
import org.mifosplatform.infrastructure.core.service.TenantAwareRoutingDataSource;
|
||||
import org.mifosplatform.infrastructure.core.service.RoutingDataSource;
|
||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||
import org.mifosplatform.portfolio.group.data.GroupLevelData;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -26,7 +26,7 @@ public class GroupLevelReadPlatformServiceImpl implements GroupLevelReadPlatform
|
||||
|
||||
|
||||
@Autowired
|
||||
public GroupLevelReadPlatformServiceImpl(final PlatformSecurityContext context , final TenantAwareRoutingDataSource dataSource) {
|
||||
public GroupLevelReadPlatformServiceImpl(final PlatformSecurityContext context , final RoutingDataSource dataSource) {
|
||||
this.context = context;
|
||||
this.jdbcTemplate = new JdbcTemplate(dataSource);
|
||||
}
|
||||
|
||||
+2
-2
@@ -18,7 +18,7 @@ import org.mifosplatform.infrastructure.core.api.ApiParameterHelper;
|
||||
import org.mifosplatform.infrastructure.core.domain.JdbcSupport;
|
||||
import org.mifosplatform.infrastructure.core.service.Page;
|
||||
import org.mifosplatform.infrastructure.core.service.PaginationHelper;
|
||||
import org.mifosplatform.infrastructure.core.service.TenantAwareRoutingDataSource;
|
||||
import org.mifosplatform.infrastructure.core.service.RoutingDataSource;
|
||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||
import org.mifosplatform.organisation.office.data.OfficeData;
|
||||
import org.mifosplatform.organisation.office.service.OfficeReadPlatformService;
|
||||
@@ -57,7 +57,7 @@ public class GroupReadPlatformServiceImpl implements GroupReadPlatformService {
|
||||
private final PaginationHelper<GroupGeneralData> paginationHelper = new PaginationHelper<GroupGeneralData>();
|
||||
|
||||
@Autowired
|
||||
public GroupReadPlatformServiceImpl(final PlatformSecurityContext context, final TenantAwareRoutingDataSource dataSource,
|
||||
public GroupReadPlatformServiceImpl(final PlatformSecurityContext context, final RoutingDataSource dataSource,
|
||||
final CenterReadPlatformService centerReadPlatformService, final ClientReadPlatformService clientReadPlatformService,
|
||||
final OfficeReadPlatformService officeReadPlatformService, final StaffReadPlatformService staffReadPlatformService,
|
||||
final CodeValueReadPlatformService codeValueReadPlatformService) {
|
||||
|
||||
+2
-2
@@ -6,7 +6,7 @@ import java.util.Collection;
|
||||
|
||||
import org.mifosplatform.infrastructure.codes.data.CodeValueData;
|
||||
import org.mifosplatform.infrastructure.core.domain.JdbcSupport;
|
||||
import org.mifosplatform.infrastructure.core.service.TenantAwareRoutingDataSource;
|
||||
import org.mifosplatform.infrastructure.core.service.RoutingDataSource;
|
||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||
import org.mifosplatform.portfolio.group.data.GroupRoleData;
|
||||
import org.mifosplatform.portfolio.group.exception.GroupRoleNotFoundException;
|
||||
@@ -23,7 +23,7 @@ public class GroupRolesReadPlatformServiceImpl implements GroupRolesReadPlatform
|
||||
private final PlatformSecurityContext context;
|
||||
|
||||
@Autowired
|
||||
public GroupRolesReadPlatformServiceImpl(final PlatformSecurityContext context, final TenantAwareRoutingDataSource dataSource) {
|
||||
public GroupRolesReadPlatformServiceImpl(final PlatformSecurityContext context, final RoutingDataSource dataSource) {
|
||||
this.context = context;
|
||||
this.jdbcTemplate = new JdbcTemplate(dataSource);
|
||||
}
|
||||
|
||||
-1
@@ -13,7 +13,6 @@ import javax.persistence.Embeddable;
|
||||
|
||||
import org.mifosplatform.organisation.monetary.domain.MonetaryCurrency;
|
||||
import org.mifosplatform.organisation.monetary.domain.Money;
|
||||
import org.mifosplatform.scheduledjobs.UpdateLoanSummariesScheduledJob;
|
||||
|
||||
/**
|
||||
* Encapsulates all the summary details of a {@link Loan}.
|
||||
|
||||
+2
-2
@@ -14,7 +14,7 @@ import org.joda.time.LocalDate;
|
||||
import org.mifosplatform.infrastructure.codes.data.CodeValueData;
|
||||
import org.mifosplatform.infrastructure.core.data.EnumOptionData;
|
||||
import org.mifosplatform.infrastructure.core.domain.JdbcSupport;
|
||||
import org.mifosplatform.infrastructure.core.service.TenantAwareRoutingDataSource;
|
||||
import org.mifosplatform.infrastructure.core.service.RoutingDataSource;
|
||||
import org.mifosplatform.organisation.staff.data.StaffData;
|
||||
import org.mifosplatform.organisation.staff.service.StaffReadPlatformService;
|
||||
import org.mifosplatform.portfolio.client.data.ClientData;
|
||||
@@ -37,7 +37,7 @@ public class GuarantorReadPlatformServiceImpl implements GuarantorReadPlatformSe
|
||||
private final LoanRepository loanRepository;
|
||||
|
||||
@Autowired
|
||||
public GuarantorReadPlatformServiceImpl(final TenantAwareRoutingDataSource dataSource,
|
||||
public GuarantorReadPlatformServiceImpl(final RoutingDataSource dataSource,
|
||||
final ClientReadPlatformService clientReadPlatformService, final StaffReadPlatformService staffReadPlatformService,
|
||||
final LoanRepository loanRepository) {
|
||||
this.jdbcTemplate = new JdbcTemplate(dataSource);
|
||||
|
||||
+2
-2
@@ -11,7 +11,7 @@ import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.mifosplatform.infrastructure.core.domain.JdbcSupport;
|
||||
import org.mifosplatform.infrastructure.core.service.TenantAwareRoutingDataSource;
|
||||
import org.mifosplatform.infrastructure.core.service.RoutingDataSource;
|
||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||
import org.mifosplatform.organisation.staff.data.StaffAccountSummaryCollectionData;
|
||||
import org.mifosplatform.portfolio.client.data.ClientAccountSummaryData;
|
||||
@@ -32,7 +32,7 @@ public class BulkLoansReadPlatformServiceImpl implements BulkLoansReadPlatformSe
|
||||
private final GroupReadPlatformService groupReadPlatformService;
|
||||
|
||||
@Autowired
|
||||
public BulkLoansReadPlatformServiceImpl(final PlatformSecurityContext context, final TenantAwareRoutingDataSource dataSource,
|
||||
public BulkLoansReadPlatformServiceImpl(final PlatformSecurityContext context, final RoutingDataSource dataSource,
|
||||
final ClientReadPlatformService clientReadPlatformService, final GroupReadPlatformService groupReadPlatformService) {
|
||||
this.context = context;
|
||||
this.jdbcTemplate = new JdbcTemplate(dataSource);
|
||||
|
||||
+2
-2
@@ -14,7 +14,7 @@ import java.util.List;
|
||||
import org.joda.time.LocalDate;
|
||||
import org.mifosplatform.infrastructure.core.data.EnumOptionData;
|
||||
import org.mifosplatform.infrastructure.core.domain.JdbcSupport;
|
||||
import org.mifosplatform.infrastructure.core.service.TenantAwareRoutingDataSource;
|
||||
import org.mifosplatform.infrastructure.core.service.RoutingDataSource;
|
||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||
import org.mifosplatform.organisation.monetary.data.CurrencyData;
|
||||
import org.mifosplatform.portfolio.charge.data.ChargeData;
|
||||
@@ -35,7 +35,7 @@ public class LoanChargeReadPlatformServiceImpl implements LoanChargeReadPlatform
|
||||
|
||||
@Autowired
|
||||
public LoanChargeReadPlatformServiceImpl(final PlatformSecurityContext context,
|
||||
final ChargeDropdownReadPlatformService chargeDropdownReadPlatformService, final TenantAwareRoutingDataSource dataSource) {
|
||||
final ChargeDropdownReadPlatformService chargeDropdownReadPlatformService, final RoutingDataSource dataSource) {
|
||||
this.context = context;
|
||||
this.chargeDropdownReadPlatformService = chargeDropdownReadPlatformService;
|
||||
this.jdbcTemplate = new JdbcTemplate(dataSource);
|
||||
|
||||
+2
-2
@@ -22,7 +22,7 @@ import org.mifosplatform.infrastructure.core.domain.JdbcSupport;
|
||||
import org.mifosplatform.infrastructure.core.service.DateUtils;
|
||||
import org.mifosplatform.infrastructure.core.service.Page;
|
||||
import org.mifosplatform.infrastructure.core.service.PaginationHelper;
|
||||
import org.mifosplatform.infrastructure.core.service.TenantAwareRoutingDataSource;
|
||||
import org.mifosplatform.infrastructure.core.service.RoutingDataSource;
|
||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||
import org.mifosplatform.organisation.monetary.data.CurrencyData;
|
||||
import org.mifosplatform.organisation.monetary.domain.ApplicationCurrency;
|
||||
@@ -102,7 +102,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
|
||||
final LoanProductReadPlatformService loanProductReadPlatformService, final ClientReadPlatformService clientReadPlatformService,
|
||||
final GroupReadPlatformService groupReadPlatformService, final LoanDropdownReadPlatformService loanDropdownReadPlatformService,
|
||||
final FundReadPlatformService fundReadPlatformService, final ChargeReadPlatformService chargeReadPlatformService,
|
||||
final CodeValueReadPlatformService codeValueReadPlatformService, final TenantAwareRoutingDataSource dataSource,
|
||||
final CodeValueReadPlatformService codeValueReadPlatformService, final RoutingDataSource dataSource,
|
||||
final CalendarReadPlatformService calendarReadPlatformService) {
|
||||
this.context = context;
|
||||
this.loanRepository = loanRepository;
|
||||
|
||||
+2
@@ -75,6 +75,7 @@ import org.mifosplatform.portfolio.note.domain.Note;
|
||||
import org.mifosplatform.portfolio.note.domain.NoteRepository;
|
||||
import org.mifosplatform.portfolio.paymentdetail.domain.PaymentDetail;
|
||||
import org.mifosplatform.portfolio.paymentdetail.service.PaymentDetailWritePlatformService;
|
||||
import org.mifosplatform.scheduledjobs.annotation.CronTargetMethod;
|
||||
import org.mifosplatform.useradministration.domain.AppUser;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -1178,6 +1179,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
@CronTargetMethod(jobName="Apply Holidays To Loans")
|
||||
public void applyHolidaysToLoans() {
|
||||
|
||||
final Collection<Integer> loanStatuses = new ArrayList<Integer>(Arrays.asList(LoanStatus.SUBMITTED_AND_PENDING_APPROVAL.getValue(),
|
||||
|
||||
+2
-2
@@ -15,7 +15,7 @@ import org.mifosplatform.accounting.common.AccountingEnumerations;
|
||||
import org.mifosplatform.infrastructure.core.data.EnumOptionData;
|
||||
import org.mifosplatform.infrastructure.core.domain.JdbcSupport;
|
||||
import org.mifosplatform.infrastructure.core.service.DateUtils;
|
||||
import org.mifosplatform.infrastructure.core.service.TenantAwareRoutingDataSource;
|
||||
import org.mifosplatform.infrastructure.core.service.RoutingDataSource;
|
||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||
import org.mifosplatform.organisation.monetary.data.CurrencyData;
|
||||
import org.mifosplatform.portfolio.charge.data.ChargeData;
|
||||
@@ -37,7 +37,7 @@ public class LoanProductReadPlatformServiceImpl implements LoanProductReadPlatfo
|
||||
|
||||
@Autowired
|
||||
public LoanProductReadPlatformServiceImpl(final PlatformSecurityContext context,
|
||||
final ChargeReadPlatformService chargeReadPlatformService, final TenantAwareRoutingDataSource dataSource) {
|
||||
final ChargeReadPlatformService chargeReadPlatformService, final RoutingDataSource dataSource) {
|
||||
this.context = context;
|
||||
this.chargeReadPlatformService = chargeReadPlatformService;
|
||||
this.jdbcTemplate = new JdbcTemplate(dataSource);
|
||||
|
||||
+2
-2
@@ -13,7 +13,7 @@ import org.apache.commons.lang.StringUtils;
|
||||
import org.joda.time.DateTime;
|
||||
import org.mifosplatform.infrastructure.core.data.EnumOptionData;
|
||||
import org.mifosplatform.infrastructure.core.domain.JdbcSupport;
|
||||
import org.mifosplatform.infrastructure.core.service.TenantAwareRoutingDataSource;
|
||||
import org.mifosplatform.infrastructure.core.service.RoutingDataSource;
|
||||
import org.mifosplatform.portfolio.note.data.NoteData;
|
||||
import org.mifosplatform.portfolio.note.domain.NoteType;
|
||||
import org.mifosplatform.portfolio.note.exception.NoteNotFoundException;
|
||||
@@ -29,7 +29,7 @@ public class NoteReadPlatformServiceImpl implements NoteReadPlatformService {
|
||||
private final JdbcTemplate jdbcTemplate;
|
||||
|
||||
@Autowired
|
||||
public NoteReadPlatformServiceImpl(final TenantAwareRoutingDataSource dataSource) {
|
||||
public NoteReadPlatformServiceImpl(final RoutingDataSource dataSource) {
|
||||
this.jdbcTemplate = new JdbcTemplate(dataSource);
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -20,7 +20,7 @@ import org.mifosplatform.infrastructure.core.domain.JdbcSupport;
|
||||
import org.mifosplatform.infrastructure.core.service.DateUtils;
|
||||
import org.mifosplatform.infrastructure.core.service.Page;
|
||||
import org.mifosplatform.infrastructure.core.service.PaginationHelper;
|
||||
import org.mifosplatform.infrastructure.core.service.TenantAwareRoutingDataSource;
|
||||
import org.mifosplatform.infrastructure.core.service.RoutingDataSource;
|
||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||
import org.mifosplatform.organisation.monetary.data.CurrencyData;
|
||||
import org.mifosplatform.portfolio.client.data.ClientData;
|
||||
@@ -64,7 +64,7 @@ public class SavingsAccountReadPlatformServiceImpl implements SavingsAccountRead
|
||||
private final SavingAccountMapper savingAccountMapper = new SavingAccountMapper();
|
||||
|
||||
@Autowired
|
||||
public SavingsAccountReadPlatformServiceImpl(final PlatformSecurityContext context, final TenantAwareRoutingDataSource dataSource,
|
||||
public SavingsAccountReadPlatformServiceImpl(final PlatformSecurityContext context, final RoutingDataSource dataSource,
|
||||
final ClientReadPlatformService clientReadPlatformService, final GroupReadPlatformService groupReadPlatformService,
|
||||
final SavingsProductReadPlatformService savingProductReadPlatformService,
|
||||
final SavingsDropdownReadPlatformService dropdownReadPlatformService) {
|
||||
|
||||
+2
-2
@@ -14,7 +14,7 @@ import org.joda.time.MonthDay;
|
||||
import org.mifosplatform.accounting.common.AccountingEnumerations;
|
||||
import org.mifosplatform.infrastructure.core.data.EnumOptionData;
|
||||
import org.mifosplatform.infrastructure.core.domain.JdbcSupport;
|
||||
import org.mifosplatform.infrastructure.core.service.TenantAwareRoutingDataSource;
|
||||
import org.mifosplatform.infrastructure.core.service.RoutingDataSource;
|
||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||
import org.mifosplatform.organisation.monetary.data.CurrencyData;
|
||||
import org.mifosplatform.portfolio.savings.data.SavingsProductData;
|
||||
@@ -34,7 +34,7 @@ public class SavingsProductReadPlatformServiceImpl implements SavingsProductRead
|
||||
private final SavingProductLookupMapper savingsProductLookupsRowMapper = new SavingProductLookupMapper();
|
||||
|
||||
@Autowired
|
||||
public SavingsProductReadPlatformServiceImpl(final PlatformSecurityContext context, final TenantAwareRoutingDataSource dataSource) {
|
||||
public SavingsProductReadPlatformServiceImpl(final PlatformSecurityContext context, final RoutingDataSource dataSource) {
|
||||
this.context = context;
|
||||
jdbcTemplate = new JdbcTemplate(dataSource);
|
||||
}
|
||||
|
||||
+2
-2
@@ -10,7 +10,7 @@ import java.sql.SQLException;
|
||||
import java.util.Collection;
|
||||
|
||||
import org.mifosplatform.infrastructure.core.domain.JdbcSupport;
|
||||
import org.mifosplatform.infrastructure.core.service.TenantAwareRoutingDataSource;
|
||||
import org.mifosplatform.infrastructure.core.service.RoutingDataSource;
|
||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||
import org.mifosplatform.portfolio.search.data.SearchConditions;
|
||||
import org.mifosplatform.portfolio.search.data.SearchData;
|
||||
@@ -28,7 +28,7 @@ public class SearchReadPlatformServiceImpl implements SearchReadPlatformService
|
||||
private final PlatformSecurityContext context;
|
||||
|
||||
@Autowired
|
||||
public SearchReadPlatformServiceImpl(final PlatformSecurityContext context, final TenantAwareRoutingDataSource dataSource) {
|
||||
public SearchReadPlatformServiceImpl(final PlatformSecurityContext context, final RoutingDataSource dataSource) {
|
||||
this.context = context;
|
||||
this.namedParameterjdbcTemplate = new NamedParameterJdbcTemplate(dataSource);
|
||||
}
|
||||
|
||||
-31
@@ -1,31 +0,0 @@
|
||||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.mifosplatform.scheduledjobs;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import org.mifosplatform.scheduledjobs.service.ScheduledJobRunnerService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class ApplyAnnualFeeForSavingsScheduledJob {
|
||||
|
||||
private final static Logger logger = LoggerFactory.getLogger(ApplyAnnualFeeForSavingsScheduledJob.class);
|
||||
|
||||
private final ScheduledJobRunnerService scheduledJobRunnerService;
|
||||
|
||||
public ApplyAnnualFeeForSavingsScheduledJob(final ScheduledJobRunnerService scheduledJobRunnerService) {
|
||||
this.scheduledJobRunnerService = scheduledJobRunnerService;
|
||||
}
|
||||
|
||||
public void execute() {
|
||||
logger.info("Running Job ApplyAnnualFeeForSavingsScheduledJob " + new Date());
|
||||
|
||||
this.scheduledJobRunnerService.applyAnnualFeeForSavings();
|
||||
|
||||
logger.info("Finishing Job ApplyAnnualFeeForSavingsScheduledJob " + new Date());
|
||||
}
|
||||
}
|
||||
-31
@@ -1,31 +0,0 @@
|
||||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.mifosplatform.scheduledjobs;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import org.mifosplatform.scheduledjobs.service.ScheduledJobRunnerService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class ApplyHolidaysToLoansScheduledJob {
|
||||
|
||||
private final static Logger logger = LoggerFactory.getLogger(ApplyHolidaysToLoansScheduledJob.class);
|
||||
|
||||
private final ScheduledJobRunnerService scheduledJobRunnerService;
|
||||
|
||||
public ApplyHolidaysToLoansScheduledJob(final ScheduledJobRunnerService scheduledJobRunnerService) {
|
||||
this.scheduledJobRunnerService = scheduledJobRunnerService;
|
||||
}
|
||||
|
||||
public void execute() {
|
||||
logger.info("Running Job ApplyHolidaysToLoansScheduledJob " + new Date());
|
||||
|
||||
this.scheduledJobRunnerService.applyHolidaysToLoans();
|
||||
|
||||
logger.info("Finishing Job ApplyHolidaysToLoansScheduledJob " + new Date());
|
||||
}
|
||||
}
|
||||
-31
@@ -1,31 +0,0 @@
|
||||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.mifosplatform.scheduledjobs;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import org.mifosplatform.scheduledjobs.service.ScheduledJobRunnerService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class UpdateLoanArrearsAgeingScheduledJob {
|
||||
|
||||
private final static Logger logger = LoggerFactory.getLogger(UpdateLoanArrearsAgeingScheduledJob.class);
|
||||
|
||||
private final ScheduledJobRunnerService scheduledJobRunnerService;
|
||||
|
||||
public UpdateLoanArrearsAgeingScheduledJob(final ScheduledJobRunnerService scheduledJobRunnerService) {
|
||||
this.scheduledJobRunnerService = scheduledJobRunnerService;
|
||||
}
|
||||
|
||||
public void execute() {
|
||||
logger.info("Running Job UpdateLoanArrearsAgeingScheduledJob " + new Date());
|
||||
|
||||
this.scheduledJobRunnerService.updateLoanArrearsAgeingDetails();
|
||||
|
||||
logger.info("Finishing Job UpdateLoanArrearsAgeingScheduledJob " + new Date());
|
||||
}
|
||||
}
|
||||
-31
@@ -1,31 +0,0 @@
|
||||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.mifosplatform.scheduledjobs;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import org.mifosplatform.scheduledjobs.service.ScheduledJobRunnerService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class UpdateLoanPaidInAdvanceScheduledJob {
|
||||
|
||||
private final static Logger logger = LoggerFactory.getLogger(UpdateLoanPaidInAdvanceScheduledJob.class);
|
||||
|
||||
private final ScheduledJobRunnerService scheduledJobRunnerService;
|
||||
|
||||
public UpdateLoanPaidInAdvanceScheduledJob(final ScheduledJobRunnerService scheduledJobRunnerService) {
|
||||
this.scheduledJobRunnerService = scheduledJobRunnerService;
|
||||
}
|
||||
|
||||
public void execute() {
|
||||
logger.info("Running Job UpdateLoanPaidInAdvanceScheduledJob " + new Date());
|
||||
|
||||
this.scheduledJobRunnerService.updateLoanPaidInAdvance();
|
||||
|
||||
logger.info("Finishing Job UpdateLoanPaidInAdvanceScheduledJob " + new Date());
|
||||
}
|
||||
}
|
||||
-34
@@ -1,34 +0,0 @@
|
||||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.mifosplatform.scheduledjobs;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import org.mifosplatform.scheduledjobs.service.ScheduledJobRunnerService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Update loan summary
|
||||
*/
|
||||
public class UpdateLoanSummariesScheduledJob {
|
||||
|
||||
private final static Logger logger = LoggerFactory.getLogger(UpdateLoanSummariesScheduledJob.class);
|
||||
|
||||
private final ScheduledJobRunnerService scheduledJobRunnerService;
|
||||
|
||||
public UpdateLoanSummariesScheduledJob(final ScheduledJobRunnerService scheduledJobRunnerService) {
|
||||
this.scheduledJobRunnerService = scheduledJobRunnerService;
|
||||
}
|
||||
|
||||
public void execute() {
|
||||
logger.info("Running Job UpdateLoanSummariesScheduledJob " + new Date());
|
||||
|
||||
this.scheduledJobRunnerService.updateLoanSummaryDetails();
|
||||
|
||||
logger.info("Finishing Job UpdateLoanSummariesScheduledJob " + new Date());
|
||||
}
|
||||
}
|
||||
Executable
+76
@@ -0,0 +1,76 @@
|
||||
package org.mifosplatform.scheduledjobs.annotation;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.springframework.core.env.StandardEnvironment;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
|
||||
import org.springframework.core.io.support.ResourcePatternResolver;
|
||||
import org.springframework.core.type.MethodMetadata;
|
||||
import org.springframework.core.type.classreading.CachingMetadataReaderFactory;
|
||||
import org.springframework.core.type.classreading.MetadataReader;
|
||||
import org.springframework.core.type.classreading.MetadataReaderFactory;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
/**
|
||||
* Parser to find method which is marked with CronTargetMethod annotation
|
||||
*
|
||||
*/
|
||||
public class CronMethodParser {
|
||||
|
||||
private static final String SEARCH_PACKAGE = "org.mifosplatform.";
|
||||
|
||||
private static final String CRON_ANNOTATION_ATTRIBUTE_NAME = "jobName";
|
||||
|
||||
private static final String RESOURCE_PATTERN = "**/*.class";
|
||||
|
||||
private static final Map<String, String[]> targetMethosMap = new HashMap<String, String[]>();
|
||||
|
||||
private static final ResourcePatternResolver resourcePatternResolver = new PathMatchingResourcePatternResolver();
|
||||
|
||||
private static final MetadataReaderFactory metadataReaderFactory = new CachingMetadataReaderFactory(resourcePatternResolver);
|
||||
|
||||
public static final int CLASS_INDEX = 0;
|
||||
|
||||
public static final int METHOD_INDEX = 1;
|
||||
|
||||
public static String[] findTargetMethodDetails(String attriuteValue) throws IOException {
|
||||
if (!targetMethosMap.containsKey(attriuteValue)) {
|
||||
findAnnotationMethods(CronTargetMethod.class, CRON_ANNOTATION_ATTRIBUTE_NAME);
|
||||
}
|
||||
return targetMethosMap.get(attriuteValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* method adds all the method names to map with annotation attribute value
|
||||
* as key
|
||||
*/
|
||||
private static void findAnnotationMethods(Class<? extends Annotation> annotationClass, String attributeName) throws IOException {
|
||||
String basePackagePath = ClassUtils.convertClassNameToResourcePath(new StandardEnvironment()
|
||||
.resolveRequiredPlaceholders(SEARCH_PACKAGE));
|
||||
String packageSearchPath = ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX + basePackagePath + "/" + RESOURCE_PATTERN;
|
||||
Resource[] resources = resourcePatternResolver.getResources(packageSearchPath);
|
||||
for (Resource resource : resources) {
|
||||
if (resource.isReadable()) {
|
||||
MetadataReader metadataReader = metadataReaderFactory.getMetadataReader(resource);
|
||||
Set<MethodMetadata> metadataSet = metadataReader.getAnnotationMetadata().getAnnotatedMethods(annotationClass.getName());
|
||||
if (metadataSet != null && metadataSet.size() > 0) {
|
||||
for (MethodMetadata metadata : metadataSet) {
|
||||
Map<String, Object> attributes = metadata.getAnnotationAttributes(annotationClass.getName());
|
||||
String attributeValue = (String) attributes.get(attributeName);
|
||||
String className = metadata.getDeclaringClassName();
|
||||
if (attributeValue == null || attributeValue.trim().length() < 1) {
|
||||
attributeValue = className.substring(className.lastIndexOf(".") + 1);
|
||||
}
|
||||
String[] mapVal = { className, metadata.getMethodName() };
|
||||
targetMethosMap.put(attributeValue, mapVal);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Executable
+18
@@ -0,0 +1,18 @@
|
||||
package org.mifosplatform.scheduledjobs.annotation;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Annotation that marks a method to be picked while scheduling a cron jobs.
|
||||
*
|
||||
*/
|
||||
|
||||
@Target(ElementType.METHOD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface CronTargetMethod {
|
||||
|
||||
String jobName() default "";
|
||||
}
|
||||
Executable
+117
@@ -0,0 +1,117 @@
|
||||
package org.mifosplatform.scheduledjobs.domain;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Temporal;
|
||||
import javax.persistence.TemporalType;
|
||||
|
||||
import org.springframework.data.jpa.domain.AbstractPersistable;
|
||||
|
||||
@Entity
|
||||
@Table(name = "scheduled_jobs")
|
||||
public class ScheduledJobDetails extends AbstractPersistable<Long> {
|
||||
|
||||
@Column(name = "job_name")
|
||||
private String jobName;
|
||||
|
||||
@Column(name = "job_display_name")
|
||||
private String jobDisplayName;
|
||||
|
||||
@Column(name = "cron_expression")
|
||||
private String croneExpression;
|
||||
|
||||
@Column(name = "create_time")
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date createTime;
|
||||
|
||||
@Column(name = "task_priority")
|
||||
private Short taskPriority;
|
||||
|
||||
@Column(name = "group_name")
|
||||
private String groupName;
|
||||
|
||||
@Column(name = "previous_run_start_time")
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date previousRunStartTime;
|
||||
|
||||
@Column(name = "next_run_time")
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date nextRunTime;
|
||||
|
||||
@Column(name = "trigger_key")
|
||||
private String triggerKey;
|
||||
|
||||
@Column(name = "job_initializing_errorlog")
|
||||
private String errorLog;
|
||||
|
||||
@Column(name = "is_active")
|
||||
private boolean activeSchedular;
|
||||
|
||||
public ScheduledJobDetails() {
|
||||
|
||||
}
|
||||
|
||||
public ScheduledJobDetails(final String jobName, final String jobDisplayName, final String croneExpression, Date createTime,
|
||||
final Short taskPriority, final String groupName, final Date previousRunStartTime, final Date nextRunTime,
|
||||
final String triggKey, final String errorLog, final boolean activeSchedular) {
|
||||
this.jobName = jobName;
|
||||
this.jobDisplayName = jobDisplayName;
|
||||
this.croneExpression = croneExpression;
|
||||
this.createTime = createTime;
|
||||
this.taskPriority = taskPriority;
|
||||
this.groupName = groupName;
|
||||
this.previousRunStartTime = previousRunStartTime;
|
||||
this.nextRunTime = nextRunTime;
|
||||
this.triggerKey = triggKey;
|
||||
this.errorLog = errorLog;
|
||||
this.activeSchedular = activeSchedular;
|
||||
}
|
||||
|
||||
public String getJobName() {
|
||||
return this.jobName;
|
||||
}
|
||||
|
||||
public String getCroneExpression() {
|
||||
return this.croneExpression;
|
||||
}
|
||||
|
||||
public Short getTaskPriority() {
|
||||
return this.taskPriority;
|
||||
}
|
||||
|
||||
public String getGroupName() {
|
||||
return this.groupName;
|
||||
}
|
||||
|
||||
public String getTriggerKey() {
|
||||
return this.triggerKey;
|
||||
}
|
||||
|
||||
public boolean isActiveSchedular() {
|
||||
return this.activeSchedular;
|
||||
}
|
||||
|
||||
public void updateCroneExpression(String croneExpression) {
|
||||
this.croneExpression = croneExpression;
|
||||
}
|
||||
|
||||
public void updatePreviousRunStartTime(Date previousRunStartTime) {
|
||||
this.previousRunStartTime = previousRunStartTime;
|
||||
}
|
||||
|
||||
public void updateNextRunTime(Date nextRunTime) {
|
||||
this.nextRunTime = nextRunTime;
|
||||
}
|
||||
|
||||
public void updateTriggerKey(String triggerKey) {
|
||||
this.triggerKey = triggerKey;
|
||||
}
|
||||
|
||||
public void updateErrorLog(String errorLog) {
|
||||
this.errorLog = errorLog;
|
||||
}
|
||||
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
package org.mifosplatform.scheduledjobs.domain;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
|
||||
public interface ScheduledJobDetailsRepository extends JpaRepository<ScheduledJobDetails, Long>,
|
||||
JpaSpecificationExecutor<ScheduledJobDetails> {
|
||||
|
||||
@Query("from ScheduledJobDetails jobDetails where jobDetails.triggerKey = :triggerKey")
|
||||
ScheduledJobDetails findByTriggerKey(@Param("triggerKey") String triggerKey);
|
||||
|
||||
}
|
||||
Executable
+62
@@ -0,0 +1,62 @@
|
||||
package org.mifosplatform.scheduledjobs.domain;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Temporal;
|
||||
import javax.persistence.TemporalType;
|
||||
|
||||
import org.springframework.data.jpa.domain.AbstractPersistable;
|
||||
|
||||
@Entity
|
||||
@Table(name = "scheduled_job_runhistory")
|
||||
public class ScheduledJobRunHistory extends AbstractPersistable<Long> {
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "job_id")
|
||||
private ScheduledJobDetails scheduledJobDetails;
|
||||
|
||||
@Column(name = "version")
|
||||
private Long version;
|
||||
|
||||
@Column(name = "start_time")
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date startTime;
|
||||
|
||||
@Column(name = "end_time")
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date endTime;
|
||||
|
||||
@Column(name = "status")
|
||||
private String status;
|
||||
|
||||
@Column(name = "errormessage")
|
||||
private String errorMessage;
|
||||
|
||||
@Column(name = "triggertype")
|
||||
private String triggerType;
|
||||
|
||||
@Column(name = "errorlog")
|
||||
private String errorLog;
|
||||
|
||||
public ScheduledJobRunHistory() {
|
||||
|
||||
}
|
||||
|
||||
public ScheduledJobRunHistory(final ScheduledJobDetails scheduledJobDetails, final Long version, final Date startTime,
|
||||
final Date endTime, final String status, final String errorMessage, final String triggerType, final String errorLog) {
|
||||
this.scheduledJobDetails = scheduledJobDetails;
|
||||
this.version = version;
|
||||
this.startTime = startTime;
|
||||
this.endTime = endTime;
|
||||
this.status = status;
|
||||
this.errorMessage = errorMessage;
|
||||
this.triggerType = triggerType;
|
||||
this.errorLog = errorLog;
|
||||
}
|
||||
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
package org.mifosplatform.scheduledjobs.domain;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
|
||||
public interface ScheduledJobRunHistoryRepository extends JpaRepository<ScheduledJobRunHistory, Long>,
|
||||
JpaSpecificationExecutor<ScheduledJobRunHistory> {
|
||||
|
||||
@Query("select max(sjrh.version) from ScheduledJobRunHistory sjrh where sjrh.scheduledJobDetails.triggerKey = :triggerKey")
|
||||
Long findMaxVersionByTriggerKey(@Param("triggerKey") String triggerKey);
|
||||
|
||||
}
|
||||
Executable
+172
@@ -0,0 +1,172 @@
|
||||
package org.mifosplatform.scheduledjobs.service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
import org.mifosplatform.infrastructure.core.domain.MifosPlatformTenant;
|
||||
import org.mifosplatform.infrastructure.core.service.ThreadLocalContextUtil;
|
||||
import org.mifosplatform.infrastructure.security.service.TenantDetailsService;
|
||||
import org.mifosplatform.scheduledjobs.annotation.CronMethodParser;
|
||||
import org.mifosplatform.scheduledjobs.domain.ScheduledJobDetails;
|
||||
import org.quartz.JobDataMap;
|
||||
import org.quartz.JobDetail;
|
||||
import org.quartz.JobKey;
|
||||
import org.quartz.SchedulerException;
|
||||
import org.quartz.Trigger;
|
||||
import org.quartz.TriggerKey;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.scheduling.quartz.CronTriggerFactoryBean;
|
||||
import org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean;
|
||||
import org.springframework.scheduling.quartz.SchedulerFactoryBean;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* Service class to create and load batch jobs to Scheduler using
|
||||
* {@link SchedulerFactoryBean} ,{@link MethodInvokingJobDetailFactoryBean} and
|
||||
* {@link CronTriggerFactoryBean}
|
||||
*
|
||||
*/
|
||||
@Service
|
||||
public class JobRegisterService {
|
||||
|
||||
private final ApplicationContext applicationContext;
|
||||
|
||||
private final SchedulerFactoryBean schedulerFactoryBean;
|
||||
|
||||
private final SchedularService schedularService;
|
||||
|
||||
private final TenantDetailsService tenantDetailsService;
|
||||
|
||||
@Autowired
|
||||
public JobRegisterService(final ApplicationContext applicationContext, final SchedulerFactoryBean schedulerFactoryBean,
|
||||
final SchedularService schedularService, final TenantDetailsService tenantDetailsService) {
|
||||
this.applicationContext = applicationContext;
|
||||
this.schedularService = schedularService;
|
||||
this.schedulerFactoryBean = schedulerFactoryBean;
|
||||
this.tenantDetailsService = tenantDetailsService;
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
public void loadAllJobs() {
|
||||
List<MifosPlatformTenant> allTenants = this.tenantDetailsService.findAllTenants();
|
||||
for (MifosPlatformTenant tenant : allTenants) {
|
||||
ThreadLocalContextUtil.setTenant(tenant);
|
||||
List<ScheduledJobDetails> scheduledJobDetails = this.schedularService.getScheduledJobDetails();
|
||||
for (ScheduledJobDetails jobDetails : scheduledJobDetails) {
|
||||
if (jobDetails.isActiveSchedular()) {
|
||||
scheduleJob(jobDetails);
|
||||
this.schedularService.saveOrUpdate(jobDetails);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void excuteJob(TriggerKey triggerKey) {
|
||||
JobDataMap jobDataMap = new JobDataMap();
|
||||
jobDataMap.put(SchedularServiceConstants.TRIGGER_TYPE_REFERENCE, SchedularServiceConstants.TRIGGER_TYPE_APPLICATION);
|
||||
try {
|
||||
JobKey jobKey = schedulerFactoryBean.getScheduler().getTrigger(triggerKey).getJobKey();
|
||||
schedulerFactoryBean.getScheduler().triggerJob(jobKey);
|
||||
} catch (SchedulerException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void rescheduleJob(ScheduledJobDetails scheduledJobDetails) {
|
||||
try {
|
||||
String triggerIdentity = scheduledJobDetails.getTriggerKey();
|
||||
String[] triggerKeyIds = triggerIdentity.split(SchedularServiceConstants.TRIGGER_KEY_SEPERATOR);
|
||||
TriggerKey triggerKey = new TriggerKey(triggerKeyIds[0].trim(), triggerKeyIds[1].trim());
|
||||
JobDetail jobDetail = createJobDetail(scheduledJobDetails);
|
||||
Trigger trigger = createTrigger(scheduledJobDetails, jobDetail);
|
||||
schedulerFactoryBean.getScheduler().rescheduleJob(triggerKey, trigger);
|
||||
scheduledJobDetails.updateTriggerKey(getTriggerKey(trigger.getKey()));
|
||||
scheduledJobDetails.updateNextRunTime(trigger.getNextFireTime());
|
||||
scheduledJobDetails.updateErrorLog(null);
|
||||
this.schedularService.saveOrUpdate(scheduledJobDetails);
|
||||
} catch (Throwable throwable) {
|
||||
String stackTrace = getStackTraceAsString(throwable);
|
||||
scheduledJobDetails.updateErrorLog(stackTrace);
|
||||
this.schedularService.saveOrUpdate(scheduledJobDetails);
|
||||
}
|
||||
}
|
||||
|
||||
private void scheduleJob(ScheduledJobDetails scheduledJobDetails) {
|
||||
try {
|
||||
JobDetail jobDetail = createJobDetail(scheduledJobDetails);
|
||||
Trigger trigger = createTrigger(scheduledJobDetails, jobDetail);
|
||||
schedulerFactoryBean.getScheduler().scheduleJob(jobDetail, trigger);
|
||||
scheduledJobDetails.updateTriggerKey(getTriggerKey(trigger.getKey()));
|
||||
scheduledJobDetails.updateNextRunTime(trigger.getNextFireTime());
|
||||
scheduledJobDetails.updateErrorLog(null);
|
||||
} catch (Throwable throwable) {
|
||||
String stackTrace = getStackTraceAsString(throwable);
|
||||
scheduledJobDetails.updateErrorLog(stackTrace);
|
||||
}
|
||||
}
|
||||
|
||||
private JobDetail createJobDetail(ScheduledJobDetails scheduledJobDetails) throws Exception {
|
||||
MifosPlatformTenant tenant = ThreadLocalContextUtil.getTenant();
|
||||
String[] jobDetails = CronMethodParser.findTargetMethodDetails(scheduledJobDetails.getJobName());
|
||||
String[] beanNames = this.applicationContext.getBeanNamesForType(Class.forName(jobDetails[CronMethodParser.CLASS_INDEX]));
|
||||
Object targetObject = this.applicationContext.getBean(beanNames[0]);
|
||||
for(String beanName:beanNames){
|
||||
Object nextObject = this.applicationContext.getBean(beanName);
|
||||
if (nextObject != null && !targetObject.getClass().isAssignableFrom(nextObject.getClass())){
|
||||
targetObject = nextObject;
|
||||
}
|
||||
}
|
||||
MethodInvokingJobDetailFactoryBean jobDetailFactoryBean = new MethodInvokingJobDetailFactoryBean();
|
||||
jobDetailFactoryBean.setName(scheduledJobDetails.getJobName() + "JobDetail-" + tenant.getId());
|
||||
jobDetailFactoryBean.setTargetObject(targetObject);
|
||||
jobDetailFactoryBean.setTargetMethod(jobDetails[CronMethodParser.METHOD_INDEX]);
|
||||
jobDetailFactoryBean.setGroup(scheduledJobDetails.getGroupName());
|
||||
jobDetailFactoryBean.setConcurrent(false);
|
||||
jobDetailFactoryBean.afterPropertiesSet();
|
||||
return jobDetailFactoryBean.getObject();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param scheduledJobDetails
|
||||
* @return
|
||||
*/
|
||||
private Trigger createTrigger(ScheduledJobDetails scheduledJobDetails, JobDetail jobDetail) {
|
||||
MifosPlatformTenant tenant = ThreadLocalContextUtil.getTenant();
|
||||
CronTriggerFactoryBean cronTriggerFactoryBean = new CronTriggerFactoryBean();
|
||||
cronTriggerFactoryBean.setName(scheduledJobDetails.getJobName() + "Trigger-" + tenant.getId());
|
||||
cronTriggerFactoryBean.setJobDetail(jobDetail);
|
||||
JobDataMap jobDataMap = new JobDataMap();
|
||||
jobDataMap.put(SchedularServiceConstants.TENANT_IDENTIFIER, tenant.getTenantIdentifier());
|
||||
cronTriggerFactoryBean.setJobDataMap(jobDataMap);
|
||||
TimeZone timeZone = TimeZone.getTimeZone(tenant.getTimezoneId());
|
||||
cronTriggerFactoryBean.setTimeZone(timeZone);
|
||||
cronTriggerFactoryBean.setGroup(scheduledJobDetails.getGroupName());
|
||||
cronTriggerFactoryBean.setCronExpression(scheduledJobDetails.getCroneExpression());
|
||||
cronTriggerFactoryBean.setPriority(scheduledJobDetails.getTaskPriority());
|
||||
cronTriggerFactoryBean.afterPropertiesSet();
|
||||
return cronTriggerFactoryBean.getObject();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param throwable
|
||||
* @return
|
||||
*/
|
||||
private String getStackTraceAsString(Throwable throwable) {
|
||||
StackTraceElement[] stackTraceElements = throwable.getStackTrace();
|
||||
StringBuffer sb = new StringBuffer(throwable.toString());
|
||||
for (StackTraceElement element : stackTraceElements) {
|
||||
sb.append("\n \t at ").append(element.getClassName()).append(".").append(element.getMethodName()).append("(")
|
||||
.append(element.getLineNumber()).append(")");
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private String getTriggerKey(TriggerKey triggerKey) {
|
||||
return triggerKey.getName() + SchedularServiceConstants.TRIGGER_KEY_SEPERATOR + triggerKey.getGroup();
|
||||
}
|
||||
|
||||
}
|
||||
Executable
+20
@@ -0,0 +1,20 @@
|
||||
package org.mifosplatform.scheduledjobs.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.mifosplatform.scheduledjobs.domain.ScheduledJobDetails;
|
||||
import org.mifosplatform.scheduledjobs.domain.ScheduledJobRunHistory;
|
||||
|
||||
public interface SchedularService {
|
||||
|
||||
public List<ScheduledJobDetails> getScheduledJobDetails();
|
||||
|
||||
public ScheduledJobDetails getByTriggerKey(String triggerKey);
|
||||
|
||||
public void saveOrUpdate(ScheduledJobDetails scheduledJobDetails);
|
||||
|
||||
public void saveOrUpdate(ScheduledJobDetails scheduledJobDetails, ScheduledJobRunHistory scheduledJobRunHistory);
|
||||
|
||||
public Long getMaxVersionBy(String triggerKey);
|
||||
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package org.mifosplatform.scheduledjobs.service;
|
||||
|
||||
public interface SchedularServiceConstants {
|
||||
|
||||
public static final String TRIGGER_KEY_SEPERATOR = " _ ";
|
||||
public static final String TRIGGER_TYPE_CRON = "cron";
|
||||
public static final String TRIGGER_TYPE_APPLICATION = "application";
|
||||
public static final String TRIGGER_TYPE_REFERENCE = "TRIGGER_TYPE_REFERENCE";
|
||||
public static final String SCHEDULAR_EXCEPTION = "SchedulerException";
|
||||
public static final String JOB_EXECUTION_EXCEPTION = "JobExecutionException";
|
||||
public static final String JOB_METHOD_INVOCATION_FAILED_EXCEPTION = "JobMethodInvocationFailedException";
|
||||
public static final String STATUS_SUCCESS = "success";
|
||||
public static final String STATUS_FAILED = "failed";
|
||||
public static final String DEFAULT_LISTENER_NAME = "Global Listner";
|
||||
public static final int STACK_TRACE_LEVEL = 7;
|
||||
public static final String TENANT_IDENTIFIER = "tenantIdentifier";
|
||||
}
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
package org.mifosplatform.scheduledjobs.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.mifosplatform.scheduledjobs.domain.ScheduledJobDetails;
|
||||
import org.mifosplatform.scheduledjobs.domain.ScheduledJobDetailsRepository;
|
||||
import org.mifosplatform.scheduledjobs.domain.ScheduledJobRunHistory;
|
||||
import org.mifosplatform.scheduledjobs.domain.ScheduledJobRunHistoryRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@Service
|
||||
public class SchedularServiceJpaRepositoryImpl implements SchedularService {
|
||||
|
||||
private final ScheduledJobDetailsRepository scheduledJobDetailsRepository;
|
||||
|
||||
private final ScheduledJobRunHistoryRepository scheduledJobRunHistoryRepository;
|
||||
|
||||
@Autowired
|
||||
public SchedularServiceJpaRepositoryImpl(final ScheduledJobDetailsRepository scheduledJobDetailsRepository,
|
||||
final ScheduledJobRunHistoryRepository scheduledJobRunHistoryRepository) {
|
||||
this.scheduledJobDetailsRepository = scheduledJobDetailsRepository;
|
||||
this.scheduledJobRunHistoryRepository = scheduledJobRunHistoryRepository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ScheduledJobDetails> getScheduledJobDetails() {
|
||||
return scheduledJobDetailsRepository.findAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ScheduledJobDetails getByTriggerKey(final String triggerKey) {
|
||||
return scheduledJobDetailsRepository.findByTriggerKey(triggerKey);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public void saveOrUpdate(final ScheduledJobDetails scheduledJobDetails) {
|
||||
this.scheduledJobDetailsRepository.save(scheduledJobDetails);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public void saveOrUpdate(final ScheduledJobDetails scheduledJobDetails, final ScheduledJobRunHistory scheduledJobRunHistory) {
|
||||
this.scheduledJobDetailsRepository.save(scheduledJobDetails);
|
||||
this.scheduledJobRunHistoryRepository.save(scheduledJobRunHistory);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getMaxVersionBy(final String triggerKey) {
|
||||
Long version = 0L;
|
||||
Long versionFromDB = scheduledJobRunHistoryRepository.findMaxVersionByTriggerKey(triggerKey);
|
||||
if (versionFromDB != null) {
|
||||
version = versionFromDB;
|
||||
}
|
||||
return version;
|
||||
}
|
||||
}
|
||||
+3
-5
@@ -10,10 +10,8 @@ public interface ScheduledJobRunnerService {
|
||||
void updateLoanSummaryDetails();
|
||||
|
||||
void updateLoanArrearsAgeingDetails();
|
||||
|
||||
|
||||
void updateLoanPaidInAdvance();
|
||||
|
||||
void applyAnnualFeeForSavings();
|
||||
|
||||
void applyHolidaysToLoans();
|
||||
|
||||
void applyAnnualFeeForSavings();
|
||||
}
|
||||
|
||||
+18
-51
@@ -7,12 +7,10 @@ package org.mifosplatform.scheduledjobs.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.mifosplatform.infrastructure.core.domain.MifosPlatformTenant;
|
||||
import org.mifosplatform.infrastructure.core.service.DataSourcePerTenantService;
|
||||
import org.mifosplatform.infrastructure.core.service.RoutingDataSourceServiceFactory;
|
||||
import org.mifosplatform.infrastructure.core.service.ThreadLocalContextUtil;
|
||||
import org.mifosplatform.infrastructure.security.service.TenantDetailsService;
|
||||
import org.mifosplatform.portfolio.loanaccount.service.LoanWritePlatformService;
|
||||
import org.mifosplatform.portfolio.savings.service.SavingsAccountWritePlatformService;
|
||||
import org.mifosplatform.scheduledjobs.annotation.CronTargetMethod;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -24,31 +22,22 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
public class ScheduledJobRunnerServiceImpl implements ScheduledJobRunnerService {
|
||||
|
||||
private final static Logger logger = LoggerFactory.getLogger(ScheduledJobRunnerServiceImpl.class);
|
||||
|
||||
private final TenantDetailsService tenantDetailsService;
|
||||
private final DataSourcePerTenantService dataSourcePerTenantService;
|
||||
private final RoutingDataSourceServiceFactory dataSourceServiceFactory;
|
||||
private final SavingsAccountWritePlatformService savingsAccountWritePlatformService;
|
||||
private final LoanWritePlatformService loanWritePlatformService;
|
||||
|
||||
@Autowired
|
||||
public ScheduledJobRunnerServiceImpl(final DataSourcePerTenantService dataSourcePerTenantService,
|
||||
final TenantDetailsService tenantDetailsService, final SavingsAccountWritePlatformService savingsAccountWritePlatformService,
|
||||
final LoanWritePlatformService loanWritePlatformService) {
|
||||
this.dataSourcePerTenantService = dataSourcePerTenantService;
|
||||
this.tenantDetailsService = tenantDetailsService;
|
||||
public ScheduledJobRunnerServiceImpl(final RoutingDataSourceServiceFactory dataSourceServiceFactory,
|
||||
final SavingsAccountWritePlatformService savingsAccountWritePlatformService) {
|
||||
this.dataSourceServiceFactory = dataSourceServiceFactory;
|
||||
this.savingsAccountWritePlatformService = savingsAccountWritePlatformService;
|
||||
this.loanWritePlatformService = loanWritePlatformService;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
@CronTargetMethod(jobName="Update loan Summary")
|
||||
public void updateLoanSummaryDetails() {
|
||||
|
||||
List<MifosPlatformTenant> allTenants = this.tenantDetailsService.findAllTenants();
|
||||
for (MifosPlatformTenant tenant : allTenants) {
|
||||
ThreadLocalContextUtil.setTenant(tenant);
|
||||
|
||||
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSourcePerTenantService.retrieveTenantAwareDataSource());
|
||||
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSourceServiceFactory.determineDataSourceService().retrieveDataSource());
|
||||
|
||||
StringBuilder updateSqlBuilder = new StringBuilder(900);
|
||||
updateSqlBuilder.append("update m_loan ");
|
||||
@@ -121,19 +110,15 @@ public class ScheduledJobRunnerServiceImpl implements ScheduledJobRunnerService
|
||||
|
||||
int result = jdbcTemplate.update(updateSqlBuilder.toString());
|
||||
|
||||
logger.info(tenant.getName() + ": Results affected by update: " + result);
|
||||
}
|
||||
logger.info(ThreadLocalContextUtil.getTenant().getName() + ": Results affected by update: " + result);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
@CronTargetMethod(jobName="Update Loan Arrears Ageing")
|
||||
public void updateLoanArrearsAgeingDetails() {
|
||||
|
||||
List<MifosPlatformTenant> allTenants = this.tenantDetailsService.findAllTenants();
|
||||
for (MifosPlatformTenant tenant : allTenants) {
|
||||
ThreadLocalContextUtil.setTenant(tenant);
|
||||
|
||||
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSourcePerTenantService.retrieveTenantAwareDataSource());
|
||||
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSourceServiceFactory.determineDataSourceService().retrieveDataSource());
|
||||
|
||||
jdbcTemplate.execute("truncate table m_loan_arrears_aging");
|
||||
|
||||
@@ -165,19 +150,15 @@ public class ScheduledJobRunnerServiceImpl implements ScheduledJobRunnerService
|
||||
|
||||
int result = jdbcTemplate.update(updateSqlBuilder.toString());
|
||||
|
||||
logger.info(tenant.getName() + ": Results affected by update: " + result);
|
||||
}
|
||||
logger.info(ThreadLocalContextUtil.getTenant().getName() + ": Results affected by update: " + result);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
@CronTargetMethod(jobName="Update Loan Paid In Advance")
|
||||
public void updateLoanPaidInAdvance() {
|
||||
|
||||
List<MifosPlatformTenant> allTenants = this.tenantDetailsService.findAllTenants();
|
||||
for (MifosPlatformTenant tenant : allTenants) {
|
||||
ThreadLocalContextUtil.setTenant(tenant);
|
||||
|
||||
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSourcePerTenantService.retrieveTenantAwareDataSource());
|
||||
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSourceServiceFactory.determineDataSourceService().retrieveDataSource());
|
||||
|
||||
jdbcTemplate.execute("truncate table m_loan_paid_in_advance");
|
||||
|
||||
@@ -200,19 +181,15 @@ public class ScheduledJobRunnerServiceImpl implements ScheduledJobRunnerService
|
||||
|
||||
int result = jdbcTemplate.update(updateSqlBuilder.toString());
|
||||
|
||||
logger.info(tenant.getName() + ": Results affected by update: " + result);
|
||||
}
|
||||
logger.info(ThreadLocalContextUtil.getTenant().getName() + ": Results affected by update: " + result);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
@CronTargetMethod(jobName="Apply Annual Fee For Savings")
|
||||
public void applyAnnualFeeForSavings() {
|
||||
|
||||
List<MifosPlatformTenant> allTenants = this.tenantDetailsService.findAllTenants();
|
||||
for (MifosPlatformTenant tenant : allTenants) {
|
||||
ThreadLocalContextUtil.setTenant(tenant);
|
||||
|
||||
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSourcePerTenantService.retrieveTenantAwareDataSource());
|
||||
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSourceServiceFactory.determineDataSourceService().retrieveDataSource());
|
||||
|
||||
String sql = "SELECT ms.id as savingsAccountId FROM m_savings_account ms WHERE ms.annual_fee_next_due_date <= NOW() ";
|
||||
List<Long> savingsIds = jdbcTemplate.queryForList(sql, Long.class);
|
||||
@@ -221,17 +198,7 @@ public class ScheduledJobRunnerServiceImpl implements ScheduledJobRunnerService
|
||||
this.savingsAccountWritePlatformService.applyAnnualFee(savingsId);
|
||||
}
|
||||
|
||||
logger.info(tenant.getName() + ": Results affected by update: " + savingsIds.size());
|
||||
}
|
||||
logger.info(ThreadLocalContextUtil.getTenant().getName() + ": Results affected by update: " + savingsIds.size());
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public void applyHolidaysToLoans() {
|
||||
List<MifosPlatformTenant> allTenants = this.tenantDetailsService.findAllTenants();
|
||||
for (MifosPlatformTenant tenant : allTenants) {
|
||||
ThreadLocalContextUtil.setTenant(tenant);
|
||||
this.loanWritePlatformService.applyHolidaysToLoans();
|
||||
}
|
||||
}
|
||||
}
|
||||
Executable
+113
@@ -0,0 +1,113 @@
|
||||
package org.mifosplatform.scheduledjobs.service;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import org.mifosplatform.infrastructure.core.domain.MifosPlatformTenant;
|
||||
import org.mifosplatform.infrastructure.core.service.ThreadLocalContextUtil;
|
||||
import org.mifosplatform.infrastructure.security.service.TenantDetailsService;
|
||||
import org.mifosplatform.scheduledjobs.domain.ScheduledJobDetails;
|
||||
import org.mifosplatform.scheduledjobs.domain.ScheduledJobRunHistory;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobExecutionException;
|
||||
import org.quartz.JobListener;
|
||||
import org.quartz.Trigger;
|
||||
import org.quartz.TriggerKey;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* Global job Listener class to set Tenant details to
|
||||
* {@link ThreadLocalContextUtil} for batch Job and stores the batch job status
|
||||
* to database after the execution
|
||||
*
|
||||
*/
|
||||
@Component
|
||||
public class SchedulerJobListener implements JobListener {
|
||||
|
||||
private int stackTraceLevel = 0;
|
||||
|
||||
private String name = SchedularServiceConstants.DEFAULT_LISTENER_NAME;
|
||||
|
||||
private final SchedularService schedularService;
|
||||
|
||||
private final TenantDetailsService tenantDetailsService;
|
||||
|
||||
@Autowired
|
||||
public SchedulerJobListener(SchedularService schedularService, TenantDetailsService tenantDetailsService) {
|
||||
this.schedularService = schedularService;
|
||||
this.tenantDetailsService = tenantDetailsService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void jobToBeExecuted(JobExecutionContext context) {
|
||||
String tenantIdentifier = context.getTrigger().getJobDataMap().getString(SchedularServiceConstants.TENANT_IDENTIFIER);
|
||||
MifosPlatformTenant tenant = this.tenantDetailsService.loadTenantById(tenantIdentifier);
|
||||
ThreadLocalContextUtil.setTenant(tenant);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void jobExecutionVetoed(JobExecutionContext context) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void jobWasExecuted(JobExecutionContext context, JobExecutionException jobException) {
|
||||
Trigger trigger = context.getTrigger();
|
||||
TriggerKey key = trigger.getKey();
|
||||
String triggerKey = key.getName() + SchedularServiceConstants.TRIGGER_KEY_SEPERATOR + key.getGroup();
|
||||
final ScheduledJobDetails scheduledJobDetails = schedularService.getByTriggerKey(triggerKey);
|
||||
Long version = schedularService.getMaxVersionBy(triggerKey) + 1;
|
||||
String status = SchedularServiceConstants.STATUS_SUCCESS;
|
||||
String errorMessage = null;
|
||||
String errorLog = null;
|
||||
if (jobException != null) {
|
||||
status = SchedularServiceConstants.STATUS_FAILED;
|
||||
stackTraceLevel = 0;
|
||||
Throwable throwable = getCauseFromException(jobException);
|
||||
stackTraceLevel = 0;
|
||||
StackTraceElement[] stackTraceElements = null;
|
||||
errorMessage = throwable.getMessage();
|
||||
stackTraceElements = throwable.getStackTrace();
|
||||
StringBuffer sb = new StringBuffer(throwable.toString());
|
||||
for (StackTraceElement element : stackTraceElements) {
|
||||
sb.append("\n \t at ").append(element.getClassName()).append(".").append(element.getMethodName()).append("(")
|
||||
.append(element.getLineNumber()).append(")");
|
||||
}
|
||||
errorLog = sb.toString();
|
||||
|
||||
}
|
||||
String triggerType = SchedularServiceConstants.TRIGGER_TYPE_CRON;
|
||||
if (context.getMergedJobDataMap().containsKey(SchedularServiceConstants.TRIGGER_TYPE_REFERENCE)) {
|
||||
triggerType = context.getMergedJobDataMap().getString(SchedularServiceConstants.TRIGGER_TYPE_REFERENCE);
|
||||
|
||||
}
|
||||
|
||||
scheduledJobDetails.updatePreviousRunStartTime(context.getFireTime());
|
||||
scheduledJobDetails.updateNextRunTime(trigger.getNextFireTime());
|
||||
|
||||
ScheduledJobRunHistory runHistory = new ScheduledJobRunHistory(scheduledJobDetails, version, context.getFireTime(), new Date(),
|
||||
status, errorMessage, triggerType, errorLog);
|
||||
// scheduledJobDetails.addRunHistory(runHistory);
|
||||
|
||||
schedularService.saveOrUpdate(scheduledJobDetails, runHistory);
|
||||
|
||||
}
|
||||
|
||||
private Throwable getCauseFromException(Throwable exception) {
|
||||
if (stackTraceLevel <= SchedularServiceConstants.STACK_TRACE_LEVEL
|
||||
&& exception.getCause() != null
|
||||
&& (exception.getCause().toString().contains(SchedularServiceConstants.SCHEDULAR_EXCEPTION)
|
||||
|| exception.getCause().toString().contains(SchedularServiceConstants.JOB_EXECUTION_EXCEPTION) || exception
|
||||
.getCause().toString().contains(SchedularServiceConstants.JOB_METHOD_INVOCATION_FAILED_EXCEPTION))) {
|
||||
stackTraceLevel++;
|
||||
return getCauseFromException(exception.getCause());
|
||||
} else if (exception.getCause() != null) { return exception.getCause(); }
|
||||
return exception;
|
||||
}
|
||||
|
||||
}
|
||||
+2
-2
@@ -12,7 +12,7 @@ import java.util.Collection;
|
||||
import java.util.Set;
|
||||
|
||||
import org.mifosplatform.infrastructure.core.domain.JdbcSupport;
|
||||
import org.mifosplatform.infrastructure.core.service.TenantAwareRoutingDataSource;
|
||||
import org.mifosplatform.infrastructure.core.service.RoutingDataSource;
|
||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||
import org.mifosplatform.organisation.office.data.OfficeData;
|
||||
import org.mifosplatform.organisation.office.service.OfficeReadPlatformService;
|
||||
@@ -37,7 +37,7 @@ public class AppUserReadPlatformServiceImpl implements AppUserReadPlatformServic
|
||||
private final AppUserRepository appUserRepository;
|
||||
|
||||
@Autowired
|
||||
public AppUserReadPlatformServiceImpl(final PlatformSecurityContext context, final TenantAwareRoutingDataSource dataSource,
|
||||
public AppUserReadPlatformServiceImpl(final PlatformSecurityContext context, final RoutingDataSource dataSource,
|
||||
final OfficeReadPlatformService officeReadPlatformService, final RoleReadPlatformService roleReadPlatformService,
|
||||
final AppUserRepository appUserRepository) {
|
||||
this.context = context;
|
||||
|
||||
+2
-2
@@ -9,7 +9,7 @@ import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Collection;
|
||||
|
||||
import org.mifosplatform.infrastructure.core.service.TenantAwareRoutingDataSource;
|
||||
import org.mifosplatform.infrastructure.core.service.RoutingDataSource;
|
||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||
import org.mifosplatform.useradministration.data.PermissionData;
|
||||
import org.slf4j.Logger;
|
||||
@@ -28,7 +28,7 @@ public class PermissionReadPlatformServiceImpl implements PermissionReadPlatform
|
||||
private final PlatformSecurityContext context;
|
||||
|
||||
@Autowired
|
||||
public PermissionReadPlatformServiceImpl(final PlatformSecurityContext context, final TenantAwareRoutingDataSource dataSource) {
|
||||
public PermissionReadPlatformServiceImpl(final PlatformSecurityContext context, final RoutingDataSource dataSource) {
|
||||
this.context = context;
|
||||
this.jdbcTemplate = new JdbcTemplate(dataSource);
|
||||
}
|
||||
|
||||
+2
-2
@@ -10,7 +10,7 @@ import java.sql.SQLException;
|
||||
import java.util.Collection;
|
||||
|
||||
import org.mifosplatform.infrastructure.core.domain.JdbcSupport;
|
||||
import org.mifosplatform.infrastructure.core.service.TenantAwareRoutingDataSource;
|
||||
import org.mifosplatform.infrastructure.core.service.RoutingDataSource;
|
||||
import org.mifosplatform.useradministration.data.RoleData;
|
||||
import org.mifosplatform.useradministration.exception.RoleNotFoundException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -26,7 +26,7 @@ public class RoleReadPlatformServiceImpl implements RoleReadPlatformService {
|
||||
private final RoleMapper roleRowMapper;
|
||||
|
||||
@Autowired
|
||||
public RoleReadPlatformServiceImpl(final TenantAwareRoutingDataSource dataSource) {
|
||||
public RoleReadPlatformServiceImpl(final RoutingDataSource dataSource) {
|
||||
this.jdbcTemplate = new JdbcTemplate(dataSource);
|
||||
this.roleRowMapper = new RoleMapper();
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
org.mifosplatform.audit.*,
|
||||
org.mifosplatform.infrastructure.*,
|
||||
org.mifosplatform.scheduledjobs.*,
|
||||
org.mifosplatform.organisation.*,
|
||||
org.mifosplatform.organisation.*,
|
||||
org.mifosplatform.portfolio.loanaccount.*,
|
||||
org.mifosplatform.portfolio.savingsaccount.*,
|
||||
org.mifosplatform.portfolio.*,
|
||||
@@ -46,6 +46,7 @@
|
||||
<jpa:repositories base-package="org.mifosplatform.useradministration.domain" />
|
||||
<jpa:repositories base-package="org.mifosplatform.organisation.*.domain" />
|
||||
<jpa:repositories base-package="org.mifosplatform.portfolio.*" />
|
||||
<jpa:repositories base-package="org.mifosplatform.scheduledjobs.domain" />
|
||||
|
||||
<import resource="infrastructure.xml" />
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd">
|
||||
|
||||
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean" depends-on="tenantDatabaseUpgradeService">
|
||||
<property name="dataSource" ref="tenantAwareDataSource" />
|
||||
<property name="dataSource" ref="routingDataSource" />
|
||||
<property name="persistenceUnitName" value="jpa-pu" />
|
||||
<property name="jpaVendorAdapter">
|
||||
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
|
||||
|
||||
@@ -10,107 +10,13 @@
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
|
||||
|
||||
<bean id="updateLoanSummariesScheduledJob"
|
||||
class="org.mifosplatform.scheduledjobs.UpdateLoanSummariesScheduledJob">
|
||||
<constructor-arg ref="scheduledJobRunnerService" />
|
||||
</bean>
|
||||
<bean id="updateLoanArrearsAgeingScheduledJob"
|
||||
class="org.mifosplatform.scheduledjobs.UpdateLoanArrearsAgeingScheduledJob">
|
||||
<constructor-arg ref="scheduledJobRunnerService" />
|
||||
</bean>
|
||||
<bean id="updateLoanPaidInAdvanceScheduledJob"
|
||||
class="org.mifosplatform.scheduledjobs.UpdateLoanPaidInAdvanceScheduledJob">
|
||||
<constructor-arg ref="scheduledJobRunnerService" />
|
||||
</bean>
|
||||
<bean id="applyAnnualFeeForSavingsScheduledJob"
|
||||
class="org.mifosplatform.scheduledjobs.ApplyAnnualFeeForSavingsScheduledJob">
|
||||
<constructor-arg ref="scheduledJobRunnerService" />
|
||||
</bean>
|
||||
<bean id="applyHolidaysToLoansScheduledJob"
|
||||
class="org.mifosplatform.scheduledjobs.ApplyHolidaysToLoansScheduledJob">
|
||||
<constructor-arg ref="scheduledJobRunnerService" />
|
||||
</bean>
|
||||
|
||||
<bean id="updateLoanSummariesJobDetail"
|
||||
class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
|
||||
<property name="group" value="mifosJobs" />
|
||||
<property name="targetObject" ref="updateLoanSummariesScheduledJob" />
|
||||
<property name="targetMethod" value="execute" />
|
||||
<property name="concurrent" value="false" />
|
||||
</bean>
|
||||
|
||||
<bean id="updateLoanArrearsAgeingJobDetail"
|
||||
class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
|
||||
<property name="group" value="mifosJobs" />
|
||||
<property name="targetObject" ref="updateLoanArrearsAgeingScheduledJob" />
|
||||
<property name="targetMethod" value="execute" />
|
||||
<property name="concurrent" value="false" />
|
||||
</bean>
|
||||
|
||||
<bean id="updateLoanPaidInAdvanceJobDetail"
|
||||
class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
|
||||
<property name="group" value="mifosJobs" />
|
||||
<property name="targetObject" ref="updateLoanPaidInAdvanceScheduledJob" />
|
||||
<property name="targetMethod" value="execute" />
|
||||
<property name="concurrent" value="false" />
|
||||
</bean>
|
||||
|
||||
<bean id="applyAnnualFeeForSavingsJobDetail"
|
||||
class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
|
||||
<property name="group" value="mifosJobs" />
|
||||
<property name="targetObject" ref="applyAnnualFeeForSavingsScheduledJob" />
|
||||
<property name="targetMethod" value="execute" />
|
||||
<property name="concurrent" value="false" />
|
||||
</bean>
|
||||
|
||||
<bean id="applyHolidaysToLoansJobDetail"
|
||||
class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
|
||||
<property name="group" value="mifosJobs" />
|
||||
<property name="targetObject" ref="applyHolidaysToLoansScheduledJob" />
|
||||
<property name="targetMethod" value="execute" />
|
||||
<property name="concurrent" value="false" />
|
||||
</bean>
|
||||
|
||||
<bean id="updateLoanSummariesJobCronTrigger"
|
||||
class="org.springframework.scheduling.quartz.CronTriggerFactoryBean">
|
||||
<property name="jobDetail" ref="updateLoanSummariesJobDetail" />
|
||||
<property name="cronExpression" value="0 0 22 1/1 * ? *" />
|
||||
</bean>
|
||||
|
||||
<bean id="updateLoanArrearsAgeingJobDetailCronTrigger"
|
||||
class="org.springframework.scheduling.quartz.CronTriggerFactoryBean">
|
||||
<property name="jobDetail" ref="updateLoanArrearsAgeingJobDetail" />
|
||||
<property name="cronExpression" value="0 1 0 1/1 * ? *" />
|
||||
</bean>
|
||||
|
||||
<bean id="updateLoanPaidInAdvanceJobDetailCronTrigger"
|
||||
class="org.springframework.scheduling.quartz.CronTriggerFactoryBean">
|
||||
<property name="jobDetail" ref="updateLoanPaidInAdvanceJobDetail" />
|
||||
<property name="cronExpression" value="0 5 0 1/1 * ? *" />
|
||||
</bean>
|
||||
|
||||
<bean id="applyAnnualFeeForSavingsJobDetailCronTrigger"
|
||||
class="org.springframework.scheduling.quartz.CronTriggerFactoryBean">
|
||||
<property name="jobDetail" ref="applyAnnualFeeForSavingsJobDetail" />
|
||||
<property name="cronExpression" value="0 20 22 1/1 * ? *" />
|
||||
</bean>
|
||||
|
||||
<bean id="applyHolidaysToJobDetailCronTrigger"
|
||||
class="org.springframework.scheduling.quartz.CronTriggerFactoryBean">
|
||||
<property name="jobDetail" ref="applyHolidaysToLoansJobDetail" />
|
||||
<property name="cronExpression" value="0 0 12 * * ?" />
|
||||
</bean>
|
||||
|
||||
<bean name="schedulerFactory"
|
||||
class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
|
||||
<property name="triggers">
|
||||
<property name="globalJobListeners">
|
||||
<list>
|
||||
<ref bean="updateLoanSummariesJobCronTrigger" />
|
||||
<ref bean="updateLoanArrearsAgeingJobDetailCronTrigger" />
|
||||
<ref bean="updateLoanPaidInAdvanceJobDetailCronTrigger" />
|
||||
<ref bean="applyAnnualFeeForSavingsJobDetailCronTrigger" />
|
||||
<ref bean="applyHolidaysToJobDetailCronTrigger" />
|
||||
<ref bean = "schedulerJobListener"/>
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
</beans>
|
||||
Reference in New Issue
Block a user