Skip to content

Commit

Permalink
radelt: use ita/ger mapping only for challenges, not not organisations
Browse files Browse the repository at this point in the history
  • Loading branch information
dulvui committed Jul 18, 2024
1 parent 53aeebf commit 10497f2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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<String, RadeltGeoDto> organizationCoordinates, StationList stationList,
DataMapDto<RecordDtoImpl> rootMap) {

List<RadeltOrganisationenDto> organisationsGer = responseDtoGer.getData().getOrganisations();
List<RadeltOrganisationenDto> 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();

Expand All @@ -77,26 +70,25 @@ public void mapData(OrganisationenResponseDto responseDtoGer, OrganisationenResp

}

private StationDto mapToStationDto(RadeltOrganisationenDto organisationGer, RadeltOrganisationenDto organisationIta,
private StationDto mapToStationDto(RadeltOrganisationenDto organisation,
Map<String, RadeltGeoDto> 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
Expand Down

0 comments on commit 10497f2

Please sign in to comment.