1 |
package dk.thoerup.traininfoservice.jdo; |
2 |
|
3 |
import java.io.Serializable; |
4 |
|
5 |
import javax.jdo.annotations.IdGeneratorStrategy; |
6 |
import javax.jdo.annotations.NotPersistent; |
7 |
import javax.jdo.annotations.PersistenceCapable; |
8 |
import javax.jdo.annotations.Persistent; |
9 |
import javax.jdo.annotations.PrimaryKey; |
10 |
|
11 |
import dk.thoerup.android.traininfo.common.StationEntry; |
12 |
|
13 |
|
14 |
@PersistenceCapable |
15 |
public class JdoStationBean implements Serializable { |
16 |
|
17 |
@PrimaryKey |
18 |
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) |
19 |
private Long id; |
20 |
|
21 |
@Persistent |
22 |
private String name; |
23 |
|
24 |
@Persistent |
25 |
private double latitude; |
26 |
|
27 |
@Persistent |
28 |
private double longitude; |
29 |
|
30 |
@Persistent |
31 |
private String regional; |
32 |
|
33 |
@Persistent |
34 |
private String strain; |
35 |
|
36 |
@Persistent |
37 |
private String metro; |
38 |
|
39 |
@Persistent |
40 |
private String address; |
41 |
|
42 |
@Persistent |
43 |
public String aliases[]; |
44 |
|
45 |
@NotPersistent |
46 |
public int distance = 0; |
47 |
|
48 |
/************** accessors **************/ |
49 |
|
50 |
|
51 |
public long getId() { |
52 |
return id; |
53 |
} |
54 |
public void setId(long id) { |
55 |
this.id = id; |
56 |
} |
57 |
public String getName() { |
58 |
return name; |
59 |
} |
60 |
public void setName(String name) { |
61 |
this.name = name; |
62 |
} |
63 |
|
64 |
public double getLatitude() { |
65 |
return latitude; |
66 |
} |
67 |
public void setLatitude(double latitude) { |
68 |
this.latitude = latitude; |
69 |
} |
70 |
public double getLongitude() { |
71 |
return longitude; |
72 |
} |
73 |
public void setLongitude(double longitude) { |
74 |
this.longitude = longitude; |
75 |
} |
76 |
public String getRegional() { |
77 |
return regional; |
78 |
} |
79 |
public void setRegional(String regional) { |
80 |
this.regional = regional; |
81 |
} |
82 |
|
83 |
|
84 |
public String getStrain() { |
85 |
return strain; |
86 |
} |
87 |
public void setStrain(String strain) { |
88 |
this.strain = strain; |
89 |
} |
90 |
|
91 |
|
92 |
|
93 |
public String getMetro() { |
94 |
return metro; |
95 |
} |
96 |
public void setMetro(String metro) { |
97 |
this.metro = metro; |
98 |
} |
99 |
|
100 |
|
101 |
|
102 |
public String getAddress() { |
103 |
return address; |
104 |
} |
105 |
public void setAddress(String address) { |
106 |
this.address = address; |
107 |
} |
108 |
|
109 |
/************** converters *******************/ |
110 |
|
111 |
public StationEntry toStationEntry() { |
112 |
StationEntry entry = new StationEntry(); |
113 |
|
114 |
entry.setId( id.intValue() ); |
115 |
entry.setName( name ); |
116 |
entry.setAddress( address ); |
117 |
entry.setLatitude( latitude ); |
118 |
entry.setLongitude( longitude ); |
119 |
|
120 |
entry.setRegional( regional ); |
121 |
entry.setIsRegional( regional != null ); |
122 |
|
123 |
entry.setStrain(strain); |
124 |
entry.setIsStrain( strain != null ); |
125 |
|
126 |
entry.setMetro(metro); |
127 |
entry.setIsMetro( metro != null ); |
128 |
entry.setCalcdist( distance ); |
129 |
|
130 |
return entry; |
131 |
} |
132 |
|
133 |
public static JdoStationBean fromStationEntry(StationEntry entry) { |
134 |
|
135 |
JdoStationBean station = new JdoStationBean(); |
136 |
station.setId( (long) entry.getId() ); |
137 |
station.setName( entry.getName() ); |
138 |
station.setAddress( entry.getAddress() ); |
139 |
station.setLatitude( entry.getLatitude() ); |
140 |
station.setLongitude( entry.getLongitude() ); |
141 |
|
142 |
station.setRegional( entry.getRegional() ); |
143 |
station.setStrain( entry.getStrain() ); |
144 |
station.setMetro( entry.getMetro() ); |
145 |
station.aliases = entry.getAliases() ; |
146 |
|
147 |
|
148 |
|
149 |
|
150 |
return station; |
151 |
} |
152 |
|
153 |
|
154 |
|
155 |
|
156 |
} |