Skip to content

Commit

Permalink
Add new fields from system_information
Browse files Browse the repository at this point in the history
  • Loading branch information
testower committed Jun 6, 2024
1 parent 40ac0e0 commit f9e72b1
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@
import org.entur.lamassu.model.entities.RentalApp;
import org.entur.lamassu.model.entities.RentalApps;
import org.entur.lamassu.model.entities.System;
import org.entur.lamassu.model.entities.TranslatedString;
import org.entur.lamassu.model.provider.FeedProvider;
import org.mobilitydata.gbfs.v3_0.system_information.GBFSAndroid;
import org.mobilitydata.gbfs.v3_0.system_information.GBFSAttributionOrganizationName;
import org.mobilitydata.gbfs.v3_0.system_information.GBFSBrandAssets;
import org.mobilitydata.gbfs.v3_0.system_information.GBFSData;
import org.mobilitydata.gbfs.v3_0.system_information.GBFSIos;
Expand Down Expand Up @@ -131,6 +133,9 @@ public System mapSystem(GBFSData systemInformation, FeedProvider feedProvider) {
.orElse(null)
);
system.setPrivacyLastUpdated(systemInformation.getPrivacyLastUpdated());
system.setAttributionOrganizationName(
mapAttributionOrganizationName(systemInformation.getAttributionOrganizationName())
);
system.setRentalApps(mapRentalApps(systemInformation.getRentalApps()));
return system;
}
Expand All @@ -150,6 +155,23 @@ private BrandAssets mapBrandAssets(GBFSBrandAssets brandAssets) {
return mapped;
}

private TranslatedString mapAttributionOrganizationName(
List<GBFSAttributionOrganizationName> attributionOrganizationName
) {
if (attributionOrganizationName == null) {
return null;
}

var mapped = new TranslatedString();
mapped.setTranslation(
attributionOrganizationName
.stream()
.map(name -> translationMapper.mapTranslation(name.getLanguage(), name.getText()))
.toList()
);
return mapped;
}

private RentalApps mapRentalApps(GBFSRentalApps sourceRentalApps) {
if (sourceRentalApps == null) {
return null;
Expand Down
20 changes: 20 additions & 0 deletions src/main/java/org/entur/lamassu/model/entities/System.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public class System implements Entity {
private String termsLastUpdated;
private String privacyUrl;
private String privacyLastUpdated;
private TranslatedString attributionOrganizationName;
private String attributionUrl;
private RentalApps rentalApps;

@Override
Expand Down Expand Up @@ -178,6 +180,24 @@ public void setPrivacyLastUpdated(String privacyLastUpdated) {
this.privacyLastUpdated = privacyLastUpdated;
}

public TranslatedString getAttributionOrganizationName() {
return attributionOrganizationName;
}

public void setAttributionOrganizationName(
TranslatedString attributionOrganizationName
) {
this.attributionOrganizationName = attributionOrganizationName;
}

public String getAttributionUrl() {
return attributionUrl;
}

public void setAttributionUrl(String attributionUrl) {
this.attributionUrl = attributionUrl;
}

public RentalApps getRentalApps() {
return rentalApps;
}
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/graphql/schema.graphqls
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,8 @@ type System {
termsLastUpdated: String
privacyUrl: String
privacyLastUpdated: String
attributionOrganizationName: TranslatedString
attributionUrl: String
rentalApps: RentalApps
}

Expand Down
9 changes: 8 additions & 1 deletion src/test/resources/v3/system_information.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@
}
],
"privacy_last_updated": "2019-01-13",
"attribution_organization_name": [
{
"text": "Another company",
"language": "en"
}
],
"attribution_url": "https://another.com",
"rental_apps": {
"android": {
"discovery_uri": "com.example.android://",
Expand All @@ -65,4 +72,4 @@
}

}
}
}

0 comments on commit f9e72b1

Please sign in to comment.