-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat&chore[Wrapper]: Add APIWrapper child class of Wrapper, and updat…
…e .gitignore and POM Added a child class of Wrapper that specializes in APIs, and updated .gitignore to ignore more artifacts, and updated .pom to use shade-plugin to build fat jars
- Loading branch information
Lucy Ciara Herud-Thomassen
authored and
Lucy Ciara Herud-Thomassen
committed
Mar 2, 2026
1 parent
d9dff24
commit a3752a2
Showing
4 changed files
with
80 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| package edu.group5.app.control; | ||
|
|
||
| import java.net.URI; | ||
| import java.net.http.HttpClient; | ||
| import java.net.http.HttpRequest; | ||
| import java.net.http.HttpResponse; | ||
|
|
||
| import tools.jackson.databind.ObjectMapper; | ||
|
|
||
| public class OrgAPIWrapper extends Wrapper { | ||
| private String urlString; | ||
| private Object[] data; | ||
|
|
||
| public OrgAPIWrapper(String urlString) { | ||
| this.urlString = urlString; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean importData() { | ||
| URI uri = URI.create(this.urlString); | ||
| HttpClient client = HttpClient.newHttpClient(); | ||
| HttpRequest request = HttpRequest.newBuilder() | ||
| .uri(uri) | ||
| .GET() | ||
| .build(); | ||
|
|
||
| try { | ||
| HttpResponse<String> response = client.send( | ||
| request, HttpResponse.BodyHandlers.ofString()); | ||
| this.data = new ObjectMapper().readValue(response.body(), Object[].class); | ||
| return true; | ||
| } catch (Exception e) { | ||
| e.printStackTrace(); | ||
| return false; | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public Object[] getData() { | ||
| return this.data; | ||
| } | ||
| } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,4 +6,6 @@ protected Wrapper() { | |
| } | ||
|
|
||
| public abstract boolean importData(); | ||
|
|
||
| public abstract Object getData(); | ||
| } | ||