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