remove formatted from openingDate parameter for office creation and update.
This commit is contained in:
+2
-2
@@ -246,8 +246,8 @@
|
|||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
<input type="hidden" id="dateFormat" name="dateFormat" value="dd MMMM yyyy" />
|
<input type="hidden" id="dateFormat" name="dateFormat" value="dd MMMM yyyy" />
|
||||||
<label for="openingDateFormatted"><spring:message code="form.label.office.openedon"/></label>
|
<label for="openingDate"><spring:message code="form.label.office.openedon"/></label>
|
||||||
<input id="openingDateFormatted" name="openingDateFormatted" title="" type="text" value="{{=$ctx.globalDate(openingDate)}}" size="75" class="datepickerfield" />
|
<input id="openingDate" name="openingDate" title="" type="text" value="{{=$ctx.globalDate(openingDate)}}" size="75" class="datepickerfield" />
|
||||||
|
|
||||||
<label for="externalId"><spring:message code="form.label.office.externalid"/></label>
|
<label for="externalId"><spring:message code="form.label.office.externalid"/></label>
|
||||||
<input id="externalId" name="externalId" title="" type="text" value="{{=externalId}}" size="75"/>
|
<input id="externalId" name="externalId" title="" type="text" value="{{=externalId}}" size="75"/>
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import javax.ws.rs.core.UriInfo;
|
|||||||
import org.joda.time.LocalDate;
|
import org.joda.time.LocalDate;
|
||||||
import org.mifosng.data.EntityIdentifier;
|
import org.mifosng.data.EntityIdentifier;
|
||||||
import org.mifosng.data.OfficeData;
|
import org.mifosng.data.OfficeData;
|
||||||
import org.mifosng.data.command.OfficeCommand;
|
import org.mifosng.platform.api.commands.OfficeCommand;
|
||||||
import org.mifosng.platform.api.infrastructure.ApiDataConversionService;
|
import org.mifosng.platform.api.infrastructure.ApiDataConversionService;
|
||||||
import org.mifosng.platform.api.infrastructure.ApiJSONFormattingService;
|
import org.mifosng.platform.api.infrastructure.ApiJSONFormattingService;
|
||||||
import org.mifosng.platform.organisation.service.OfficeReadPlatformService;
|
import org.mifosng.platform.organisation.service.OfficeReadPlatformService;
|
||||||
@@ -80,10 +80,10 @@ public class OfficeApiResource {
|
|||||||
@Produces({ MediaType.APPLICATION_JSON })
|
@Produces({ MediaType.APPLICATION_JSON })
|
||||||
public Response createOffice(final OfficeCommand command) {
|
public Response createOffice(final OfficeCommand command) {
|
||||||
|
|
||||||
LocalDate openingDate = apiDataConversionService.convertFrom(
|
LocalDate openingLocalDate = apiDataConversionService.convertFrom(
|
||||||
command.getOpeningDateFormatted(), "openingDateFormatted",
|
command.getOpeningDate(), "openingDate",
|
||||||
command.getDateFormat());
|
command.getDateFormat());
|
||||||
command.setOpeningDate(openingDate);
|
command.setOpeningLocalDate(openingLocalDate);
|
||||||
|
|
||||||
Long officeId = this.writePlatformService.createOffice(command);
|
Long officeId = this.writePlatformService.createOffice(command);
|
||||||
|
|
||||||
@@ -115,10 +115,10 @@ public class OfficeApiResource {
|
|||||||
public Response updateOffice(@PathParam("officeId") final Long officeId,
|
public Response updateOffice(@PathParam("officeId") final Long officeId,
|
||||||
final OfficeCommand command) {
|
final OfficeCommand command) {
|
||||||
|
|
||||||
LocalDate openingDate = apiDataConversionService.convertFrom(
|
LocalDate openingLocalDate = apiDataConversionService.convertFrom(
|
||||||
command.getOpeningDateFormatted(), "openingDateFormatted",
|
command.getOpeningDate(), "openingDate",
|
||||||
command.getDateFormat());
|
command.getDateFormat());
|
||||||
command.setOpeningDate(openingDate);
|
command.setOpeningLocalDate(openingLocalDate);
|
||||||
command.setId(officeId);
|
command.setId(officeId);
|
||||||
|
|
||||||
Long entityId = this.writePlatformService.updateOffice(command);
|
Long entityId = this.writePlatformService.updateOffice(command);
|
||||||
|
|||||||
+21
-21
@@ -1,4 +1,4 @@
|
|||||||
package org.mifosng.data.command;
|
package org.mifosng.platform.api.commands;
|
||||||
|
|
||||||
import javax.xml.bind.annotation.XmlRootElement;
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
|
||||||
@@ -15,8 +15,8 @@ public class OfficeCommand {
|
|||||||
private String externalId;
|
private String externalId;
|
||||||
|
|
||||||
private String dateFormat;
|
private String dateFormat;
|
||||||
private String openingDateFormatted;
|
private String openingDate;
|
||||||
private LocalDate openingDate;
|
private LocalDate openingLocalDate;
|
||||||
|
|
||||||
private Long parentId;
|
private Long parentId;
|
||||||
private Boolean rootOffice = false;
|
private Boolean rootOffice = false;
|
||||||
@@ -30,7 +30,7 @@ public class OfficeCommand {
|
|||||||
this.name = officeName;
|
this.name = officeName;
|
||||||
this.externalId = externalId;
|
this.externalId = externalId;
|
||||||
this.parentId = parentId;
|
this.parentId = parentId;
|
||||||
this.openingDate = openingDate;
|
this.openingLocalDate = openingDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public OfficeCommand(final Long id, final String officeName,
|
public OfficeCommand(final Long id, final String officeName,
|
||||||
@@ -40,15 +40,7 @@ public class OfficeCommand {
|
|||||||
this.name = officeName;
|
this.name = officeName;
|
||||||
this.externalId = externalId;
|
this.externalId = externalId;
|
||||||
this.parentId = parentId;
|
this.parentId = parentId;
|
||||||
this.openingDate = openingDate;
|
this.openingLocalDate = openingDate;
|
||||||
}
|
|
||||||
|
|
||||||
public LocalDate getOpeningDate() {
|
|
||||||
return this.openingDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setOpeningDate(final LocalDate openingDate) {
|
|
||||||
this.openingDate = openingDate;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
@@ -91,14 +83,6 @@ public class OfficeCommand {
|
|||||||
this.dateFormat = dateFormat;
|
this.dateFormat = dateFormat;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getOpeningDateFormatted() {
|
|
||||||
return openingDateFormatted;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setOpeningDateFormatted(String openingDateFormatted) {
|
|
||||||
this.openingDateFormatted = openingDateFormatted;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isRootOffice() {
|
public boolean isRootOffice() {
|
||||||
return rootOffice;
|
return rootOffice;
|
||||||
}
|
}
|
||||||
@@ -106,4 +90,20 @@ public class OfficeCommand {
|
|||||||
public void setRootOffice(boolean rootOffice) {
|
public void setRootOffice(boolean rootOffice) {
|
||||||
this.rootOffice = rootOffice;
|
this.rootOffice = rootOffice;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getOpeningDate() {
|
||||||
|
return openingDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOpeningDate(String openingDate) {
|
||||||
|
this.openingDate = openingDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalDate getOpeningLocalDate() {
|
||||||
|
return openingLocalDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOpeningLocalDate(LocalDate openingLocalDate) {
|
||||||
|
this.openingLocalDate = openingLocalDate;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -17,7 +17,7 @@ import javax.persistence.UniqueConstraint;
|
|||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.joda.time.LocalDate;
|
import org.joda.time.LocalDate;
|
||||||
import org.mifosng.data.command.OfficeCommand;
|
import org.mifosng.platform.api.commands.OfficeCommand;
|
||||||
import org.mifosng.platform.infrastructure.AbstractAuditableCustom;
|
import org.mifosng.platform.infrastructure.AbstractAuditableCustom;
|
||||||
import org.mifosng.platform.user.domain.AppUser;
|
import org.mifosng.platform.user.domain.AppUser;
|
||||||
|
|
||||||
@@ -115,7 +115,7 @@ public class Office extends AbstractAuditableCustom<AppUser, Long> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (command.getOpeningDate() != null) {
|
if (command.getOpeningDate() != null) {
|
||||||
this.openingDate = command.getOpeningDate().toDate();
|
this.openingDate = command.getOpeningLocalDate().toDate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+4
-4
@@ -4,8 +4,8 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.mifosng.data.ApiParameterError;
|
import org.mifosng.data.ApiParameterError;
|
||||||
import org.mifosng.data.command.OfficeCommand;
|
|
||||||
import org.mifosng.platform.DataValidatorBuilder;
|
import org.mifosng.platform.DataValidatorBuilder;
|
||||||
|
import org.mifosng.platform.api.commands.OfficeCommand;
|
||||||
import org.mifosng.platform.exceptions.PlatformApiDataValidationException;
|
import org.mifosng.platform.exceptions.PlatformApiDataValidationException;
|
||||||
|
|
||||||
public class OfficeCommandValidator {
|
public class OfficeCommandValidator {
|
||||||
@@ -23,7 +23,7 @@ public class OfficeCommandValidator {
|
|||||||
DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors).resource("office");
|
DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors).resource("office");
|
||||||
|
|
||||||
baseDataValidator.reset().parameter("name").value(command.getName()).notBlank();
|
baseDataValidator.reset().parameter("name").value(command.getName()).notBlank();
|
||||||
baseDataValidator.reset().parameter("openingDateFormatted").value(command.getOpeningDateFormatted()).notBlank();
|
baseDataValidator.reset().parameter("openingDate").value(command.getOpeningDate()).notBlank();
|
||||||
baseDataValidator.reset().parameter("externalId").value(command.getExternalId()).notExceedingLengthOf(100);
|
baseDataValidator.reset().parameter("externalId").value(command.getExternalId()).notExceedingLengthOf(100);
|
||||||
baseDataValidator.reset().parameter("parentId").value(command.getParentId()).notNull().greaterThanZero();
|
baseDataValidator.reset().parameter("parentId").value(command.getParentId()).notNull().greaterThanZero();
|
||||||
|
|
||||||
@@ -39,11 +39,11 @@ public class OfficeCommandValidator {
|
|||||||
|
|
||||||
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("openingDateFormatted").value(command.getOpeningDateFormatted()).ignoreIfNull().notBlank();
|
baseDataValidator.reset().parameter("openingDate").value(command.getOpeningDate()).ignoreIfNull().notBlank();
|
||||||
baseDataValidator.reset().parameter("externalId").value(command.getExternalId()).ignoreIfNull().notExceedingLengthOf(100);
|
baseDataValidator.reset().parameter("externalId").value(command.getExternalId()).ignoreIfNull().notExceedingLengthOf(100);
|
||||||
baseDataValidator.reset().parameter("parentId").value(command.getParentId()).ignoreIfNull().notNull().greaterThanZero();
|
baseDataValidator.reset().parameter("parentId").value(command.getParentId()).ignoreIfNull().notNull().greaterThanZero();
|
||||||
|
|
||||||
baseDataValidator.reset().anyOfNotNull(command.getName(), command.getOpeningDateFormatted(), command.getExternalId(), command.getParentId());
|
baseDataValidator.reset().anyOfNotNull(command.getName(), command.getOpeningDate(), command.getExternalId(), command.getParentId());
|
||||||
|
|
||||||
if (!dataValidationErrors.isEmpty()) {
|
if (!dataValidationErrors.isEmpty()) {
|
||||||
throw new PlatformApiDataValidationException("validation.msg.validation.errors.exist", "Validation errors exist.", dataValidationErrors);
|
throw new PlatformApiDataValidationException("validation.msg.validation.errors.exist", "Validation errors exist.", dataValidationErrors);
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
package org.mifosng.platform.organisation.service;
|
package org.mifosng.platform.organisation.service;
|
||||||
|
|
||||||
import org.mifosng.data.command.OfficeCommand;
|
import org.mifosng.platform.api.commands.OfficeCommand;
|
||||||
|
|
||||||
public interface OfficeWritePlatformService {
|
public interface OfficeWritePlatformService {
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -2,7 +2,7 @@ package org.mifosng.platform.organisation.service;
|
|||||||
|
|
||||||
import static org.mifosng.platform.Specifications.officesThatMatch;
|
import static org.mifosng.platform.Specifications.officesThatMatch;
|
||||||
|
|
||||||
import org.mifosng.data.command.OfficeCommand;
|
import org.mifosng.platform.api.commands.OfficeCommand;
|
||||||
import org.mifosng.platform.exceptions.NoAuthorizationException;
|
import org.mifosng.platform.exceptions.NoAuthorizationException;
|
||||||
import org.mifosng.platform.exceptions.OfficeNotFoundException;
|
import org.mifosng.platform.exceptions.OfficeNotFoundException;
|
||||||
import org.mifosng.platform.exceptions.PlatformDataIntegrityException;
|
import org.mifosng.platform.exceptions.PlatformDataIntegrityException;
|
||||||
@@ -47,7 +47,7 @@ public class OfficeWritePlatformServiceJpaRepositoryImpl implements OfficeWriteP
|
|||||||
throw new OfficeNotFoundException(command.getParentId());
|
throw new OfficeNotFoundException(command.getParentId());
|
||||||
}
|
}
|
||||||
|
|
||||||
Office office = Office.createNew(currentUser.getOrganisation(), parent, command.getName(), command.getOpeningDate(), command.getExternalId());
|
Office office = Office.createNew(currentUser.getOrganisation(), parent, command.getName(), command.getOpeningLocalDate(), command.getExternalId());
|
||||||
|
|
||||||
// pre save to generate id for use in office hierarchy
|
// pre save to generate id for use in office hierarchy
|
||||||
this.officeRepository.save(office);
|
this.officeRepository.save(office);
|
||||||
|
|||||||
Reference in New Issue
Block a user