use of org.onebusaway.admin.model.BundleBuildResponse in project onebusaway-application-modules by camsys.
the class BundleBuildingServiceImplTest method testBuildStif.
private void testBuildStif() {
_service.setAuxConfig("false");
String bundleDir = "test";
String tmpDir = new NYCFileUtils().createTmpDirectory();
BundleBuildRequest request = new BundleBuildRequest();
request.setBundleDirectory(bundleDir);
request.setBundleName("testname");
request.setTmpDirectory(tmpDir);
request.setBundleStartDate("2012-04-08");
request.setBundleEndDate("2012-07-07");
request.setBundleComment("Test");
assertNotNull(request.getTmpDirectory());
assertNotNull(request.getBundleDirectory());
BundleBuildResponse response = new BundleBuildResponse("" + System.currentTimeMillis());
assertEquals(0, response.getStatusList().size());
// step 1
_service.download(request, response);
assertNotNull(response.getGtfsList());
assertEquals(1, response.getGtfsList().size());
assertNotNull(response.getAuxZipList());
assertEquals(1, response.getAuxZipList().size());
assertNotNull(response.getStatusList());
assertTrue(response.getStatusList().size() > 0);
assertNotNull(response.getConfigList());
assertEquals(0, response.getConfigList().size());
// step 2
_service.prepare(request, response);
assertFalse(response.isComplete());
// step 3
int rc = _service.build(request, response);
if (response.getException() != null) {
_log.error("Failed with exception=" + response.getException(), response.getException());
}
assertNull(response.getException());
assertFalse(response.isComplete());
assertEquals(0, rc);
// step 4
// OBANYC-1451 -- fails on OSX TODO
// _service.assemble(request, response);
// step 5
_service.upload(request, response);
// set by BundleRequestService
assertFalse(response.isComplete());
}
use of org.onebusaway.admin.model.BundleBuildResponse in project onebusaway-application-modules by camsys.
the class BundleRequestServiceImplTest method testBuild.
@Test
public void testBuild() throws Exception {
BundleBuildRequest req = new BundleBuildRequest();
String key = "2012Jan";
// String key = "m34"; // use for faster testing
req.setBundleDirectory(key);
req.setBundleName("test_0");
req.setTmpDirectory(new NYCFileUtils().createTmpDirectory());
req.setBundleStartDate("2012-04-08");
req.setBundleEndDate("2012-07-07");
req.setBundleComment("Test Bundle");
_log.debug("calling build for dir=" + req.getBundleDirectory() + " name=" + req.getBundleName());
BundleBuildResponse res = service.build(req);
assertFalse(res.isComplete());
int count = 0;
while (count < 300 && !res.isComplete() && res.getException() == null) {
// _log.info("sleeping[" + count + "]...");
Thread.sleep(10 * 1000);
count++;
// NOTE: this is optional to demonstrate retrieval service
_log.info("calling lookup(local) for id=" + res.getId());
res = service.lookupBuildRequest(res.getId());
assertNotNull(res);
}
if (res.getException() != null) {
_log.error("Failed with exception=" + res.getException());
}
assertNull(res.getException());
assertTrue(res.isComplete());
assertNotNull(res.getGtfsList());
assertEquals(2, res.getGtfsList().size());
}
use of org.onebusaway.admin.model.BundleBuildResponse in project onebusaway-application-modules by camsys.
the class BundleBuildResponseDaoImpl method getBundleBuildResponseForId.
@Override
public BundleBuildResponse getBundleBuildResponseForId(String id) {
Session session = _template.getSessionFactory().getCurrentSession();
Transaction tx = session.beginTransaction();
List<BundleBuildResponse> responses = _template.findByNamedParam("from BundleBuildResponse where id=:id", "id", id);
BundleBuildResponse bbr = responses.get(0);
tx.commit();
return bbr;
}
use of org.onebusaway.admin.model.BundleBuildResponse in project onebusaway-application-modules by camsys.
the class BundleRequestServiceImpl method buildBundleResultURL.
@Override
public BundleBuildResponse buildBundleResultURL(String id) {
BundleBuildResponse bundleResponse = this.lookupBuildRequest(id);
bundleResponse.setBundleResultLink(getResultLink(bundleResponse.getBundleBuildName(), bundleResponse.getId(), bundleResponse.getBundleStartDate(), bundleResponse.getBundleEndDate()));
return bundleResponse;
}
use of org.onebusaway.admin.model.BundleBuildResponse in project onebusaway-application-modules by camsys.
the class GtfsArchiveTask method createMetaData.
private Integer createMetaData(Session session, BundleRequestResponse requestResponse) {
GtfsBundleInfo info = new GtfsBundleInfo();
BundleBuildRequest request = requestResponse.getRequest();
BundleBuildResponse response = requestResponse.getResponse();
info.setBundleId(response.getBundleId());
info.setName(request.getBundleName());
info.setDirectory(request.getBundleDirectory());
info.setStartDate(request.getBundleStartDate().toDate());
info.setEndDate(request.getBundleEndDate().toDate());
info.setTimestamp(new Date());
return (Integer) session.save(info);
}
Aggregations