Search in sources :

Example 1 with BlockConfigurationBean

use of org.onebusaway.transit_data.model.blocks.BlockConfigurationBean in project onebusaway-application-modules by camsys.

the class BeanFactoryV2 method getBlock.

public BlockV2Bean getBlock(BlockBean block) {
    BlockV2Bean bean = new BlockV2Bean();
    bean.setId(block.getId());
    List<BlockConfigurationV2Bean> blockConfigs = new ArrayList<BlockConfigurationV2Bean>();
    for (BlockConfigurationBean blockConfig : block.getConfigurations()) blockConfigs.add(getBlockConfig(blockConfig));
    bean.setConfigurations(blockConfigs);
    return bean;
}
Also used : BlockV2Bean(org.onebusaway.api.model.transit.blocks.BlockV2Bean) ArrayList(java.util.ArrayList) BlockConfigurationBean(org.onebusaway.transit_data.model.blocks.BlockConfigurationBean) BlockConfigurationV2Bean(org.onebusaway.api.model.transit.blocks.BlockConfigurationV2Bean)

Example 2 with BlockConfigurationBean

use of org.onebusaway.transit_data.model.blocks.BlockConfigurationBean in project onebusaway-application-modules by camsys.

the class BlockAction method execute.

@Override
@Actions({ @Action(value = "/where/block"), @Action(value = "/where/iphone/block") })
public String execute() throws ServiceException {
    if (_id == null)
        return INPUT;
    _blockInstance = _service.getBlockInstance(_id, _serviceDate.getTime());
    if (_blockInstance == null)
        return ERROR;
    BlockConfigurationBean blockConfig = _blockInstance.getBlockConfiguration();
    _timeZone = TimeZone.getTimeZone(blockConfig.getTimeZone());
    return SUCCESS;
}
Also used : BlockConfigurationBean(org.onebusaway.transit_data.model.blocks.BlockConfigurationBean) Actions(org.apache.struts2.convention.annotation.Actions)

Example 3 with BlockConfigurationBean

use of org.onebusaway.transit_data.model.blocks.BlockConfigurationBean in project onebusaway-application-modules by camsys.

the class BlockBeanServiceImpl method getBlockForId.

@Cacheable
public BlockBean getBlockForId(AgencyAndId blockId) {
    BlockEntry blockEntry = _graph.getBlockEntryForId(blockId);
    if (blockEntry == null)
        return null;
    BlockBean bean = new BlockBean();
    bean.setId(AgencyAndIdLibrary.convertToString(blockEntry.getId()));
    List<BlockConfigurationBean> configBeans = new ArrayList<BlockConfigurationBean>();
    for (BlockConfigurationEntry blockConfiguration : blockEntry.getConfigurations()) {
        BlockConfigurationBean configBean = getBlockConfigurationAsBean(blockConfiguration);
        configBeans.add(configBean);
    }
    bean.setConfigurations(configBeans);
    return bean;
}
Also used : BlockEntry(org.onebusaway.transit_data_federation.services.transit_graph.BlockEntry) BlockBean(org.onebusaway.transit_data.model.blocks.BlockBean) ArrayList(java.util.ArrayList) BlockConfigurationBean(org.onebusaway.transit_data.model.blocks.BlockConfigurationBean) BlockConfigurationEntry(org.onebusaway.transit_data_federation.services.transit_graph.BlockConfigurationEntry) Cacheable(org.onebusaway.container.cache.Cacheable)

Example 4 with BlockConfigurationBean

use of org.onebusaway.transit_data.model.blocks.BlockConfigurationBean in project onebusaway-application-modules by camsys.

the class BlockBeanServiceImpl method getBlockConfigurationAsBean.

private BlockConfigurationBean getBlockConfigurationAsBean(BlockConfigurationEntry blockConfiguration) {
    BlockConfigurationBean bean = new BlockConfigurationBean();
    ServiceIdActivation serviceIds = blockConfiguration.getServiceIds();
    AgencyAndId blockId = blockConfiguration.getBlock().getId();
    bean.setBlockId(AgencyAndIdLibrary.convertToString(blockId));
    List<String> activeServiceIds = new ArrayList<String>();
    for (LocalizedServiceId lsid : serviceIds.getActiveServiceIds()) activeServiceIds.add(AgencyAndIdLibrary.convertToString(lsid.getId()));
    bean.setActiveServiceIds(activeServiceIds);
    List<String> inactiveServiceIds = new ArrayList<String>();
    for (LocalizedServiceId lsid : serviceIds.getInactiveServiceIds()) inactiveServiceIds.add(AgencyAndIdLibrary.convertToString(lsid.getId()));
    bean.setInactiveServiceIds(inactiveServiceIds);
    List<BlockTripBean> tripBeans = new ArrayList<BlockTripBean>();
    for (BlockTripEntry blockTrip : blockConfiguration.getTrips()) tripBeans.add(getBlockTripAsBean(blockTrip));
    bean.setTrips(tripBeans);
    TimeZone tz = _agencyService.getTimeZoneForAgencyId(blockId.getAgencyId());
    bean.setTimeZone(tz.getID());
    return bean;
}
Also used : BlockTripBean(org.onebusaway.transit_data.model.blocks.BlockTripBean) TimeZone(java.util.TimeZone) AgencyAndId(org.onebusaway.gtfs.model.AgencyAndId) LocalizedServiceId(org.onebusaway.gtfs.model.calendar.LocalizedServiceId) BlockTripEntry(org.onebusaway.transit_data_federation.services.transit_graph.BlockTripEntry) ArrayList(java.util.ArrayList) ServiceIdActivation(org.onebusaway.transit_data_federation.services.transit_graph.ServiceIdActivation) BlockConfigurationBean(org.onebusaway.transit_data.model.blocks.BlockConfigurationBean)

Example 5 with BlockConfigurationBean

use of org.onebusaway.transit_data.model.blocks.BlockConfigurationBean in project onebusaway-application-modules by camsys.

the class BlockBeanServiceImpl method getBlockInstanceAsBean.

/**
 **
 * Private Methods
 ***
 */
private BlockInstanceBean getBlockInstanceAsBean(BlockInstance blockInstance) {
    BlockInstanceBean bean = new BlockInstanceBean();
    BlockConfigurationBean blockConfig = getBlockConfigurationAsBean(blockInstance.getBlock());
    bean.setBlockId(blockConfig.getBlockId());
    bean.setBlockConfiguration(blockConfig);
    long serviceDate = blockInstance.getServiceDate();
    bean.setServiceDate(serviceDate);
    return bean;
}
Also used : BlockInstanceBean(org.onebusaway.transit_data.model.blocks.BlockInstanceBean) BlockConfigurationBean(org.onebusaway.transit_data.model.blocks.BlockConfigurationBean)

Aggregations

BlockConfigurationBean (org.onebusaway.transit_data.model.blocks.BlockConfigurationBean)5 ArrayList (java.util.ArrayList)3 TimeZone (java.util.TimeZone)1 Actions (org.apache.struts2.convention.annotation.Actions)1 BlockConfigurationV2Bean (org.onebusaway.api.model.transit.blocks.BlockConfigurationV2Bean)1 BlockV2Bean (org.onebusaway.api.model.transit.blocks.BlockV2Bean)1 Cacheable (org.onebusaway.container.cache.Cacheable)1 AgencyAndId (org.onebusaway.gtfs.model.AgencyAndId)1 LocalizedServiceId (org.onebusaway.gtfs.model.calendar.LocalizedServiceId)1 BlockBean (org.onebusaway.transit_data.model.blocks.BlockBean)1 BlockInstanceBean (org.onebusaway.transit_data.model.blocks.BlockInstanceBean)1 BlockTripBean (org.onebusaway.transit_data.model.blocks.BlockTripBean)1 BlockConfigurationEntry (org.onebusaway.transit_data_federation.services.transit_graph.BlockConfigurationEntry)1 BlockEntry (org.onebusaway.transit_data_federation.services.transit_graph.BlockEntry)1 BlockTripEntry (org.onebusaway.transit_data_federation.services.transit_graph.BlockTripEntry)1 ServiceIdActivation (org.onebusaway.transit_data_federation.services.transit_graph.ServiceIdActivation)1