1 |
package dk.thoerup.traininfoservice.jdo; |
package dk.thoerup.traininfoservice.jdo; |
2 |
|
|
|
import java.util.List; |
|
|
|
|
3 |
import javax.jdo.annotations.IdGeneratorStrategy; |
import javax.jdo.annotations.IdGeneratorStrategy; |
4 |
|
import javax.jdo.annotations.NotPersistent; |
5 |
import javax.jdo.annotations.PersistenceCapable; |
import javax.jdo.annotations.PersistenceCapable; |
6 |
import javax.jdo.annotations.Persistent; |
import javax.jdo.annotations.Persistent; |
7 |
import javax.jdo.annotations.PrimaryKey; |
import javax.jdo.annotations.PrimaryKey; |
8 |
|
|
9 |
|
import dk.thoerup.android.traininfo.common.StationBean.StationEntry; |
10 |
|
|
11 |
|
|
12 |
@PersistenceCapable |
@PersistenceCapable |
13 |
public class JdoStationBean { |
public class JdoStationBean { |
20 |
private String name; |
private String name; |
21 |
|
|
22 |
@Persistent |
@Persistent |
|
private String nameLower; |
|
|
|
|
|
@Persistent |
|
23 |
private double latitude; |
private double latitude; |
24 |
|
|
25 |
@Persistent |
@Persistent |
38 |
private String address; |
private String address; |
39 |
|
|
40 |
@Persistent |
@Persistent |
41 |
private List<JdoStationAlias> aliases; |
public String aliases[]; |
42 |
|
|
43 |
|
@NotPersistent |
44 |
|
public int distance = 0; |
45 |
|
|
46 |
/************** accessors **************/ |
/************** accessors **************/ |
47 |
|
|
59 |
this.name = name; |
this.name = name; |
60 |
} |
} |
61 |
|
|
|
|
|
|
public String getNameLower() { |
|
|
return nameLower; |
|
|
} |
|
|
public void setNameLower(String name) { |
|
|
this.nameLower = name; |
|
|
} |
|
|
|
|
|
|
|
62 |
public double getLatitude() { |
public double getLatitude() { |
63 |
return latitude; |
return latitude; |
64 |
} |
} |
103 |
public void setAddress(String address) { |
public void setAddress(String address) { |
104 |
this.address = address; |
this.address = address; |
105 |
} |
} |
106 |
|
|
107 |
|
/************** converters *******************/ |
108 |
|
|
109 |
|
public StationEntry toStationEntry() { |
110 |
|
StationEntry entry = new StationEntry(); |
111 |
|
|
112 |
|
entry.setId( id.intValue() ); |
113 |
|
entry.setName( name ); |
114 |
|
entry.setAddress( address ); |
115 |
|
entry.setLatitude( latitude ); |
116 |
|
entry.setLongitude( longitude ); |
117 |
|
|
118 |
|
entry.setRegional( regional ); |
119 |
|
entry.setIsRegional( regional != null ); |
120 |
|
|
121 |
|
entry.setStrain(strain); |
122 |
|
entry.setIsStrain( strain != null ); |
123 |
|
|
124 |
|
entry.setMetro(metro); |
125 |
|
entry.setIsMetro( metro != null ); |
126 |
|
entry.setCalcdist( distance ); |
127 |
|
|
128 |
|
return entry; |
129 |
|
} |
130 |
|
|
131 |
|
public static JdoStationBean fromStationEntry(StationEntry entry) { |
132 |
|
|
133 |
|
JdoStationBean station = new JdoStationBean(); |
134 |
|
station.setId( (long) entry.getId() ); |
135 |
|
station.setName( entry.getName() ); |
136 |
|
station.setAddress( entry.getAddress() ); |
137 |
|
station.setLatitude( entry.getLatitude() ); |
138 |
|
station.setLongitude( entry.getLongitude() ); |
139 |
|
|
140 |
|
station.setRegional( entry.getRegional() ); |
141 |
|
station.setStrain( entry.getStrain() ); |
142 |
|
station.setMetro( entry.getMetro() ); |
143 |
|
station.aliases = entry.getAliases() ; |
144 |
|
|
145 |
|
|
146 |
|
|
147 |
|
|
148 |
|
return station; |
149 |
|
} |
150 |
|
|
151 |
|
|
152 |
|
|
153 |
|
|