use of org.onebusaway.transit_data.model.config.BundleMetadata in project onebusaway-application-modules by camsys.
the class BundleConfigDao method setup.
@PostConstruct
@Refreshable(dependsOn = RefreshableResources.TRANSIT_GRAPH)
public void setup() throws IOException, ClassNotFoundException {
_meta = null;
File path = _bundle.getBundleMetadataPath();
_log.info("looking for metadata file " + path);
if (path.exists()) {
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);
BundleMetadata meta = null;
try {
meta = mapper.readValue(path, BundleMetadata.class);
} catch (Exception any) {
_log.error("reading metadata failed:", any);
}
if (meta != null) {
_meta = meta;
}
} else {
_log.error(" did not find metadata file " + path);
}
}
use of org.onebusaway.transit_data.model.config.BundleMetadata in project onebusaway-application-modules by camsys.
the class ConfigAction method index.
public DefaultHttpHeaders index() throws IOException, ServiceException {
if (hasErrors())
return setValidationErrorsResponse();
BundleMetadata meta = _service.getBundleMetadata();
BeanFactoryV2 factory = getBeanFactoryV2();
return setOkResponse(factory.getResponse(meta));
}
use of org.onebusaway.transit_data.model.config.BundleMetadata in project onebusaway-application-modules by camsys.
the class LocalBundleStoreImpl method createBundleItem.
private BundleItem createBundleItem(File calendarServiceObjectFile, File metadataFile, String filename) throws Exception {
// get data to fill in the BundleItem for this bundle.
ServiceDate minServiceDate = null;
ServiceDate maxServiceDate = null;
try {
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);
BundleMetadata meta = null;
meta = mapper.readValue(metadataFile, BundleMetadata.class);
// Convert metadata String Dates to Date Objects
Date fromDate = new Date(Long.parseLong(meta.getServiceDateFrom()));
Date toDate = new Date(Long.parseLong(meta.getServiceDateTo()));
// Convert Date Objects to ServiceDate Objects
minServiceDate = new ServiceDate(fromDate);
maxServiceDate = new ServiceDate(toDate);
} catch (Exception e) {
_log.error(e.getMessage());
_log.error("Deserialization of metadata.json in local bundle " + filename + "; skipping.");
throw new Exception(e);
}
_log.info("Found local bundle " + filename + " with service range " + minServiceDate + " => " + maxServiceDate);
BundleItem bundleItem = new BundleItem();
bundleItem.setId(filename);
bundleItem.setName(filename);
bundleItem.setServiceDateFrom(minServiceDate);
bundleItem.setServiceDateTo(maxServiceDate);
DateTime lastModified = new DateTime(calendarServiceObjectFile.lastModified());
bundleItem.setCreated(lastModified);
bundleItem.setUpdated(lastModified);
return bundleItem;
}
Aggregations