Search in sources :

Example 1 with GtfsBundleInfo

use of org.onebusaway.admin.service.bundle.task.model.GtfsBundleInfo in project onebusaway-application-modules by camsys.

the class GtfsArchiveDaoImpl method getBuildNamesForDataset.

/**
 * Accesses the database to get the list of build names for the
 * specified dataset..
 *
 * @return    a SortedSet of the dataset names.
 */
@Override
public SortedSet<String> getBuildNamesForDataset(String dataset) {
    SortedSet<String> buildNames = new TreeSet<>();
    Session session = _template.getSessionFactory().getCurrentSession();
    Transaction tx = session.beginTransaction();
    List<GtfsBundleInfo> archivedBundles = session.createCriteria(GtfsBundleInfo.class).list();
    tx.commit();
    for (GtfsBundleInfo archivedBundle : archivedBundles) {
        if (archivedBundle.getDirectory().equals(dataset)) {
            buildNames.add(archivedBundle.getName());
        }
    }
    return buildNames;
}
Also used : GtfsBundleInfo(org.onebusaway.admin.service.bundle.task.model.GtfsBundleInfo) Transaction(org.hibernate.Transaction) TreeSet(java.util.TreeSet) Session(org.hibernate.classic.Session)

Example 2 with GtfsBundleInfo

use of org.onebusaway.admin.service.bundle.task.model.GtfsBundleInfo in project onebusaway-application-modules by camsys.

the class GtfsArchiveServiceImpl method getBundleStartDate.

@Override
public Date getBundleStartDate(int buildId) {
    GtfsBundleInfo bundleInfo = _gtfsArchiveDao.getBundleInfoForId(buildId);
    Date startDate = bundleInfo == null ? null : bundleInfo.getStartDate();
    return startDate;
}
Also used : GtfsBundleInfo(org.onebusaway.admin.service.bundle.task.model.GtfsBundleInfo) Date(java.util.Date)

Example 3 with GtfsBundleInfo

use of org.onebusaway.admin.service.bundle.task.model.GtfsBundleInfo in project onebusaway-application-modules by camsys.

the class GtfsArchiveDaoImpl method getBundleInfoForId.

@Override
public GtfsBundleInfo getBundleInfoForId(int buildId) {
    Session session = _template.getSessionFactory().getCurrentSession();
    Transaction tx = session.beginTransaction();
    List<GtfsBundleInfo> responses = _template.findByNamedParam("from GtfsBundleInfo where gid=:id", "id", buildId);
    tx.commit();
    GtfsBundleInfo bundleInfo = responses.get(0);
    return bundleInfo;
}
Also used : GtfsBundleInfo(org.onebusaway.admin.service.bundle.task.model.GtfsBundleInfo) Transaction(org.hibernate.Transaction) Session(org.hibernate.classic.Session)

Example 4 with GtfsBundleInfo

use of org.onebusaway.admin.service.bundle.task.model.GtfsBundleInfo in project onebusaway-application-modules by camsys.

the class GtfsArchiveDaoImpl method getAllDatasets.

/**
 * Accesses the database to get the names of all the archived datasets.
 *
 * @return    a SortedSet of the dataset names.
 */
@Override
public SortedSet<String> getAllDatasets() {
    SortedSet<String> datasets = new TreeSet<>();
    Session session = _template.getSessionFactory().getCurrentSession();
    Transaction tx = session.beginTransaction();
    List<GtfsBundleInfo> archivedBundles = session.createCriteria(GtfsBundleInfo.class).list();
    tx.commit();
    for (GtfsBundleInfo archivedBundle : archivedBundles) {
        datasets.add(archivedBundle.getDirectory());
    }
    return datasets;
}
Also used : GtfsBundleInfo(org.onebusaway.admin.service.bundle.task.model.GtfsBundleInfo) Transaction(org.hibernate.Transaction) TreeSet(java.util.TreeSet) Session(org.hibernate.classic.Session)

Example 5 with GtfsBundleInfo

use of org.onebusaway.admin.service.bundle.task.model.GtfsBundleInfo in project onebusaway-application-modules by camsys.

the class GtfsArchiveDaoImpl method getBuildNameMapForDataset.

@Override
public SortedMap<String, String> getBuildNameMapForDataset(String dataset) {
    SortedMap<String, String> buildNameMap = new TreeMap<>();
    Session session = _template.getSessionFactory().getCurrentSession();
    Transaction tx = session.beginTransaction();
    List<GtfsBundleInfo> archivedBundles = session.createCriteria(GtfsBundleInfo.class).list();
    tx.commit();
    for (GtfsBundleInfo archivedBundle : archivedBundles) {
        if (archivedBundle.getDirectory().equals(dataset)) {
            buildNameMap.put(archivedBundle.getName(), "" + archivedBundle.getId());
        }
    }
    return buildNameMap;
}
Also used : GtfsBundleInfo(org.onebusaway.admin.service.bundle.task.model.GtfsBundleInfo) Transaction(org.hibernate.Transaction) TreeMap(java.util.TreeMap) Session(org.hibernate.classic.Session)

Aggregations

GtfsBundleInfo (org.onebusaway.admin.service.bundle.task.model.GtfsBundleInfo)6 Transaction (org.hibernate.Transaction)4 Session (org.hibernate.classic.Session)4 Date (java.util.Date)2 TreeSet (java.util.TreeSet)2 TreeMap (java.util.TreeMap)1 BundleBuildRequest (org.onebusaway.admin.model.BundleBuildRequest)1 BundleBuildResponse (org.onebusaway.admin.model.BundleBuildResponse)1