mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-15 09:00:36 +00:00
query history remembers whole Locations
git-svn-id: https://public-transport-enabler.googlecode.com/svn/trunk@250 0924bc21-9374-b0fa-ee44-9ff1593b38f0
This commit is contained in:
parent
e282106c00
commit
9c7150956a
9 changed files with 53 additions and 45 deletions
|
@ -102,8 +102,11 @@ public abstract class AbstractEfaProvider implements NetworkProvider
|
|||
|
||||
private Location processOdvNameElem(final XmlPullParser pp) throws XmlPullParserException, IOException
|
||||
{
|
||||
final String type = pp.getAttributeValue(null, "anyType");
|
||||
int id = Integer.parseInt(pp.getAttributeValue(null, "id"));
|
||||
final String anyType = pp.getAttributeValue(null, "anyType");
|
||||
final String idStr = pp.getAttributeValue(null, "id");
|
||||
int id = 0;
|
||||
if (idStr != null)
|
||||
id = Integer.parseInt(idStr);
|
||||
if (id < 0)
|
||||
id = 0;
|
||||
int lat = 0, lon = 0;
|
||||
|
@ -113,7 +116,11 @@ public abstract class AbstractEfaProvider implements NetworkProvider
|
|||
lon = Integer.parseInt(pp.getAttributeValue(null, "x"));
|
||||
}
|
||||
final String name = normalizeLocationName(pp.nextText());
|
||||
return new Location(type(type), id, lat, lon, name);
|
||||
|
||||
LocationType type = LocationType.ADDRESS;
|
||||
if (anyType != null)
|
||||
type = type(anyType);
|
||||
return new Location(type, id, lat, lon, name);
|
||||
}
|
||||
|
||||
private Location processItdOdvAssignedStop(final XmlPullParser pp)
|
||||
|
@ -654,7 +661,7 @@ public abstract class AbstractEfaProvider implements NetworkProvider
|
|||
|
||||
// parse odv name elements
|
||||
List<Location> ambiguousFrom = null, ambiguousTo = null, ambiguousVia = null;
|
||||
String from = null, to = null;
|
||||
Location from = null, via = null, to = null;
|
||||
|
||||
XmlPullUtil.jumpToStartTag(pp, null, "itdOdv");
|
||||
if (!"origin".equals(pp.getAttributeValue(null, "usage")))
|
||||
|
@ -670,7 +677,7 @@ public abstract class AbstractEfaProvider implements NetworkProvider
|
|||
else if ("identified".equals(originState))
|
||||
{
|
||||
XmlPullUtil.nextStartTagInsideTree(pp, null, "odvNameElem");
|
||||
from = pp.nextText();
|
||||
from = processOdvNameElem(pp);
|
||||
}
|
||||
|
||||
XmlPullUtil.jumpToStartTag(pp, null, "itdOdv");
|
||||
|
@ -687,7 +694,7 @@ public abstract class AbstractEfaProvider implements NetworkProvider
|
|||
else if ("identified".equals(destinationState))
|
||||
{
|
||||
XmlPullUtil.nextStartTagInsideTree(pp, null, "odvNameElem");
|
||||
to = pp.nextText();
|
||||
to = processOdvNameElem(pp);
|
||||
}
|
||||
|
||||
XmlPullUtil.jumpToStartTag(pp, null, "itdOdv");
|
||||
|
@ -703,7 +710,8 @@ public abstract class AbstractEfaProvider implements NetworkProvider
|
|||
}
|
||||
else if ("identified".equals(viaState))
|
||||
{
|
||||
// TODO parse identified name/id
|
||||
XmlPullUtil.nextStartTagInsideTree(pp, null, "odvNameElem");
|
||||
via = processOdvNameElem(pp);
|
||||
}
|
||||
|
||||
if (ambiguousFrom != null || ambiguousTo != null || ambiguousVia != null)
|
||||
|
@ -779,7 +787,7 @@ public abstract class AbstractEfaProvider implements NetworkProvider
|
|||
XmlPullUtil.skipRestOfTree(pp);
|
||||
}
|
||||
|
||||
return new QueryConnectionsResult(uri, from, to, null, commandLink(sessionId, "tripPrev"), commandLink(sessionId, "tripNext"),
|
||||
return new QueryConnectionsResult(uri, from, via, to, commandLink(sessionId, "tripPrev"), commandLink(sessionId, "tripNext"),
|
||||
connections);
|
||||
}
|
||||
else
|
||||
|
|
|
@ -253,8 +253,8 @@ public final class BahnProvider implements NetworkProvider
|
|||
final Matcher mHead = P_CONNECTIONS_HEAD.matcher(page);
|
||||
if (mHead.matches())
|
||||
{
|
||||
final String from = ParserUtils.resolveEntities(mHead.group(1));
|
||||
final String to = ParserUtils.resolveEntities(mHead.group(2));
|
||||
final Location from = new Location(LocationType.ANY, 0, 0, 0, ParserUtils.resolveEntities(mHead.group(1)));
|
||||
final Location to = new Location(LocationType.ANY, 0, 0, 0, ParserUtils.resolveEntities(mHead.group(2)));
|
||||
final Date currentDate = ParserUtils.parseDate(mHead.group(3));
|
||||
final String linkEarlier = mHead.group(4) != null ? ParserUtils.resolveEntities(mHead.group(4)) : null;
|
||||
final String linkLater = mHead.group(5) != null ? ParserUtils.resolveEntities(mHead.group(5)) : null;
|
||||
|
@ -285,7 +285,7 @@ public final class BahnProvider implements NetworkProvider
|
|||
else
|
||||
line = null;
|
||||
final Connection connection = new Connection(ParserUtils.extractId(link), link, departureTime, arrivalTime, line,
|
||||
line != null ? LINES.get(line.charAt(0)) : null, 0, from, 0, to, null);
|
||||
line != null ? LINES.get(line.charAt(0)) : null, 0, from.name, 0, to.name, null);
|
||||
connections.add(connection);
|
||||
}
|
||||
else
|
||||
|
@ -294,7 +294,7 @@ public final class BahnProvider implements NetworkProvider
|
|||
}
|
||||
}
|
||||
|
||||
return new QueryConnectionsResult(uri, from, to, currentDate, linkEarlier, linkLater, connections);
|
||||
return new QueryConnectionsResult(uri, from, null, to, linkEarlier, linkLater, connections);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -352,9 +352,9 @@ public class MvvProvider extends AbstractEfaProvider
|
|||
final Matcher mHead = P_CONNECTIONS_HEAD.matcher(page);
|
||||
if (mHead.matches())
|
||||
{
|
||||
final String from = ParserUtils.resolveEntities(mHead.group(1));
|
||||
final String to = ParserUtils.resolveEntities(mHead.group(2));
|
||||
// final String via = ParserUtils.resolveEntities(mHead.group(3));
|
||||
final Location from = new Location(LocationType.ANY, 0, 0, 0, ParserUtils.resolveEntities(mHead.group(1)));
|
||||
final Location to = new Location(LocationType.ANY, 0, 0, 0, ParserUtils.resolveEntities(mHead.group(2)));
|
||||
final Location via = mHead.group(3) != null ? new Location(LocationType.ANY, 0, 0, 0, ParserUtils.resolveEntities(mHead.group(3))) : null;
|
||||
final Date currentDate = parseDate(mHead.group(4), mHead.group(5), mHead.group(6));
|
||||
final String linkEarlier = mHead.group(7) != null ? API_BASE + ParserUtils.resolveEntities(mHead.group(7)) : null;
|
||||
final String linkLater = mHead.group(8) != null ? API_BASE + ParserUtils.resolveEntities(mHead.group(8)) : null;
|
||||
|
@ -388,7 +388,7 @@ public class MvvProvider extends AbstractEfaProvider
|
|||
if (departureTime.after(arrivalTime))
|
||||
arrivalTime = ParserUtils.addDays(arrivalTime, 1);
|
||||
final Connection connection = new Connection(ParserUtils.extractId(link), link, departureTime, arrivalTime, null, null, 0,
|
||||
from, 0, to, null);
|
||||
from.name, 0, to.name, null);
|
||||
connections.add(connection);
|
||||
}
|
||||
else
|
||||
|
@ -399,7 +399,7 @@ public class MvvProvider extends AbstractEfaProvider
|
|||
calendar.add(Calendar.MINUTE, min);
|
||||
final Date arrivalTime = calendar.getTime();
|
||||
final Connection connection = new Connection(ParserUtils.extractId(link), link, departureTime, arrivalTime, null, null, 0,
|
||||
from, 0, to, null);
|
||||
from.name, 0, to.name, null);
|
||||
connections.add(connection);
|
||||
}
|
||||
}
|
||||
|
@ -409,7 +409,7 @@ public class MvvProvider extends AbstractEfaProvider
|
|||
}
|
||||
}
|
||||
|
||||
return new QueryConnectionsResult(uri, from, to, currentDate, linkEarlier, linkLater, connections);
|
||||
return new QueryConnectionsResult(uri, from, via, to, linkEarlier, linkLater, connections);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -370,8 +370,8 @@ public class OebbProvider extends AbstractHafasProvider
|
|||
final Matcher mHead = P_CONNECTIONS_HEAD.matcher(page);
|
||||
if (mHead.matches())
|
||||
{
|
||||
final String from = ParserUtils.resolveEntities(mHead.group(1));
|
||||
final String to = ParserUtils.resolveEntities(mHead.group(2));
|
||||
final Location from = new Location(LocationType.ANY, 0, 0, 0, ParserUtils.resolveEntities(mHead.group(1)));
|
||||
final Location to = new Location(LocationType.ANY, 0, 0, 0, ParserUtils.resolveEntities(mHead.group(2)));
|
||||
final Date currentDate = ParserUtils.parseDate(mHead.group(3));
|
||||
final String linkEarlier = mHead.group(4) != null ? ParserUtils.resolveEntities(mHead.group(4)) : null;
|
||||
final String linkLater = mHead.group(5) != null ? ParserUtils.resolveEntities(mHead.group(5)) : null;
|
||||
|
@ -396,8 +396,8 @@ public class OebbProvider extends AbstractHafasProvider
|
|||
: overviewDepartureDate, ParserUtils.parseTime(mConFine.group(4)));
|
||||
final String link = allDetailsUri; // TODO use print link?
|
||||
|
||||
final Connection connection = new Connection(id, link, overviewDepartureTime, overviewArrivalTime, null, null, 0, from, 0, to,
|
||||
new ArrayList<Connection.Part>(1));
|
||||
final Connection connection = new Connection(id, link, overviewDepartureTime, overviewArrivalTime, null, null, 0, from.name, 0,
|
||||
to.name, new ArrayList<Connection.Part>(1));
|
||||
connections.add(connection);
|
||||
|
||||
final Matcher mDetCoarse = P_CONNECTION_DETAILS_COARSE.matcher(details);
|
||||
|
@ -471,7 +471,7 @@ public class OebbProvider extends AbstractHafasProvider
|
|||
|
||||
}
|
||||
|
||||
return new QueryConnectionsResult(allDetailsUri, from, to, currentDate, linkEarlier, linkLater, connections);
|
||||
return new QueryConnectionsResult(allDetailsUri, from, null, to, linkEarlier, linkLater, connections);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -251,8 +251,8 @@ public class RmvProvider extends AbstractHafasProvider
|
|||
final Matcher mHead = P_CONNECTIONS_HEAD.matcher(page);
|
||||
if (mHead.matches())
|
||||
{
|
||||
final String from = ParserUtils.resolveEntities(mHead.group(1));
|
||||
final String to = ParserUtils.resolveEntities(mHead.group(2));
|
||||
final Location from = new Location(LocationType.ANY, 0, 0, 0, ParserUtils.resolveEntities(mHead.group(1)));
|
||||
final Location to = new Location(LocationType.ANY, 0, 0, 0, ParserUtils.resolveEntities(mHead.group(2)));
|
||||
final Date currentDate = ParserUtils.parseDate(mHead.group(3));
|
||||
final String linkEarlier = mHead.group(4) != null ? ParserUtils.resolveEntities(mHead.group(4)) : null;
|
||||
final String linkLater = mHead.group(5) != null ? ParserUtils.resolveEntities(mHead.group(5)) : null;
|
||||
|
@ -283,7 +283,7 @@ public class RmvProvider extends AbstractHafasProvider
|
|||
else
|
||||
line = null;
|
||||
final Connection connection = new Connection(ParserUtils.extractId(link), link, departureTime, arrivalTime, line,
|
||||
line != null ? lineColors(line) : null, 0, from, 0, to, null);
|
||||
line != null ? lineColors(line) : null, 0, from.name, 0, to.name, null);
|
||||
connections.add(connection);
|
||||
}
|
||||
else
|
||||
|
@ -292,7 +292,7 @@ public class RmvProvider extends AbstractHafasProvider
|
|||
}
|
||||
}
|
||||
|
||||
return new QueryConnectionsResult(uri, from, to, currentDate, linkEarlier, linkLater, connections);
|
||||
return new QueryConnectionsResult(uri, from, null, to, linkEarlier, linkLater, connections);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -258,9 +258,8 @@ public class SbbProvider extends AbstractHafasProvider
|
|||
final Matcher mHead = P_CONNECTIONS_HEAD.matcher(page);
|
||||
if (mHead.matches())
|
||||
{
|
||||
final String from = ParserUtils.resolveEntities(mHead.group(1));
|
||||
final Date currentDate = ParserUtils.parseDate(mHead.group(2));
|
||||
final String to = ParserUtils.resolveEntities(mHead.group(3));
|
||||
final Location from = new Location(LocationType.ANY, 0, 0, 0, ParserUtils.resolveEntities(mHead.group(1)));
|
||||
final Location to = new Location(LocationType.ANY, 0, 0, 0, ParserUtils.resolveEntities(mHead.group(3)));
|
||||
final String linkEarlier = mHead.group(4) != null ? ParserUtils.resolveEntities(mHead.group(4)) : null;
|
||||
final String linkLater = mHead.group(5) != null ? ParserUtils.resolveEntities(mHead.group(5)) : null;
|
||||
final List<Connection> connections = new ArrayList<Connection>();
|
||||
|
@ -287,7 +286,7 @@ public class SbbProvider extends AbstractHafasProvider
|
|||
.parseTime(mConFine.group(5)));
|
||||
final String link = uri + "#" + id; // TODO use print link?
|
||||
|
||||
final Connection connection = new Connection(id, link, departureTime, arrivalTime, null, null, 0, from, 0, to,
|
||||
final Connection connection = new Connection(id, link, departureTime, arrivalTime, null, null, 0, from.name, 0, to.name,
|
||||
new ArrayList<Connection.Part>(1));
|
||||
connections.add(connection);
|
||||
}
|
||||
|
@ -368,7 +367,7 @@ public class SbbProvider extends AbstractHafasProvider
|
|||
}
|
||||
}
|
||||
|
||||
return new QueryConnectionsResult(uri, from, to, currentDate, linkEarlier, linkLater, connections);
|
||||
return new QueryConnectionsResult(uri, from, null, to, linkEarlier, linkLater, connections);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -266,8 +266,8 @@ public final class VbbProvider implements NetworkProvider
|
|||
final Matcher mHead = P_CONNECTIONS_HEAD.matcher(page);
|
||||
if (mHead.matches())
|
||||
{
|
||||
final String from = ParserUtils.resolveEntities(mHead.group(1));
|
||||
final String to = ParserUtils.resolveEntities(mHead.group(2));
|
||||
final Location from = new Location(LocationType.ANY, 0, 0, 0, ParserUtils.resolveEntities(mHead.group(1)));
|
||||
final Location to = new Location(LocationType.ANY, 0, 0, 0, ParserUtils.resolveEntities(mHead.group(2)));
|
||||
final Date currentDate = ParserUtils.parseDate(mHead.group(3));
|
||||
final String linkEarlier = mHead.group(4) != null ? BVG_BASE_URL + ParserUtils.resolveEntities(mHead.group(4)) : null;
|
||||
final String linkLater = mHead.group(5) != null ? BVG_BASE_URL + ParserUtils.resolveEntities(mHead.group(5)) : null;
|
||||
|
@ -294,7 +294,7 @@ public final class VbbProvider implements NetworkProvider
|
|||
arrivalTime = ParserUtils.addDays(arrivalTime, 1);
|
||||
final String line = normalizeLine(ParserUtils.resolveEntities(mConFine.group(4)));
|
||||
final Connection connection = new Connection(ParserUtils.extractId(link), link, departureTime, arrivalTime, line,
|
||||
line != null ? LINES.get(line.charAt(0)) : null, 0, from, 0, to, null);
|
||||
line != null ? LINES.get(line.charAt(0)) : null, 0, from.name, 0, to.name, null);
|
||||
connections.add(connection);
|
||||
}
|
||||
else
|
||||
|
@ -303,7 +303,7 @@ public final class VbbProvider implements NetworkProvider
|
|||
}
|
||||
}
|
||||
|
||||
return new QueryConnectionsResult(uri, from, to, currentDate, linkEarlier, linkLater, connections);
|
||||
return new QueryConnectionsResult(uri, from, null, to, linkEarlier, linkLater, connections);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -16,10 +16,12 @@
|
|||
*/
|
||||
package de.schildbach.pte.dto;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author Andreas Schildbach
|
||||
*/
|
||||
public final class Location
|
||||
public final class Location implements Serializable
|
||||
{
|
||||
public final LocationType type;
|
||||
public final int id;
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
package de.schildbach.pte.dto;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -42,21 +41,21 @@ public final class QueryConnectionsResult implements Serializable
|
|||
public final List<Location> ambiguousTo;
|
||||
|
||||
public final String queryUri;
|
||||
public final String from;
|
||||
public final String to;
|
||||
public final Date currentDate;
|
||||
public final Location from;
|
||||
public final Location via;
|
||||
public final Location to;
|
||||
public final String linkEarlier;
|
||||
public final String linkLater;
|
||||
public final List<Connection> connections;
|
||||
|
||||
public QueryConnectionsResult(final String queryUri, final String from, final String to, final Date currentDate, final String linkEarlier,
|
||||
public QueryConnectionsResult(final String queryUri, final Location from, final Location via, final Location to, final String linkEarlier,
|
||||
final String linkLater, final List<Connection> connections)
|
||||
{
|
||||
this.status = Status.OK;
|
||||
this.queryUri = queryUri;
|
||||
this.from = from;
|
||||
this.via = via;
|
||||
this.to = to;
|
||||
this.currentDate = currentDate;
|
||||
this.linkEarlier = linkEarlier;
|
||||
this.linkLater = linkLater;
|
||||
this.connections = connections;
|
||||
|
@ -75,8 +74,8 @@ public final class QueryConnectionsResult implements Serializable
|
|||
|
||||
this.queryUri = null;
|
||||
this.from = null;
|
||||
this.via = null;
|
||||
this.to = null;
|
||||
this.currentDate = null;
|
||||
this.linkEarlier = null;
|
||||
this.linkLater = null;
|
||||
this.connections = null;
|
||||
|
@ -91,8 +90,8 @@ public final class QueryConnectionsResult implements Serializable
|
|||
this.ambiguousTo = null;
|
||||
this.queryUri = null;
|
||||
this.from = null;
|
||||
this.via = null;
|
||||
this.to = null;
|
||||
this.currentDate = null;
|
||||
this.linkEarlier = null;
|
||||
this.linkLater = null;
|
||||
this.connections = null;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue