use of org.onebusaway.gtfs_transformer.services.GtfsTransformStrategy in project onebusaway-gtfs-modules by OneBusAway.
the class TransformFactoryTest method testFileMatch.
@Test
public void testFileMatch() throws IOException, TransformSpecificationException {
_factory.addModificationsFromString("{'op':'remove', 'match':{'file':'routes.txt', 'shortName':'10'}}");
GtfsTransformStrategy transform = _transformer.getLastTransform();
assertEquals(EntitiesTransformStrategy.class, transform.getClass());
EntitiesTransformStrategy strategy = (EntitiesTransformStrategy) transform;
List<MatchAndTransform> transforms = strategy.getModifications();
assertEquals(1, transforms.size());
}
use of org.onebusaway.gtfs_transformer.services.GtfsTransformStrategy in project onebusaway-gtfs-modules by OneBusAway.
the class TransformFactory method handleTransformOperation.
private void handleTransformOperation(String line, JSONObject json, Object factoryObj) throws JSONException, TransformSpecificationException {
setObjectPropertiesFromJsonUsingCsvFields(factoryObj, json, line);
boolean added = false;
if (factoryObj instanceof GtfsTransformStrategy) {
_transformer.addTransform((GtfsTransformStrategy) factoryObj);
added = true;
}
if (factoryObj instanceof GtfsEntityTransformStrategy) {
_transformer.addEntityTransform((GtfsEntityTransformStrategy) factoryObj);
added = true;
}
if (factoryObj instanceof GtfsTransformStrategyFactory) {
GtfsTransformStrategyFactory factory = (GtfsTransformStrategyFactory) factoryObj;
factory.createTransforms(_transformer);
added = true;
}
if (!added) {
throw new TransformSpecificationException("factory object is not an instance of GtfsTransformStrategy, GtfsEntityTransformStrategy, or GtfsTransformStrategyFactory: " + factoryObj.getClass().getName(), line);
}
}
use of org.onebusaway.gtfs_transformer.services.GtfsTransformStrategy in project onebusaway-gtfs-modules by OneBusAway.
the class TransformFactory method getStrategy.
@SuppressWarnings("unchecked")
private <T extends GtfsTransformStrategy> T getStrategy(Class<T> transformerType) {
GtfsTransformStrategy lastTransform = _transformer.getLastTransform();
if (lastTransform != null && transformerType.isAssignableFrom(lastTransform.getClass()))
return (T) lastTransform;
T strategy = (T) instantiate(transformerType);
_transformer.addTransform(strategy);
return strategy;
}
Aggregations