From 10497f2d24be9182d52cb16ae9fe8765b148a491 Mon Sep 17 00:00:00 2001 From: Simon Dalvai Date: Thu, 18 Jul 2024 14:01:17 +0200 Subject: [PATCH] radelt: use ita/ger mapping only for challenges, not not organisations --- .../opendatahub/bdp/radelt/SyncScheduler.java | 7 +---- .../utils/MappingUtilsOrganisationen.java | 30 +++++++------------ 2 files changed, 12 insertions(+), 25 deletions(-) diff --git a/data-collectors/radelt/src/main/java/com/opendatahub/bdp/radelt/SyncScheduler.java b/data-collectors/radelt/src/main/java/com/opendatahub/bdp/radelt/SyncScheduler.java index a4eaede4..fb7bfdb8 100644 --- a/data-collectors/radelt/src/main/java/com/opendatahub/bdp/radelt/SyncScheduler.java +++ b/data-collectors/radelt/src/main/java/com/opendatahub/bdp/radelt/SyncScheduler.java @@ -89,17 +89,12 @@ public void syncJob() { // Initialize pagination variables // Fetch and process organizations OrganisationenResponseDto organizationResponseDtoGer; - OrganisationenResponseDto organizationResponseDtoIta; try { organizationResponseDtoGer = radeltClient.fetchOrganizations( String.valueOf(challengeDto.getId()), "", "", Language.GER); - organizationResponseDtoIta = radeltClient.fetchOrganizations( - String.valueOf(challengeDto.getId()), - "", "", Language.ITA); - - mappingUtilsOrganisationen.mapData(organizationResponseDtoGer, organizationResponseDtoIta, + mappingUtilsOrganisationen.mapData(organizationResponseDtoGer, this.organizationCoordinates, stationsOrganisationen, dataOrganisationen); } catch (Exception e) { diff --git a/data-collectors/radelt/src/main/java/com/opendatahub/bdp/radelt/utils/MappingUtilsOrganisationen.java b/data-collectors/radelt/src/main/java/com/opendatahub/bdp/radelt/utils/MappingUtilsOrganisationen.java index 840f2002..2cd1c9f8 100644 --- a/data-collectors/radelt/src/main/java/com/opendatahub/bdp/radelt/utils/MappingUtilsOrganisationen.java +++ b/data-collectors/radelt/src/main/java/com/opendatahub/bdp/radelt/utils/MappingUtilsOrganisationen.java @@ -19,8 +19,6 @@ import com.opendatahub.bdp.radelt.dto.common.RadeltGeoDto; import org.slf4j.Logger; import org.slf4j.LoggerFactory; - -import java.util.List; import java.util.Map; @Component @@ -34,24 +32,19 @@ public class MappingUtilsOrganisationen { public final String DATA_ORIGIN = "SuedtirolRadelt_AltoAdigePedala"; public final String DATA_TYPE = "CompanyGamificationAction"; - public void mapData(OrganisationenResponseDto responseDtoGer, OrganisationenResponseDto responseDtoIta, + public void mapData(OrganisationenResponseDto responseDto, Map organizationCoordinates, StationList stationList, DataMapDto rootMap) { - List organisationsGer = responseDtoGer.getData().getOrganisations(); - List organisationsIta = responseDtoIta.getData().getOrganisations(); - - for (int i = 0; i < organisationsGer.size(); i++) { - - StationDto stationDto = mapToStationDto(organisationsGer.get(i), organisationsIta.get(i), - organizationCoordinates); + for (RadeltOrganisationenDto organisationenDto : responseDto.getData().getOrganisations()) { + StationDto stationDto = mapToStationDto(organisationenDto, organizationCoordinates); if (stationDto.getId() == null) {// TODO: handle duplicated entries? LOG.debug("Skipping station with empty statistics"); continue; } stationList.add(stationDto); - for (RadeltChallengeStatisticDto challengeStatisticDto : organisationsGer.get(i).getStatistics() + for (RadeltChallengeStatisticDto challengeStatisticDto : organisationenDto.getStatistics() .getChallengeStatistics()) { long timestamp = challengeStatisticDto.getCreated_at(); @@ -77,26 +70,25 @@ public void mapData(OrganisationenResponseDto responseDtoGer, OrganisationenResp } - private StationDto mapToStationDto(RadeltOrganisationenDto organisationGer, RadeltOrganisationenDto organisationIta, + private StationDto mapToStationDto(RadeltOrganisationenDto organisation, Map organizationCoordinates) { StationDto stationDto = new StationDto(); - RadeltStatisticsDto statisticsDto = organisationGer.getStatistics(); + RadeltStatisticsDto statisticsDto = organisation.getStatistics(); if (statisticsDto != null) { RadeltChallengeStatisticDto challengeStatistics = statisticsDto.getChallengeStatistics().get(0); if (challengeStatistics.getChallenge_id() != null) { stationDto.setId(String.valueOf(challengeStatistics.getId()) + "-" + String.valueOf(challengeStatistics.getChallenge_id())); - stationDto.setName(organisationGer.getName() + "_" - + organisationIta.getName() + '-' + challengeStatistics.getChallenge_name()); + stationDto.setName(organisation.getName() + '-' + challengeStatistics.getChallenge_name()); stationDto.setStationType(DATA_TYPE); // METADATA - stationDto.getMetaData().put("type", organisationGer.getType()); - stationDto.getMetaData().put("logo", organisationGer.getLogo()); - stationDto.getMetaData().put("website", organisationGer.getWebsite()); - stationDto.getMetaData().put("peopleTotal", organisationGer.getPeopleTotal()); + stationDto.getMetaData().put("type", organisation.getType()); + stationDto.getMetaData().put("logo", organisation.getLogo()); + stationDto.getMetaData().put("website", organisation.getWebsite()); + stationDto.getMetaData().put("peopleTotal", organisation.getPeopleTotal()); stationDto.getMetaData().put("challenge_type", challengeStatistics.getChallenge_type()); // Additional