mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-15 17:10:30 +00:00
disable earlier connections querying for efa based providers
This commit is contained in:
parent
17c75051b8
commit
0b40edff29
3 changed files with 24 additions and 45 deletions
|
@ -59,7 +59,6 @@ import de.schildbach.pte.dto.QueryConnectionsContext;
|
|||
import de.schildbach.pte.dto.QueryConnectionsResult;
|
||||
import de.schildbach.pte.dto.QueryDeparturesResult;
|
||||
import de.schildbach.pte.dto.ResultHeader;
|
||||
import de.schildbach.pte.dto.SimpleStringContext;
|
||||
import de.schildbach.pte.dto.StationDepartures;
|
||||
import de.schildbach.pte.dto.Stop;
|
||||
import de.schildbach.pte.exception.ParserException;
|
||||
|
@ -84,6 +83,26 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
|
|||
private boolean suppressPositions = false;
|
||||
private final XmlPullParserFactory parserFactory;
|
||||
|
||||
private static class Context implements QueryConnectionsContext
|
||||
{
|
||||
private final String context;
|
||||
|
||||
private Context(final String context)
|
||||
{
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
public boolean canQueryLater()
|
||||
{
|
||||
return context != null;
|
||||
}
|
||||
|
||||
public boolean canQueryEarlier()
|
||||
{
|
||||
return false; // TODO enable earlier querying
|
||||
}
|
||||
}
|
||||
|
||||
public AbstractEfaProvider()
|
||||
{
|
||||
this(null, null);
|
||||
|
@ -1670,7 +1689,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
|
|||
|
||||
public QueryConnectionsResult queryMoreConnections(final QueryConnectionsContext contextObj, final boolean later) throws IOException
|
||||
{
|
||||
final SimpleStringContext context = (SimpleStringContext) contextObj;
|
||||
final Context context = (Context) contextObj;
|
||||
final String commandUri = context.context;
|
||||
final StringBuilder uri = new StringBuilder(commandUri);
|
||||
uri.append("&command=").append(later ? "tripNext" : "tripPrev");
|
||||
|
@ -2082,8 +2101,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
|
|||
|
||||
XmlPullUtil.exit(pp, "itdRouteList");
|
||||
|
||||
return new QueryConnectionsResult(header, uri, from, via, to, new SimpleStringContext(commandLink((String) context, requestId)),
|
||||
connections);
|
||||
return new QueryConnectionsResult(header, uri, from, via, to, new Context(commandLink((String) context, requestId)), connections);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -1,41 +0,0 @@
|
|||
/*
|
||||
* Copyright 2012 the original author or authors.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.schildbach.pte.dto;
|
||||
|
||||
/**
|
||||
* @author Andreas Schildbach
|
||||
*/
|
||||
public class SimpleStringContext implements QueryConnectionsContext
|
||||
{
|
||||
public final String context;
|
||||
|
||||
public SimpleStringContext(final String context)
|
||||
{
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
public boolean canQueryLater()
|
||||
{
|
||||
return context != null;
|
||||
}
|
||||
|
||||
public boolean canQueryEarlier()
|
||||
{
|
||||
return context != null;
|
||||
}
|
||||
}
|
|
@ -109,6 +109,8 @@ public class LinzProviderLiveTest extends AbstractProviderLiveTest
|
|||
System.out.println(result);
|
||||
final QueryConnectionsResult laterResult = provider.queryMoreConnections(result.context, true);
|
||||
System.out.println(laterResult);
|
||||
final QueryConnectionsResult earlierResult = provider.queryMoreConnections(laterResult.context, false);
|
||||
System.out.println(earlierResult);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue