Search in sources :

Example 6 with BundleBuildResponse

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());
}
Also used : BundleBuildRequest(org.onebusaway.admin.model.BundleBuildRequest) NYCFileUtils(org.onebusaway.admin.util.NYCFileUtils) BundleBuildResponse(org.onebusaway.admin.model.BundleBuildResponse)

Example 7 with BundleBuildResponse

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());
}
Also used : BundleBuildRequest(org.onebusaway.admin.model.BundleBuildRequest) NYCFileUtils(org.onebusaway.admin.util.NYCFileUtils) BundleBuildResponse(org.onebusaway.admin.model.BundleBuildResponse) Test(org.junit.Test)

Example 8 with BundleBuildResponse

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;
}
Also used : Transaction(org.hibernate.Transaction) BundleBuildResponse(org.onebusaway.admin.model.BundleBuildResponse) Session(org.hibernate.Session)

Example 9 with BundleBuildResponse

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;
}
Also used : BundleBuildResponse(org.onebusaway.admin.model.BundleBuildResponse)

Example 10 with BundleBuildResponse

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);
}
Also used : BundleBuildRequest(org.onebusaway.admin.model.BundleBuildRequest) GtfsBundleInfo(org.onebusaway.admin.service.bundle.task.model.GtfsBundleInfo) BundleBuildResponse(org.onebusaway.admin.model.BundleBuildResponse) Date(java.util.Date)

Aggregations

BundleBuildResponse (org.onebusaway.admin.model.BundleBuildResponse)13 BundleBuildRequest (org.onebusaway.admin.model.BundleBuildRequest)6 Path (javax.ws.rs.Path)5 Produces (javax.ws.rs.Produces)5 Response (javax.ws.rs.core.Response)5 NYCFileUtils (org.onebusaway.admin.util.NYCFileUtils)4 IOException (java.io.IOException)3 StringWriter (java.io.StringWriter)3 GET (javax.ws.rs.GET)3 JsonGenerationException (org.codehaus.jackson.JsonGenerationException)3 JsonGenerator (org.codehaus.jackson.JsonGenerator)3 JsonMappingException (org.codehaus.jackson.map.JsonMappingException)3 MappingJsonFactory (org.codehaus.jackson.map.MappingJsonFactory)3 DateValidationException (org.onebusaway.admin.service.exceptions.DateValidationException)3 POST (javax.ws.rs.POST)2 InputStream (java.io.InputStream)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 Map (java.util.Map)1 Session (org.hibernate.Session)1