use of org.opentripplanner.model.FareAttribute in project OpenTripPlanner by opentripplanner.
the class DefaultFareServiceFactory method fillFareRules.
protected void fillFareRules(Collection<FareAttribute> fareAttributes, Collection<FareRule> fareRules, Map<FeedScopedId, FareRuleSet> fareRuleSet) {
/*
* Create an empty FareRuleSet for each FareAttribute, as some FareAttribute may have no
* rules attached to them.
*/
for (FareAttribute fare : fareAttributes) {
FeedScopedId id = fare.getId();
FareRuleSet fareRule = fareRuleSet.get(id);
if (fareRule == null) {
fareRule = new FareRuleSet(fare);
fareRuleSet.put(id, fareRule);
}
}
/*
* For each fare rule, add it to the FareRuleSet of the fare.
*/
for (FareRule rule : fareRules) {
FareAttribute fare = rule.getFare();
FeedScopedId id = fare.getId();
FareRuleSet fareRule = fareRuleSet.get(id);
if (fareRule == null) {
// Should never happen by design
LOG.error("Inexistant fare ID in fare rule: " + id);
continue;
}
String contains = rule.getContainsId();
if (contains != null) {
fareRule.addContains(contains);
}
String origin = rule.getOriginId();
String destination = rule.getDestinationId();
if (origin != null || destination != null) {
fareRule.addOriginDestination(origin, destination);
}
Route route = rule.getRoute();
if (route != null) {
FeedScopedId routeId = route.getId();
fareRule.addRoute(routeId);
}
}
}
use of org.opentripplanner.model.FareAttribute in project OpenTripPlanner by opentripplanner.
the class DefaultFareServiceFactory method fillFareRules.
protected void fillFareRules(Collection<FareAttribute> fareAttributes, Collection<FareRule> fareRules, Map<FeedScopedId, FareRuleSet> fareRuleSet) {
/*
* Create an empty FareRuleSet for each FareAttribute, as some FareAttribute may have no
* rules attached to them.
*/
for (FareAttribute fare : fareAttributes) {
FeedScopedId id = fare.getId();
FareRuleSet fareRule = fareRuleSet.get(id);
if (fareRule == null) {
fareRule = new FareRuleSet(fare);
fareRuleSet.put(id, fareRule);
}
}
/*
* For each fare rule, add it to the FareRuleSet of the fare.
*/
for (FareRule rule : fareRules) {
FareAttribute fare = rule.getFare();
FeedScopedId id = fare.getId();
FareRuleSet fareRule = fareRuleSet.get(id);
if (fareRule == null) {
// Should never happen by design
LOG.error("Inexistant fare ID in fare rule: " + id);
continue;
}
String contains = rule.getContainsId();
if (contains != null) {
fareRule.addContains(contains);
}
String origin = rule.getOriginId();
String destination = rule.getDestinationId();
if (origin != null || destination != null) {
fareRule.addOriginDestination(origin, destination);
}
Route route = rule.getRoute();
if (route != null) {
FeedScopedId routeId = route.getId();
fareRule.addRoute(routeId);
}
}
}
use of org.opentripplanner.model.FareAttribute in project OpenTripPlanner by opentripplanner.
the class FareAttributeMapper method doMap.
private FareAttribute doMap(org.onebusaway.gtfs.model.FareAttribute rhs) {
FareAttribute lhs = new FareAttribute(mapAgencyAndId(rhs.getId()));
lhs.setPrice(rhs.getPrice());
lhs.setCurrencyType(rhs.getCurrencyType());
lhs.setPaymentMethod(rhs.getPaymentMethod());
lhs.setTransfers(rhs.getTransfers());
lhs.setTransferDuration(rhs.getTransferDuration());
lhs.setYouthPrice(rhs.getYouthPrice());
lhs.setSeniorPrice(rhs.getSeniorPrice());
lhs.setJourneyDuration(rhs.getJourneyDuration());
return lhs;
}
Aggregations