cosmetic office Txn changes to java

This commit is contained in:
John Woodlock
2012-08-28 13:54:45 +10:00
parent c4b5359ef9
commit 72d854b0cd
3 changed files with 44 additions and 32 deletions
@@ -1,5 +1,21 @@
package org.mifosng.platform.api; package org.mifosng.platform.api;
import java.util.Collection;
import java.util.Set;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
import org.mifosng.platform.api.commands.ChargeCommand; import org.mifosng.platform.api.commands.ChargeCommand;
import org.mifosng.platform.api.data.ChargeData; import org.mifosng.platform.api.data.ChargeData;
import org.mifosng.platform.api.data.EntityIdentifier; import org.mifosng.platform.api.data.EntityIdentifier;
@@ -12,16 +28,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope; import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.ws.rs.*;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.UriInfo;
import javax.ws.rs.core.Response;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
@Path("/charges") @Path("/charges")
@Component @Component
@Scope("singleton") @Scope("singleton")
@@ -16,8 +16,7 @@ public class OfficeTransactionData {
private final String fromOfficeName; private final String fromOfficeName;
private final Long toOfficeId; private final Long toOfficeId;
private final String toOfficeName; private final String toOfficeName;
private final String currencyCode; private CurrencyData currency;
private final Integer digitsAfterDecimal;
private final BigDecimal transactionAmount; private final BigDecimal transactionAmount;
private final String description; private final String description;
private final List<CurrencyData> currencyOptions; private final List<CurrencyData> currencyOptions;
@@ -34,8 +33,7 @@ public class OfficeTransactionData {
this.fromOfficeName = null; this.fromOfficeName = null;
this.toOfficeId = null; this.toOfficeId = null;
this.toOfficeName = null; this.toOfficeName = null;
this.currencyCode = null; this.currency = null;
this.digitsAfterDecimal = null;
this.transactionAmount = null; this.transactionAmount = null;
this.description = null; this.description = null;
} }
@@ -43,16 +41,14 @@ public class OfficeTransactionData {
public OfficeTransactionData(final Long id, public OfficeTransactionData(final Long id,
final LocalDate transactionDate, final Long fromOfficeId, final LocalDate transactionDate, final Long fromOfficeId,
final String fromOfficeName, final Long toOfficeId, final String fromOfficeName, final Long toOfficeId,
final String toOfficeName, final String currencyCode, final String toOfficeName, final CurrencyData currency,
final Integer digitsAfterDecimal,
final BigDecimal transactionAmount, final String description) { final BigDecimal transactionAmount, final String description) {
this.id = id; this.id = id;
this.fromOfficeId = fromOfficeId; this.fromOfficeId = fromOfficeId;
this.fromOfficeName = fromOfficeName; this.fromOfficeName = fromOfficeName;
this.toOfficeId = toOfficeId; this.toOfficeId = toOfficeId;
this.toOfficeName = toOfficeName; this.toOfficeName = toOfficeName;
this.currencyCode = currencyCode; this.currency = currency;
this.digitsAfterDecimal = digitsAfterDecimal;
this.transactionAmount = transactionAmount; this.transactionAmount = transactionAmount;
this.description = description; this.description = description;
this.transactionDate = transactionDate; this.transactionDate = transactionDate;
@@ -93,12 +89,8 @@ public class OfficeTransactionData {
return toOfficeName; return toOfficeName;
} }
public String getCurrencyCode() { public CurrencyData getCurrency() {
return currencyCode; return currency;
}
public Integer getDigitsAfterDecimal() {
return digitsAfterDecimal;
} }
public BigDecimal getTransactionAmount() { public BigDecimal getTransactionAmount() {
@@ -96,7 +96,9 @@ public class OfficeReadPlatformServiceImpl implements OfficeReadPlatformService
public String officeTransactionSchema() { public String officeTransactionSchema() {
return " ot.id as id, ot.transaction_date as transactionDate, ot.from_office_id as fromOfficeId, fromoff.name as fromOfficeName, " 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.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 digitsAfterDecimal" + " 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 "
+ " from m_office_transaction ot " + " from m_office_transaction ot "
+ " left join m_office fromoff on fromoff.id = ot.from_office_id " + " left join m_office fromoff on fromoff.id = ot.from_office_id "
+ " left join m_office tooff on tooff.id = ot.to_office_id " + " left join m_office tooff on tooff.id = ot.to_office_id "
@@ -114,16 +116,26 @@ public class OfficeReadPlatformServiceImpl implements OfficeReadPlatformService
String fromOfficeName = rs.getString("fromOfficeName"); String fromOfficeName = rs.getString("fromOfficeName");
Long toOfficeId = JdbcSupport.getLong(rs, "toOfficeId"); Long toOfficeId = JdbcSupport.getLong(rs, "toOfficeId");
String toOfficeName = rs.getString("toOfficeName"); String toOfficeName = rs.getString("toOfficeName");
String currencyCode = rs.getString("currencyCode"); String currencyCode = rs.getString("currencyCode");
Integer digitsAfterDecimal = JdbcSupport.getInteger(rs, String currencyName = rs.getString("currencyName");
"digitsAfterDecimal"); String currencyNameCode = rs.getString("currencyNameCode");
String currencyDisplaySymbol = rs
.getString("currencyDisplaySymbol");
Integer currencyDigits = JdbcSupport.getInteger(rs,
"currencyDigits");
CurrencyData currencyData = new CurrencyData(currencyCode,
currencyName, currencyDigits, currencyDisplaySymbol,
currencyNameCode);
BigDecimal transactionAmount = rs BigDecimal transactionAmount = rs
.getBigDecimal("transactionAmount"); .getBigDecimal("transactionAmount");
String description = rs.getString("description"); String description = rs.getString("description");
return new OfficeTransactionData(id, transactionDate, fromOfficeId, return new OfficeTransactionData(id, transactionDate, fromOfficeId,
fromOfficeName, toOfficeId, toOfficeName, currencyCode, fromOfficeName, toOfficeId, toOfficeName, currencyData,
digitsAfterDecimal, transactionAmount, description); transactionAmount, description);
} }
} }
@@ -221,11 +233,13 @@ public class OfficeReadPlatformServiceImpl implements OfficeReadPlatformService
String hierarchySearchString = hierarchy + "%"; String hierarchySearchString = hierarchy + "%";
OfficeTransactionMapper rm = new OfficeTransactionMapper(); OfficeTransactionMapper rm = new OfficeTransactionMapper();
String sql = "select " + rm.officeTransactionSchema() String sql = "select "
+ rm.officeTransactionSchema()
+ " where (fromoff.hierarchy like ? or tooff.hierarchy like ?) order by ot.transaction_date, ot.id"; + " where (fromoff.hierarchy like ? or tooff.hierarchy like ?) order by ot.transaction_date, ot.id";
return this.jdbcTemplate.query(sql, rm, return this.jdbcTemplate.query(sql, rm, new Object[] {
new Object[] { hierarchySearchString, hierarchySearchString }); } hierarchySearchString, hierarchySearchString });
}
@Override @Override
public OfficeTransactionData retrieveNewOfficeTransactionDetails() { public OfficeTransactionData retrieveNewOfficeTransactionDetails() {