cleaning up -MIFOSX-1877
This commit is contained in:
+22
-32
@@ -5,73 +5,63 @@
|
|||||||
*/
|
*/
|
||||||
package org.mifosplatform.integrationtests.common;
|
package org.mifosplatform.integrationtests.common;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.jayway.restassured.specification.RequestSpecification;
|
import com.jayway.restassured.specification.RequestSpecification;
|
||||||
import com.jayway.restassured.specification.ResponseSpecification;
|
import com.jayway.restassured.specification.ResponseSpecification;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
public class WorkingDaysHelper {
|
public class WorkingDaysHelper {
|
||||||
private static final String WORKINGDAYS_URL = "/mifosng-provider/api/v1/workingdays";
|
|
||||||
private static final String CREATE_HOLIDAY_URL = WORKINGDAYS_URL + "?" + Utils.TENANT_IDENTIFIER;
|
|
||||||
|
|
||||||
|
private static final String WORKINGDAYS_URL = "/mifosng-provider/api/v1/workingdays";
|
||||||
|
|
||||||
public static Object updateWorkingDays(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
|
public static Object updateWorkingDays(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
|
||||||
final String UPDATE_WORKINGDAYS_URL = WORKINGDAYS_URL +"/" +workingDaysId(requestSpec,responseSpec) + "?" + Utils.TENANT_IDENTIFIER;
|
final String UPDATE_WORKINGDAYS_URL = WORKINGDAYS_URL + "?" + Utils.TENANT_IDENTIFIER;
|
||||||
System.out.println("---------------------------------UPDATE WORKINGDAY---------------------------------------------");
|
System.out.println("---------------------------------UPDATE WORKINGDAY---------------------------------------------");
|
||||||
return Utils.performServerPut(requestSpec, responseSpec,UPDATE_WORKINGDAYS_URL, updateWorkingDaysAsJson(), "");
|
return Utils.performServerPut(requestSpec, responseSpec, UPDATE_WORKINGDAYS_URL, updateWorkingDaysAsJson(), "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Object updateWorkingDaysWithWrongRecurrence(final RequestSpecification requestSpec,
|
||||||
public static Object updateWorkingDaysWithWrongRecurrence(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,String jsonAttributeToGetback){
|
final ResponseSpecification responseSpec, String jsonAttributeToGetback) {
|
||||||
final String UPDATE_WORKINGDAYS_URL = WORKINGDAYS_URL +"/" +workingDaysId(requestSpec,responseSpec) + "?" + Utils.TENANT_IDENTIFIER;
|
final String UPDATE_WORKINGDAYS_URL = WORKINGDAYS_URL + "?" + Utils.TENANT_IDENTIFIER;
|
||||||
System.out.println("---------------------------------UPDATE WORKINGDAY WITH WRONG RECURRENCE-----------------------------------------");
|
System.out
|
||||||
return Utils.performServerPut(requestSpec, responseSpec,UPDATE_WORKINGDAYS_URL, updateWorkingDayWithWrongRecur(), jsonAttributeToGetback);
|
.println("---------------------------------UPDATE WORKINGDAY WITH WRONG RECURRENCE-----------------------------------------");
|
||||||
|
return Utils.performServerPut(requestSpec, responseSpec, UPDATE_WORKINGDAYS_URL, updateWorkingDayWithWrongRecur(),
|
||||||
|
jsonAttributeToGetback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String updateWorkingDaysAsJson() {
|
||||||
public static String updateWorkingDaysAsJson(){
|
|
||||||
final HashMap<String, Object> map = new HashMap<>();
|
final HashMap<String, Object> map = new HashMap<>();
|
||||||
map.put("recurrence", "FREQ=WEEKLY;INTERVAL=1;BYDAY=MO,TU,WE,TH");
|
map.put("recurrence", "FREQ=WEEKLY;INTERVAL=1;BYDAY=MO,TU,WE,TH");
|
||||||
map.put("locale", "en");
|
map.put("locale", "en");
|
||||||
map.put("repaymentRescheduleType", randomInt(1,4));
|
map.put("repaymentRescheduleType", randomInt(1, 4));
|
||||||
System.out.println("map : " + map);
|
System.out.println("map : " + map);
|
||||||
return new Gson().toJson(map);
|
return new Gson().toJson(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String updateWorkingDayWithWrongRecur() {
|
||||||
public static String updateWorkingDayWithWrongRecur(){
|
|
||||||
final HashMap<String, Object> map = new HashMap<>();
|
final HashMap<String, Object> map = new HashMap<>();
|
||||||
map.put("recurrence", "FREQ=WEEKLY;INTERVAL=1;BYDAY=MP,TI,TE,TH");
|
map.put("recurrence", "FREQ=WEEKLY;INTERVAL=1;BYDAY=MP,TI,TE,TH");
|
||||||
map.put("locale", "en");
|
map.put("locale", "en");
|
||||||
map.put("repaymentRescheduleType", randomInt(1,4));
|
map.put("repaymentRescheduleType", randomInt(1, 4));
|
||||||
System.out.println("map : " + map);
|
System.out.println("map : " + map);
|
||||||
return new Gson().toJson(map);
|
return new Gson().toJson(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int randomInt(int low, int high) {
|
||||||
public static int randomInt(int low, int high){
|
|
||||||
int i = new Random().nextInt(high) + low;
|
int i = new Random().nextInt(high) + low;
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int workingDaysId(final RequestSpecification requestSpec,final ResponseSpecification responseSpec){
|
public static int workingDaysId(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
|
||||||
List<HashMap<String, Object>> workingDaysId = getAllWorkingDays(requestSpec,responseSpec);
|
HashMap<String, Object> workingDays = getAllWorkingDays(requestSpec, responseSpec);
|
||||||
final HashMap<String, Object> workingDay = workingDaysId.get(0);
|
return (int) workingDays.get("id");
|
||||||
return (int) workingDay.get("id");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static HashMap<String, Object> getAllWorkingDays(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
|
||||||
|
|
||||||
public static ArrayList<HashMap<String, Object>> getAllWorkingDays(
|
return Utils.performServerGet(requestSpec, responseSpec, WORKINGDAYS_URL + "?" + Utils.TENANT_IDENTIFIER, "");
|
||||||
final RequestSpecification requestSpec,
|
|
||||||
final ResponseSpecification responseSpec) {
|
|
||||||
|
|
||||||
return Utils.performServerGet(requestSpec, responseSpec, WORKINGDAYS_URL + "?"
|
|
||||||
+ Utils.TENANT_IDENTIFIER, "");
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+14
-13
@@ -200,7 +200,7 @@ public class CommandWrapper {
|
|||||||
public boolean isUpdate() {
|
public boolean isUpdate() {
|
||||||
// permissions resource has special update which involves no resource.
|
// permissions resource has special update which involves no resource.
|
||||||
return isPermissionResource() && isUpdateOperation() || isCurrencyResource() && isUpdateOperation() || isCacheResource()
|
return isPermissionResource() && isUpdateOperation() || isCurrencyResource() && isUpdateOperation() || isCacheResource()
|
||||||
&& isUpdateOperation() || isUpdateOperation() && this.entityId != null;
|
&& isUpdateOperation() || isWorkingDaysResource() && isUpdateOperation() || isUpdateOperation() && this.entityId != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isUpdateOperation() {
|
public boolean isUpdateOperation() {
|
||||||
@@ -258,7 +258,7 @@ public class CommandWrapper {
|
|||||||
public boolean isAccountNumberFormatResource() {
|
public boolean isAccountNumberFormatResource() {
|
||||||
return this.entityName.equals(AccountNumberFormatConstants.ENTITY_NAME.toUpperCase());
|
return this.entityName.equals(AccountNumberFormatConstants.ENTITY_NAME.toUpperCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isApprove() {
|
public boolean isApprove() {
|
||||||
return this.actionName.equalsIgnoreCase("APPROVE");
|
return this.actionName.equalsIgnoreCase("APPROVE");
|
||||||
}
|
}
|
||||||
@@ -394,19 +394,19 @@ public class CommandWrapper {
|
|||||||
public boolean isLoanResource() {
|
public boolean isLoanResource() {
|
||||||
return this.entityName.equalsIgnoreCase("LOAN");
|
return this.entityName.equalsIgnoreCase("LOAN");
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isTellerResource() {
|
public boolean isTellerResource() {
|
||||||
return this.entityName.equalsIgnoreCase("TELLER");
|
return this.entityName.equalsIgnoreCase("TELLER");
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAllocateCashier() {
|
public boolean isAllocateCashier() {
|
||||||
return this.actionName.equalsIgnoreCase("ALLOCATECASHIER");
|
return this.actionName.equalsIgnoreCase("ALLOCATECASHIER");
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isUpdateCashierAllocation() {
|
public boolean isUpdateCashierAllocation() {
|
||||||
return this.actionName.equalsIgnoreCase("UPDATECASHIERALLOCATION");
|
return this.actionName.equalsIgnoreCase("UPDATECASHIERALLOCATION");
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isDeleteCashierAllocation() {
|
public boolean isDeleteCashierAllocation() {
|
||||||
return this.actionName.equalsIgnoreCase("DELETECASHIERALLOCATION");
|
return this.actionName.equalsIgnoreCase("DELETECASHIERALLOCATION");
|
||||||
}
|
}
|
||||||
@@ -414,7 +414,7 @@ public class CommandWrapper {
|
|||||||
public boolean isAllocateCashToCashier() {
|
public boolean isAllocateCashToCashier() {
|
||||||
return this.actionName.equalsIgnoreCase("ALLOCATECASHTOCASHIER");
|
return this.actionName.equalsIgnoreCase("ALLOCATECASHTOCASHIER");
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSettleCashFromCashier() {
|
public boolean isSettleCashFromCashier() {
|
||||||
return this.actionName.equalsIgnoreCase("SETTLECASHFROMCASHIER");
|
return this.actionName.equalsIgnoreCase("SETTLECASHFROMCASHIER");
|
||||||
}
|
}
|
||||||
@@ -488,13 +488,15 @@ public class CommandWrapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isUpdateDisbursementDate() {
|
public boolean isUpdateDisbursementDate() {
|
||||||
return this.actionName.equalsIgnoreCase("UPDATE") && this.entityName.equalsIgnoreCase("DISBURSEMENTDETAIL") && this.entityId != null;
|
return this.actionName.equalsIgnoreCase("UPDATE") && this.entityName.equalsIgnoreCase("DISBURSEMENTDETAIL")
|
||||||
|
&& this.entityId != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean addAndDeleteDisbursementDetails() {
|
public boolean addAndDeleteDisbursementDetails() {
|
||||||
return this.actionName.equalsIgnoreCase("UPDATE") && this.entityName.equalsIgnoreCase("DISBURSEMENTDETAIL") && this.entityId == null;
|
return this.actionName.equalsIgnoreCase("UPDATE") && this.entityName.equalsIgnoreCase("DISBURSEMENTDETAIL")
|
||||||
|
&& this.entityId == null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isStandingInstruction() {
|
public boolean isStandingInstruction() {
|
||||||
return this.entityName.equalsIgnoreCase("STANDINGINSTRUCTION");
|
return this.entityName.equalsIgnoreCase("STANDINGINSTRUCTION");
|
||||||
}
|
}
|
||||||
@@ -701,12 +703,11 @@ public class CommandWrapper {
|
|||||||
public boolean isCollectionSheetResource() {
|
public boolean isCollectionSheetResource() {
|
||||||
return this.entityName.equals("COLLECTIONSHEET");
|
return this.entityName.equals("COLLECTIONSHEET");
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSaveIndividualCollectionSheet() {
|
public boolean isSaveIndividualCollectionSheet() {
|
||||||
return isCollectionSheetResource() && this.actionName.equalsIgnoreCase("SAVE");
|
return isCollectionSheetResource() && this.actionName.equalsIgnoreCase("SAVE");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean isCenterResource() {
|
public boolean isCenterResource() {
|
||||||
return this.entityName.equalsIgnoreCase("CENTER");
|
return this.entityName.equalsIgnoreCase("CENTER");
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -2353,11 +2353,11 @@ public class CommandWrapperBuilder {
|
|||||||
this.href = "/entitytoentitymapping/" + mapId;
|
this.href = "/entitytoentitymapping/" + mapId;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
public CommandWrapperBuilder updateWorkingDays(final Long workingDaysId) {
|
|
||||||
|
public CommandWrapperBuilder updateWorkingDays() {
|
||||||
this.actionName = "UPDATE";
|
this.actionName = "UPDATE";
|
||||||
this.entityName = "WORKINGDAYS";
|
this.entityName = "WORKINGDAYS";
|
||||||
this.entityId = workingDaysId;
|
this.href = "/workingdays/";
|
||||||
this.href = "/workingdays/" + workingDaysId;
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+21
-39
@@ -5,6 +5,15 @@
|
|||||||
*/
|
*/
|
||||||
package org.mifosplatform.organisation.workingdays.api;
|
package org.mifosplatform.organisation.workingdays.api;
|
||||||
|
|
||||||
|
import javax.ws.rs.Consumes;
|
||||||
|
import javax.ws.rs.GET;
|
||||||
|
import javax.ws.rs.PUT;
|
||||||
|
import javax.ws.rs.Path;
|
||||||
|
import javax.ws.rs.Produces;
|
||||||
|
import javax.ws.rs.core.Context;
|
||||||
|
import javax.ws.rs.core.MediaType;
|
||||||
|
import javax.ws.rs.core.UriInfo;
|
||||||
|
|
||||||
import org.mifosplatform.commands.domain.CommandWrapper;
|
import org.mifosplatform.commands.domain.CommandWrapper;
|
||||||
import org.mifosplatform.commands.service.CommandWrapperBuilder;
|
import org.mifosplatform.commands.service.CommandWrapperBuilder;
|
||||||
import org.mifosplatform.commands.service.PortfolioCommandSourceWritePlatformService;
|
import org.mifosplatform.commands.service.PortfolioCommandSourceWritePlatformService;
|
||||||
@@ -19,27 +28,22 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.springframework.context.annotation.Scope;
|
import org.springframework.context.annotation.Scope;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import javax.ws.rs.*;
|
|
||||||
import javax.ws.rs.core.Context;
|
|
||||||
import javax.ws.rs.core.MediaType;
|
|
||||||
import javax.ws.rs.core.UriInfo;
|
|
||||||
import java.util.Collection;
|
|
||||||
|
|
||||||
@Path("/workingdays")
|
@Path("/workingdays")
|
||||||
@Component
|
@Component
|
||||||
@Scope("singleton")
|
@Scope("singleton")
|
||||||
public class WorkingDaysApiResource {
|
public class WorkingDaysApiResource {
|
||||||
|
|
||||||
|
|
||||||
private final DefaultToApiJsonSerializer<WorkingDaysData> toApiJsonSerializer;
|
private final DefaultToApiJsonSerializer<WorkingDaysData> toApiJsonSerializer;
|
||||||
private final WorkingDaysReadPlatformService workingDaysReadPlatformService;
|
private final WorkingDaysReadPlatformService workingDaysReadPlatformService;
|
||||||
private final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService;
|
private final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService;
|
||||||
private final PlatformSecurityContext context;
|
private final PlatformSecurityContext context;
|
||||||
private final ApiRequestParameterHelper apiRequestParameterHelper;
|
private final ApiRequestParameterHelper apiRequestParameterHelper;
|
||||||
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public WorkingDaysApiResource(DefaultToApiJsonSerializer<WorkingDaysData> toApiJsonSerializer, WorkingDaysReadPlatformService workingDaysReadPlatformService, PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService, PlatformSecurityContext context, ApiRequestParameterHelper apiRequestParameterHelper) {
|
public WorkingDaysApiResource(DefaultToApiJsonSerializer<WorkingDaysData> toApiJsonSerializer,
|
||||||
|
WorkingDaysReadPlatformService workingDaysReadPlatformService,
|
||||||
|
PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService, PlatformSecurityContext context,
|
||||||
|
ApiRequestParameterHelper apiRequestParameterHelper) {
|
||||||
this.toApiJsonSerializer = toApiJsonSerializer;
|
this.toApiJsonSerializer = toApiJsonSerializer;
|
||||||
this.workingDaysReadPlatformService = workingDaysReadPlatformService;
|
this.workingDaysReadPlatformService = workingDaysReadPlatformService;
|
||||||
this.commandsSourceWritePlatformService = commandsSourceWritePlatformService;
|
this.commandsSourceWritePlatformService = commandsSourceWritePlatformService;
|
||||||
@@ -47,63 +51,41 @@ public class WorkingDaysApiResource {
|
|||||||
this.apiRequestParameterHelper = apiRequestParameterHelper;
|
this.apiRequestParameterHelper = apiRequestParameterHelper;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@GET
|
|
||||||
@Path("{workingdaysId}")
|
|
||||||
@Consumes({ MediaType.APPLICATION_JSON })
|
|
||||||
@Produces({ MediaType.APPLICATION_JSON })
|
|
||||||
public String retrieveOne(@PathParam("workingdaysId") final Long workingDaysId, @Context final UriInfo uriInfo){
|
|
||||||
this.context.authenticatedUser().validateHasReadPermission(WorkingDaysApiConstants.WORKING_DAYS_RESOURCE_NAME);
|
|
||||||
|
|
||||||
final WorkingDaysData workingDaysData = this.workingDaysReadPlatformService.retrieveOne(workingDaysId);
|
|
||||||
|
|
||||||
final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
|
||||||
return this.toApiJsonSerializer.serialize(settings,workingDaysData);
|
|
||||||
}
|
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Consumes({ MediaType.APPLICATION_JSON })
|
@Consumes({ MediaType.APPLICATION_JSON })
|
||||||
@Produces({ MediaType.APPLICATION_JSON })
|
@Produces({ MediaType.APPLICATION_JSON })
|
||||||
public String retrieveAll(@Context final UriInfo uriInfo){
|
public String retrieveAll(@Context final UriInfo uriInfo) {
|
||||||
this.context.authenticatedUser().validateHasReadPermission(WorkingDaysApiConstants.WORKING_DAYS_RESOURCE_NAME);
|
this.context.authenticatedUser().validateHasReadPermission(WorkingDaysApiConstants.WORKING_DAYS_RESOURCE_NAME);
|
||||||
final Collection<WorkingDaysData> workingDaysData = this.workingDaysReadPlatformService.retrieveAll();
|
final WorkingDaysData workingDaysData = this.workingDaysReadPlatformService.retrieve();
|
||||||
|
|
||||||
final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
||||||
return this.toApiJsonSerializer.serialize(settings,workingDaysData);
|
return this.toApiJsonSerializer.serialize(settings, workingDaysData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@PUT
|
@PUT
|
||||||
@Path("{workingdaysId}")
|
|
||||||
@Consumes({ MediaType.APPLICATION_JSON })
|
@Consumes({ MediaType.APPLICATION_JSON })
|
||||||
@Produces({ MediaType.APPLICATION_JSON })
|
@Produces({ MediaType.APPLICATION_JSON })
|
||||||
public String update(@PathParam("workingdaysId") final Long workingDaysId,final String jsonRequestBody, @Context final UriInfo uriInfo){
|
public String update(final String jsonRequestBody) {
|
||||||
this.context.authenticatedUser().validateHasReadPermission(WorkingDaysApiConstants.WORKING_DAYS_RESOURCE_NAME);
|
|
||||||
|
|
||||||
final CommandWrapper commandRequest = new CommandWrapperBuilder().updateWorkingDays(workingDaysId).withJson(jsonRequestBody).build();
|
final CommandWrapper commandRequest = new CommandWrapperBuilder().updateWorkingDays().withJson(jsonRequestBody).build();
|
||||||
|
|
||||||
final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
|
final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
|
||||||
|
|
||||||
return this.toApiJsonSerializer.serialize(result);
|
return this.toApiJsonSerializer.serialize(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("/template")
|
@Path("/template")
|
||||||
@Consumes({ MediaType.APPLICATION_JSON })
|
@Consumes({ MediaType.APPLICATION_JSON })
|
||||||
@Produces({ MediaType.APPLICATION_JSON })
|
@Produces({ MediaType.APPLICATION_JSON })
|
||||||
public String template(@Context final UriInfo uriInfo){
|
public String template(@Context final UriInfo uriInfo) {
|
||||||
this.context.authenticatedUser().validateHasReadPermission(WorkingDaysApiConstants.WORKING_DAYS_RESOURCE_NAME);
|
this.context.authenticatedUser().validateHasReadPermission(WorkingDaysApiConstants.WORKING_DAYS_RESOURCE_NAME);
|
||||||
|
|
||||||
final WorkingDaysData repaymentRescheduleOptions = this.workingDaysReadPlatformService.repaymentRescheduleType();
|
final WorkingDaysData repaymentRescheduleOptions = this.workingDaysReadPlatformService.repaymentRescheduleType();
|
||||||
|
|
||||||
final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
||||||
return this.toApiJsonSerializer.serialize(settings,repaymentRescheduleOptions,WorkingDaysApiConstants.WORKING_DAYS_TEMPLATE_PARAMETERS);
|
return this.toApiJsonSerializer.serialize(settings, repaymentRescheduleOptions,
|
||||||
|
WorkingDaysApiConstants.WORKING_DAYS_TEMPLATE_PARAMETERS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
-3
@@ -16,7 +16,4 @@ public class WorkingDaysNotFoundException extends AbstractPlatformResourceNotFou
|
|||||||
super("error.msg.working.days.not.configured", "Must configure the Working days for the organisation.");
|
super("error.msg.working.days.not.configured", "Must configure the Working days for the organisation.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public WorkingDaysNotFoundException(Long id){
|
|
||||||
super("error.msg.workingdays.id.invalid", "Working day with identifier " + id + " does not exist", id);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
+1
-5
@@ -5,15 +5,11 @@
|
|||||||
*/
|
*/
|
||||||
package org.mifosplatform.organisation.workingdays.service;
|
package org.mifosplatform.organisation.workingdays.service;
|
||||||
|
|
||||||
|
|
||||||
import org.mifosplatform.organisation.workingdays.data.WorkingDaysData;
|
import org.mifosplatform.organisation.workingdays.data.WorkingDaysData;
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
|
|
||||||
public interface WorkingDaysReadPlatformService {
|
public interface WorkingDaysReadPlatformService {
|
||||||
|
|
||||||
Collection<WorkingDaysData> retrieveAll();
|
WorkingDaysData retrieve();
|
||||||
WorkingDaysData retrieveOne(Long id);
|
|
||||||
|
|
||||||
WorkingDaysData repaymentRescheduleType();
|
WorkingDaysData repaymentRescheduleType();
|
||||||
}
|
}
|
||||||
|
|||||||
+18
-31
@@ -5,11 +5,14 @@
|
|||||||
*/
|
*/
|
||||||
package org.mifosplatform.organisation.workingdays.service;
|
package org.mifosplatform.organisation.workingdays.service;
|
||||||
|
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
import org.mifosplatform.infrastructure.core.data.EnumOptionData;
|
import org.mifosplatform.infrastructure.core.data.EnumOptionData;
|
||||||
import org.mifosplatform.infrastructure.core.domain.JdbcSupport;
|
import org.mifosplatform.infrastructure.core.domain.JdbcSupport;
|
||||||
import org.mifosplatform.infrastructure.core.service.RoutingDataSource;
|
import org.mifosplatform.infrastructure.core.service.RoutingDataSource;
|
||||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
|
||||||
import org.mifosplatform.organisation.workingdays.data.WorkingDaysData;
|
import org.mifosplatform.organisation.workingdays.data.WorkingDaysData;
|
||||||
import org.mifosplatform.organisation.workingdays.domain.RepaymentRescheduleType;
|
import org.mifosplatform.organisation.workingdays.domain.RepaymentRescheduleType;
|
||||||
import org.mifosplatform.organisation.workingdays.domain.WorkingDaysEnumerations;
|
import org.mifosplatform.organisation.workingdays.domain.WorkingDaysEnumerations;
|
||||||
@@ -20,24 +23,16 @@ import org.springframework.jdbc.core.JdbcTemplate;
|
|||||||
import org.springframework.jdbc.core.RowMapper;
|
import org.springframework.jdbc.core.RowMapper;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.sql.ResultSet;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collection;
|
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class WorkingDaysReadPlatformServiceImpl implements WorkingDaysReadPlatformService{
|
public class WorkingDaysReadPlatformServiceImpl implements WorkingDaysReadPlatformService {
|
||||||
|
|
||||||
private final PlatformSecurityContext context;
|
|
||||||
private final JdbcTemplate jdbcTemplate;
|
private final JdbcTemplate jdbcTemplate;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public WorkingDaysReadPlatformServiceImpl(final PlatformSecurityContext context, final RoutingDataSource dataSource) {
|
public WorkingDaysReadPlatformServiceImpl(final RoutingDataSource dataSource) {
|
||||||
this.context = context;
|
|
||||||
this.jdbcTemplate = new JdbcTemplate(dataSource);
|
this.jdbcTemplate = new JdbcTemplate(dataSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static final class WorkingDaysMapper implements RowMapper<WorkingDaysData> {
|
private static final class WorkingDaysMapper implements RowMapper<WorkingDaysData> {
|
||||||
|
|
||||||
private final String schema;
|
private final String schema;
|
||||||
@@ -49,48 +44,40 @@ public class WorkingDaysReadPlatformServiceImpl implements WorkingDaysReadPlatfo
|
|||||||
|
|
||||||
this.schema = sqlBuilder.toString();
|
this.schema = sqlBuilder.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String schema() {
|
public String schema() {
|
||||||
return this.schema;
|
return this.schema;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public WorkingDaysData mapRow(ResultSet rs, int rowNum) throws SQLException {
|
public WorkingDaysData mapRow(ResultSet rs, @SuppressWarnings("unused") int rowNum) throws SQLException {
|
||||||
final Long id = rs.getLong("id");
|
final Long id = rs.getLong("id");
|
||||||
final String recurrence = rs.getString("recurrence");
|
final String recurrence = rs.getString("recurrence");
|
||||||
final Integer statusEnum = JdbcSupport.getInteger(rs, "status_enum");
|
final Integer statusEnum = JdbcSupport.getInteger(rs, "status_enum");
|
||||||
final EnumOptionData status = WorkingDaysEnumerations.workingDaysStatusType(statusEnum);
|
final EnumOptionData status = WorkingDaysEnumerations.workingDaysStatusType(statusEnum);
|
||||||
|
|
||||||
return new WorkingDaysData(id,recurrence,status);
|
return new WorkingDaysData(id, recurrence, status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<WorkingDaysData> retrieveAll() {
|
public WorkingDaysData retrieve() {
|
||||||
final WorkingDaysMapper rm = new WorkingDaysMapper();
|
|
||||||
final String sql = " select " + rm.schema() ;
|
|
||||||
return this.jdbcTemplate.query(sql, rm, new Object[] {});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public WorkingDaysData retrieveOne(final Long id) {
|
|
||||||
try {
|
try {
|
||||||
final WorkingDaysMapper rm = new WorkingDaysMapper();
|
final WorkingDaysMapper rm = new WorkingDaysMapper();
|
||||||
|
final String sql = " select " + rm.schema();
|
||||||
final String sql = " select " + rm.schema() + " where w.id = ?";
|
return this.jdbcTemplate.queryForObject(sql, rm, new Object[] {});
|
||||||
|
|
||||||
return this.jdbcTemplate.queryForObject(sql, rm, new Object[] { id });
|
|
||||||
} catch (final EmptyResultDataAccessException e) {
|
} catch (final EmptyResultDataAccessException e) {
|
||||||
throw new WorkingDaysNotFoundException(id);
|
throw new WorkingDaysNotFoundException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public WorkingDaysData repaymentRescheduleType() {
|
public WorkingDaysData repaymentRescheduleType() {
|
||||||
Collection<EnumOptionData> repaymentRescheduleOptions = Arrays.asList(WorkingDaysEnumerations.repaymentRescheduleType(RepaymentRescheduleType.SAME_DAY),
|
Collection<EnumOptionData> repaymentRescheduleOptions = Arrays.asList(
|
||||||
|
WorkingDaysEnumerations.repaymentRescheduleType(RepaymentRescheduleType.SAME_DAY),
|
||||||
WorkingDaysEnumerations.repaymentRescheduleType(RepaymentRescheduleType.MOVE_TO_NEXT_WORKING_DAY),
|
WorkingDaysEnumerations.repaymentRescheduleType(RepaymentRescheduleType.MOVE_TO_NEXT_WORKING_DAY),
|
||||||
WorkingDaysEnumerations.repaymentRescheduleType(RepaymentRescheduleType.MOVE_TO_NEXT_REPAYMENT_MEETING_DAY),
|
WorkingDaysEnumerations.repaymentRescheduleType(RepaymentRescheduleType.MOVE_TO_NEXT_REPAYMENT_MEETING_DAY),
|
||||||
WorkingDaysEnumerations.repaymentRescheduleType(RepaymentRescheduleType.MOVE_TO_PREVIOUS_WORKING_DAY)
|
WorkingDaysEnumerations.repaymentRescheduleType(RepaymentRescheduleType.MOVE_TO_PREVIOUS_WORKING_DAY));
|
||||||
);
|
return new WorkingDaysData(null, null, null, repaymentRescheduleOptions);
|
||||||
return new WorkingDaysData(null,null,null,repaymentRescheduleOptions);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Executable → Regular
+36
-36
@@ -1,36 +1,36 @@
|
|||||||
INSERT INTO `m_permission` (
|
INSERT INTO `m_permission` (
|
||||||
`grouping` ,
|
`grouping` ,
|
||||||
`code` ,
|
`code` ,
|
||||||
`entity_name` ,
|
`entity_name` ,
|
||||||
`action_name` ,
|
`action_name` ,
|
||||||
`can_maker_checker`
|
`can_maker_checker`
|
||||||
)
|
)
|
||||||
VALUES (
|
VALUES (
|
||||||
'organisation', 'READ_WORKINGDAYS', 'WORKINGDAYS', 'READ', '0'
|
'organisation', 'READ_WORKINGDAYS', 'WORKINGDAYS', 'READ', '0'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
INSERT INTO `m_permission` (
|
INSERT INTO `m_permission` (
|
||||||
`grouping` ,
|
`grouping` ,
|
||||||
`code` ,
|
`code` ,
|
||||||
`entity_name` ,
|
`entity_name` ,
|
||||||
`action_name` ,
|
`action_name` ,
|
||||||
`can_maker_checker`
|
`can_maker_checker`
|
||||||
)
|
)
|
||||||
VALUES (
|
VALUES (
|
||||||
'organisation', 'UPDATE_WORKINGDAYS', 'WORKINGDAYS', 'UPDATE', '0'
|
'organisation', 'UPDATE_WORKINGDAYS', 'WORKINGDAYS', 'UPDATE', '0'
|
||||||
);
|
);
|
||||||
|
|
||||||
INSERT INTO `m_permission` (
|
INSERT INTO `m_permission` (
|
||||||
`grouping` ,
|
`grouping` ,
|
||||||
`code` ,
|
`code` ,
|
||||||
`entity_name` ,
|
`entity_name` ,
|
||||||
`action_name` ,
|
`action_name` ,
|
||||||
`can_maker_checker`
|
`can_maker_checker`
|
||||||
)
|
)
|
||||||
VALUES (
|
VALUES (
|
||||||
'organisation', 'UPDATE_WORKINGDAYS_CHECKER', 'WORKINGDAYS', 'UPDATE_CHECKER', '0'
|
'organisation', 'UPDATE_WORKINGDAYS_CHECKER', 'WORKINGDAYS', 'UPDATE_CHECKER', '0'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user