use of org.onebusaway.gtfs_transformer.deferred.ValueSetter in project onebusaway-gtfs-modules by OneBusAway.
the class SimpleModificationStrategy method run.
@Override
public void run(TransformContext context, GtfsMutableRelationalDao dao, Object entity) {
BeanWrapper wrapper = BeanWrapperFactory.wrap(entity);
for (Map.Entry<String, ValueSetter> entry : _propertyUpdates.entrySet()) {
String propertyName = entry.getKey();
ValueSetter setter = entry.getValue();
setter.setValue(wrapper, propertyName);
}
}
use of org.onebusaway.gtfs_transformer.deferred.ValueSetter 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);
}
use of org.onebusaway.gtfs_transformer.deferred.ValueSetter in project onebusaway-gtfs-modules by OneBusAway.
the class TransformFactory method getPropertyValueSettersFromJsonObject.
private Map<String, ValueSetter> getPropertyValueSettersFromJsonObject(Class<?> entityType, JSONObject obj, Set<String> propertiesToExclude) throws JSONException {
Map<String, Object> map = getPropertyValuesFromJsonObject(obj, propertiesToExclude);
Map<String, ValueSetter> setters = new HashMap<String, ValueSetter>();
for (Map.Entry<String, Object> entry : map.entrySet()) {
String propertyName = entry.getKey();
SingleFieldMapping mapping = _schemaCache.getFieldMappingForCsvFieldName(entityType, propertyName);
if (mapping != null) {
propertyName = mapping.getObjFieldName();
}
ValueSetter setter = createSetterForValue(entry.getValue());
setters.put(propertyName, setter);
}
return setters;
}
Aggregations