本文整理汇总了Java中org.onebusaway.gtfs.model.AgencyAndId类的典型用法代码示例。如果您正苦于以下问题:Java AgencyAndId类的具体用法?Java AgencyAndId怎么用?Java AgencyAndId使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AgencyAndId类属于org.onebusaway.gtfs.model包,在下文中一共展示了AgencyAndId类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testSyntheticGetTripAgencyIdsReferencingServiceId
import org.onebusaway.gtfs.model.AgencyAndId; //导入依赖的package包/类
@Test
public void testSyntheticGetTripAgencyIdsReferencingServiceId() {
GtfsRelationalDaoImpl dao = new GtfsRelationalDaoImpl();
AgencyAndId serviceId = new AgencyAndId("C", "serviceId");
Trip tripA = new Trip();
tripA.setId(new AgencyAndId("A", "tripId"));
tripA.setServiceId(serviceId);
dao.saveEntity(tripA);
Trip tripB = new Trip();
tripB.setId(new AgencyAndId("B", "tripId"));
tripB.setServiceId(serviceId);
dao.saveEntity(tripB);
List<String> agencyIds = dao.getTripAgencyIdsReferencingServiceId(serviceId);
assertEquals(2, agencyIds.size());
assertTrue(agencyIds.contains("A"));
assertTrue(agencyIds.contains("B"));
}
示例2: testFrequency
import org.onebusaway.gtfs.model.AgencyAndId; //导入依赖的package包/类
@Test
public void testFrequency() throws CsvEntityIOException, IOException {
_reader.setDefaultAgencyId("1");
Trip trip = new Trip();
trip.setId(new AgencyAndId("1", "trip"));
_reader.injectEntity(trip);
StringBuilder b = new StringBuilder();
b.append("trip_id,start_time,end_time,headway_secs,exact_times\n");
b.append("trip,08:30:00,09:45:00,300,1\n");
_reader.readEntities(Frequency.class, new StringReader(b.toString()));
Frequency frequency = _dao.getFrequencyForId(1);
assertEquals(30600, frequency.getStartTime());
assertEquals(35100, frequency.getEndTime());
assertEquals(1, frequency.getExactTimes());
assertEquals(300, frequency.getHeadwaySecs());
assertSame(trip, frequency.getTrip());
}
示例3: translateFromCSVToObject
import org.onebusaway.gtfs.model.AgencyAndId; //导入依赖的package包/类
@Override
public void translateFromCSVToObject(CsvEntityContext context,
Map<String, Object> csvValues, BeanWrapper object) {
String agencyId = (String) csvValues.get(_csvFieldName + "_agencyId");
String id = (String) csvValues.get(_csvFieldName + "_id");
boolean missing = (agencyId == null || agencyId.isEmpty())
|| (id == null || id.isEmpty());
if (missing) {
if (_required)
throw new MissingRequiredFieldException(_entityType, _csvFieldName);
return;
}
AgencyAndId agencyAndId = new AgencyAndId(agencyId, id);
object.setPropertyValue(_objFieldName, agencyAndId);
}
示例4: getStopsForStation
import org.onebusaway.gtfs.model.AgencyAndId; //导入依赖的package包/类
@Override
public List<Stop> getStopsForStation(Stop station) {
if (_stopsByStation == null) {
_stopsByStation = new HashMap<Stop, List<Stop>>();
for (Stop stop : getAllStops()) {
if (stop.getLocationType() == 0 && stop.getParentStation() != null) {
Stop parentStation = getStopForId(new AgencyAndId(
stop.getId().getAgencyId(), stop.getParentStation()));
List<Stop> subStops = _stopsByStation.get(parentStation);
if (subStops == null) {
subStops = new ArrayList<Stop>(2);
_stopsByStation.put(parentStation, subStops);
}
subStops.add(stop);
}
}
}
return list(_stopsByStation.get(station));
}
示例5: getTripsForBlockId
import org.onebusaway.gtfs.model.AgencyAndId; //导入依赖的package包/类
@Override
public List<Trip> getTripsForBlockId(AgencyAndId blockId) {
if (_tripsByBlockId == null) {
_tripsByBlockId = new HashMap<AgencyAndId, List<Trip>>();
for (Trip trip : getAllTrips()) {
if (trip.getBlockId() != null) {
AgencyAndId bid = new AgencyAndId(trip.getId().getAgencyId(),
trip.getBlockId());
List<Trip> trips = _tripsByBlockId.get(bid);
if (trips == null) {
trips = new ArrayList<Trip>();
_tripsByBlockId.put(bid, trips);
}
trips.add(trip);
}
}
}
return list(_tripsByBlockId.get(blockId));
}
示例6: testBart
import org.onebusaway.gtfs.model.AgencyAndId; //导入依赖的package包/类
@Test
public void testBart() throws IOException, ParseException {
File resourcePath = GtfsTestData.getBartGtfs();
String agencyId = "BART";
GtfsDao entityStore = processFeed(resourcePath, agencyId, false);
Collection<Frequency> frequencies = entityStore.getAllFrequencies();
assertEquals(6, frequencies.size());
List<Frequency> frequenciesForTrip = GtfsTestData.grep(frequencies,
"trip.id", new AgencyAndId("AirBART", "M-FSAT1DN"));
assertEquals(1, frequenciesForTrip.size());
Frequency frequencyForTrip = frequenciesForTrip.get(0);
assertEquals(18000, frequencyForTrip.getStartTime());
assertEquals(21600, frequencyForTrip.getEndTime());
assertEquals(1200, frequencyForTrip.getHeadwaySecs());
Collection<Transfer> transfers = entityStore.getAllTransfers();
assertEquals(4, transfers.size());
}
示例7: testUtf8
import org.onebusaway.gtfs.model.AgencyAndId; //导入依赖的package包/类
@Test
public void testUtf8() throws IOException, ParseException,
InterruptedException {
MockGtfs mockGtfs = MockGtfs.create();
mockGtfs.putDefaultStopTimes();
mockGtfs.putFile("routes.txt", new File(
"src/test/resources/org/onebusaway/gtfs/utf8-routes.txt"));
String agencyId = "1";
GtfsDao dao = processFeed(mockGtfs.getPath(), agencyId, false);
Route route = dao.getRouteForId(new AgencyAndId(agencyId, "R10"));
assertEquals("Enguera-Alcúdia de Crespins-Xàtiva", route.getLongName());
route = dao.getRouteForId(new AgencyAndId(agencyId, "R11"));
assertEquals("Tuéjar-Casinos", route.getLongName());
}
示例8: testFrequency
import org.onebusaway.gtfs.model.AgencyAndId; //导入依赖的package包/类
@Test
public void testFrequency() throws CsvEntityIOException, IOException {
GtfsReader reader = new GtfsReader();
reader.setDefaultAgencyId("1");
Trip trip = new Trip();
trip.setId(new AgencyAndId("1", "trip"));
reader.injectEntity(trip);
StringBuilder b = new StringBuilder();
b.append("trip_id,start_time,end_time,headway_secs,exact_times\n");
b.append("trip,08:30:00,09:45:00,300,1\n");
reader.readEntities(Frequency.class, new StringReader(b.toString()));
Frequency frequency = reader.getEntityStore().getEntityForId(
Frequency.class, 1);
assertEquals(30600, frequency.getStartTime());
assertEquals(35100, frequency.getEndTime());
assertEquals(1, frequency.getExactTimes());
assertEquals(300, frequency.getHeadwaySecs());
assertSame(trip, frequency.getTrip());
}
示例9: testCsvParser
import org.onebusaway.gtfs.model.AgencyAndId; //导入依赖的package包/类
@Test
public void testCsvParser() throws CsvEntityIOException, IOException {
GtfsReader reader = new GtfsReader();
reader.setDefaultAgencyId("1");
Agency agency = new Agency();
agency.setId("1");
reader.setAgencies(Arrays.asList(agency));
StringBuilder b = new StringBuilder();
b.append("agency_id,route_id,route_short_name,route_long_name,route_type\n");
b.append(" 1, R-10, 10, \"Ten, Ten\",3\n");
reader.readEntities(Route.class, new StringReader(b.toString()));
Route route = reader.getEntityStore().getEntityForId(Route.class,
new AgencyAndId("1", "R-10"));
assertEquals("Ten, Ten", route.getLongName());
}
示例10: testExtensionRead
import org.onebusaway.gtfs.model.AgencyAndId; //导入依赖的package包/类
@Test
public void testExtensionRead() throws IOException {
MockGtfs gtfs = MockGtfs.create();
gtfs.putMinimal();
gtfs.putStops(2, "label=a,b");
DefaultEntitySchemaFactory factory = GtfsEntitySchemaFactory.createEntitySchemaFactory();
factory.addExtension(Stop.class, StopExtension.class);
GtfsReader reader = new GtfsReader();
reader.setEntitySchemaFactory(factory);
GtfsMutableRelationalDao dao = gtfs.read(reader);
Stop stop = dao.getStopForId(new AgencyAndId("a0", "s0"));
StopExtension extension = stop.getExtension(StopExtension.class);
assertEquals("a", extension.getLabel());
}
示例11: testPutCalendarDates
import org.onebusaway.gtfs.model.AgencyAndId; //导入依赖的package包/类
@Test
public void testPutCalendarDates() throws IOException {
_gtfs.putMinimal();
_gtfs.putCalendarDates("sid0=20120901,-20120902", "sid1=20120903");
GtfsRelationalDao dao = _gtfs.read();
List<ServiceCalendarDate> dates = dao.getCalendarDatesForServiceId(new AgencyAndId(
"a0", "sid0"));
assertEquals(2, dates.size());
assertEquals(new ServiceDate(2012, 9, 1), dates.get(0).getDate());
assertEquals(1, dates.get(0).getExceptionType());
assertEquals(new ServiceDate(2012, 9, 2), dates.get(1).getDate());
assertEquals(2, dates.get(1).getExceptionType());
dates = dao.getCalendarDatesForServiceId(new AgencyAndId("a0", "sid1"));
assertEquals(1, dates.size());
assertEquals(new ServiceDate(2012, 9, 3), dates.get(0).getDate());
assertEquals(1, dates.get(0).getExceptionType());
}
示例12: testDaylightSavingTime
import org.onebusaway.gtfs.model.AgencyAndId; //导入依赖的package包/类
@Test
public void testDaylightSavingTime() {
CalendarServiceDataFactoryImpl factory = new CalendarServiceDataFactoryImpl();
Agency agencyA = agency("A", "America/Los_Angeles");
AgencyAndId serviceId = new AgencyAndId("A", "2");
ServiceDate dStart = new ServiceDate(2012, 3, 1);
ServiceDate dEnd = new ServiceDate(2012, 3, 31);
ServiceCalendar c = calendar(serviceId, dStart, dEnd, "1111111");
GtfsRelationalDaoImpl dao = new GtfsRelationalDaoImpl();
factory.setGtfsDao(dao);
saveEntities(dao, agencyA);
saveEntities(dao, c);
CalendarServiceData data = factory.createData();
List<ServiceDate> serviceDates = data.getServiceDatesForServiceId(serviceId);
assertTrue(serviceDates.contains(new ServiceDate(2012, 3, 11)));
}
开发者ID:gov-ithub,项目名称:infotranspub-backend,代码行数:24,代码来源:CalendarServiceDataFactoryImplSyntheticTest.java
示例13: getTripAgencyIdsReferencingServiceId
import org.onebusaway.gtfs.model.AgencyAndId; //导入依赖的package包/类
/****
* {@link GtfsRelationalDao} Interface
****/
@Override
public List<String> getTripAgencyIdsReferencingServiceId(AgencyAndId serviceId) {
return _ops.findByNamedQueryAndNamedParam("agencyIdsReferencingServiceId",
"serviceId", serviceId);
}
示例14: getAllServiceIds
import org.onebusaway.gtfs.model.AgencyAndId; //导入依赖的package包/类
@Override
public List<AgencyAndId> getAllServiceIds() {
List<AgencyAndId> calendarIds = _ops.findByNamedQuery("calendarServiceIds");
List<AgencyAndId> calendarDateIds = _ops.findByNamedQuery("calendarDateServiceIds");
Set<AgencyAndId> allIds = new HashSet<AgencyAndId>();
allIds.addAll(calendarIds);
allIds.addAll(calendarDateIds);
return new ArrayList<AgencyAndId>(allIds);
}
示例15: testDaylightSavingTimeCalendarDatesOnly
import org.onebusaway.gtfs.model.AgencyAndId; //导入依赖的package包/类
@Test
public void testDaylightSavingTimeCalendarDatesOnly() throws IOException {
CalendarServiceDataFactoryImpl factory = new CalendarServiceDataFactoryImpl();
Agency agencyA = agency("A", "America/Los_Angeles");
AgencyAndId serviceId = new AgencyAndId("A", "2");
ServiceCalendarDate cd1 = calendarDate(serviceId, new ServiceDate(2012, 3,
10), ServiceCalendarDate.EXCEPTION_TYPE_ADD);
ServiceCalendarDate cd2 = calendarDate(serviceId, new ServiceDate(2012, 3,
11), ServiceCalendarDate.EXCEPTION_TYPE_ADD);
ServiceCalendarDate cd3 = calendarDate(serviceId, new ServiceDate(2012, 3,
12), ServiceCalendarDate.EXCEPTION_TYPE_ADD);
GtfsRelationalDaoImpl dao = new GtfsRelationalDaoImpl();
factory.setGtfsDao(dao);
saveEntities(dao, agencyA);
saveEntities(dao, cd1, cd2, cd3);
CalendarServiceData data = factory.createData();
List<ServiceDate> serviceDates = data.getServiceDatesForServiceId(serviceId);
assertEquals(serviceDates,
Arrays.asList(cd1.getDate(), cd2.getDate(), cd3.getDate()));
}
开发者ID:gov-ithub,项目名称:infotranspub-backend,代码行数:28,代码来源:CalendarServiceDataFactoryImplSyntheticTest.java