diff --git a/helpmehelpapplication/src/main/java/ntnu/systemutvikling/team6/scraper/APICharityData.java b/helpmehelpapplication/src/main/java/ntnu/systemutvikling/team6/scraper/APICharityData.java index 1b6a930..d4a6e90 100644 --- a/helpmehelpapplication/src/main/java/ntnu/systemutvikling/team6/scraper/APICharityData.java +++ b/helpmehelpapplication/src/main/java/ntnu/systemutvikling/team6/scraper/APICharityData.java @@ -6,7 +6,7 @@ * Represents data parsed from the IK API JSON response. Instances are immutable; to update any * value, a new object must be created. * - *

Receives data directly from {@link APICharityScraper} or {@link IKOrganizationScraper}. + *

Receives data directly from {@link APICharityScraper}. * *

{@code org_number} should be a unique number, as it is used as a primary key in {@link * DatabaseManager}. @@ -20,6 +20,7 @@ public class APICharityData { /** * Constructs a new APICharityData object. + * This class represents the data provided from the IK Api, and is used expand and provide data to our design of a charity. * * @param org_number a unique number that identifies the organization * @param name the name of the organization diff --git a/helpmehelpapplication/src/main/java/ntnu/systemutvikling/team6/scraper/APICharityScraper.java b/helpmehelpapplication/src/main/java/ntnu/systemutvikling/team6/scraper/APICharityScraper.java index 9f71537..7b341b7 100644 --- a/helpmehelpapplication/src/main/java/ntnu/systemutvikling/team6/scraper/APICharityScraper.java +++ b/helpmehelpapplication/src/main/java/ntnu/systemutvikling/team6/scraper/APICharityScraper.java @@ -64,31 +64,22 @@ public String getJSONData() throws IOException, InterruptedException { } /** - * Parses the JSON data using gson and creates a list of APICharityData objects. + * Parses the JSON data using gson and translates the {@code APICharityData} into our predefined charity classes + * and puts it in a CharityRegistry object. + * * * @param JSONData the {@code String} of JSON data to be parsed - * @return a list of APICharityDaya objects + * @return a CharityRegistry class object * @throws com.google.gson.JsonSyntaxException if the provided JSON is not valid */ - // public List parseJSON(String JSONData) { public CharityRegistry parseJSON(String JSONData) { Gson gson = new Gson(); APICharityData[] charityData = gson.fromJson(JSONData, APICharityData[].class); if (charityData == null) { - // return new ArrayList<>(); return new CharityRegistry(); } - // Filters out "obs" status due to non-unique org_number values - /* - return Arrays.stream(charityData) - .filter(c-> !"obs".equalsIgnoreCase(c.getStatus())) - .toList(); - - */ - - // Alternate using predefiend Charity class CharityRegistry charityRegistry = new CharityRegistry(); for (APICharityData apiCharityData : charityData) { Charity charity = @@ -102,20 +93,4 @@ public CharityRegistry parseJSON(String JSONData) { } return charityRegistry; } - /** - * Synchronizes the {@code charities} table with the provided list of APICharityData. - * - *

Summary of function: - * - *

- * - * A temporary table is used to determine which records should be deleted. - * - * @param charities a list of ApiCharityDaya objects - * @throws RuntimeException if a {@link SQLException} occurs during database synchronization - */ }