private Route doMap(org.onebusaway.gtfs.model.Route rhs) { Route lhs = new Route(); lhs.setId(AgencyAndIdMapper.mapAgencyAndId(rhs.getId())); lhs.setAgency(agencyMapper.map(rhs.getAgency())); lhs.setShortName(rhs.getShortName()); lhs.setLongName(rhs.getLongName()); lhs.setType(rhs.getType()); lhs.setDesc(rhs.getDesc()); lhs.setUrl(rhs.getUrl()); lhs.setColor(rhs.getColor()); lhs.setTextColor(rhs.getTextColor()); lhs.setRouteBikesAllowed(rhs.getRouteBikesAllowed()); lhs.setBikesAllowed(rhs.getBikesAllowed()); lhs.setSortOrder(rhs.getSortOrder()); lhs.setBrandingUrl(rhs.getBrandingUrl()); return lhs; } }
public static String getRouteName(Route route) { if (route.getShortName() != null) return route.getShortName(); return route.getLongName(); }
private String getRouteCollectionIdForRoute(Route route) { String id = trim(route.getShortName()); if (id == null || id.length() == 0) id = trim(route.getLongName()); if (id == null || id.length() == 0) throw new IllegalStateException("no short or long name for route " + route.getId()); id = id.replace('/', '_'); id = id.replace('\\', '_'); return id; }
@Override public void run(TransformContext context, GtfsMutableRelationalDao dao, Object entity) { if (!(entity instanceof Trip)) return; Trip trip = (Trip) entity; String headsign = trip.getTripHeadsign(); Route route = trip.getRoute(); String shortName = route.getShortName(); if (headsign == null || shortName == null) return; headsign = headsign.replaceAll("^" + shortName + "\\s+", ""); headsign = headsign.replaceAll("-\\s+" + shortName + "\\s+", "- "); trip.setTripHeadsign(headsign); }
public void validateEntity(CsvEntityContext context, Map<String, Object> csvValues, BeanWrapper object) { Route route = object.getWrappedInstance(Route.class); String shortName = route.getShortName(); String longName = route.getLongName(); if ((shortName == null || shortName.length() == 0) && (longName == null || longName.length() == 0)) throw new RouteNameException(route.getId()); } }
public void validateEntity(CsvEntityContext context, Map<String, Object> csvValues, BeanWrapper object) { Route route = object.getWrappedInstance(Route.class); String shortName = route.getShortName(); String longName = route.getLongName(); if ((shortName == null || shortName.length() == 0) && (longName == null || longName.length() == 0)) throw new RouteNameException(route.getId()); } }
private AgencyAndId getRouteCollectionIdForRoute(Route route) { String id = trim(route.getShortName()); // If no short name is supplied, we go back to using the original route id if (id == null || id.length() == 0) id = route.getId().getId(); id = id.replace('/', '_'); id = id.replace('\\', '_'); return new AgencyAndId(route.getId().getAgencyId(), id); }
private AgencyAndId getRouteCollectionIdForRoute(Route route) { String id = trim(route.getShortName()); // If no short name is supplied, we go back to using the original route id if (id == null || id.length() == 0) id = route.getId().getId(); id = id.replace('/', '_'); id = id.replace('\\', '_'); return new AgencyAndId(route.getId().getAgencyId(), id); }
private List<Document> getRouteCollectionAsDocuments( RouteCollection routeCollection) { List<Document> documents = new ArrayList<Document>(); AgencyAndId routeCollectionId = routeCollection.getId(); for (Route route : routeCollection.getRoutes()) { Document document = new Document(); // Route Collection document.add(new Field(FIELD_ROUTE_COLLECTION_AGENCY_ID, routeCollectionId.getAgencyId(), Field.Store.YES, Field.Index.NO)); document.add(new Field(FIELD_ROUTE_COLLECTION_ID, routeCollectionId.getId(), Field.Store.YES, Field.Index.NO)); // Id AgencyAndId id = route.getId(); document.add(new Field(FIELD_AGENCY_ID, id.getAgencyId(), Field.Store.YES, Field.Index.NO)); document.add(new Field(FIELD_ROUTE_ID, id.getId(), Field.Store.YES, Field.Index.ANALYZED)); if (isValue(route.getShortName())) document.add(new Field(FIELD_ROUTE_SHORT_NAME, route.getShortName(), Field.Store.NO, Field.Index.ANALYZED)); if (isValue(route.getLongName())) document.add(new Field(FIELD_ROUTE_LONG_NAME, route.getLongName(), Field.Store.NO, Field.Index.ANALYZED)); if (isValue(route.getDesc())) document.add(new Field(FIELD_ROUTE_DESCRIPTION, route.getDesc(), Field.Store.NO, Field.Index.ANALYZED)); documents.add(document); } return documents; }
boolean isExpress = trip.getTripShortName().equals("EXPRESS"); if (isExpress) { _log.info("route(" + route.getShortName() + ") gets an E for trip " + trip.getId()); trip.setRouteShortName(trip.getRoute().getShortName() + "E"); if (addLocalVsExpressToTripName) { String tripHeadsign = trip.getTripHeadsign();
identifier = route.getShortName(); route.setShortName(refRoute.getShortName()); route.setLongName(refRoute.getLongName()); route.setType(refRoute.getType());
route.setShortName(refRoute.getShortName()); route.setLongName(refRoute.getLongName()); route.setType(refRoute.getType());
@Override public void run(TransformContext context, GtfsMutableRelationalDao dao) { GtfsMutableRelationalDao reference = (GtfsMutableRelationalDao) context.getReferenceReader().getEntityStore(); HashMap<String, Route> referenceRoutes = new HashMap<>(); for (Route route : reference.getAllRoutes()) { referenceRoutes.put(route.getId().getId(), route); } for (Route route: dao.getAllRoutes()) { String identifier = route.getId().getId(); if (identifier.length() > 2) { identifier = identifier.substring(0,2); } Route refRoute = referenceRoutes.get(identifier); if (refRoute != null) { route.setShortName(refRoute.getShortName()); route.setLongName(refRoute.getLongName()); route.setType(refRoute.getType()); route.setDesc(refRoute.getDesc()); route.setUrl(refRoute.getUrl()); route.setColor(refRoute.getColor()); route.setTextColor(refRoute.getTextColor()); route.setId(refRoute.getId()); } } } }
private Route getShuttleRoute(GtfsMutableRelationalDao dao, Route orig) { Route shuttleRoute = new Route(orig); AgencyAndId id = new AgencyAndId(shuttleRoute.getId().getAgencyId(), shuttleRoute.getId().getId() + SHUTTLE_ID_SUFFIX); shuttleRoute.setId(id); shuttleRoute.setShortName(shuttleRoute.getShortName() + SHUTTLE_ID_SUFFIX); shuttleRoute.setLongName(shuttleRoute.getLongName() + SHUTTLE_NAME_SUFFIX); shuttleRoute.setType(SHUTTLE_ROUTE_TYPE); dao.saveEntity(shuttleRoute); return shuttleRoute; } }
private void setRoute(Route daoRoute, Route refRoute) { daoRoute.setShortName(refRoute.getShortName()); daoRoute.setLongName(refRoute.getLongName()); daoRoute.setType(refRoute.getType()); daoRoute.setDesc(refRoute.getDesc()); daoRoute.setUrl(refRoute.getUrl()); daoRoute.setColor(refRoute.getColor()); daoRoute.setTextColor(refRoute.getTextColor()); }
private void setLTDRoute(Route daoRoute, Route refRoute) { daoRoute.setShortName(refRoute.getShortName()); daoRoute.setLongName(refRoute.getLongName()); daoRoute.setType(refRoute.getType()); daoRoute.setDesc(refRoute.getDesc()); daoRoute.setUrl(refRoute.getUrl()); daoRoute.setColor(refRoute.getColor()); daoRoute.setTextColor(refRoute.getTextColor()); //set the id to also be the same daoRoute.setId(refRoute.getId()); } }
addValueToCounterIfValid(route.getShortName(), shortNames, count); addValueToCounterIfValid(route.getLongName(), longNames, count); addValueToCounterIfValid(route.getDesc(), descriptions, count);
addValueToCounterIfValid(route.getShortName(), shortNames, count); addValueToCounterIfValid(route.getLongName(), longNames, count); addValueToCounterIfValid(route.getDesc(), descriptions, count);
addValueToCounterIfValid(route.getShortName(), shortNames, count); addValueToCounterIfValid(route.getLongName(), longNames, count); addValueToCounterIfValid(route.getDesc(), descriptions, count);