convert all Java files from DOS to UNIX line ending (FINERACT-821)

find . -type f -name "*.java" -exec dos2unix '{}' ';'
This commit is contained in:
Michael Vorburger
2020-01-19 19:58:21 +01:00
committed by Michael Vorburger ⛑️
parent 125924303b
commit 68006ae8f2
13 changed files with 871 additions and 871 deletions
@@ -1,70 +1,70 @@
/** /**
* Licensed to the Apache Software Foundation (ASF) under one * Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file * or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information * distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file * regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the * to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance * "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at * with the License. You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, * Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an * software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the * KIND, either express or implied. See the License for the
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
package org.apache.fineract.integrationtests; package org.apache.fineract.integrationtests;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import org.apache.fineract.integrationtests.common.CommonConstants; import org.apache.fineract.integrationtests.common.CommonConstants;
import org.apache.fineract.integrationtests.common.Utils; import org.apache.fineract.integrationtests.common.Utils;
import org.apache.fineract.integrationtests.common.WorkingDaysHelper; import org.apache.fineract.integrationtests.common.WorkingDaysHelper;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import com.jayway.restassured.builder.RequestSpecBuilder; import com.jayway.restassured.builder.RequestSpecBuilder;
import com.jayway.restassured.builder.ResponseSpecBuilder; import com.jayway.restassured.builder.ResponseSpecBuilder;
import com.jayway.restassured.http.ContentType; import com.jayway.restassured.http.ContentType;
import com.jayway.restassured.specification.RequestSpecification; import com.jayway.restassured.specification.RequestSpecification;
import com.jayway.restassured.specification.ResponseSpecification; import com.jayway.restassured.specification.ResponseSpecification;
@SuppressWarnings({ "rawtypes", "unchecked" }) @SuppressWarnings({ "rawtypes", "unchecked" })
public class WorkingDaysTest { public class WorkingDaysTest {
private ResponseSpecification responseSpec; private ResponseSpecification responseSpec;
private RequestSpecification requestSpec; private RequestSpecification requestSpec;
private ResponseSpecification generalResponseSpec; private ResponseSpecification generalResponseSpec;
@Before @Before
public void setUp() { public void setUp() {
Utils.initializeRESTAssured(); Utils.initializeRESTAssured();
this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build(); this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey()); this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build(); this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
this.generalResponseSpec = new ResponseSpecBuilder().build(); this.generalResponseSpec = new ResponseSpecBuilder().build();
} }
@Test @Test
public void updateWorkingDays() { public void updateWorkingDays() {
HashMap response = (HashMap) WorkingDaysHelper.updateWorkingDays(requestSpec, responseSpec); HashMap response = (HashMap) WorkingDaysHelper.updateWorkingDays(requestSpec, responseSpec);
Assert.assertNotNull(response.get("resourceId")); Assert.assertNotNull(response.get("resourceId"));
} }
@Test @Test
public void updateWorkingDaysWithWrongRecurrencePattern() { public void updateWorkingDaysWithWrongRecurrencePattern() {
final List<HashMap> error = (List) WorkingDaysHelper.updateWorkingDaysWithWrongRecurrence(requestSpec, generalResponseSpec, final List<HashMap> error = (List) WorkingDaysHelper.updateWorkingDaysWithWrongRecurrence(requestSpec, generalResponseSpec,
CommonConstants.RESPONSE_ERROR); CommonConstants.RESPONSE_ERROR);
assertEquals("Verify wrong recurrence pattern error", "error.msg.recurring.rule.parsing.error", assertEquals("Verify wrong recurrence pattern error", "error.msg.recurring.rule.parsing.error",
error.get(0).get("userMessageGlobalisationCode")); error.get(0).get("userMessageGlobalisationCode"));
} }
} }
@@ -1,78 +1,78 @@
/** /**
* Licensed to the Apache Software Foundation (ASF) under one * Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file * or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information * distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file * regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the * to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance * "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at * with the License. You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, * Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an * software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the * KIND, either express or implied. See the License for the
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
package org.apache.fineract.integrationtests.common; package org.apache.fineract.integrationtests.common;
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.HashMap; import java.util.HashMap;
import java.util.Random; import java.util.Random;
public class WorkingDaysHelper { public class WorkingDaysHelper {
private static final String WORKINGDAYS_URL = "/fineract-provider/api/v1/workingdays"; private static final String WORKINGDAYS_URL = "/fineract-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 + "?" + 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 + "?" + Utils.TENANT_IDENTIFIER; final String UPDATE_WORKINGDAYS_URL = WORKINGDAYS_URL + "?" + Utils.TENANT_IDENTIFIER;
System.out System.out
.println("---------------------------------UPDATE WORKINGDAY WITH WRONG RECURRENCE-----------------------------------------"); .println("---------------------------------UPDATE WORKINGDAY WITH WRONG RECURRENCE-----------------------------------------");
return Utils.performServerPut(requestSpec, responseSpec, UPDATE_WORKINGDAYS_URL, updateWorkingDayWithWrongRecur(), return Utils.performServerPut(requestSpec, responseSpec, UPDATE_WORKINGDAYS_URL, updateWorkingDayWithWrongRecur(),
jsonAttributeToGetback); 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,FR,SA,SU"); map.put("recurrence", "FREQ=WEEKLY;INTERVAL=1;BYDAY=MO,TU,WE,TH,FR,SA,SU");
map.put("locale", "en"); map.put("locale", "en");
map.put("repaymentRescheduleType", new Random().nextInt(4) + 1); map.put("repaymentRescheduleType", new Random().nextInt(4) + 1);
map.put("extendTermForDailyRepayments", false); map.put("extendTermForDailyRepayments", false);
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", new Random().nextInt(4) + 1); map.put("repaymentRescheduleType", new Random().nextInt(4) + 1);
map.put("extendTermForDailyRepayments", false); map.put("extendTermForDailyRepayments", false);
System.out.println("map : " + map); System.out.println("map : " + map);
return new Gson().toJson(map); return new Gson().toJson(map);
} }
public static int workingDaysId(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) { public static int workingDaysId(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
HashMap<String, Object> workingDays = getAllWorkingDays(requestSpec, responseSpec); HashMap<String, Object> workingDays = getAllWorkingDays(requestSpec, responseSpec);
return (int) workingDays.get("id"); return (int) workingDays.get("id");
} }
public static HashMap<String, Object> getAllWorkingDays(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) { public static HashMap<String, Object> getAllWorkingDays(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
return Utils.performServerGet(requestSpec, responseSpec, WORKINGDAYS_URL + "?" + Utils.TENANT_IDENTIFIER, ""); return Utils.performServerGet(requestSpec, responseSpec, WORKINGDAYS_URL + "?" + Utils.TENANT_IDENTIFIER, "");
} }
} }
@@ -1,31 +1,31 @@
/** /**
* Licensed to the Apache Software Foundation (ASF) under one * Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file * or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information * distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file * regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the * to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance * "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at * with the License. You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, * Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an * software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the * KIND, either express or implied. See the License for the
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
package org.apache.fineract.infrastructure.documentmanagement.exception; package org.apache.fineract.infrastructure.documentmanagement.exception;
import org.apache.fineract.infrastructure.core.exception.AbstractPlatformResourceNotFoundException; import org.apache.fineract.infrastructure.core.exception.AbstractPlatformResourceNotFoundException;
/** /**
* Runtime exception for invalid image types * Runtime exception for invalid image types
*/ */
public class InvalidEntityTypeForImageManagementException extends AbstractPlatformResourceNotFoundException { public class InvalidEntityTypeForImageManagementException extends AbstractPlatformResourceNotFoundException {
public InvalidEntityTypeForImageManagementException(String imageType) { public InvalidEntityTypeForImageManagementException(String imageType) {
super("error.imagemanagement.entitytype.invalid", "Image Management is not support for the Entity Type: " + imageType); super("error.imagemanagement.entitytype.invalid", "Image Management is not support for the Entity Type: " + imageType);
} }
} }
@@ -1,47 +1,47 @@
/** /**
* Licensed to the Apache Software Foundation (ASF) under one * Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file * or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information * distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file * regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the * to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance * "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at * with the License. You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, * Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an * software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the * KIND, either express or implied. See the License for the
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
package org.apache.fineract.organisation.workingdays.api; package org.apache.fineract.organisation.workingdays.api;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
public class WorkingDaysApiConstants { public class WorkingDaysApiConstants {
public static final String WORKING_DAYS_RESOURCE_NAME = "workingdays"; public static final String WORKING_DAYS_RESOURCE_NAME = "workingdays";
// request parameters // request parameters
public static final String recurrence = "recurrence"; public static final String recurrence = "recurrence";
public static final String repayment_rescheduling_enum = "repaymentRescheduleType"; public static final String repayment_rescheduling_enum = "repaymentRescheduleType";
public static final String idParamName = "id"; public static final String idParamName = "id";
public static final String rescheduleRepaymentTemplate = "rescheduleRepaymentTemplate"; public static final String rescheduleRepaymentTemplate = "rescheduleRepaymentTemplate";
public static final String localeParamName = "locale"; public static final String localeParamName = "locale";
public static final String extendTermForDailyRepayments = "extendTermForDailyRepayments"; public static final String extendTermForDailyRepayments = "extendTermForDailyRepayments";
public static final String extendTermForRepaymentsOnHolidays = "extendTermForRepaymentsOnHolidays"; public static final String extendTermForRepaymentsOnHolidays = "extendTermForRepaymentsOnHolidays";
protected static final Set<String> WORKING_DAYS_RESPONSE_DATA_PARAMETERS = new HashSet<>(Arrays.asList(idParamName, protected static final Set<String> WORKING_DAYS_RESPONSE_DATA_PARAMETERS = new HashSet<>(Arrays.asList(idParamName,
recurrence,repayment_rescheduling_enum,extendTermForDailyRepayments,extendTermForRepaymentsOnHolidays recurrence,repayment_rescheduling_enum,extendTermForDailyRepayments,extendTermForRepaymentsOnHolidays
)); ));
protected static final Set<String> WORKING_DAYS_TEMPLATE_PARAMETERS = new HashSet<>(Arrays.asList protected static final Set<String> WORKING_DAYS_TEMPLATE_PARAMETERS = new HashSet<>(Arrays.asList
(rescheduleRepaymentTemplate)); (rescheduleRepaymentTemplate));
} }
@@ -1,116 +1,116 @@
/** /**
* Licensed to the Apache Software Foundation (ASF) under one * Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file * or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information * distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file * regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the * to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance * "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at * with the License. You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, * Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an * software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the * KIND, either express or implied. See the License for the
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
package org.apache.fineract.organisation.workingdays.api; package org.apache.fineract.organisation.workingdays.api;
import javax.ws.rs.Consumes; import javax.ws.rs.Consumes;
import javax.ws.rs.GET; import javax.ws.rs.GET;
import javax.ws.rs.PUT; import javax.ws.rs.PUT;
import javax.ws.rs.Path; import javax.ws.rs.Path;
import javax.ws.rs.Produces; import javax.ws.rs.Produces;
import javax.ws.rs.core.Context; import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.UriInfo; import javax.ws.rs.core.UriInfo;
import io.swagger.annotations.*; import io.swagger.annotations.*;
import org.apache.fineract.commands.domain.CommandWrapper; import org.apache.fineract.commands.domain.CommandWrapper;
import org.apache.fineract.commands.service.CommandWrapperBuilder; import org.apache.fineract.commands.service.CommandWrapperBuilder;
import org.apache.fineract.commands.service.PortfolioCommandSourceWritePlatformService; import org.apache.fineract.commands.service.PortfolioCommandSourceWritePlatformService;
import org.apache.fineract.infrastructure.core.api.ApiRequestParameterHelper; import org.apache.fineract.infrastructure.core.api.ApiRequestParameterHelper;
import org.apache.fineract.infrastructure.core.data.CommandProcessingResult; import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
import org.apache.fineract.infrastructure.core.serialization.ApiRequestJsonSerializationSettings; import org.apache.fineract.infrastructure.core.serialization.ApiRequestJsonSerializationSettings;
import org.apache.fineract.infrastructure.core.serialization.DefaultToApiJsonSerializer; import org.apache.fineract.infrastructure.core.serialization.DefaultToApiJsonSerializer;
import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext; import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext;
import org.apache.fineract.organisation.workingdays.data.WorkingDaysData; import org.apache.fineract.organisation.workingdays.data.WorkingDaysData;
import org.apache.fineract.organisation.workingdays.service.WorkingDaysReadPlatformService; import org.apache.fineract.organisation.workingdays.service.WorkingDaysReadPlatformService;
import org.springframework.beans.factory.annotation.Autowired; 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;
@Path("/workingdays") @Path("/workingdays")
@Component @Component
@Scope("singleton") @Scope("singleton")
@Api(tags = {"Working days"}) @Api(tags = {"Working days"})
@SwaggerDefinition(tags = { @SwaggerDefinition(tags = {
@Tag(name = "Working days", description = "The days of the week that are workdays.\n" + "\n" + "Rescheduling of repayments when it falls on a non-working is turned on /off by enable/disable reschedule-future-repayments parameter in Global configurations\n" + "\n" + "Allow transactions on non-working days is configurable by enabling/disbaling the allow-transactions-on-non_workingday parameter in Global configurations.") @Tag(name = "Working days", description = "The days of the week that are workdays.\n" + "\n" + "Rescheduling of repayments when it falls on a non-working is turned on /off by enable/disable reschedule-future-repayments parameter in Global configurations\n" + "\n" + "Allow transactions on non-working days is configurable by enabling/disbaling the allow-transactions-on-non_workingday parameter in Global configurations.")
}) })
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, public WorkingDaysApiResource(DefaultToApiJsonSerializer<WorkingDaysData> toApiJsonSerializer,
WorkingDaysReadPlatformService workingDaysReadPlatformService, WorkingDaysReadPlatformService workingDaysReadPlatformService,
PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService, PlatformSecurityContext context, PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService, PlatformSecurityContext context,
ApiRequestParameterHelper apiRequestParameterHelper) { ApiRequestParameterHelper apiRequestParameterHelper) {
this.toApiJsonSerializer = toApiJsonSerializer; this.toApiJsonSerializer = toApiJsonSerializer;
this.workingDaysReadPlatformService = workingDaysReadPlatformService; this.workingDaysReadPlatformService = workingDaysReadPlatformService;
this.commandsSourceWritePlatformService = commandsSourceWritePlatformService; this.commandsSourceWritePlatformService = commandsSourceWritePlatformService;
this.context = context; this.context = context;
this.apiRequestParameterHelper = apiRequestParameterHelper; this.apiRequestParameterHelper = apiRequestParameterHelper;
} }
@GET @GET
@Consumes({ MediaType.APPLICATION_JSON }) @Consumes({ MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON })
@ApiOperation(value = "List Working days", notes = "Example Requests:\n" + "\n" + "workingdays") @ApiOperation(value = "List Working days", notes = "Example Requests:\n" + "\n" + "workingdays")
@ApiResponses({@ApiResponse(code = 200, message = "", response = WorkingDaysApiResourceSwagger.GetWorkingDaysResponse.class, responseContainer = "list")}) @ApiResponses({@ApiResponse(code = 200, message = "", response = WorkingDaysApiResourceSwagger.GetWorkingDaysResponse.class, responseContainer = "list")})
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 WorkingDaysData workingDaysData = this.workingDaysReadPlatformService.retrieve(); 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
@Consumes({ MediaType.APPLICATION_JSON }) @Consumes({ MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON })
@ApiOperation(value = "Update a Working Day", notes = "Mandatory Fields\n" + "recurrence,repaymentRescheduleType,extendTermForDailyRepayments,locale") @ApiOperation(value = "Update a Working Day", notes = "Mandatory Fields\n" + "recurrence,repaymentRescheduleType,extendTermForDailyRepayments,locale")
@ApiImplicitParams({@ApiImplicitParam(value = "body", required = true, paramType = "body", dataType = "body", format = "body", dataTypeClass = WorkingDaysApiResourceSwagger.PutWorkingDaysRequest.class )}) @ApiImplicitParams({@ApiImplicitParam(value = "body", required = true, paramType = "body", dataType = "body", format = "body", dataTypeClass = WorkingDaysApiResourceSwagger.PutWorkingDaysRequest.class )})
@ApiResponses({@ApiResponse(code = 200, message = "", response = WorkingDaysApiResourceSwagger.PutWorkingDaysResponse.class)}) @ApiResponses({@ApiResponse(code = 200, message = "", response = WorkingDaysApiResourceSwagger.PutWorkingDaysResponse.class)})
public String update(@ApiParam(hidden = true) final String jsonRequestBody) { public String update(@ApiParam(hidden = true) final String jsonRequestBody) {
final CommandWrapper commandRequest = new CommandWrapperBuilder().updateWorkingDays().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 })
@ApiOperation(value = "Working Days Template", notes = "This is a convenience resource. It can be useful when building maintenance user interface screens for working days.\n" + "\n" + "Example Request:\n" + "\n" + "workingdays/template") @ApiOperation(value = "Working Days Template", notes = "This is a convenience resource. It can be useful when building maintenance user interface screens for working days.\n" + "\n" + "Example Request:\n" + "\n" + "workingdays/template")
@ApiResponses({@ApiResponse(code = 200, message = "", response = WorkingDaysApiResourceSwagger.GetWorkingDaysTemplateResponse.class )}) @ApiResponses({@ApiResponse(code = 200, message = "", response = WorkingDaysApiResourceSwagger.GetWorkingDaysTemplateResponse.class )})
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, return this.toApiJsonSerializer.serialize(settings, repaymentRescheduleOptions,
WorkingDaysApiConstants.WORKING_DAYS_TEMPLATE_PARAMETERS); WorkingDaysApiConstants.WORKING_DAYS_TEMPLATE_PARAMETERS);
} }
} }
@@ -1,90 +1,90 @@
/** /**
* Licensed to the Apache Software Foundation (ASF) under one * Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file * or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information * distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file * regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the * to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance * "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at * with the License. You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, * Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an * software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the * KIND, either express or implied. See the License for the
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
package org.apache.fineract.organisation.workingdays.data; package org.apache.fineract.organisation.workingdays.data;
import java.lang.reflect.Type; import java.lang.reflect.Type;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.apache.fineract.infrastructure.core.data.ApiParameterError; import org.apache.fineract.infrastructure.core.data.ApiParameterError;
import org.apache.fineract.infrastructure.core.data.DataValidatorBuilder; import org.apache.fineract.infrastructure.core.data.DataValidatorBuilder;
import org.apache.fineract.infrastructure.core.exception.InvalidJsonException; import org.apache.fineract.infrastructure.core.exception.InvalidJsonException;
import org.apache.fineract.infrastructure.core.exception.PlatformApiDataValidationException; import org.apache.fineract.infrastructure.core.exception.PlatformApiDataValidationException;
import org.apache.fineract.infrastructure.core.serialization.FromJsonHelper; import org.apache.fineract.infrastructure.core.serialization.FromJsonHelper;
import org.apache.fineract.organisation.workingdays.api.WorkingDaysApiConstants; import org.apache.fineract.organisation.workingdays.api.WorkingDaysApiConstants;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import com.google.gson.reflect.TypeToken; import com.google.gson.reflect.TypeToken;
@Component @Component
public class WorkingDayValidator { public class WorkingDayValidator {
private final FromJsonHelper fromApiJsonHelper; private final FromJsonHelper fromApiJsonHelper;
private static final Set<String> WORKING_DAYS_CREATE_OR_UPDATE_REQUEST_DATA_PARAMETERS = new HashSet<>( private static final Set<String> WORKING_DAYS_CREATE_OR_UPDATE_REQUEST_DATA_PARAMETERS = new HashSet<>(
Arrays.asList(WorkingDaysApiConstants.recurrence, WorkingDaysApiConstants.repayment_rescheduling_enum, Arrays.asList(WorkingDaysApiConstants.recurrence, WorkingDaysApiConstants.repayment_rescheduling_enum,
WorkingDaysApiConstants.localeParamName, WorkingDaysApiConstants.extendTermForDailyRepayments, WorkingDaysApiConstants.localeParamName, WorkingDaysApiConstants.extendTermForDailyRepayments,
WorkingDaysApiConstants.extendTermForRepaymentsOnHolidays)); WorkingDaysApiConstants.extendTermForRepaymentsOnHolidays));
@Autowired @Autowired
public WorkingDayValidator(FromJsonHelper fromApiJsonHelper) { public WorkingDayValidator(FromJsonHelper fromApiJsonHelper) {
this.fromApiJsonHelper = fromApiJsonHelper; this.fromApiJsonHelper = fromApiJsonHelper;
} }
public void validateForUpdate(final String json) { public void validateForUpdate(final String json) {
if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); } if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
final Type typeOfMap = new TypeToken<Map<String, Object>>() {}.getType(); final Type typeOfMap = new TypeToken<Map<String, Object>>() {}.getType();
this.fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, this.fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json,
WORKING_DAYS_CREATE_OR_UPDATE_REQUEST_DATA_PARAMETERS); WORKING_DAYS_CREATE_OR_UPDATE_REQUEST_DATA_PARAMETERS);
final JsonElement element = this.fromApiJsonHelper.parse(json); final JsonElement element = this.fromApiJsonHelper.parse(json);
final List<ApiParameterError> dataValidationErrors = new ArrayList<>(); final List<ApiParameterError> dataValidationErrors = new ArrayList<>();
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors) final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors)
.resource(WorkingDaysApiConstants.WORKING_DAYS_RESOURCE_NAME); .resource(WorkingDaysApiConstants.WORKING_DAYS_RESOURCE_NAME);
final String recurrence = this.fromApiJsonHelper.extractStringNamed(WorkingDaysApiConstants.recurrence, element); final String recurrence = this.fromApiJsonHelper.extractStringNamed(WorkingDaysApiConstants.recurrence, element);
baseDataValidator.reset().parameter(WorkingDaysApiConstants.recurrence).value(recurrence).notNull(); baseDataValidator.reset().parameter(WorkingDaysApiConstants.recurrence).value(recurrence).notNull();
final Integer repaymentRescheduleType = this.fromApiJsonHelper.extractIntegerSansLocaleNamed("repaymentRescheduleType", element); final Integer repaymentRescheduleType = this.fromApiJsonHelper.extractIntegerSansLocaleNamed("repaymentRescheduleType", element);
baseDataValidator.reset().parameter("repaymentRescheduleType").value(repaymentRescheduleType).ignoreIfNull().inMinMaxRange(1, 4); baseDataValidator.reset().parameter("repaymentRescheduleType").value(repaymentRescheduleType).ignoreIfNull().inMinMaxRange(1, 4);
final Boolean extendTermForDailyRepayments = this.fromApiJsonHelper.extractBooleanNamed("extendTermForDailyRepayments", element); final Boolean extendTermForDailyRepayments = this.fromApiJsonHelper.extractBooleanNamed("extendTermForDailyRepayments", element);
baseDataValidator.reset().parameter(WorkingDaysApiConstants.extendTermForDailyRepayments).value(extendTermForDailyRepayments).ignoreIfNull().validateForBooleanValue(); baseDataValidator.reset().parameter(WorkingDaysApiConstants.extendTermForDailyRepayments).value(extendTermForDailyRepayments).ignoreIfNull().validateForBooleanValue();
final Boolean extendTermForRepaymentsOnHolidays = this.fromApiJsonHelper.extractBooleanNamed("extendTermForRepaymentsOnHolidays", element); final Boolean extendTermForRepaymentsOnHolidays = this.fromApiJsonHelper.extractBooleanNamed("extendTermForRepaymentsOnHolidays", element);
baseDataValidator.reset().parameter(WorkingDaysApiConstants.extendTermForRepaymentsOnHolidays).value(extendTermForRepaymentsOnHolidays).ignoreIfNull().validateForBooleanValue(); baseDataValidator.reset().parameter(WorkingDaysApiConstants.extendTermForRepaymentsOnHolidays).value(extendTermForRepaymentsOnHolidays).ignoreIfNull().validateForBooleanValue();
throwExceptionIfValidationWarningsExist(dataValidationErrors); throwExceptionIfValidationWarningsExist(dataValidationErrors);
} }
private void throwExceptionIfValidationWarningsExist(final List<ApiParameterError> dataValidationErrors) { private void throwExceptionIfValidationWarningsExist(final List<ApiParameterError> dataValidationErrors) {
if (!dataValidationErrors.isEmpty()) { if (!dataValidationErrors.isEmpty()) {
throw new PlatformApiDataValidationException(dataValidationErrors); throw new PlatformApiDataValidationException(dataValidationErrors);
} }
} }
} }
@@ -1,68 +1,68 @@
/** /**
* Licensed to the Apache Software Foundation (ASF) under one * Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file * or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information * distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file * regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the * to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance * "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at * with the License. You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, * Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an * software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the * KIND, either express or implied. See the License for the
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
package org.apache.fineract.organisation.workingdays.data; package org.apache.fineract.organisation.workingdays.data;
import org.apache.fineract.infrastructure.core.data.EnumOptionData; import org.apache.fineract.infrastructure.core.data.EnumOptionData;
import java.util.Collection; import java.util.Collection;
public class WorkingDaysData { public class WorkingDaysData {
private final Long id; private final Long id;
private final String recurrence; private final String recurrence;
private final EnumOptionData repaymentRescheduleType; private final EnumOptionData repaymentRescheduleType;
private final Boolean extendTermForDailyRepayments; private final Boolean extendTermForDailyRepayments;
private final Boolean extendTermForRepaymentsOnHolidays; private final Boolean extendTermForRepaymentsOnHolidays;
// template date // template date
@SuppressWarnings("unused") @SuppressWarnings("unused")
private final Collection<EnumOptionData> repaymentRescheduleOptions; private final Collection<EnumOptionData> repaymentRescheduleOptions;
public WorkingDaysData(Long id, String recurrence, EnumOptionData repaymentRescheduleType, Boolean extendTermForDailyRepayments, Boolean extendTermForRepaymentsOnHolidays) { public WorkingDaysData(Long id, String recurrence, EnumOptionData repaymentRescheduleType, Boolean extendTermForDailyRepayments, Boolean extendTermForRepaymentsOnHolidays) {
this.id = id; this.id = id;
this.recurrence = recurrence; this.recurrence = recurrence;
this.repaymentRescheduleType = repaymentRescheduleType; this.repaymentRescheduleType = repaymentRescheduleType;
this.repaymentRescheduleOptions = null; this.repaymentRescheduleOptions = null;
this.extendTermForDailyRepayments = extendTermForDailyRepayments; this.extendTermForDailyRepayments = extendTermForDailyRepayments;
this.extendTermForRepaymentsOnHolidays = extendTermForRepaymentsOnHolidays; this.extendTermForRepaymentsOnHolidays = extendTermForRepaymentsOnHolidays;
} }
public WorkingDaysData(Long id, String recurrence, EnumOptionData repaymentRescheduleType, public WorkingDaysData(Long id, String recurrence, EnumOptionData repaymentRescheduleType,
Collection<EnumOptionData> repaymentRescheduleOptions, Boolean extendTermForDailyRepayments, Boolean extendTermForRepaymentsOnHolidays) { Collection<EnumOptionData> repaymentRescheduleOptions, Boolean extendTermForDailyRepayments, Boolean extendTermForRepaymentsOnHolidays) {
this.id = id; this.id = id;
this.recurrence = recurrence; this.recurrence = recurrence;
this.repaymentRescheduleType = repaymentRescheduleType; this.repaymentRescheduleType = repaymentRescheduleType;
this.repaymentRescheduleOptions = repaymentRescheduleOptions; this.repaymentRescheduleOptions = repaymentRescheduleOptions;
this.extendTermForDailyRepayments = extendTermForDailyRepayments; this.extendTermForDailyRepayments = extendTermForDailyRepayments;
this.extendTermForRepaymentsOnHolidays = extendTermForRepaymentsOnHolidays; this.extendTermForRepaymentsOnHolidays = extendTermForRepaymentsOnHolidays;
} }
public WorkingDaysData(WorkingDaysData data, Collection<EnumOptionData> repaymentRescheduleOptions) { public WorkingDaysData(WorkingDaysData data, Collection<EnumOptionData> repaymentRescheduleOptions) {
this.id = data.id; this.id = data.id;
this.recurrence = data.recurrence; this.recurrence = data.recurrence;
this.repaymentRescheduleType = data.repaymentRescheduleType; this.repaymentRescheduleType = data.repaymentRescheduleType;
this.repaymentRescheduleOptions = repaymentRescheduleOptions; this.repaymentRescheduleOptions = repaymentRescheduleOptions;
this.extendTermForDailyRepayments = data.extendTermForDailyRepayments; this.extendTermForDailyRepayments = data.extendTermForDailyRepayments;
this.extendTermForRepaymentsOnHolidays = data.extendTermForRepaymentsOnHolidays; this.extendTermForRepaymentsOnHolidays = data.extendTermForRepaymentsOnHolidays;
} }
} }
@@ -1,60 +1,60 @@
/** /**
* Licensed to the Apache Software Foundation (ASF) under one * Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file * or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information * distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file * regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the * to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance * "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at * with the License. You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, * Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an * software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the * KIND, either express or implied. See the License for the
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
package org.apache.fineract.organisation.workingdays.domain; package org.apache.fineract.organisation.workingdays.domain;
import org.apache.fineract.infrastructure.core.data.EnumOptionData; import org.apache.fineract.infrastructure.core.data.EnumOptionData;
public class WorkingDaysEnumerations { public class WorkingDaysEnumerations {
public static EnumOptionData workingDaysStatusType(final int id) { public static EnumOptionData workingDaysStatusType(final int id) {
return repaymentRescheduleType(RepaymentRescheduleType.fromInt(id)); return repaymentRescheduleType(RepaymentRescheduleType.fromInt(id));
} }
public static EnumOptionData repaymentRescheduleType(final RepaymentRescheduleType type){ public static EnumOptionData repaymentRescheduleType(final RepaymentRescheduleType type){
EnumOptionData optionData = null; EnumOptionData optionData = null;
switch(type){ switch(type){
case INVALID: case INVALID:
optionData = new EnumOptionData(RepaymentRescheduleType.INVALID.getValue().longValue(),RepaymentRescheduleType.INVALID.getCode(), optionData = new EnumOptionData(RepaymentRescheduleType.INVALID.getValue().longValue(),RepaymentRescheduleType.INVALID.getCode(),
"invalid"); "invalid");
break; break;
case SAME_DAY: case SAME_DAY:
optionData = new EnumOptionData(RepaymentRescheduleType.SAME_DAY.getValue().longValue(),RepaymentRescheduleType.SAME_DAY.getCode(), optionData = new EnumOptionData(RepaymentRescheduleType.SAME_DAY.getValue().longValue(),RepaymentRescheduleType.SAME_DAY.getCode(),
"same day"); "same day");
break; break;
case MOVE_TO_NEXT_WORKING_DAY: case MOVE_TO_NEXT_WORKING_DAY:
optionData = new EnumOptionData(RepaymentRescheduleType.MOVE_TO_NEXT_WORKING_DAY.getValue().longValue(),RepaymentRescheduleType.MOVE_TO_NEXT_WORKING_DAY.getCode(), optionData = new EnumOptionData(RepaymentRescheduleType.MOVE_TO_NEXT_WORKING_DAY.getValue().longValue(),RepaymentRescheduleType.MOVE_TO_NEXT_WORKING_DAY.getCode(),
"move to next working day"); "move to next working day");
break; break;
case MOVE_TO_NEXT_REPAYMENT_MEETING_DAY: case MOVE_TO_NEXT_REPAYMENT_MEETING_DAY:
optionData = new EnumOptionData(RepaymentRescheduleType.MOVE_TO_NEXT_REPAYMENT_MEETING_DAY.getValue().longValue(),RepaymentRescheduleType.MOVE_TO_NEXT_REPAYMENT_MEETING_DAY.getCode(), optionData = new EnumOptionData(RepaymentRescheduleType.MOVE_TO_NEXT_REPAYMENT_MEETING_DAY.getValue().longValue(),RepaymentRescheduleType.MOVE_TO_NEXT_REPAYMENT_MEETING_DAY.getCode(),
"move to next repayment meeting day"); "move to next repayment meeting day");
break; break;
case MOVE_TO_PREVIOUS_WORKING_DAY: case MOVE_TO_PREVIOUS_WORKING_DAY:
optionData = new EnumOptionData(RepaymentRescheduleType.MOVE_TO_PREVIOUS_WORKING_DAY.getValue().longValue(),RepaymentRescheduleType.MOVE_TO_PREVIOUS_WORKING_DAY.getCode(), optionData = new EnumOptionData(RepaymentRescheduleType.MOVE_TO_PREVIOUS_WORKING_DAY.getValue().longValue(),RepaymentRescheduleType.MOVE_TO_PREVIOUS_WORKING_DAY.getCode(),
"move to previous working day"); "move to previous working day");
break; break;
} }
return optionData; return optionData;
} }
} }
@@ -1,46 +1,46 @@
/** /**
* Licensed to the Apache Software Foundation (ASF) under one * Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file * or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information * distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file * regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the * to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance * "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at * with the License. You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, * Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an * software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the * KIND, either express or implied. See the License for the
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
package org.apache.fineract.organisation.workingdays.handler; package org.apache.fineract.organisation.workingdays.handler;
import org.apache.fineract.commands.annotation.CommandType; import org.apache.fineract.commands.annotation.CommandType;
import org.apache.fineract.commands.handler.NewCommandSourceHandler; import org.apache.fineract.commands.handler.NewCommandSourceHandler;
import org.apache.fineract.infrastructure.core.api.JsonCommand; import org.apache.fineract.infrastructure.core.api.JsonCommand;
import org.apache.fineract.infrastructure.core.data.CommandProcessingResult; import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
import org.apache.fineract.organisation.workingdays.service.WorkingDaysWritePlatformService; import org.apache.fineract.organisation.workingdays.service.WorkingDaysWritePlatformService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@Service @Service
@CommandType(entity = "WORKINGDAYS", action = "UPDATE") @CommandType(entity = "WORKINGDAYS", action = "UPDATE")
public class UpdateWorkingDaysCommandHandler implements NewCommandSourceHandler { public class UpdateWorkingDaysCommandHandler implements NewCommandSourceHandler {
private final WorkingDaysWritePlatformService workingDaysWritePlatformService; private final WorkingDaysWritePlatformService workingDaysWritePlatformService;
@Autowired @Autowired
public UpdateWorkingDaysCommandHandler(final WorkingDaysWritePlatformService workingDaysWritePlatformService) { public UpdateWorkingDaysCommandHandler(final WorkingDaysWritePlatformService workingDaysWritePlatformService) {
this.workingDaysWritePlatformService = workingDaysWritePlatformService; this.workingDaysWritePlatformService = workingDaysWritePlatformService;
} }
@Transactional @Transactional
@Override @Override
public CommandProcessingResult processCommand(JsonCommand command) { public CommandProcessingResult processCommand(JsonCommand command) {
return this.workingDaysWritePlatformService.updateWorkingDays(command); return this.workingDaysWritePlatformService.updateWorkingDays(command);
} }
} }
@@ -1,28 +1,28 @@
/** /**
* Licensed to the Apache Software Foundation (ASF) under one * Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file * or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information * distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file * regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the * to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance * "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at * with the License. You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, * Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an * software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the * KIND, either express or implied. See the License for the
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
package org.apache.fineract.organisation.workingdays.service; package org.apache.fineract.organisation.workingdays.service;
import org.apache.fineract.organisation.workingdays.data.WorkingDaysData; import org.apache.fineract.organisation.workingdays.data.WorkingDaysData;
public interface WorkingDaysReadPlatformService { public interface WorkingDaysReadPlatformService {
WorkingDaysData retrieve(); WorkingDaysData retrieve();
WorkingDaysData repaymentRescheduleType(); WorkingDaysData repaymentRescheduleType();
} }
@@ -1,107 +1,107 @@
/** /**
* Licensed to the Apache Software Foundation (ASF) under one * Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file * or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information * distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file * regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the * to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance * "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at * with the License. You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, * Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an * software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the * KIND, either express or implied. See the License for the
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
package org.apache.fineract.organisation.workingdays.service; package org.apache.fineract.organisation.workingdays.service;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import org.apache.fineract.infrastructure.core.data.EnumOptionData; import org.apache.fineract.infrastructure.core.data.EnumOptionData;
import org.apache.fineract.infrastructure.core.domain.JdbcSupport; import org.apache.fineract.infrastructure.core.domain.JdbcSupport;
import org.apache.fineract.infrastructure.core.service.RoutingDataSource; import org.apache.fineract.infrastructure.core.service.RoutingDataSource;
import org.apache.fineract.organisation.workingdays.data.WorkingDaysData; import org.apache.fineract.organisation.workingdays.data.WorkingDaysData;
import org.apache.fineract.organisation.workingdays.domain.RepaymentRescheduleType; import org.apache.fineract.organisation.workingdays.domain.RepaymentRescheduleType;
import org.apache.fineract.organisation.workingdays.domain.WorkingDaysEnumerations; import org.apache.fineract.organisation.workingdays.domain.WorkingDaysEnumerations;
import org.apache.fineract.organisation.workingdays.exception.WorkingDaysNotFoundException; import org.apache.fineract.organisation.workingdays.exception.WorkingDaysNotFoundException;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.EmptyResultDataAccessException; import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.jdbc.core.JdbcTemplate; 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;
@Service @Service
public class WorkingDaysReadPlatformServiceImpl implements WorkingDaysReadPlatformService { public class WorkingDaysReadPlatformServiceImpl implements WorkingDaysReadPlatformService {
private final JdbcTemplate jdbcTemplate; private final JdbcTemplate jdbcTemplate;
@Autowired @Autowired
public WorkingDaysReadPlatformServiceImpl(final RoutingDataSource dataSource) { public WorkingDaysReadPlatformServiceImpl(final RoutingDataSource dataSource) {
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;
public WorkingDaysMapper() { public WorkingDaysMapper() {
final StringBuilder sqlBuilder = new StringBuilder(100); final StringBuilder sqlBuilder = new StringBuilder(100);
sqlBuilder.append("w.id as id,w.recurrence as recurrence,w.repayment_rescheduling_enum as status_enum,"); sqlBuilder.append("w.id as id,w.recurrence as recurrence,w.repayment_rescheduling_enum as status_enum,");
sqlBuilder.append("w.extend_term_daily_repayments as extendTermForDailyRepayments,"); sqlBuilder.append("w.extend_term_daily_repayments as extendTermForDailyRepayments,");
sqlBuilder.append("w.extend_term_holiday_repayment as extendTermForRepaymentsOnHolidays "); sqlBuilder.append("w.extend_term_holiday_repayment as extendTermForRepaymentsOnHolidays ");
sqlBuilder.append("from m_working_days w"); sqlBuilder.append("from m_working_days w");
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, @SuppressWarnings("unused") 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);
final Boolean extendTermForDailyRepayments = rs.getBoolean("extendTermForDailyRepayments"); final Boolean extendTermForDailyRepayments = rs.getBoolean("extendTermForDailyRepayments");
final Boolean extendTermForRepaymentsOnHolidays = rs.getBoolean("extendTermForRepaymentsOnHolidays"); final Boolean extendTermForRepaymentsOnHolidays = rs.getBoolean("extendTermForRepaymentsOnHolidays");
return new WorkingDaysData(id, recurrence, status, extendTermForDailyRepayments, extendTermForRepaymentsOnHolidays); return new WorkingDaysData(id, recurrence, status, extendTermForDailyRepayments, extendTermForRepaymentsOnHolidays);
} }
} }
@Override @Override
public WorkingDaysData retrieve() { public WorkingDaysData retrieve() {
//Check whether template is enabled or not? //Check whether template is enabled or not?
try { try {
final WorkingDaysMapper rm = new WorkingDaysMapper(); final WorkingDaysMapper rm = new WorkingDaysMapper();
final String sql = " select " + rm.schema(); final String sql = " select " + rm.schema();
WorkingDaysData data = this.jdbcTemplate.queryForObject(sql, rm, new Object[] {}); WorkingDaysData data = this.jdbcTemplate.queryForObject(sql, rm, new Object[] {});
Collection<EnumOptionData> repaymentRescheduleOptions = repaymentRescheduleTypeOptions() ; Collection<EnumOptionData> repaymentRescheduleOptions = repaymentRescheduleTypeOptions() ;
return new WorkingDaysData(data, repaymentRescheduleOptions) ; return new WorkingDaysData(data, repaymentRescheduleOptions) ;
} catch (final EmptyResultDataAccessException e) { } catch (final EmptyResultDataAccessException e) {
throw new WorkingDaysNotFoundException(); throw new WorkingDaysNotFoundException();
} }
} }
@Override @Override
public WorkingDaysData repaymentRescheduleType() { public WorkingDaysData repaymentRescheduleType() {
Collection<EnumOptionData> repaymentRescheduleOptions = repaymentRescheduleTypeOptions(); Collection<EnumOptionData> repaymentRescheduleOptions = repaymentRescheduleTypeOptions();
return new WorkingDaysData(null, null, null, repaymentRescheduleOptions, null, null); return new WorkingDaysData(null, null, null, repaymentRescheduleOptions, null, null);
} }
private Collection<EnumOptionData> repaymentRescheduleTypeOptions() { private Collection<EnumOptionData> repaymentRescheduleTypeOptions() {
return Arrays.asList( return Arrays.asList(
WorkingDaysEnumerations.repaymentRescheduleType(RepaymentRescheduleType.SAME_DAY), 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));
} }
} }
@@ -1,45 +1,45 @@
/** /**
* Licensed to the Apache Software Foundation (ASF) under one * Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file * or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information * distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file * regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the * to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance * "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at * with the License. You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, * Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an * software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the * KIND, either express or implied. See the License for the
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
package org.apache.fineract.portfolio.loanaccount.handler; package org.apache.fineract.portfolio.loanaccount.handler;
import org.apache.fineract.commands.annotation.CommandType; import org.apache.fineract.commands.annotation.CommandType;
import org.apache.fineract.commands.handler.NewCommandSourceHandler; import org.apache.fineract.commands.handler.NewCommandSourceHandler;
import org.apache.fineract.infrastructure.core.api.JsonCommand; import org.apache.fineract.infrastructure.core.api.JsonCommand;
import org.apache.fineract.infrastructure.core.data.CommandProcessingResult; import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
import org.apache.fineract.portfolio.loanaccount.service.LoanWritePlatformService; import org.apache.fineract.portfolio.loanaccount.service.LoanWritePlatformService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@Service @Service
@CommandType(entity = "LOAN", action = "RECOVERYPAYMENT") @CommandType(entity = "LOAN", action = "RECOVERYPAYMENT")
public class LoanRecoveryPaymentCommandHandler implements NewCommandSourceHandler { public class LoanRecoveryPaymentCommandHandler implements NewCommandSourceHandler {
private final LoanWritePlatformService writePlatformService; private final LoanWritePlatformService writePlatformService;
@Autowired @Autowired
public LoanRecoveryPaymentCommandHandler(LoanWritePlatformService writePlatformService) { public LoanRecoveryPaymentCommandHandler(LoanWritePlatformService writePlatformService) {
this.writePlatformService = writePlatformService; this.writePlatformService = writePlatformService;
} }
@Override @Override
public CommandProcessingResult processCommand(JsonCommand command) { public CommandProcessingResult processCommand(JsonCommand command) {
final boolean isRecoveryRepayment = true; final boolean isRecoveryRepayment = true;
return writePlatformService.makeLoanRepayment(command.getLoanId(), command, isRecoveryRepayment); return writePlatformService.makeLoanRepayment(command.getLoanId(), command, isRecoveryRepayment);
} }
} }
@@ -1,85 +1,85 @@
/** /**
* Licensed to the Apache Software Foundation (ASF) under one * Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file * or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information * distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file * regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the * to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance * "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at * with the License. You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, * Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an * software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the * KIND, either express or implied. See the License for the
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
package org.apache.fineract.portfolio.loanaccount.loanschedule.data; package org.apache.fineract.portfolio.loanaccount.loanschedule.data;
import java.math.BigDecimal; import java.math.BigDecimal;
public class OverdueLoanScheduleData { public class OverdueLoanScheduleData {
private final Long loanId; private final Long loanId;
private final Long chargeId; private final Long chargeId;
private final String locale; private final String locale;
private final BigDecimal amount; private final BigDecimal amount;
private final String dateFormat; private final String dateFormat;
private final String dueDate; private final String dueDate;
private final BigDecimal principalOverdue; private final BigDecimal principalOverdue;
private final BigDecimal interestOverdue; private final BigDecimal interestOverdue;
private final Integer periodNumber; private final Integer periodNumber;
public OverdueLoanScheduleData(final Long loanId, final Long chargeId, final String dueDate, final BigDecimal amount, public OverdueLoanScheduleData(final Long loanId, final Long chargeId, final String dueDate, final BigDecimal amount,
final String dateFormat, final String locale, final BigDecimal principalOverdue, final BigDecimal interestOverdue, final String dateFormat, final String locale, final BigDecimal principalOverdue, final BigDecimal interestOverdue,
final Integer periodNumber) { final Integer periodNumber) {
this.loanId = loanId; this.loanId = loanId;
this.chargeId = chargeId; this.chargeId = chargeId;
this.dueDate = dueDate; this.dueDate = dueDate;
this.amount = amount; this.amount = amount;
this.dateFormat = dateFormat; this.dateFormat = dateFormat;
this.locale = locale; this.locale = locale;
this.principalOverdue = principalOverdue; this.principalOverdue = principalOverdue;
this.interestOverdue = interestOverdue; this.interestOverdue = interestOverdue;
this.periodNumber = periodNumber; this.periodNumber = periodNumber;
} }
public Long getLoanId() { public Long getLoanId() {
return this.loanId; return this.loanId;
} }
public Long getChargeId() { public Long getChargeId() {
return this.chargeId; return this.chargeId;
} }
public String getDueDate() { public String getDueDate() {
return this.dueDate; return this.dueDate;
} }
public BigDecimal getAmount() { public BigDecimal getAmount() {
return this.amount; return this.amount;
} }
public String getDateFormat() { public String getDateFormat() {
return this.dateFormat; return this.dateFormat;
} }
public String getLocale() { public String getLocale() {
return this.locale; return this.locale;
} }
public Integer getPeriodNumber() { public Integer getPeriodNumber() {
return this.periodNumber; return this.periodNumber;
} }
@Override @Override
public String toString() { public String toString() {
return "{" + "chargeId:" + this.chargeId + ", locale:'" + this.locale + '\'' + ", amount:" + this.amount + ", dateFormat:'" return "{" + "chargeId:" + this.chargeId + ", locale:'" + this.locale + '\'' + ", amount:" + this.amount + ", dateFormat:'"
+ this.dateFormat + '\'' + ", dueDate:'" + this.dueDate + '\'' + ", principal:'" + this.principalOverdue + '\'' + this.dateFormat + '\'' + ", dueDate:'" + this.dueDate + '\'' + ", principal:'" + this.principalOverdue + '\''
+ ", interest:'" + this.interestOverdue + '\'' + '}'; + ", interest:'" + this.interestOverdue + '\'' + '}';
} }
} }