From cc8bd8ba5ece37b9db6219709b1b2d373d5cbf01 Mon Sep 17 00:00:00 2001 From: John Woodlock Date: Mon, 28 May 2012 02:27:57 +1000 Subject: [PATCH] getLong replacement (temp) plus some api doc updates --- APIFolder/api.htm | 166 ++++++++++-------- APIFolder/apidocs.css | 1 + APIFolder/docUpdateComments.txt | 2 +- .../ReadExtraDataAndReportingServiceImpl.java | 2 + .../ApiDataConversionService.java | 6 +- .../ApiDataConversionServiceImpl.java | 56 ++++-- .../OfficeReadPlatformServiceImpl.java | 12 +- 7 files changed, 150 insertions(+), 95 deletions(-) diff --git a/APIFolder/api.htm b/APIFolder/api.htm index 7d2fa28ce..42bc07402 100644 --- a/APIFolder/api.htm +++ b/APIFolder/api.htm @@ -18,6 +18,8 @@
@@ -1859,67 +1909,31 @@ Request Body:

Retrieve Office Details Template

-

Returns a template that contains the office fields and allowed value lists. This is a convienence when building user intereface screens for client applications. +

This is a convenience resource. It can be useful when building maintenance user interface screens for client applications. The template data returned consists of any or all of: +

    +
  • Field Defaults
  • +
  • Allowed Value Lists
  • +

-

Example Request: - - https://localhost:8443/mifosng-provider/api/v1/offices/template +

Example Request:

+ + https://localhost:8443/mifosng-provider/api/v1/offices/template?pretty=true -

GET https://thedomainname/api/v1/offices/template - -{ - "id": null, - "name": null, - "externalId": null, - "openingDate": "2012-05-21", - "hierarchy": null, - "parentName": null, - "parentId": null, - "allowedParents": [ - { - "id": 1, - "name": "Demo MFI Head Office", - "externalId": "1", - "openingDate": "2009-01-01", - "hierarchy": ".", - "parentName": null, - "parentId": 0, - "allowedParents": [] - }, - { - "id": 2, - "name": "sub branch 1", - "externalId": "2", - "openingDate": "2012-01-02", - "hierarchy": ".2.", - "parentName": "Demo MFI Head Office", - "parentId": 1, - "allowedParents": [] - }, - { - "id": 3, - "name": "sub branch 2", - "externalId": "3", - "openingDate": "2012-03-01", - "hierarchy": ".3.", - "parentName": "Demo MFI Head Office", - "parentId": 1, - "allowedParents": [] - }, - { - "id": 4, - "name": "sub branch 3", - "externalId": null, - "openingDate": "2012-04-17", - "hierarchy": ".4.", - "parentName": "Demo MFI Head Office", - "parentId": 1, - "allowedParents": [] - } - ] +{ + "openingDate" : [ 2012, 5, 28 ], + "allowedParents" : [ { + "id" : 1, + "name" : "Demo MFI Head Office" + }, { + "id" : 2, + "name" : "B1" + }, { + "id" : 3, + "name" : "B2" + } ] }
@@ -1928,26 +1942,30 @@ Request Body:  
GET https://thedomainname/api/v1/offices/1 - -{ - "id": 1, - "name": "Demo MFI Head Office", - "externalId": "1", - "openingDate": "2009-01-01", - "hierarchy": ".", - "parentName": null, - "parentId": 0, - "allowedParents": [] +{ + "id" : 1, + "name" : "Demo MFI Head Office", + "externalId" : "1", + "openingDate" : [ 2009, 1, 1 ], + "hierarchy" : ".", + "parentName" : null, + "parentId" : null }
@@ -2431,7 +2449,7 @@ Request Body:

Returns the list of currencies permitted for use AND the list of currencies not selected (but available for selection).

Example Requests:

https://localhost:8443/mifosng-provider/api/v1/configurations/currency?pretty=true -
+

https://localhost:8443/mifosng-provider/api/v1/configurations/currency?pretty=true&fields=selectedCurrencyOptions
diff --git a/APIFolder/apidocs.css b/APIFolder/apidocs.css index a5aff1972..9a31362ea 100644 --- a/APIFolder/apidocs.css +++ b/APIFolder/apidocs.css @@ -43,6 +43,7 @@ color: rgb(240, 240, 255); } +.normalli {list-style:disc outside none;} html{color:#000;background:#FFF;}body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,code,form,fieldset,legend,input,textarea,p,blockquote,th,tdjpw{margin:0;padding:0;}tablejpw{border-collapse:collapse;border-spacing:0;}fieldset,img{border:0;}address,caption,cite,code,dfn,em,strong,th,var{font-style:normal;font-weight:normal;}li{list-style:none;}caption,th{text-align:left;}h1,h2,h3,h4,h5,h6{font-size:100%;font-weight:normal;}q:before,q:after{content:'';}abbr,acronym{border:0;font-variant:normal;}sup{vertical-align:text-top;}sub{vertical-align:text-bottom;}input,textarea,select{font-family:inherit;font-size:inherit;font-weight:inherit;}input,textarea,select{*font-size:100%;}legend{color:#000;} diff --git a/APIFolder/docUpdateComments.txt b/APIFolder/docUpdateComments.txt index 330bf4ce1..67215cf02 100644 --- a/APIFolder/docUpdateComments.txt +++ b/APIFolder/docUpdateComments.txt @@ -1,6 +1,6 @@ \loan\?\transactions\id get exception if loan doesn't match id.... should loan be taken out here? template for waiver/repayment... is it same for both? no type needed? -new loan template ... is it 2 templates... one to pick product... and 2nd to return default properties in selected product +new loan template ... is it 2 templates... one to pick product... and 2nd to return default properties in selected product or is it meant that if only one product then use that. Configuration diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/ReadExtraDataAndReportingServiceImpl.java b/mifosng-provider/src/main/java/org/mifosng/platform/ReadExtraDataAndReportingServiceImpl.java index b39e5293d..aac3d6611 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/ReadExtraDataAndReportingServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/ReadExtraDataAndReportingServiceImpl.java @@ -434,6 +434,8 @@ public class ReadExtraDataAndReportingServiceImpl implements rsch.setColumnDisplayType(rsmd.getString("display_type")); allowedListId = rsmd.getInt("allowed_list_id"); if (allowedListId != null) { + + logger.info("allowedListId != null: Column: " + rsch.getColumnName()); sql = "select v.`name` from stretchydata_allowed_value v where allowed_list_id = " + allowedListId + " order by id"; ResultSet rsValues = db_statement2.executeQuery(sql); diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/api/infrastructure/ApiDataConversionService.java b/mifosng-provider/src/main/java/org/mifosng/platform/api/infrastructure/ApiDataConversionService.java index 706600ea7..cdd4508bc 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/api/infrastructure/ApiDataConversionService.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/api/infrastructure/ApiDataConversionService.java @@ -7,8 +7,10 @@ import org.joda.time.LocalDate; public interface ApiDataConversionService { - LocalDate convertFrom(String dateAsString, String parameterName, String dateFormat); + LocalDate convertFrom(String dateAsString, String parameterName, + String dateFormat); - BigDecimal convertFrom(String principalFormatted, String parameterName, Locale clientApplicationLocale); + BigDecimal convertFrom(String principalFormatted, String parameterName, + Locale clientApplicationLocale); } diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/api/infrastructure/ApiDataConversionServiceImpl.java b/mifosng-provider/src/main/java/org/mifosng/platform/api/infrastructure/ApiDataConversionServiceImpl.java index 356053bae..5bf0fd87f 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/api/infrastructure/ApiDataConversionServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/api/infrastructure/ApiDataConversionServiceImpl.java @@ -19,45 +19,69 @@ import org.springframework.stereotype.Service; public class ApiDataConversionServiceImpl implements ApiDataConversionService { @Override - public LocalDate convertFrom(String dateAsString, String parameterName, String dateFormat) { + public LocalDate convertFrom(String dateAsString, String parameterName, + String dateFormat) { LocalDate eventLocalDate = null; if (StringUtils.isNotBlank(dateAsString)) { try { Locale locale = LocaleContextHolder.getLocale(); - eventLocalDate = DateTimeFormat.forPattern(dateFormat).withLocale(locale).parseLocalDate(dateAsString.toLowerCase(locale)); + eventLocalDate = DateTimeFormat.forPattern(dateFormat) + .withLocale(locale) + .parseLocalDate(dateAsString.toLowerCase(locale)); } catch (IllegalArgumentException e) { List dataValidationErrors = new ArrayList(); - ApiParameterError error = ApiParameterError.parameterError("validation.msg.invalid.date.format", "The parameter " + parameterName + " is invalid based on the dateFormat provided:" + dateFormat, parameterName, dateAsString, dateFormat); + ApiParameterError error = ApiParameterError + .parameterError( + "validation.msg.invalid.date.format", + "The parameter " + + parameterName + + " is invalid based on the dateFormat provided:" + + dateFormat, parameterName, + dateAsString, dateFormat); dataValidationErrors.add(error); - - throw new PlatformApiDataValidationException("validation.msg.validation.errors.exist", "Validation errors exist.", dataValidationErrors); + + throw new PlatformApiDataValidationException( + "validation.msg.validation.errors.exist", + "Validation errors exist.", dataValidationErrors); } } - + return eventLocalDate; } @Override - public BigDecimal convertFrom(String numericalValueFormatted, String parameterName, Locale clientApplicationLocale) { - + public BigDecimal convertFrom(String numericalValueFormatted, + String parameterName, Locale clientApplicationLocale) { + try { BigDecimal number = null; if (StringUtils.isNotBlank(numericalValueFormatted)) { - String sourceWithoutSpaces = numericalValueFormatted.replaceAll(" ", ""); - NumberFormat format = NumberFormat.getNumberInstance(clientApplicationLocale); + String sourceWithoutSpaces = numericalValueFormatted + .replaceAll(" ", ""); + NumberFormat format = NumberFormat + .getNumberInstance(clientApplicationLocale); Number parsedNumber = format.parse(sourceWithoutSpaces); - number = BigDecimal.valueOf(Double.valueOf(parsedNumber.doubleValue())); + number = BigDecimal.valueOf(Double.valueOf(parsedNumber + .doubleValue())); } - + return number; } catch (ParseException e) { - + List dataValidationErrors = new ArrayList(); - ApiParameterError error = ApiParameterError.parameterError("validation.msg.invalid.number.format", "The parameter " + parameterName + " is invalid for provided locale" + clientApplicationLocale.toString() + ".", parameterName, numericalValueFormatted, clientApplicationLocale); + ApiParameterError error = ApiParameterError.parameterError( + "validation.msg.invalid.number.format", "The parameter " + + parameterName + " is invalid for provided locale" + + clientApplicationLocale.toString() + ".", + parameterName, numericalValueFormatted, + clientApplicationLocale); dataValidationErrors.add(error); - - throw new PlatformApiDataValidationException("validation.msg.validation.errors.exist", "Validation errors exist.", dataValidationErrors); + + throw new PlatformApiDataValidationException( + "validation.msg.validation.errors.exist", + "Validation errors exist.", dataValidationErrors); } } + } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/organisation/service/OfficeReadPlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosng/platform/organisation/service/OfficeReadPlatformServiceImpl.java index bfaaf960f..293c8032e 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/organisation/service/OfficeReadPlatformServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/organisation/service/OfficeReadPlatformServiceImpl.java @@ -32,7 +32,7 @@ public class OfficeReadPlatformServiceImpl implements OfficeReadPlatformService this.context = context; this.jdbcTemplate = new SimpleJdbcTemplate(dataSource); } - + private static final class OfficeMapper implements RowMapper { public String officeSchema() { @@ -49,7 +49,9 @@ public class OfficeReadPlatformServiceImpl implements OfficeReadPlatformService String externalId = rs.getString("externalId"); LocalDate openingDate = new LocalDate(rs.getDate("openingDate")); String hierarchy = rs.getString("hierarchy"); - Long parentId = rs.getLong("parentId"); + + Long parentId = getRSLong(rs.getString("parentId"), rs.getLong("parentId")); + String parentName = rs.getString("parentName"); return new OfficeData(id, name, externalId, openingDate, hierarchy, @@ -165,4 +167,10 @@ public class OfficeReadPlatformServiceImpl implements OfficeReadPlatformService } + public static Long getRSLong(String stringVal, Long longVal) { + if (stringVal == null) + return null; + + return longVal; + } } \ No newline at end of file