本文整理汇总了Java中org.onebusaway.gtfs.serialization.GtfsReader.setEntityStore方法的典型用法代码示例。如果您正苦于以下问题:Java GtfsReader.setEntityStore方法的具体用法?Java GtfsReader.setEntityStore怎么用?Java GtfsReader.setEntityStore使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.onebusaway.gtfs.serialization.GtfsReader
的用法示例。
在下文中一共展示了GtfsReader.setEntityStore方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setup
import org.onebusaway.gtfs.serialization.GtfsReader; //导入方法依赖的package包/类
@BeforeClass
public static void setup() throws IOException {
Configuration config = new Configuration();
config = config.configure("org/onebusaway/gtfs/hibernate-configuration.xml");
_sessionFactory = config.buildSessionFactory();
_dao = new HibernateGtfsRelationalDaoImpl(_sessionFactory);
GtfsReader reader = new GtfsReader();
reader.setInputLocation(new File(
"src/test/resources/org/onebusaway/gtfs/caltrain-long-route.zip"));
reader.setEntityStore(_dao);
reader.setDefaultAgencyId(_agencyId);
List<Class<?>> entityClasses = reader.getEntityClasses();
entityClasses.clear();
entityClasses.add(Agency.class);
entityClasses.add(Route.class);
reader.run();
}
示例2: setup
import org.onebusaway.gtfs.serialization.GtfsReader; //导入方法依赖的package包/类
@BeforeClass
public static void setup() throws IOException {
Configuration config = new Configuration();
config = config.configure("org/onebusaway/gtfs/hibernate-configuration.xml");
_sessionFactory = config.buildSessionFactory();
_dao = new HibernateGtfsRelationalDaoImpl(_sessionFactory);
GtfsReader reader = new GtfsReader();
reader.setInputLocation(new File(
"src/test/resources/org/onebusaway/gtfs/caltrain.zip"));
reader.setEntityStore(_dao);
reader.setDefaultAgencyId(_agencyId);
reader.run();
}
开发者ID:gov-ithub,项目名称:infotranspub-backend,代码行数:17,代码来源:HibernateGtfsRelationalDaoImplCaltrainTest.java
示例3: setup
import org.onebusaway.gtfs.serialization.GtfsReader; //导入方法依赖的package包/类
@BeforeClass
public static void setup() throws IOException {
Configuration config = new Configuration();
config = config.configure("org/onebusaway/gtfs/hibernate-configuration.xml");
_sessionFactory = config.buildSessionFactory();
_dao = new HibernateGtfsRelationalDaoImpl(_sessionFactory);
GtfsReader reader = new GtfsReader();
reader.setInputLocation(new File(
"src/test/resources/org/onebusaway/gtfs/bart.zip"));
reader.setEntityStore(_dao);
reader.setDefaultAgencyId(_agencyId);
reader.run();
}
示例4: setup
import org.onebusaway.gtfs.serialization.GtfsReader; //导入方法依赖的package包/类
@Before
public void setup() throws IOException {
Configuration config = new Configuration();
config = config.configure("org/onebusaway/gtfs/hibernate-configuration.xml");
_sessionFactory = config.buildSessionFactory();
_dao = new HibernateGtfsRelationalDaoImpl(_sessionFactory);
_dao.open();
_reader = new GtfsReader();
_reader.setEntityStore(_dao);
}
示例5: read
import org.onebusaway.gtfs.serialization.GtfsReader; //导入方法依赖的package包/类
public GtfsMutableRelationalDao read(GtfsReader reader) throws IOException {
reader.setInputLocation(_path);
GtfsRelationalDaoImpl dao = new GtfsRelationalDaoImpl();
reader.setEntityStore(dao);
try {
reader.run();
} finally {
reader.close();
}
return dao;
}
示例6: main
import org.onebusaway.gtfs.serialization.GtfsReader; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException {
if (args.length != 1) {
System.err.println("usage: gtfsPath");
System.exit(-1);
}
GtfsReader reader = new GtfsReader();
reader.setInputLocation(new File(args[0]));
/**
* You can register an entity handler that listens for new objects as they
* are read
*/
reader.addEntityHandler(new GtfsEntityHandler());
/**
* Or you can use the internal entity store, which has references to all the
* loaded entities
*/
GtfsDaoImpl store = new GtfsDaoImpl();
reader.setEntityStore(store);
reader.run();
// Access entities through the store
Map<AgencyAndId, Route> routesById = store.getEntitiesByIdForEntityType(
AgencyAndId.class, Route.class);
for (Route route : routesById.values()) {
System.out.println("route: " + route.getShortName());
}
}
示例7: get
import org.onebusaway.gtfs.serialization.GtfsReader; //导入方法依赖的package包/类
@Override
public GtfsRelationalDao get() {
_log.info("Loading GTFS from {}", _gtfsPath.toString());
GtfsRelationalDaoImpl dao = new GtfsRelationalDaoImpl();
GtfsReader reader = new GtfsReader();
reader.setEntityStore(dao);
try {
reader.setInputLocation(_gtfsPath);
reader.run();
reader.close();
} catch (IOException e) {
throw new RuntimeException("Failure while reading GTFS", e);
}
return dao;
}
示例8: setGtfsBundle
import org.onebusaway.gtfs.serialization.GtfsReader; //导入方法依赖的package包/类
public void setGtfsBundle(File gtfsBundle) throws IOException {
GtfsReader reader = new GtfsReader();
reader.setInputLocation(gtfsBundle);
dao = new GtfsRelationalDaoImpl();
reader.setEntityStore((GtfsRelationalDaoImpl) dao);
reader.run();
}
示例9: main
import org.onebusaway.gtfs.serialization.GtfsReader; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException {
if (!(args.length == 1 || args.length == 2)) {
System.err.println("usage: gtfsPath [hibernate-config.xml]");
System.exit(-1);
}
String resource = "classpath:org/onebusaway/gtfs/examples/hibernate-configuration-examples.xml";
if (args.length == 2)
resource = args[1];
HibernateGtfsFactory factory = createHibernateGtfsFactory(resource);
GtfsReader reader = new GtfsReader();
reader.setInputLocation(new File(args[0]));
GtfsMutableRelationalDao dao = factory.getDao();
reader.setEntityStore(dao);
reader.run();
Collection<Stop> stops = dao.getAllStops();
for (Stop stop : stops)
System.out.println(stop.getName());
CalendarService calendarService = factory.getCalendarService();
Set<AgencyAndId> serviceIds = calendarService.getServiceIds();
for (AgencyAndId serviceId : serviceIds) {
Set<ServiceDate> dates = calendarService.getServiceDatesForServiceId(serviceId);
ServiceDate from = null;
ServiceDate to = null;
for (ServiceDate date : dates) {
from = min(from, date);
to = max(to, date);
}
System.out.println("serviceId=" + serviceId + " from=" + from + " to="
+ to);
}
}
示例10: testExtensionWrite
import org.onebusaway.gtfs.serialization.GtfsReader; //导入方法依赖的package包/类
@Test
public void testExtensionWrite() throws IOException {
DefaultEntitySchemaFactory factory = GtfsEntitySchemaFactory.createEntitySchemaFactory();
factory.addExtension(Stop.class, StopExtension.class);
{
MockGtfs gtfs = MockGtfs.create();
gtfs.putMinimal();
gtfs.putStops(2, "label=a,b");
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());
GtfsWriter writer = new GtfsWriter();
writer.setEntitySchemaFactory(factory);
writer.setOutputLocation(_tmpDirectory);
writer.run(dao);
writer.close();
}
{
GtfsReader reader2 = new GtfsReader();
reader2.setEntitySchemaFactory(factory);
reader2.setInputLocation(_tmpDirectory);
GtfsRelationalDaoImpl dao2 = new GtfsRelationalDaoImpl();
reader2.setDefaultAgencyId("a0");
reader2.setEntityStore(dao2);
reader2.readEntities(Stop.class);
Stop stop2 = dao2.getStopForId(new AgencyAndId("a0", "s0"));
StopExtension extension2 = stop2.getExtension(StopExtension.class);
assertEquals("a", extension2.getLabel());
}
}
示例11: readGtfs
import org.onebusaway.gtfs.serialization.GtfsReader; //导入方法依赖的package包/类
public static GtfsContext readGtfs(File path, String defaultAgencyId) throws IOException {
GtfsRelationalDaoImpl dao = new GtfsRelationalDaoImpl();
GtfsReader reader = new GtfsReader();
reader.setInputLocation(path);
reader.setEntityStore(dao);
if (defaultAgencyId != null) {
reader.setDefaultAgencyId(defaultAgencyId);
}
reader.run();
CalendarService calendarService = createCalendarService(dao);
return new GtfsContextImpl(dao, calendarService);
}
示例12: readGtfs
import org.onebusaway.gtfs.serialization.GtfsReader; //导入方法依赖的package包/类
public static <T extends GenericMutableDao> void readGtfs(T entityStore,
File resourcePath, String defaultAgencyId) throws IOException {
GtfsReader reader = new GtfsReader();
reader.setDefaultAgencyId(defaultAgencyId);
reader.setInputLocation(resourcePath);
reader.setEntityStore(entityStore);
reader.run();
}