tidy up some bits around deposit products for example going forward.
This commit is contained in:
@@ -919,124 +919,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="flybar-nav">
|
|
||||||
<h2 class="flybar-button">Account</h2>
|
|
||||||
<div id="toc-menu-account" class="flybar-menu">
|
|
||||||
<div class="tocMatrix">
|
|
||||||
<table class=matrixHeading>
|
|
||||||
<tr class="matrixHeadingBG">
|
|
||||||
<td colspan=2 valign="top"><div class="matrixHeadingVerbs">
|
|
||||||
<table>
|
|
||||||
<tr>
|
|
||||||
<td>RESOURCES</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
</div></td>
|
|
||||||
<td><table>
|
|
||||||
<tr>
|
|
||||||
<td><div class="matrixHeadingVerbs">POST</div></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td><div class=matrixHeadingCommands>create/complex
|
|
||||||
update</div></td>
|
|
||||||
</tr>
|
|
||||||
</table></td>
|
|
||||||
<td><table>
|
|
||||||
<tr>
|
|
||||||
<td><div class="matrixHeadingVerbs">GET</div></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td><div class=matrixHeadingCommands>read</div></td>
|
|
||||||
</tr>
|
|
||||||
</table></td>
|
|
||||||
<td><table>
|
|
||||||
<tr>
|
|
||||||
<td><div class="matrixHeadingVerbs">PUT</div></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td><div class=matrixHeadingCommands>update</div></td>
|
|
||||||
</tr>
|
|
||||||
</table></td>
|
|
||||||
<td><table>
|
|
||||||
<tr>
|
|
||||||
<td><div class="matrixHeadingVerbs">DELETE</div></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td><div class=matrixHeadingCommands>delete</div></td>
|
|
||||||
</tr>
|
|
||||||
</table></td>
|
|
||||||
</tr>
|
|
||||||
<tr class="alt">
|
|
||||||
<td>Not Yet Available</a></td>
|
|
||||||
<td></td>
|
|
||||||
<td></td>
|
|
||||||
<td></td>
|
|
||||||
<td></td>
|
|
||||||
<td></td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="flybar-nav">
|
|
||||||
<h2 class="flybar-button">Group</h2>
|
|
||||||
<div id="toc-menu-group" class="flybar-menu">
|
|
||||||
<div class="tocMatrix">
|
|
||||||
<table class=matrixHeading>
|
|
||||||
<tr class="matrixHeadingBG">
|
|
||||||
<td colspan=2 valign="top"><div class="matrixHeadingVerbs">
|
|
||||||
<table>
|
|
||||||
<tr>
|
|
||||||
<td>RESOURCES</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
</div></td>
|
|
||||||
<td><table>
|
|
||||||
<tr>
|
|
||||||
<td><div class="matrixHeadingVerbs">POST</div></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td><div class=matrixHeadingCommands>create/complex
|
|
||||||
update</div></td>
|
|
||||||
</tr>
|
|
||||||
</table></td>
|
|
||||||
<td><table>
|
|
||||||
<tr>
|
|
||||||
<td><div class="matrixHeadingVerbs">GET</div></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td><div class=matrixHeadingCommands>read</div></td>
|
|
||||||
</tr>
|
|
||||||
</table></td>
|
|
||||||
<td><table>
|
|
||||||
<tr>
|
|
||||||
<td><div class="matrixHeadingVerbs">PUT</div></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td><div class=matrixHeadingCommands>update</div></td>
|
|
||||||
</tr>
|
|
||||||
</table></td>
|
|
||||||
<td><table>
|
|
||||||
<tr>
|
|
||||||
<td><div class="matrixHeadingVerbs">DELETE</div></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td><div class=matrixHeadingCommands>delete</div></td>
|
|
||||||
</tr>
|
|
||||||
</table></td>
|
|
||||||
</tr>
|
|
||||||
<tr class="alt">
|
|
||||||
<td>Not Yet Available</a></td>
|
|
||||||
<td></td>
|
|
||||||
<td></td>
|
|
||||||
<td></td>
|
|
||||||
<td></td>
|
|
||||||
<td></td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="flybar-nav">
|
<div class="flybar-nav">
|
||||||
<h2 class="flybar-button">Savings</h2>
|
<h2 class="flybar-button">Savings</h2>
|
||||||
<div id="toc-menu-savings" class="flybar-menu">
|
<div id="toc-menu-savings" class="flybar-menu">
|
||||||
|
|||||||
+35
-24
@@ -16,12 +16,13 @@ import javax.ws.rs.PathParam;
|
|||||||
import javax.ws.rs.Produces;
|
import javax.ws.rs.Produces;
|
||||||
import javax.ws.rs.core.Context;
|
import javax.ws.rs.core.Context;
|
||||||
import javax.ws.rs.core.MediaType;
|
import javax.ws.rs.core.MediaType;
|
||||||
import javax.ws.rs.core.Response;
|
|
||||||
import javax.ws.rs.core.UriInfo;
|
import javax.ws.rs.core.UriInfo;
|
||||||
|
|
||||||
import org.mifosplatform.infrastructure.core.api.ApiParameterHelper;
|
import org.mifosplatform.infrastructure.core.api.ApiParameterHelper;
|
||||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||||
|
import org.mifosplatform.infrastructure.core.data.CommandProcessingResultBuilder;
|
||||||
import org.mifosplatform.infrastructure.core.data.EnumOptionData;
|
import org.mifosplatform.infrastructure.core.data.EnumOptionData;
|
||||||
|
import org.mifosplatform.infrastructure.core.serialization.DefaultToApiJsonSerializer;
|
||||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||||
import org.mifosplatform.organisation.monetary.data.CurrencyData;
|
import org.mifosplatform.organisation.monetary.data.CurrencyData;
|
||||||
import org.mifosplatform.organisation.monetary.service.CurrencyReadPlatformService;
|
import org.mifosplatform.organisation.monetary.service.CurrencyReadPlatformService;
|
||||||
@@ -44,56 +45,66 @@ public class DepositProductsApiResource {
|
|||||||
|
|
||||||
private final String entityType = "DEPOSITPRODUCT";
|
private final String entityType = "DEPOSITPRODUCT";
|
||||||
|
|
||||||
@Autowired
|
private final PlatformSecurityContext context;
|
||||||
private DepositProductReadPlatformService depositProductReadPlatformService;
|
private final DepositProductReadPlatformService depositProductReadPlatformService;
|
||||||
|
private final CurrencyReadPlatformService currencyReadPlatformService;
|
||||||
|
private final DepositProductWritePlatformService depositProductWritePlatformService;
|
||||||
|
private final PortfolioApiDataConversionService apiDataConversionService;
|
||||||
|
private final PortfolioApiJsonSerializerService apiJsonSerializerService;
|
||||||
|
private final DefaultToApiJsonSerializer<DepositProductData> toApiJsonSerializer;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private CurrencyReadPlatformService currencyReadPlatformService;
|
public DepositProductsApiResource(final PlatformSecurityContext context,
|
||||||
|
final DepositProductReadPlatformService depositProductReadPlatformService,
|
||||||
@Autowired
|
final CurrencyReadPlatformService currencyReadPlatformService,
|
||||||
private DepositProductWritePlatformService depositProductWritePlatformService;
|
final DepositProductWritePlatformService depositProductWritePlatformService,
|
||||||
|
final PortfolioApiDataConversionService apiDataConversionService,
|
||||||
@Autowired
|
final PortfolioApiJsonSerializerService apiJsonSerializerService,
|
||||||
private PortfolioApiDataConversionService apiDataConversionService;
|
final DefaultToApiJsonSerializer<DepositProductData> toApiJsonSerializer) {
|
||||||
|
this.context = context;
|
||||||
@Autowired
|
this.depositProductReadPlatformService = depositProductReadPlatformService;
|
||||||
private PortfolioApiJsonSerializerService apiJsonSerializerService;
|
this.currencyReadPlatformService = currencyReadPlatformService;
|
||||||
|
this.depositProductWritePlatformService = depositProductWritePlatformService;
|
||||||
@Autowired
|
this.apiDataConversionService = apiDataConversionService;
|
||||||
private PlatformSecurityContext context;
|
this.apiJsonSerializerService = apiJsonSerializerService;
|
||||||
|
this.toApiJsonSerializer = toApiJsonSerializer;
|
||||||
|
}
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@Consumes({ MediaType.APPLICATION_JSON })
|
@Consumes({ MediaType.APPLICATION_JSON })
|
||||||
@Produces({ MediaType.APPLICATION_JSON })
|
@Produces({ MediaType.APPLICATION_JSON })
|
||||||
public Response createDepositProduct(final String jsonRequestBody) {
|
public String createDepositProduct(final String jsonRequestBody) {
|
||||||
|
|
||||||
final DepositProductCommand command = this.apiDataConversionService.convertJsonToDepositProductCommand(null, jsonRequestBody);
|
final DepositProductCommand command = this.apiDataConversionService.convertJsonToDepositProductCommand(null, jsonRequestBody);
|
||||||
|
|
||||||
CommandProcessingResult entityIdentifier = this.depositProductWritePlatformService.createDepositProduct(command);
|
final CommandProcessingResult result = this.depositProductWritePlatformService.createDepositProduct(command);
|
||||||
|
|
||||||
return Response.ok().entity(entityIdentifier).build();
|
return this.toApiJsonSerializer.serialize(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PUT
|
@PUT
|
||||||
@Path("{productId}")
|
@Path("{productId}")
|
||||||
@Consumes({ MediaType.APPLICATION_JSON })
|
@Consumes({ MediaType.APPLICATION_JSON })
|
||||||
@Produces({ MediaType.APPLICATION_JSON })
|
@Produces({ MediaType.APPLICATION_JSON })
|
||||||
public Response updateDepositProduct(@PathParam("productId") final Long productId, final String jsonRequestBody) {
|
public String updateDepositProduct(@PathParam("productId") final Long productId, final String jsonRequestBody) {
|
||||||
|
|
||||||
final DepositProductCommand command = this.apiDataConversionService.convertJsonToDepositProductCommand(productId, jsonRequestBody);
|
final DepositProductCommand command = this.apiDataConversionService.convertJsonToDepositProductCommand(productId, jsonRequestBody);
|
||||||
CommandProcessingResult entityIdentifier = this.depositProductWritePlatformService.updateDepositProduct(command);
|
final CommandProcessingResult result = this.depositProductWritePlatformService.updateDepositProduct(command);
|
||||||
return Response.ok().entity(entityIdentifier).build();
|
|
||||||
|
return this.toApiJsonSerializer.serialize(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@DELETE
|
@DELETE
|
||||||
@Path("{productId}")
|
@Path("{productId}")
|
||||||
@Consumes({ MediaType.APPLICATION_JSON })
|
@Consumes({ MediaType.APPLICATION_JSON })
|
||||||
@Produces({ MediaType.APPLICATION_JSON })
|
@Produces({ MediaType.APPLICATION_JSON })
|
||||||
public Response deleteDepositProduct(@PathParam("productId") final Long productId) {
|
public String deleteDepositProduct(@PathParam("productId") final Long productId) {
|
||||||
|
|
||||||
this.depositProductWritePlatformService.deleteDepositProduct(productId);
|
this.depositProductWritePlatformService.deleteDepositProduct(productId);
|
||||||
|
|
||||||
return Response.ok(new CommandProcessingResult(productId)).build();
|
final CommandProcessingResult result = new CommandProcessingResultBuilder().withEntityId(productId).build();
|
||||||
|
|
||||||
|
return this.toApiJsonSerializer.serialize(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
|
|||||||
+13
-3
@@ -1,6 +1,7 @@
|
|||||||
package org.mifosplatform.portfolio.savingsdepositproduct.service;
|
package org.mifosplatform.portfolio.savingsdepositproduct.service;
|
||||||
|
|
||||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||||
|
import org.mifosplatform.infrastructure.core.data.CommandProcessingResultBuilder;
|
||||||
import org.mifosplatform.infrastructure.core.exception.PlatformDataIntegrityException;
|
import org.mifosplatform.infrastructure.core.exception.PlatformDataIntegrityException;
|
||||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||||
import org.mifosplatform.organisation.monetary.domain.MonetaryCurrency;
|
import org.mifosplatform.organisation.monetary.domain.MonetaryCurrency;
|
||||||
@@ -70,7 +71,9 @@ public class DepositProductWritePlatformServiceJpaRepositoryImpl implements Depo
|
|||||||
command.isLockinPeriodAllowed(), command.getLockinPeriod(), lockinPeriodType);
|
command.isLockinPeriodAllowed(), command.getLockinPeriod(), lockinPeriodType);
|
||||||
this.depositProductRepository.save(product);
|
this.depositProductRepository.save(product);
|
||||||
|
|
||||||
return new CommandProcessingResult(product.getId());
|
return new CommandProcessingResultBuilder() //
|
||||||
|
.withEntityId(product.getId()) //
|
||||||
|
.build();
|
||||||
} catch (DataIntegrityViolationException dve) {
|
} catch (DataIntegrityViolationException dve) {
|
||||||
handleDataIntegrityIssues(command, dve);
|
handleDataIntegrityIssues(command, dve);
|
||||||
return new CommandProcessingResult(Long.valueOf(-1));
|
return new CommandProcessingResult(Long.valueOf(-1));
|
||||||
@@ -101,7 +104,10 @@ public class DepositProductWritePlatformServiceJpaRepositoryImpl implements Depo
|
|||||||
|
|
||||||
product.update(command, interestCompoundingFrequency, lockinPeriodType);
|
product.update(command, interestCompoundingFrequency, lockinPeriodType);
|
||||||
this.depositProductRepository.save(product);
|
this.depositProductRepository.save(product);
|
||||||
return new CommandProcessingResult(Long.valueOf(product.getId()));
|
|
||||||
|
return new CommandProcessingResultBuilder() //
|
||||||
|
.withEntityId(product.getId()) //
|
||||||
|
.build();
|
||||||
} catch (DataIntegrityViolationException dve) {
|
} catch (DataIntegrityViolationException dve) {
|
||||||
handleDataIntegrityIssues(command, dve);
|
handleDataIntegrityIssues(command, dve);
|
||||||
return new CommandProcessingResult(Long.valueOf(-1));
|
return new CommandProcessingResult(Long.valueOf(-1));
|
||||||
@@ -116,7 +122,11 @@ public class DepositProductWritePlatformServiceJpaRepositoryImpl implements Depo
|
|||||||
DepositProduct product = this.depositProductRepository.findOne(productId);
|
DepositProduct product = this.depositProductRepository.findOne(productId);
|
||||||
if (product == null) { throw new DepositProductNotFoundException(productId); }
|
if (product == null) { throw new DepositProductNotFoundException(productId); }
|
||||||
product.delete();
|
product.delete();
|
||||||
|
|
||||||
this.depositProductRepository.save(product);
|
this.depositProductRepository.save(product);
|
||||||
return new CommandProcessingResult(Long.valueOf(product.getId()));
|
|
||||||
|
return new CommandProcessingResultBuilder() //
|
||||||
|
.withEntityId(product.getId()) //
|
||||||
|
.build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user