Search in sources :

Example 6 with TransformSpecificationMissingArgumentException

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

the class TransformFactory method handleAddOperation.

/****
   * Private Method
   ****/
private void handleAddOperation(String line, JSONObject json) throws JSONException, TransformSpecificationException {
    if (!json.has(ARG_OBJ)) {
        throw new TransformSpecificationMissingArgumentException(line, ARG_OBJ);
    }
    JSONObject objectSpec = json.getJSONObject(ARG_OBJ);
    Class<?> entityType = getEntityClassFromJsonSpec(line, objectSpec);
    if (entityType == null) {
        throw new TransformSpecificationMissingArgumentException(line, new String[] { ARG_CLASS, ARG_FILE }, ARG_OBJ);
    }
    Map<String, ValueSetter> propertyUpdates = getPropertyValueSettersFromJsonObject(entityType, objectSpec, _excludeForObjectSpec);
    EntitySourceImpl source = new EntitySourceImpl(entityType, propertyUpdates);
    AddEntitiesTransformStrategy strategy = getStrategy(AddEntitiesTransformStrategy.class);
    strategy.addEntityFactory(source);
}
Also used : JSONObject(org.json.JSONObject) TransformSpecificationMissingArgumentException(org.onebusaway.gtfs_transformer.TransformSpecificationMissingArgumentException) DeferredValueSetter(org.onebusaway.gtfs_transformer.deferred.DeferredValueSetter) ValueSetter(org.onebusaway.gtfs_transformer.deferred.ValueSetter) PropertyPathExpressionValueSetter(org.onebusaway.gtfs_transformer.deferred.PropertyPathExpressionValueSetter) ReplaceValueSetter(org.onebusaway.gtfs_transformer.deferred.ReplaceValueSetter)

Aggregations

TransformSpecificationMissingArgumentException (org.onebusaway.gtfs_transformer.TransformSpecificationMissingArgumentException)6 JSONObject (org.json.JSONObject)5 TransformSpecificationException (org.onebusaway.gtfs_transformer.TransformSpecificationException)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 JSONException (org.json.JSONException)2 MissingRequiredFieldException (org.onebusaway.csv_entities.exceptions.MissingRequiredFieldException)2 TypedEntityMatch (org.onebusaway.gtfs_transformer.match.TypedEntityMatch)2 IOException (java.io.IOException)1 Map (java.util.Map)1 Matcher (java.util.regex.Matcher)1 JSONArray (org.json.JSONArray)1 PropertyPathCollectionExpression (org.onebusaway.collections.beans.PropertyPathCollectionExpression)1 PropertyPathExpression (org.onebusaway.collections.beans.PropertyPathExpression)1 CsvEntityContext (org.onebusaway.csv_entities.CsvEntityContext)1 CsvEntityContextImpl (org.onebusaway.csv_entities.CsvEntityContextImpl)1 BeanWrapper (org.onebusaway.csv_entities.schema.BeanWrapper)1 EntitySchema (org.onebusaway.csv_entities.schema.EntitySchema)1 EntitySchemaFactory (org.onebusaway.csv_entities.schema.EntitySchemaFactory)1 FieldMapping (org.onebusaway.csv_entities.schema.FieldMapping)1