minor changes after madhukar pull-request, nothing of note.
This commit is contained in:
+1
-3
@@ -80,7 +80,7 @@ public class SavingProductsApiResource {
|
|||||||
|
|
||||||
Collection<SavingProductData> products = this.savingProductReadPlatformService.retrieveAllSavingProducts();
|
Collection<SavingProductData> products = this.savingProductReadPlatformService.retrieveAllSavingProducts();
|
||||||
|
|
||||||
return this.apiDataConversionService.convertSavingProductDataToJson(prettyPrint, responseParameters, products.toArray(new SavingProductData[products.size()]));
|
return this.apiDataConversionService.convertSavingProductDataToJson(prettyPrint, responseParameters, products.toArray(new SavingProductData[products.size()]));
|
||||||
}
|
}
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@@ -122,6 +122,4 @@ public class SavingProductsApiResource {
|
|||||||
|
|
||||||
return this.apiDataConversionService.convertSavingProductDataToJson(prettyPrint, responseParameters, savingProduct);
|
return this.apiDataConversionService.convertSavingProductDataToJson(prettyPrint, responseParameters, savingProduct);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
+1
-2
@@ -1341,8 +1341,7 @@ public class ApiDataConversionServiceImpl implements ApiDataConversionService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SavingProductCommand convertJsonToSavingProductCommand(
|
public SavingProductCommand convertJsonToSavingProductCommand(final Long resourceIdentifier, final String json) {
|
||||||
final Long resourceIdentifier, final String json) {
|
|
||||||
|
|
||||||
if (StringUtils.isBlank(json)) {
|
if (StringUtils.isBlank(json)) {
|
||||||
throw new InvalidJsonException();
|
throw new InvalidJsonException();
|
||||||
|
|||||||
+4
-17
@@ -13,15 +13,16 @@ import org.mifosng.platform.user.domain.AppUser;
|
|||||||
@Table(name = "portfolio_product_savings")
|
@Table(name = "portfolio_product_savings")
|
||||||
public class SavingProduct extends AbstractAuditableCustom<AppUser, Long> {
|
public class SavingProduct extends AbstractAuditableCustom<AppUser, Long> {
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
@Column(name = "name", nullable = false)
|
@Column(name = "name", nullable = false)
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
@Column(name = "description")
|
@Column(name = "description")
|
||||||
private String description;
|
private String description;
|
||||||
|
|
||||||
public SavingProduct() {
|
protected SavingProduct() {
|
||||||
this.name = null;
|
//
|
||||||
this.description = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public SavingProduct(final String name, final String description) {
|
public SavingProduct(final String name, final String description) {
|
||||||
@@ -33,18 +34,6 @@ public class SavingProduct extends AbstractAuditableCustom<AppUser, Long> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return this.name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDescription() {
|
|
||||||
return this.description;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean identifiedBy(final String identifier) {
|
|
||||||
return identifier.equalsIgnoreCase(this.name);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void update(final SavingProductCommand command) {
|
public void update(final SavingProductCommand command) {
|
||||||
|
|
||||||
if (command.isNameChanged()) {
|
if (command.isNameChanged()) {
|
||||||
@@ -54,7 +43,5 @@ public class SavingProduct extends AbstractAuditableCustom<AppUser, Long> {
|
|||||||
if (command.isDescriptionChanged()) {
|
if (command.isDescriptionChanged()) {
|
||||||
this.description = command.getDescription();
|
this.description = command.getDescription();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
+4
-2
@@ -12,14 +12,15 @@ public class SavingProductCommandValidator {
|
|||||||
|
|
||||||
private final SavingProductCommand command;
|
private final SavingProductCommand command;
|
||||||
|
|
||||||
public SavingProductCommandValidator(SavingProductCommand command) {
|
public SavingProductCommandValidator(final SavingProductCommand command) {
|
||||||
this.command=command;
|
this.command=command;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void validateForUpdate() {
|
public void validateForUpdate() {
|
||||||
|
|
||||||
List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>();
|
List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>();
|
||||||
|
|
||||||
DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors).resource("product");
|
DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors).resource("savingsproduct");
|
||||||
baseDataValidator.reset().parameter("id").value(command.getId()).notNull();
|
baseDataValidator.reset().parameter("id").value(command.getId()).notNull();
|
||||||
baseDataValidator.reset().parameter("name").value(command.getName()).ignoreIfNull().notBlank();
|
baseDataValidator.reset().parameter("name").value(command.getName()).ignoreIfNull().notBlank();
|
||||||
baseDataValidator.reset().parameter("description").value(command.getDescription()).ignoreIfNull().notExceedingLengthOf(500);
|
baseDataValidator.reset().parameter("description").value(command.getDescription()).ignoreIfNull().notExceedingLengthOf(500);
|
||||||
@@ -29,6 +30,7 @@ public class SavingProductCommandValidator {
|
|||||||
throw new PlatformApiDataValidationException("validation.msg.validation.errors.exist", "Validation errors exist.", dataValidationErrors);
|
throw new PlatformApiDataValidationException("validation.msg.validation.errors.exist", "Validation errors exist.", dataValidationErrors);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void validateForCreate() {
|
public void validateForCreate() {
|
||||||
|
|
||||||
List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>();
|
List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>();
|
||||||
|
|||||||
+3
-4
@@ -24,20 +24,20 @@ public class SavingProductWritePlatformServiceJpaRepositoryImpl implements Savin
|
|||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
@Override
|
@Override
|
||||||
public EntityIdentifier createSavingProduct(SavingProductCommand command) {
|
public EntityIdentifier createSavingProduct(final SavingProductCommand command) {
|
||||||
|
|
||||||
this.context.authenticatedUser();
|
this.context.authenticatedUser();
|
||||||
SavingProductCommandValidator validator=new SavingProductCommandValidator(command);
|
SavingProductCommandValidator validator=new SavingProductCommandValidator(command);
|
||||||
validator.validateForCreate();
|
validator.validateForCreate();
|
||||||
|
|
||||||
SavingProduct product= new SavingProduct(command.getName(),command.getDescription());
|
SavingProduct product = new SavingProduct(command.getName(),command.getDescription());
|
||||||
this.savingProductRepository.save(product);
|
this.savingProductRepository.save(product);
|
||||||
return new EntityIdentifier(product.getId());
|
return new EntityIdentifier(product.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
@Override
|
@Override
|
||||||
public EntityIdentifier updateSavingProduct(SavingProductCommand command) {
|
public EntityIdentifier updateSavingProduct(final SavingProductCommand command) {
|
||||||
|
|
||||||
this.context.authenticatedUser();
|
this.context.authenticatedUser();
|
||||||
SavingProductCommandValidator validator=new SavingProductCommandValidator(command);
|
SavingProductCommandValidator validator=new SavingProductCommandValidator(command);
|
||||||
@@ -51,5 +51,4 @@ public class SavingProductWritePlatformServiceJpaRepositoryImpl implements Savin
|
|||||||
this.savingProductRepository.save(product);
|
this.savingProductRepository.save(product);
|
||||||
return new EntityIdentifier(Long.valueOf(product.getId()));
|
return new EntityIdentifier(Long.valueOf(product.getId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user