use of org.onebusaway.collections.beans.PropertyMethod in project onebusaway-gtfs-modules by OneBusAway.
the class PropertyMethodResolverImpl method getPropertyMethod.
@Override
public PropertyMethod getPropertyMethod(Class<?> targetType, String propertyName) {
@SuppressWarnings("rawtypes") PropertyMethod method = _virtualPropertyMethods.get(Tuples.tuple((Class) targetType, propertyName));
if (method != null) {
return method;
}
SingleFieldMapping mapping = _schemaCache.getFieldMappingForCsvFieldName(targetType, propertyName);
if (mapping != null) {
propertyName = mapping.getObjFieldName();
}
return super.getPropertyMethod(targetType, propertyName);
}
use of org.onebusaway.collections.beans.PropertyMethod in project onebusaway-gtfs-modules by OneBusAway.
the class PropertyMethodResolverImplTest method testTripCalendarsVirtualMethod.
@Test
public void testTripCalendarsVirtualMethod() throws IllegalArgumentException, IllegalAccessException, InvocationTargetException {
Trip trip = new Trip();
trip.setId(new AgencyAndId("1", "t0"));
trip.setServiceId(new AgencyAndId("1", "sid0"));
_dao.saveEntity(trip);
ServiceCalendar calendar = new ServiceCalendar();
calendar.setServiceId(trip.getServiceId());
_dao.saveEntity(calendar);
PropertyMethod method = _resolver.getPropertyMethod(Trip.class, "calendar");
assertEquals(calendar, method.invoke(trip));
}
use of org.onebusaway.collections.beans.PropertyMethod in project onebusaway-gtfs-modules by OneBusAway.
the class PropertyMethodResolverImplTest method testAgencyRoutesVirtualMethod.
@Test
public void testAgencyRoutesVirtualMethod() throws IllegalArgumentException, IllegalAccessException, InvocationTargetException {
Agency agency = new Agency();
agency.setId("1");
Route route = new Route();
route.setId(new AgencyAndId("1", "r0"));
route.setAgency(agency);
_dao.saveEntity(route);
PropertyMethod method = _resolver.getPropertyMethod(Agency.class, "routes");
assertEquals(Arrays.asList(route), method.invoke(agency));
}
use of org.onebusaway.collections.beans.PropertyMethod in project onebusaway-gtfs-modules by OneBusAway.
the class PropertyMethodResolverImplTest method testTripStopTimesVirtualMethod.
@Test
public void testTripStopTimesVirtualMethod() throws IllegalArgumentException, IllegalAccessException, InvocationTargetException {
Trip trip = new Trip();
trip.setId(new AgencyAndId("1", "t0"));
_dao.saveEntity(trip);
StopTime stopTime = new StopTime();
stopTime.setTrip(trip);
stopTime.setStop(new Stop());
_dao.saveEntity(stopTime);
PropertyMethod method = _resolver.getPropertyMethod(Trip.class, "stop_times");
assertEquals(Arrays.asList(stopTime), method.invoke(trip));
}
use of org.onebusaway.collections.beans.PropertyMethod in project onebusaway-gtfs-modules by OneBusAway.
the class PropertyMethodResolverImplTest method testUseCsvFieldMappings.
@Test
public void testUseCsvFieldMappings() throws IllegalArgumentException, IllegalAccessException, InvocationTargetException {
DefaultEntitySchemaFactory factory = GtfsEntitySchemaFactory.createEntitySchemaFactory();
EntitySchema entitySchema = factory.getSchema(Route.class);
_schemaCache.addEntitySchema(entitySchema);
PropertyMethod method = _resolver.getPropertyMethod(Route.class, "route_id");
Route route = new Route();
AgencyAndId id = new AgencyAndId("1", "10");
route.setId(id);
assertSame(id, method.invoke(route));
}
Aggregations