from MIFOSX-38 - update serialization of offices and office transactions.
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
ALTER TABLE `m_deposit_account` ADD COLUMN `status_enum` smallint(5) NOT NULL AFTER `is_deleted`;
|
ALTER TABLE `m_deposit_account` ADD COLUMN `status_enum` smallint(5) NOT NULL DEFAULT 0 AFTER `is_deleted`;
|
||||||
|
|
||||||
DROP TABLE IF EXISTS `m_deposit_account_transaction`;
|
DROP TABLE IF EXISTS `m_deposit_account_transaction`;
|
||||||
CREATE TABLE `m_deposit_account_transaction` (
|
CREATE TABLE `m_deposit_account_transaction` (
|
||||||
|
|||||||
+6
-9
@@ -11,7 +11,7 @@ import javax.ws.rs.QueryParam;
|
|||||||
import javax.ws.rs.core.MediaType;
|
import javax.ws.rs.core.MediaType;
|
||||||
|
|
||||||
import org.mifosng.platform.api.data.AuthenticatedUserData;
|
import org.mifosng.platform.api.data.AuthenticatedUserData;
|
||||||
import org.mifosng.platform.api.infrastructure.ApiDataConversionService;
|
import org.mifosng.platform.api.infrastructure.ApiJsonSerializerService;
|
||||||
import org.mifosng.platform.user.domain.AppUser;
|
import org.mifosng.platform.user.domain.AppUser;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Qualifier;
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
@@ -34,7 +34,7 @@ public class AuthenticationApiResource {
|
|||||||
private DaoAuthenticationProvider customAuthenticationProvider;
|
private DaoAuthenticationProvider customAuthenticationProvider;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ApiDataConversionService apiDataConversionService;
|
private ApiJsonSerializerService apiJsonSerializerService;
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@Consumes({MediaType.APPLICATION_JSON})
|
@Consumes({MediaType.APPLICATION_JSON})
|
||||||
@@ -45,22 +45,19 @@ public class AuthenticationApiResource {
|
|||||||
Authentication authenticationCheck = customAuthenticationProvider.authenticate(authentication);
|
Authentication authenticationCheck = customAuthenticationProvider.authenticate(authentication);
|
||||||
|
|
||||||
Collection<String> permissions = new ArrayList<String>();
|
Collection<String> permissions = new ArrayList<String>();
|
||||||
AuthenticatedUserData authenticatedUserData = new AuthenticatedUserData(permissions);
|
AuthenticatedUserData authenticatedUserData = new AuthenticatedUserData(username, permissions);
|
||||||
authenticatedUserData.setUsername(username);
|
|
||||||
|
|
||||||
if (authenticationCheck.isAuthenticated()) {
|
if (authenticationCheck.isAuthenticated()) {
|
||||||
Collection<GrantedAuthority> authorities = new ArrayList<GrantedAuthority>(authenticationCheck.getAuthorities());
|
Collection<GrantedAuthority> authorities = new ArrayList<GrantedAuthority>(authenticationCheck.getAuthorities());
|
||||||
for (GrantedAuthority grantedAuthority : authorities) {
|
for (GrantedAuthority grantedAuthority : authorities) {
|
||||||
permissions.add(grantedAuthority.getAuthority());
|
permissions.add(grantedAuthority.getAuthority());
|
||||||
}
|
}
|
||||||
authenticatedUserData.setPermissions(permissions);
|
|
||||||
authenticatedUserData.setAuthenticated(true);
|
|
||||||
AppUser principal = (AppUser) authenticationCheck.getPrincipal();
|
AppUser principal = (AppUser) authenticationCheck.getPrincipal();
|
||||||
authenticatedUserData.setUserId(principal.getId());
|
|
||||||
byte[] base64EncodedAuthenticationKey = Base64.encode(username + ":" + password);
|
byte[] base64EncodedAuthenticationKey = Base64.encode(username + ":" + password);
|
||||||
authenticatedUserData.setBase64EncodedAuthenticationKey(new String(base64EncodedAuthenticationKey));
|
|
||||||
|
authenticatedUserData = new AuthenticatedUserData(username, permissions, principal.getId(), new String(base64EncodedAuthenticationKey));
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.apiDataConversionService.convertAuthenticatedUserDataToJson(false, authenticatedUserData);
|
return this.apiJsonSerializerService.serializeAuthenticatedUserDataToJson(false, authenticatedUserData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+5
-1
@@ -18,6 +18,7 @@ import org.mifosng.platform.api.commands.BranchMoneyTransferCommand;
|
|||||||
import org.mifosng.platform.api.data.EntityIdentifier;
|
import org.mifosng.platform.api.data.EntityIdentifier;
|
||||||
import org.mifosng.platform.api.data.OfficeTransactionData;
|
import org.mifosng.platform.api.data.OfficeTransactionData;
|
||||||
import org.mifosng.platform.api.infrastructure.ApiDataConversionService;
|
import org.mifosng.platform.api.infrastructure.ApiDataConversionService;
|
||||||
|
import org.mifosng.platform.api.infrastructure.ApiJsonSerializerService;
|
||||||
import org.mifosng.platform.api.infrastructure.ApiParameterHelper;
|
import org.mifosng.platform.api.infrastructure.ApiParameterHelper;
|
||||||
import org.mifosng.platform.organisation.service.OfficeReadPlatformService;
|
import org.mifosng.platform.organisation.service.OfficeReadPlatformService;
|
||||||
import org.mifosng.platform.organisation.service.OfficeWritePlatformService;
|
import org.mifosng.platform.organisation.service.OfficeWritePlatformService;
|
||||||
@@ -39,6 +40,9 @@ public class OfficeTransactionsApiResource {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private ApiDataConversionService apiDataConversionService;
|
private ApiDataConversionService apiDataConversionService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ApiJsonSerializerService apiJsonSerializerService;
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("template")
|
@Path("template")
|
||||||
@Consumes({MediaType.APPLICATION_JSON})
|
@Consumes({MediaType.APPLICATION_JSON})
|
||||||
@@ -55,7 +59,7 @@ public class OfficeTransactionsApiResource {
|
|||||||
|
|
||||||
OfficeTransactionData officeTransactionData = this.readPlatformService.retrieveNewOfficeTransactionDetails();
|
OfficeTransactionData officeTransactionData = this.readPlatformService.retrieveNewOfficeTransactionDetails();
|
||||||
|
|
||||||
return this.apiDataConversionService.convertOfficeTransactionDataToJson(prettyPrint, responseParameters, officeTransactionData);
|
return this.apiJsonSerializerService.serializeOfficeTransactionDataToJson(prettyPrint, responseParameters, officeTransactionData);
|
||||||
}
|
}
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package org.mifosng.platform.api;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import javax.ws.rs.Consumes;
|
import javax.ws.rs.Consumes;
|
||||||
@@ -20,7 +21,9 @@ import javax.ws.rs.core.UriInfo;
|
|||||||
import org.mifosng.platform.api.commands.OfficeCommand;
|
import org.mifosng.platform.api.commands.OfficeCommand;
|
||||||
import org.mifosng.platform.api.data.EntityIdentifier;
|
import org.mifosng.platform.api.data.EntityIdentifier;
|
||||||
import org.mifosng.platform.api.data.OfficeData;
|
import org.mifosng.platform.api.data.OfficeData;
|
||||||
|
import org.mifosng.platform.api.data.OfficeLookup;
|
||||||
import org.mifosng.platform.api.infrastructure.ApiDataConversionService;
|
import org.mifosng.platform.api.infrastructure.ApiDataConversionService;
|
||||||
|
import org.mifosng.platform.api.infrastructure.ApiJsonSerializerService;
|
||||||
import org.mifosng.platform.api.infrastructure.ApiParameterHelper;
|
import org.mifosng.platform.api.infrastructure.ApiParameterHelper;
|
||||||
import org.mifosng.platform.organisation.service.OfficeReadPlatformService;
|
import org.mifosng.platform.organisation.service.OfficeReadPlatformService;
|
||||||
import org.mifosng.platform.organisation.service.OfficeWritePlatformService;
|
import org.mifosng.platform.organisation.service.OfficeWritePlatformService;
|
||||||
@@ -42,6 +45,9 @@ public class OfficesApiResource {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private ApiDataConversionService apiDataConversionService;
|
private ApiDataConversionService apiDataConversionService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ApiJsonSerializerService apiJsonSerializerService;
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Consumes({MediaType.APPLICATION_JSON})
|
@Consumes({MediaType.APPLICATION_JSON})
|
||||||
@Produces({MediaType.APPLICATION_JSON})
|
@Produces({MediaType.APPLICATION_JSON})
|
||||||
@@ -59,7 +65,7 @@ public class OfficesApiResource {
|
|||||||
|
|
||||||
Collection<OfficeData> offices = this.readPlatformService.retrieveAllOffices();
|
Collection<OfficeData> offices = this.readPlatformService.retrieveAllOffices();
|
||||||
|
|
||||||
return this.apiDataConversionService.convertOfficeDataToJson(prettyPrint, responseParameters, offices.toArray(new OfficeData[offices.size()]));
|
return this.apiJsonSerializerService.serializeOfficeDataToJson(prettyPrint, responseParameters, offices);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@@ -74,9 +80,9 @@ public class OfficesApiResource {
|
|||||||
|
|
||||||
boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters());
|
boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters());
|
||||||
|
|
||||||
OfficeData officeData = this.readPlatformService.retrieveNewOfficeTemplate();
|
OfficeData office = this.readPlatformService.retrieveNewOfficeTemplate();
|
||||||
|
|
||||||
return this.apiDataConversionService.convertOfficeDataToJson(prettyPrint, typicalResponseParameters, officeData);
|
return this.apiJsonSerializerService.serializeOfficeDataToJson(prettyPrint, typicalResponseParameters, office);
|
||||||
}
|
}
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@@ -110,11 +116,12 @@ public class OfficesApiResource {
|
|||||||
|
|
||||||
OfficeData office = this.readPlatformService.retrieveOffice(officeId);
|
OfficeData office = this.readPlatformService.retrieveOffice(officeId);
|
||||||
if (template) {
|
if (template) {
|
||||||
office.setAllowedParents(this.readPlatformService.retrieveAllowedParents(officeId));
|
List<OfficeLookup> allowedParents = this.readPlatformService.retrieveAllowedParents(officeId);
|
||||||
|
office = OfficeData.appendedTemplate(office, allowedParents);
|
||||||
responseParameters.add("allowedParents");
|
responseParameters.add("allowedParents");
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.apiDataConversionService.convertOfficeDataToJson(prettyPrint, responseParameters, office);
|
return this.apiJsonSerializerService.serializeOfficeDataToJson(prettyPrint, responseParameters, office);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PUT
|
@PUT
|
||||||
|
|||||||
+24
-35
@@ -1,29 +1,31 @@
|
|||||||
package org.mifosng.platform.api.data;
|
package org.mifosng.platform.api.data;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Immutable data object for authentication.
|
||||||
|
*/
|
||||||
public class AuthenticatedUserData {
|
public class AuthenticatedUserData {
|
||||||
|
|
||||||
private String username;
|
private final String username;
|
||||||
private Long userId;
|
private final Long userId;
|
||||||
private String base64EncodedAuthenticationKey;
|
private final String base64EncodedAuthenticationKey;
|
||||||
private boolean authenticated = false;
|
private final boolean authenticated;
|
||||||
private Collection<String> permissions = new ArrayList<String>();
|
private final Collection<String> permissions;
|
||||||
|
|
||||||
protected AuthenticatedUserData() {
|
public AuthenticatedUserData(final String username, final Collection<String> permissions) {
|
||||||
//
|
this.username = username;
|
||||||
}
|
this.userId = null;
|
||||||
|
this.base64EncodedAuthenticationKey = null;
|
||||||
public AuthenticatedUserData(final Collection<String> permissions) {
|
this.authenticated = false;
|
||||||
this.permissions = permissions;
|
this.permissions = permissions;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Collection<String> getPermissions() {
|
public AuthenticatedUserData(final String username, final Collection<String> permissions, final Long userId, final String base64EncodedAuthenticationKey) {
|
||||||
return this.permissions;
|
this.username = username;
|
||||||
}
|
this.userId = userId;
|
||||||
|
this.base64EncodedAuthenticationKey = base64EncodedAuthenticationKey;
|
||||||
public void setPermissions(final Collection<String> permissions) {
|
this.authenticated = true;
|
||||||
this.permissions = permissions;
|
this.permissions = permissions;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -31,32 +33,19 @@ public class AuthenticatedUserData {
|
|||||||
return username;
|
return username;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUsername(String username) {
|
public Long getUserId() {
|
||||||
this.username = username;
|
return userId;
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isAuthenticated() {
|
|
||||||
return authenticated;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAuthenticated(boolean authenticated) {
|
|
||||||
this.authenticated = authenticated;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getBase64EncodedAuthenticationKey() {
|
public String getBase64EncodedAuthenticationKey() {
|
||||||
return base64EncodedAuthenticationKey;
|
return base64EncodedAuthenticationKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBase64EncodedAuthenticationKey(
|
public boolean isAuthenticated() {
|
||||||
String base64EncodedAuthenticationKey) {
|
return authenticated;
|
||||||
this.base64EncodedAuthenticationKey = base64EncodedAuthenticationKey;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getUserId() {
|
public Collection<String> getPermissions() {
|
||||||
return userId;
|
return permissions;
|
||||||
}
|
|
||||||
|
|
||||||
public void setUserId(Long userId) {
|
|
||||||
this.userId = userId;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,31 +1,38 @@
|
|||||||
package org.mifosng.platform.api.data;
|
package org.mifosng.platform.api.data;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.joda.time.LocalDate;
|
import org.joda.time.LocalDate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Immutable data object for office data.
|
||||||
|
*/
|
||||||
public class OfficeData {
|
public class OfficeData {
|
||||||
|
|
||||||
private Long id;
|
private final Long id;
|
||||||
private String name;
|
private final String name;
|
||||||
private String nameDecorated;
|
private final String nameDecorated;
|
||||||
private String externalId;
|
private final String externalId;
|
||||||
private LocalDate openingDate;
|
private final LocalDate openingDate;
|
||||||
private String hierarchy;
|
private final String hierarchy;
|
||||||
private Long parentId;
|
private final Long parentId;
|
||||||
private String parentName;
|
private final String parentName;
|
||||||
|
|
||||||
private List<OfficeLookup> allowedParents = new ArrayList<OfficeLookup>();
|
private final List<OfficeLookup> allowedParents;
|
||||||
|
|
||||||
public OfficeData() {
|
public static OfficeData template(final List<OfficeLookup> parentLookups, final LocalDate defaultOpeningDate) {
|
||||||
//
|
return new OfficeData(null, null, null, null, defaultOpeningDate, null, null, null, parentLookups);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static OfficeData appendedTemplate(final OfficeData office, final List<OfficeLookup> allowedParents) {
|
||||||
|
return new OfficeData(office.getId(), office.getName(), office.getNameDecorated(), office.getExternalId(),
|
||||||
|
office.getOpeningDate(), office.getHierarchy(), office.getParentId(), office.getParentName(), allowedParents);
|
||||||
}
|
}
|
||||||
|
|
||||||
public OfficeData(final Long id, final String name,
|
public OfficeData(final Long id, final String name,
|
||||||
final String nameDecorated, final String externalId,
|
final String nameDecorated, final String externalId,
|
||||||
final LocalDate openingDate, String hierarchy, final Long parentId,
|
final LocalDate openingDate, String hierarchy, final Long parentId,
|
||||||
final String parentName) {
|
final String parentName, final List<OfficeLookup> allowedParents) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.nameDecorated = nameDecorated;
|
this.nameDecorated = nameDecorated;
|
||||||
@@ -34,14 +41,15 @@ public class OfficeData {
|
|||||||
this.hierarchy = hierarchy;
|
this.hierarchy = hierarchy;
|
||||||
this.parentName = parentName;
|
this.parentName = parentName;
|
||||||
this.parentId = parentId;
|
this.parentId = parentId;
|
||||||
|
this.allowedParents = allowedParents;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getId() {
|
public Long getId() {
|
||||||
return this.id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return this.name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getNameDecorated() {
|
public String getNameDecorated() {
|
||||||
@@ -49,62 +57,26 @@ public class OfficeData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getExternalId() {
|
public String getExternalId() {
|
||||||
return this.externalId;
|
return externalId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LocalDate getOpeningDate() {
|
public LocalDate getOpeningDate() {
|
||||||
return this.openingDate;
|
return openingDate;
|
||||||
}
|
|
||||||
|
|
||||||
public Long getParentId() {
|
|
||||||
return this.parentId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getParentName() {
|
|
||||||
return this.parentName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(final Long id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setName(final String name) {
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setNameDecorated(String nameDecorated) {
|
|
||||||
this.nameDecorated = nameDecorated;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setExternalId(final String externalId) {
|
|
||||||
this.externalId = externalId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setOpeningDate(final LocalDate openingDate) {
|
|
||||||
this.openingDate = openingDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setParentName(final String parentName) {
|
|
||||||
this.parentName = parentName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setParentId(final Long parentId) {
|
|
||||||
this.parentId = parentId;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getHierarchy() {
|
public String getHierarchy() {
|
||||||
return hierarchy;
|
return hierarchy;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setHierarchy(String hierarchy) {
|
public Long getParentId() {
|
||||||
this.hierarchy = hierarchy;
|
return parentId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getParentName() {
|
||||||
|
return parentName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<OfficeLookup> getAllowedParents() {
|
public List<OfficeLookup> getAllowedParents() {
|
||||||
return allowedParents;
|
return allowedParents;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAllowedParents(List<OfficeLookup> allowedParents) {
|
|
||||||
this.allowedParents = allowedParents;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
+6
-17
@@ -1,15 +1,17 @@
|
|||||||
package org.mifosng.platform.api.data;
|
package org.mifosng.platform.api.data;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.joda.time.LocalDate;
|
import org.joda.time.LocalDate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Immutable data object for office transactions.
|
||||||
|
*/
|
||||||
public class OfficeTransactionData {
|
public class OfficeTransactionData {
|
||||||
|
|
||||||
private LocalDate transactionDate;
|
private final LocalDate transactionDate;
|
||||||
private List<CurrencyData> currencyOptions = new ArrayList<CurrencyData>();
|
private final List<CurrencyData> currencyOptions;
|
||||||
private List<OfficeLookup> allowedOffices = new ArrayList<OfficeLookup>();
|
private final List<OfficeLookup> allowedOffices;
|
||||||
|
|
||||||
public OfficeTransactionData(final LocalDate transactionDate, final List<OfficeLookup> allowedOffices, final List<CurrencyData> currencyOptions) {
|
public OfficeTransactionData(final LocalDate transactionDate, final List<OfficeLookup> allowedOffices, final List<CurrencyData> currencyOptions) {
|
||||||
this.transactionDate = transactionDate;
|
this.transactionDate = transactionDate;
|
||||||
@@ -21,24 +23,11 @@ public class OfficeTransactionData {
|
|||||||
return transactionDate;
|
return transactionDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTransactionDate(LocalDate transactionDate) {
|
|
||||||
this.transactionDate = transactionDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<CurrencyData> getCurrencyOptions() {
|
public List<CurrencyData> getCurrencyOptions() {
|
||||||
return currencyOptions;
|
return currencyOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCurrencyOptions(List<CurrencyData> currencyOptions) {
|
|
||||||
this.currencyOptions = currencyOptions;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<OfficeLookup> getAllowedOffices() {
|
public List<OfficeLookup> getAllowedOffices() {
|
||||||
return allowedOffices;
|
return allowedOffices;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAllowedOffices(List<OfficeLookup> allowedOffices) {
|
|
||||||
this.allowedOffices = allowedOffices;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
-9
@@ -22,7 +22,6 @@ import org.mifosng.platform.api.commands.SavingProductCommand;
|
|||||||
import org.mifosng.platform.api.commands.SubmitLoanApplicationCommand;
|
import org.mifosng.platform.api.commands.SubmitLoanApplicationCommand;
|
||||||
import org.mifosng.platform.api.commands.UserCommand;
|
import org.mifosng.platform.api.commands.UserCommand;
|
||||||
import org.mifosng.platform.api.data.AdditionalFieldsSetData;
|
import org.mifosng.platform.api.data.AdditionalFieldsSetData;
|
||||||
import org.mifosng.platform.api.data.AuthenticatedUserData;
|
|
||||||
import org.mifosng.platform.api.data.ChargeData;
|
import org.mifosng.platform.api.data.ChargeData;
|
||||||
import org.mifosng.platform.api.data.ClientData;
|
import org.mifosng.platform.api.data.ClientData;
|
||||||
import org.mifosng.platform.api.data.ClientLoanAccountSummaryCollectionData;
|
import org.mifosng.platform.api.data.ClientLoanAccountSummaryCollectionData;
|
||||||
@@ -37,15 +36,11 @@ import org.mifosng.platform.api.data.LoanProductData;
|
|||||||
import org.mifosng.platform.api.data.LoanTransactionData;
|
import org.mifosng.platform.api.data.LoanTransactionData;
|
||||||
import org.mifosng.platform.api.data.NewLoanData;
|
import org.mifosng.platform.api.data.NewLoanData;
|
||||||
import org.mifosng.platform.api.data.NoteData;
|
import org.mifosng.platform.api.data.NoteData;
|
||||||
import org.mifosng.platform.api.data.OfficeData;
|
|
||||||
import org.mifosng.platform.api.data.OfficeTransactionData;
|
|
||||||
import org.mifosng.platform.api.data.SavingProductData;
|
import org.mifosng.platform.api.data.SavingProductData;
|
||||||
|
|
||||||
public interface ApiDataConversionService {
|
public interface ApiDataConversionService {
|
||||||
|
|
||||||
//
|
//
|
||||||
String convertOfficeTransactionDataToJson(boolean prettyPrint, Set<String> responseParameters, OfficeTransactionData... officeTransactions);
|
|
||||||
|
|
||||||
String convertConfigurationDataToJson(boolean prettyPrint, Set<String> responseParameters, ConfigurationData... configuration);
|
String convertConfigurationDataToJson(boolean prettyPrint, Set<String> responseParameters, ConfigurationData... configuration);
|
||||||
|
|
||||||
String convertClientDataToJson(boolean prettyPrint, Set<String> responseParameters, ClientData... clients);
|
String convertClientDataToJson(boolean prettyPrint, Set<String> responseParameters, ClientData... clients);
|
||||||
@@ -76,8 +71,6 @@ public interface ApiDataConversionService {
|
|||||||
String convertAdditionalFieldsSetDataToJson(boolean prettyPrint, AdditionalFieldsSetData... additionalFields);
|
String convertAdditionalFieldsSetDataToJson(boolean prettyPrint, AdditionalFieldsSetData... additionalFields);
|
||||||
|
|
||||||
String convertGenericResultsetDataToJson(boolean prettyPrint, GenericResultsetData result);
|
String convertGenericResultsetDataToJson(boolean prettyPrint, GenericResultsetData result);
|
||||||
|
|
||||||
String convertAuthenticatedUserDataToJson(boolean prettyPrint, AuthenticatedUserData authenticatedUserData);
|
|
||||||
//
|
//
|
||||||
|
|
||||||
ChargeCommand convertJsonToChargeCommand(Long resourceIdentifier, String json);
|
ChargeCommand convertJsonToChargeCommand(Long resourceIdentifier, String json);
|
||||||
@@ -90,8 +83,6 @@ public interface ApiDataConversionService {
|
|||||||
|
|
||||||
OfficeCommand convertJsonToOfficeCommand(Long resourceIdentifier, String json);
|
OfficeCommand convertJsonToOfficeCommand(Long resourceIdentifier, String json);
|
||||||
|
|
||||||
String convertOfficeDataToJson(boolean prettyPrint, Set<String> responseParameters, OfficeData... offices);
|
|
||||||
|
|
||||||
RoleCommand convertJsonToRoleCommand(Long resourceIdentifier, String json);
|
RoleCommand convertJsonToRoleCommand(Long resourceIdentifier, String json);
|
||||||
|
|
||||||
UserCommand convertJsonToUserCommand(Long resourceIdentifier, String json);
|
UserCommand convertJsonToUserCommand(Long resourceIdentifier, String json);
|
||||||
|
|||||||
-88
@@ -39,7 +39,6 @@ import org.mifosng.platform.api.commands.SubmitLoanApplicationCommand;
|
|||||||
import org.mifosng.platform.api.commands.UserCommand;
|
import org.mifosng.platform.api.commands.UserCommand;
|
||||||
import org.mifosng.platform.api.data.AdditionalFieldsSetData;
|
import org.mifosng.platform.api.data.AdditionalFieldsSetData;
|
||||||
import org.mifosng.platform.api.data.ApiParameterError;
|
import org.mifosng.platform.api.data.ApiParameterError;
|
||||||
import org.mifosng.platform.api.data.AuthenticatedUserData;
|
|
||||||
import org.mifosng.platform.api.data.ChargeData;
|
import org.mifosng.platform.api.data.ChargeData;
|
||||||
import org.mifosng.platform.api.data.ClientData;
|
import org.mifosng.platform.api.data.ClientData;
|
||||||
import org.mifosng.platform.api.data.ClientLoanAccountSummaryCollectionData;
|
import org.mifosng.platform.api.data.ClientLoanAccountSummaryCollectionData;
|
||||||
@@ -54,8 +53,6 @@ import org.mifosng.platform.api.data.LoanProductData;
|
|||||||
import org.mifosng.platform.api.data.LoanTransactionData;
|
import org.mifosng.platform.api.data.LoanTransactionData;
|
||||||
import org.mifosng.platform.api.data.NewLoanData;
|
import org.mifosng.platform.api.data.NewLoanData;
|
||||||
import org.mifosng.platform.api.data.NoteData;
|
import org.mifosng.platform.api.data.NoteData;
|
||||||
import org.mifosng.platform.api.data.OfficeData;
|
|
||||||
import org.mifosng.platform.api.data.OfficeTransactionData;
|
|
||||||
import org.mifosng.platform.api.data.SavingProductData;
|
import org.mifosng.platform.api.data.SavingProductData;
|
||||||
import org.mifosng.platform.api.errorhandling.InvalidJsonException;
|
import org.mifosng.platform.api.errorhandling.InvalidJsonException;
|
||||||
import org.mifosng.platform.api.errorhandling.UnsupportedParameterException;
|
import org.mifosng.platform.api.errorhandling.UnsupportedParameterException;
|
||||||
@@ -82,20 +79,6 @@ public class ApiDataConversionServiceImpl implements ApiDataConversionService {
|
|||||||
gsonConverter = new Gson();
|
gsonConverter = new Gson();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String convertAuthenticatedUserDataToJson(final boolean prettyPrint, final AuthenticatedUserData authenticatedUserData) {
|
|
||||||
GsonBuilder builder = new GsonBuilder();
|
|
||||||
builder.registerTypeAdapter(LocalDate.class, new JodaLocalDateAdapter());
|
|
||||||
builder.registerTypeAdapter(DateTime.class, new JodaDateTimeAdapter());
|
|
||||||
|
|
||||||
if (prettyPrint) {
|
|
||||||
builder.setPrettyPrinting();
|
|
||||||
}
|
|
||||||
Gson gsonDeserializer = builder.create();
|
|
||||||
|
|
||||||
return gsonDeserializer.toJson(authenticatedUserData);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String convertGenericResultsetDataToJson(final boolean prettyPrint, final GenericResultsetData result) {
|
public String convertGenericResultsetDataToJson(final boolean prettyPrint, final GenericResultsetData result) {
|
||||||
GsonBuilder builder = new GsonBuilder();
|
GsonBuilder builder = new GsonBuilder();
|
||||||
@@ -456,77 +439,6 @@ public class ApiDataConversionServiceImpl implements ApiDataConversionService {
|
|||||||
return json;
|
return json;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String convertOfficeTransactionDataToJson(final boolean prettyPrint, final Set<String> responseParameters, final OfficeTransactionData... officeTransactions) {
|
|
||||||
|
|
||||||
final Set<String> supportedParameters = new HashSet<String>(Arrays.asList("transactionDate", "allowedOffices", "currencyOptions"));
|
|
||||||
|
|
||||||
final Set<String> parameterNamesToSkip = new HashSet<String>();
|
|
||||||
|
|
||||||
if (!responseParameters.isEmpty()) {
|
|
||||||
if (!supportedParameters.containsAll(responseParameters)) {
|
|
||||||
throw new UnsupportedParameterException(new ArrayList<String>(responseParameters));
|
|
||||||
}
|
|
||||||
|
|
||||||
parameterNamesToSkip.addAll(supportedParameters);
|
|
||||||
parameterNamesToSkip.removeAll(responseParameters);
|
|
||||||
}
|
|
||||||
|
|
||||||
ExclusionStrategy strategy = new ParameterListExclusionStrategy(parameterNamesToSkip);
|
|
||||||
|
|
||||||
GsonBuilder builder = new GsonBuilder().addSerializationExclusionStrategy(strategy);
|
|
||||||
builder.registerTypeAdapter(LocalDate.class, new JodaLocalDateAdapter());
|
|
||||||
if (prettyPrint) {
|
|
||||||
builder.setPrettyPrinting();
|
|
||||||
}
|
|
||||||
Gson gsonDeserializer = builder.create();
|
|
||||||
|
|
||||||
String json = "";
|
|
||||||
if (officeTransactions != null && officeTransactions.length == 1) {
|
|
||||||
json = gsonDeserializer.toJson(officeTransactions[0]);
|
|
||||||
} else {
|
|
||||||
json = gsonDeserializer.toJson(officeTransactions);
|
|
||||||
}
|
|
||||||
|
|
||||||
return json;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String convertOfficeDataToJson(final boolean prettyPrint, final Set<String> responseParameters, final OfficeData... offices) {
|
|
||||||
|
|
||||||
Set<String> supportedParameters = new HashSet<String>(Arrays.asList("id", "name", "nameDecorated", "externalId", "openingDate",
|
|
||||||
"hierarchy", "parentId", "parentName", "allowedParents"));
|
|
||||||
|
|
||||||
final Set<String> parameterNamesToSkip = new HashSet<String>();
|
|
||||||
|
|
||||||
if (!responseParameters.isEmpty()) {
|
|
||||||
if (!supportedParameters.containsAll(responseParameters)) {
|
|
||||||
throw new UnsupportedParameterException(new ArrayList<String>(responseParameters));
|
|
||||||
}
|
|
||||||
|
|
||||||
parameterNamesToSkip.addAll(supportedParameters);
|
|
||||||
parameterNamesToSkip.removeAll(responseParameters);
|
|
||||||
}
|
|
||||||
|
|
||||||
ExclusionStrategy strategy = new ParameterListExclusionStrategy(parameterNamesToSkip);
|
|
||||||
|
|
||||||
GsonBuilder builder = new GsonBuilder().addSerializationExclusionStrategy(strategy);
|
|
||||||
builder.registerTypeAdapter(LocalDate.class, new JodaLocalDateAdapter());
|
|
||||||
if (prettyPrint) {
|
|
||||||
builder.setPrettyPrinting();
|
|
||||||
}
|
|
||||||
Gson gsonDeserializer = builder.create();
|
|
||||||
|
|
||||||
String json = "";
|
|
||||||
if (offices != null && offices.length == 1) {
|
|
||||||
json = gsonDeserializer.toJson(offices[0]);
|
|
||||||
} else {
|
|
||||||
json = gsonDeserializer.toJson(offices);
|
|
||||||
}
|
|
||||||
|
|
||||||
return json;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String convertFundDataToJson(final boolean prettyPrint, final Set<String> responseParameters, final FundData... funds) {
|
public String convertFundDataToJson(final boolean prettyPrint, final Set<String> responseParameters, final FundData... funds) {
|
||||||
|
|
||||||
|
|||||||
+11
@@ -4,6 +4,9 @@ import java.util.Collection;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.mifosng.platform.api.data.AppUserData;
|
import org.mifosng.platform.api.data.AppUserData;
|
||||||
|
import org.mifosng.platform.api.data.AuthenticatedUserData;
|
||||||
|
import org.mifosng.platform.api.data.OfficeData;
|
||||||
|
import org.mifosng.platform.api.data.OfficeTransactionData;
|
||||||
import org.mifosng.platform.api.data.PermissionData;
|
import org.mifosng.platform.api.data.PermissionData;
|
||||||
import org.mifosng.platform.api.data.RoleData;
|
import org.mifosng.platform.api.data.RoleData;
|
||||||
|
|
||||||
@@ -19,4 +22,12 @@ public interface ApiJsonSerializerService {
|
|||||||
|
|
||||||
String serializeAppUserDataToJson(boolean prettyPrint, Set<String> responseParameters, AppUserData user);
|
String serializeAppUserDataToJson(boolean prettyPrint, Set<String> responseParameters, AppUserData user);
|
||||||
|
|
||||||
|
String serializeAuthenticatedUserDataToJson(boolean prettyPrint, AuthenticatedUserData authenticatedUserData);
|
||||||
|
|
||||||
|
String serializeOfficeDataToJson(boolean prettyPrint, Set<String> responseParameters, Collection<OfficeData> offices);
|
||||||
|
|
||||||
|
String serializeOfficeDataToJson(boolean prettyPrint, Set<String> responseParameters, OfficeData office);
|
||||||
|
|
||||||
|
String serializeOfficeTransactionDataToJson(boolean prettyPrint, Set<String> responseParameters, OfficeTransactionData officeTransactionData);
|
||||||
|
|
||||||
}
|
}
|
||||||
+32
@@ -6,6 +6,9 @@ import java.util.HashSet;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.mifosng.platform.api.data.AppUserData;
|
import org.mifosng.platform.api.data.AppUserData;
|
||||||
|
import org.mifosng.platform.api.data.AuthenticatedUserData;
|
||||||
|
import org.mifosng.platform.api.data.OfficeData;
|
||||||
|
import org.mifosng.platform.api.data.OfficeTransactionData;
|
||||||
import org.mifosng.platform.api.data.PermissionData;
|
import org.mifosng.platform.api.data.PermissionData;
|
||||||
import org.mifosng.platform.api.data.RoleData;
|
import org.mifosng.platform.api.data.RoleData;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -24,6 +27,11 @@ public class GoogleGsonApiJsonSerializerService implements ApiJsonSerializerServ
|
|||||||
private static final Set<String> APP_USER_DATA_PARAMETERS = new HashSet<String>(
|
private static final Set<String> APP_USER_DATA_PARAMETERS = new HashSet<String>(
|
||||||
Arrays.asList("id", "officeId", "officeName", "username", "firstname", "lastname", "email",
|
Arrays.asList("id", "officeId", "officeName", "username", "firstname", "lastname", "email",
|
||||||
"allowedOffices", "availableRoles", "selectedRoles"));
|
"allowedOffices", "availableRoles", "selectedRoles"));
|
||||||
|
private static final Set<String> OFFICE_DATA_PARAMETERS = new HashSet<String>(
|
||||||
|
Arrays.asList("id", "name", "nameDecorated", "externalId", "openingDate",
|
||||||
|
"hierarchy", "parentId", "parentName", "allowedParents")
|
||||||
|
);
|
||||||
|
private static final Set<String> OFFICE_TRANSACTIONS_DATA_PARAMETERS = new HashSet<String>(Arrays.asList("transactionDate", "allowedOffices", "currencyOptions"));
|
||||||
|
|
||||||
private final GoogleGsonSerializerHelper helper;
|
private final GoogleGsonSerializerHelper helper;
|
||||||
|
|
||||||
@@ -61,4 +69,28 @@ public class GoogleGsonApiJsonSerializerService implements ApiJsonSerializerServ
|
|||||||
final Gson gsonDeserializer = helper.createGsonBuilderWithParameterExclusionSerializationStrategy(APP_USER_DATA_PARAMETERS, prettyPrint, responseParameters);
|
final Gson gsonDeserializer = helper.createGsonBuilderWithParameterExclusionSerializationStrategy(APP_USER_DATA_PARAMETERS, prettyPrint, responseParameters);
|
||||||
return helper.serializedJsonFrom(gsonDeserializer, user);
|
return helper.serializedJsonFrom(gsonDeserializer, user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String serializeAuthenticatedUserDataToJson(final boolean prettyPrint, final AuthenticatedUserData authenticatedUserData) {
|
||||||
|
final Gson gsonDeserializer = helper.createGsonBuilder(prettyPrint);
|
||||||
|
return helper.serializedJsonFrom(gsonDeserializer, authenticatedUserData);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String serializeOfficeDataToJson(final boolean prettyPrint, final Set<String> responseParameters, final Collection<OfficeData> offices) {
|
||||||
|
final Gson gsonDeserializer = helper.createGsonBuilderWithParameterExclusionSerializationStrategy(OFFICE_DATA_PARAMETERS, prettyPrint, responseParameters);
|
||||||
|
return helper.serializedJsonFrom(gsonDeserializer, offices.toArray(new OfficeData[offices.size()]));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String serializeOfficeDataToJson(final boolean prettyPrint, final Set<String> responseParameters, final OfficeData office) {
|
||||||
|
final Gson gsonDeserializer = helper.createGsonBuilderWithParameterExclusionSerializationStrategy(OFFICE_DATA_PARAMETERS, prettyPrint, responseParameters);
|
||||||
|
return helper.serializedJsonFrom(gsonDeserializer, office);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String serializeOfficeTransactionDataToJson(final boolean prettyPrint, final Set<String> responseParameters, final OfficeTransactionData officeTransaction) {
|
||||||
|
final Gson gsonDeserializer = helper.createGsonBuilderWithParameterExclusionSerializationStrategy(OFFICE_TRANSACTIONS_DATA_PARAMETERS, prettyPrint, responseParameters);
|
||||||
|
return helper.serializedJsonFrom(gsonDeserializer, officeTransaction);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+10
@@ -19,6 +19,16 @@ import com.google.gson.GsonBuilder;
|
|||||||
@Service
|
@Service
|
||||||
public class GoogleGsonSerializerHelper {
|
public class GoogleGsonSerializerHelper {
|
||||||
|
|
||||||
|
public Gson createGsonBuilder(final boolean prettyPrint) {
|
||||||
|
final GsonBuilder builder = new GsonBuilder();
|
||||||
|
builder.registerTypeAdapter(LocalDate.class, new JodaLocalDateAdapter());
|
||||||
|
builder.registerTypeAdapter(DateTime.class, new JodaDateTimeAdapter());
|
||||||
|
if (prettyPrint) {
|
||||||
|
builder.setPrettyPrinting();
|
||||||
|
}
|
||||||
|
return builder.create();
|
||||||
|
}
|
||||||
|
|
||||||
public Gson createGsonBuilderWithParameterExclusionSerializationStrategy(
|
public Gson createGsonBuilderWithParameterExclusionSerializationStrategy(
|
||||||
final Set<String> supportedParameters,
|
final Set<String> supportedParameters,
|
||||||
final boolean prettyPrint,
|
final boolean prettyPrint,
|
||||||
|
|||||||
+4
-9
@@ -62,8 +62,8 @@ public class OfficeReadPlatformServiceImpl implements OfficeReadPlatformService
|
|||||||
Long parentId = JdbcSupport.getLong(rs, "parentId");
|
Long parentId = JdbcSupport.getLong(rs, "parentId");
|
||||||
String parentName = rs.getString("parentName");
|
String parentName = rs.getString("parentName");
|
||||||
|
|
||||||
return new OfficeData(id, name, nameDecorated, externalId,
|
List<OfficeLookup> allowedParents = new ArrayList<OfficeLookup>();
|
||||||
openingDate, hierarchy, parentId, parentName);
|
return new OfficeData(id, name, nameDecorated, externalId, openingDate, hierarchy, parentId, parentName, allowedParents);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -144,11 +144,7 @@ public class OfficeReadPlatformServiceImpl implements OfficeReadPlatformService
|
|||||||
List<OfficeLookup> parentLookups = new ArrayList<OfficeLookup>(
|
List<OfficeLookup> parentLookups = new ArrayList<OfficeLookup>(
|
||||||
retrieveAllOfficesForLookup());
|
retrieveAllOfficesForLookup());
|
||||||
|
|
||||||
OfficeData officeData = new OfficeData();
|
return OfficeData.template(parentLookups, new LocalDate());
|
||||||
officeData.setAllowedParents(parentLookups);
|
|
||||||
officeData.setOpeningDate(new LocalDate());
|
|
||||||
|
|
||||||
return officeData;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -156,8 +152,7 @@ public class OfficeReadPlatformServiceImpl implements OfficeReadPlatformService
|
|||||||
|
|
||||||
context.authenticatedUser();
|
context.authenticatedUser();
|
||||||
|
|
||||||
List<OfficeLookup> parentLookups = new ArrayList<OfficeLookup>(
|
List<OfficeLookup> parentLookups = new ArrayList<OfficeLookup>(retrieveAllOfficesForLookup());
|
||||||
retrieveAllOfficesForLookup());
|
|
||||||
List<OfficeLookup> filterParentLookups = new ArrayList<OfficeLookup>();
|
List<OfficeLookup> filterParentLookups = new ArrayList<OfficeLookup>();
|
||||||
|
|
||||||
for (OfficeLookup office : parentLookups) {
|
for (OfficeLookup office : parentLookups) {
|
||||||
|
|||||||
Reference in New Issue
Block a user