Search in sources :

Example 1 with TrimTripTransformStrategy

use of org.onebusaway.gtfs_transformer.updates.TrimTripTransformStrategy in project onebusaway-gtfs-modules by OneBusAway.

the class TransformFactory method handleTrimOperation.

private void handleTrimOperation(String line, JSONObject json) throws JSONException, TransformSpecificationException {
    TypedEntityMatch match = getMatch(line, json);
    if (match.getType() != Trip.class) {
        throw new TransformSpecificationException("the trim_trip op only supports matching against trips", line);
    }
    TrimTripTransformStrategy strategy = getStrategy(TrimTripTransformStrategy.class);
    TrimOperation operation = new TrimTripTransformStrategy.TrimOperation();
    operation.setMatch(match);
    if (json.has("to_stop_id")) {
        operation.setToStopId(json.getString("to_stop_id"));
    }
    if (json.has("from_stop_id")) {
        operation.setFromStopId(json.getString("from_stop_id"));
    }
    if (operation.getToStopId() == null && operation.getFromStopId() == null) {
        throw new TransformSpecificationMissingArgumentException(line, new String[] { "to_stop_id", "from_stop_id" });
    }
    strategy.addOperation(operation);
}
Also used : TypedEntityMatch(org.onebusaway.gtfs_transformer.match.TypedEntityMatch) TrimTripTransformStrategy(org.onebusaway.gtfs_transformer.updates.TrimTripTransformStrategy) TransformSpecificationMissingArgumentException(org.onebusaway.gtfs_transformer.TransformSpecificationMissingArgumentException) TrimOperation(org.onebusaway.gtfs_transformer.updates.TrimTripTransformStrategy.TrimOperation) TransformSpecificationException(org.onebusaway.gtfs_transformer.TransformSpecificationException)

Aggregations

TransformSpecificationException (org.onebusaway.gtfs_transformer.TransformSpecificationException)1 TransformSpecificationMissingArgumentException (org.onebusaway.gtfs_transformer.TransformSpecificationMissingArgumentException)1 TypedEntityMatch (org.onebusaway.gtfs_transformer.match.TypedEntityMatch)1 TrimTripTransformStrategy (org.onebusaway.gtfs_transformer.updates.TrimTripTransformStrategy)1 TrimOperation (org.onebusaway.gtfs_transformer.updates.TrimTripTransformStrategy.TrimOperation)1