Package org.onebusaway.transit_data_federation.services.service_alerts.ServiceAlerts

Examples of org.onebusaway.transit_data_federation.services.service_alerts.ServiceAlerts.ServiceAlert


  public void testGetServiceAlertsForStopId() {
    ServiceAlert.Builder builder = ServiceAlert.newBuilder();
    Affects.Builder affects = Affects.newBuilder();
    affects.setStopId(ServiceAlertLibrary.id("1", "10020"));
    builder.addAffects(affects);
    ServiceAlert serviceAlert = _service.createOrUpdateServiceAlert(builder,
        "1");

    List<ServiceAlert> alerts = _service.getServiceAlertsForStopId(
        System.currentTimeMillis(), new AgencyAndId("1", "10020"));
    assertEquals(1, alerts.size());
View Full Code Here


     */
    ServiceAlert.Builder builder2 = ServiceAlert.newBuilder();
    Affects.Builder affects2 = Affects.newBuilder();
    affects2.setTripId(ServiceAlertLibrary.id("1", "TripA"));
    builder2.addAffects(affects2);
    ServiceAlert serviceAlert2 = _service.createOrUpdateServiceAlert(builder2,
        "1");

    ServiceAlert.Builder builder3 = ServiceAlert.newBuilder();
    Affects.Builder affects3 = Affects.newBuilder();
    affects3.setRouteId(ServiceAlertLibrary.id("1", "RouteX"));
    builder3.addAffects(affects3);
    ServiceAlert serviceAlert3 = _service.createOrUpdateServiceAlert(builder3,
        "1");

    ServiceAlert.Builder builder4 = ServiceAlert.newBuilder();
    Affects.Builder affects4 = Affects.newBuilder();
    affects4.setRouteId(ServiceAlertLibrary.id("1", "RouteX"));
    affects4.setDirectionId("1");
    builder4.addAffects(affects4);
    ServiceAlert serviceAlert4 = _service.createOrUpdateServiceAlert(builder4,
        "1");

    /**
     * These alerts shouldn't match
     */
 
View Full Code Here

  @Test
  public void testRemoveServiceAlert() {

    ServiceAlert.Builder builder = ServiceAlert.newBuilder();
    ServiceAlert serviceAlert = _service.createOrUpdateServiceAlert(builder,
        "1");

    AgencyAndId id = ServiceAlertLibrary.agencyAndId(serviceAlert.getId());
    _service.removeServiceAlert(id);

    assertNull(_service.getServiceAlertForId(id));
  }
View Full Code Here

    ServiceAlert.Builder builder = ServiceAlert.newBuilder();
    Affects.Builder affects = Affects.newBuilder();
    affects.setAgencyId("2");
    builder.addAffects(affects);
    ServiceAlert serviceAlert1 = _service.createOrUpdateServiceAlert(builder,
        "1");

    builder = ServiceAlert.newBuilder(serviceAlert1);
    builder.clearAffects();
    affects = Affects.newBuilder();
    affects.setStopId(ServiceAlertLibrary.id("1", "10020"));
    builder.addAffects(affects);

    ServiceAlert serviceAlert2 = _service.createOrUpdateServiceAlert(builder,
        null);

    List<ServiceAlert> alerts = _service.getServiceAlertsForAgencyId(
        System.currentTimeMillis(), "2");
    assertEquals(0, alerts.size());
View Full Code Here

  @Override
  public ServiceAlertBean createServiceAlert(String agencyId,
      ServiceAlertBean situationBean) {
    ServiceAlert.Builder serviceAlertBuilder = getBeanAsServiceAlertBuilder(situationBean);
    ServiceAlert serviceAlert = _serviceAlertsService.createOrUpdateServiceAlert(
        serviceAlertBuilder, agencyId);
    return getServiceAlertAsBean(serviceAlert);
  }
View Full Code Here

    _serviceAlertsService.removeServiceAlert(situationId);
  }

  @Override
  public ServiceAlertBean getServiceAlertForId(AgencyAndId situationId) {
    ServiceAlert serviceAlert = _serviceAlertsService.getServiceAlertForId(situationId);
    if (serviceAlert == null)
      return null;
    return getServiceAlertAsBean(serviceAlert);
  }
View Full Code Here

    if (!builder.hasCreationTime())
      builder.setCreationTime(System.currentTimeMillis());
    builder.setModifiedTime(System.currentTimeMillis());

    ServiceAlert serviceAlert = builder.build();
    updateReferences(serviceAlert);
    saveServiceAlerts();
    return serviceAlert;
  }
View Full Code Here

  @Override
  public synchronized void removeServiceAlerts(List<AgencyAndId> serviceAlertIds) {

    for (AgencyAndId serviceAlertId : serviceAlertIds) {

      ServiceAlert existingServiceAlert = _serviceAlerts.remove(serviceAlertId);

      if (existingServiceAlert != null) {
        updateReferences(existingServiceAlert, null);
      }
    }
View Full Code Here

//    }
//  }
//
  private void updateReferences(ServiceAlert serviceAlert) {
    AgencyAndId id = ServiceAlertLibrary.agencyAndId(serviceAlert.getId());
    ServiceAlert existingServiceAlert = _serviceAlerts.put(id, serviceAlert);
    updateReferences(existingServiceAlert, serviceAlert);
  }
View Full Code Here

    if (serviceAlertIds == null || serviceAlertIds.isEmpty())
      return Collections.emptyList();
    List<ServiceAlert> serviceAlerts = new ArrayList<ServiceAlert>(
        serviceAlertIds.size());
    for (AgencyAndId serviceAlertId : serviceAlertIds) {
      ServiceAlert serviceAlert = _serviceAlerts.get(serviceAlertId);
      if (serviceAlert != null && filterByTime(serviceAlert, time))
        serviceAlerts.add(serviceAlert);
    }
    return serviceAlerts;
  }
View Full Code Here

TOP

Related Classes of org.onebusaway.transit_data_federation.services.service_alerts.ServiceAlerts.ServiceAlert

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.