tidy up some bits around deposit products for example going forward.
This commit is contained in:
@@ -919,124 +919,6 @@
|
||||
</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">
|
||||
<h2 class="flybar-button">Savings</h2>
|
||||
<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.core.Context;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.UriInfo;
|
||||
|
||||
import org.mifosplatform.infrastructure.core.api.ApiParameterHelper;
|
||||
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.serialization.DefaultToApiJsonSerializer;
|
||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||
import org.mifosplatform.organisation.monetary.data.CurrencyData;
|
||||
import org.mifosplatform.organisation.monetary.service.CurrencyReadPlatformService;
|
||||
@@ -44,56 +45,66 @@ public class DepositProductsApiResource {
|
||||
|
||||
private final String entityType = "DEPOSITPRODUCT";
|
||||
|
||||
@Autowired
|
||||
private DepositProductReadPlatformService depositProductReadPlatformService;
|
||||
private final PlatformSecurityContext context;
|
||||
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
|
||||
private CurrencyReadPlatformService currencyReadPlatformService;
|
||||
|
||||
@Autowired
|
||||
private DepositProductWritePlatformService depositProductWritePlatformService;
|
||||
|
||||
@Autowired
|
||||
private PortfolioApiDataConversionService apiDataConversionService;
|
||||
|
||||
@Autowired
|
||||
private PortfolioApiJsonSerializerService apiJsonSerializerService;
|
||||
|
||||
@Autowired
|
||||
private PlatformSecurityContext context;
|
||||
public DepositProductsApiResource(final PlatformSecurityContext context,
|
||||
final DepositProductReadPlatformService depositProductReadPlatformService,
|
||||
final CurrencyReadPlatformService currencyReadPlatformService,
|
||||
final DepositProductWritePlatformService depositProductWritePlatformService,
|
||||
final PortfolioApiDataConversionService apiDataConversionService,
|
||||
final PortfolioApiJsonSerializerService apiJsonSerializerService,
|
||||
final DefaultToApiJsonSerializer<DepositProductData> toApiJsonSerializer) {
|
||||
this.context = context;
|
||||
this.depositProductReadPlatformService = depositProductReadPlatformService;
|
||||
this.currencyReadPlatformService = currencyReadPlatformService;
|
||||
this.depositProductWritePlatformService = depositProductWritePlatformService;
|
||||
this.apiDataConversionService = apiDataConversionService;
|
||||
this.apiJsonSerializerService = apiJsonSerializerService;
|
||||
this.toApiJsonSerializer = toApiJsonSerializer;
|
||||
}
|
||||
|
||||
@POST
|
||||
@Consumes({ 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);
|
||||
|
||||
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
|
||||
@Path("{productId}")
|
||||
@Consumes({ 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);
|
||||
CommandProcessingResult entityIdentifier = this.depositProductWritePlatformService.updateDepositProduct(command);
|
||||
return Response.ok().entity(entityIdentifier).build();
|
||||
final CommandProcessingResult result = this.depositProductWritePlatformService.updateDepositProduct(command);
|
||||
|
||||
return this.toApiJsonSerializer.serialize(result);
|
||||
}
|
||||
|
||||
@DELETE
|
||||
@Path("{productId}")
|
||||
@Consumes({ 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);
|
||||
|
||||
return Response.ok(new CommandProcessingResult(productId)).build();
|
||||
final CommandProcessingResult result = new CommandProcessingResultBuilder().withEntityId(productId).build();
|
||||
|
||||
return this.toApiJsonSerializer.serialize(result);
|
||||
}
|
||||
|
||||
@GET
|
||||
|
||||
+13
-3
@@ -1,6 +1,7 @@
|
||||
package org.mifosplatform.portfolio.savingsdepositproduct.service;
|
||||
|
||||
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.security.service.PlatformSecurityContext;
|
||||
import org.mifosplatform.organisation.monetary.domain.MonetaryCurrency;
|
||||
@@ -70,7 +71,9 @@ public class DepositProductWritePlatformServiceJpaRepositoryImpl implements Depo
|
||||
command.isLockinPeriodAllowed(), command.getLockinPeriod(), lockinPeriodType);
|
||||
this.depositProductRepository.save(product);
|
||||
|
||||
return new CommandProcessingResult(product.getId());
|
||||
return new CommandProcessingResultBuilder() //
|
||||
.withEntityId(product.getId()) //
|
||||
.build();
|
||||
} catch (DataIntegrityViolationException dve) {
|
||||
handleDataIntegrityIssues(command, dve);
|
||||
return new CommandProcessingResult(Long.valueOf(-1));
|
||||
@@ -101,7 +104,10 @@ public class DepositProductWritePlatformServiceJpaRepositoryImpl implements Depo
|
||||
|
||||
product.update(command, interestCompoundingFrequency, lockinPeriodType);
|
||||
this.depositProductRepository.save(product);
|
||||
return new CommandProcessingResult(Long.valueOf(product.getId()));
|
||||
|
||||
return new CommandProcessingResultBuilder() //
|
||||
.withEntityId(product.getId()) //
|
||||
.build();
|
||||
} catch (DataIntegrityViolationException dve) {
|
||||
handleDataIntegrityIssues(command, dve);
|
||||
return new CommandProcessingResult(Long.valueOf(-1));
|
||||
@@ -116,7 +122,11 @@ public class DepositProductWritePlatformServiceJpaRepositoryImpl implements Depo
|
||||
DepositProduct product = this.depositProductRepository.findOne(productId);
|
||||
if (product == null) { throw new DepositProductNotFoundException(productId); }
|
||||
product.delete();
|
||||
|
||||
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