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 dea4a7f
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 3 deletions.
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
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public void testVehiclesByIdQuery() throws IOException, InterruptedException {
response.get("$.data.vehicles[0].id")
);
assertEquals("TST:Vehicle:1235", response.get("$.data.vehicles[1].id"));
assertEquals("Another company", response.get("$.data.vehicles[0].system.attributionOrganizationName.translation[0].value"));
}

@Test
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 @@
}

}
}
}
2 changes: 1 addition & 1 deletion src/test/resources/vehicle_by_id_query.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,4 @@
}
}
}
}
}
9 changes: 8 additions & 1 deletion src/test/resources/vehicles_by_id_query.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@
}
}
}
attributionOrganizationName {
translation {
language
value
}
}
attributionUrl
rentalApps {
android {
storeUri
Expand All @@ -75,4 +82,4 @@
}
}
}
}
}

0 comments on commit dea4a7f

Please sign in to comment.