Skip to content

Commit

Permalink
feat&chore[Wrapper]: Add APIWrapper child class of Wrapper, and updat…
Browse files Browse the repository at this point in the history
…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
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 7 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,10 @@ out/
## VSCode
##############################
.vscode/

##############################
## Misc
##############################
.settings/*
.project
.classpath
36 changes: 29 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@
<version>7.0.2</version>
</dependency>

<!-- Source: https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.21.1</version>
<scope>compile</scope>
</dependency>
<!-- Source: https://mvnrepository.com/artifact/tools.jackson.core/jackson-databind -->
<dependency>
<groupId>tools.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>3.1.0</version>
<scope>compile</scope>
</dependency>


</dependencies>
Expand Down Expand Up @@ -96,6 +96,28 @@
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.12.0</version>
</plugin>

<!-- Fat JAR plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.6.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>edu.group5.app.App</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
42 changes: 42 additions & 0 deletions src/main/java/edu/group5/app/control/OrgAPIWrapper.java
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;
}
}
2 changes: 2 additions & 0 deletions src/main/java/edu/group5/app/control/Wrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ protected Wrapper() {
}

public abstract boolean importData();

public abstract Object getData();
}

0 comments on commit a3752a2

Please sign in to comment.