mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-20 17:29:51 +00:00
query previous connections for EFA based providers
git-svn-id: https://public-transport-enabler.googlecode.com/svn/trunk@944 0924bc21-9374-b0fa-ee44-9ff1593b38f0
This commit is contained in:
parent
e897aaf718
commit
69ca0a5f94
69 changed files with 127 additions and 119 deletions
|
@ -1612,7 +1612,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
|
|||
return uri.toString();
|
||||
}
|
||||
|
||||
private String commandLink(final String sessionId, final String requestId, final String command)
|
||||
private String commandLink(final String sessionId, final String requestId)
|
||||
{
|
||||
final StringBuilder uri = new StringBuilder(apiBase);
|
||||
uri.append(tripEndpoint);
|
||||
|
@ -1620,7 +1620,6 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
|
|||
uri.append("?sessionID=").append(sessionId);
|
||||
uri.append("&requestID=").append(requestId);
|
||||
appendCommonXsltTripRequest2Params(uri);
|
||||
uri.append("&command=").append(command);
|
||||
|
||||
return uri.toString();
|
||||
}
|
||||
|
@ -1653,13 +1652,16 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
|
|||
}
|
||||
}
|
||||
|
||||
public QueryConnectionsResult queryMoreConnections(final String uri) throws IOException
|
||||
public QueryConnectionsResult queryMoreConnections(final String commandUri, final boolean next) throws IOException
|
||||
{
|
||||
final StringBuilder uri = new StringBuilder(commandUri);
|
||||
uri.append("&command=").append(next ? "tripNext" : "tripPrev");
|
||||
|
||||
InputStream is = null;
|
||||
try
|
||||
{
|
||||
is = ParserUtils.scrapeInputStream(uri, null, "NSC_", 3);
|
||||
return queryConnections(uri, is);
|
||||
is = ParserUtils.scrapeInputStream(uri.toString(), null, "NSC_", 3);
|
||||
return queryConnections(uri.toString(), is);
|
||||
}
|
||||
catch (final XmlPullParserException x)
|
||||
{
|
||||
|
@ -2052,7 +2054,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
|
|||
|
||||
XmlPullUtil.exit(pp, "itdRouteList");
|
||||
|
||||
return new QueryConnectionsResult(header, uri, from, via, to, commandLink(context, requestId, "tripNext"), connections);
|
||||
return new QueryConnectionsResult(header, uri, from, via, to, commandLink(context, requestId), connections);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -752,7 +752,6 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
|
|||
}
|
||||
|
||||
final StringBuilder request = new StringBuilder("<ConReq>");
|
||||
|
||||
request.append("<Start>").append(locationXml(from));
|
||||
request.append("<Prod prod=\"").append(productsStr).append("\" bike=\"0\" couchette=\"0\" direct=\"0\" sleeper=\"0\"/>");
|
||||
request.append("</Start>");
|
||||
|
@ -773,13 +772,14 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
|
|||
return queryConnections(request.toString(), from, via, to);
|
||||
}
|
||||
|
||||
public QueryConnectionsResult queryMoreConnections(final String context) throws IOException
|
||||
public QueryConnectionsResult queryMoreConnections(final String context, final boolean next) throws IOException
|
||||
{
|
||||
final String request = "<ConScrReq scr=\"F\" nrCons=\"" + NUM_CONNECTIONS + "\">" //
|
||||
+ "<ConResCtxt>" + context + "</ConResCtxt>" //
|
||||
+ "</ConScrReq>";
|
||||
final StringBuilder request = new StringBuilder("<ConScrReq scr=\"").append('F').append("\" nrCons=\"").append(NUM_CONNECTIONS).append("\">");
|
||||
request.append("<ConResCtxt>").append(context).append("</ConResCtxt>");
|
||||
request.append("</ConScrReq>");
|
||||
// TODO handle next/prev
|
||||
|
||||
return queryConnections(request, null, null, null);
|
||||
return queryConnections(request.toString(), null, null, null);
|
||||
}
|
||||
|
||||
private QueryConnectionsResult queryConnections(final String request, final Location from, final Location via, final Location to)
|
||||
|
|
|
@ -295,9 +295,10 @@ public final class BahnProvider extends AbstractHafasProvider
|
|||
}
|
||||
|
||||
@Override
|
||||
public QueryConnectionsResult queryMoreConnections(final String uri) throws IOException
|
||||
public QueryConnectionsResult queryMoreConnections(final String uri, final boolean next) throws IOException
|
||||
{
|
||||
final CharSequence page = ParserUtils.scrape(uri);
|
||||
// TODO handle next/prev
|
||||
return queryConnections(uri, page);
|
||||
}
|
||||
|
||||
|
|
|
@ -606,9 +606,10 @@ public final class BvgProvider extends AbstractHafasProvider
|
|||
}
|
||||
|
||||
@Override
|
||||
public QueryConnectionsResult queryMoreConnections(final String uri) throws IOException
|
||||
public QueryConnectionsResult queryMoreConnections(final String uri, final boolean next) throws IOException
|
||||
{
|
||||
final CharSequence page = ParserUtils.scrape(uri);
|
||||
// TODO handle next/prev
|
||||
return queryConnections(uri, page);
|
||||
}
|
||||
|
||||
|
|
|
@ -123,10 +123,12 @@ public interface NetworkProvider
|
|||
*
|
||||
* @param context
|
||||
* context to query more connections from
|
||||
* @param next
|
||||
* {@code true} for get next connections, {@code false} for get previous connections
|
||||
* @return result object that contains possible connections
|
||||
* @throws IOException
|
||||
*/
|
||||
QueryConnectionsResult queryMoreConnections(String context) throws IOException;
|
||||
QueryConnectionsResult queryMoreConnections(String context, boolean next) throws IOException;
|
||||
|
||||
/**
|
||||
* Get details about a connection
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue