This is an automated email from the ASF dual-hosted git repository.

arnold pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/fineract.git


The following commit(s) were added to refs/heads/develop by this push:
     new 5bf9e1a28 [FINERACT-1678] Retrieving locked loan accounts via API
5bf9e1a28 is described below

commit 5bf9e1a288a2f61b08f11c5b43b9ce22ad53c717
Author: taskain7 <[email protected]>
AuthorDate: Fri Aug 26 04:02:34 2022 +0200

    [FINERACT-1678] Retrieving locked loan accounts via API
---
 .../cob/api/LoanAccountLockApiResource.java        | 82 ++++++++++++++++++++++
 .../cob/api/LoanAccountLockApiResourceSwagger.java | 41 +++++++++++
 .../cob/data/LoanAccountLockResponseDTO.java       | 31 ++++++++
 .../fineract/cob/domain/LoanAccountLock.java       | 58 +++++++++++++++
 .../cob/domain/LoanAccountLockRepository.java      | 24 +++++++
 .../org/apache/fineract/cob/domain/LockOwner.java  | 23 ++++++
 .../cob/service/LoanAccountLockService.java        | 27 +++++++
 .../cob/service/LoanAccountLockServiceImpl.java    | 42 +++++++++++
 8 files changed, 328 insertions(+)

diff --git 
a/fineract-provider/src/main/java/org/apache/fineract/cob/api/LoanAccountLockApiResource.java
 
b/fineract-provider/src/main/java/org/apache/fineract/cob/api/LoanAccountLockApiResource.java
new file mode 100644
index 000000000..dcae39083
--- /dev/null
+++ 
b/fineract-provider/src/main/java/org/apache/fineract/cob/api/LoanAccountLockApiResource.java
@@ -0,0 +1,82 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.fineract.cob.api;
+
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.media.ArraySchema;
+import io.swagger.v3.oas.annotations.media.Content;
+import io.swagger.v3.oas.annotations.media.Schema;
+import io.swagger.v3.oas.annotations.responses.ApiResponse;
+import io.swagger.v3.oas.annotations.responses.ApiResponses;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.UriInfo;
+import lombok.RequiredArgsConstructor;
+import org.apache.fineract.cob.data.LoanAccountLockResponseDTO;
+import org.apache.fineract.cob.domain.LoanAccountLock;
+import org.apache.fineract.cob.service.LoanAccountLockService;
+import org.apache.fineract.infrastructure.core.api.ApiRequestParameterHelper;
+import 
org.apache.fineract.infrastructure.core.serialization.ApiRequestJsonSerializationSettings;
+import 
org.apache.fineract.infrastructure.core.serialization.DefaultToApiJsonSerializer;
+import org.springframework.stereotype.Component;
+
+@Path("/loans")
+@Component
+@Tag(name = "Loan Account Lock", description = "")
+@RequiredArgsConstructor
+public class LoanAccountLockApiResource {
+
+    private static final Set<String> 
LOAN_ACCOUNT_LOCK_RESPONSE_DATA_PARAMETERS = new 
HashSet<>(Arrays.asList("page", "limit", "content"));
+
+    private final LoanAccountLockService loanAccountLockService;
+    private final ApiRequestParameterHelper apiRequestParameterHelper;
+    private final DefaultToApiJsonSerializer<LoanAccountLockResponseDTO> 
businessStepConfigSerializeService;
+
+    @GET
+    @Path("locked")
+    @Consumes({ MediaType.APPLICATION_JSON })
+    @Produces({ MediaType.APPLICATION_JSON })
+    @Operation(summary = "List locked loan accounts", description = "Returns 
the locked loan IDs")
+    @ApiResponses({
+            @ApiResponse(responseCode = "200", description = "OK", content = 
@Content(array = @ArraySchema(schema = @Schema(implementation = 
LoanAccountLockApiResourceSwagger.GetLoanAccountLockResponse.class)))) })
+    public String retrieveAllConfiguredBusinessStep(@Context final UriInfo 
uriInfo, @QueryParam("page") String page,
+            @QueryParam("limit") String limit) {
+
+        List<LoanAccountLock> lockedLoanAccounts = 
loanAccountLockService.getLockedLoanAccountByPage(Integer.parseInt(page),
+                Integer.parseInt(limit));
+        LoanAccountLockResponseDTO response = new LoanAccountLockResponseDTO();
+        response.setPage(Integer.parseInt(page));
+        response.setLimit(Integer.parseInt(limit));
+        response.setContent(lockedLoanAccounts);
+
+        final ApiRequestJsonSerializationSettings settings = 
apiRequestParameterHelper.process(uriInfo.getQueryParameters());
+
+        return businessStepConfigSerializeService.serialize(settings, 
response, LOAN_ACCOUNT_LOCK_RESPONSE_DATA_PARAMETERS);
+    }
+}
diff --git 
a/fineract-provider/src/main/java/org/apache/fineract/cob/api/LoanAccountLockApiResourceSwagger.java
 
b/fineract-provider/src/main/java/org/apache/fineract/cob/api/LoanAccountLockApiResourceSwagger.java
new file mode 100644
index 000000000..d75c5626f
--- /dev/null
+++ 
b/fineract-provider/src/main/java/org/apache/fineract/cob/api/LoanAccountLockApiResourceSwagger.java
@@ -0,0 +1,41 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.fineract.cob.api;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import java.util.List;
+import org.apache.fineract.cob.domain.LoanAccountLock;
+
+final class LoanAccountLockApiResourceSwagger {
+
+    private LoanAccountLockApiResourceSwagger() {
+
+    }
+
+    @Schema(description = "GetLoanAccountLockResponse")
+    public static final class GetLoanAccountLockResponse {
+
+        private GetLoanAccountLockResponse() {}
+
+        public int page;
+        public int limit;
+        public List<LoanAccountLock> content;
+
+    }
+}
diff --git 
a/fineract-provider/src/main/java/org/apache/fineract/cob/data/LoanAccountLockResponseDTO.java
 
b/fineract-provider/src/main/java/org/apache/fineract/cob/data/LoanAccountLockResponseDTO.java
new file mode 100644
index 000000000..b321656f0
--- /dev/null
+++ 
b/fineract-provider/src/main/java/org/apache/fineract/cob/data/LoanAccountLockResponseDTO.java
@@ -0,0 +1,31 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.fineract.cob.data;
+
+import java.util.List;
+import lombok.Data;
+import org.apache.fineract.cob.domain.LoanAccountLock;
+
+@Data
+public class LoanAccountLockResponseDTO {
+
+    private int page;
+    private int limit;
+    private List<LoanAccountLock> content;
+}
diff --git 
a/fineract-provider/src/main/java/org/apache/fineract/cob/domain/LoanAccountLock.java
 
b/fineract-provider/src/main/java/org/apache/fineract/cob/domain/LoanAccountLock.java
new file mode 100644
index 000000000..917dbf480
--- /dev/null
+++ 
b/fineract-provider/src/main/java/org/apache/fineract/cob/domain/LoanAccountLock.java
@@ -0,0 +1,58 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.fineract.cob.domain;
+
+import java.time.LocalDateTime;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import javax.persistence.Version;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+
+@Entity
+@Table(name = "m_loan_account_locks")
+@NoArgsConstructor
+@Getter
+public class LoanAccountLock {
+
+    @Id
+    @Column(name = "loan_id", nullable = false)
+    private Long loanId;
+
+    @Version
+    @Column(name = "version")
+    private Long version;
+
+    @Enumerated(EnumType.STRING)
+    @Column(name = "lock_owner", nullable = false)
+    private LockOwner lockOwner;
+
+    @Column(name = "lock_placed_on", nullable = false)
+    private LocalDateTime lockPlacedOn;
+
+    @Column(name = "error")
+    private String error;
+
+    @Column(name = "stacktrace")
+    private String stacktrace;
+}
diff --git 
a/fineract-provider/src/main/java/org/apache/fineract/cob/domain/LoanAccountLockRepository.java
 
b/fineract-provider/src/main/java/org/apache/fineract/cob/domain/LoanAccountLockRepository.java
new file mode 100644
index 000000000..5398e8773
--- /dev/null
+++ 
b/fineract-provider/src/main/java/org/apache/fineract/cob/domain/LoanAccountLockRepository.java
@@ -0,0 +1,24 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.fineract.cob.domain;
+
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+
+public interface LoanAccountLockRepository extends 
JpaRepository<LoanAccountLock, Long>, JpaSpecificationExecutor<LoanAccountLock> 
{}
diff --git 
a/fineract-provider/src/main/java/org/apache/fineract/cob/domain/LockOwner.java 
b/fineract-provider/src/main/java/org/apache/fineract/cob/domain/LockOwner.java
new file mode 100644
index 000000000..5b8943348
--- /dev/null
+++ 
b/fineract-provider/src/main/java/org/apache/fineract/cob/domain/LockOwner.java
@@ -0,0 +1,23 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.fineract.cob.domain;
+
+public enum LockOwner {
+    LOAN_COB, LOAN_INLINE_COB;
+}
diff --git 
a/fineract-provider/src/main/java/org/apache/fineract/cob/service/LoanAccountLockService.java
 
b/fineract-provider/src/main/java/org/apache/fineract/cob/service/LoanAccountLockService.java
new file mode 100644
index 000000000..e1daca429
--- /dev/null
+++ 
b/fineract-provider/src/main/java/org/apache/fineract/cob/service/LoanAccountLockService.java
@@ -0,0 +1,27 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.fineract.cob.service;
+
+import java.util.List;
+import org.apache.fineract.cob.domain.LoanAccountLock;
+
+public interface LoanAccountLockService {
+
+    List<LoanAccountLock> getLockedLoanAccountByPage(int page, int limit);
+}
diff --git 
a/fineract-provider/src/main/java/org/apache/fineract/cob/service/LoanAccountLockServiceImpl.java
 
b/fineract-provider/src/main/java/org/apache/fineract/cob/service/LoanAccountLockServiceImpl.java
new file mode 100644
index 000000000..63a2cd606
--- /dev/null
+++ 
b/fineract-provider/src/main/java/org/apache/fineract/cob/service/LoanAccountLockServiceImpl.java
@@ -0,0 +1,42 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.fineract.cob.service;
+
+import java.util.List;
+import lombok.RequiredArgsConstructor;
+import org.apache.fineract.cob.domain.LoanAccountLock;
+import org.apache.fineract.cob.domain.LoanAccountLockRepository;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.PageRequest;
+import org.springframework.data.domain.Pageable;
+import org.springframework.stereotype.Service;
+
+@Service
+@RequiredArgsConstructor
+public class LoanAccountLockServiceImpl implements LoanAccountLockService {
+
+    private final LoanAccountLockRepository loanAccountLockRepository;
+
+    @Override
+    public List<LoanAccountLock> getLockedLoanAccountByPage(int page, int 
limit) {
+        Pageable loanAccountLockPage = PageRequest.of(page, limit);
+        Page<LoanAccountLock> loanAccountLocks = 
loanAccountLockRepository.findAll(loanAccountLockPage);
+        return loanAccountLocks.getContent();
+    }
+}

Reply via email to