1 |
torben |
1080 |
package dk.thoerup.traininfoservice.jdo; |
2 |
|
|
|
3 |
|
|
import javax.jdo.annotations.IdGeneratorStrategy; |
4 |
torben |
1105 |
import javax.jdo.annotations.NotPersistent; |
5 |
torben |
1080 |
import javax.jdo.annotations.PersistenceCapable; |
6 |
|
|
import javax.jdo.annotations.Persistent; |
7 |
|
|
import javax.jdo.annotations.PrimaryKey; |
8 |
|
|
|
9 |
torben |
1105 |
import dk.thoerup.android.traininfo.common.StationBean.StationEntry; |
10 |
torben |
1080 |
|
11 |
torben |
1105 |
|
12 |
torben |
1080 |
@PersistenceCapable |
13 |
|
|
public class JdoStationBean { |
14 |
|
|
|
15 |
|
|
@PrimaryKey |
16 |
|
|
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) |
17 |
|
|
private Long id; |
18 |
|
|
|
19 |
|
|
@Persistent |
20 |
torben |
1093 |
private String name; |
21 |
|
|
|
22 |
|
|
@Persistent |
23 |
torben |
1080 |
private double latitude; |
24 |
|
|
|
25 |
|
|
@Persistent |
26 |
|
|
private double longitude; |
27 |
|
|
|
28 |
|
|
@Persistent |
29 |
|
|
private String regional; |
30 |
|
|
|
31 |
|
|
@Persistent |
32 |
|
|
private String strain; |
33 |
|
|
|
34 |
|
|
@Persistent |
35 |
|
|
private String metro; |
36 |
|
|
|
37 |
|
|
@Persistent |
38 |
|
|
private String address; |
39 |
|
|
|
40 |
torben |
1093 |
@Persistent |
41 |
torben |
1105 |
public String aliases[]; |
42 |
torben |
1093 |
|
43 |
torben |
1105 |
@NotPersistent |
44 |
|
|
public int distance = 0; |
45 |
|
|
|
46 |
torben |
1080 |
/************** accessors **************/ |
47 |
|
|
|
48 |
|
|
|
49 |
|
|
public long getId() { |
50 |
|
|
return id; |
51 |
|
|
} |
52 |
|
|
public void setId(long id) { |
53 |
|
|
this.id = id; |
54 |
|
|
} |
55 |
|
|
public String getName() { |
56 |
|
|
return name; |
57 |
|
|
} |
58 |
|
|
public void setName(String name) { |
59 |
|
|
this.name = name; |
60 |
|
|
} |
61 |
torben |
1093 |
|
62 |
torben |
1080 |
public double getLatitude() { |
63 |
|
|
return latitude; |
64 |
|
|
} |
65 |
|
|
public void setLatitude(double latitude) { |
66 |
|
|
this.latitude = latitude; |
67 |
|
|
} |
68 |
|
|
public double getLongitude() { |
69 |
|
|
return longitude; |
70 |
|
|
} |
71 |
|
|
public void setLongitude(double longitude) { |
72 |
|
|
this.longitude = longitude; |
73 |
|
|
} |
74 |
|
|
public String getRegional() { |
75 |
|
|
return regional; |
76 |
|
|
} |
77 |
|
|
public void setRegional(String regional) { |
78 |
|
|
this.regional = regional; |
79 |
|
|
} |
80 |
|
|
|
81 |
|
|
|
82 |
|
|
public String getStrain() { |
83 |
|
|
return strain; |
84 |
|
|
} |
85 |
|
|
public void setStrain(String strain) { |
86 |
|
|
this.strain = strain; |
87 |
|
|
} |
88 |
|
|
|
89 |
|
|
|
90 |
|
|
|
91 |
|
|
public String getMetro() { |
92 |
|
|
return metro; |
93 |
|
|
} |
94 |
|
|
public void setMetro(String metro) { |
95 |
|
|
this.metro = metro; |
96 |
|
|
} |
97 |
|
|
|
98 |
|
|
|
99 |
|
|
|
100 |
|
|
public String getAddress() { |
101 |
|
|
return address; |
102 |
|
|
} |
103 |
|
|
public void setAddress(String address) { |
104 |
|
|
this.address = address; |
105 |
|
|
} |
106 |
torben |
1105 |
|
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 |
torben |
1080 |
|
152 |
|
|
|
153 |
|
|
|
154 |
|
|
} |