Skip to content

Commit bfdfe96

Browse files
committed
FINERACT-2460: Fix code style violations using Spotless
1 parent 6f5d2a5 commit bfdfe96

File tree

3 files changed

+69
-65
lines changed

3 files changed

+69
-65
lines changed

fineract-provider/src/main/java/org/apache/fineract/portfolio/client/api/ClientsApiResource.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@
6565
import org.apache.fineract.infrastructure.security.service.SqlValidator;
6666
import org.apache.fineract.portfolio.accountdetails.data.AccountSummaryCollectionData;
6767
import org.apache.fineract.portfolio.accountdetails.service.AccountDetailsReadPlatformService;
68-
import org.apache.fineract.portfolio.client.data.ClientPerformanceData;
6968
import org.apache.fineract.portfolio.client.data.ClientData;
69+
import org.apache.fineract.portfolio.client.data.ClientPerformanceData;
7070
import org.apache.fineract.portfolio.client.exception.ClientNotFoundException;
7171
import org.apache.fineract.portfolio.client.service.ClientReadPlatformService;
7272
import org.apache.fineract.portfolio.client.service.ClientTemplateReadPlatformService;
@@ -180,7 +180,7 @@ public String retrieveOne(@PathParam("clientId") @Parameter(description = "clien
180180
@Operation(summary = "Retrieve client performance metrics", description = "Returns a summary of active loans and outstanding balances for a specific client.")
181181
@ApiResponses({
182182
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = ClientPerformanceData.class))) })
183-
public String retrieveClientPerformance(@PathParam("clientId") @Parameter(description = "clientId") final Long clientId,
183+
public String retrieveClientPerformance(@PathParam("clientId") @Parameter(description = "clientId") final Long clientId,
184184
@Context final UriInfo uriInfo) {
185185

186186
this.context.authenticatedUser().validateHasReadPermission(ClientApiConstants.CLIENT_RESOURCE_NAME);
@@ -190,7 +190,6 @@ public String retrieveClientPerformance(@PathParam("clientId") @Parameter(descri
190190
return this.toApiJsonSerializer.serialize(performanceData);
191191
}
192192

193-
194193
@POST
195194
@Consumes({ MediaType.APPLICATION_JSON })
196195
@Produces({ MediaType.APPLICATION_JSON })
Lines changed: 51 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,51 @@
1-
/**
2-
* Licensed to the Apache Software Foundation (ASF) under one
3-
* or more contributor license agreements. See the NOTICE file
4-
* distributed with this work for additional information
5-
* regarding copyright ownership. The ASF licenses this file
6-
* to you under the Apache License, Version 2.0 (the
7-
* "License"); you may not use this file except in compliance
8-
* with the License. You may obtain a copy of the License at
9-
*
10-
* http://www.apache.org/licenses/LICENSE-2.0
11-
*
12-
* Unless required by applicable law or agreed to in writing,
13-
* software distributed under the License is distributed on an
14-
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15-
* KIND, either express or implied. See the License for the
16-
* specific language governing permissions and limitations
17-
* under the License.
18-
*/
19-
20-
package org.apache.fineract.portfolio.client.data;
21-
22-
import java.io.Serializable;
23-
import java.math.BigDecimal;
24-
25-
/**
26-
* Data object for Client Performance metrics.
27-
*/
28-
public final class ClientPerformanceData implements Serializable {
29-
30-
private final Integer activeLoans;
31-
private final BigDecimal totalOutstandingBalance;
32-
33-
// Constructor is private to force use of the static 'instance' method (Fineract style)
34-
private ClientPerformanceData(final Integer activeLoans, final BigDecimal totalOutstandingBalance) {
35-
this.activeLoans = activeLoans;
36-
this.totalOutstandingBalance = totalOutstandingBalance;
37-
}
38-
39-
public static ClientPerformanceData instance(final Integer activeLoans, final BigDecimal totalOutstandingBalance) {
40-
return new ClientPerformanceData(activeLoans, totalOutstandingBalance);
41-
}
42-
43-
// Getters for Spring to convert this to JSON
44-
public Integer getActiveLoans() { return activeLoans; }
45-
public BigDecimal getTotalOutstandingBalance() { return totalOutstandingBalance; }
46-
}
1+
/**
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
package org.apache.fineract.portfolio.client.data;
21+
22+
import java.io.Serializable;
23+
import java.math.BigDecimal;
24+
25+
/**
26+
* Data object for Client Performance metrics.
27+
*/
28+
public final class ClientPerformanceData implements Serializable {
29+
30+
private final Integer activeLoans;
31+
private final BigDecimal totalOutstandingBalance;
32+
33+
// Constructor is private to force use of the static 'instance' method (Fineract style)
34+
private ClientPerformanceData(final Integer activeLoans, final BigDecimal totalOutstandingBalance) {
35+
this.activeLoans = activeLoans;
36+
this.totalOutstandingBalance = totalOutstandingBalance;
37+
}
38+
39+
public static ClientPerformanceData instance(final Integer activeLoans, final BigDecimal totalOutstandingBalance) {
40+
return new ClientPerformanceData(activeLoans, totalOutstandingBalance);
41+
}
42+
43+
// Getters for Spring to convert this to JSON
44+
public Integer getActiveLoans() {
45+
return activeLoans;
46+
}
47+
48+
public BigDecimal getTotalOutstandingBalance() {
49+
return totalOutstandingBalance;
50+
}
51+
}

fineract-provider/src/main/java/org/apache/fineract/portfolio/client/service/ClientReadPlatformServiceImpl.java

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
import org.apache.fineract.portfolio.client.data.ClientCollateralManagementData;
4848
import org.apache.fineract.portfolio.client.data.ClientData;
4949
import org.apache.fineract.portfolio.client.data.ClientNonPersonData;
50+
import org.apache.fineract.portfolio.client.data.ClientPerformanceData;
5051
import org.apache.fineract.portfolio.client.data.ClientTimelineData;
5152
import org.apache.fineract.portfolio.client.domain.Client;
5253
import org.apache.fineract.portfolio.client.domain.ClientEnumerations;
@@ -62,7 +63,6 @@
6263
import org.springframework.jdbc.core.JdbcTemplate;
6364
import org.springframework.jdbc.core.RowMapper;
6465
import org.springframework.stereotype.Service;
65-
import org.apache.fineract.portfolio.client.data.ClientPerformanceData;
6666

6767
@Service
6868
@RequiredArgsConstructor
@@ -601,6 +601,7 @@ public Collection<Long> retrieveUserClients(Long aUserID) {
601601
public Long retrieveClientIdByExternalId(final ExternalId externalId) {
602602
return clientRepositoryWrapper.findIdByExternalId(externalId);
603603
}
604+
604605
@Override
605606
public ClientPerformanceData retrieveClientPerformance(final Long clientId) {
606607
try {
@@ -609,21 +610,20 @@ public ClientPerformanceData retrieveClientPerformance(final Long clientId) {
609610
if (count == null || count == 0) {
610611
throw new ClientNotFoundException(clientId);
611612
}
612-
final String sql = "SELECT " +
613-
"(SELECT COUNT(*) FROM m_loan WHERE client_id = c.id AND loan_status_id = 300) as activeLoans, " +
614-
"(SELECT COALESCE(SUM(principal_outstanding_derived + interest_outstanding_derived + fee_charges_outstanding_derived + penalty_charges_outstanding_derived), 0) " +
615-
" FROM m_loan WHERE client_id = c.id AND loan_status_id = 300) as totalOutstanding " +
616-
"FROM m_client c WHERE c.id = ?";
617-
618-
return this.jdbcTemplate.queryForObject(sql, (rs, rowNum) -> {
619-
final Integer activeLoans = rs.getInt("activeLoans");
620-
BigDecimal totalOutstanding = rs.getBigDecimal("totalOutstanding");
621-
return ClientPerformanceData.instance(activeLoans, totalOutstanding);
622-
}, clientId);
623-
} catch (EmptyResultDataAccessException e) {
624-
throw new ClientNotFoundException(clientId);
625-
}
626-
}
613+
final String sql = "SELECT " + "(SELECT COUNT(*) FROM m_loan WHERE client_id = c.id AND loan_status_id = 300) as activeLoans, "
614+
+ "(SELECT COALESCE(SUM(principal_outstanding_derived + interest_outstanding_derived + fee_charges_outstanding_derived + penalty_charges_outstanding_derived), 0) "
615+
+ " FROM m_loan WHERE client_id = c.id AND loan_status_id = 300) as totalOutstanding "
616+
+ "FROM m_client c WHERE c.id = ?";
617+
618+
return this.jdbcTemplate.queryForObject(sql, (rs, rowNum) -> {
619+
final Integer activeLoans = rs.getInt("activeLoans");
620+
BigDecimal totalOutstanding = rs.getBigDecimal("totalOutstanding");
621+
return ClientPerformanceData.instance(activeLoans, totalOutstanding);
622+
}, clientId);
623+
} catch (EmptyResultDataAccessException e) {
624+
throw new ClientNotFoundException(clientId);
625+
}
626+
}
627627

628628
private static final class ClientToDataMapper implements RowMapper<ClientData> {
629629

0 commit comments

Comments
 (0)