drop audit columns for office transactions, funds, staff, charges.

This commit is contained in:
Keith Woodlock
2013-01-27 22:13:22 +00:00
parent abea5e3116
commit b9ba666bfb
24 changed files with 136 additions and 165 deletions
@@ -126,10 +126,6 @@ CREATE TABLE `m_document` (
`type` varchar(50) DEFAULT NULL,
`description` varchar(1000) DEFAULT NULL,
`location` varchar(500) NOT NULL DEFAULT '0',
`createdby_id` int(20) NOT NULL,
`lastmodifiedby_id` int(20) NOT NULL,
`created_date` datetime NOT NULL,
`lastmodified_date` datetime NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
@@ -291,10 +287,6 @@ CREATE TABLE `m_charge` (
`is_penalty` tinyint(1) NOT NULL DEFAULT '0',
`is_active` tinyint(1) NOT NULL,
`is_deleted` tinyint(1) NOT NULL DEFAULT '0',
`createdby_id` bigint(20) DEFAULT NULL,
`created_date` datetime DEFAULT NULL,
`lastmodifiedby_id` bigint(20) DEFAULT NULL,
`lastmodified_date` datetime DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
@@ -303,10 +295,6 @@ CREATE TABLE `m_fund` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`name` varchar(255) DEFAULT NULL,
`external_id` varchar(100) DEFAULT NULL,
`createdby_id` bigint(20) DEFAULT NULL,
`created_date` datetime DEFAULT NULL,
`lastmodifiedby_id` bigint(20) DEFAULT NULL,
`lastmodified_date` datetime DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `fund_name_org` (`name`),
UNIQUE KEY `fund_externalid_org` (`external_id`)
@@ -319,10 +307,6 @@ CREATE TABLE `m_staff` (
`firstname` varchar(50) DEFAULT NULL,
`lastname` varchar(50) DEFAULT NULL,
`display_name` varchar(100) NOT NULL,
`createdby_id` bigint(20) DEFAULT NULL,
`created_date` datetime DEFAULT NULL,
`lastmodifiedby_id` bigint(20) DEFAULT NULL,
`lastmodified_date` datetime DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `display_name` (`display_name`),
KEY `FK_m_staff_m_office` (`office_id`),
@@ -396,10 +396,6 @@ CREATE TABLE `m_charge` (
`is_penalty` tinyint(1) NOT NULL DEFAULT '0',
`is_active` tinyint(1) NOT NULL,
`is_deleted` tinyint(1) NOT NULL DEFAULT '0',
`createdby_id` bigint(20) DEFAULT NULL,
`created_date` datetime DEFAULT NULL,
`lastmodifiedby_id` bigint(20) DEFAULT NULL,
`lastmodified_date` datetime DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
@@ -765,10 +761,6 @@ CREATE TABLE `m_document` (
`type` varchar(50) DEFAULT NULL,
`description` varchar(1000) DEFAULT NULL,
`location` varchar(500) NOT NULL DEFAULT '0',
`createdby_id` int(20) NOT NULL,
`lastmodifiedby_id` int(20) NOT NULL,
`created_date` datetime NOT NULL,
`lastmodified_date` datetime NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -793,10 +785,6 @@ CREATE TABLE `m_fund` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`name` varchar(255) DEFAULT NULL,
`external_id` varchar(100) DEFAULT NULL,
`createdby_id` bigint(20) DEFAULT NULL,
`created_date` datetime DEFAULT NULL,
`lastmodifiedby_id` bigint(20) DEFAULT NULL,
`lastmodified_date` datetime DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `fund_name_org` (`name`),
UNIQUE KEY `fund_externalid_org` (`external_id`)
@@ -1790,10 +1778,6 @@ CREATE TABLE `m_staff` (
`firstname` varchar(50) DEFAULT NULL,
`lastname` varchar(50) DEFAULT NULL,
`display_name` varchar(100) NOT NULL,
`createdby_id` bigint(20) DEFAULT NULL,
`created_date` datetime DEFAULT NULL,
`lastmodifiedby_id` bigint(20) DEFAULT NULL,
`lastmodified_date` datetime DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `display_name` (`display_name`),
KEY `FK_m_staff_m_office` (`office_id`),
@@ -2070,4 +2054,4 @@ UNLOCK TABLES;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2013-01-27 0:02:57
-- Dump completed on 2013-01-27 22:10:46
@@ -399,10 +399,6 @@ CREATE TABLE `m_charge` (
`is_penalty` tinyint(1) NOT NULL DEFAULT '0',
`is_active` tinyint(1) NOT NULL,
`is_deleted` tinyint(1) NOT NULL DEFAULT '0',
`createdby_id` bigint(20) DEFAULT NULL,
`created_date` datetime DEFAULT NULL,
`lastmodifiedby_id` bigint(20) DEFAULT NULL,
`lastmodified_date` datetime DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8;
@@ -414,7 +410,7 @@ CREATE TABLE `m_charge` (
LOCK TABLES `m_charge` WRITE;
/*!40000 ALTER TABLE `m_charge` DISABLE KEYS */;
INSERT INTO `m_charge` VALUES (1,'Fee','USD',1,1,1,'10.000000',0,1,0,1,'2012-10-25 15:12:08',1,'2012-10-25 15:12:08'),(2,'Check Bounce penalty','XOF',1,2,1,'50.000000',0,1,0,1,'2012-10-29 10:27:32',1,'2012-10-29 10:44:28'),(3,'fee2','XOF',1,1,1,'12.000000',0,1,0,1,'2012-12-06 16:54:43',1,'2012-12-06 16:54:43'),(4,'PlusOne Service Charge %','HKD',1,1,2,'1.000000',0,1,0,1,'2012-12-12 07:20:24',1,'2012-12-12 07:34:55'),(5,'Administration Fee','HKD',1,1,1,'500.000000',0,1,0,1,'2012-12-12 07:32:11',1,'2012-12-12 08:02:37'),(6,'OD Charge','HKD',1,2,2,'12.000000',1,1,0,1,'2012-12-19 02:49:05',1,'2012-12-19 02:55:36');
INSERT INTO `m_charge` VALUES (1,'Fee','USD',1,1,1,'10.000000',0,1,0),(2,'Check Bounce penalty','XOF',1,2,1,'50.000000',0,1,0),(3,'fee2','XOF',1,1,1,'12.000000',0,1,0),(4,'PlusOne Service Charge %','HKD',1,1,2,'1.000000',0,1,0),(5,'Administration Fee','HKD',1,1,1,'500.000000',0,1,0),(6,'OD Charge','HKD',1,2,2,'12.000000',1,1,0);
/*!40000 ALTER TABLE `m_charge` ENABLE KEYS */;
UNLOCK TABLES;
@@ -773,10 +769,6 @@ CREATE TABLE `m_document` (
`type` varchar(50) DEFAULT NULL,
`description` varchar(1000) DEFAULT NULL,
`location` varchar(500) NOT NULL DEFAULT '0',
`createdby_id` int(20) NOT NULL,
`lastmodifiedby_id` int(20) NOT NULL,
`created_date` datetime NOT NULL,
`lastmodified_date` datetime NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -787,7 +779,7 @@ CREATE TABLE `m_document` (
LOCK TABLES `m_document` WRITE;
/*!40000 ALTER TABLE `m_document` DISABLE KEYS */;
INSERT INTO `m_document` VALUES (4,'loans',22,'test docs','jscam.swf',35091,'application/x-shockwave-flash',NULL,'/root/.mifosx/DefaultDemoTenant/documents/loans/22/n8uivwkh/jscam.swf',1,1,'2012-10-29 09:16:55','2012-10-29 09:16:55'),(7,'clients',37,'Passport','australianprofile.pdf',494511,'application/pdf',NULL,'/root/.mifosx/DefaultDemoTenant/documents/clients/37/539uhy4c/australianprofile.pdf',1,1,'2012-11-15 05:20:40','2012-11-15 05:20:40'),(8,'clients',17,'testdoc','doc00003186.doc',110994,'application/msword','wddwoidwi','/root/.mifosx/DefaultDemoTenant/documents/clients/17/6ppzw73tdebnson/doc00003186.doc',1,1,'2012-11-15 07:49:32','2012-11-15 07:49:32'),(9,'client_identifiers',4,'hfghfgh','passport-shaun.gif',64646,'image/gif',NULL,'/root/.mifosx/DefaultDemoTenant/documents/client_identifiers/4/qfx4h9pn4o1/passport-shaun.gif',1,1,'2012-12-01 10:42:50','2012-12-01 10:42:50'),(10,'clients',16,'TestSave','restclient.jpg',55485,'image/jpeg',NULL,'/root/.mifosx/DefaultDemoTenant/documents/clients/16/o4ielexzj6n/restclient.jpg',1,1,'2012-12-15 18:08:38','2012-12-15 18:08:38');
INSERT INTO `m_document` VALUES (4,'loans',22,'test docs','jscam.swf',35091,'application/x-shockwave-flash',NULL,'/root/.mifosx/DefaultDemoTenant/documents/loans/22/n8uivwkh/jscam.swf'),(7,'clients',37,'Passport','australianprofile.pdf',494511,'application/pdf',NULL,'/root/.mifosx/DefaultDemoTenant/documents/clients/37/539uhy4c/australianprofile.pdf'),(8,'clients',17,'testdoc','doc00003186.doc',110994,'application/msword','wddwoidwi','/root/.mifosx/DefaultDemoTenant/documents/clients/17/6ppzw73tdebnson/doc00003186.doc'),(9,'client_identifiers',4,'hfghfgh','passport-shaun.gif',64646,'image/gif',NULL,'/root/.mifosx/DefaultDemoTenant/documents/client_identifiers/4/qfx4h9pn4o1/passport-shaun.gif'),(10,'clients',16,'TestSave','restclient.jpg',55485,'image/jpeg',NULL,'/root/.mifosx/DefaultDemoTenant/documents/clients/16/o4ielexzj6n/restclient.jpg');
/*!40000 ALTER TABLE `m_document` ENABLE KEYS */;
UNLOCK TABLES;
@@ -802,10 +794,6 @@ CREATE TABLE `m_fund` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`name` varchar(255) DEFAULT NULL,
`external_id` varchar(100) DEFAULT NULL,
`createdby_id` bigint(20) DEFAULT NULL,
`created_date` datetime DEFAULT NULL,
`lastmodifiedby_id` bigint(20) DEFAULT NULL,
`lastmodified_date` datetime DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `fund_name_org` (`name`),
UNIQUE KEY `fund_externalid_org` (`external_id`)
@@ -818,7 +806,7 @@ CREATE TABLE `m_fund` (
LOCK TABLES `m_fund` WRITE;
/*!40000 ALTER TABLE `m_fund` DISABLE KEYS */;
INSERT INTO `m_fund` VALUES (1,'Z3','Z3',1,'2012-07-17 00:33:46',1,'2012-12-12 07:30:49'),(2,'Z4','Z4',1,'2012-07-17 03:19:10',1,'2012-12-12 07:30:56'),(3,'Z5','Z5',1,'2012-07-19 15:30:54',1,'2012-12-12 07:31:01'),(4,'PlusOne Fund','PlusOne',1,'2012-07-19 15:31:21',1,'2012-12-12 07:04:48'),(5,'Z1','Z1',1,'2012-11-13 09:34:15',1,'2012-12-12 07:30:42'),(6,'Z6','Z6',1,'2012-11-13 10:10:56',1,'2012-12-12 07:31:06'),(7,'Z2','Z2',1,'2012-12-06 16:44:31',1,'2012-12-12 07:30:38');
INSERT INTO `m_fund` VALUES (1,'Z3','Z3'),(2,'Z4','Z4'),(3,'Z5','Z5'),(4,'PlusOne Fund','PlusOne'),(5,'Z1','Z1'),(6,'Z6','Z6'),(7,'Z2','Z2');
/*!40000 ALTER TABLE `m_fund` ENABLE KEYS */;
UNLOCK TABLES;
@@ -1815,10 +1803,6 @@ CREATE TABLE `m_staff` (
`firstname` varchar(50) DEFAULT NULL,
`lastname` varchar(50) DEFAULT NULL,
`display_name` varchar(100) NOT NULL,
`createdby_id` bigint(20) DEFAULT NULL,
`created_date` datetime DEFAULT NULL,
`lastmodifiedby_id` bigint(20) DEFAULT NULL,
`lastmodified_date` datetime DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `display_name` (`display_name`),
KEY `FK_m_staff_m_office` (`office_id`),
@@ -1832,7 +1816,7 @@ CREATE TABLE `m_staff` (
LOCK TABLES `m_staff` WRITE;
/*!40000 ALTER TABLE `m_staff` DISABLE KEYS */;
INSERT INTO `m_staff` VALUES (1,1,20,'Nayan','Ambali','Ambali, Nayan',1,'2012-11-15 04:30:24',1,'2012-11-15 04:30:24'),(2,1,21,'Uganda','loanofficer','loanofficer, Uganda',1,'2012-12-07 11:04:47',1,'2013-01-22 12:16:52'),(3,1,22,'Loan 01','Officer','Officer, Loan 01',1,'2012-12-12 07:18:57',1,'2012-12-12 08:02:01'),(4,1,22,'Loan 02','Officer','Officer, Loan 02',1,'2012-12-12 07:19:17',1,'2012-12-12 08:02:07');
INSERT INTO `m_staff` VALUES (1,1,20,'Nayan','Ambali','Ambali, Nayan'),(2,1,21,'Uganda','loanofficer','loanofficer, Uganda'),(3,1,22,'Loan 01','Officer','Officer, Loan 01'),(4,1,22,'Loan 02','Officer','Officer, Loan 02');
/*!40000 ALTER TABLE `m_staff` ENABLE KEYS */;
UNLOCK TABLES;
@@ -2099,4 +2083,4 @@ UNLOCK TABLES;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2013-01-27 0:29:30
-- Dump completed on 2013-01-27 22:12:43
@@ -0,0 +1,23 @@
ALTER TABLE `m_fund`
DROP COLUMN `lastmodifiedby_id` ,
DROP COLUMN `lastmodified_date` ,
DROP COLUMN `created_date`,
DROP COLUMN `createdby_id`;
ALTER TABLE `m_staff`
DROP COLUMN `lastmodifiedby_id` ,
DROP COLUMN `lastmodified_date` ,
DROP COLUMN `created_date`,
DROP COLUMN `createdby_id`;
ALTER TABLE `m_charge`
DROP COLUMN `lastmodifiedby_id` ,
DROP COLUMN `lastmodified_date` ,
DROP COLUMN `created_date`,
DROP COLUMN `createdby_id`;
ALTER TABLE `m_document`
DROP COLUMN `lastmodifiedby_id` ,
DROP COLUMN `lastmodified_date` ,
DROP COLUMN `created_date`,
DROP COLUMN `createdby_id`;
@@ -12,7 +12,11 @@ public class CodeData {
@SuppressWarnings("unused")
private final boolean systemDefined;
public CodeData(final Long id, final String name, final boolean systemDefined) {
public static CodeData instance(final Long id, final String name, final boolean systemDefined) {
return new CodeData(id, name, systemDefined);
}
private CodeData(final Long id, final String name, final boolean systemDefined) {
this.id = id;
this.name = name;
this.systemDefined = systemDefined;
@@ -14,7 +14,11 @@ public class CodeValueData {
@SuppressWarnings("unused")
private final Integer position;
public CodeValueData(final Long id, final String name, final Integer position) {
public static CodeValueData instance(final Long id, final String name, final Integer position) {
return new CodeValueData(id, name, position);
}
private CodeValueData(final Long id, final String name, final Integer position) {
this.id = id;
this.name = name;
this.position = position;
@@ -39,7 +39,7 @@ public class CodeReadPlatformServiceImpl implements CodeReadPlatformService {
final String code_name = rs.getString("code_name");
final boolean systemDefined = rs.getBoolean("systemDefined");
return new CodeData(id, code_name, systemDefined);
return CodeData.instance(id, code_name, systemDefined);
}
}
@@ -15,42 +15,41 @@ import org.springframework.stereotype.Service;
@Service
public class CodeValueReadPlatformServiceImpl implements CodeValueReadPlatformService {
private final JdbcTemplate jdbcTemplate;
private final PlatformSecurityContext context;
private final JdbcTemplate jdbcTemplate;
private final PlatformSecurityContext context;
@Autowired
public CodeValueReadPlatformServiceImpl(final PlatformSecurityContext context, final TenantAwareRoutingDataSource dataSource) {
this.context = context;
this.jdbcTemplate = new JdbcTemplate(dataSource);
}
@Autowired
public CodeValueReadPlatformServiceImpl(final PlatformSecurityContext context, final TenantAwareRoutingDataSource dataSource) {
this.context = context;
this.jdbcTemplate = new JdbcTemplate(dataSource);
}
private static final class CodeValueDataMapper implements RowMapper<CodeValueData> {
private static final class CodeValueDataMapper implements RowMapper<CodeValueData> {
public String schema() {
return " cv.id as id, cv.code_value as value, cv.code_id as codeId, cv.order_position as position"
+ " from m_code_value as cv join m_code c on cv.code_id = c.id ";
}
public String schema() {
return " cv.id as id, cv.code_value as value, cv.code_id as codeId, cv.order_position as position"
+ " from m_code_value as cv join m_code c on cv.code_id = c.id ";
}
@Override
public CodeValueData mapRow(final ResultSet rs, @SuppressWarnings("unused") final int rowNum)
throws SQLException {
@Override
public CodeValueData mapRow(final ResultSet rs, @SuppressWarnings("unused") final int rowNum) throws SQLException {
final Long id = rs.getLong("id");
final String value = rs.getString("value");
final Integer position = rs.getInt("position");
final Long id = rs.getLong("id");
final String value = rs.getString("value");
final Integer position = rs.getInt("position");
return new CodeValueData(id, value, position);
}
}
@Override
public Collection<CodeValueData> retrieveCustomIdentifierCodeValues() {
context.authenticatedUser();
return CodeValueData.instance(id, value, position);
}
}
final CodeValueDataMapper rm = new CodeValueDataMapper();
final String sql = "select " + rm.schema() + "where c.code_name like ? order by position";
@Override
public Collection<CodeValueData> retrieveCustomIdentifierCodeValues() {
return this.jdbcTemplate.query(sql, rm, new Object[] {"Customer Identifier"});
}
context.authenticatedUser();
final CodeValueDataMapper rm = new CodeValueDataMapper();
final String sql = "select " + rm.schema() + "where c.code_name like ? order by position";
return this.jdbcTemplate.query(sql, rm, new Object[] { "Customer Identifier" });
}
}
@@ -5,13 +5,12 @@ import javax.persistence.Entity;
import javax.persistence.Table;
import org.apache.commons.lang.StringUtils;
import org.mifosplatform.infrastructure.core.domain.AbstractAuditableCustom;
import org.mifosplatform.infrastructure.documentmanagement.command.DocumentCommand;
import org.mifosplatform.useradministration.domain.AppUser;
import org.springframework.data.jpa.domain.AbstractPersistable;
@Entity
@Table(name = "m_document")
public class Document extends AbstractAuditableCustom<AppUser, Long> {
public class Document extends AbstractPersistable<Long> {
@Column(name = "parent_entity_type", length = 50)
private String parentEntityType;
@@ -34,24 +34,21 @@ public class OfficeTransactionData {
@SuppressWarnings("unused")
private final Collection<OfficeData> allowedOffices;
public OfficeTransactionData(final LocalDate transactionDate, final Collection<OfficeData> allowedOffices,
final Collection<CurrencyData> currencyOptions) {
this.transactionDate = transactionDate;
this.allowedOffices = allowedOffices;
this.currencyOptions = currencyOptions;
this.id = null;
this.fromOfficeId = null;
this.fromOfficeName = null;
this.toOfficeId = null;
this.toOfficeName = null;
this.currency = null;
this.transactionAmount = null;
this.description = null;
public static OfficeTransactionData instance(final Long id, final LocalDate transactionDate, final Long fromOfficeId,
final String fromOfficeName, final Long toOfficeId, final String toOfficeName, final CurrencyData currency,
final BigDecimal transactionAmount, final String description) {
return new OfficeTransactionData(id, transactionDate, fromOfficeId, fromOfficeName, toOfficeId, toOfficeName, currency,
transactionAmount, description, null, null);
}
public OfficeTransactionData(final Long id, final LocalDate transactionDate, final Long fromOfficeId, final String fromOfficeName,
public static OfficeTransactionData template(final LocalDate transactionDate, final Collection<OfficeData> parentLookups,
final Collection<CurrencyData> currencyOptions) {
return new OfficeTransactionData(null, transactionDate, null, null, null, null, null, null, null, parentLookups, currencyOptions);
}
private OfficeTransactionData(final Long id, final LocalDate transactionDate, final Long fromOfficeId, final String fromOfficeName,
final Long toOfficeId, final String toOfficeName, final CurrencyData currency, final BigDecimal transactionAmount,
final String description) {
final String description, final Collection<OfficeData> allowedOffices, final Collection<CurrencyData> currencyOptions) {
this.id = id;
this.fromOfficeId = fromOfficeId;
this.fromOfficeName = fromOfficeName;
@@ -61,7 +58,7 @@ public class OfficeTransactionData {
this.transactionAmount = transactionAmount;
this.description = description;
this.transactionDate = transactionDate;
this.currencyOptions = null;
this.allowedOffices = null;
this.allowedOffices = allowedOffices;
this.currencyOptions = currencyOptions;
}
}
@@ -15,14 +15,13 @@ import javax.persistence.TemporalType;
import org.joda.time.LocalDate;
import org.mifosplatform.infrastructure.core.api.JsonCommand;
import org.mifosplatform.infrastructure.core.domain.AbstractAuditableCustom;
import org.mifosplatform.organisation.monetary.domain.MonetaryCurrency;
import org.mifosplatform.organisation.monetary.domain.Money;
import org.mifosplatform.useradministration.domain.AppUser;
import org.springframework.data.jpa.domain.AbstractPersistable;
@Entity
@Table(name = "m_office_transaction")
public class OfficeTransaction extends AbstractAuditableCustom<AppUser, Long> {
public class OfficeTransaction extends AbstractPersistable<Long> {
@SuppressWarnings("unused")
@ManyToOne(fetch = FetchType.LAZY)
@@ -100,12 +100,11 @@ public class OfficeReadPlatformServiceImpl implements OfficeReadPlatformService
private static final class OfficeTransactionMapper implements RowMapper<OfficeTransactionData> {
public String officeTransactionSchema() {
public String schema() {
return " ot.id as id, ot.transaction_date as transactionDate, ot.from_office_id as fromOfficeId, fromoff.name as fromOfficeName, "
+ " ot.to_office_id as toOfficeId, tooff.name as toOfficeName, ot.transaction_amount as transactionAmount, ot.description as description, "
+ " ot.currency_code as currencyCode, rc.decimal_places as currencyDigits, "
+ "rc.name as currencyName, rc.internationalized_name_code as currencyNameCode, rc.display_symbol as currencyDisplaySymbol "
+ " rc.name as currencyName, rc.internationalized_name_code as currencyNameCode, rc.display_symbol as currencyDisplaySymbol "
+ " from m_office_transaction ot "
+ " left join m_office fromoff on fromoff.id = ot.from_office_id "
+ " left join m_office tooff on tooff.id = ot.to_office_id " + " join m_currency rc on rc.`code` = ot.currency_code";
@@ -133,7 +132,7 @@ public class OfficeReadPlatformServiceImpl implements OfficeReadPlatformService
BigDecimal transactionAmount = rs.getBigDecimal("transactionAmount");
String description = rs.getString("description");
return new OfficeTransactionData(id, transactionDate, fromOfficeId, fromOfficeName, toOfficeId, toOfficeName, currencyData,
return OfficeTransactionData.instance(id, transactionDate, fromOfficeId, fromOfficeName, toOfficeId, toOfficeName, currencyData,
transactionAmount, description);
}
}
@@ -235,7 +234,7 @@ public class OfficeReadPlatformServiceImpl implements OfficeReadPlatformService
String hierarchySearchString = hierarchy + "%";
OfficeTransactionMapper rm = new OfficeTransactionMapper();
String sql = "select " + rm.officeTransactionSchema()
String sql = "select " + rm.schema()
+ " where (fromoff.hierarchy like ? or tooff.hierarchy like ?) order by ot.transaction_date, ot.id";
return this.jdbcTemplate.query(sql, rm, new Object[] { hierarchySearchString, hierarchySearchString });
@@ -248,6 +247,6 @@ public class OfficeReadPlatformServiceImpl implements OfficeReadPlatformService
final Collection<OfficeData> parentLookups = retrieveAllOfficesForDropdown();
final Collection<CurrencyData> currencyOptions = currencyReadPlatformService.retrieveAllowedCurrencies();
return new OfficeTransactionData(new LocalDate(), parentLookups, currencyOptions);
return OfficeTransactionData.template(new LocalDate(), parentLookups, currencyOptions);
}
}
@@ -26,7 +26,7 @@ import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
import org.mifosplatform.infrastructure.core.serialization.ApiRequestJsonSerializationSettings;
import org.mifosplatform.infrastructure.core.serialization.DefaultToApiJsonSerializer;
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
import org.mifosplatform.organisation.office.data.OfficeLookup;
import org.mifosplatform.organisation.office.data.OfficeData;
import org.mifosplatform.organisation.office.service.OfficeReadPlatformService;
import org.mifosplatform.organisation.staff.data.StaffData;
import org.mifosplatform.organisation.staff.service.StaffReadPlatformService;
@@ -107,7 +107,7 @@ public class StaffApiResource {
StaffData staff = this.readPlatformService.retrieveStaff(staffId);
if (settings.isTemplate()) {
final Collection<OfficeLookup> allowedOffices = officeReadPlatformService.retrieveAllOfficesForLookup();
final Collection<OfficeData> allowedOffices = officeReadPlatformService.retrieveAllOfficesForDropdown();
staff = StaffData.templateData(staff, allowedOffices);
}
@@ -2,7 +2,7 @@ package org.mifosplatform.organisation.staff.data;
import java.util.Collection;
import org.mifosplatform.organisation.office.data.OfficeLookup;
import org.mifosplatform.organisation.office.data.OfficeData;
/**
* Immutable data object representing staff data.
@@ -18,15 +18,20 @@ public class StaffData {
private final boolean isLoanOfficer;
@SuppressWarnings("unused")
private final Collection<OfficeLookup> allowedOffices;
private final Collection<OfficeData> allowedOffices;
public static StaffData templateData(final StaffData staff, final Collection<OfficeLookup> allowedOffices) {
public static StaffData templateData(final StaffData staff, final Collection<OfficeData> allowedOffices) {
return new StaffData(staff.id, staff.firstname, staff.lastname, staff.displayName, staff.officeId, staff.officeName,
staff.isLoanOfficer, allowedOffices);
}
public StaffData(final Long id, final String firstname, final String lastname, final String displayName, final Long officeId,
final String officeName, final boolean isLoanOfficer, final Collection<OfficeLookup> allowedOffices) {
public static StaffData instance(final Long id, final String firstname, final String lastname, final String displayName,
final Long officeId, final String officeName, final boolean isLoanOfficer) {
return new StaffData(id, firstname, lastname, displayName, officeId, officeName, isLoanOfficer, null);
}
private StaffData(final Long id, final String firstname, final String lastname, final String displayName, final Long officeId,
final String officeName, final boolean isLoanOfficer, final Collection<OfficeData> allowedOffices) {
this.id = id;
this.firstname = firstname;
this.lastname = lastname;
@@ -12,13 +12,12 @@ import javax.persistence.UniqueConstraint;
import org.apache.commons.lang.StringUtils;
import org.mifosplatform.infrastructure.core.api.JsonCommand;
import org.mifosplatform.infrastructure.core.domain.AbstractAuditableCustom;
import org.mifosplatform.organisation.office.domain.Office;
import org.mifosplatform.useradministration.domain.AppUser;
import org.springframework.data.jpa.domain.AbstractPersistable;
@Entity
@Table(name = "m_staff", uniqueConstraints = { @UniqueConstraint(columnNames = { "display_name" }, name = "display_name") })
public class Staff extends AbstractAuditableCustom<AppUser, Long> {
public class Staff extends AbstractPersistable<Long> {
@Column(name = "firstname", length = 50)
private String firstname;
@@ -58,7 +58,7 @@ public class StaffReadPlatformServiceImpl implements StaffReadPlatformService {
final boolean isLoanOfficer = rs.getBoolean("isLoanOfficer");
final String officeName = rs.getString("officeName");
return new StaffData(id, firstname, lastname, displayName, officeId, officeName, isLoanOfficer, null);
return StaffData.instance(id, firstname, lastname, displayName, officeId, officeName, isLoanOfficer);
}
}
@@ -107,8 +107,8 @@ public class StaffReadPlatformServiceImpl implements StaffReadPlatformService {
final StaffGroupMapper staffGroupMapper = new StaffGroupMapper();
final String groupSql = "select distinct " + staffGroupMapper.schema();
final List<StaffAccountSummaryCollectionData.ClientSummary> clientSummaryList = this.jdbcTemplate.query(clientSql, staffClientMapper,
new Object[] { loanOfficerId });
final List<StaffAccountSummaryCollectionData.ClientSummary> clientSummaryList = this.jdbcTemplate.query(clientSql,
staffClientMapper, new Object[] { loanOfficerId });
for (StaffAccountSummaryCollectionData.ClientSummary clientSummary : clientSummaryList) {
@@ -123,8 +123,8 @@ public class StaffReadPlatformServiceImpl implements StaffReadPlatformService {
for (StaffAccountSummaryCollectionData.GroupSummary groupSummary : groupSummaryList) {
final Collection<GroupAccountSummaryData> groupLoanAccounts = this.groupReadPlatformService.retrieveGroupLoanAccountsByLoanOfficerId(
groupSummary.getId(), loanOfficerId);
final Collection<GroupAccountSummaryData> groupLoanAccounts = this.groupReadPlatformService
.retrieveGroupLoanAccountsByLoanOfficerId(groupSummary.getId(), loanOfficerId);
groupSummary.setLoans(groupLoanAccounts);
}
@@ -85,7 +85,7 @@ public class ChargesApiResource {
ChargeData charge = this.readPlatformService.retrieveCharge(chargeId);
if (settings.isTemplate()) {
ChargeData templateData = this.readPlatformService.retrieveNewChargeDetails();
charge = new ChargeData(charge, templateData);
charge = ChargeData.withTemplate(charge, templateData);
}
return this.toApiJsonSerializer.serialize(settings, charge, CHARGES_DATA_PARAMETERS);
@@ -27,38 +27,27 @@ public class ChargeData {
private final List<EnumOptionData> chargeAppliesToOptions;
private final List<EnumOptionData> chargeTimeTypeOptions;
public static ChargeData template(final Collection<CurrencyData> currencyOptions, final List<EnumOptionData> chargeCalculationTypeOptions,
final List<EnumOptionData> chargeAppliesToOptions, final List<EnumOptionData> chargeTimeTypeOptions) {
public static ChargeData template(final Collection<CurrencyData> currencyOptions,
final List<EnumOptionData> chargeCalculationTypeOptions, final List<EnumOptionData> chargeAppliesToOptions,
final List<EnumOptionData> chargeTimeTypeOptions) {
return new ChargeData(null, null, null, null, null, null, null, false, false, currencyOptions, chargeCalculationTypeOptions,
chargeAppliesToOptions, chargeTimeTypeOptions);
}
public ChargeData(final ChargeData charge, final ChargeData template) {
this(charge.id, charge.name, charge.amount, charge.currency, charge.chargeTimeType, charge.chargeAppliesTo,
public static ChargeData withTemplate(final ChargeData charge, final ChargeData template) {
return new ChargeData(charge.id, charge.name, charge.amount, charge.currency, charge.chargeTimeType, charge.chargeAppliesTo,
charge.chargeCalculationType, charge.penalty, charge.active, template.currencyOptions,
template.chargeCalculationTypeOptions, template.chargeAppliesToOptions, template.chargeTimeTypeOptions);
}
public ChargeData(final Long id, final String name, final BigDecimal amount, final CurrencyData currency,
public static ChargeData instance(final Long id, final String name, final BigDecimal amount, final CurrencyData currency,
final EnumOptionData chargeTimeType, final EnumOptionData chargeAppliesTo, final EnumOptionData chargeCalculationType,
final boolean penalty, final boolean active) {
this.id = id;
this.name = name;
this.amount = amount;
this.currency = currency;
this.chargeTimeType = chargeTimeType;
this.chargeAppliesTo = chargeAppliesTo;
this.chargeCalculationType = chargeCalculationType;
this.penalty = penalty;
this.active = active;
this.currencyOptions = null;
this.chargeCalculationTypeOptions = null;
this.chargeAppliesToOptions = null;
this.chargeTimeTypeOptions = null;
return new ChargeData(id, name, amount, currency, chargeTimeType, chargeAppliesTo, chargeCalculationType, penalty, active, null,
null, null, null);
}
public ChargeData(final Long id, final String name, final BigDecimal amount, final CurrencyData currency,
private ChargeData(final Long id, final String name, final BigDecimal amount, final CurrencyData currency,
final EnumOptionData chargeTimeType, final EnumOptionData chargeAppliesTo, final EnumOptionData chargeCalculationType,
final boolean penalty, final boolean active, final Collection<CurrencyData> currencyOptions,
final List<EnumOptionData> chargeCalculationTypeOptions, final List<EnumOptionData> chargeAppliesToOptions,
@@ -10,12 +10,11 @@ import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
import org.mifosplatform.infrastructure.core.api.JsonCommand;
import org.mifosplatform.infrastructure.core.domain.AbstractAuditableCustom;
import org.mifosplatform.useradministration.domain.AppUser;
import org.springframework.data.jpa.domain.AbstractPersistable;
@Entity
@Table(name = "m_charge", uniqueConstraints = { @UniqueConstraint(columnNames = { "name" }, name = "name") })
public class Charge extends AbstractAuditableCustom<AppUser, Long> {
public class Charge extends AbstractPersistable<Long> {
@Column(name = "name", length = 100)
private String name;
@@ -185,7 +185,7 @@ public class ChargeReadPlatformServiceImpl implements ChargeReadPlatformService
final boolean penalty = rs.getBoolean("penalty");
final boolean active = rs.getBoolean("active");
return new ChargeData(id, name, amount, currency, chargeTimeType, chargeAppliesToType, chargeCalculationType, penalty, active);
return ChargeData.instance(id, name, amount, currency, chargeTimeType, chargeAppliesToType, chargeCalculationType, penalty, active);
}
}
@@ -87,8 +87,8 @@ public class ClientIdentifiersApiResource {
context.authenticatedUser().validateHasReadPermission(resourceNameForPermissions);
Collection<CodeValueData> codeValues = codeValueReadPlatformService.retrieveCustomIdentifierCodeValues();
ClientIdentifierData clientIdentifierData = ClientIdentifierData.template(codeValues);
final Collection<CodeValueData> codeValues = codeValueReadPlatformService.retrieveCustomIdentifierCodeValues();
final ClientIdentifierData clientIdentifierData = ClientIdentifierData.template(codeValues);
final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper.process(uriInfo.getQueryParameters());
return this.toApiJsonSerializer.serialize(settings, clientIdentifierData, CLIENT_IDENTIFIER_DATA_PARAMETERS);
@@ -123,8 +123,8 @@ public class ClientIdentifiersApiResource {
@Path("{identifierId}")
@Consumes({ MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_JSON })
public String getClientIdentifier(@PathParam("clientId") final Long clientId, @PathParam("identifierId") final Long clientIdentifierId,
@Context final UriInfo uriInfo) {
public String retrieveClientIdentifiers(@PathParam("clientId") final Long clientId,
@PathParam("identifierId") final Long clientIdentifierId, @Context final UriInfo uriInfo) {
context.authenticatedUser().validateHasReadPermission(resourceNameForPermissions);
@@ -12,7 +12,11 @@ public class FundData {
@SuppressWarnings("unused")
private String externalId;
public FundData(final Long id, final String name, final String externalId) {
public static FundData instance(final Long id, final String name, final String externalId) {
return new FundData(id, name, externalId);
}
private FundData(final Long id, final String name, final String externalId) {
this.id = id;
this.name = name;
this.externalId = externalId;
@@ -10,13 +10,12 @@ import javax.persistence.UniqueConstraint;
import org.apache.commons.lang.StringUtils;
import org.mifosplatform.infrastructure.core.api.JsonCommand;
import org.mifosplatform.infrastructure.core.domain.AbstractAuditableCustom;
import org.mifosplatform.useradministration.domain.AppUser;
import org.springframework.data.jpa.domain.AbstractPersistable;
@Entity
@Table(name = "m_fund", uniqueConstraints = { @UniqueConstraint(columnNames = { "name" }, name = "fund_name_org"),
@UniqueConstraint(columnNames = { "external_id" }, name = "fund_externalid_org") })
public class Fund extends AbstractAuditableCustom<AppUser, Long> {
public class Fund extends AbstractPersistable<Long> {
@Column(name = "name")
private String name;
@@ -39,7 +39,7 @@ public class FundReadPlatformServiceImpl implements FundReadPlatformService {
final String name = rs.getString("name");
final String externalId = rs.getString("externalId");
return new FundData(id, name, externalId);
return FundData.instance(id, name, externalId);
}
}