MIFOSX-97: restructuring of api resources, data, commands and the services and domain concepts they use. The api is not responsible for logging the command which is then in turn processed. When maker checker is enabled no changes are persisted through until a checker approves them.
This commit is contained in:
@@ -13,6 +13,7 @@ buildscript {
|
||||
|
||||
apply plugin: 'war'
|
||||
apply plugin: 'eclipse'
|
||||
apply plugin: 'idea'
|
||||
apply plugin: 'tomcat'
|
||||
apply plugin: 'project-report'
|
||||
|
||||
|
||||
+3
-3
@@ -19,7 +19,6 @@ import javax.ws.rs.core.UriInfo;
|
||||
import org.mifosng.platform.api.commands.ClientIdentifierCommand;
|
||||
import org.mifosng.platform.api.data.ClientData;
|
||||
import org.mifosng.platform.api.data.ClientIdentifierData;
|
||||
import org.mifosng.platform.api.data.CodeValueData;
|
||||
import org.mifosng.platform.api.data.EntityIdentifier;
|
||||
import org.mifosng.platform.api.infrastructure.PortfolioApiDataConversionService;
|
||||
import org.mifosng.platform.api.infrastructure.PortfolioApiJsonSerializerService;
|
||||
@@ -27,8 +26,9 @@ import org.mifosng.platform.client.service.ClientReadPlatformService;
|
||||
import org.mifosng.platform.client.service.ClientWritePlatformService;
|
||||
import org.mifosng.platform.exceptions.DuplicateClientIdentifierException;
|
||||
import org.mifosng.platform.infrastructure.api.ApiParameterHelper;
|
||||
import org.mifosng.platform.organisation.service.CodeValueReadPlatformService;
|
||||
import org.mifosng.platform.security.PlatformSecurityContext;
|
||||
import org.mifosplatform.infrastructure.codes.data.CodeValueData;
|
||||
import org.mifosplatform.infrastructure.codes.service.CodeValueReadPlatformService;
|
||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@@ -28,7 +28,6 @@ import org.mifosng.platform.api.data.ClientAccountSummaryCollectionData;
|
||||
import org.mifosng.platform.api.data.ClientData;
|
||||
import org.mifosng.platform.api.data.EntityIdentifier;
|
||||
import org.mifosng.platform.api.data.NoteData;
|
||||
import org.mifosng.platform.api.data.OfficeLookup;
|
||||
import org.mifosng.platform.api.infrastructure.ApiConstants;
|
||||
import org.mifosng.platform.api.infrastructure.PortfolioApiDataConversionService;
|
||||
import org.mifosng.platform.api.infrastructure.PortfolioApiJsonSerializerService;
|
||||
@@ -38,11 +37,12 @@ import org.mifosng.platform.exceptions.ImageNotFoundException;
|
||||
import org.mifosng.platform.infrastructure.Base64EncodedImage;
|
||||
import org.mifosng.platform.infrastructure.FileUtils;
|
||||
import org.mifosng.platform.infrastructure.api.ApiParameterHelper;
|
||||
import org.mifosng.platform.organisation.service.OfficeReadPlatformService;
|
||||
import org.mifosng.platform.security.PlatformSecurityContext;
|
||||
import org.mifosplatform.commands.api.data.CommandSourceData;
|
||||
import org.mifosplatform.commands.service.PortfolioCommandSourceWritePlatformService;
|
||||
import org.mifosplatform.commands.service.PortfolioCommandsReadPlatformService;
|
||||
import org.mifosplatform.infrastructure.office.data.OfficeLookup;
|
||||
import org.mifosplatform.infrastructure.office.service.OfficeReadPlatformService;
|
||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
@@ -1,121 +0,0 @@
|
||||
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.CodeCommand;
|
||||
import org.mifosng.platform.api.data.CodeData;
|
||||
import org.mifosng.platform.api.data.EntityIdentifier;
|
||||
import org.mifosng.platform.api.infrastructure.PortfolioApiDataConversionService;
|
||||
import org.mifosng.platform.api.infrastructure.PortfolioApiJsonSerializerService;
|
||||
import org.mifosng.platform.infrastructure.api.ApiParameterHelper;
|
||||
import org.mifosng.platform.organisation.service.CodeWritePlatformService;
|
||||
import org.mifosng.platform.organisation.service.CodeReadPlatformService;
|
||||
import org.mifosng.platform.security.PlatformSecurityContext;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Path("/codes")
|
||||
@Component
|
||||
@Scope("singleton")
|
||||
public class CodesApiResource {
|
||||
|
||||
@Autowired
|
||||
private CodeReadPlatformService readPlatformService;
|
||||
|
||||
@Autowired
|
||||
private CodeWritePlatformService writePlatformService;
|
||||
|
||||
@Autowired
|
||||
private PortfolioApiDataConversionService apiDataConversionService;
|
||||
|
||||
@Autowired
|
||||
private PortfolioApiJsonSerializerService apiJsonSerializerService;
|
||||
|
||||
private final String entityType = "CODE";
|
||||
private final PlatformSecurityContext context;
|
||||
|
||||
@Autowired
|
||||
public CodesApiResource(final PlatformSecurityContext context) {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@GET
|
||||
@Consumes({MediaType.APPLICATION_JSON})
|
||||
@Produces({MediaType.APPLICATION_JSON})
|
||||
public String retrieveCodes(@Context final UriInfo uriInfo) {
|
||||
|
||||
context.authenticatedUser().validateHasReadPermission(entityType);
|
||||
|
||||
Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters());
|
||||
boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters());
|
||||
|
||||
final Collection<CodeData> codes = this.readPlatformService.retrieveAllCodes();
|
||||
|
||||
return this.apiJsonSerializerService.serializeCodeDataToJson(prettyPrint, responseParameters, codes);
|
||||
}
|
||||
|
||||
@POST
|
||||
@Consumes({MediaType.APPLICATION_JSON})
|
||||
@Produces({MediaType.APPLICATION_JSON})
|
||||
public Response createCode(final String jsonRequestBody) {
|
||||
|
||||
final CodeCommand command = this.apiDataConversionService.convertJsonToCodeCommand(null, jsonRequestBody);
|
||||
|
||||
final Long id = this.writePlatformService.createCode(command);
|
||||
|
||||
return Response.ok().entity(new EntityIdentifier(id)).build();
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("{codeId}")
|
||||
@Consumes({MediaType.APPLICATION_JSON})
|
||||
@Produces({MediaType.APPLICATION_JSON})
|
||||
public String retreiveOffice(@PathParam("codeId") final Long codeId, @Context final UriInfo uriInfo) {
|
||||
|
||||
final Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters());
|
||||
final boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters());
|
||||
|
||||
final CodeData code = this.readPlatformService.retrieveCode(codeId);
|
||||
|
||||
return this.apiJsonSerializerService.serializeCodeDataToJson(prettyPrint, responseParameters, code);
|
||||
}
|
||||
|
||||
@PUT
|
||||
@Path("{Id}")
|
||||
@Consumes({MediaType.APPLICATION_JSON})
|
||||
@Produces({MediaType.APPLICATION_JSON})
|
||||
public Response updateCode(@PathParam("Id") final Long codeId, final String jsonRequestBody) {
|
||||
|
||||
final CodeCommand command = this.apiDataConversionService.convertJsonToCodeCommand(codeId, jsonRequestBody);
|
||||
final Long entityId = this.writePlatformService.updateCode(command);
|
||||
return Response.ok().entity(new EntityIdentifier(entityId)).build();
|
||||
|
||||
}
|
||||
|
||||
@DELETE
|
||||
@Path("{codeId}")
|
||||
@Consumes({ MediaType.APPLICATION_JSON })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public Response deleteCodeApplication(@PathParam("codeId") final Long Id) {
|
||||
|
||||
EntityIdentifier identifier = this.writePlatformService.deleteCode(Id);
|
||||
|
||||
return Response.ok().entity(identifier).build();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,82 +0,0 @@
|
||||
package org.mifosng.platform.api;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.PUT;
|
||||
import javax.ws.rs.Path;
|
||||
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.OrganisationCurrencyCommand;
|
||||
import org.mifosng.platform.api.data.ConfigurationData;
|
||||
import org.mifosng.platform.api.infrastructure.PortfolioApiDataConversionService;
|
||||
import org.mifosng.platform.api.infrastructure.PortfolioApiJsonSerializerService;
|
||||
import org.mifosng.platform.configuration.service.ConfigurationReadPlatformService;
|
||||
import org.mifosng.platform.configuration.service.ConfigurationWritePlatformService;
|
||||
import org.mifosng.platform.infrastructure.api.ApiParameterHelper;
|
||||
import org.mifosng.platform.security.PlatformSecurityContext;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Path("/configurations")
|
||||
@Component
|
||||
@Scope("singleton")
|
||||
public class ConfigurationApiResource {
|
||||
|
||||
@Autowired
|
||||
private ConfigurationReadPlatformService configurationReadPlatformService;
|
||||
|
||||
@Autowired
|
||||
private ConfigurationWritePlatformService configurationWritePlatformService;
|
||||
|
||||
@Autowired
|
||||
private PortfolioApiDataConversionService apiDataConversionService;
|
||||
|
||||
@Autowired
|
||||
private PortfolioApiJsonSerializerService apiJsonSerializerService;
|
||||
|
||||
@Autowired
|
||||
private PlatformSecurityContext context;
|
||||
|
||||
@GET
|
||||
@Path("currency")
|
||||
@Consumes({ MediaType.APPLICATION_JSON })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public String retrieveCurrencyDataForConfiguration(@Context final UriInfo uriInfo) {
|
||||
|
||||
context.authenticatedUser().validateHasReadPermission("CURRENCY");
|
||||
|
||||
Set<String> typicalResponseParameters = new HashSet<String>(Arrays.asList("selectedCurrencyOptions", "currencyOptions"));
|
||||
|
||||
Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters());
|
||||
if (responseParameters.isEmpty()) {
|
||||
responseParameters.addAll(typicalResponseParameters);
|
||||
}
|
||||
boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters());
|
||||
|
||||
ConfigurationData configurationData = this.configurationReadPlatformService.retrieveCurrencyConfiguration();
|
||||
|
||||
return this.apiJsonSerializerService.serializeConfigurationDataToJson(prettyPrint, responseParameters, configurationData);
|
||||
}
|
||||
|
||||
@PUT
|
||||
@Path("currency")
|
||||
@Consumes({ MediaType.APPLICATION_JSON })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public Response updateAllowedCurrenciesForOrganisation(final String jsonRequestBody) {
|
||||
|
||||
OrganisationCurrencyCommand command = this.apiDataConversionService.convertJsonToOrganisationCurrencyCommand(jsonRequestBody);
|
||||
|
||||
this.configurationWritePlatformService.updateOrganisationCurrencies(command);
|
||||
|
||||
return Response.ok().entity(command).build();
|
||||
}
|
||||
}
|
||||
@@ -1,286 +0,0 @@
|
||||
package org.mifosng.platform.api;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
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.QueryParam;
|
||||
import javax.ws.rs.WebApplicationException;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.Response.Status;
|
||||
import javax.ws.rs.core.UriInfo;
|
||||
|
||||
import org.codehaus.jettison.json.JSONArray;
|
||||
import org.codehaus.jettison.json.JSONException;
|
||||
import org.codehaus.jettison.json.JSONObject;
|
||||
import org.mifosng.platform.api.data.DatatableData;
|
||||
import org.mifosng.platform.api.data.EntityIdentifier;
|
||||
import org.mifosng.platform.api.data.GenericResultsetData;
|
||||
import org.mifosng.platform.api.infrastructure.PortfolioApiJsonSerializerService;
|
||||
import org.mifosng.platform.exceptions.NoAuthorizationException;
|
||||
import org.mifosng.platform.infrastructure.api.ApiParameterHelper;
|
||||
import org.mifosng.platform.noncore.GenericDataService;
|
||||
import org.mifosng.platform.noncore.ReadWriteNonCoreDataService;
|
||||
import org.mifosng.platform.security.PlatformSecurityContext;
|
||||
import org.mifosplatform.infrastructure.user.domain.AppUser;
|
||||
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;
|
||||
|
||||
@Path("/datatables")
|
||||
@Component
|
||||
@Scope("singleton")
|
||||
public class DataTableApiResource {
|
||||
|
||||
private final static Logger logger = LoggerFactory
|
||||
.getLogger(DataTableApiResource.class);
|
||||
|
||||
@Autowired
|
||||
private PlatformSecurityContext context;
|
||||
|
||||
@Autowired
|
||||
private GenericDataService genericDataService;
|
||||
|
||||
@Autowired
|
||||
private ReadWriteNonCoreDataService readWriteNonCoreDataService;
|
||||
|
||||
@Autowired
|
||||
private PortfolioApiJsonSerializerService apiJsonSerializerService;
|
||||
|
||||
@GET
|
||||
@Consumes({ MediaType.APPLICATION_JSON })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public String getDatatables(@QueryParam("apptable") final String apptable,
|
||||
@Context final UriInfo uriInfo) {
|
||||
|
||||
List<DatatableData> result = this.readWriteNonCoreDataService
|
||||
.retrieveDatatableNames(apptable);
|
||||
|
||||
boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo
|
||||
.getQueryParameters());
|
||||
return this.apiJsonSerializerService.serializeDatatableDataToJson(
|
||||
prettyPrint, result);
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("register/{datatable}/{apptable}")
|
||||
@Consumes({ MediaType.APPLICATION_JSON })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public Response registerDatatable(
|
||||
@PathParam("datatable") final String datatable,
|
||||
@PathParam("apptable") final String apptable) {
|
||||
|
||||
this.readWriteNonCoreDataService.registerDatatable(datatable, apptable);
|
||||
|
||||
EntityIdentifier entityIdentifier = new EntityIdentifier();
|
||||
return Response.ok().entity(entityIdentifier).build();
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("deregister/{datatable}")
|
||||
@Consumes({ MediaType.APPLICATION_JSON })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public Response deregisterDatatable(
|
||||
@PathParam("datatable") final String datatable) {
|
||||
|
||||
this.readWriteNonCoreDataService.deregisterDatatable(datatable);
|
||||
|
||||
EntityIdentifier entityIdentifier = new EntityIdentifier();
|
||||
return Response.ok().entity(entityIdentifier).build();
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("{datatable}/{apptableId}")
|
||||
@Consumes({ MediaType.APPLICATION_JSON })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public String getDatatable(@PathParam("datatable") final String datatable,
|
||||
@PathParam("apptableId") final Long apptableId,
|
||||
@QueryParam("order") final String order,
|
||||
@Context final UriInfo uriInfo) {
|
||||
|
||||
checkUserPermissionForDatatable(datatable, "READ");
|
||||
|
||||
GenericResultsetData results = this.readWriteNonCoreDataService
|
||||
.retrieveDataTableGenericResultSet(datatable, apptableId,
|
||||
order, null);
|
||||
|
||||
String json = "";
|
||||
final boolean genericResultSet = ApiParameterHelper.genericResultSet(uriInfo.getQueryParameters());
|
||||
if (genericResultSet) {
|
||||
boolean prettyPrints = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters());
|
||||
json = this.apiJsonSerializerService.serializeGenericResultsetDataToJson(prettyPrints, results);
|
||||
} else {
|
||||
json = this.genericDataService.generateJsonFromGenericResultsetData(results);
|
||||
}
|
||||
|
||||
return json;
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("{datatable}/{apptableId}")
|
||||
@Consumes({ MediaType.APPLICATION_JSON })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public Response newDatatableEntry(
|
||||
@PathParam("datatable") final String datatable,
|
||||
@PathParam("apptableId") final Long apptableId,
|
||||
final String jsonRequestBody) {
|
||||
|
||||
checkUserPermissionForDatatable(datatable, "CREATE");
|
||||
Map<String, String> queryParams = getQueryParamsFromJsonRequestBody(jsonRequestBody);
|
||||
|
||||
this.readWriteNonCoreDataService.newDatatableEntry(datatable,
|
||||
apptableId, queryParams);
|
||||
|
||||
EntityIdentifier entityIdentifier = new EntityIdentifier(
|
||||
Long.valueOf(apptableId));
|
||||
|
||||
return Response.ok().entity(entityIdentifier).build();
|
||||
|
||||
}
|
||||
|
||||
@PUT
|
||||
@Path("{datatable}/{apptableId}")
|
||||
@Consumes({ MediaType.APPLICATION_JSON })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public Response updateDatatableEntryOnetoOne(
|
||||
@PathParam("datatable") final String datatable,
|
||||
@PathParam("apptableId") final Long apptableId,
|
||||
final String jsonRequestBody) {
|
||||
/*
|
||||
* for updating one to one relationships (where foreign key is the
|
||||
* primary key)
|
||||
*/
|
||||
checkUserPermissionForDatatable(datatable, "UPDATE");
|
||||
Map<String, String> queryParams = getQueryParamsFromJsonRequestBody(jsonRequestBody);
|
||||
|
||||
this.readWriteNonCoreDataService.updateDatatableEntryOnetoOne(
|
||||
datatable, apptableId, queryParams);
|
||||
|
||||
EntityIdentifier entityIdentifier = new EntityIdentifier(
|
||||
Long.valueOf(apptableId));
|
||||
|
||||
return Response.ok().entity(entityIdentifier).build();
|
||||
|
||||
}
|
||||
|
||||
@PUT
|
||||
@Path("{datatable}/{apptableId}/{datatableId}")
|
||||
@Consumes({ MediaType.APPLICATION_JSON })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public Response updateDatatableEntryOnetoOne(
|
||||
@PathParam("datatable") final String datatable,
|
||||
@PathParam("apptableId") final Long apptableId,
|
||||
@PathParam("datatableId") final Long datatableId,
|
||||
final String jsonRequestBody) {
|
||||
/*
|
||||
* for updating one to many relationships (where foreign key isn't the
|
||||
* primary key)
|
||||
*/
|
||||
checkUserPermissionForDatatable(datatable, "UPDATE");
|
||||
Map<String, String> queryParams = getQueryParamsFromJsonRequestBody(jsonRequestBody);
|
||||
|
||||
this.readWriteNonCoreDataService.updateDatatableEntryOnetoMany(
|
||||
datatable, apptableId, datatableId, queryParams);
|
||||
|
||||
EntityIdentifier entityIdentifier = new EntityIdentifier(
|
||||
Long.valueOf(apptableId));
|
||||
|
||||
return Response.ok().entity(entityIdentifier).build();
|
||||
|
||||
}
|
||||
|
||||
@DELETE
|
||||
@Path("{datatable}/{apptableId}")
|
||||
@Consumes({ MediaType.APPLICATION_JSON })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public Response deleteDatatableEntries(
|
||||
@PathParam("datatable") final String datatable,
|
||||
@PathParam("apptableId") final Long apptableId) {
|
||||
|
||||
checkUserPermissionForDatatable(datatable, "DELETE");
|
||||
|
||||
this.readWriteNonCoreDataService.deleteDatatableEntries(datatable,
|
||||
apptableId);
|
||||
|
||||
EntityIdentifier entityIdentifier = new EntityIdentifier(
|
||||
Long.valueOf(apptableId));
|
||||
|
||||
return Response.ok().entity(entityIdentifier).build();
|
||||
|
||||
}
|
||||
|
||||
@DELETE
|
||||
@Path("{datatable}/{apptableId}/{datatableId}")
|
||||
@Consumes({ MediaType.APPLICATION_JSON })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public Response deleteDatatableEntries(
|
||||
@PathParam("datatable") final String datatable,
|
||||
@PathParam("apptableId") final Long apptableId,
|
||||
@PathParam("datatableId") final Long datatableId) {
|
||||
|
||||
checkUserPermissionForDatatable(datatable, "DELETE");
|
||||
|
||||
this.readWriteNonCoreDataService.deleteDatatableEntry(datatable,
|
||||
apptableId, datatableId);
|
||||
|
||||
EntityIdentifier entityIdentifier = new EntityIdentifier(
|
||||
Long.valueOf(apptableId));
|
||||
|
||||
return Response.ok().entity(entityIdentifier).build();
|
||||
|
||||
}
|
||||
|
||||
private Map<String, String> getQueryParamsFromJsonRequestBody(
|
||||
String jsonRequestBody) {
|
||||
|
||||
Map<String, String> queryParams = new HashMap<String, String>();
|
||||
|
||||
String pValue = "";
|
||||
String pName;
|
||||
try {
|
||||
JSONObject jsonObj = new JSONObject(jsonRequestBody);
|
||||
JSONArray jsonArr = jsonObj.names();
|
||||
if (jsonArr != null) {
|
||||
for (int i = 0; i < jsonArr.length(); i++) {
|
||||
pName = (String) jsonArr.get(i);
|
||||
pValue = jsonObj.getString(pName);
|
||||
logger.info("getQueryParamsFromJsonRequestBody: " + pName
|
||||
+ " - " + pValue);
|
||||
queryParams.put(pName, pValue);
|
||||
}
|
||||
return queryParams;
|
||||
}
|
||||
throw new WebApplicationException(Response
|
||||
.status(Status.BAD_REQUEST).entity("JSON body empty")
|
||||
.build());
|
||||
|
||||
} catch (JSONException e) {
|
||||
throw new WebApplicationException(Response
|
||||
.status(Status.BAD_REQUEST).entity("JSON body is wrong")
|
||||
.build());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void checkUserPermissionForDatatable(String datatable,
|
||||
String accessType) {
|
||||
AppUser currentUser = context.authenticatedUser();
|
||||
if (currentUser.hasNotPermissionForDatatable(datatable, accessType)) {
|
||||
throw new NoAuthorizationException("Not Authorised to "
|
||||
+ accessType + " Data Table: " + datatable);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+1
-1
@@ -41,7 +41,7 @@ import org.mifosng.platform.saving.service.DepositAccountReadPlatformService;
|
||||
import org.mifosng.platform.saving.service.DepositAccountWritePlatformService;
|
||||
import org.mifosng.platform.savingproduct.service.DepositProductReadPlatformService;
|
||||
import org.mifosng.platform.savingproduct.service.SavingsDepositEnumerations;
|
||||
import org.mifosng.platform.security.PlatformSecurityContext;
|
||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
+3
-3
@@ -20,19 +20,19 @@ import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.UriInfo;
|
||||
|
||||
import org.mifosng.platform.api.commands.DepositProductCommand;
|
||||
import org.mifosng.platform.api.data.CurrencyData;
|
||||
import org.mifosng.platform.api.data.DepositProductData;
|
||||
import org.mifosng.platform.api.data.EntityIdentifier;
|
||||
import org.mifosng.platform.api.data.EnumOptionData;
|
||||
import org.mifosng.platform.api.infrastructure.PortfolioApiDataConversionService;
|
||||
import org.mifosng.platform.api.infrastructure.PortfolioApiJsonSerializerService;
|
||||
import org.mifosng.platform.currency.service.CurrencyReadPlatformService;
|
||||
import org.mifosng.platform.infrastructure.api.ApiParameterHelper;
|
||||
import org.mifosng.platform.loan.domain.PeriodFrequencyType;
|
||||
import org.mifosng.platform.savingproduct.service.DepositProductReadPlatformService;
|
||||
import org.mifosng.platform.savingproduct.service.DepositProductWritePlatformService;
|
||||
import org.mifosng.platform.savingproduct.service.SavingsDepositEnumerations;
|
||||
import org.mifosng.platform.security.PlatformSecurityContext;
|
||||
import org.mifosplatform.infrastructure.configuration.data.CurrencyData;
|
||||
import org.mifosplatform.infrastructure.configuration.service.CurrencyReadPlatformService;
|
||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@ import org.mifosng.platform.documentmanagement.service.DocumentReadPlatformServi
|
||||
import org.mifosng.platform.documentmanagement.service.DocumentWritePlatformService;
|
||||
import org.mifosng.platform.infrastructure.FileUtils;
|
||||
import org.mifosng.platform.infrastructure.api.ApiParameterHelper;
|
||||
import org.mifosng.platform.security.PlatformSecurityContext;
|
||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@@ -1,107 +0,0 @@
|
||||
package org.mifosng.platform.api;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
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.FundCommand;
|
||||
import org.mifosng.platform.api.data.EntityIdentifier;
|
||||
import org.mifosng.platform.api.data.FundData;
|
||||
import org.mifosng.platform.api.infrastructure.PortfolioApiDataConversionService;
|
||||
import org.mifosng.platform.api.infrastructure.PortfolioApiJsonSerializerService;
|
||||
import org.mifosng.platform.fund.service.FundReadPlatformService;
|
||||
import org.mifosng.platform.fund.service.FundWritePlatformService;
|
||||
import org.mifosng.platform.infrastructure.api.ApiParameterHelper;
|
||||
import org.mifosng.platform.security.PlatformSecurityContext;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Path("/funds")
|
||||
@Component
|
||||
@Scope("singleton")
|
||||
public class FundsApiResource {
|
||||
|
||||
@Autowired
|
||||
private FundReadPlatformService readPlatformService;
|
||||
|
||||
@Autowired
|
||||
private FundWritePlatformService writePlatformService;
|
||||
|
||||
@Autowired
|
||||
private PortfolioApiDataConversionService apiDataConversionService;
|
||||
|
||||
@Autowired
|
||||
private PortfolioApiJsonSerializerService apiJsonSerializerService;
|
||||
|
||||
private final String entityType = "FUND";
|
||||
@Autowired
|
||||
private PlatformSecurityContext context;
|
||||
|
||||
@GET
|
||||
@Consumes({MediaType.APPLICATION_JSON})
|
||||
@Produces({MediaType.APPLICATION_JSON})
|
||||
public String retrieveFunds(@Context final UriInfo uriInfo) {
|
||||
|
||||
context.authenticatedUser().validateHasReadPermission(entityType);
|
||||
|
||||
Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters());
|
||||
boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters());
|
||||
|
||||
final Collection<FundData> funds = this.readPlatformService.retrieveAllFunds();
|
||||
|
||||
return this.apiJsonSerializerService.serializeFundDataToJson(prettyPrint, responseParameters, funds);
|
||||
}
|
||||
|
||||
@POST
|
||||
@Consumes({MediaType.APPLICATION_JSON})
|
||||
@Produces({MediaType.APPLICATION_JSON})
|
||||
public Response createFund(final String jsonRequestBody) {
|
||||
|
||||
final FundCommand command = this.apiDataConversionService.convertJsonToFundCommand(null, jsonRequestBody);
|
||||
|
||||
final Long fundId = this.writePlatformService.createFund(command);
|
||||
|
||||
return Response.ok().entity(new EntityIdentifier(fundId)).build();
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("{fundId}")
|
||||
@Consumes({MediaType.APPLICATION_JSON})
|
||||
@Produces({MediaType.APPLICATION_JSON})
|
||||
public String retreiveFund(@PathParam("fundId") final Long fundId, @Context final UriInfo uriInfo) {
|
||||
|
||||
context.authenticatedUser().validateHasReadPermission(entityType);
|
||||
|
||||
final Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters());
|
||||
final boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters());
|
||||
|
||||
final FundData fund = this.readPlatformService.retrieveFund(fundId);
|
||||
|
||||
return this.apiJsonSerializerService.serializeFundDataToJson(prettyPrint, responseParameters, fund);
|
||||
}
|
||||
|
||||
@PUT
|
||||
@Path("{fundId}")
|
||||
@Consumes({MediaType.APPLICATION_JSON})
|
||||
@Produces({MediaType.APPLICATION_JSON})
|
||||
public Response updateFund(@PathParam("fundId") final Long fundId, final String jsonRequestBody) {
|
||||
|
||||
final FundCommand command = this.apiDataConversionService.convertJsonToFundCommand(fundId, jsonRequestBody);
|
||||
|
||||
final Long entityId = this.writePlatformService.updateFund(command);
|
||||
|
||||
return Response.ok().entity(new EntityIdentifier(entityId)).build();
|
||||
}
|
||||
}
|
||||
@@ -25,15 +25,15 @@ import org.mifosng.platform.api.data.ClientLookup;
|
||||
import org.mifosng.platform.api.data.EntityIdentifier;
|
||||
import org.mifosng.platform.api.data.GroupAccountSummaryCollectionData;
|
||||
import org.mifosng.platform.api.data.GroupData;
|
||||
import org.mifosng.platform.api.data.OfficeLookup;
|
||||
import org.mifosng.platform.api.infrastructure.PortfolioApiDataConversionService;
|
||||
import org.mifosng.platform.api.infrastructure.PortfolioApiJsonSerializerService;
|
||||
import org.mifosng.platform.client.service.ClientReadPlatformService;
|
||||
import org.mifosng.platform.group.service.GroupReadPlatformService;
|
||||
import org.mifosng.platform.group.service.GroupWritePlatformService;
|
||||
import org.mifosng.platform.infrastructure.api.ApiParameterHelper;
|
||||
import org.mifosng.platform.organisation.service.OfficeReadPlatformService;
|
||||
import org.mifosng.platform.security.PlatformSecurityContext;
|
||||
import org.mifosplatform.infrastructure.office.data.OfficeLookup;
|
||||
import org.mifosplatform.infrastructure.office.service.OfficeReadPlatformService;
|
||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.mifosng.platform.api.infrastructure.PortfolioApiJsonSerializerService
|
||||
import org.mifosng.platform.guarantor.GuarantorReadPlatformService;
|
||||
import org.mifosng.platform.guarantor.GuarantorWritePlatformService;
|
||||
import org.mifosng.platform.infrastructure.api.ApiParameterHelper;
|
||||
import org.mifosng.platform.security.PlatformSecurityContext;
|
||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
+7
-7
@@ -16,23 +16,23 @@ import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.UriInfo;
|
||||
|
||||
import org.mifosng.platform.api.commands.LoanProductCommand;
|
||||
import org.mifosng.platform.api.data.ChargeData;
|
||||
import org.mifosng.platform.api.data.CurrencyData;
|
||||
import org.mifosng.platform.api.data.EntityIdentifier;
|
||||
import org.mifosng.platform.api.data.EnumOptionData;
|
||||
import org.mifosng.platform.api.data.FundData;
|
||||
import org.mifosng.platform.api.data.LoanProductData;
|
||||
import org.mifosng.platform.api.data.TransactionProcessingStrategyData;
|
||||
import org.mifosng.platform.api.infrastructure.PortfolioApiDataConversionService;
|
||||
import org.mifosng.platform.api.infrastructure.PortfolioApiJsonSerializerService;
|
||||
import org.mifosng.platform.charge.service.ChargeReadPlatformService;
|
||||
import org.mifosng.platform.currency.service.CurrencyReadPlatformService;
|
||||
import org.mifosng.platform.fund.service.FundReadPlatformService;
|
||||
import org.mifosng.platform.infrastructure.api.ApiParameterHelper;
|
||||
import org.mifosng.platform.loanproduct.service.LoanDropdownReadPlatformService;
|
||||
import org.mifosng.platform.loanproduct.service.LoanProductReadPlatformService;
|
||||
import org.mifosng.platform.loanproduct.service.LoanProductWritePlatformService;
|
||||
import org.mifosng.platform.security.PlatformSecurityContext;
|
||||
import org.mifosplatform.infrastructure.configuration.data.CurrencyData;
|
||||
import org.mifosplatform.infrastructure.configuration.service.CurrencyReadPlatformService;
|
||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||
import org.mifosplatform.portfolio.charge.data.ChargeData;
|
||||
import org.mifosplatform.portfolio.charge.service.ChargeReadPlatformService;
|
||||
import org.mifosplatform.portfolio.fund.data.FundData;
|
||||
import org.mifosplatform.portfolio.fund.service.FundReadPlatformService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@@ -24,33 +24,25 @@ import org.mifosng.platform.api.commands.AdjustLoanTransactionCommand;
|
||||
import org.mifosng.platform.api.commands.CalculateLoanScheduleCommand;
|
||||
import org.mifosng.platform.api.commands.LoanApplicationCommand;
|
||||
import org.mifosng.platform.api.commands.LoanChargeCommand;
|
||||
import org.mifosng.platform.api.commands.LoanReassignmentCommand;
|
||||
import org.mifosng.platform.api.commands.LoanStateTransitionCommand;
|
||||
import org.mifosng.platform.api.commands.LoanTransactionCommand;
|
||||
import org.mifosng.platform.api.commands.UndoStateTransitionCommand;
|
||||
import org.mifosng.platform.api.data.ChargeData;
|
||||
import org.mifosng.platform.api.data.DisbursementData;
|
||||
import org.mifosng.platform.api.data.EntityIdentifier;
|
||||
import org.mifosng.platform.api.data.EnumOptionData;
|
||||
import org.mifosng.platform.api.data.FundData;
|
||||
import org.mifosng.platform.api.data.GuarantorData;
|
||||
import org.mifosng.platform.api.data.LoanAccountData;
|
||||
import org.mifosng.platform.api.data.LoanBasicDetailsData;
|
||||
import org.mifosng.platform.api.data.LoanChargeData;
|
||||
import org.mifosng.platform.api.data.LoanPermissionData;
|
||||
import org.mifosng.platform.api.data.LoanProductData;
|
||||
import org.mifosng.platform.api.data.LoanReassignmentData;
|
||||
import org.mifosng.platform.api.data.LoanScheduleData;
|
||||
import org.mifosng.platform.api.data.LoanTransactionData;
|
||||
import org.mifosng.platform.api.data.StaffData;
|
||||
import org.mifosng.platform.api.data.StaffAccountSummaryCollectionData;
|
||||
import org.mifosng.platform.api.data.TransactionProcessingStrategyData;
|
||||
import org.mifosng.platform.api.infrastructure.PortfolioApiDataConversionService;
|
||||
import org.mifosng.platform.api.infrastructure.PortfolioApiJsonSerializerService;
|
||||
import org.mifosng.platform.charge.service.ChargeReadPlatformService;
|
||||
import org.mifosng.platform.currency.domain.MonetaryCurrency;
|
||||
import org.mifosng.platform.currency.domain.Money;
|
||||
import org.mifosng.platform.exceptions.UnrecognizedQueryParamException;
|
||||
import org.mifosng.platform.fund.service.FundReadPlatformService;
|
||||
import org.mifosng.platform.guarantor.GuarantorReadPlatformService;
|
||||
import org.mifosng.platform.infrastructure.api.ApiParameterHelper;
|
||||
import org.mifosng.platform.loan.service.CalculationPlatformService;
|
||||
@@ -58,8 +50,19 @@ import org.mifosng.platform.loan.service.LoanReadPlatformService;
|
||||
import org.mifosng.platform.loan.service.LoanWritePlatformService;
|
||||
import org.mifosng.platform.loanproduct.service.LoanDropdownReadPlatformService;
|
||||
import org.mifosng.platform.loanproduct.service.LoanProductReadPlatformService;
|
||||
import org.mifosng.platform.security.PlatformSecurityContext;
|
||||
import org.mifosng.platform.staff.service.StaffReadPlatformService;
|
||||
import org.mifosplatform.infrastructure.configuration.domain.MonetaryCurrency;
|
||||
import org.mifosplatform.infrastructure.configuration.domain.Money;
|
||||
import org.mifosplatform.infrastructure.office.data.OfficeLookup;
|
||||
import org.mifosplatform.infrastructure.office.service.OfficeReadPlatformService;
|
||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||
import org.mifosplatform.infrastructure.staff.command.BulkTransferLoanOfficerCommand;
|
||||
import org.mifosplatform.infrastructure.staff.data.BulkTransferLoanOfficerData;
|
||||
import org.mifosplatform.infrastructure.staff.data.StaffData;
|
||||
import org.mifosplatform.infrastructure.staff.service.StaffReadPlatformService;
|
||||
import org.mifosplatform.portfolio.charge.data.ChargeData;
|
||||
import org.mifosplatform.portfolio.charge.service.ChargeReadPlatformService;
|
||||
import org.mifosplatform.portfolio.fund.data.FundData;
|
||||
import org.mifosplatform.portfolio.fund.service.FundReadPlatformService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -99,6 +102,9 @@ public class LoansApiResource {
|
||||
|
||||
@Autowired
|
||||
private StaffReadPlatformService staffReadPlatformService;
|
||||
|
||||
@Autowired
|
||||
private OfficeReadPlatformService officeReadPlatformService;
|
||||
|
||||
@Autowired
|
||||
private PlatformSecurityContext context;
|
||||
@@ -215,8 +221,8 @@ public class LoansApiResource {
|
||||
// FIXME - KW - Waive feature was changed to waive interest at
|
||||
// anytime so this permission checking is probably not needed -
|
||||
// look into.
|
||||
final MonetaryCurrency currency = new MonetaryCurrency(loanBasicDetails.getCurrency().getCode(), loanBasicDetails
|
||||
.getCurrency().getDecimalPlaces());
|
||||
final MonetaryCurrency currency = new MonetaryCurrency(loanBasicDetails.getCurrency().code(), loanBasicDetails
|
||||
.getCurrency().decimalPlaces());
|
||||
final Money tolerance = Money.of(currency, loanBasicDetails.getInArrearsTolerance());
|
||||
final Money totalOutstandingMoney = Money.of(currency, repaymentSchedule.totalOutstanding());
|
||||
|
||||
@@ -576,7 +582,7 @@ public class LoansApiResource {
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public Response assignLoanOfficer(@PathParam("loanId") final Long loanId, final String jsonRequestBody) {
|
||||
|
||||
final LoanReassignmentCommand command = this.apiDataConversionService.convertJsonToLoanReassignmentCommand(loanId, jsonRequestBody);
|
||||
final BulkTransferLoanOfficerCommand command = this.apiDataConversionService.convertJsonToLoanReassignmentCommand(loanId, jsonRequestBody);
|
||||
|
||||
EntityIdentifier identifier = this.loanWritePlatformService.loanReassignment(command);
|
||||
|
||||
@@ -593,13 +599,64 @@ public class LoansApiResource {
|
||||
|
||||
final boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters());
|
||||
|
||||
LoanBasicDetailsData loanBasicDetails = this.loanReadPlatformService.retrieveLoanAccountDetails(loanId);
|
||||
final LoanBasicDetailsData loanBasicDetails = this.loanReadPlatformService.retrieveLoanAccountDetails(loanId);
|
||||
|
||||
Collection<StaffData> allowedLoanOfficers = this.staffReadPlatformService.retrieveAllLoanOfficersByOffice(loanBasicDetails
|
||||
.getOfficeId());
|
||||
Long fromLoanOfficerId = loanBasicDetails.getLoanOfficerId();
|
||||
final Collection<StaffData> allowedLoanOfficers = this.staffReadPlatformService.retrieveAllLoanOfficersByOffice(loanBasicDetails.getOfficeId());
|
||||
final Long fromLoanOfficerId = loanBasicDetails.getLoanOfficerId();
|
||||
|
||||
LoanReassignmentData loanReassignmentData = LoanReassignmentData.template(fromLoanOfficerId, allowedLoanOfficers, new LocalDate());
|
||||
final BulkTransferLoanOfficerData loanReassignmentData = BulkTransferLoanOfficerData.template(fromLoanOfficerId, allowedLoanOfficers, new LocalDate());
|
||||
|
||||
return this.apiJsonSerializerService.serializeLoanReassignmentDataToJson(prettyPrint, responseParameters, loanReassignmentData);
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("loanreassignment")
|
||||
@Consumes({ MediaType.APPLICATION_JSON })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public Response loanReassignment(final String apiRequestBodyAsJson) {
|
||||
|
||||
// final List<String> allowedPermissions = Arrays.asList("ALL_FUNCTIONS", "PORTFOLIO_MANAGEMENT_SUPER_USER", "BULKREASSIGN_LOAN");
|
||||
// context.authenticatedUser().validateHasPermissionTo("BULKREASSIGN_LOAN", allowedPermissions);
|
||||
//
|
||||
// final EntityIdentifier result = this.commandsSourceWritePlatformService.logCommandSource("BULKREASSIGN_LOAN", "staff", null,
|
||||
// apiRequestBodyAsJson);
|
||||
//
|
||||
// return this.apiJsonSerializerService.serializeEntityIdentifier(result);
|
||||
|
||||
final BulkTransferLoanOfficerCommand command = this.apiDataConversionService.convertJsonToBulkLoanReassignmentCommand(apiRequestBodyAsJson);
|
||||
|
||||
final EntityIdentifier loanOfficerIdentifier = this.loanWritePlatformService.bulkLoanReassignment(command);
|
||||
|
||||
return Response.ok().entity(loanOfficerIdentifier).build();
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("loanreassignment/template")
|
||||
@Consumes({ MediaType.APPLICATION_JSON })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public String loanReassignmentTemplate(@QueryParam("officeId") final Long officeId,
|
||||
@QueryParam("fromLoanOfficerId") final Long loanOfficerId, @Context final UriInfo uriInfo) {
|
||||
|
||||
context.authenticatedUser().validateHasReadPermission("LOAN");
|
||||
|
||||
final Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters());
|
||||
final boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters());
|
||||
|
||||
final Collection<OfficeLookup> offices = this.officeReadPlatformService.retrieveAllOfficesForLookup();
|
||||
|
||||
Collection<StaffData> loanOfficers = null;
|
||||
StaffAccountSummaryCollectionData staffAccountSummaryCollectionData = null;
|
||||
|
||||
if (officeId != null) {
|
||||
loanOfficers = this.staffReadPlatformService.retrieveAllLoanOfficersByOffice(officeId);
|
||||
}
|
||||
|
||||
if (loanOfficerId != null) {
|
||||
staffAccountSummaryCollectionData = this.staffReadPlatformService.retrieveLoanOfficerAccountSummary(loanOfficerId);
|
||||
}
|
||||
|
||||
final BulkTransferLoanOfficerData loanReassignmentData = BulkTransferLoanOfficerData.templateForBulk(officeId, loanOfficerId, new LocalDate(),
|
||||
offices, loanOfficers, staffAccountSummaryCollectionData);
|
||||
|
||||
return this.apiJsonSerializerService.serializeLoanReassignmentDataToJson(prettyPrint, responseParameters, loanReassignmentData);
|
||||
}
|
||||
|
||||
-125
@@ -1,125 +0,0 @@
|
||||
package org.mifosng.platform.api;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
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.BranchMoneyTransferCommand;
|
||||
import org.mifosng.platform.api.data.EntityIdentifier;
|
||||
import org.mifosng.platform.api.data.OfficeTransactionData;
|
||||
import org.mifosng.platform.api.infrastructure.PortfolioApiDataConversionService;
|
||||
import org.mifosng.platform.api.infrastructure.PortfolioApiJsonSerializerService;
|
||||
import org.mifosng.platform.infrastructure.api.ApiParameterHelper;
|
||||
import org.mifosng.platform.organisation.service.OfficeReadPlatformService;
|
||||
import org.mifosng.platform.organisation.service.OfficeWritePlatformService;
|
||||
import org.mifosng.platform.security.PlatformSecurityContext;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Path("/officetransactions")
|
||||
@Component
|
||||
@Scope("singleton")
|
||||
public class OfficeTransactionsApiResource {
|
||||
|
||||
@Autowired
|
||||
private OfficeWritePlatformService writePlatformService;
|
||||
|
||||
@Autowired
|
||||
private OfficeReadPlatformService readPlatformService;
|
||||
|
||||
@Autowired
|
||||
private PortfolioApiDataConversionService apiDataConversionService;
|
||||
|
||||
@Autowired
|
||||
private PortfolioApiJsonSerializerService apiJsonSerializerService;
|
||||
|
||||
private final String entityType = "OFFICE";
|
||||
@Autowired
|
||||
private PlatformSecurityContext context;
|
||||
|
||||
@GET
|
||||
@Consumes({ MediaType.APPLICATION_JSON })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public String retrieveOfficeTransactions(@Context final UriInfo uriInfo) {
|
||||
|
||||
context.authenticatedUser().validateHasReadPermission(entityType);
|
||||
|
||||
Set<String> typicalResponseParameters = new HashSet<String>(
|
||||
Arrays.asList("id", "transactionDate", "fromOfficeId",
|
||||
"fromOfficeName", "toOfficeId", "toOfficeIdName",
|
||||
"currencyCode", "digitsAfterDecimal",
|
||||
"transactionAmount", "description"));
|
||||
|
||||
Set<String> responseParameters = ApiParameterHelper
|
||||
.extractFieldsForResponseIfProvided(uriInfo
|
||||
.getQueryParameters());
|
||||
if (responseParameters.isEmpty()) {
|
||||
responseParameters.addAll(typicalResponseParameters);
|
||||
}
|
||||
boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo
|
||||
.getQueryParameters());
|
||||
|
||||
Collection<OfficeTransactionData> officeTransactions = this.readPlatformService
|
||||
.retrieveAllOfficeTransactions();
|
||||
|
||||
return this.apiJsonSerializerService
|
||||
.serializeOfficeTransactionDataToJson(prettyPrint,
|
||||
responseParameters, officeTransactions);
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("template")
|
||||
@Consumes({ MediaType.APPLICATION_JSON })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public String newOfficeTransactionDetails(@Context final UriInfo uriInfo) {
|
||||
|
||||
context.authenticatedUser().validateHasReadPermission(entityType);
|
||||
|
||||
Set<String> typicalResponseParameters = new HashSet<String>(
|
||||
Arrays.asList("id", "transactionDate", "allowedOffices",
|
||||
"currencyOptions"));
|
||||
|
||||
Set<String> responseParameters = ApiParameterHelper
|
||||
.extractFieldsForResponseIfProvided(uriInfo
|
||||
.getQueryParameters());
|
||||
if (responseParameters.isEmpty()) {
|
||||
responseParameters.addAll(typicalResponseParameters);
|
||||
}
|
||||
boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo
|
||||
.getQueryParameters());
|
||||
|
||||
OfficeTransactionData officeTransactionData = this.readPlatformService
|
||||
.retrieveNewOfficeTransactionDetails();
|
||||
|
||||
return this.apiJsonSerializerService
|
||||
.serializeOfficeTransactionDataToJson(prettyPrint,
|
||||
responseParameters, officeTransactionData);
|
||||
}
|
||||
|
||||
@POST
|
||||
@Consumes({ MediaType.APPLICATION_JSON })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public Response transferMoneyFrom(final String jsonRequestBody) {
|
||||
|
||||
context.authenticatedUser().validateHasReadPermission("OFFICETRANSACTION");
|
||||
|
||||
BranchMoneyTransferCommand command = this.apiDataConversionService
|
||||
.convertJsonToBranchMoneyTransferCommand(jsonRequestBody);
|
||||
|
||||
Long id = this.writePlatformService
|
||||
.externalBranchMoneyTransfer(command);
|
||||
return Response.ok().entity(new EntityIdentifier(id)).build();
|
||||
}
|
||||
}
|
||||
@@ -1,154 +0,0 @@
|
||||
package org.mifosng.platform.api;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
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.OfficeCommand;
|
||||
import org.mifosng.platform.api.data.EntityIdentifier;
|
||||
import org.mifosng.platform.api.data.OfficeData;
|
||||
import org.mifosng.platform.api.data.OfficeLookup;
|
||||
import org.mifosng.platform.api.infrastructure.PortfolioApiDataConversionService;
|
||||
import org.mifosng.platform.api.infrastructure.PortfolioApiJsonSerializerService;
|
||||
import org.mifosng.platform.infrastructure.api.ApiParameterHelper;
|
||||
import org.mifosng.platform.organisation.service.OfficeReadPlatformService;
|
||||
import org.mifosng.platform.organisation.service.OfficeWritePlatformService;
|
||||
import org.mifosng.platform.security.PlatformSecurityContext;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Path("/offices")
|
||||
@Component
|
||||
@Scope("singleton")
|
||||
public class OfficesApiResource {
|
||||
|
||||
@Autowired
|
||||
private OfficeReadPlatformService readPlatformService;
|
||||
|
||||
@Autowired
|
||||
private OfficeWritePlatformService writePlatformService;
|
||||
|
||||
@Autowired
|
||||
private PortfolioApiDataConversionService apiDataConversionService;
|
||||
|
||||
@Autowired
|
||||
private PortfolioApiJsonSerializerService apiJsonSerializerService;
|
||||
|
||||
private final String entityType = "OFFICE";
|
||||
@Autowired
|
||||
private PlatformSecurityContext context;
|
||||
|
||||
@GET
|
||||
@Consumes({MediaType.APPLICATION_JSON})
|
||||
@Produces({MediaType.APPLICATION_JSON})
|
||||
public String retrieveOffices(@Context final UriInfo uriInfo) {
|
||||
|
||||
context.authenticatedUser().validateHasReadPermission(entityType);
|
||||
|
||||
Set<String> typicalResponseParameters = new HashSet<String>(
|
||||
Arrays.asList("id", "name", "nameDecorated", "externalId", "openingDate",
|
||||
"hierarchy", "parentId", "parentName"));
|
||||
|
||||
Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters());
|
||||
if (responseParameters.isEmpty()) {
|
||||
responseParameters.addAll(typicalResponseParameters);
|
||||
}
|
||||
boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters());
|
||||
|
||||
Collection<OfficeData> offices = this.readPlatformService.retrieveAllOffices();
|
||||
|
||||
return this.apiJsonSerializerService.serializeOfficeDataToJson(prettyPrint, responseParameters, offices);
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("template")
|
||||
@Consumes({MediaType.APPLICATION_JSON})
|
||||
@Produces({MediaType.APPLICATION_JSON})
|
||||
public String retrieveOfficeTemplate(@Context final UriInfo uriInfo) {
|
||||
|
||||
context.authenticatedUser().validateHasReadPermission(entityType);
|
||||
|
||||
Set<String> typicalResponseParameters = new HashSet<String>(
|
||||
Arrays.asList("id", "name", "nameDecorated", "externalId", "openingDate",
|
||||
"hierarchy", "parentId", "parentName", "allowedParents"));
|
||||
|
||||
boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters());
|
||||
|
||||
OfficeData office = this.readPlatformService.retrieveNewOfficeTemplate();
|
||||
List<OfficeLookup> allowedParents = new ArrayList<OfficeLookup>(this.readPlatformService.retrieveAllOfficesForLookup());
|
||||
office = OfficeData.appendedTemplate(office, allowedParents);
|
||||
typicalResponseParameters.add("allowedParents");
|
||||
|
||||
return this.apiJsonSerializerService.serializeOfficeDataToJson(prettyPrint, typicalResponseParameters, office);
|
||||
}
|
||||
|
||||
@POST
|
||||
@Consumes({MediaType.APPLICATION_JSON})
|
||||
@Produces({MediaType.APPLICATION_JSON})
|
||||
public Response createOffice(final String jsonRequestBody) {
|
||||
|
||||
OfficeCommand command = this.apiDataConversionService.convertJsonToOfficeCommand(null, jsonRequestBody);
|
||||
|
||||
Long officeId = this.writePlatformService.createOffice(command);
|
||||
|
||||
return Response.ok().entity(new EntityIdentifier(officeId)).build();
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("{officeId}")
|
||||
@Consumes({MediaType.APPLICATION_JSON})
|
||||
@Produces({MediaType.APPLICATION_JSON})
|
||||
public String retreiveOffice(@PathParam("officeId") final Long officeId, @Context final UriInfo uriInfo) {
|
||||
|
||||
context.authenticatedUser().validateHasReadPermission(entityType);
|
||||
|
||||
Set<String> typicalResponseParameters = new HashSet<String>(
|
||||
Arrays.asList("id", "name", "nameDecorated", "externalId", "openingDate",
|
||||
"hierarchy", "parentId", "parentName"));
|
||||
|
||||
Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters());
|
||||
if (responseParameters.isEmpty()) {
|
||||
responseParameters.addAll(typicalResponseParameters);
|
||||
}
|
||||
boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters());
|
||||
boolean template = ApiParameterHelper.template(uriInfo.getQueryParameters());
|
||||
|
||||
OfficeData office = this.readPlatformService.retrieveOffice(officeId);
|
||||
if (template) {
|
||||
List<OfficeLookup> allowedParents = this.readPlatformService.retrieveAllowedParents(officeId);
|
||||
office = OfficeData.appendedTemplate(office, allowedParents);
|
||||
responseParameters.add("allowedParents");
|
||||
}
|
||||
|
||||
return this.apiJsonSerializerService.serializeOfficeDataToJson(prettyPrint, responseParameters, office);
|
||||
}
|
||||
|
||||
@PUT
|
||||
@Path("{officeId}")
|
||||
@Consumes({MediaType.APPLICATION_JSON})
|
||||
@Produces({MediaType.APPLICATION_JSON})
|
||||
public Response updateOffice(@PathParam("officeId") final Long officeId, final String jsonRequestBody) {
|
||||
|
||||
OfficeCommand command = this.apiDataConversionService.convertJsonToOfficeCommand(officeId, jsonRequestBody);
|
||||
|
||||
Long entityId = this.writePlatformService.updateOffice(command);
|
||||
|
||||
return Response.ok().entity(new EntityIdentifier(entityId)).build();
|
||||
}
|
||||
}
|
||||
@@ -1,183 +0,0 @@
|
||||
package org.mifosng.platform.api;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.GET;
|
||||
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.MultivaluedMap;
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.StreamingOutput;
|
||||
import javax.ws.rs.core.UriInfo;
|
||||
|
||||
import org.mifosng.platform.api.data.GenericResultsetData;
|
||||
import org.mifosng.platform.api.infrastructure.PortfolioApiJsonSerializerService;
|
||||
import org.mifosng.platform.exceptions.NoAuthorizationException;
|
||||
import org.mifosng.platform.infrastructure.api.ApiParameterHelper;
|
||||
import org.mifosng.platform.noncore.ReadReportingService;
|
||||
import org.mifosng.platform.security.PlatformSecurityContext;
|
||||
import org.mifosplatform.infrastructure.user.domain.AppUser;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Path("/reports")
|
||||
@Component
|
||||
@Scope("singleton")
|
||||
public class ReportsApiResource {
|
||||
|
||||
@Autowired
|
||||
private PlatformSecurityContext context;
|
||||
|
||||
@Autowired
|
||||
private ReadReportingService readExtraDataAndReportingService;
|
||||
|
||||
@Autowired
|
||||
private PortfolioApiJsonSerializerService apiJsonSerializerService;
|
||||
|
||||
@GET
|
||||
@Consumes({ MediaType.APPLICATION_JSON })
|
||||
@Produces({ MediaType.APPLICATION_JSON, "application/x-msdownload" })
|
||||
public Response retrieveReportList(@Context final UriInfo uriInfo) {
|
||||
|
||||
Map<String, String> extractedQueryParams = new HashMap<String, String>();
|
||||
|
||||
boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo
|
||||
.getQueryParameters());
|
||||
boolean exportCsv = ApiParameterHelper.exportCsv(uriInfo
|
||||
.getQueryParameters());
|
||||
|
||||
if (!exportCsv) {
|
||||
GenericResultsetData result = this.readExtraDataAndReportingService
|
||||
.retrieveGenericResultset(".", ".", extractedQueryParams);
|
||||
|
||||
final String json = this.apiJsonSerializerService
|
||||
.serializeGenericResultsetDataToJson(prettyPrint, result);
|
||||
|
||||
return Response.ok().entity(json).build();
|
||||
}
|
||||
|
||||
StreamingOutput result = this.readExtraDataAndReportingService
|
||||
.retrieveReportCSV(".", ".", extractedQueryParams);
|
||||
|
||||
return Response
|
||||
.ok()
|
||||
.entity(result)
|
||||
.header("Content-Disposition",
|
||||
"attachment;filename=ReportList.csv").build();
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("{reportName}")
|
||||
@Consumes({ MediaType.APPLICATION_JSON })
|
||||
@Produces({ MediaType.APPLICATION_JSON, "application/x-msdownload",
|
||||
"application/vnd.ms-excel", "application/pdf", "text/html" })
|
||||
public Response retrieveReport(
|
||||
@PathParam("reportName") final String reportName,
|
||||
@Context final UriInfo uriInfo) {
|
||||
|
||||
MultivaluedMap<String, String> queryParams = uriInfo
|
||||
.getQueryParameters();
|
||||
|
||||
boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo
|
||||
.getQueryParameters());
|
||||
boolean exportCsv = ApiParameterHelper.exportCsv(uriInfo
|
||||
.getQueryParameters());
|
||||
boolean parameterType = ApiParameterHelper.parameterType(uriInfo
|
||||
.getQueryParameters());
|
||||
|
||||
checkUserPermissionForReport(reportName, parameterType);
|
||||
|
||||
String parameterTypeValue = null;
|
||||
if (!parameterType) {
|
||||
parameterTypeValue = "report";
|
||||
if (this.readExtraDataAndReportingService.getReportType(reportName)
|
||||
.equalsIgnoreCase("Pentaho")) {
|
||||
Map<String, String> reportParams = getReportParams(queryParams,
|
||||
true);
|
||||
return this.readExtraDataAndReportingService
|
||||
.processPentahoRequest(reportName,
|
||||
queryParams.getFirst("output-type"),
|
||||
reportParams);
|
||||
}
|
||||
} else {
|
||||
parameterTypeValue = "parameter";
|
||||
}
|
||||
|
||||
if (!exportCsv) {
|
||||
|
||||
Map<String, String> reportParams = getReportParams(queryParams,
|
||||
false);
|
||||
|
||||
GenericResultsetData result = this.readExtraDataAndReportingService
|
||||
.retrieveGenericResultset(reportName, parameterTypeValue,
|
||||
reportParams);
|
||||
|
||||
final String json = this.apiJsonSerializerService
|
||||
.serializeGenericResultsetDataToJson(prettyPrint, result);
|
||||
|
||||
return Response.ok().entity(json).type(MediaType.APPLICATION_JSON)
|
||||
.build();
|
||||
}
|
||||
|
||||
// CSV Export
|
||||
Map<String, String> reportParams = getReportParams(queryParams, false);
|
||||
StreamingOutput result = this.readExtraDataAndReportingService
|
||||
.retrieveReportCSV(reportName, parameterTypeValue, reportParams);
|
||||
|
||||
return Response
|
||||
.ok()
|
||||
.entity(result)
|
||||
.type("application/x-msdownload")
|
||||
.header("Content-Disposition",
|
||||
"attachment;filename=" + reportName.replaceAll(" ", "")
|
||||
+ ".csv").build();
|
||||
}
|
||||
|
||||
private void checkUserPermissionForReport(String reportName,
|
||||
boolean parameterType) {
|
||||
|
||||
// Anyone can run a 'report' that is simply getting possible parameter
|
||||
// (dropdown listbox) values.
|
||||
|
||||
if (!parameterType) {
|
||||
AppUser currentUser = context.authenticatedUser();
|
||||
if (currentUser.hasNotPermissionForReport(reportName)) {
|
||||
// FIXME - JW - message isnt passing back the message in the string in
|
||||
// the json just a generalised not authorised message
|
||||
throw new NoAuthorizationException(
|
||||
"Not Authorised to Run Report: " + reportName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Map<String, String> getReportParams(
|
||||
final MultivaluedMap<String, String> queryParams,
|
||||
final Boolean isPentaho) {
|
||||
|
||||
Map<String, String> reportParams = new HashMap<String, String>();
|
||||
Set<String> keys = queryParams.keySet();
|
||||
String pKey;
|
||||
String pValue;
|
||||
for (String k : keys) {
|
||||
|
||||
if (k.startsWith("R_")) {
|
||||
if (isPentaho)
|
||||
pKey = k.substring(2);
|
||||
else
|
||||
pKey = "${" + k.substring(2) + "}";
|
||||
|
||||
pValue = queryParams.get(k).get(0);
|
||||
reportParams.put(pKey, pValue);
|
||||
}
|
||||
}
|
||||
return reportParams;
|
||||
}
|
||||
|
||||
}
|
||||
+3
-3
@@ -20,13 +20,11 @@ import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.UriInfo;
|
||||
|
||||
import org.mifosng.platform.api.commands.SavingProductCommand;
|
||||
import org.mifosng.platform.api.data.CurrencyData;
|
||||
import org.mifosng.platform.api.data.EntityIdentifier;
|
||||
import org.mifosng.platform.api.data.EnumOptionData;
|
||||
import org.mifosng.platform.api.data.SavingProductData;
|
||||
import org.mifosng.platform.api.infrastructure.PortfolioApiDataConversionService;
|
||||
import org.mifosng.platform.api.infrastructure.PortfolioApiJsonSerializerService;
|
||||
import org.mifosng.platform.currency.service.CurrencyReadPlatformService;
|
||||
import org.mifosng.platform.infrastructure.api.ApiParameterHelper;
|
||||
import org.mifosng.platform.savingproduct.domain.SavingFrequencyType;
|
||||
import org.mifosng.platform.savingproduct.domain.SavingInterestCalculationMethod;
|
||||
@@ -37,7 +35,9 @@ import org.mifosng.platform.savingproduct.domain.TenureTypeEnum;
|
||||
import org.mifosng.platform.savingproduct.service.SavingProductEnumerations;
|
||||
import org.mifosng.platform.savingproduct.service.SavingProductReadPlatformService;
|
||||
import org.mifosng.platform.savingproduct.service.SavingProductWritePlatformService;
|
||||
import org.mifosng.platform.security.PlatformSecurityContext;
|
||||
import org.mifosplatform.infrastructure.configuration.data.CurrencyData;
|
||||
import org.mifosplatform.infrastructure.configuration.service.CurrencyReadPlatformService;
|
||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ import org.mifosng.platform.api.infrastructure.PortfolioApiJsonSerializerService
|
||||
import org.mifosng.platform.infrastructure.api.ApiParameterHelper;
|
||||
import org.mifosng.platform.saving.service.SavingAccountReadPlatformService;
|
||||
import org.mifosng.platform.saving.service.SavingAccountWritePlatformService;
|
||||
import org.mifosng.platform.security.PlatformSecurityContext;
|
||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@@ -1,219 +0,0 @@
|
||||
package org.mifosng.platform.api;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
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.QueryParam;
|
||||
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.apache.commons.lang.StringUtils;
|
||||
import org.joda.time.LocalDate;
|
||||
import org.mifosng.platform.api.commands.LoanReassignmentCommand;
|
||||
import org.mifosng.platform.api.commands.StaffCommand;
|
||||
import org.mifosng.platform.api.data.EntityIdentifier;
|
||||
import org.mifosng.platform.api.data.LoanReassignmentData;
|
||||
import org.mifosng.platform.api.data.OfficeLookup;
|
||||
import org.mifosng.platform.api.data.StaffAccountSummaryCollectionData;
|
||||
import org.mifosng.platform.api.data.StaffData;
|
||||
import org.mifosng.platform.api.infrastructure.PortfolioApiDataConversionService;
|
||||
import org.mifosng.platform.api.infrastructure.PortfolioApiJsonSerializerService;
|
||||
import org.mifosng.platform.infrastructure.api.ApiParameterHelper;
|
||||
import org.mifosng.platform.loan.service.LoanWritePlatformService;
|
||||
import org.mifosng.platform.organisation.service.OfficeReadPlatformService;
|
||||
import org.mifosng.platform.security.PlatformSecurityContext;
|
||||
import org.mifosng.platform.staff.service.StaffReadPlatformService;
|
||||
import org.mifosng.platform.staff.service.StaffWritePlatformService;
|
||||
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;
|
||||
|
||||
@Path("/staff")
|
||||
@Component
|
||||
@Scope("singleton")
|
||||
public class StaffApiResource {
|
||||
|
||||
@Autowired
|
||||
private StaffReadPlatformService readPlatformService;
|
||||
|
||||
@Autowired
|
||||
private StaffWritePlatformService writePlatformService;
|
||||
|
||||
@Autowired
|
||||
private PortfolioApiDataConversionService apiDataConversionService;
|
||||
|
||||
@Autowired
|
||||
private PortfolioApiJsonSerializerService apiJsonSerializerService;
|
||||
|
||||
@Autowired
|
||||
private OfficeReadPlatformService officeReadPlatformService;
|
||||
|
||||
@Autowired
|
||||
private LoanWritePlatformService loanWritePlatformService;
|
||||
|
||||
private final String entityType = "STAFF";
|
||||
@Autowired
|
||||
private PlatformSecurityContext context;
|
||||
|
||||
private final static Logger logger = LoggerFactory
|
||||
.getLogger(StaffApiResource.class);
|
||||
|
||||
@GET
|
||||
@Consumes({ MediaType.APPLICATION_JSON })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public String retrieveStaff(@Context final UriInfo uriInfo,
|
||||
@QueryParam("sqlSearch") final String sqlSearch,
|
||||
@QueryParam("officeId") final Integer officeId) {
|
||||
|
||||
context.authenticatedUser().validateHasReadPermission(entityType);
|
||||
|
||||
Set<String> responseParameters = ApiParameterHelper
|
||||
.extractFieldsForResponseIfProvided(uriInfo
|
||||
.getQueryParameters());
|
||||
boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo
|
||||
.getQueryParameters());
|
||||
|
||||
final String extraCriteria = getStaffCriteria(sqlSearch, officeId);
|
||||
final Collection<StaffData> staff = this.readPlatformService
|
||||
.retrieveAllStaff(extraCriteria);
|
||||
|
||||
return this.apiJsonSerializerService.serializeStaffDataToJson(
|
||||
prettyPrint, responseParameters, staff);
|
||||
}
|
||||
|
||||
@POST
|
||||
@Consumes({ MediaType.APPLICATION_JSON })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public Response createStaff(final String jsonRequestBody) {
|
||||
|
||||
final StaffCommand command = this.apiDataConversionService
|
||||
.convertJsonToStaffCommand(null, jsonRequestBody);
|
||||
|
||||
final Long staffId = this.writePlatformService.createStaff(command);
|
||||
|
||||
return Response.ok().entity(new EntityIdentifier(staffId)).build();
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("{staffId}")
|
||||
@Consumes({ MediaType.APPLICATION_JSON })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public String retreiveStaff(@PathParam("staffId") final Long staffId,
|
||||
@Context final UriInfo uriInfo) {
|
||||
|
||||
context.authenticatedUser().validateHasReadPermission(entityType);
|
||||
|
||||
final Set<String> responseParameters = ApiParameterHelper
|
||||
.extractFieldsForResponseIfProvided(uriInfo
|
||||
.getQueryParameters());
|
||||
final boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo
|
||||
.getQueryParameters());
|
||||
boolean template = ApiParameterHelper.template(uriInfo
|
||||
.getQueryParameters());
|
||||
|
||||
final StaffData staff = this.readPlatformService.retrieveStaff(staffId);
|
||||
if (template) {
|
||||
staff.setAllowedOffices(new ArrayList<OfficeLookup>(
|
||||
officeReadPlatformService.retrieveAllOfficesForLookup()));
|
||||
}
|
||||
|
||||
return this.apiJsonSerializerService.serializeStaffDataToJson(
|
||||
prettyPrint, responseParameters, staff);
|
||||
}
|
||||
|
||||
@PUT
|
||||
@Path("{staffId}")
|
||||
@Consumes({ MediaType.APPLICATION_JSON })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public Response updateStaff(@PathParam("staffId") final Long staffId,
|
||||
final String jsonRequestBody) {
|
||||
|
||||
final StaffCommand command = this.apiDataConversionService
|
||||
.convertJsonToStaffCommand(staffId, jsonRequestBody);
|
||||
|
||||
final Long entityId = this.writePlatformService.updateStaff(command);
|
||||
|
||||
return Response.ok().entity(new EntityIdentifier(entityId)).build();
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("loanreassignment")
|
||||
@Consumes({ MediaType.APPLICATION_JSON })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public Response loanReassignment(final String jsonRequestBody){
|
||||
|
||||
LoanReassignmentCommand command =
|
||||
this.apiDataConversionService.convertJsonToBulkLoanReassignmentCommand(jsonRequestBody);
|
||||
|
||||
EntityIdentifier loanOfficerIdentifier = this.loanWritePlatformService.bulkLoanReassignment(command);
|
||||
|
||||
return Response.ok().entity(loanOfficerIdentifier).build();
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("loanreassignment/template")
|
||||
@Consumes({ MediaType.APPLICATION_JSON })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public String loanReassignmentTemplate(@QueryParam("officeId") final Long officeId,
|
||||
@QueryParam("fromLoanOfficerId") final Long loanOfficerId,
|
||||
@Context final UriInfo uriInfo){
|
||||
|
||||
context.authenticatedUser().validateHasReadPermission("LOAN");
|
||||
|
||||
final Set<String> responseParameters = ApiParameterHelper
|
||||
.extractFieldsForResponseIfProvided(uriInfo
|
||||
.getQueryParameters());
|
||||
|
||||
final boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters());
|
||||
|
||||
final Collection<OfficeLookup> offices = this.officeReadPlatformService.retrieveAllOfficesForLookup();
|
||||
|
||||
Collection<StaffData> loanOfficers = null;
|
||||
StaffAccountSummaryCollectionData staffAccountSummaryCollectionData = null;
|
||||
|
||||
if (officeId != null) {
|
||||
loanOfficers = this.readPlatformService.retrieveAllLoanOfficersByOffice(officeId);
|
||||
}
|
||||
|
||||
if (loanOfficerId != null) {
|
||||
staffAccountSummaryCollectionData = this.readPlatformService.retrieveLoanOfficerAccountSummary(loanOfficerId);
|
||||
}
|
||||
|
||||
final LoanReassignmentData loanReassignmentData = LoanReassignmentData.templateForBulk(officeId, loanOfficerId,
|
||||
new LocalDate(), offices, loanOfficers, staffAccountSummaryCollectionData);
|
||||
|
||||
return this.apiJsonSerializerService.serializeLoanReassignmentDataToJson(prettyPrint, responseParameters, loanReassignmentData);
|
||||
}
|
||||
|
||||
private String getStaffCriteria(String sqlSearch, Integer officeId) {
|
||||
|
||||
String extraCriteria = "";
|
||||
|
||||
if (sqlSearch != null) {
|
||||
extraCriteria = " and (" + sqlSearch + ")";
|
||||
}
|
||||
if (officeId != null) {
|
||||
extraCriteria += " and office_id = " + officeId;
|
||||
}
|
||||
|
||||
if (StringUtils.isNotBlank(extraCriteria)) {
|
||||
extraCriteria = extraCriteria.substring(4);
|
||||
}
|
||||
logger.info("extraCriteria; " + extraCriteria);
|
||||
|
||||
return extraCriteria;
|
||||
}
|
||||
|
||||
}
|
||||
-60
@@ -1,60 +0,0 @@
|
||||
package org.mifosng.platform.api.commands;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Set;
|
||||
|
||||
import org.joda.time.LocalDate;
|
||||
|
||||
/**
|
||||
* Immutable command for transfering money between two branches.
|
||||
*/
|
||||
public class BranchMoneyTransferCommand {
|
||||
|
||||
private final Long fromOfficeId;
|
||||
private final Long toOfficeId;
|
||||
private final LocalDate transactionDate;
|
||||
private final String currencyCode;
|
||||
private final BigDecimal transactionAmount;
|
||||
private final String description;
|
||||
|
||||
private final Set<String> modifiedParameters;
|
||||
|
||||
public BranchMoneyTransferCommand(final Set<String> modifiedParameters, final Long fromOfficeId, final Long toOfficeId,
|
||||
final LocalDate transactionDate, final String currencyCode, final BigDecimal transactionAmount, final String description) {
|
||||
this.modifiedParameters = modifiedParameters;
|
||||
this.fromOfficeId = fromOfficeId;
|
||||
this.toOfficeId = toOfficeId;
|
||||
this.transactionDate = transactionDate;
|
||||
this.currencyCode = currencyCode;
|
||||
this.transactionAmount = transactionAmount;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public Long getFromOfficeId() {
|
||||
return fromOfficeId;
|
||||
}
|
||||
|
||||
public Long getToOfficeId() {
|
||||
return toOfficeId;
|
||||
}
|
||||
|
||||
public LocalDate getTransactionDate() {
|
||||
return transactionDate;
|
||||
}
|
||||
|
||||
public String getCurrencyCode() {
|
||||
return currencyCode;
|
||||
}
|
||||
|
||||
public BigDecimal getTransactionAmount() {
|
||||
return transactionAmount;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public boolean isFromOfficeIdChanged() {
|
||||
return this.modifiedParameters.contains("fromOfficeId");
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
package org.mifosng.platform.api.commands;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Immutable command for creating or updating details of a Code in mifos.
|
||||
*/
|
||||
public class CodeCommand {
|
||||
|
||||
private final Long id;
|
||||
private final String codeName;
|
||||
|
||||
private final Set<String> modifiedParameters;
|
||||
|
||||
public CodeCommand(final Set<String> modifiedParameters, final Long id, final String codeName) {
|
||||
this.modifiedParameters = modifiedParameters;
|
||||
this.id = id;
|
||||
this.codeName = codeName;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getCodeName() {
|
||||
return codeName;
|
||||
}
|
||||
|
||||
public boolean isNameChanged() {
|
||||
return this.modifiedParameters.contains("name");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
package org.mifosng.platform.api.commands;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Immutable command for creating or updating details of a fund.
|
||||
*/
|
||||
public class FundCommand {
|
||||
|
||||
private final Long id;
|
||||
private final String name;
|
||||
private final String externalId;
|
||||
|
||||
private final Set<String> modifiedParameters;
|
||||
|
||||
public FundCommand(final Set<String> modifiedParameters, final Long id, final String fundName, final String externalId) {
|
||||
this.modifiedParameters = modifiedParameters;
|
||||
this.id = id;
|
||||
this.name = fundName;
|
||||
this.externalId = externalId;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getExternalId() {
|
||||
return externalId;
|
||||
}
|
||||
|
||||
public boolean isNameChanged() {
|
||||
return this.modifiedParameters.contains("name");
|
||||
}
|
||||
|
||||
public boolean isExternalIdChanged() {
|
||||
return this.modifiedParameters.contains("externalId");
|
||||
}
|
||||
}
|
||||
-55
@@ -1,55 +0,0 @@
|
||||
package org.mifosng.platform.api.commands;
|
||||
|
||||
import org.joda.time.LocalDate;
|
||||
|
||||
/**
|
||||
* Immutable data object for reassigning loan officers on loans in bulk.
|
||||
*/
|
||||
public class LoanReassignmentCommand {
|
||||
|
||||
private final Long loanId;
|
||||
|
||||
private final Long fromLoanOfficerId;
|
||||
private final Long toLoanOfficerId;
|
||||
private final LocalDate assignmentDate;
|
||||
|
||||
private final String[] loans;
|
||||
|
||||
public LoanReassignmentCommand(Long loanId, Long fromLoanOfficerId,
|
||||
Long toLoanOfficerId, LocalDate assignmentDate) {
|
||||
this.loanId = loanId;
|
||||
this.fromLoanOfficerId = fromLoanOfficerId;
|
||||
this.toLoanOfficerId = toLoanOfficerId;
|
||||
this.assignmentDate = assignmentDate;
|
||||
this.loans = null;
|
||||
}
|
||||
|
||||
public LoanReassignmentCommand(Long fromLoanOfficerId, Long toLoanOfficerId,
|
||||
LocalDate assignmentDate, String[] loans) {
|
||||
this.fromLoanOfficerId = fromLoanOfficerId;
|
||||
this.toLoanOfficerId = toLoanOfficerId;
|
||||
this.assignmentDate = assignmentDate;
|
||||
this.loans = loans;
|
||||
this.loanId = null;
|
||||
}
|
||||
|
||||
public Long getLoanId() {
|
||||
return loanId;
|
||||
}
|
||||
|
||||
public Long getFromLoanOfficerId() {
|
||||
return fromLoanOfficerId;
|
||||
}
|
||||
|
||||
public Long getToLoanOfficerId() {
|
||||
return toLoanOfficerId;
|
||||
}
|
||||
|
||||
public LocalDate getAssignmentDate() {
|
||||
return assignmentDate;
|
||||
}
|
||||
|
||||
public String[] getLoans() {
|
||||
return loans;
|
||||
}
|
||||
}
|
||||
@@ -1,66 +0,0 @@
|
||||
package org.mifosng.platform.api.commands;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.joda.time.LocalDate;
|
||||
|
||||
/**
|
||||
* Immutable command for creating or updating details of a office.
|
||||
*/
|
||||
public class OfficeCommand {
|
||||
|
||||
private final Long id;
|
||||
private final String name;
|
||||
private final String externalId;
|
||||
private final LocalDate openingDate;
|
||||
private final Long parentId;
|
||||
|
||||
private final Set<String> modifiedParameters;
|
||||
|
||||
public OfficeCommand(final Set<String> modifiedParameters, final Long id, final String officeName,
|
||||
final String externalId, final Long parentId,
|
||||
final LocalDate openingDate) {
|
||||
this.modifiedParameters = modifiedParameters;
|
||||
this.id = id;
|
||||
this.name = officeName;
|
||||
this.externalId = externalId;
|
||||
this.parentId = parentId;
|
||||
this.openingDate = openingDate;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getExternalId() {
|
||||
return externalId;
|
||||
}
|
||||
|
||||
public LocalDate getOpeningDate() {
|
||||
return openingDate;
|
||||
}
|
||||
|
||||
public Long getParentId() {
|
||||
return parentId;
|
||||
}
|
||||
|
||||
public boolean isNameChanged() {
|
||||
return this.modifiedParameters.contains("name");
|
||||
}
|
||||
|
||||
public boolean isExternalIdChanged() {
|
||||
return this.modifiedParameters.contains("externalId");
|
||||
}
|
||||
|
||||
public boolean isOpeningDateChanged() {
|
||||
return this.modifiedParameters.contains("openingDate");
|
||||
}
|
||||
|
||||
public boolean isParentChanged() {
|
||||
return this.modifiedParameters.contains("parentId");
|
||||
}
|
||||
}
|
||||
-17
@@ -1,17 +0,0 @@
|
||||
package org.mifosng.platform.api.commands;
|
||||
|
||||
/**
|
||||
* Immutable command for updating allowed currencies.
|
||||
*/
|
||||
public class OrganisationCurrencyCommand {
|
||||
|
||||
private String[] currencies;
|
||||
|
||||
public OrganisationCurrencyCommand(final String[] currencies) {
|
||||
this.currencies = currencies;
|
||||
}
|
||||
|
||||
public String[] getCurrencies() {
|
||||
return currencies;
|
||||
}
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
package org.mifosng.platform.api.commands;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Immutable command for creating or updating details of a staff member.
|
||||
*/
|
||||
public class StaffCommand {
|
||||
|
||||
private final Long id;
|
||||
private final String firstName;
|
||||
private final String lastName;
|
||||
private final Long officeId;
|
||||
private final Boolean loanOfficerFlag;
|
||||
|
||||
private final Set<String> modifiedParameters;
|
||||
|
||||
public StaffCommand(final Set<String> modifiedParameters, final Long id,
|
||||
final Long officeId, final String firstName, final String lastName,
|
||||
final Boolean loanOfficerFlag) {
|
||||
this.modifiedParameters = modifiedParameters;
|
||||
this.id = id;
|
||||
this.firstName = firstName;
|
||||
this.lastName = lastName;
|
||||
this.officeId = officeId;
|
||||
this.loanOfficerFlag = loanOfficerFlag;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getFirstName() {
|
||||
return firstName;
|
||||
}
|
||||
|
||||
public String getLastName() {
|
||||
return lastName;
|
||||
}
|
||||
|
||||
public Long getOfficeId() {
|
||||
return officeId;
|
||||
}
|
||||
|
||||
public Boolean getLoanOfficerFlag() {
|
||||
return loanOfficerFlag;
|
||||
}
|
||||
|
||||
public boolean isLoanOfficerFlag() {
|
||||
boolean isLoanOfficer = false;
|
||||
if (loanOfficerFlag != null) {
|
||||
isLoanOfficer = loanOfficerFlag.booleanValue();
|
||||
}
|
||||
return isLoanOfficer;
|
||||
}
|
||||
|
||||
public boolean isFirstNameChanged() {
|
||||
return this.modifiedParameters.contains("firstname");
|
||||
}
|
||||
|
||||
public boolean isLastNameChanged() {
|
||||
return this.modifiedParameters.contains("lastname");
|
||||
}
|
||||
|
||||
public boolean isLoanOfficerFlagChanged() {
|
||||
return this.modifiedParameters.contains("loanOfficerFlag");
|
||||
}
|
||||
|
||||
public boolean isOfficeChanged() {
|
||||
return this.modifiedParameters.contains("officeId");
|
||||
}
|
||||
}
|
||||
@@ -1,128 +0,0 @@
|
||||
package org.mifosng.platform.api.data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Immutable data object for charge data.
|
||||
*/
|
||||
public class ChargeData {
|
||||
|
||||
private final Long id;
|
||||
private final String name;
|
||||
private final boolean active;
|
||||
private final boolean penalty;
|
||||
private final CurrencyData currency;
|
||||
private final BigDecimal amount;
|
||||
private final EnumOptionData chargeTimeType;
|
||||
private final EnumOptionData chargeAppliesTo;
|
||||
private final EnumOptionData chargeCalculationType;
|
||||
|
||||
private final List<CurrencyData> currencyOptions;
|
||||
private final List<EnumOptionData> chargeCalculationTypeOptions;
|
||||
private final List<EnumOptionData> chargeAppliesToOptions;
|
||||
private final List<EnumOptionData> chargeTimeTypeOptions;
|
||||
|
||||
public static ChargeData template(
|
||||
final List<CurrencyData> currencyOptions,
|
||||
final List<EnumOptionData> chargeCalculationTypeOptions,
|
||||
final List<EnumOptionData> chargeAppliesToOptions,
|
||||
final List<EnumOptionData> chargeTimeTypeOptions) {
|
||||
|
||||
return new ChargeData(null, null, null, null, null, null, null, false, false,
|
||||
currencyOptions, chargeCalculationTypeOptions, chargeAppliesToOptions, chargeTimeTypeOptions);
|
||||
}
|
||||
|
||||
public ChargeData(final ChargeData charge, final ChargeData template){
|
||||
this(charge.id, charge.name, charge.amount, charge.currency, charge.chargeTimeType,
|
||||
charge.chargeAppliesTo, charge.chargeCalculationType,
|
||||
charge.penalty, charge.active,
|
||||
template.currencyOptions, template.chargeCalculationTypeOptions,
|
||||
template.chargeAppliesToOptions, template.chargeTimeTypeOptions);
|
||||
}
|
||||
|
||||
public ChargeData(final Long id, final String name,
|
||||
final BigDecimal amount, final CurrencyData currency,
|
||||
final EnumOptionData chargeTimeType,
|
||||
final EnumOptionData chargeAppliesTo,
|
||||
final EnumOptionData chargeCalculationType, final boolean penalty, final boolean active) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.amount = amount;
|
||||
this.currency = currency;
|
||||
this.chargeTimeType = chargeTimeType;
|
||||
this.chargeAppliesTo = chargeAppliesTo;
|
||||
this.chargeCalculationType = chargeCalculationType;
|
||||
this.penalty = penalty;
|
||||
this.active = active;
|
||||
this.currencyOptions = null;
|
||||
this.chargeCalculationTypeOptions = null;
|
||||
this.chargeAppliesToOptions = null;
|
||||
this.chargeTimeTypeOptions = null;
|
||||
}
|
||||
|
||||
public ChargeData(final Long id, final String name,
|
||||
final BigDecimal amount, final CurrencyData currency,
|
||||
final EnumOptionData chargeTimeType,
|
||||
final EnumOptionData chargeAppliesTo,
|
||||
final EnumOptionData chargeCalculationType,
|
||||
final boolean penalty,
|
||||
final boolean active,
|
||||
final List<CurrencyData> currencyOptions,
|
||||
final List<EnumOptionData> chargeCalculationTypeOptions,
|
||||
final List<EnumOptionData> chargeAppliesToOptions,
|
||||
final List<EnumOptionData> chargeTimeTypeOptions) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.amount = amount;
|
||||
this.currency = currency;
|
||||
this.chargeTimeType = chargeTimeType;
|
||||
this.chargeAppliesTo = chargeAppliesTo;
|
||||
this.chargeCalculationType = chargeCalculationType;
|
||||
this.penalty = penalty;
|
||||
this.active = active;
|
||||
this.currencyOptions = currencyOptions;
|
||||
this.chargeCalculationTypeOptions = chargeCalculationTypeOptions;
|
||||
this.chargeAppliesToOptions = chargeAppliesToOptions;
|
||||
this.chargeTimeTypeOptions = chargeTimeTypeOptions;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public boolean isPenalty() {
|
||||
return this.penalty;
|
||||
}
|
||||
|
||||
public BigDecimal getAmount() {
|
||||
return amount;
|
||||
}
|
||||
|
||||
public CurrencyData getCurrency() {
|
||||
return currency;
|
||||
}
|
||||
|
||||
public EnumOptionData getChargeTimeType() {
|
||||
return chargeTimeType;
|
||||
}
|
||||
|
||||
public EnumOptionData getChargeCalculationType() {
|
||||
return chargeCalculationType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
ChargeData chargeData = (ChargeData) obj;
|
||||
return this.id.equals(chargeData.id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return this.id.hashCode();
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import java.util.List;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.joda.time.LocalDate;
|
||||
import org.mifosplatform.infrastructure.office.data.OfficeLookup;
|
||||
|
||||
/**
|
||||
* Immutable data object representing client data.
|
||||
|
||||
@@ -2,6 +2,8 @@ package org.mifosng.platform.api.data;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.mifosplatform.infrastructure.codes.data.CodeValueData;
|
||||
|
||||
/**
|
||||
* Immutable data object represent client identity data.
|
||||
*/
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
package org.mifosng.platform.api.data;
|
||||
|
||||
/**
|
||||
* Immutable data object representing a code.
|
||||
*/
|
||||
public class CodeData {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private final Long id;
|
||||
@SuppressWarnings("unused")
|
||||
private final String name;
|
||||
|
||||
public CodeData(final Long id, final String name) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
package org.mifosng.platform.api.data;
|
||||
|
||||
/**
|
||||
* Immutable data object represent code-value data in system.
|
||||
*/
|
||||
public class CodeValueData {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private final Long id;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private final String name;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private final Integer position;
|
||||
|
||||
public CodeValueData(
|
||||
final Long id,
|
||||
final String name,
|
||||
final Integer position) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.position = position;
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
package org.mifosng.platform.api.data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Immutable data object for configuration.
|
||||
*/
|
||||
public class ConfigurationData {
|
||||
|
||||
private final List<CurrencyData> selectedCurrencyOptions;
|
||||
private final List<CurrencyData> currencyOptions;
|
||||
|
||||
public ConfigurationData(final List<CurrencyData> currencyOptions, final List<CurrencyData> selectedCurrencyOptions) {
|
||||
this.currencyOptions = currencyOptions;
|
||||
this.selectedCurrencyOptions = selectedCurrencyOptions;
|
||||
}
|
||||
|
||||
public List<CurrencyData> getSelectedCurrencyOptions() {
|
||||
return selectedCurrencyOptions;
|
||||
}
|
||||
|
||||
public List<CurrencyData> getCurrencyOptions() {
|
||||
return currencyOptions;
|
||||
}
|
||||
}
|
||||
@@ -1,75 +0,0 @@
|
||||
package org.mifosng.platform.api.data;
|
||||
|
||||
/**
|
||||
* Immutable data object representing currency.
|
||||
*/
|
||||
public class CurrencyData {
|
||||
|
||||
private final String code;
|
||||
private final String name;
|
||||
private final int decimalPlaces;
|
||||
private final String displaySymbol;
|
||||
private final String nameCode;
|
||||
private final String displayLabel;
|
||||
|
||||
public static CurrencyData blank() {
|
||||
return new CurrencyData("", "", 0, "", "");
|
||||
}
|
||||
|
||||
public CurrencyData(final String code, final String name, final int decimalPlaces, final String displaySymbol, final String nameCode) {
|
||||
this.code = code;
|
||||
this.name = name;
|
||||
this.decimalPlaces = decimalPlaces;
|
||||
this.displaySymbol = displaySymbol;
|
||||
this.nameCode = nameCode;
|
||||
this.displayLabel = generateDisplayLabel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
CurrencyData currencyData = (CurrencyData) obj;
|
||||
return currencyData.code.equals(this.code);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return this.code.hashCode();
|
||||
}
|
||||
|
||||
private String generateDisplayLabel() {
|
||||
|
||||
StringBuilder builder = new StringBuilder(this.name).append(' ');
|
||||
|
||||
if (this.displaySymbol != null && !"".equalsIgnoreCase(displaySymbol.trim())) {
|
||||
builder.append('(').append(this.displaySymbol).append(')');
|
||||
} else {
|
||||
builder.append('[').append(this.code).append(']');
|
||||
}
|
||||
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public int getDecimalPlaces() {
|
||||
return decimalPlaces;
|
||||
}
|
||||
|
||||
public String getDisplaySymbol() {
|
||||
return displaySymbol;
|
||||
}
|
||||
|
||||
public String getNameCode() {
|
||||
return nameCode;
|
||||
}
|
||||
|
||||
public String getDisplayLabel() {
|
||||
return displayLabel;
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
package org.mifosng.platform.api.data;
|
||||
|
||||
public class DatatableData {
|
||||
|
||||
private final String applicationTableName;
|
||||
private final String registeredTableName;
|
||||
|
||||
public DatatableData(final String applicationTableName,
|
||||
final String registeredTableName) {
|
||||
this.applicationTableName = applicationTableName;
|
||||
this.registeredTableName = registeredTableName;
|
||||
}
|
||||
|
||||
public String getApplicationTableName() {
|
||||
return applicationTableName;
|
||||
}
|
||||
|
||||
public String getRegisteredTableName() {
|
||||
return registeredTableName;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10,6 +10,7 @@ import java.util.List;
|
||||
import org.joda.time.Days;
|
||||
import org.joda.time.LocalDate;
|
||||
import org.joda.time.Months;
|
||||
import org.mifosplatform.infrastructure.configuration.data.CurrencyData;
|
||||
|
||||
/**
|
||||
* Immutable data object for deposit accounts.
|
||||
|
||||
@@ -5,6 +5,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.joda.time.DateTime;
|
||||
import org.mifosplatform.infrastructure.configuration.data.CurrencyData;
|
||||
|
||||
/**
|
||||
* Immutable data object representing details of a deposit product.
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
package org.mifosng.platform.api.data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class FundData implements Serializable {
|
||||
|
||||
private Long id;
|
||||
private String name;
|
||||
private String externalId;
|
||||
|
||||
public FundData() {
|
||||
//
|
||||
}
|
||||
|
||||
public FundData(final Long id, final String name, final String externalId) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.externalId = externalId;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getExternalId() {
|
||||
return externalId;
|
||||
}
|
||||
|
||||
public void setExternalId(String externalId) {
|
||||
this.externalId = externalId;
|
||||
}
|
||||
}
|
||||
-25
@@ -1,25 +0,0 @@
|
||||
package org.mifosng.platform.api.data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Immutable data object for generic resultset data.
|
||||
*/
|
||||
public class GenericResultsetData {
|
||||
|
||||
private final List<ResultsetColumnHeader> columnHeaders;
|
||||
private final List<ResultsetDataRow> data;
|
||||
|
||||
public GenericResultsetData(final List<ResultsetColumnHeader> columnHeaders, final List<ResultsetDataRow> resultsetDataRows) {
|
||||
this.columnHeaders = columnHeaders;
|
||||
this.data = resultsetDataRows;
|
||||
}
|
||||
|
||||
public List<ResultsetColumnHeader> getColumnHeaders() {
|
||||
return columnHeaders;
|
||||
}
|
||||
|
||||
public List<ResultsetDataRow> getData() {
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,8 @@ package org.mifosng.platform.api.data;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.mifosplatform.infrastructure.office.data.OfficeLookup;
|
||||
|
||||
/**
|
||||
* Immutable data object representing groups.
|
||||
*/
|
||||
|
||||
@@ -4,6 +4,10 @@ import java.math.BigDecimal;
|
||||
import java.util.Collection;
|
||||
|
||||
import org.joda.time.LocalDate;
|
||||
import org.mifosplatform.infrastructure.configuration.data.CurrencyData;
|
||||
import org.mifosplatform.infrastructure.staff.data.StaffData;
|
||||
import org.mifosplatform.portfolio.charge.data.ChargeData;
|
||||
import org.mifosplatform.portfolio.fund.data.FundData;
|
||||
|
||||
/**
|
||||
* Immutable data object representing loan account data.
|
||||
|
||||
@@ -8,6 +8,8 @@ import org.joda.time.DateTime;
|
||||
import org.joda.time.Days;
|
||||
import org.joda.time.LocalDate;
|
||||
import org.joda.time.Months;
|
||||
import org.mifosplatform.infrastructure.configuration.data.CurrencyData;
|
||||
import org.mifosplatform.portfolio.charge.data.ChargeData;
|
||||
|
||||
/**
|
||||
* Immutable data object for core details of loan to be combined with {@link LoanAccountData} usage.
|
||||
|
||||
@@ -4,6 +4,8 @@ import java.math.BigDecimal;
|
||||
import java.util.Collection;
|
||||
|
||||
import org.joda.time.LocalDate;
|
||||
import org.mifosplatform.infrastructure.configuration.data.CurrencyData;
|
||||
import org.mifosplatform.portfolio.charge.data.ChargeData;
|
||||
|
||||
/**
|
||||
* Immutable data object for loan charge data.
|
||||
|
||||
@@ -11,6 +11,9 @@ import org.mifosng.platform.loan.domain.InterestCalculationPeriodMethod;
|
||||
import org.mifosng.platform.loan.domain.InterestMethod;
|
||||
import org.mifosng.platform.loan.domain.PeriodFrequencyType;
|
||||
import org.mifosng.platform.loanproduct.service.LoanEnumerations;
|
||||
import org.mifosplatform.infrastructure.configuration.data.CurrencyData;
|
||||
import org.mifosplatform.portfolio.charge.data.ChargeData;
|
||||
import org.mifosplatform.portfolio.fund.data.FundData;
|
||||
|
||||
/**
|
||||
* Immutable data object to represent loan products.
|
||||
|
||||
-56
@@ -1,56 +0,0 @@
|
||||
package org.mifosng.platform.api.data;
|
||||
|
||||
import org.joda.time.LocalDate;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* Immutable data object returned for loan-officer reassignment screens.
|
||||
*/
|
||||
public class LoanReassignmentData {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private final Long officeId;
|
||||
@SuppressWarnings("unused")
|
||||
private final Long fromLoanOfficerId;
|
||||
@SuppressWarnings("unused")
|
||||
private final LocalDate assignmentDate;
|
||||
|
||||
//template
|
||||
@SuppressWarnings("unused")
|
||||
private final Collection<OfficeLookup> officeOptions;
|
||||
@SuppressWarnings("unused")
|
||||
private final Collection<StaffData> loanOfficerOptions;
|
||||
@SuppressWarnings("unused")
|
||||
private final StaffAccountSummaryCollectionData accountSummaryCollection;
|
||||
|
||||
public static LoanReassignmentData templateForBulk(final Long officeId,
|
||||
final Long fromLoanOfficerId,
|
||||
final LocalDate assignmentDate,
|
||||
final Collection<OfficeLookup> officeOptions,
|
||||
final Collection<StaffData> loanOfficerOptions,
|
||||
final StaffAccountSummaryCollectionData accountSummaryCollection) {
|
||||
return new LoanReassignmentData(officeId, fromLoanOfficerId, assignmentDate, officeOptions, loanOfficerOptions, accountSummaryCollection);
|
||||
}
|
||||
|
||||
public static LoanReassignmentData template(final Long fromLoanOfficerId,
|
||||
final Collection<StaffData> loanOfficerOptions,
|
||||
final LocalDate assignmentDate){
|
||||
return new LoanReassignmentData(null, fromLoanOfficerId, assignmentDate, null, loanOfficerOptions, null);
|
||||
}
|
||||
|
||||
private LoanReassignmentData(
|
||||
final Long officeId,
|
||||
final Long fromLoanOfficerId,
|
||||
final LocalDate assignmentDate,
|
||||
final Collection<OfficeLookup> officeOptions,
|
||||
final Collection<StaffData> loanOfficerOptions,
|
||||
final StaffAccountSummaryCollectionData accountSummaryCollection) {
|
||||
this.officeId = officeId;
|
||||
this.fromLoanOfficerId = fromLoanOfficerId;
|
||||
this.assignmentDate = assignmentDate;
|
||||
this.officeOptions = officeOptions;
|
||||
this.loanOfficerOptions = loanOfficerOptions;
|
||||
this.accountSummaryCollection = accountSummaryCollection;
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,8 @@ package org.mifosng.platform.api.data;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Collection;
|
||||
|
||||
import org.mifosplatform.infrastructure.configuration.data.CurrencyData;
|
||||
|
||||
|
||||
/**
|
||||
* Immutable data object to represent aspects of a loan schedule such as:
|
||||
|
||||
@@ -3,6 +3,7 @@ package org.mifosng.platform.api.data;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import org.joda.time.LocalDate;
|
||||
import org.mifosplatform.infrastructure.configuration.data.CurrencyData;
|
||||
|
||||
/**
|
||||
* Immutable data object representing a loan transaction.
|
||||
|
||||
-104
@@ -1,104 +0,0 @@
|
||||
package org.mifosng.platform.api.data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
import org.joda.time.LocalDate;
|
||||
|
||||
/**
|
||||
* Immutable data object for office transactions.
|
||||
*/
|
||||
public class OfficeTransactionData {
|
||||
|
||||
private final Long id;
|
||||
private final LocalDate transactionDate;
|
||||
private final Long fromOfficeId;
|
||||
private final String fromOfficeName;
|
||||
private final Long toOfficeId;
|
||||
private final String toOfficeName;
|
||||
private CurrencyData currency;
|
||||
private final BigDecimal transactionAmount;
|
||||
private final String description;
|
||||
private final List<CurrencyData> currencyOptions;
|
||||
private final List<OfficeLookup> allowedOffices;
|
||||
|
||||
public OfficeTransactionData(final LocalDate transactionDate,
|
||||
final List<OfficeLookup> allowedOffices,
|
||||
final List<CurrencyData> currencyOptions) {
|
||||
this.transactionDate = transactionDate;
|
||||
this.allowedOffices = allowedOffices;
|
||||
this.currencyOptions = currencyOptions;
|
||||
this.id = null;
|
||||
this.fromOfficeId = null;
|
||||
this.fromOfficeName = null;
|
||||
this.toOfficeId = null;
|
||||
this.toOfficeName = null;
|
||||
this.currency = null;
|
||||
this.transactionAmount = null;
|
||||
this.description = null;
|
||||
}
|
||||
|
||||
public OfficeTransactionData(final Long id,
|
||||
final LocalDate transactionDate, final Long fromOfficeId,
|
||||
final String fromOfficeName, final Long toOfficeId,
|
||||
final String toOfficeName, final CurrencyData currency,
|
||||
final BigDecimal transactionAmount, final String description) {
|
||||
this.id = id;
|
||||
this.fromOfficeId = fromOfficeId;
|
||||
this.fromOfficeName = fromOfficeName;
|
||||
this.toOfficeId = toOfficeId;
|
||||
this.toOfficeName = toOfficeName;
|
||||
this.currency = currency;
|
||||
this.transactionAmount = transactionAmount;
|
||||
this.description = description;
|
||||
this.transactionDate = transactionDate;
|
||||
this.currencyOptions = null;
|
||||
this.allowedOffices = null;
|
||||
|
||||
}
|
||||
|
||||
public LocalDate getTransactionDate() {
|
||||
return transactionDate;
|
||||
}
|
||||
|
||||
public List<CurrencyData> getCurrencyOptions() {
|
||||
return currencyOptions;
|
||||
}
|
||||
|
||||
public List<OfficeLookup> getAllowedOffices() {
|
||||
return allowedOffices;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public Long getFromOfficeId() {
|
||||
return fromOfficeId;
|
||||
}
|
||||
|
||||
public String getFromOfficeName() {
|
||||
return fromOfficeName;
|
||||
}
|
||||
|
||||
public Long getToOfficeId() {
|
||||
return toOfficeId;
|
||||
}
|
||||
|
||||
public String getToOfficeName() {
|
||||
return toOfficeName;
|
||||
}
|
||||
|
||||
public CurrencyData getCurrency() {
|
||||
return currency;
|
||||
}
|
||||
|
||||
public BigDecimal getTransactionAmount() {
|
||||
return transactionAmount;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
}
|
||||
-131
@@ -1,131 +0,0 @@
|
||||
package org.mifosng.platform.api.data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.mifosng.platform.exceptions.PlatformDataIntegrityException;
|
||||
|
||||
public class ResultsetColumnHeader {
|
||||
|
||||
private String columnName;
|
||||
private String columnType;
|
||||
private Long columnLength;
|
||||
private String columnDisplayType;
|
||||
private boolean isColumnNullable;
|
||||
private boolean isColumnPrimaryKey;
|
||||
private List<ResultsetColumnValue> columnValues = new ArrayList<ResultsetColumnValue>();
|
||||
|
||||
public ResultsetColumnHeader() {
|
||||
|
||||
}
|
||||
|
||||
public String getColumnName() {
|
||||
return columnName;
|
||||
}
|
||||
|
||||
public void setColumnName(String columnName) {
|
||||
this.columnName = columnName;
|
||||
}
|
||||
|
||||
public String getColumnType() {
|
||||
return columnType;
|
||||
}
|
||||
|
||||
public void setColumnType(String columnType) {
|
||||
this.columnType = columnType;
|
||||
}
|
||||
|
||||
public Long getColumnLength() {
|
||||
return columnLength;
|
||||
}
|
||||
|
||||
public void setColumnLength(Long columnLength) {
|
||||
this.columnLength = columnLength;
|
||||
}
|
||||
|
||||
public List<ResultsetColumnValue> getColumnValues() {
|
||||
return columnValues;
|
||||
}
|
||||
|
||||
public void setColumnValues(List<ResultsetColumnValue> columnValues) {
|
||||
this.columnValues = columnValues;
|
||||
}
|
||||
|
||||
public boolean isColumnNullable() {
|
||||
return isColumnNullable;
|
||||
}
|
||||
|
||||
public void setColumnNullable(boolean isColumnNullable) {
|
||||
this.isColumnNullable = isColumnNullable;
|
||||
}
|
||||
|
||||
public boolean isColumnPrimaryKey() {
|
||||
return isColumnPrimaryKey;
|
||||
}
|
||||
|
||||
public void setColumnPrimaryKey(boolean isColumnPrimaryKey) {
|
||||
this.isColumnPrimaryKey = isColumnPrimaryKey;
|
||||
}
|
||||
|
||||
public String getColumnDisplayType() {
|
||||
return columnDisplayType;
|
||||
}
|
||||
|
||||
public void setColumnDisplayType() {
|
||||
|
||||
if (this.getColumnValues().size() > 0) {
|
||||
|
||||
if (this.getColumnType().equalsIgnoreCase("int")) {
|
||||
this.columnDisplayType = "CODELOOKUP";
|
||||
return;
|
||||
}
|
||||
if (this.getColumnType().equalsIgnoreCase("varchar")) {
|
||||
this.columnDisplayType = "CODEVALUE";
|
||||
return;
|
||||
}
|
||||
|
||||
throw new PlatformDataIntegrityException(
|
||||
"error.msg.invalid.lookup.type", "Invalid Lookup Type:"
|
||||
+ this.getColumnType() + " - Column Name: "
|
||||
+ this.getColumnName());
|
||||
}
|
||||
|
||||
if (this.getColumnType().equalsIgnoreCase("varchar") || this.getColumnType().equalsIgnoreCase("char")) {
|
||||
this.columnDisplayType = "STRING";
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.getColumnType().equalsIgnoreCase("int")
|
||||
|| this.getColumnType().equalsIgnoreCase("bigint")
|
||||
|| this.getColumnType().equalsIgnoreCase("smallint")
|
||||
|| this.getColumnType().equalsIgnoreCase("mediumint")
|
||||
|| this.getColumnType().equalsIgnoreCase("tinyint")) {
|
||||
this.columnDisplayType = "INTEGER";
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.getColumnType().equalsIgnoreCase("date")) {
|
||||
this.columnDisplayType = "DATE";
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.getColumnType().equalsIgnoreCase("decimal")) {
|
||||
this.columnDisplayType = "DECIMAL";
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.getColumnType().equalsIgnoreCase("text")
|
||||
|| this.getColumnType().equalsIgnoreCase("mediumtext")
|
||||
|| this.getColumnType().equalsIgnoreCase("longtext")
|
||||
|| this.getColumnType().equalsIgnoreCase("tinytext")) {
|
||||
this.columnDisplayType = "TEXT";
|
||||
return;
|
||||
}
|
||||
|
||||
throw new PlatformDataIntegrityException(
|
||||
"error.msg.unsupported.column.type", "Unsupported Column Type:"
|
||||
+ this.getColumnType() + " - Column Name: "
|
||||
+ this.getColumnName());
|
||||
}
|
||||
|
||||
}
|
||||
-29
@@ -1,29 +0,0 @@
|
||||
package org.mifosng.platform.api.data;
|
||||
|
||||
public class ResultsetColumnValue {
|
||||
|
||||
private int id;
|
||||
private String value;
|
||||
|
||||
public ResultsetColumnValue(int id, String value) {
|
||||
this.id = id;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package org.mifosng.platform.api.data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ResultsetDataRow {
|
||||
|
||||
private List<String> row = new ArrayList<String>();
|
||||
|
||||
public ResultsetDataRow() {
|
||||
|
||||
}
|
||||
|
||||
public List<String> getRow() {
|
||||
return row;
|
||||
}
|
||||
|
||||
public void setRow(List<String> row) {
|
||||
this.row = row;
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package org.mifosng.platform.api.data;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import org.joda.time.LocalDate;
|
||||
import org.mifosplatform.infrastructure.configuration.data.CurrencyData;
|
||||
|
||||
/**
|
||||
* Immutable data object reprsenting a savings account.
|
||||
|
||||
@@ -6,6 +6,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.joda.time.DateTime;
|
||||
import org.mifosplatform.infrastructure.configuration.data.CurrencyData;
|
||||
|
||||
public class SavingProductData implements Serializable {
|
||||
|
||||
|
||||
@@ -1,84 +0,0 @@
|
||||
package org.mifosng.platform.api.data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class StaffData implements Serializable {
|
||||
|
||||
private Long id;
|
||||
private String firstname;
|
||||
private String lastname;
|
||||
private String displayName;
|
||||
private final Long officeId;
|
||||
private final String officeName;
|
||||
private final Boolean loanOfficerFlag;
|
||||
|
||||
private List<OfficeLookup> allowedOffices = new ArrayList<OfficeLookup>();
|
||||
|
||||
public StaffData(final Long id, final String firstname,
|
||||
final String lastname, final String displayName,
|
||||
final Long officeId, final String officeName,
|
||||
final Boolean loanOfficerFlag) {
|
||||
this.id = id;
|
||||
this.firstname = firstname;
|
||||
this.lastname = lastname;
|
||||
this.displayName = displayName;
|
||||
this.officeName = officeName;
|
||||
this.loanOfficerFlag = loanOfficerFlag;
|
||||
this.officeId = officeId;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getFirstname() {
|
||||
return firstname;
|
||||
}
|
||||
|
||||
public void setFirstname(String firstname) {
|
||||
this.firstname = firstname;
|
||||
}
|
||||
|
||||
public String getLastname() {
|
||||
return lastname;
|
||||
}
|
||||
|
||||
public void setLastname(String lastname) {
|
||||
this.lastname = lastname;
|
||||
}
|
||||
|
||||
public String getDisplayName() {
|
||||
return displayName;
|
||||
}
|
||||
|
||||
public void setDisplayName(String displayName) {
|
||||
this.displayName = displayName;
|
||||
}
|
||||
|
||||
public Long getOfficeId() {
|
||||
return officeId;
|
||||
}
|
||||
|
||||
public String getOfficeName() {
|
||||
return officeName;
|
||||
}
|
||||
|
||||
public Boolean getLoanOfficerFlag() {
|
||||
return loanOfficerFlag;
|
||||
}
|
||||
|
||||
public List<OfficeLookup> getAllowedOffices() {
|
||||
return allowedOffices;
|
||||
}
|
||||
|
||||
public void setAllowedOffices(List<OfficeLookup> allowedOffices) {
|
||||
this.allowedOffices = allowedOffices;
|
||||
}
|
||||
|
||||
}
|
||||
+18
-19
@@ -1,27 +1,26 @@
|
||||
package org.mifosng.platform.api.data;
|
||||
|
||||
|
||||
public final class TransactionProcessingStrategyData {
|
||||
|
||||
private final Long id;
|
||||
private final String code;
|
||||
private final String name;
|
||||
private final Long id;
|
||||
private final String code;
|
||||
private final String name;
|
||||
|
||||
public TransactionProcessingStrategyData(final Long id, final String code, final String name) {
|
||||
this.id = id;
|
||||
this.code = code;
|
||||
this.name = name;
|
||||
}
|
||||
public TransactionProcessingStrategyData(final Long id, final String code, final String name) {
|
||||
this.id = id;
|
||||
this.code = code;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
+11
-11
@@ -6,41 +6,41 @@ import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.mifosng.platform.api.commands.ClientCommand;
|
||||
import org.mifosng.platform.api.data.ChargeData;
|
||||
import org.mifosng.platform.api.data.ClientAccountSummaryCollectionData;
|
||||
import org.mifosng.platform.api.data.ClientData;
|
||||
import org.mifosng.platform.api.data.ClientIdentifierData;
|
||||
import org.mifosng.platform.api.data.CodeData;
|
||||
import org.mifosng.platform.api.data.ConfigurationData;
|
||||
import org.mifosng.platform.api.data.DatatableData;
|
||||
import org.mifosng.platform.api.data.DepositAccountData;
|
||||
import org.mifosng.platform.api.data.DepositProductData;
|
||||
import org.mifosng.platform.api.data.DocumentData;
|
||||
import org.mifosng.platform.api.data.EntityIdentifier;
|
||||
import org.mifosng.platform.api.data.FundData;
|
||||
import org.mifosng.platform.api.data.GenericResultsetData;
|
||||
import org.mifosng.platform.api.data.GroupAccountSummaryCollectionData;
|
||||
import org.mifosng.platform.api.data.GroupData;
|
||||
import org.mifosng.platform.api.data.GuarantorData;
|
||||
import org.mifosng.platform.api.data.LoanAccountData;
|
||||
import org.mifosng.platform.api.data.LoanChargeData;
|
||||
import org.mifosng.platform.api.data.LoanProductData;
|
||||
import org.mifosng.platform.api.data.LoanReassignmentData;
|
||||
import org.mifosng.platform.api.data.LoanScheduleData;
|
||||
import org.mifosng.platform.api.data.LoanTransactionData;
|
||||
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.SavingAccountData;
|
||||
import org.mifosng.platform.api.data.SavingProductData;
|
||||
import org.mifosng.platform.api.data.StaffData;
|
||||
import org.mifosng.platform.infrastructure.api.GoogleGsonSerializerHelper;
|
||||
import org.mifosplatform.commands.api.data.CommandSourceData;
|
||||
import org.mifosplatform.infrastructure.codes.data.CodeData;
|
||||
import org.mifosplatform.infrastructure.configuration.data.ConfigurationData;
|
||||
import org.mifosplatform.infrastructure.dataqueries.data.DatatableData;
|
||||
import org.mifosplatform.infrastructure.dataqueries.data.GenericResultsetData;
|
||||
import org.mifosplatform.infrastructure.office.data.OfficeData;
|
||||
import org.mifosplatform.infrastructure.office.data.OfficeTransactionData;
|
||||
import org.mifosplatform.infrastructure.staff.data.BulkTransferLoanOfficerData;
|
||||
import org.mifosplatform.infrastructure.staff.data.StaffData;
|
||||
import org.mifosplatform.infrastructure.user.api.data.AppUserData;
|
||||
import org.mifosplatform.infrastructure.user.api.data.AuthenticatedUserData;
|
||||
import org.mifosplatform.infrastructure.user.api.data.PermissionUsageData;
|
||||
import org.mifosplatform.infrastructure.user.api.data.RoleData;
|
||||
import org.mifosplatform.infrastructure.user.api.data.RolePermissionsData;
|
||||
import org.mifosplatform.portfolio.charge.data.ChargeData;
|
||||
import org.mifosplatform.portfolio.fund.data.FundData;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -456,7 +456,7 @@ public class GoogleGsonPortfolioApiJsonSerializerService implements PortfolioApi
|
||||
|
||||
@Override
|
||||
public String serializeLoanReassignmentDataToJson(boolean prettyPrint, Set<String> responseParameters,
|
||||
LoanReassignmentData loanReassignmentData) {
|
||||
BulkTransferLoanOfficerData loanReassignmentData) {
|
||||
final Gson gsonDeserializer = helper.createGsonBuilderWithParameterExclusionSerializationStrategy(
|
||||
LOAN_REASSIGNMENT_DATA_PARAMETERS, prettyPrint, responseParameters);
|
||||
return helper.serializedJsonFrom(gsonDeserializer, loanReassignmentData);
|
||||
|
||||
+16
-16
@@ -1,19 +1,14 @@
|
||||
package org.mifosng.platform.api.infrastructure;
|
||||
|
||||
import org.mifosng.platform.api.commands.AdjustLoanTransactionCommand;
|
||||
import org.mifosng.platform.api.commands.BranchMoneyTransferCommand;
|
||||
import org.mifosng.platform.api.commands.LoanReassignmentCommand;
|
||||
import org.mifosng.platform.api.commands.ChargeCommand;
|
||||
import org.mifosng.platform.api.commands.ClientCommand;
|
||||
import org.mifosng.platform.api.commands.ClientIdentifierCommand;
|
||||
import org.mifosng.platform.api.commands.CodeCommand;
|
||||
import org.mifosng.platform.api.commands.DepositAccountCommand;
|
||||
import org.mifosng.platform.api.commands.DepositAccountWithdrawInterestCommand;
|
||||
import org.mifosng.platform.api.commands.DepositAccountWithdrawalCommand;
|
||||
import org.mifosng.platform.api.commands.DepositProductCommand;
|
||||
import org.mifosng.platform.api.commands.DepositStateTransitionApprovalCommand;
|
||||
import org.mifosng.platform.api.commands.DepositStateTransitionCommand;
|
||||
import org.mifosng.platform.api.commands.FundCommand;
|
||||
import org.mifosng.platform.api.commands.GroupCommand;
|
||||
import org.mifosng.platform.api.commands.GuarantorCommand;
|
||||
import org.mifosng.platform.api.commands.LoanApplicationCommand;
|
||||
@@ -22,24 +17,29 @@ import org.mifosng.platform.api.commands.LoanProductCommand;
|
||||
import org.mifosng.platform.api.commands.LoanStateTransitionCommand;
|
||||
import org.mifosng.platform.api.commands.LoanTransactionCommand;
|
||||
import org.mifosng.platform.api.commands.NoteCommand;
|
||||
import org.mifosng.platform.api.commands.OfficeCommand;
|
||||
import org.mifosng.platform.api.commands.OrganisationCurrencyCommand;
|
||||
import org.mifosng.platform.api.commands.SavingAccountCommand;
|
||||
import org.mifosng.platform.api.commands.SavingProductCommand;
|
||||
import org.mifosng.platform.api.commands.StaffCommand;
|
||||
import org.mifosng.platform.api.data.ClientData;
|
||||
import org.mifosplatform.infrastructure.codes.command.CodeCommand;
|
||||
import org.mifosplatform.infrastructure.configuration.command.CurrencyCommand;
|
||||
import org.mifosplatform.infrastructure.office.command.BranchMoneyTransferCommand;
|
||||
import org.mifosplatform.infrastructure.office.command.OfficeCommand;
|
||||
import org.mifosplatform.infrastructure.staff.command.BulkTransferLoanOfficerCommand;
|
||||
import org.mifosplatform.infrastructure.staff.command.StaffCommand;
|
||||
import org.mifosplatform.infrastructure.user.command.PermissionsCommand;
|
||||
import org.mifosplatform.infrastructure.user.command.RoleCommand;
|
||||
import org.mifosplatform.infrastructure.user.command.RolePermissionCommand;
|
||||
import org.mifosplatform.infrastructure.user.command.UserCommand;
|
||||
import org.mifosplatform.portfolio.charge.command.ChargeCommand;
|
||||
import org.mifosplatform.portfolio.fund.command.FundCommand;
|
||||
|
||||
public interface PortfolioApiDataConversionService {
|
||||
|
||||
ChargeCommand convertJsonToChargeCommand(Long resourceIdentifier, String json);
|
||||
|
||||
FundCommand convertJsonToFundCommand(Long resourceIdentifier, String json);
|
||||
FundCommand convertApiRequestJsonToFundCommand(Long resourceIdentifier, String json);
|
||||
|
||||
OfficeCommand convertJsonToOfficeCommand(Long resourceIdentifier, String json);
|
||||
OfficeCommand convertApiRequestJsonToOfficeCommand(Long resourceIdentifier, String json);
|
||||
|
||||
RoleCommand convertApiRequestJsonToRoleCommand(Long resourceIdentifier, String json);
|
||||
|
||||
@@ -49,7 +49,7 @@ public interface PortfolioApiDataConversionService {
|
||||
|
||||
UserCommand convertApiRequestJsonToUserCommand(Long resourceIdentifier, String json);
|
||||
|
||||
BranchMoneyTransferCommand convertJsonToBranchMoneyTransferCommand(String json);
|
||||
BranchMoneyTransferCommand convertApiRequestJsonToBranchMoneyTransferCommand(String json);
|
||||
|
||||
LoanProductCommand convertJsonToLoanProductCommand(Long resourceIdentifier, String json);
|
||||
|
||||
@@ -77,7 +77,7 @@ public interface PortfolioApiDataConversionService {
|
||||
|
||||
AdjustLoanTransactionCommand convertJsonToAdjustLoanTransactionCommand(Long loanId, Long transactionId, String json);
|
||||
|
||||
OrganisationCurrencyCommand convertJsonToOrganisationCurrencyCommand(String json);
|
||||
CurrencyCommand convertApiRequestJsonToCurrencyCommand(String json);
|
||||
|
||||
NoteCommand convertJsonToNoteCommand(Long resourceIdentifier, Long clientId, String json);
|
||||
|
||||
@@ -87,11 +87,11 @@ public interface PortfolioApiDataConversionService {
|
||||
|
||||
DepositStateTransitionApprovalCommand convertJsonToDepositStateTransitionApprovalCommand(Long resourceIdentifier, String json);
|
||||
|
||||
StaffCommand convertJsonToStaffCommand(Long resourceIdentifier, String json);
|
||||
StaffCommand convertApiRequestJsonToStaffCommand(Long resourceIdentifier, String json);
|
||||
|
||||
LoanReassignmentCommand convertJsonToLoanReassignmentCommand(Long resourceIdentifier, String json);
|
||||
BulkTransferLoanOfficerCommand convertJsonToLoanReassignmentCommand(Long resourceIdentifier, String json);
|
||||
|
||||
LoanReassignmentCommand convertJsonToBulkLoanReassignmentCommand(String json);
|
||||
BulkTransferLoanOfficerCommand convertJsonToBulkLoanReassignmentCommand(String json);
|
||||
|
||||
DepositAccountWithdrawalCommand convertJsonToDepositWithdrawalCommand(Long resourceIdentifier, String json);
|
||||
|
||||
@@ -99,7 +99,7 @@ public interface PortfolioApiDataConversionService {
|
||||
|
||||
ClientIdentifierCommand convertJsonToClientIdentifierCommand(Long resourceIdentifier, Long clientId, String json);
|
||||
|
||||
CodeCommand convertJsonToCodeCommand(Long resourceIdentifier, String json);
|
||||
CodeCommand convertApiRequestJsonToCodeCommand(Long resourceIdentifier, String json);
|
||||
|
||||
SavingAccountCommand convertJsonToSavingAccountCommand(Long resourceIdentifier, String json);
|
||||
|
||||
|
||||
+57
-82
@@ -18,42 +18,42 @@ import org.apache.commons.lang.StringUtils;
|
||||
import org.joda.time.LocalDate;
|
||||
import org.joda.time.format.DateTimeFormat;
|
||||
import org.mifosng.platform.api.commands.AdjustLoanTransactionCommand;
|
||||
import org.mifosng.platform.api.commands.BranchMoneyTransferCommand;
|
||||
import org.mifosng.platform.api.commands.ChargeCommand;
|
||||
import org.mifosng.platform.api.commands.ClientCommand;
|
||||
import org.mifosng.platform.api.commands.ClientIdentifierCommand;
|
||||
import org.mifosng.platform.api.commands.CodeCommand;
|
||||
import org.mifosng.platform.api.commands.DepositAccountCommand;
|
||||
import org.mifosng.platform.api.commands.DepositAccountWithdrawInterestCommand;
|
||||
import org.mifosng.platform.api.commands.DepositAccountWithdrawalCommand;
|
||||
import org.mifosng.platform.api.commands.DepositProductCommand;
|
||||
import org.mifosng.platform.api.commands.DepositStateTransitionApprovalCommand;
|
||||
import org.mifosng.platform.api.commands.DepositStateTransitionCommand;
|
||||
import org.mifosng.platform.api.commands.FundCommand;
|
||||
import org.mifosng.platform.api.commands.GroupCommand;
|
||||
import org.mifosng.platform.api.commands.GuarantorCommand;
|
||||
import org.mifosng.platform.api.commands.LoanApplicationCommand;
|
||||
import org.mifosng.platform.api.commands.LoanChargeCommand;
|
||||
import org.mifosng.platform.api.commands.LoanProductCommand;
|
||||
import org.mifosng.platform.api.commands.LoanReassignmentCommand;
|
||||
import org.mifosng.platform.api.commands.LoanStateTransitionCommand;
|
||||
import org.mifosng.platform.api.commands.LoanTransactionCommand;
|
||||
import org.mifosng.platform.api.commands.NoteCommand;
|
||||
import org.mifosng.platform.api.commands.OfficeCommand;
|
||||
import org.mifosng.platform.api.commands.OrganisationCurrencyCommand;
|
||||
import org.mifosng.platform.api.commands.SavingAccountCommand;
|
||||
import org.mifosng.platform.api.commands.SavingProductCommand;
|
||||
import org.mifosng.platform.api.commands.StaffCommand;
|
||||
import org.mifosng.platform.api.data.ApiParameterError;
|
||||
import org.mifosng.platform.api.data.ClientData;
|
||||
import org.mifosng.platform.exceptions.PlatformApiDataValidationException;
|
||||
import org.mifosng.platform.infrastructure.api.JsonParserHelper;
|
||||
import org.mifosng.platform.infrastructure.errorhandling.InvalidJsonException;
|
||||
import org.mifosng.platform.infrastructure.errorhandling.UnsupportedParameterException;
|
||||
import org.mifosplatform.infrastructure.codes.command.CodeCommand;
|
||||
import org.mifosplatform.infrastructure.configuration.command.CurrencyCommand;
|
||||
import org.mifosplatform.infrastructure.office.command.BranchMoneyTransferCommand;
|
||||
import org.mifosplatform.infrastructure.office.command.OfficeCommand;
|
||||
import org.mifosplatform.infrastructure.staff.command.BulkTransferLoanOfficerCommand;
|
||||
import org.mifosplatform.infrastructure.staff.command.StaffCommand;
|
||||
import org.mifosplatform.infrastructure.user.command.PermissionsCommand;
|
||||
import org.mifosplatform.infrastructure.user.command.RoleCommand;
|
||||
import org.mifosplatform.infrastructure.user.command.RolePermissionCommand;
|
||||
import org.mifosplatform.infrastructure.user.command.UserCommand;
|
||||
import org.mifosplatform.portfolio.charge.command.ChargeCommand;
|
||||
import org.mifosplatform.portfolio.fund.command.FundCommand;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.format.number.NumberFormatter;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -73,16 +73,22 @@ public class PortfolioApiDataConversionServiceImpl implements PortfolioApiDataCo
|
||||
* different to that of the json of a serialized command object.
|
||||
*/
|
||||
private final PortfolioCommandDeserializerService portfolioCommandDeserializerService;
|
||||
|
||||
|
||||
/**
|
||||
* Google-gson class for converting to and from json.
|
||||
*/
|
||||
private final Gson gsonConverter;
|
||||
|
||||
/**
|
||||
* Google-gson class for parsing json.
|
||||
*/
|
||||
// private final JsonParser parser;
|
||||
|
||||
@Autowired
|
||||
public PortfolioApiDataConversionServiceImpl(final PortfolioCommandDeserializerService portfolioCommandDeserializerService) {
|
||||
this.portfolioCommandDeserializerService = portfolioCommandDeserializerService;
|
||||
gsonConverter = new Gson();
|
||||
this.gsonConverter = new Gson();
|
||||
// this.parser = new JsonParser();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -116,49 +122,37 @@ public class PortfolioApiDataConversionServiceImpl implements PortfolioApiDataCo
|
||||
}
|
||||
|
||||
@Override
|
||||
public FundCommand convertJsonToFundCommand(final Long resourceIdentifier, final String json) {
|
||||
public FundCommand convertApiRequestJsonToFundCommand(final Long resourceIdentifier, final String json) {
|
||||
|
||||
if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
|
||||
|
||||
Type typeOfMap = new TypeToken<Map<String, String>>() {}.getType();
|
||||
Map<String, String> requestMap = gsonConverter.fromJson(json, typeOfMap);
|
||||
final Type typeOfMap = new TypeToken<Map<String, String>>() {}.getType();
|
||||
final Map<String, String> requestMap = gsonConverter.fromJson(json, typeOfMap);
|
||||
|
||||
Set<String> supportedParams = new HashSet<String>(Arrays.asList("name", "externalId"));
|
||||
final Set<String> supportedParams = new HashSet<String>(Arrays.asList("name", "externalId"));
|
||||
|
||||
checkForUnsupportedParameters(requestMap, supportedParams);
|
||||
|
||||
Set<String> modifiedParameters = new HashSet<String>();
|
||||
|
||||
String name = extractStringParameter("name", requestMap, modifiedParameters);
|
||||
String externalId = extractStringParameter("externalId", requestMap, modifiedParameters);
|
||||
|
||||
return new FundCommand(modifiedParameters, resourceIdentifier, name, externalId);
|
||||
return this.portfolioCommandDeserializerService.deserializeFundCommand(resourceIdentifier, json, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public StaffCommand convertJsonToStaffCommand(Long resourceIdentifier, String json) {
|
||||
public StaffCommand convertApiRequestJsonToStaffCommand(final Long resourceIdentifier, final String json) {
|
||||
|
||||
if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
|
||||
|
||||
Type typeOfMap = new TypeToken<Map<String, String>>() {}.getType();
|
||||
Map<String, String> requestMap = gsonConverter.fromJson(json, typeOfMap);
|
||||
final Type typeOfMap = new TypeToken<Map<String, String>>() {}.getType();
|
||||
final Map<String, String> requestMap = gsonConverter.fromJson(json, typeOfMap);
|
||||
|
||||
Set<String> supportedParams = new HashSet<String>(Arrays.asList("firstname", "lastname", "officeId", "loanOfficerFlag"));
|
||||
final Set<String> supportedParams = new HashSet<String>(Arrays.asList("firstname", "lastname", "officeId", "isLoanOfficer"));
|
||||
|
||||
checkForUnsupportedParameters(requestMap, supportedParams);
|
||||
|
||||
Set<String> modifiedParameters = new HashSet<String>();
|
||||
|
||||
String firstname = extractStringParameter("firstname", requestMap, modifiedParameters);
|
||||
String lastname = extractStringParameter("lastname", requestMap, modifiedParameters);
|
||||
Boolean isLoanOfficer = extractBooleanParameter("loanOfficerFlag", requestMap, modifiedParameters);
|
||||
Long officeId = extractLongParameter("officeId", requestMap, modifiedParameters);
|
||||
|
||||
return new StaffCommand(modifiedParameters, resourceIdentifier, officeId, firstname, lastname, isLoanOfficer);
|
||||
return this.portfolioCommandDeserializerService.deserializeStaffCommand(resourceIdentifier, json, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LoanReassignmentCommand convertJsonToLoanReassignmentCommand(Long resourceIdentifier, String json) {
|
||||
public BulkTransferLoanOfficerCommand convertJsonToLoanReassignmentCommand(Long resourceIdentifier, String json) {
|
||||
|
||||
if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
|
||||
|
||||
@@ -176,11 +170,11 @@ public class PortfolioApiDataConversionServiceImpl implements PortfolioApiDataCo
|
||||
Long toLoanOfficerId = extractLongParameter("toLoanOfficerId", requestMap, modifiedParameters);
|
||||
LocalDate assignmentDate = extractLocalDateParameter("assignmentDate", requestMap, modifiedParameters);
|
||||
|
||||
return new LoanReassignmentCommand(resourceIdentifier, fromLoanOfficerId, toLoanOfficerId, assignmentDate);
|
||||
return new BulkTransferLoanOfficerCommand(resourceIdentifier, fromLoanOfficerId, toLoanOfficerId, assignmentDate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LoanReassignmentCommand convertJsonToBulkLoanReassignmentCommand(final String json) {
|
||||
public BulkTransferLoanOfficerCommand convertJsonToBulkLoanReassignmentCommand(final String json) {
|
||||
|
||||
if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
|
||||
|
||||
@@ -216,11 +210,11 @@ public class PortfolioApiDataConversionServiceImpl implements PortfolioApiDataCo
|
||||
}
|
||||
//
|
||||
|
||||
return new LoanReassignmentCommand(fromLoanOfficerId, toLoanOfficerId, assignmentDate, loans);
|
||||
return new BulkTransferLoanOfficerCommand(fromLoanOfficerId, toLoanOfficerId, assignmentDate, loans);
|
||||
}
|
||||
|
||||
@Override
|
||||
public OfficeCommand convertJsonToOfficeCommand(final Long resourceIdentifier, final String json) {
|
||||
public OfficeCommand convertApiRequestJsonToOfficeCommand(final Long resourceIdentifier, final String json) {
|
||||
if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
|
||||
|
||||
Type typeOfMap = new TypeToken<Map<String, String>>() {}.getType();
|
||||
@@ -231,14 +225,18 @@ public class PortfolioApiDataConversionServiceImpl implements PortfolioApiDataCo
|
||||
|
||||
checkForUnsupportedParameters(requestMap, supportedParams);
|
||||
|
||||
Set<String> modifiedParameters = new HashSet<String>();
|
||||
final Set<String> parametersPassedInRequest = new HashSet<String>();
|
||||
|
||||
String name = extractStringParameter("name", requestMap, modifiedParameters);
|
||||
String externalId = extractStringParameter("externalId", requestMap, modifiedParameters);
|
||||
Long parentId = extractLongParameter("parentId", requestMap, modifiedParameters);
|
||||
LocalDate openingLocalDate = extractLocalDateParameter("openingDate", requestMap, modifiedParameters);
|
||||
final JsonParser parser = new JsonParser();
|
||||
final JsonElement element = parser.parse(json);
|
||||
final JsonParserHelper helper = new JsonParserHelper();
|
||||
|
||||
return new OfficeCommand(modifiedParameters, resourceIdentifier, name, externalId, parentId, openingLocalDate);
|
||||
final String name = helper.extractStringNamed("name", element, parametersPassedInRequest);
|
||||
final String externalId = helper.extractStringNamed("externalId", element, parametersPassedInRequest);
|
||||
final Long parentId = helper.extractLongNamed("parentId", element, parametersPassedInRequest);
|
||||
final LocalDate openingLocalDate = helper.extractLocalDateNamed("openingDate", element, parametersPassedInRequest);
|
||||
|
||||
return new OfficeCommand(parametersPassedInRequest, false, resourceIdentifier, name, externalId, parentId, openingLocalDate);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -262,18 +260,18 @@ public class PortfolioApiDataConversionServiceImpl implements PortfolioApiDataCo
|
||||
public PermissionsCommand convertApiRequestJsonToPermissionsCommand(final String json) {
|
||||
|
||||
if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
|
||||
|
||||
|
||||
final Type typeOfMap = new TypeToken<Map<String, Boolean>>() {}.getType();
|
||||
final Map<String, Boolean> permissionsMap = gsonConverter.fromJson(json, typeOfMap);
|
||||
|
||||
return new PermissionsCommand(permissionsMap, false);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public RolePermissionCommand convertApiRequestJsonToRolePermissionCommand(final Long resourceIdentifier, final String json) {
|
||||
|
||||
if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
|
||||
|
||||
|
||||
final Type typeOfMap = new TypeToken<Map<String, Boolean>>() {}.getType();
|
||||
final Map<String, Boolean> permissionsMap = gsonConverter.fromJson(json, typeOfMap);
|
||||
|
||||
@@ -288,8 +286,8 @@ public class PortfolioApiDataConversionServiceImpl implements PortfolioApiDataCo
|
||||
final Type typeOfMap = new TypeToken<Map<String, Object>>() {}.getType();
|
||||
final Map<String, Object> requestMap = gsonConverter.fromJson(json, typeOfMap);
|
||||
|
||||
final Set<String> supportedParams = new HashSet<String>(Arrays.asList("username", "firstname", "lastname", "password", "repeatPassword",
|
||||
"email", "officeId", "notSelectedRoles", "roles"));
|
||||
final Set<String> supportedParams = new HashSet<String>(Arrays.asList("username", "firstname", "lastname", "password",
|
||||
"repeatPassword", "email", "officeId", "notSelectedRoles", "roles"));
|
||||
|
||||
checkForUnsupportedParameters(requestMap, supportedParams);
|
||||
|
||||
@@ -300,7 +298,7 @@ public class PortfolioApiDataConversionServiceImpl implements PortfolioApiDataCo
|
||||
}
|
||||
|
||||
@Override
|
||||
public BranchMoneyTransferCommand convertJsonToBranchMoneyTransferCommand(final String json) {
|
||||
public BranchMoneyTransferCommand convertApiRequestJsonToBranchMoneyTransferCommand(final String json) {
|
||||
|
||||
if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
|
||||
|
||||
@@ -321,7 +319,7 @@ public class PortfolioApiDataConversionServiceImpl implements PortfolioApiDataCo
|
||||
BigDecimal transactionAmountValue = extractBigDecimalParameter("transactionAmount", requestMap, modifiedParameters);
|
||||
String description = extractStringParameter("description", requestMap, modifiedParameters);
|
||||
|
||||
return new BranchMoneyTransferCommand(modifiedParameters, fromOfficeId, toOfficeId, transactionLocalDate, currencyCode,
|
||||
return new BranchMoneyTransferCommand(modifiedParameters, false, fromOfficeId, toOfficeId, transactionLocalDate, currencyCode,
|
||||
transactionAmountValue, description);
|
||||
}
|
||||
|
||||
@@ -424,7 +422,7 @@ public class PortfolioApiDataConversionServiceImpl implements PortfolioApiDataCo
|
||||
} else {
|
||||
differenceExists = workingCopyValue != null;
|
||||
}
|
||||
|
||||
|
||||
return differenceExists;
|
||||
}
|
||||
|
||||
@@ -436,7 +434,7 @@ public class PortfolioApiDataConversionServiceImpl implements PortfolioApiDataCo
|
||||
} else {
|
||||
differenceExists = StringUtils.isNotBlank(workingCopyValue);
|
||||
}
|
||||
|
||||
|
||||
return differenceExists;
|
||||
}
|
||||
|
||||
@@ -815,7 +813,7 @@ public class PortfolioApiDataConversionServiceImpl implements PortfolioApiDataCo
|
||||
}
|
||||
|
||||
@Override
|
||||
public OrganisationCurrencyCommand convertJsonToOrganisationCurrencyCommand(final String json) {
|
||||
public CurrencyCommand convertApiRequestJsonToCurrencyCommand(final String json) {
|
||||
if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
|
||||
|
||||
Type typeOfMap = new TypeToken<Map<String, Object>>() {}.getType();
|
||||
@@ -825,27 +823,7 @@ public class PortfolioApiDataConversionServiceImpl implements PortfolioApiDataCo
|
||||
|
||||
checkForUnsupportedParameters(requestMap, supportedParams);
|
||||
|
||||
Set<String> modifiedParameters = new HashSet<String>();
|
||||
|
||||
// check array
|
||||
JsonParser parser = new JsonParser();
|
||||
|
||||
String[] currencies = null;
|
||||
JsonElement element = parser.parse(json);
|
||||
if (element.isJsonObject()) {
|
||||
JsonObject object = element.getAsJsonObject();
|
||||
if (object.has("currencies")) {
|
||||
modifiedParameters.add("currencies");
|
||||
JsonArray array = object.get("currencies").getAsJsonArray();
|
||||
currencies = new String[array.size()];
|
||||
for (int i = 0; i < array.size(); i++) {
|
||||
currencies[i] = array.get(i).getAsString();
|
||||
}
|
||||
}
|
||||
}
|
||||
//
|
||||
|
||||
return new OrganisationCurrencyCommand(currencies);
|
||||
return this.portfolioCommandDeserializerService.deserializeCurrencyCommand(json, false);
|
||||
}
|
||||
|
||||
private void checkForUnsupportedParameters(Map<String, ?> requestMap, Set<String> supportedParams) {
|
||||
@@ -1562,7 +1540,7 @@ public class PortfolioApiDataConversionServiceImpl implements PortfolioApiDataCo
|
||||
}
|
||||
|
||||
@Override
|
||||
public CodeCommand convertJsonToCodeCommand(Long resourceIdentifier, String json) {
|
||||
public CodeCommand convertApiRequestJsonToCodeCommand(final Long resourceIdentifier, final String json) {
|
||||
if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
|
||||
|
||||
Type typeOfMap = new TypeToken<Map<String, String>>() {}.getType();
|
||||
@@ -1572,12 +1550,9 @@ public class PortfolioApiDataConversionServiceImpl implements PortfolioApiDataCo
|
||||
|
||||
checkForUnsupportedParameters(requestMap, supportedParams);
|
||||
|
||||
Set<String> modifiedParameters = new HashSet<String>();
|
||||
|
||||
String name = extractStringParameter("name", requestMap, modifiedParameters);
|
||||
|
||||
return new CodeCommand(modifiedParameters, resourceIdentifier, name);
|
||||
|
||||
// no difference between api request json format and internal command
|
||||
// json format.
|
||||
return this.portfolioCommandDeserializerService.deserializeCodeCommand(resourceIdentifier, json, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1656,7 +1631,7 @@ public class PortfolioApiDataConversionServiceImpl implements PortfolioApiDataCo
|
||||
String housePhoneNumber = extractStringParameter("housePhoneNumber", requestMap, modifiedParameters);
|
||||
String comment = extractStringParameter("comment", requestMap, modifiedParameters);
|
||||
String dob = extractStringParameter("dob", requestMap, modifiedParameters);
|
||||
|
||||
|
||||
// workaround for passing locale info to data table api
|
||||
final String dateFormat = requestMap.get("dateFormat");
|
||||
final String locale = requestMap.get("locale");
|
||||
|
||||
+11
-11
@@ -4,40 +4,40 @@ import java.util.Collection;
|
||||
import java.util.Set;
|
||||
|
||||
import org.mifosng.platform.api.commands.ClientCommand;
|
||||
import org.mifosng.platform.api.data.ChargeData;
|
||||
import org.mifosng.platform.api.data.ClientAccountSummaryCollectionData;
|
||||
import org.mifosng.platform.api.data.ClientData;
|
||||
import org.mifosng.platform.api.data.ClientIdentifierData;
|
||||
import org.mifosng.platform.api.data.CodeData;
|
||||
import org.mifosng.platform.api.data.ConfigurationData;
|
||||
import org.mifosng.platform.api.data.DatatableData;
|
||||
import org.mifosng.platform.api.data.DepositAccountData;
|
||||
import org.mifosng.platform.api.data.DepositProductData;
|
||||
import org.mifosng.platform.api.data.DocumentData;
|
||||
import org.mifosng.platform.api.data.EntityIdentifier;
|
||||
import org.mifosng.platform.api.data.FundData;
|
||||
import org.mifosng.platform.api.data.GenericResultsetData;
|
||||
import org.mifosng.platform.api.data.GroupAccountSummaryCollectionData;
|
||||
import org.mifosng.platform.api.data.GroupData;
|
||||
import org.mifosng.platform.api.data.GuarantorData;
|
||||
import org.mifosng.platform.api.data.LoanAccountData;
|
||||
import org.mifosng.platform.api.data.LoanChargeData;
|
||||
import org.mifosng.platform.api.data.LoanProductData;
|
||||
import org.mifosng.platform.api.data.LoanReassignmentData;
|
||||
import org.mifosng.platform.api.data.LoanScheduleData;
|
||||
import org.mifosng.platform.api.data.LoanTransactionData;
|
||||
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.SavingAccountData;
|
||||
import org.mifosng.platform.api.data.SavingProductData;
|
||||
import org.mifosng.platform.api.data.StaffData;
|
||||
import org.mifosplatform.commands.api.data.CommandSourceData;
|
||||
import org.mifosplatform.infrastructure.codes.data.CodeData;
|
||||
import org.mifosplatform.infrastructure.configuration.data.ConfigurationData;
|
||||
import org.mifosplatform.infrastructure.dataqueries.data.DatatableData;
|
||||
import org.mifosplatform.infrastructure.dataqueries.data.GenericResultsetData;
|
||||
import org.mifosplatform.infrastructure.office.data.OfficeData;
|
||||
import org.mifosplatform.infrastructure.office.data.OfficeTransactionData;
|
||||
import org.mifosplatform.infrastructure.staff.data.BulkTransferLoanOfficerData;
|
||||
import org.mifosplatform.infrastructure.staff.data.StaffData;
|
||||
import org.mifosplatform.infrastructure.user.api.data.AppUserData;
|
||||
import org.mifosplatform.infrastructure.user.api.data.AuthenticatedUserData;
|
||||
import org.mifosplatform.infrastructure.user.api.data.PermissionUsageData;
|
||||
import org.mifosplatform.infrastructure.user.api.data.RoleData;
|
||||
import org.mifosplatform.infrastructure.user.api.data.RolePermissionsData;
|
||||
import org.mifosplatform.portfolio.charge.data.ChargeData;
|
||||
import org.mifosplatform.portfolio.fund.data.FundData;
|
||||
|
||||
public interface PortfolioApiJsonSerializerService {
|
||||
|
||||
@@ -119,7 +119,7 @@ public interface PortfolioApiJsonSerializerService {
|
||||
String serializeLoanTransactionDataToJson(boolean prettyPrint, Set<String> responseParameters, LoanTransactionData newTransactionData);
|
||||
|
||||
String serializeLoanReassignmentDataToJson(boolean prettyPrint, Set<String> responseParameters,
|
||||
LoanReassignmentData loanReassignmentData);
|
||||
BulkTransferLoanOfficerData loanReassignmentData);
|
||||
|
||||
String serializeChargeDataToJson(boolean prettyPrint, Set<String> responseParameters, Collection<ChargeData> charges);
|
||||
|
||||
|
||||
+120
-1
@@ -1,14 +1,24 @@
|
||||
package org.mifosng.platform.api.infrastructure;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.HashSet;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.joda.time.LocalDate;
|
||||
import org.mifosng.platform.infrastructure.api.JsonParserHelper;
|
||||
import org.mifosng.platform.infrastructure.errorhandling.InvalidJsonException;
|
||||
import org.mifosplatform.infrastructure.codes.command.CodeCommand;
|
||||
import org.mifosplatform.infrastructure.configuration.command.CurrencyCommand;
|
||||
import org.mifosplatform.infrastructure.office.command.BranchMoneyTransferCommand;
|
||||
import org.mifosplatform.infrastructure.office.command.OfficeCommand;
|
||||
import org.mifosplatform.infrastructure.staff.command.StaffCommand;
|
||||
import org.mifosplatform.infrastructure.user.command.PermissionsCommand;
|
||||
import org.mifosplatform.infrastructure.user.command.RoleCommand;
|
||||
import org.mifosplatform.infrastructure.user.command.RolePermissionCommand;
|
||||
import org.mifosplatform.infrastructure.user.command.UserCommand;
|
||||
import org.mifosplatform.portfolio.fund.command.FundCommand;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
@@ -49,13 +59,21 @@ public class PortfolioCommandDeerializerServiceGoogleGson implements PortfolioCo
|
||||
|
||||
@Override
|
||||
public RolePermissionCommand deserializeRolePermissionCommand(final Long roleId, final String commandAsJson, final boolean makerCheckerApproval) {
|
||||
|
||||
if (StringUtils.isBlank(commandAsJson)) { throw new InvalidJsonException(); }
|
||||
|
||||
final RolePermissionCommand command = gsonConverter.fromJson(commandAsJson, RolePermissionCommand.class);
|
||||
|
||||
return new RolePermissionCommand(roleId, command.getPermissions(), makerCheckerApproval);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PermissionsCommand deserializePermissionsCommand(final String commandAsJson, final boolean makerCheckerApproval) {
|
||||
if (StringUtils.isBlank(commandAsJson)) { throw new InvalidJsonException(); }
|
||||
|
||||
final PermissionsCommand command = gsonConverter.fromJson(commandAsJson, PermissionsCommand.class);
|
||||
|
||||
return new PermissionsCommand(command.getPermissions(), makerCheckerApproval);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserCommand deserializeUserCommand(final Long userId, final String commandAsJson, final boolean makerCheckerApproval) {
|
||||
@@ -102,4 +120,105 @@ public class PortfolioCommandDeerializerServiceGoogleGson implements PortfolioCo
|
||||
return new UserCommand(parametersPassedInRequest, makerCheckerApproval, userId, username, firstname, lastname,
|
||||
password, repeatPassword, email, officeId, notSelectedRoles, roles);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CodeCommand deserializeCodeCommand(final Long codeId, final String commandAsJson, final boolean makerCheckerApproval) {
|
||||
if (StringUtils.isBlank(commandAsJson)) { throw new InvalidJsonException(); }
|
||||
|
||||
final JsonParserHelper helper = new JsonParserHelper();
|
||||
final JsonElement element = parser.parse(commandAsJson);
|
||||
|
||||
final Set<String> parametersPassedInRequest = new HashSet<String>();
|
||||
|
||||
final String name = helper.extractStringNamed("name", element, parametersPassedInRequest);
|
||||
|
||||
return new CodeCommand(parametersPassedInRequest, makerCheckerApproval, codeId, name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public StaffCommand deserializeStaffCommand(final Long staffId, final String commandAsJson, final boolean makerCheckerApproval) {
|
||||
|
||||
if (StringUtils.isBlank(commandAsJson)) { throw new InvalidJsonException(); }
|
||||
|
||||
final JsonParserHelper helper = new JsonParserHelper();
|
||||
final JsonElement element = parser.parse(commandAsJson);
|
||||
|
||||
final Set<String> parametersPassedInRequest = new HashSet<String>();
|
||||
|
||||
final String firstname = helper.extractStringNamed("firstname", element, parametersPassedInRequest);
|
||||
final String lastname = helper.extractStringNamed("lastname", element, parametersPassedInRequest);
|
||||
final Boolean isLoanOfficer = helper.extractBooleanNamed("isLoanOfficer", element, parametersPassedInRequest);
|
||||
final Long officeId = helper.extractLongNamed("officeId", element, parametersPassedInRequest);
|
||||
|
||||
return new StaffCommand(parametersPassedInRequest, makerCheckerApproval, staffId, officeId, firstname, lastname, isLoanOfficer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FundCommand deserializeFundCommand(final Long fundId, final String commandAsJson, final boolean makerCheckerApproval) {
|
||||
|
||||
if (StringUtils.isBlank(commandAsJson)) { throw new InvalidJsonException(); }
|
||||
|
||||
final JsonParserHelper helper = new JsonParserHelper();
|
||||
final JsonElement element = parser.parse(commandAsJson);
|
||||
|
||||
final Set<String> parametersPassedInRequest = new HashSet<String>();
|
||||
|
||||
final String name = helper.extractStringNamed("name", element, parametersPassedInRequest);
|
||||
final String externalId = helper.extractStringNamed("externalId", element, parametersPassedInRequest);
|
||||
|
||||
return new FundCommand(parametersPassedInRequest, makerCheckerApproval, fundId, name, externalId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public OfficeCommand deserializeOfficeCommand(final Long officeId, final String commandAsJson, final boolean makerCheckerApproval) {
|
||||
|
||||
if (StringUtils.isBlank(commandAsJson)) { throw new InvalidJsonException(); }
|
||||
|
||||
final JsonParserHelper helper = new JsonParserHelper();
|
||||
final JsonElement element = parser.parse(commandAsJson);
|
||||
|
||||
final Set<String> parametersPassedInRequest = new HashSet<String>();
|
||||
|
||||
final String name = helper.extractStringNamed("name", element, parametersPassedInRequest);
|
||||
final String externalId = helper.extractStringNamed("externalId", element, parametersPassedInRequest);
|
||||
final Long parentId = helper.extractLongNamed("parentId", element, parametersPassedInRequest);
|
||||
final LocalDate openingLocalDate = helper.extractLocalDateAsArrayNamed("openingDate", element, parametersPassedInRequest);
|
||||
|
||||
return new OfficeCommand(parametersPassedInRequest, makerCheckerApproval, officeId, name, externalId, parentId, openingLocalDate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BranchMoneyTransferCommand deserializeOfficeTransactionCommand(final String commandAsJson, final boolean makerCheckerApproval) {
|
||||
|
||||
if (StringUtils.isBlank(commandAsJson)) { throw new InvalidJsonException(); }
|
||||
|
||||
final JsonParserHelper helper = new JsonParserHelper();
|
||||
final JsonElement element = parser.parse(commandAsJson);
|
||||
|
||||
final Set<String> parametersPassedInRequest = new HashSet<String>();
|
||||
|
||||
final Long fromOfficeId = helper.extractLongNamed("fromOfficeId", element, parametersPassedInRequest);
|
||||
final Long toOfficeId = helper.extractLongNamed("toOfficeId", element, parametersPassedInRequest);
|
||||
final LocalDate transactionLocalDate = helper.extractLocalDateAsArrayNamed("transactionDate", element, parametersPassedInRequest);
|
||||
final String currencyCode = helper.extractStringNamed("currencyCode", element, parametersPassedInRequest);
|
||||
final BigDecimal transactionAmount = helper.extractBigDecimalNamed("transactionAmount", element.getAsJsonObject(), Locale.US, parametersPassedInRequest);
|
||||
final String description = helper.extractStringNamed("description", element, parametersPassedInRequest);
|
||||
|
||||
return new BranchMoneyTransferCommand(parametersPassedInRequest, makerCheckerApproval, fromOfficeId, toOfficeId, transactionLocalDate, currencyCode,
|
||||
transactionAmount, description);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CurrencyCommand deserializeCurrencyCommand(final String commandAsJson, final boolean makerCheckerApproval) {
|
||||
if (StringUtils.isBlank(commandAsJson)) { throw new InvalidJsonException(); }
|
||||
|
||||
final JsonParserHelper helper = new JsonParserHelper();
|
||||
final JsonElement element = parser.parse(commandAsJson);
|
||||
|
||||
final Set<String> parametersPassedInRequest = new HashSet<String>();
|
||||
|
||||
final String[] currencies = helper.extractArrayNamed("currencies", element, parametersPassedInRequest);
|
||||
|
||||
return new CurrencyCommand(makerCheckerApproval, currencies);
|
||||
}
|
||||
}
|
||||
+22
-1
@@ -1,8 +1,15 @@
|
||||
package org.mifosng.platform.api.infrastructure;
|
||||
|
||||
import org.mifosplatform.infrastructure.codes.command.CodeCommand;
|
||||
import org.mifosplatform.infrastructure.configuration.command.CurrencyCommand;
|
||||
import org.mifosplatform.infrastructure.office.command.BranchMoneyTransferCommand;
|
||||
import org.mifosplatform.infrastructure.office.command.OfficeCommand;
|
||||
import org.mifosplatform.infrastructure.staff.command.StaffCommand;
|
||||
import org.mifosplatform.infrastructure.user.command.PermissionsCommand;
|
||||
import org.mifosplatform.infrastructure.user.command.RoleCommand;
|
||||
import org.mifosplatform.infrastructure.user.command.RolePermissionCommand;
|
||||
import org.mifosplatform.infrastructure.user.command.UserCommand;
|
||||
import org.mifosplatform.portfolio.fund.command.FundCommand;
|
||||
|
||||
/**
|
||||
* Service for de-serializing JSON for a command into the platforms internal
|
||||
@@ -20,5 +27,19 @@ public interface PortfolioCommandDeserializerService {
|
||||
|
||||
RolePermissionCommand deserializeRolePermissionCommand(Long roleId, String commandAsJson, boolean makerCheckerApproval);
|
||||
|
||||
UserCommand deserializeUserCommand(Long resourceId, String jsonOfChangesOnly, boolean makerCheckerApproval);
|
||||
PermissionsCommand deserializePermissionsCommand(String commandAsJson, boolean makerCheckerApproval);
|
||||
|
||||
UserCommand deserializeUserCommand(Long userId, String commandAsJson, boolean makerCheckerApproval);
|
||||
|
||||
CodeCommand deserializeCodeCommand(Long codeId, String commandAsJson, boolean makerCheckerApproval);
|
||||
|
||||
StaffCommand deserializeStaffCommand(Long staffId, String commandAsJson, boolean makerCheckerApproval);
|
||||
|
||||
FundCommand deserializeFundCommand(Long fundId, String commandAsJson, boolean makerCheckerApproval);
|
||||
|
||||
OfficeCommand deserializeOfficeCommand(Long officeId, String commandAsJson, boolean makerCheckerApproval);
|
||||
|
||||
BranchMoneyTransferCommand deserializeOfficeTransactionCommand(String commandAsJson, boolean makerCheckerApproval);
|
||||
|
||||
CurrencyCommand deserializeCurrencyCommand(String commandAsJson, boolean makerCheckerApproval);
|
||||
}
|
||||
+21
@@ -1,8 +1,15 @@
|
||||
package org.mifosng.platform.api.infrastructure;
|
||||
|
||||
import org.mifosplatform.infrastructure.codes.command.CodeCommand;
|
||||
import org.mifosplatform.infrastructure.configuration.command.CurrencyCommand;
|
||||
import org.mifosplatform.infrastructure.office.command.BranchMoneyTransferCommand;
|
||||
import org.mifosplatform.infrastructure.office.command.OfficeCommand;
|
||||
import org.mifosplatform.infrastructure.staff.command.StaffCommand;
|
||||
import org.mifosplatform.infrastructure.user.command.PermissionsCommand;
|
||||
import org.mifosplatform.infrastructure.user.command.RoleCommand;
|
||||
import org.mifosplatform.infrastructure.user.command.RolePermissionCommand;
|
||||
import org.mifosplatform.infrastructure.user.command.UserCommand;
|
||||
import org.mifosplatform.portfolio.fund.command.FundCommand;
|
||||
|
||||
/**
|
||||
* Service for serializing commands into another format.
|
||||
@@ -16,5 +23,19 @@ public interface PortfolioCommandSerializerService {
|
||||
|
||||
String serializeRolePermissionCommandToJson(RolePermissionCommand command);
|
||||
|
||||
String serializePermissionsCommandToJson(PermissionsCommand command);
|
||||
|
||||
String serializeUserCommandToJson(UserCommand command);
|
||||
|
||||
String serializeCodeCommandToJson(CodeCommand command);
|
||||
|
||||
String serializeStaffCommandToJson(StaffCommand command);
|
||||
|
||||
String serializeFundCommandToJson(FundCommand command);
|
||||
|
||||
String serializeOfficeCommandToJson(OfficeCommand command);
|
||||
|
||||
String serializeOfficeTransactionCommandToJson(BranchMoneyTransferCommand command);
|
||||
|
||||
String serializeCurrencyCommandToJson(CurrencyCommand command);
|
||||
}
|
||||
+49
@@ -3,9 +3,16 @@ package org.mifosng.platform.api.infrastructure;
|
||||
import java.util.HashSet;
|
||||
|
||||
import org.mifosng.platform.infrastructure.api.GoogleGsonSerializerHelper;
|
||||
import org.mifosplatform.infrastructure.codes.command.CodeCommand;
|
||||
import org.mifosplatform.infrastructure.configuration.command.CurrencyCommand;
|
||||
import org.mifosplatform.infrastructure.office.command.BranchMoneyTransferCommand;
|
||||
import org.mifosplatform.infrastructure.office.command.OfficeCommand;
|
||||
import org.mifosplatform.infrastructure.staff.command.StaffCommand;
|
||||
import org.mifosplatform.infrastructure.user.command.PermissionsCommand;
|
||||
import org.mifosplatform.infrastructure.user.command.RoleCommand;
|
||||
import org.mifosplatform.infrastructure.user.command.RolePermissionCommand;
|
||||
import org.mifosplatform.infrastructure.user.command.UserCommand;
|
||||
import org.mifosplatform.portfolio.fund.command.FundCommand;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -37,10 +44,52 @@ public class PortfolioCommandSerializerServiceJson implements PortfolioCommandSe
|
||||
final Gson gsonDeserializer = helper.createGsonBuilderWithParameterExclusionSerializationStrategy(new HashSet<String>(), false, new HashSet<String>());
|
||||
return helper.serializedJsonFrom(gsonDeserializer, command);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String serializePermissionsCommandToJson(final PermissionsCommand command) {
|
||||
final Gson gsonDeserializer = helper.createGsonBuilderWithParameterExclusionSerializationStrategy(new HashSet<String>(), false, new HashSet<String>());
|
||||
return helper.serializedJsonFrom(gsonDeserializer, command);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String serializeUserCommandToJson(final UserCommand command) {
|
||||
final Gson gsonDeserializer = helper.createGsonBuilderWithParameterExclusionSerializationStrategy(new HashSet<String>(), false, new HashSet<String>());
|
||||
return helper.serializedJsonFrom(gsonDeserializer, command);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String serializeCodeCommandToJson(final CodeCommand command) {
|
||||
final Gson gsonDeserializer = helper.createGsonBuilderWithParameterExclusionSerializationStrategy(new HashSet<String>(), false, new HashSet<String>());
|
||||
return helper.serializedJsonFrom(gsonDeserializer, command);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String serializeStaffCommandToJson(final StaffCommand command) {
|
||||
final Gson gsonDeserializer = helper.createGsonBuilderWithParameterExclusionSerializationStrategy(new HashSet<String>(), false, new HashSet<String>());
|
||||
return helper.serializedJsonFrom(gsonDeserializer, command);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String serializeFundCommandToJson(final FundCommand command) {
|
||||
final Gson gsonDeserializer = helper.createGsonBuilderWithParameterExclusionSerializationStrategy(new HashSet<String>(), false, new HashSet<String>());
|
||||
return helper.serializedJsonFrom(gsonDeserializer, command);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String serializeOfficeCommandToJson(final OfficeCommand command) {
|
||||
final Gson gsonDeserializer = helper.createGsonBuilderWithParameterExclusionSerializationStrategy(new HashSet<String>(), false, new HashSet<String>());
|
||||
return helper.serializedJsonFrom(gsonDeserializer, command);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String serializeOfficeTransactionCommandToJson(final BranchMoneyTransferCommand command) {
|
||||
final Gson gsonDeserializer = helper.createGsonBuilderWithParameterExclusionSerializationStrategy(new HashSet<String>(), false, new HashSet<String>());
|
||||
return helper.serializedJsonFrom(gsonDeserializer, command);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String serializeCurrencyCommandToJson(final CurrencyCommand command) {
|
||||
final Gson gsonDeserializer = helper.createGsonBuilderWithParameterExclusionSerializationStrategy(new HashSet<String>(), false, new HashSet<String>());
|
||||
return helper.serializedJsonFrom(gsonDeserializer, command);
|
||||
}
|
||||
}
|
||||
-16
@@ -1,16 +0,0 @@
|
||||
package org.mifosng.platform.charge.service;
|
||||
|
||||
import org.mifosng.platform.api.commands.ChargeCommand;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
|
||||
public interface ChargeWritePlatformService {
|
||||
|
||||
@PreAuthorize(value = "hasAnyRole('ALL_FUNCTIONS', 'ORGANISATION_ADMINISTRATION_SUPER_USER', 'CREATE_CHARGE')")
|
||||
Long createCharge(final ChargeCommand command);
|
||||
|
||||
@PreAuthorize(value = "hasAnyRole('ALL_FUNCTIONS', 'ORGANISATION_ADMINISTRATION_SUPER_USER', 'UPDATE_CHARGE')")
|
||||
Long updateCharge(final ChargeCommand command);
|
||||
|
||||
@PreAuthorize(value = "hasAnyRole('ALL_FUNCTIONS', 'ORGANISATION_ADMINISTRATION_SUPER_USER', 'DELETE_CHARGE')")
|
||||
Long deleteCharge(final Long chargeId);
|
||||
}
|
||||
@@ -14,7 +14,7 @@ import org.apache.commons.lang.StringUtils;
|
||||
import org.joda.time.LocalDate;
|
||||
import org.mifosng.platform.api.commands.ClientCommand;
|
||||
import org.mifosng.platform.infrastructure.AbstractAuditableCustom;
|
||||
import org.mifosng.platform.organisation.domain.Office;
|
||||
import org.mifosplatform.infrastructure.office.domain.Office;
|
||||
import org.mifosplatform.infrastructure.user.domain.AppUser;
|
||||
|
||||
@Entity
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@ import javax.persistence.UniqueConstraint;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.mifosng.platform.api.commands.ClientIdentifierCommand;
|
||||
import org.mifosng.platform.infrastructure.AbstractAuditableCustom;
|
||||
import org.mifosng.platform.organisation.domain.CodeValue;
|
||||
import org.mifosplatform.infrastructure.codes.domain.CodeValue;
|
||||
import org.mifosplatform.infrastructure.user.domain.AppUser;
|
||||
|
||||
@Entity
|
||||
|
||||
+3
-3
@@ -16,15 +16,15 @@ import org.mifosng.platform.api.data.ClientIdentifierData;
|
||||
import org.mifosng.platform.api.data.ClientLookup;
|
||||
import org.mifosng.platform.api.data.EnumOptionData;
|
||||
import org.mifosng.platform.api.data.NoteData;
|
||||
import org.mifosng.platform.api.data.OfficeLookup;
|
||||
import org.mifosng.platform.client.domain.NoteEnumerations;
|
||||
import org.mifosng.platform.exceptions.ClientIdentifierNotFoundException;
|
||||
import org.mifosng.platform.exceptions.ClientNotFoundException;
|
||||
import org.mifosng.platform.exceptions.NoteNotFoundException;
|
||||
import org.mifosng.platform.infrastructure.JdbcSupport;
|
||||
import org.mifosng.platform.infrastructure.TenantAwareRoutingDataSource;
|
||||
import org.mifosng.platform.organisation.service.OfficeReadPlatformService;
|
||||
import org.mifosng.platform.security.PlatformSecurityContext;
|
||||
import org.mifosplatform.infrastructure.office.data.OfficeLookup;
|
||||
import org.mifosplatform.infrastructure.office.service.OfficeReadPlatformService;
|
||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||
import org.mifosplatform.infrastructure.user.api.data.AppUserData;
|
||||
import org.mifosplatform.infrastructure.user.domain.AppUser;
|
||||
import org.mifosplatform.infrastructure.user.service.AppUserReadPlatformService;
|
||||
|
||||
+7
-7
@@ -25,11 +25,11 @@ import org.mifosng.platform.exceptions.OfficeNotFoundException;
|
||||
import org.mifosng.platform.exceptions.PlatformDataIntegrityException;
|
||||
import org.mifosng.platform.infrastructure.Base64EncodedImage;
|
||||
import org.mifosng.platform.infrastructure.FileUtils;
|
||||
import org.mifosng.platform.organisation.domain.CodeValue;
|
||||
import org.mifosng.platform.organisation.domain.CodeValueRepository;
|
||||
import org.mifosng.platform.organisation.domain.Office;
|
||||
import org.mifosng.platform.organisation.domain.OfficeRepository;
|
||||
import org.mifosng.platform.security.PlatformSecurityContext;
|
||||
import org.mifosplatform.infrastructure.codes.domain.CodeValue;
|
||||
import org.mifosplatform.infrastructure.codes.domain.CodeValueRepository;
|
||||
import org.mifosplatform.infrastructure.office.domain.Office;
|
||||
import org.mifosplatform.infrastructure.office.domain.OfficeRepository;
|
||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||
import org.mifosplatform.infrastructure.user.domain.Permission;
|
||||
import org.mifosplatform.infrastructure.user.domain.PermissionRepository;
|
||||
import org.slf4j.Logger;
|
||||
@@ -216,7 +216,7 @@ public class ClientWritePlatformServiceJpaRepositoryImpl implements ClientWriteP
|
||||
final CodeValue documentType = this.codeValueRepository.findOne(command.getDocumentTypeId());
|
||||
if (documentType == null) { throw new CodeValueNotFoundException(command.getDocumentTypeId()); }
|
||||
documentTypeId = documentType.getId();
|
||||
documentTypeLabel = documentType.getLabel();
|
||||
documentTypeLabel = documentType.label();
|
||||
|
||||
final ClientIdentifier clientIdentifier = ClientIdentifier.createNew(client, documentType, documentKey,
|
||||
command.getDescription());
|
||||
@@ -250,7 +250,7 @@ public class ClientWritePlatformServiceJpaRepositoryImpl implements ClientWriteP
|
||||
documentType = this.codeValueRepository.findOne(documentTypeId);
|
||||
if (documentType == null) { throw new CodeValueNotFoundException(command.getDocumentTypeId()); }
|
||||
documentTypeId = documentType.getId();
|
||||
documentTypeLabel = documentType.getLabel();
|
||||
documentTypeLabel = documentType.label();
|
||||
}
|
||||
|
||||
final ClientIdentifier clientIdentifierForUpdate = this.clientIdentifierRepository.findOne(command.getId());
|
||||
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
package org.mifosng.platform.configuration.service;
|
||||
|
||||
import org.mifosng.platform.api.data.ConfigurationData;
|
||||
|
||||
public interface ConfigurationReadPlatformService {
|
||||
|
||||
ConfigurationData retrieveCurrencyConfiguration();
|
||||
|
||||
}
|
||||
-11
@@ -1,11 +0,0 @@
|
||||
package org.mifosng.platform.configuration.service;
|
||||
|
||||
import org.mifosng.platform.api.commands.OrganisationCurrencyCommand;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
|
||||
public interface ConfigurationWritePlatformService {
|
||||
|
||||
@PreAuthorize(value = "hasAnyRole('ALL_FUNCTIONS', 'ORGANISATION_ADMINISTRATION_SUPER_USER', 'UPDATE_CURRENCY')")
|
||||
void updateOrganisationCurrencies(OrganisationCurrencyCommand command);
|
||||
|
||||
}
|
||||
-12
@@ -1,12 +0,0 @@
|
||||
package org.mifosng.platform.currency.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.mifosng.platform.api.data.CurrencyData;
|
||||
|
||||
public interface CurrencyReadPlatformService {
|
||||
|
||||
List<CurrencyData> retrieveAllowedCurrencies();
|
||||
|
||||
List<CurrencyData> retrieveAllPlatformCurrencies();
|
||||
}
|
||||
-65
@@ -1,65 +0,0 @@
|
||||
package org.mifosng.platform.currency.service;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
|
||||
import org.mifosng.platform.api.data.CurrencyData;
|
||||
import org.mifosng.platform.infrastructure.JdbcSupport;
|
||||
import org.mifosng.platform.infrastructure.TenantAwareRoutingDataSource;
|
||||
import org.mifosng.platform.security.PlatformSecurityContext;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.jdbc.core.RowMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class CurrencyReadPlatformServiceImpl implements CurrencyReadPlatformService {
|
||||
|
||||
private final JdbcTemplate jdbcTemplate;
|
||||
private final PlatformSecurityContext context;
|
||||
|
||||
@Autowired
|
||||
public CurrencyReadPlatformServiceImpl(final PlatformSecurityContext context, final TenantAwareRoutingDataSource dataSource) {
|
||||
this.context = context;
|
||||
this.jdbcTemplate = new JdbcTemplate(dataSource);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CurrencyData> retrieveAllowedCurrencies() {
|
||||
|
||||
context.authenticatedUser();
|
||||
|
||||
String sql = "select c.code as code, c.name as name, c.decimal_places as decimalPlaces, c.display_symbol as displaySymbol, c.internationalized_name_code as nameCode from m_organisation_currency c order by c.name";
|
||||
|
||||
RowMapper<CurrencyData> rm = new CurrencyMapper();
|
||||
|
||||
return this.jdbcTemplate.query(sql, rm, new Object[] {});
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CurrencyData> retrieveAllPlatformCurrencies() {
|
||||
|
||||
String sql = "select c.code as code, c.name as name, c.decimal_places as decimalPlaces, c.display_symbol as displaySymbol, c.internationalized_name_code as nameCode from m_currency c order by c.name";
|
||||
|
||||
RowMapper<CurrencyData> rm = new CurrencyMapper();
|
||||
|
||||
return this.jdbcTemplate.query(sql, rm, new Object[] {});
|
||||
}
|
||||
|
||||
private static final class CurrencyMapper implements RowMapper<CurrencyData> {
|
||||
|
||||
@Override
|
||||
public CurrencyData mapRow(final ResultSet rs, @SuppressWarnings("unused") final int rowNum)
|
||||
throws SQLException {
|
||||
|
||||
String code = rs.getString("code");
|
||||
String name = rs.getString("name");
|
||||
int decimalPlaces = JdbcSupport.getInteger(rs, "decimalPlaces");
|
||||
String displaySymbol = rs.getString("displaySymbol");
|
||||
String nameCode = rs.getString("nameCode");
|
||||
|
||||
return new CurrencyData(code, name, decimalPlaces, displaySymbol, nameCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -8,7 +8,7 @@ import org.mifosng.platform.api.data.DocumentData;
|
||||
import org.mifosng.platform.exceptions.DocumentNotFoundException;
|
||||
import org.mifosng.platform.infrastructure.JdbcSupport;
|
||||
import org.mifosng.platform.infrastructure.TenantAwareRoutingDataSource;
|
||||
import org.mifosng.platform.security.PlatformSecurityContext;
|
||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.dao.EmptyResultDataAccessException;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@ import org.mifosng.platform.exceptions.DocumentNotFoundException;
|
||||
import org.mifosng.platform.exceptions.InvalidEntityTypeForDocumentManagementException;
|
||||
import org.mifosng.platform.exceptions.PlatformDataIntegrityException;
|
||||
import org.mifosng.platform.infrastructure.FileUtils;
|
||||
import org.mifosng.platform.security.PlatformSecurityContext;
|
||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
+19
-18
@@ -1,29 +1,30 @@
|
||||
package org.mifosng.platform.exceptions;
|
||||
|
||||
/**
|
||||
* A {@link RuntimeException} thrown when valid api request end up violating some domain rule.
|
||||
* A {@link RuntimeException} thrown when valid api request end up violating
|
||||
* some domain rule.
|
||||
*/
|
||||
public abstract class AbstractPlatformDomainRuleException extends RuntimeException {
|
||||
|
||||
private final String globalisationMessageCode;
|
||||
private final String defaultUserMessage;
|
||||
private final Object[] defaultUserMessageArgs;
|
||||
private final String globalisationMessageCode;
|
||||
private final String defaultUserMessage;
|
||||
private final Object[] defaultUserMessageArgs;
|
||||
|
||||
public AbstractPlatformDomainRuleException(String globalisationMessageCode, String defaultUserMessage, Object... defaultUserMessageArgs) {
|
||||
this.globalisationMessageCode = globalisationMessageCode;
|
||||
this.defaultUserMessage = defaultUserMessage;
|
||||
this.defaultUserMessageArgs = defaultUserMessageArgs;
|
||||
}
|
||||
public AbstractPlatformDomainRuleException(String globalisationMessageCode, String defaultUserMessage, Object... defaultUserMessageArgs) {
|
||||
this.globalisationMessageCode = globalisationMessageCode;
|
||||
this.defaultUserMessage = defaultUserMessage;
|
||||
this.defaultUserMessageArgs = defaultUserMessageArgs;
|
||||
}
|
||||
|
||||
public String getGlobalisationMessageCode() {
|
||||
return globalisationMessageCode;
|
||||
}
|
||||
public String getGlobalisationMessageCode() {
|
||||
return globalisationMessageCode;
|
||||
}
|
||||
|
||||
public String getDefaultUserMessage() {
|
||||
return defaultUserMessage;
|
||||
}
|
||||
public String getDefaultUserMessage() {
|
||||
return defaultUserMessage;
|
||||
}
|
||||
|
||||
public Object[] getDefaultUserMessageArgs() {
|
||||
return defaultUserMessageArgs;
|
||||
}
|
||||
public Object[] getDefaultUserMessageArgs() {
|
||||
return defaultUserMessageArgs;
|
||||
}
|
||||
}
|
||||
+20
-18
@@ -1,29 +1,31 @@
|
||||
package org.mifosng.platform.exceptions;
|
||||
|
||||
/**
|
||||
* A {@link RuntimeException} thrown when resources that are queried for are not found.
|
||||
* A {@link RuntimeException} thrown when resources that are queried for are not
|
||||
* found.
|
||||
*/
|
||||
public abstract class AbstractPlatformResourceNotFoundException extends RuntimeException {
|
||||
|
||||
private final String globalisationMessageCode;
|
||||
private final String defaultUserMessage;
|
||||
private final Object[] defaultUserMessageArgs;
|
||||
private final String globalisationMessageCode;
|
||||
private final String defaultUserMessage;
|
||||
private final Object[] defaultUserMessageArgs;
|
||||
|
||||
public AbstractPlatformResourceNotFoundException(String globalisationMessageCode, String defaultUserMessage, Object... defaultUserMessageArgs) {
|
||||
this.globalisationMessageCode = globalisationMessageCode;
|
||||
this.defaultUserMessage = defaultUserMessage;
|
||||
this.defaultUserMessageArgs = defaultUserMessageArgs;
|
||||
}
|
||||
public AbstractPlatformResourceNotFoundException(String globalisationMessageCode, String defaultUserMessage,
|
||||
Object... defaultUserMessageArgs) {
|
||||
this.globalisationMessageCode = globalisationMessageCode;
|
||||
this.defaultUserMessage = defaultUserMessage;
|
||||
this.defaultUserMessageArgs = defaultUserMessageArgs;
|
||||
}
|
||||
|
||||
public String getGlobalisationMessageCode() {
|
||||
return globalisationMessageCode;
|
||||
}
|
||||
public String getGlobalisationMessageCode() {
|
||||
return globalisationMessageCode;
|
||||
}
|
||||
|
||||
public String getDefaultUserMessage() {
|
||||
return defaultUserMessage;
|
||||
}
|
||||
public String getDefaultUserMessage() {
|
||||
return defaultUserMessage;
|
||||
}
|
||||
|
||||
public Object[] getDefaultUserMessageArgs() {
|
||||
return defaultUserMessageArgs;
|
||||
}
|
||||
public Object[] getDefaultUserMessageArgs() {
|
||||
return defaultUserMessageArgs;
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -5,7 +5,7 @@ package org.mifosng.platform.exceptions;
|
||||
*/
|
||||
public class CodeValueNotFoundException extends AbstractPlatformResourceNotFoundException {
|
||||
|
||||
public CodeValueNotFoundException(Long id) {
|
||||
super("error.msg.codevalue.id.invalid", "Code value with identifier " + id + " does not exist", id);
|
||||
}
|
||||
public CodeValueNotFoundException(Long id) {
|
||||
super("error.msg.codevalue.id.invalid", "Code value with identifier " + id + " does not exist", id);
|
||||
}
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
package org.mifosng.platform.fund.domain;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.UniqueConstraint;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.mifosng.platform.api.commands.FundCommand;
|
||||
import org.mifosng.platform.infrastructure.AbstractAuditableCustom;
|
||||
import org.mifosplatform.infrastructure.user.domain.AppUser;
|
||||
|
||||
@Entity
|
||||
@Table(name = "m_fund", uniqueConstraints={
|
||||
@UniqueConstraint(columnNames = {"name"}, name="fund_name_org"),
|
||||
@UniqueConstraint(columnNames = {"external_id"}, name="fund_externalid_org")
|
||||
})
|
||||
public class Fund extends AbstractAuditableCustom<AppUser, Long> {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Column(name = "name")
|
||||
private String name;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Column(name = "external_id", length=100)
|
||||
private String externalId;
|
||||
|
||||
public static Fund createNew(final String fundName, final String externalId) {
|
||||
return new Fund(fundName, externalId);
|
||||
}
|
||||
|
||||
protected Fund() {
|
||||
//
|
||||
}
|
||||
|
||||
private Fund(final String fundName, final String externalId) {
|
||||
this.name = StringUtils.defaultIfEmpty(fundName, null);
|
||||
this.externalId = StringUtils.defaultIfEmpty(externalId, null);
|
||||
}
|
||||
|
||||
public void update(final FundCommand command) {
|
||||
|
||||
if (command.isNameChanged()) {
|
||||
this.name = StringUtils.defaultIfEmpty(command.getName(), null);
|
||||
}
|
||||
|
||||
if (command.isExternalIdChanged()) {
|
||||
this.externalId = StringUtils.defaultIfEmpty(command.getExternalId(), null);
|
||||
}
|
||||
}
|
||||
}
|
||||
-48
@@ -1,48 +0,0 @@
|
||||
package org.mifosng.platform.fund.service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.mifosng.platform.DataValidatorBuilder;
|
||||
import org.mifosng.platform.api.commands.FundCommand;
|
||||
import org.mifosng.platform.api.data.ApiParameterError;
|
||||
import org.mifosng.platform.exceptions.PlatformApiDataValidationException;
|
||||
|
||||
public class FundCommandValidator {
|
||||
|
||||
private final FundCommand command;
|
||||
|
||||
public FundCommandValidator(FundCommand command) {
|
||||
this.command = command;
|
||||
}
|
||||
|
||||
public void validateForCreate() {
|
||||
|
||||
List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>();
|
||||
|
||||
DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors).resource("fund");
|
||||
|
||||
baseDataValidator.reset().parameter("name").value(command.getName()).notBlank();
|
||||
baseDataValidator.reset().parameter("externalId").value(command.getExternalId()).notExceedingLengthOf(100);
|
||||
|
||||
if (!dataValidationErrors.isEmpty()) {
|
||||
throw new PlatformApiDataValidationException("validation.msg.validation.errors.exist", "Validation errors exist.", dataValidationErrors);
|
||||
}
|
||||
}
|
||||
|
||||
public void validateForUpdate() {
|
||||
List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>();
|
||||
|
||||
DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors).resource("fund");
|
||||
|
||||
baseDataValidator.reset().parameter("id").value(command.getId()).notNull();
|
||||
baseDataValidator.reset().parameter("name").value(command.getName()).ignoreIfNull().notBlank();
|
||||
baseDataValidator.reset().parameter("externalId").value(command.getExternalId()).ignoreIfNull().notExceedingLengthOf(100);
|
||||
|
||||
baseDataValidator.reset().anyOfNotNull(command.getName(), command.getExternalId());
|
||||
|
||||
if (!dataValidationErrors.isEmpty()) {
|
||||
throw new PlatformApiDataValidationException("validation.msg.validation.errors.exist", "Validation errors exist.", dataValidationErrors);
|
||||
}
|
||||
}
|
||||
}
|
||||
-12
@@ -1,12 +0,0 @@
|
||||
package org.mifosng.platform.fund.service;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.mifosng.platform.api.data.FundData;
|
||||
|
||||
public interface FundReadPlatformService {
|
||||
|
||||
Collection<FundData> retrieveAllFunds();
|
||||
|
||||
FundData retrieveFund(Long fundId);
|
||||
}
|
||||
-77
@@ -1,77 +0,0 @@
|
||||
package org.mifosng.platform.fund.service;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Collection;
|
||||
|
||||
import org.mifosng.platform.api.data.FundData;
|
||||
import org.mifosng.platform.exceptions.FundNotFoundException;
|
||||
import org.mifosng.platform.infrastructure.TenantAwareRoutingDataSource;
|
||||
import org.mifosng.platform.security.PlatformSecurityContext;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.dao.EmptyResultDataAccessException;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.jdbc.core.RowMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class FundReadPlatformServiceImpl implements FundReadPlatformService {
|
||||
|
||||
private final JdbcTemplate jdbcTemplate;
|
||||
private final PlatformSecurityContext context;
|
||||
|
||||
@Autowired
|
||||
public FundReadPlatformServiceImpl(final PlatformSecurityContext context,
|
||||
final TenantAwareRoutingDataSource dataSource) {
|
||||
this.context = context;
|
||||
this.jdbcTemplate = new JdbcTemplate(dataSource);
|
||||
}
|
||||
|
||||
private static final class FundMapper implements RowMapper<FundData> {
|
||||
|
||||
public String schema() {
|
||||
return " f.id as id, f.name as name, f.external_id as externalId from m_fund f ";
|
||||
}
|
||||
|
||||
@Override
|
||||
public FundData mapRow(final ResultSet rs, @SuppressWarnings("unused") final int rowNum)
|
||||
throws SQLException {
|
||||
|
||||
Long id = rs.getLong("id");
|
||||
String name = rs.getString("name");
|
||||
String externalId = rs.getString("externalId");
|
||||
|
||||
return new FundData(id, name, externalId);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<FundData> retrieveAllFunds() {
|
||||
|
||||
context.authenticatedUser();
|
||||
|
||||
FundMapper rm = new FundMapper();
|
||||
String sql = "select "
|
||||
+ rm.schema()
|
||||
+ " order by f.name";
|
||||
|
||||
return this.jdbcTemplate.query(sql, rm, new Object[] {});
|
||||
}
|
||||
|
||||
@Override
|
||||
public FundData retrieveFund(final Long fundId) {
|
||||
|
||||
try {
|
||||
context.authenticatedUser();
|
||||
|
||||
FundMapper rm = new FundMapper();
|
||||
String sql = "select " + rm.schema() + " where f.id = ?";
|
||||
|
||||
FundData selectedFund = this.jdbcTemplate.queryForObject(sql, rm, new Object[] {fundId});
|
||||
|
||||
return selectedFund;
|
||||
} catch (EmptyResultDataAccessException e) {
|
||||
throw new FundNotFoundException(fundId);
|
||||
}
|
||||
}
|
||||
}
|
||||
-13
@@ -1,13 +0,0 @@
|
||||
package org.mifosng.platform.fund.service;
|
||||
|
||||
import org.mifosng.platform.api.commands.FundCommand;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
|
||||
public interface FundWritePlatformService {
|
||||
|
||||
@PreAuthorize(value = "hasAnyRole('ALL_FUNCTIONS', 'ORGANISATION_ADMINISTRATION_SUPER_USER', 'CREATE_FUND')")
|
||||
Long createFund(final FundCommand command);
|
||||
|
||||
@PreAuthorize(value = "hasAnyRole('ALL_FUNCTIONS', 'ORGANISATION_ADMINISTRATION_SUPER_USER', 'UPDATE_FUND')")
|
||||
Long updateFund(final FundCommand command);
|
||||
}
|
||||
-92
@@ -1,92 +0,0 @@
|
||||
package org.mifosng.platform.fund.service;
|
||||
|
||||
import org.mifosng.platform.api.commands.FundCommand;
|
||||
import org.mifosng.platform.exceptions.FundNotFoundException;
|
||||
import org.mifosng.platform.exceptions.PlatformDataIntegrityException;
|
||||
import org.mifosng.platform.fund.domain.Fund;
|
||||
import org.mifosng.platform.fund.domain.FundRepository;
|
||||
import org.mifosng.platform.security.PlatformSecurityContext;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.dao.DataIntegrityViolationException;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@Service
|
||||
public class FundWritePlatformServiceJpaRepositoryImpl implements FundWritePlatformService {
|
||||
|
||||
private final static Logger logger = LoggerFactory.getLogger(FundWritePlatformServiceJpaRepositoryImpl.class);
|
||||
|
||||
private final PlatformSecurityContext context;
|
||||
private final FundRepository fundRepository;
|
||||
|
||||
@Autowired
|
||||
public FundWritePlatformServiceJpaRepositoryImpl(final PlatformSecurityContext context, final FundRepository fundRepository) {
|
||||
this.context = context;
|
||||
this.fundRepository = fundRepository;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public Long createFund(final FundCommand command) {
|
||||
|
||||
try {
|
||||
context.authenticatedUser();
|
||||
|
||||
FundCommandValidator validator = new FundCommandValidator(command);
|
||||
validator.validateForCreate();
|
||||
|
||||
Fund fund = Fund.createNew(command.getName(), command.getExternalId());
|
||||
|
||||
this.fundRepository.saveAndFlush(fund);
|
||||
|
||||
return fund.getId();
|
||||
} catch (DataIntegrityViolationException dve) {
|
||||
handleFundDataIntegrityIssues(command, dve);
|
||||
return Long.valueOf(-1);
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public Long updateFund(final FundCommand command) {
|
||||
|
||||
try {
|
||||
context.authenticatedUser();
|
||||
|
||||
FundCommandValidator validator = new FundCommandValidator(command);
|
||||
validator.validateForUpdate();
|
||||
|
||||
final Long fundId = command.getId();
|
||||
Fund fund = this.fundRepository.findOne(fundId);
|
||||
if (fund == null) {
|
||||
throw new FundNotFoundException(fundId);
|
||||
}
|
||||
fund.update(command);
|
||||
|
||||
this.fundRepository.saveAndFlush(fund);
|
||||
|
||||
return fund.getId();
|
||||
} catch (DataIntegrityViolationException dve) {
|
||||
handleFundDataIntegrityIssues(command, dve);
|
||||
return Long.valueOf(-1);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Guaranteed to throw an exception no matter what the data integrity issue is.
|
||||
*/
|
||||
private void handleFundDataIntegrityIssues(final FundCommand command, DataIntegrityViolationException dve) {
|
||||
|
||||
Throwable realCause = dve.getMostSpecificCause();
|
||||
if (realCause.getMessage().contains("fund_externalid_org")) {
|
||||
throw new PlatformDataIntegrityException("error.msg.fund.duplicate.externalId", "A fund with external id '" + command.getExternalId() + "' already exists", "externalId", command.getExternalId());
|
||||
} else if (realCause.getMessage().contains("fund_name_org")) {
|
||||
throw new PlatformDataIntegrityException("error.msg.fund.duplicate.name", "A fund with name '" + command.getExternalId() + "' already exists", "name", command.getName());
|
||||
}
|
||||
|
||||
logger.error(dve.getMessage(), dve);
|
||||
throw new PlatformDataIntegrityException("error.msg.fund.unknown.data.integrity.issue", "Unknown data integrity issue with resource: " + realCause.getMessage());
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,7 @@ import org.apache.commons.lang.StringUtils;
|
||||
import org.mifosng.platform.api.commands.GroupCommand;
|
||||
import org.mifosng.platform.client.domain.Client;
|
||||
import org.mifosng.platform.infrastructure.AbstractAuditableCustom;
|
||||
import org.mifosng.platform.organisation.domain.Office;
|
||||
import org.mifosplatform.infrastructure.office.domain.Office;
|
||||
import org.mifosplatform.infrastructure.user.domain.AppUser;
|
||||
|
||||
@Entity
|
||||
|
||||
+3
-3
@@ -11,14 +11,14 @@ import org.mifosng.platform.api.data.ClientLookup;
|
||||
import org.mifosng.platform.api.data.GroupAccountSummaryCollectionData;
|
||||
import org.mifosng.platform.api.data.GroupAccountSummaryData;
|
||||
import org.mifosng.platform.api.data.GroupData;
|
||||
import org.mifosng.platform.api.data.OfficeLookup;
|
||||
import org.mifosng.platform.client.service.ClientReadPlatformService;
|
||||
import org.mifosng.platform.client.service.LoanStatusMapper;
|
||||
import org.mifosng.platform.exceptions.GroupNotFoundException;
|
||||
import org.mifosng.platform.infrastructure.JdbcSupport;
|
||||
import org.mifosng.platform.infrastructure.TenantAwareRoutingDataSource;
|
||||
import org.mifosng.platform.organisation.service.OfficeReadPlatformService;
|
||||
import org.mifosng.platform.security.PlatformSecurityContext;
|
||||
import org.mifosplatform.infrastructure.office.data.OfficeLookup;
|
||||
import org.mifosplatform.infrastructure.office.service.OfficeReadPlatformService;
|
||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.dao.EmptyResultDataAccessException;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
|
||||
+3
-3
@@ -14,9 +14,9 @@ import org.mifosng.platform.exceptions.OfficeNotFoundException;
|
||||
import org.mifosng.platform.exceptions.PlatformDataIntegrityException;
|
||||
import org.mifosng.platform.group.domain.Group;
|
||||
import org.mifosng.platform.group.domain.GroupRepository;
|
||||
import org.mifosng.platform.organisation.domain.Office;
|
||||
import org.mifosng.platform.organisation.domain.OfficeRepository;
|
||||
import org.mifosng.platform.security.PlatformSecurityContext;
|
||||
import org.mifosplatform.infrastructure.office.domain.Office;
|
||||
import org.mifosplatform.infrastructure.office.domain.OfficeRepository;
|
||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
+2
-2
@@ -4,14 +4,14 @@ import java.util.List;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.joda.time.LocalDate;
|
||||
import org.mifosng.platform.api.data.GenericResultsetData;
|
||||
import org.mifosng.platform.api.data.GuarantorData;
|
||||
import org.mifosng.platform.client.domain.Client;
|
||||
import org.mifosng.platform.exceptions.GuarantorNotFoundException;
|
||||
import org.mifosng.platform.exceptions.LoanNotFoundException;
|
||||
import org.mifosng.platform.loan.domain.Loan;
|
||||
import org.mifosng.platform.loan.domain.LoanRepository;
|
||||
import org.mifosng.platform.noncore.ReadWriteNonCoreDataService;
|
||||
import org.mifosplatform.infrastructure.dataqueries.data.GenericResultsetData;
|
||||
import org.mifosplatform.infrastructure.dataqueries.service.ReadWriteNonCoreDataService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@ import org.mifosng.platform.exceptions.LoanNotFoundException;
|
||||
import org.mifosng.platform.exceptions.PlatformApiDataValidationException;
|
||||
import org.mifosng.platform.loan.domain.Loan;
|
||||
import org.mifosng.platform.loan.domain.LoanRepository;
|
||||
import org.mifosng.platform.noncore.ReadWriteNonCoreDataService;
|
||||
import org.mifosplatform.infrastructure.dataqueries.service.ReadWriteNonCoreDataService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
-58
@@ -1,58 +0,0 @@
|
||||
package org.mifosng.platform.infrastructure;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.springframework.security.core.GrantedAuthority;
|
||||
|
||||
public class BasicPasswordEncodablePlatformUser implements PlatformUser {
|
||||
|
||||
private final Long id;
|
||||
private final String username;
|
||||
private final String password;
|
||||
|
||||
public BasicPasswordEncodablePlatformUser(final Long id, final String username,
|
||||
final String password) {
|
||||
this.id = id;
|
||||
this.username = username;
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPassword() {
|
||||
return this.password;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUsername() {
|
||||
return this.username;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<GrantedAuthority> getAuthorities() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAccountNonExpired() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAccountNonLocked() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCredentialsNonExpired() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
+1
@@ -1,5 +1,6 @@
|
||||
package org.mifosng.platform.infrastructure;
|
||||
|
||||
import org.mifosplatform.infrastructure.security.domain.PlatformUser;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.security.authentication.dao.SaltSource;
|
||||
|
||||
-59
@@ -1,59 +0,0 @@
|
||||
package org.mifosng.platform.infrastructure;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.dao.EmptyResultDataAccessException;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.jdbc.core.RowMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* A JDBC implementation of {@link TenantDetailsService} for loading a tenants details by a <code>tenantIdentifier</code>.
|
||||
*/
|
||||
@Service
|
||||
public class JdbcTenantDetailsService implements TenantDetailsService {
|
||||
|
||||
private final JdbcTemplate jdbcTemplate;
|
||||
|
||||
@Autowired
|
||||
public JdbcTenantDetailsService(@Qualifier("tenantDataSourceJndi") final DataSource dataSource) {
|
||||
this.jdbcTemplate = new JdbcTemplate(dataSource);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MifosPlatformTenant loadTenantById(final String tenantIdentifier) {
|
||||
|
||||
try {
|
||||
TenantMapper rm = new TenantMapper();
|
||||
String sql = "select id, name, schema_name as schemaName, schema_server as schemaServer, schema_server_port as schemaServerPort, " +
|
||||
" schema_username as schemaUsername, schema_password as schemaPassword " +
|
||||
" from tenants t where t.identifier like ?";
|
||||
|
||||
return this.jdbcTemplate.queryForObject(sql, rm, new Object[] {tenantIdentifier});
|
||||
} catch (EmptyResultDataAccessException e) {
|
||||
throw new InvalidTenantIdentiferException("The tenant identifier: " + tenantIdentifier + " is not valid.");
|
||||
}
|
||||
}
|
||||
|
||||
private static final class TenantMapper implements RowMapper<MifosPlatformTenant> {
|
||||
|
||||
@Override
|
||||
public MifosPlatformTenant mapRow(final ResultSet rs, @SuppressWarnings("unused") final int rowNum) throws SQLException {
|
||||
|
||||
Long id = rs.getLong("id");
|
||||
String name = rs.getString("name");
|
||||
String schemaName = rs.getString("schemaName");
|
||||
String schemaServer = rs.getString("schemaServer");
|
||||
String schemaServerPort = rs.getString("schemaServerPort");
|
||||
String schemaUsername = rs.getString("schemaUsername");
|
||||
String schemaPassword = rs.getString("schemaPassword");
|
||||
|
||||
return new MifosPlatformTenant(id, name, schemaName, schemaServer, schemaServerPort, schemaUsername, schemaPassword);
|
||||
}
|
||||
}
|
||||
}
|
||||
+38
-38
@@ -2,50 +2,50 @@ package org.mifosng.platform.infrastructure;
|
||||
|
||||
public class MifosPlatformTenant {
|
||||
|
||||
private final Long id;
|
||||
private final String name;
|
||||
private final String schemaName;
|
||||
private final String schemaServer;
|
||||
private final String schemaServerPort;
|
||||
private final String schemaUsername;
|
||||
private final String schemaPassword;
|
||||
private final Long id;
|
||||
private final String name;
|
||||
private final String schemaName;
|
||||
private final String schemaServer;
|
||||
private final String schemaServerPort;
|
||||
private final String schemaUsername;
|
||||
private final String schemaPassword;
|
||||
|
||||
public MifosPlatformTenant(final Long id, final String name, final String schemaName,
|
||||
final String schemaServer, final String schemaServerPort, final String schemaUsername, final String schemaPassword) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.schemaName = schemaName;
|
||||
this.schemaServer = schemaServer;
|
||||
this.schemaServerPort = schemaServerPort;
|
||||
this.schemaUsername = schemaUsername;
|
||||
this.schemaPassword = schemaPassword;
|
||||
}
|
||||
public MifosPlatformTenant(final Long id, final String name, final String schemaName, final String schemaServer,
|
||||
final String schemaServerPort, final String schemaUsername, final String schemaPassword) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.schemaName = schemaName;
|
||||
this.schemaServer = schemaServer;
|
||||
this.schemaServerPort = schemaServerPort;
|
||||
this.schemaUsername = schemaUsername;
|
||||
this.schemaPassword = schemaPassword;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getSchemaName() {
|
||||
return schemaName;
|
||||
}
|
||||
public String getSchemaName() {
|
||||
return schemaName;
|
||||
}
|
||||
|
||||
public String getSchemaServer() {
|
||||
return schemaServer;
|
||||
}
|
||||
public String getSchemaServer() {
|
||||
return schemaServer;
|
||||
}
|
||||
|
||||
public String getSchemaServerPort() {
|
||||
return schemaServerPort;
|
||||
}
|
||||
public String getSchemaServerPort() {
|
||||
return schemaServerPort;
|
||||
}
|
||||
|
||||
public String getSchemaUsername() {
|
||||
return schemaUsername;
|
||||
}
|
||||
public String getSchemaUsername() {
|
||||
return schemaUsername;
|
||||
}
|
||||
|
||||
public String getSchemaPassword() {
|
||||
return schemaPassword;
|
||||
}
|
||||
public String getSchemaPassword() {
|
||||
return schemaPassword;
|
||||
}
|
||||
}
|
||||
+2
@@ -1,5 +1,7 @@
|
||||
package org.mifosng.platform.infrastructure;
|
||||
|
||||
import org.mifosplatform.infrastructure.security.domain.PlatformUser;
|
||||
|
||||
|
||||
public interface PlatformPasswordEncoder {
|
||||
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
package org.mifosng.platform.infrastructure;
|
||||
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
|
||||
/**
|
||||
* Interface to protect platform from implementation detail of spring security.
|
||||
*/
|
||||
public interface PlatformUser extends UserDetails {
|
||||
|
||||
// void updatePasswordOnFirstTimeLogin(String newPasswordEncoded);
|
||||
}
|
||||
-84
@@ -1,84 +0,0 @@
|
||||
package org.mifosng.platform.infrastructure;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.servlet.FilterChain;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.ServletResponse;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.authentication.AuthenticationManager;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.security.web.AuthenticationEntryPoint;
|
||||
import org.springframework.security.web.authentication.www.BasicAuthenticationFilter;
|
||||
|
||||
/**
|
||||
* A customised version of spring security's {@link BasicAuthenticationFilter}.
|
||||
*
|
||||
* This filter is responsible for extracting multi-tenant and basic auth
|
||||
* credentials from the request and checking that the details provided are
|
||||
* valid.
|
||||
*
|
||||
* If multi-tenant and basic auth credentials are valid, the details of the
|
||||
* tenant are stored in {@link MifosPlatformTenant} and stored in a
|
||||
* {@link ThreadLocal} variable for this request using
|
||||
* {@link ThreadLocalContextUtil}.
|
||||
*
|
||||
* If multi-tenant and basic auth credentials are invalid, a http error response
|
||||
* is returned.
|
||||
*/
|
||||
public class TenantAwareBasicAuthenticationFilter extends BasicAuthenticationFilter {
|
||||
|
||||
@Autowired
|
||||
private TenantDetailsService tenantDetailsService;
|
||||
|
||||
private String tenantRequestHeader = "X-Mifos-Platform-TenantId";
|
||||
private boolean exceptionIfHeaderMissing = true;
|
||||
|
||||
public TenantAwareBasicAuthenticationFilter(AuthenticationManager authenticationManager, AuthenticationEntryPoint authenticationEntryPoint) {
|
||||
super(authenticationManager, authenticationEntryPoint);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException {
|
||||
|
||||
HttpServletRequest request = (HttpServletRequest) req;
|
||||
HttpServletResponse response = (HttpServletResponse) res;
|
||||
|
||||
try {
|
||||
|
||||
if ("OPTIONS".equalsIgnoreCase(request.getMethod())) {
|
||||
// ignore to allow 'preflight' requests from AJAX applications in different origin (domain name)
|
||||
} else {
|
||||
|
||||
String tenantId = request.getHeader(tenantRequestHeader);
|
||||
if (org.apache.commons.lang.StringUtils.isBlank(tenantId)) {
|
||||
tenantId = request.getParameter("tenantIdentifier");
|
||||
}
|
||||
|
||||
if (tenantId == null && exceptionIfHeaderMissing) {
|
||||
throw new InvalidTenantIdentiferException("No tenant identifier found: Add request header of '" + tenantRequestHeader +
|
||||
"' or add the parameter 'tenantIdentifier' to query string of request URL.");
|
||||
}
|
||||
|
||||
// check tenants database for tenantId
|
||||
MifosPlatformTenant tenant = this.tenantDetailsService.loadTenantById(tenantId);
|
||||
|
||||
ThreadLocalContextUtil.setTenant(tenant);
|
||||
}
|
||||
|
||||
super.doFilter(req, res, chain);
|
||||
} catch (InvalidTenantIdentiferException e) {
|
||||
// deal with exception at low level
|
||||
SecurityContextHolder.getContext().setAuthentication(null);
|
||||
|
||||
response.addHeader("WWW-Authenticate", "Basic realm=\"" + "Mifos Platform API" + "\"");
|
||||
response.sendError(HttpServletResponse.SC_BAD_REQUEST, e.getMessage());
|
||||
} finally {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
-7
@@ -1,7 +0,0 @@
|
||||
package org.mifosng.platform.infrastructure;
|
||||
|
||||
public interface TenantDetailsService {
|
||||
|
||||
MifosPlatformTenant loadTenantById(String tenantId);
|
||||
|
||||
}
|
||||
+11
-11
@@ -7,18 +7,18 @@ import org.springframework.util.Assert;
|
||||
*/
|
||||
public class ThreadLocalContextUtil {
|
||||
|
||||
private static final ThreadLocal<MifosPlatformTenant> contextHolder = new ThreadLocal<MifosPlatformTenant>();
|
||||
private static final ThreadLocal<MifosPlatformTenant> contextHolder = new ThreadLocal<MifosPlatformTenant>();
|
||||
|
||||
public static void setTenant(final MifosPlatformTenant tenant) {
|
||||
Assert.notNull(tenant, "tenant cannot be null");
|
||||
contextHolder.set(tenant);
|
||||
}
|
||||
public static void setTenant(final MifosPlatformTenant tenant) {
|
||||
Assert.notNull(tenant, "tenant cannot be null");
|
||||
contextHolder.set(tenant);
|
||||
}
|
||||
|
||||
public static MifosPlatformTenant getTenant() {
|
||||
return contextHolder.get();
|
||||
}
|
||||
public static MifosPlatformTenant getTenant() {
|
||||
return contextHolder.get();
|
||||
}
|
||||
|
||||
public static void clearTenant() {
|
||||
contextHolder.remove();
|
||||
}
|
||||
public static void clearTenant() {
|
||||
contextHolder.remove();
|
||||
}
|
||||
}
|
||||
+16
-1
@@ -157,6 +157,22 @@ public class JsonParserHelper {
|
||||
}
|
||||
return clientApplicationLocale;
|
||||
}
|
||||
|
||||
public String[] extractArrayNamed(final String parameterName, final JsonElement element, final Set<String> parametersPassedInRequest) {
|
||||
String[] arrayValue = null;
|
||||
if (element.isJsonObject()) {
|
||||
JsonObject object = element.getAsJsonObject();
|
||||
if (object.has(parameterName)) {
|
||||
parametersPassedInRequest.add(parameterName);
|
||||
JsonArray array = object.get(parameterName).getAsJsonArray();
|
||||
arrayValue = new String[array.size()];
|
||||
for (int i = 0; i < array.size(); i++) {
|
||||
arrayValue[i] = array.get(i).getAsString();
|
||||
}
|
||||
}
|
||||
}
|
||||
return arrayValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used with the local date is in array format
|
||||
@@ -447,5 +463,4 @@ public class JsonParserHelper {
|
||||
}
|
||||
return clientApplicationLocale;
|
||||
}
|
||||
|
||||
}
|
||||
+2
-2
@@ -4,8 +4,8 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.joda.time.LocalDate;
|
||||
import org.mifosng.platform.currency.domain.MonetaryCurrency;
|
||||
import org.mifosng.platform.currency.domain.Money;
|
||||
import org.mifosplatform.infrastructure.configuration.domain.MonetaryCurrency;
|
||||
import org.mifosplatform.infrastructure.configuration.domain.Money;
|
||||
|
||||
/**
|
||||
* Abstract implementation of {@link LoanRepaymentScheduleTransactionProcessor} which is more convenient for concrete implementations to extend.
|
||||
|
||||
+2
-2
@@ -3,8 +3,8 @@ package org.mifosng.platform.loan.domain;
|
||||
import java.util.List;
|
||||
|
||||
import org.joda.time.LocalDate;
|
||||
import org.mifosng.platform.currency.domain.MonetaryCurrency;
|
||||
import org.mifosng.platform.currency.domain.Money;
|
||||
import org.mifosplatform.infrastructure.configuration.domain.MonetaryCurrency;
|
||||
import org.mifosplatform.infrastructure.configuration.domain.Money;
|
||||
|
||||
/**
|
||||
* Creocore style {@link LoanRepaymentScheduleTransactionProcessor}.
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user