diff --git a/APIFolder/api.htm b/APIFolder/api.htm index 82de72b4d..bfab265d5 100644 --- a/APIFolder/api.htm +++ b/APIFolder/api.htm @@ -10,8 +10,9 @@
+
-

API Overview

+

Overview

@@ -30,21 +31,21 @@
- - - - - - - - - - - - - - - + + + + + + + + + + + + + + +
Resources
POST
create/update
GET
read
PUT
simple update
DELETE
delete
CLIENT/v1/clientsCreate a ClientList Clients--
/v1/clients/{clientId}-Retrieve a ClientUpdate a Client-
/v1/clients/{clientId}/loans-Retrieve a Client's Loan Account Summary--
/v1/clients/{clientId}/notesAdd a Client NoteRetrieve a Client's Notes--
/v1/clients/{clientId}/notes/{noteId}-Retrieve a Client NoteUpdate a Client Note-
LOAN/v1/loansCreate a New Loan/Submit a Loan Application---
/v1/loans/{loanId}Approve, Disburse, Reject a Loan or Withdraw a Loan ApplicationRetrieve a Loan-Delete a Loan
/v1/loans/{loanId}/undoUndo Loan Approval or Disbursal---
/v1/loans/{loanId}/transactionsMake a Repayment / Loan Waiver---
/v1/loans/{loanId}/transactions/{transactionId}-Retrieve a Repayment or Waiver DetailsAdjust a Repayment or Waiver-
OFFICE/v1/officesCreate an OfficeList Offices--
/v1/offices/{officeId}-Retrieve an OfficeUpdate an Office-
LOAN PRODUCT/v1/loanproductsCreate a Loan ProductList Loan Products--
/v1/loanproducts/{productId}-Retrieve a Loan ProductUpdate a Loan Product-
RESOURCES
POST
create/update
GET
read
PUT
simple update
DELETE
delete
CLIENT/v1/clientsCreate a ClientList Clients
/v1/clients/{clientId}Retrieve a ClientUpdate a Client
/v1/clients/{clientId}/loansRetrieve a Client's Loan Account Summary
/v1/clients/{clientId}/notesAdd a Client NoteRetrieve a Client's Notes
/v1/clients/{clientId}/notes/{noteId}Retrieve a Client NoteUpdate a Client Note
LOAN/v1/loansCreate a New Loan/Submit a Loan Application
/v1/loans/{loanId}Approve, Disburse, Reject a Loan or Withdraw a Loan ApplicationRetrieve a LoanDelete a Loan
/v1/loans/{loanId}/undoUndo Loan Approval or Disbursal
/v1/loans/{loanId}/transactionsMake a Repayment / Loan Waiver
/v1/loans/{loanId}/transactions/{transactionId}Retrieve a Repayment or Waiver DetailsAdjust a Repayment or Waiver
OFFICE/v1/officesCreate an OfficeList Offices
/v1/offices/{officeId}Retrieve an OfficeUpdate an Office
LOAN PRODUCT/v1/loanproductsCreate a Loan ProductList Loan Products
/v1/loanproducts/{productId}Retrieve a Loan ProductUpdate a Loan Product
@@ -52,10 +53,10 @@

Configuration

-
+
- - + +
Resources
POST
create/update
GET
read
PUT
simple update
DELETE
delete
CONFIGURATION/v1/configurations/currency-Retrieve Currency ConfigurationUpdate Currency Configuration-
RESOURCES
POST
create/update
GET
read
PUT
simple update
DELETE
delete
CONFIGURATION/v1/configurations/currencyRetrieve Currency ConfigurationUpdate Currency Configuration
@@ -63,11 +64,11 @@

Additional Fields

-
+
- - - + + +
Resources
POST
create/update
GET
read
PUT
simple update
DELETE
delete
ADDITIONAL FIELDS/v1/additionalfields-List Additional Fields Sets--
/v1/additionalfields/{Type}/{Set}/{id}Update Additional FieldsRetrieve Additional Fields--
RESOURCES
POST
create/update
GET
read
PUT
simple update
DELETE
delete
ADDITIONAL FIELDS/v1/additionalfieldsList Additional Fields Sets
/v1/additionalfields/{Type}/{Set}/{id}Update Additional FieldsRetrieve Additional Fields
@@ -75,11 +76,11 @@

Report

-
+
- - - + + +
Resources
POST
create/update
GET
read
PUT
simple update
DELETE
delete
REPORT/v1/reports-List Reports--
/v1/reports/{reportName}-Run a Report--
RESOURCES
POST
create/update
GET
read
PUT
simple update
DELETE
delete
REPORT/v1/reportsList Reports
/v1/reports/{reportName}Run a Report
@@ -87,17 +88,17 @@

User Related

-
+
- - - - - - - - - + + + + + + + + +
Resources
POST
create/update
GET
read
PUT
simple update
DELETE
delete
AUTHENTICATION/v1/authenticationVerify Authentication---
USER ACCOUNT/v1/useraccounts/current-Retrieve Current Users' Account DetailsUpdate Current Users' Account Details-
/v1/useraccounts/current/password--Update Current Users' Password-
USER/v1/usersCreate a UserList Users--
/v1/users/{userId}-Retrieve a UserUpdate a UserDelete a User
ROLE/v1/rolesCreate a New RoleList Roles--
/v1/roles/{roleId}-Retrieve a RoleUpdate a Role-
PERMISSION/v1/permissions-List Application Permissions--
RESOURCES
POST
create/update
GET
read
PUT
simple update
DELETE
delete
AUTHENTICATION/v1/authenticationVerify Authentication
USER ACCOUNT/v1/useraccounts/currentRetrieve Current Users' Account DetailsUpdate Current Users' Account Details
/v1/useraccounts/current/passwordUpdate Current Users' Password
USER/v1/usersCreate a UserList Users
/v1/users/{userId}Retrieve a UserUpdate a UserDelete a User
ROLE/v1/rolesCreate a New RoleList Roles
/v1/roles/{roleId}Retrieve a RoleUpdate a Role
PERMISSION/v1/permissionsList Application Permissions
@@ -105,9 +106,9 @@

Convenience

-
+
- + @@ -1821,47 +1822,37 @@ Request Body:
GET https://thedomainname/api/v1/offices - -{ - "offices": [ - { - "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" : 1, + "name" : "Demo MFI Head Office", + "externalId" : "1", + "openingDate" : [ 2009, 1, 1 ], + "hierarchy" : ".", + "parentName" : null, + "parentId" : null +}, { + "id" : 2, + "name" : "B1", + "externalId" : null, + "openingDate" : [ 2012, 4, 1 ], + "hierarchy" : ".2.", + "parentName" : "Demo MFI Head Office", + "parentId" : 1 +}, { + "id" : 3, + "name" : "B2", + "externalId" : null, + "openingDate" : [ 2012, 4, 4 ], + "hierarchy" : ".3.", + "parentName" : "Demo MFI Head Office", + "parentId" : 1 +} ]
@@ -3969,53 +3960,52 @@ Request body:   -
-

- -
Convenience Resources
GET
read
RESOURCES
GET
read
/v1/clients/templateRetrieve Client Details Template
/v1/loans/templateRetrieve Loan Details Template
/v1/loans/{loanId}/transactions/templateRetrieve Loan Repayment/Loan Waiver Template

Full API Matrix

Mifos X API Endpoint:
https://thedomainname/api
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Resources
POST
create/update
GET
read
PUT
simple update
DELETE
delete
CLIENT/v1/clientsCreate a ClientList Clients--
/v1/clients/{clientId}-Retrieve a ClientUpdate a Client-
/v1/clients/{clientId}/loans-Retrieve a Client's Loan Account Summary--
/v1/clients/{clientId}/notesAdd a Client NoteRetrieve a Client's Notes--
/v1/clients/{clientId}/notes/{noteId}-Retrieve a Client NoteUpdate a Client Note-
LOAN/v1/loansCreate a New Loan/Submit a Loan Application---
/v1/loans/{loanId}Approve, Disburse, Reject a Loan or Withdraw a Loan ApplicationRetrieve a Loan-Delete a Loan
/v1/loans/{loanId}/undoUndo Loan Approval or Disbursal---
/v1/loans/{loanId}/transactionsMake a Repayment / Loan Waiver---
/v1/loans/{loanId}/transactions/{transactionId}-Retrieve a Repayment or Waiver DetailsAdjust a Repayment or Waiver-
OFFICE/v1/officesCreate an OfficeList Offices--
/v1/offices/{officeId}-Retrieve an OfficeUpdate an Office-
LOAN PRODUCT/v1/loanproductsCreate a Loan ProductList Loan Products--
/v1/loanproducts/{productId}-Retrieve a Loan ProductUpdate a Loan Product-
CONFIGURATION/v1/configurations/currency-Retrieve Currency ConfigurationUpdate Currency Configuration-
ADDITIONAL FIELDS/v1/additionalfields-List Additional Fields Sets--
/v1/additionalfields/{Type}/{Set}/{id}Update Additional FieldsRetrieve Additional Fields--
REPORT/v1/reports-List Reports--
/v1/reports/{reportName}-Run a Report--
AUTHENTICATION/v1/authenticationVerify Authentication---
USER ACCOUNT/v1/useraccounts/current-Retrieve Current Users' Account DetailsUpdate Current Users' Account Details-
/v1/useraccounts/current/password--Update Current Users' Password-
USER/v1/usersCreate a UserList Users--
/v1/users/{userId}-Retrieve a UserUpdate a UserDelete a User
ROLE/v1/rolesCreate a New RoleList Roles--
/v1/roles/{roleId}-Retrieve a RoleUpdate a Role-
PERMISSION/v1/permissions-List Application Permissions--
-
- - - - - - - - - - -
Convenience Resources
GET
read
/v1/clients/templateRetrieve Client Details Template
/v1/loans/templateRetrieve Loan Details Template
/v1/loans/{loanId}/transactions/templateRetrieve Loan Repayment/Loan Waiver Template
/v1/offices/templateRetrieve Office Details Template
/v1/loanproducts/templateRetrieve Loan Product Details Template
/v1/useraccounts/current/password/templateRetrieve change password template
/v1/users/templateRetrieve new user template
/v1/roles/templateRetrieve new role template
- +


+
+

Full API Matrix

API Endpoint:

https://thedomainname/api
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
RESOURCES
POST
create/update
GET
read
PUT
simple update
DELETE
delete
CLIENT/v1/clientsCreate a ClientList Clients
/v1/clients/{clientId}Retrieve a ClientUpdate a Client
/v1/clients/{clientId}/loansRetrieve a Client's Loan Account Summary
/v1/clients/{clientId}/notesAdd a Client NoteRetrieve a Client's Notes
/v1/clients/{clientId}/notes/{noteId}Retrieve a Client NoteUpdate a Client Note
LOAN/v1/loansCreate a New Loan/Submit a Loan Application
/v1/loans/{loanId}Approve, Disburse, Reject a Loan or Withdraw a Loan ApplicationRetrieve a LoanDelete a Loan
/v1/loans/{loanId}/undoUndo Loan Approval or Disbursal
/v1/loans/{loanId}/transactionsMake a Repayment / Loan Waiver
/v1/loans/{loanId}/transactions/{transactionId}Retrieve a Repayment or Waiver DetailsAdjust a Repayment or Waiver
OFFICE/v1/officesCreate an OfficeList Offices
/v1/offices/{officeId}Retrieve an OfficeUpdate an Office
LOAN PRODUCT/v1/loanproductsCreate a Loan ProductList Loan Products
/v1/loanproducts/{productId}Retrieve a Loan ProductUpdate a Loan Product
CONFIGURATION/v1/configurations/currencyRetrieve Currency ConfigurationUpdate Currency Configuration
ADDITIONAL FIELDS/v1/additionalfieldsList Additional Fields Sets
/v1/additionalfields/{Type}/{Set}/{id}Update Additional FieldsRetrieve Additional Fields
REPORT/v1/reportsList Reports
/v1/reports/{reportName}Run a Report
AUTHENTICATION/v1/authenticationVerify Authentication
USER ACCOUNT/v1/useraccounts/currentRetrieve Current Users' Account DetailsUpdate Current Users' Account Details
/v1/useraccounts/current/passwordUpdate Current Users' Password
USER/v1/usersCreate a UserList Users
/v1/users/{userId}Retrieve a UserUpdate a UserDelete a User
ROLE/v1/rolesCreate a New RoleList Roles
/v1/roles/{roleId}Retrieve a RoleUpdate a Role
PERMISSION/v1/permissionsList Application Permissions
+
+ + + + + + + + + + +
CONVENIENCE RESOURCES
GET
read
/v1/clients/templateRetrieve Client Details Template
/v1/loans/templateRetrieve Loan Details Template
/v1/loans/{loanId}/transactions/templateRetrieve Loan Repayment/Loan Waiver Template
/v1/offices/templateRetrieve Office Details Template
/v1/loanproducts/templateRetrieve Loan Product Details Template
/v1/useraccounts/current/password/templateRetrieve change password template
/v1/users/templateRetrieve new user template
/v1/roles/templateRetrieve new role template
+
diff --git a/APIFolder/apicss/apidocs.css b/APIFolder/apicss/apidocs.css index d908c83d0..a5aff1972 100644 --- a/APIFolder/apicss/apidocs.css +++ b/APIFolder/apicss/apidocs.css @@ -1,29 +1,36 @@ .tocMatrix { font-size: 85%; } +.fullMatrixOuter { + margin-right: 20px; + margin-left: 20px; + margin-bottom: 20px; +} .matrixHeading { font-family: Helvetica, Arial, sans-serif; border-collapse:collapse; - margin-right:10px; - margin-left:10px; - border:3px solid blue; + border:3px solid #6eb4db; + width:100%; } -.matrixHeading td, +.matrixHeading td { - border:1px solid #98bf21; - padding:3px 7px 2px 7px; + //padding:3px 7px 2px 7px; + + padding-right:5px; + + vertical-align:text-top; } -.matrixHeading tr.alt td +.matrixHeading tr.alt { color:#000; - background-color:#EAF2D3; + background-color: rgb(240, 240, 255); } .matrixHeadingBG { - background-color: blue; + background-color: #6eb4db; } .matrixHeadingVerbs { @@ -32,6 +39,10 @@ font-size: 125% } +.matrixHeadingCommands { + color: rgb(240, 240, 255); +} + 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;} @@ -86,7 +97,7 @@ body { background: #eee; background: -webkit-gradient(linear, left top, left bottom, from(#f8f8f8), to(#dadada)); background: -moz-linear-gradient(top, #f8f8f8, #dadada); - border-top: 15px solid black; + border-top: 3px solid black; border-bottom: 1px solid #888; -webkit-box-shadow: 0 3px 5px rgba(0,0,0,0.1); -moz-box-shadow: 0 3px 5px rgba(0,0,0,0.1); @@ -97,8 +108,13 @@ body { display: block; height: 30px; position: absolute; - top: 7px; - left: 10px; + top: 10px; + left: 20px; + font-weight: bold; + color: black; + font-size: 16px; + text-decoration: none; + } .flybar-button { @@ -141,7 +157,7 @@ body { position: absolute; top: 41px; - width: 800px; + width: 850px; background-color: rgba(249, 249, 249, 0.99); border: 1px solid rgb(187, 187, 187); border-top: 0; @@ -175,7 +191,7 @@ body { position: absolute; top: 41px; - width: 600px; + width: 575px; background-color: rgba(249, 249, 249, 0.99); border: 1px solid rgb(187, 187, 187); border-top: 0; diff --git a/mifosng-data/src/main/java/org/mifosng/data/OfficeData.java b/mifosng-data/src/main/java/org/mifosng/data/OfficeData.java index 674746dfb..3c0bb7688 100644 --- a/mifosng-data/src/main/java/org/mifosng/data/OfficeData.java +++ b/mifosng-data/src/main/java/org/mifosng/data/OfficeData.java @@ -1,6 +1,8 @@ package org.mifosng.data; import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; import javax.xml.bind.annotation.XmlRootElement; @@ -18,7 +20,7 @@ public class OfficeData implements Serializable { private String hierarchy; private String parentName; private Long parentId; - private OfficeTemplateData officeTemplateData; + private List allowedParents = new ArrayList(); public OfficeData() { // @@ -92,11 +94,12 @@ public class OfficeData implements Serializable { this.hierarchy = hierarchy; } - public OfficeTemplateData getOfficeTemplateData() { - return officeTemplateData; + public List getAllowedParents() { + return allowedParents; } - public void setOfficeTemplateData(OfficeTemplateData officeTemplateData) { - this.officeTemplateData = officeTemplateData; + public void setAllowedParents(List allowedParents) { + this.allowedParents = allowedParents; } + } \ No newline at end of file diff --git a/mifosng-data/src/main/java/org/mifosng/data/OfficeList.java b/mifosng-data/src/main/java/org/mifosng/data/OfficeList.java deleted file mode 100644 index 1527f5bf6..000000000 --- a/mifosng-data/src/main/java/org/mifosng/data/OfficeList.java +++ /dev/null @@ -1,28 +0,0 @@ -package org.mifosng.data; - -import java.util.ArrayList; -import java.util.Collection; - -import javax.xml.bind.annotation.XmlRootElement; - -@XmlRootElement -public class OfficeList { - - private Collection offices = new ArrayList(); - - protected OfficeList() { - // - } - - public OfficeList(final Collection offices) { - this.offices = offices; - } - - public Collection getOffices() { - return this.offices; - } - - public void setOffices(final Collection offices) { - this.offices = offices; - } -} \ No newline at end of file diff --git a/mifosng-data/src/main/java/org/mifosng/data/OfficeTemplateData.java b/mifosng-data/src/main/java/org/mifosng/data/OfficeTemplateData.java deleted file mode 100644 index e5c002af0..000000000 --- a/mifosng-data/src/main/java/org/mifosng/data/OfficeTemplateData.java +++ /dev/null @@ -1,43 +0,0 @@ -package org.mifosng.data; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; - -import javax.xml.bind.annotation.XmlRootElement; - -import org.joda.time.LocalDate; - -@XmlRootElement(name = "office template") -public class OfficeTemplateData implements Serializable { - - private LocalDate defaultOpeningDate; - private List allowedParents = new ArrayList(); - - public OfficeTemplateData() { - // - } - - public OfficeTemplateData(final LocalDate defaultOpeningDate, - final List allowedParents) { - this.defaultOpeningDate = defaultOpeningDate; - this.allowedParents = allowedParents; - } - - public LocalDate getDefaultOpeningDate() { - return defaultOpeningDate; - } - - public void setDefaultOpeningDate(LocalDate defaultOpeningDate) { - this.defaultOpeningDate = defaultOpeningDate; - } - - public List getAllowedParents() { - return allowedParents; - } - - public void setAllowedParents(List allowedParents) { - this.allowedParents = allowedParents; - } - -} \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/api/OfficeApiResource.java b/mifosng-provider/src/main/java/org/mifosng/platform/api/OfficeApiResource.java index 1582b5408..450c86a3c 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/api/OfficeApiResource.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/api/OfficeApiResource.java @@ -18,14 +18,11 @@ import javax.ws.rs.core.Response; import org.joda.time.LocalDate; import org.mifosng.data.EntityIdentifier; import org.mifosng.data.OfficeData; -import org.mifosng.data.OfficeTemplateData; import org.mifosng.data.command.OfficeCommand; import org.mifosng.platform.api.infrastructure.ApiDataConversionService; import org.mifosng.platform.api.infrastructure.ApiJSONFormattingService; import org.mifosng.platform.organisation.service.OfficeReadPlatformService; import org.mifosng.platform.organisation.service.OfficeWritePlatformService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; @@ -35,8 +32,6 @@ import org.springframework.stereotype.Component; @Scope("singleton") public class OfficeApiResource { - private final static Logger logger = LoggerFactory.getLogger(OfficeApiResource.class); - @Autowired private OfficeReadPlatformService readPlatformService; @@ -45,45 +40,42 @@ public class OfficeApiResource { @Autowired private ApiDataConversionService apiDataConversionService; - + @Autowired private ApiJSONFormattingService jsonFormattingService; @GET @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @Produces({ MediaType.APPLICATION_JSON }) - public String retrieveOffices(@QueryParam("fields") String fields) { + public String retrieveOffices(@QueryParam("fields") String fields, + @QueryParam("pretty") String pretty) { Collection offices = this.readPlatformService .retrieveAllOffices(); Set excludeFields = new HashSet(); - excludeFields.add("officeTemplateData"); - - // can use parameters for turning this on/off etc. - boolean prettyOutput = true; - - return this.jsonFormattingService.convertDataObjectJSON(offices, fields, excludeFields, prettyOutput); + excludeFields.add("allowedParents"); + + return this.jsonFormattingService.convertDataObjectJSON(offices, + fields, excludeFields, + this.jsonFormattingService.isTrue(pretty)); } @GET @Path("template") @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @Produces({ MediaType.APPLICATION_JSON }) - public String retrieveOfficeTemplate() { + public String retrieveOfficeTemplate(@QueryParam("pretty") String pretty) { - OfficeData officeData = new OfficeData(); - OfficeTemplateData officeTemplateData = this.readPlatformService + OfficeData officeData = this.readPlatformService .retrieveNewOfficeTemplate(); - officeData.setOfficeTemplateData(officeTemplateData); Set excludeFields = new HashSet(); - String includeFields = "officeTemplateData"; - - // can use parameters for turning this on/off etc. - boolean prettyOutput = true; - - return this.jsonFormattingService.convertDataObjectJSON(officeData, includeFields, excludeFields, prettyOutput); + String includeFields = "openingDate,allowedParents"; + + return this.jsonFormattingService.convertDataObjectJSON(officeData, + includeFields, excludeFields, + this.jsonFormattingService.isTrue(pretty)); } @POST @@ -107,42 +99,30 @@ public class OfficeApiResource { @Produces({ MediaType.APPLICATION_JSON }) public String retreiveOffice(@PathParam("officeId") final Long officeId, @QueryParam("fields") String fields, - @QueryParam("returnTemplateData") String returnTemplateData) { - - Boolean isReturnTemplate = false; - if (returnTemplateData != null - && returnTemplateData.equalsIgnoreCase("true")) { - isReturnTemplate = true; - } - - Boolean isIncludeFields = false; - if (!(fields == null || fields.equals(""))) { - isIncludeFields = true; - } - - OfficeData office = this.readPlatformService.retrieveOffice(officeId); - - if (isReturnTemplate) { - OfficeTemplateData officeTemplateData = this.readPlatformService - .retrieveExistingOfficeTemplate(officeId); - office.setOfficeTemplateData(officeTemplateData); - } + @QueryParam("template") String template, + @QueryParam("pretty") String pretty) { String includeFields = fields; Set excludeFields = new HashSet(); - if (isIncludeFields) { - if (isReturnTemplate) { - includeFields += ",officeTemplateData"; + OfficeData office = this.readPlatformService.retrieveOffice(officeId); + + if (this.jsonFormattingService.isTrue(template)) { + office.setAllowedParents(this.readPlatformService + .retrieveAllowedParents(officeId)); + + if (this.jsonFormattingService.isPassed(includeFields)) { + includeFields += ",allowedParents"; } + } else { - if (!(isReturnTemplate)) { - excludeFields.add("officeTemplateData"); + if (!(this.jsonFormattingService.isPassed(includeFields))) { + excludeFields.add("allowedParents"); } } - - boolean prettyOutput = true; - - return this.jsonFormattingService.convertDataObjectJSON(office, includeFields, excludeFields, prettyOutput); + + return this.jsonFormattingService.convertDataObjectJSON(office, + includeFields, excludeFields, + this.jsonFormattingService.isTrue(pretty)); } @PUT diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/api/infrastructure/ApiJSONFormattingService.java b/mifosng-provider/src/main/java/org/mifosng/platform/api/infrastructure/ApiJSONFormattingService.java index fb3ef3aed..d6dd5d698 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/api/infrastructure/ApiJSONFormattingService.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/api/infrastructure/ApiJSONFormattingService.java @@ -7,4 +7,8 @@ public interface ApiJSONFormattingService { String convertDataObjectJSON(Object dataObject, String fields, Set excludeFields, boolean prettyOutput); + Boolean isTrue(String param); + + Boolean isPassed(String param); + } diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/api/infrastructure/ApiJSONFormattingServiceImpl.java b/mifosng-provider/src/main/java/org/mifosng/platform/api/infrastructure/ApiJSONFormattingServiceImpl.java index 24173c6a7..b63562565 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/api/infrastructure/ApiJSONFormattingServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/api/infrastructure/ApiJSONFormattingServiceImpl.java @@ -20,10 +20,12 @@ import org.springframework.stereotype.Service; @Service public class ApiJSONFormattingServiceImpl implements ApiJSONFormattingService { - private final static Logger logger = LoggerFactory.getLogger(ApiJSONFormattingServiceImpl.class); - + private final static Logger logger = LoggerFactory + .getLogger(ApiJSONFormattingServiceImpl.class); + @Override - public String convertDataObjectJSON(Object dataObject, String fields, Set excludeFields, boolean prettyOutput) { + public String convertDataObjectJSON(Object dataObject, String fields, + Set excludeFields, boolean prettyOutput) { try { String json = ""; @@ -33,7 +35,8 @@ public class ApiJSONFormattingServiceImpl implements ApiJSONFormattingService { if (fields == null || fields.equals("")) { filters = new SimpleFilterProvider().addFilter(myFilter, - SimpleBeanPropertyFilter.serializeAllExcept(excludeFields)); + SimpleBeanPropertyFilter + .serializeAllExcept(excludeFields)); } else { @@ -43,18 +46,53 @@ public class ApiJSONFormattingServiceImpl implements ApiJSONFormattingService { } filters = new SimpleFilterProvider().addFilter(myFilter, - SimpleBeanPropertyFilter.filterOutAllExcept(includeFields)); + SimpleBeanPropertyFilter + .filterOutAllExcept(includeFields)); } - - ObjectWriter jsonWriter = new ObjectMapper().writerWithDefaultPrettyPrinter(); - json = jsonWriter.withFilters(filters).writeValueAsString(dataObject); + ObjectWriter jsonWriter = null; + + if (prettyOutput) { + jsonWriter = new ObjectMapper() + .writerWithDefaultPrettyPrinter(); + } else { + jsonWriter = new ObjectMapper().writer(); + } + + json = jsonWriter.withFilters(filters).writeValueAsString( + dataObject); return json; } catch (JsonGenerationException e) { - throw new PlatformInternalServerException("error.msg.platform.json.generation", "An error occured whilst generating response from the platform server.", e.getMessage(), e.getStackTrace()); + throw new PlatformInternalServerException( + "error.msg.platform.json.generation", + "An error occured whilst generating response from the platform server.", + e.getMessage(), e.getStackTrace()); } catch (JsonMappingException e) { - throw new PlatformInternalServerException("error.msg.platform.json.generation", "An error occured whilst generating response from the platform server.", e.getMessage(), e.getStackTrace()); + throw new PlatformInternalServerException( + "error.msg.platform.json.generation", + "An error occured whilst generating response from the platform server.", + e.getMessage(), e.getStackTrace()); } catch (IOException e) { - throw new PlatformInternalServerException("error.msg.platform.json.generation", "An error occured whilst generating response from the platform server.", e.getMessage(), e.getStackTrace()); + throw new PlatformInternalServerException( + "error.msg.platform.json.generation", + "An error occured whilst generating response from the platform server.", + e.getMessage(), e.getStackTrace()); } } + + @Override + public Boolean isTrue(String param) { + if (param != null && param.equalsIgnoreCase("true")) + return true; + else + return false; + } + + @Override + public Boolean isPassed(String param) { + if (param == null || param.equals("")) + return false; + else + return true; + } + } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/organisation/service/OfficeReadPlatformService.java b/mifosng-provider/src/main/java/org/mifosng/platform/organisation/service/OfficeReadPlatformService.java index f7ea5ce46..f3976a22b 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/organisation/service/OfficeReadPlatformService.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/organisation/service/OfficeReadPlatformService.java @@ -1,10 +1,10 @@ package org.mifosng.platform.organisation.service; import java.util.Collection; +import java.util.List; import org.mifosng.data.OfficeData; import org.mifosng.data.OfficeLookup; -import org.mifosng.data.OfficeTemplateData; public interface OfficeReadPlatformService { @@ -14,7 +14,7 @@ public interface OfficeReadPlatformService { OfficeData retrieveOffice(Long officeId); - OfficeTemplateData retrieveNewOfficeTemplate(); - - OfficeTemplateData retrieveExistingOfficeTemplate(Long officeId); + OfficeData retrieveNewOfficeTemplate(); + + List retrieveAllowedParents(Long officeId); } \ 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 8c28ef143..bfaaf960f 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 @@ -11,7 +11,6 @@ import javax.sql.DataSource; import org.joda.time.LocalDate; import org.mifosng.data.OfficeData; import org.mifosng.data.OfficeLookup; -import org.mifosng.data.OfficeTemplateData; import org.mifosng.platform.exceptions.PlatformResourceNotFoundException; import org.mifosng.platform.security.PlatformSecurityContext; import org.mifosng.platform.user.domain.AppUser; @@ -132,22 +131,22 @@ public class OfficeReadPlatformServiceImpl implements OfficeReadPlatformService } @Override - public OfficeTemplateData retrieveNewOfficeTemplate() { + public OfficeData retrieveNewOfficeTemplate() { context.authenticatedUser(); List parentLookups = new ArrayList( retrieveAllOfficesForLookup()); - OfficeTemplateData officeTemplateData = new OfficeTemplateData(); - officeTemplateData.setAllowedParents(parentLookups); - officeTemplateData.setDefaultOpeningDate(new LocalDate()); + OfficeData officeData = new OfficeData(); + officeData.setAllowedParents(parentLookups); + officeData.setOpeningDate(new LocalDate()); - return officeTemplateData; + return officeData; } @Override - public OfficeTemplateData retrieveExistingOfficeTemplate(Long officeId) { + public List retrieveAllowedParents(Long officeId) { context.authenticatedUser(); @@ -162,11 +161,7 @@ public class OfficeReadPlatformServiceImpl implements OfficeReadPlatformService } } - OfficeTemplateData officeTemplateData = new OfficeTemplateData(); - officeTemplateData.setAllowedParents(filterParentLookups); - officeTemplateData.setDefaultOpeningDate(new LocalDate()); - - return officeTemplateData; + return filterParentLookups; }