Skip to content
This repository was archived by the owner on Jun 9, 2024. It is now read-only.

Commit 09874a0

Browse files
committed
return endpoint GET
1 parent 0555923 commit 09874a0

1 file changed

Lines changed: 5 additions & 8 deletions

File tree

src/main/java/Return.java

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import EJB.BookBean;
2-
import EJB.LoanBean;
2+
import EJB.LoanOracleBean;
33
import EJB.FineBean;
4+
import Objects.loanModel;
45
import com.google.gson.Gson;
56
import com.mongodb.client.AggregateIterable;
67
import jakarta.ejb.EJB;
@@ -20,7 +21,7 @@
2021
@WebServlet(name = "Return", value = "/return")
2122
public class Return extends HttpServlet {
2223
@EJB
23-
LoanBean loanBean;
24+
LoanOracleBean loanBean;
2425
@EJB
2526
BookBean bookBean;
2627
@EJB
@@ -31,15 +32,11 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response) t
3132
response.setContentType("application/json");
3233

3334
PrintWriter out = response.getWriter();
34-
AggregateIterable<Document> result = loanBean.getActiveLoans();
35-
36-
// Iterate through the aggregateIterable and store the documents in a list
37-
List<Document> documents = new ArrayList<>();
38-
result.into(documents);
35+
ArrayList<loanModel> result = loanBean.getActiveLoans();
3936

4037
// Convert the list of documents to a JSON array
4138
Gson gson = new Gson();
42-
String jsonArray = gson.toJson(documents);
39+
String jsonArray = gson.toJson(result);
4340

4441
out.print(jsonArray);
4542
out.flush();

0 commit comments

Comments
 (0)