Search in sources :

Example 1 with Actions

use of org.apache.struts2.convention.annotation.Actions in project uavstack by uavorg.

the class TestStruts2ActionAnno method anno1.

@Actions({ @Action("aa"), @Action("bb") })
@Action("anno1")
public void anno1() throws IOException {
    ServletActionContext.getResponse().setContentType("text/html;charset=utf-8");
    PrintWriter out = ServletActionContext.getResponse().getWriter();
    try {
        out.print("TestStruts2ActionAnno anno1()");
        out.flush();
        out.close();
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}
Also used : IOException(java.io.IOException) PrintWriter(java.io.PrintWriter) Action(org.apache.struts2.convention.annotation.Action) Actions(org.apache.struts2.convention.annotation.Actions)

Example 2 with Actions

use of org.apache.struts2.convention.annotation.Actions in project onebusaway-application-modules by camsys.

the class RoutesAction method execute.

@Override
@Actions({ @Action(value = "/where/iphone/routes") })
public String execute() throws ServiceException {
    if (_query == null || _query.length() == 0)
        return INPUT;
    CoordinateBounds bounds = getServiceArea();
    if (bounds == null) {
        pushNextAction("routes", "query", _query);
        return "query-default-search-location";
    }
    SearchQueryBean query = new SearchQueryBean();
    query.setBounds(bounds);
    query.setMaxCount(5);
    query.setQuery(_query);
    query.setType(EQueryType.BOUNDS_OR_CLOSEST);
    RoutesBean routesResult = _transitDataService.getRoutes(query);
    _routes = routesResult.getRoutes();
    if (_routes.size() == 0) {
        return "noRoutesFound";
    } else if (_routes.size() > 1) {
        return "multipleRoutesFound";
    } else {
        _route = _routes.get(0);
        return "singleRouteFound";
    }
}
Also used : SearchQueryBean(org.onebusaway.transit_data.model.SearchQueryBean) RoutesBean(org.onebusaway.transit_data.model.RoutesBean) CoordinateBounds(org.onebusaway.geospatial.model.CoordinateBounds) Actions(org.apache.struts2.convention.annotation.Actions)

Example 3 with Actions

use of org.apache.struts2.convention.annotation.Actions in project onebusaway-application-modules by camsys.

the class ScheduleAction method execute.

@Override
@Actions({ @Action(value = "/where/schedule") })
public String execute() throws Exception {
    if (_date == null)
        _date = new Date();
    if (_id == null)
        return INPUT;
    _result = _service.getScheduleForStop(_id, _date);
    if (_result == null)
        throw new NoSuchStopServiceException(_id);
    StopCalendarDaysBean days = _result.getCalendarDays();
    String tzName = days.getTimeZone();
    _timeZone = TimeZone.getTimeZone(tzName);
    if (_timeZone == null)
        _timeZone = TimeZone.getDefault();
    filterResults();
    return SUCCESS;
}
Also used : StopCalendarDaysBean(org.onebusaway.transit_data.model.StopCalendarDaysBean) NoSuchStopServiceException(org.onebusaway.exceptions.NoSuchStopServiceException) Date(java.util.Date) Actions(org.apache.struts2.convention.annotation.Actions)

Example 4 with Actions

use of org.apache.struts2.convention.annotation.Actions in project onebusaway-application-modules by camsys.

the class StopsAction method execute.

@Override
@Actions({ @Action(value = "/where/iphone/stops") })
public String execute() throws ServiceException {
    CoordinateBounds bounds = getServiceArea();
    if (bounds == null) {
        pushNextAction("stops", "code", _code);
        return "query-default-search-location";
    }
    SearchQueryBean searchQuery = new SearchQueryBean();
    searchQuery.setBounds(bounds);
    searchQuery.setMaxCount(5);
    searchQuery.setType(EQueryType.BOUNDS_OR_CLOSEST);
    searchQuery.setQuery(_code);
    StopsBean stopsResult = _transitDataService.getStops(searchQuery);
    _stops = stopsResult.getStops();
    if (_stops.size() == 0) {
        return "noStopsFound";
    } else if (_stops.size() > 1) {
        return "multipleStopsFound";
    } else {
        _stop = _stops.get(0);
        return "singleStopFound";
    }
}
Also used : SearchQueryBean(org.onebusaway.transit_data.model.SearchQueryBean) CoordinateBounds(org.onebusaway.geospatial.model.CoordinateBounds) StopsBean(org.onebusaway.transit_data.model.StopsBean) Actions(org.apache.struts2.convention.annotation.Actions)

Example 5 with Actions

use of org.apache.struts2.convention.annotation.Actions in project onebusaway-application-modules by camsys.

the class StopsForRouteAction method execute.

@Override
@Actions({ @Action(value = "/where/iphone/stops-for-route") })
public String execute() throws ServiceException {
    if (_id == null || _id.length() == 0)
        return INPUT;
    _route = _transitDataService.getRouteForId(_id);
    StopsForRouteBean stopsForRoute = _transitDataService.getStopsForRoute(_id);
    Map<String, StopGroupingBean> groupingsByType = MappingLibrary.mapToValue(stopsForRoute.getStopGroupings(), "type", String.class);
    StopGroupingBean byDirection = groupingsByType.get(TransitDataConstants.STOP_GROUPING_TYPE_DIRECTION);
    if (_groupIndex == -1) {
        if (byDirection != null) {
            for (StopGroupBean group : byDirection.getStopGroups()) _directionNames.add(group.getName());
        }
        _stops = stopsForRoute.getStops();
        Collections.sort(_stops, _stopNameComparator);
    } else {
        if (byDirection == null)
            return INPUT;
        List<StopGroupBean> groups = byDirection.getStopGroups();
        if (_groupIndex < 0 && groups.size() <= _groupIndex)
            return INPUT;
        Map<String, StopBean> stopById = MappingLibrary.mapToValue(stopsForRoute.getStops(), "id", String.class);
        StopGroupBean stopGroup = groups.get(_groupIndex);
        _stops = new ArrayList<StopBean>();
        for (String stopId : stopGroup.getStopIds()) _stops.add(stopById.get(stopId));
    }
    return SUCCESS;
}
Also used : StopGroupingBean(org.onebusaway.transit_data.model.StopGroupingBean) StopGroupBean(org.onebusaway.transit_data.model.StopGroupBean) StopsForRouteBean(org.onebusaway.transit_data.model.StopsForRouteBean) StopBean(org.onebusaway.transit_data.model.StopBean) Actions(org.apache.struts2.convention.annotation.Actions)

Aggregations

Actions (org.apache.struts2.convention.annotation.Actions)8 Date (java.util.Date)2 CoordinateBounds (org.onebusaway.geospatial.model.CoordinateBounds)2 SearchQueryBean (org.onebusaway.transit_data.model.SearchQueryBean)2 ConfigurationException (com.opensymphony.xwork2.config.ConfigurationException)1 ActionConfig (com.opensymphony.xwork2.config.entities.ActionConfig)1 PackageConfig (com.opensymphony.xwork2.config.entities.PackageConfig)1 ResultTypeConfig (com.opensymphony.xwork2.config.entities.ResultTypeConfig)1 IOException (java.io.IOException)1 PrintWriter (java.io.PrintWriter)1 Annotation (java.lang.annotation.Annotation)1 org.apache.struts2.config (org.apache.struts2.config)1 Action (org.apache.struts2.convention.annotation.Action)1 NoSuchStopServiceException (org.onebusaway.exceptions.NoSuchStopServiceException)1 NoSuchTripServiceException (org.onebusaway.exceptions.NoSuchTripServiceException)1 AgencyWithCoverageBeanComparator (org.onebusaway.presentation.impl.AgencyWithCoverageBeanComparator)1 RoutesBean (org.onebusaway.transit_data.model.RoutesBean)1 StopBean (org.onebusaway.transit_data.model.StopBean)1 StopCalendarDaysBean (org.onebusaway.transit_data.model.StopCalendarDaysBean)1 StopGroupBean (org.onebusaway.transit_data.model.StopGroupBean)1