Search in sources :

Example 11 with BeanFactoryV2

use of org.onebusaway.api.model.transit.BeanFactoryV2 in project onebusaway-application-modules by camsys.

the class BlockInstanceAction method show.

public DefaultHttpHeaders show() throws ServiceException {
    if (!isVersion(V2))
        return setUnknownVersionResponse();
    if (hasErrors())
        return setValidationErrorsResponse();
    BlockInstanceBean blockInstance = _service.getBlockInstance(_id, _serviceDate);
    if (blockInstance == null)
        return setResourceNotFoundResponse();
    BeanFactoryV2 factory = getBeanFactoryV2();
    BlockInstanceV2Bean bean = factory.getBlockInstance(blockInstance);
    EntryWithReferencesBean<BlockInstanceV2Bean> response = factory.entry(bean);
    return setOkResponse(response);
}
Also used : BlockInstanceV2Bean(org.onebusaway.api.model.transit.blocks.BlockInstanceV2Bean) BlockInstanceBean(org.onebusaway.transit_data.model.blocks.BlockInstanceBean) BeanFactoryV2(org.onebusaway.api.model.transit.BeanFactoryV2)

Example 12 with BeanFactoryV2

use of org.onebusaway.api.model.transit.BeanFactoryV2 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));
}
Also used : BundleMetadata(org.onebusaway.transit_data.model.config.BundleMetadata) BeanFactoryV2(org.onebusaway.api.model.transit.BeanFactoryV2)

Example 13 with BeanFactoryV2

use of org.onebusaway.api.model.transit.BeanFactoryV2 in project onebusaway-application-modules by camsys.

the class CurrentTimeAction method index.

public DefaultHttpHeaders index() {
    Date date = new Date();
    date.setTime(SystemTime.currentTimeMillis());
    String readableTime = DateLibrary.getTimeAsIso8601String(date);
    TimeBean bean = new TimeBean(date, readableTime);
    if (isVersion(V1)) {
        return setOkResponse(bean);
    } else if (isVersion(V2)) {
        BeanFactoryV2 factory = getBeanFactoryV2();
        EntryWithReferencesBean<TimeBean> response = factory.entry(bean);
        return setOkResponse(response);
    } else {
        return setUnknownVersionResponse();
    }
}
Also used : EntryWithReferencesBean(org.onebusaway.api.model.transit.EntryWithReferencesBean) TimeBean(org.onebusaway.api.model.TimeBean) Date(java.util.Date) BeanFactoryV2(org.onebusaway.api.model.transit.BeanFactoryV2)

Example 14 with BeanFactoryV2

use of org.onebusaway.api.model.transit.BeanFactoryV2 in project onebusaway-application-modules by camsys.

the class EstimateCurrentVehicleAction method index.

public DefaultHttpHeaders index() throws IOException, ServiceException {
    if (!isVersion(V2))
        return setUnknownVersionResponse();
    if (hasErrors())
        return setValidationErrorsResponse();
    fillInQuery();
    if (hasErrors())
        return setValidationErrorsResponse();
    BeanFactoryV2 factory = getBeanFactoryV2();
    ListBean<CurrentVehicleEstimateBean> estimates = _service.getCurrentVehicleEstimates(_query);
    return setOkResponse(factory.getCurrentVehicleEstimates(estimates));
}
Also used : CurrentVehicleEstimateBean(org.onebusaway.transit_data.model.realtime.CurrentVehicleEstimateBean) BeanFactoryV2(org.onebusaway.api.model.transit.BeanFactoryV2)

Example 15 with BeanFactoryV2

use of org.onebusaway.api.model.transit.BeanFactoryV2 in project onebusaway-application-modules by camsys.

the class RegisterAlarmForArrivalAndDepartureAtStopAction method show.

public DefaultHttpHeaders show() throws ServiceException {
    if (hasErrors())
        return setValidationErrorsResponse();
    if (_query.getTime() == 0)
        _query.setTime(SystemTime.currentTimeMillis());
    AlarmDetails details = _alarmService.alterAlarmQuery(_alarm, _data);
    String alarmId = _service.registerAlarmForArrivalAndDepartureAtStop(_query, _alarm);
    if (alarmId == null)
        return setResourceNotFoundResponse();
    if (details != null) {
        _alarmService.registerAlarm(alarmId, details);
    }
    if (isVersion(V2)) {
        RegisteredAlarmV2Bean bean = new RegisteredAlarmV2Bean();
        bean.setAlarmId(alarmId);
        BeanFactoryV2 factory = getBeanFactoryV2();
        return setOkResponse(factory.entry(bean));
    } else {
        return setUnknownVersionResponse();
    }
}
Also used : AlarmDetails(org.onebusaway.api.services.AlarmDetails) RegisteredAlarmV2Bean(org.onebusaway.api.model.transit.RegisteredAlarmV2Bean) BeanFactoryV2(org.onebusaway.api.model.transit.BeanFactoryV2)

Aggregations

BeanFactoryV2 (org.onebusaway.api.model.transit.BeanFactoryV2)24 OutOfServiceAreaServiceException (org.onebusaway.exceptions.OutOfServiceAreaServiceException)5 TripDetailsBean (org.onebusaway.transit_data.model.trips.TripDetailsBean)5 TripDetailsInclusionBean (org.onebusaway.transit_data.model.trips.TripDetailsInclusionBean)5 TripDetailsV2Bean (org.onebusaway.api.model.transit.TripDetailsV2Bean)2 VehicleStatusBean (org.onebusaway.transit_data.model.VehicleStatusBean)2 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 TimeBean (org.onebusaway.api.model.TimeBean)1 EntryWithReferencesBean (org.onebusaway.api.model.transit.EntryWithReferencesBean)1 RegisteredAlarmV2Bean (org.onebusaway.api.model.transit.RegisteredAlarmV2Bean)1 RouteV2Bean (org.onebusaway.api.model.transit.RouteV2Bean)1 TripV2Bean (org.onebusaway.api.model.transit.TripV2Bean)1 BlockInstanceV2Bean (org.onebusaway.api.model.transit.blocks.BlockInstanceV2Bean)1 BlockV2Bean (org.onebusaway.api.model.transit.blocks.BlockV2Bean)1 ArrivalAndDepartureBeanV1 (org.onebusaway.api.model.where.ArrivalAndDepartureBeanV1)1 StopWithArrivalsAndDeparturesBeanV1 (org.onebusaway.api.model.where.StopWithArrivalsAndDeparturesBeanV1)1 AlarmDetails (org.onebusaway.api.services.AlarmDetails)1 CoordinateBounds (org.onebusaway.geospatial.model.CoordinateBounds)1 EncodedPolylineBean (org.onebusaway.geospatial.model.EncodedPolylineBean)1