-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#17 convertion of gpsdata to and from string when saving and retrivin…
…g from db, for route automatically
- Loading branch information
Showing
11 changed files
with
183 additions
and
25 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
...erbusserver/core/src/main/java/gse1/buergerbusserver/general/common/api/datatype/Gps.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package gse1.buergerbusserver.general.common.api.datatype; | ||
|
||
public class Gps { | ||
|
||
private double langitude; | ||
|
||
private double lattitude; | ||
|
||
public double getLangitude() { | ||
|
||
return langitude; | ||
} | ||
|
||
public void setLangitude(double langitude) { | ||
|
||
this.langitude = langitude; | ||
} | ||
|
||
public double getLattitude() { | ||
|
||
return lattitude; | ||
} | ||
|
||
public void setLattitude(double lattitude) { | ||
|
||
this.lattitude = lattitude; | ||
} | ||
|
||
public Gps(String stringValue){ | ||
this.lattitude = Double.parseDouble(stringValue.substring(0, stringValue.indexOf(','))); | ||
this.langitude = Double.parseDouble(stringValue.substring(stringValue.indexOf(',')+1,stringValue.length()-1)); | ||
|
||
} | ||
public Gps() | ||
{ | ||
|
||
} | ||
|
||
@Override | ||
public String toString(){ | ||
|
||
return String.valueOf(this.lattitude) + ',' + String.valueOf(this.langitude); | ||
} | ||
|
||
|
||
} |
38 changes: 38 additions & 0 deletions
38
...server/core/src/main/java/gse1/buergerbusserver/general/dataaccess/base/GpsConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package gse1.buergerbusserver.general.dataaccess.base; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
import gse1.buergerbusserver.general.common.api.datatype.Gps; | ||
|
||
import javax.persistence.AttributeConverter; | ||
|
||
import org.hibernate.metamodel.domain.BasicType; | ||
|
||
public class GpsConverter implements AttributeConverter<List<Gps>, String> { | ||
|
||
@Override | ||
public String convertToDatabaseColumn(List<Gps> Gpslist) { | ||
|
||
String aggrigated = ""; | ||
for(Gps gps:Gpslist) | ||
aggrigated = aggrigated + gps.toString() + ';'; | ||
|
||
aggrigated = aggrigated.substring(0, aggrigated.length()-1); | ||
return aggrigated; | ||
} | ||
|
||
@Override | ||
public List<Gps> convertToEntityAttribute(String gpsCommaSeperated) { | ||
|
||
List<String> listOfGpses = Arrays.asList(gpsCommaSeperated.split("\\s*;\\s*")); | ||
|
||
List<Gps> GpsList = new ArrayList<Gps>(); | ||
for(String gpsString:listOfGpses) | ||
GpsList.add(new Gps(gpsString)); | ||
|
||
return GpsList; | ||
} | ||
//#todo extends AttributeConverter<String, List<Gps>> | ||
} |
6 changes: 4 additions & 2 deletions
6
...erbusserver/core/src/main/java/gse1/buergerbusserver/linemanagement/common/api/Route.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
...re/src/main/java/gse1/buergerbusserver/linemanagement/logic/api/to/LineWithBusIdsCto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package gse1.buergerbusserver.linemanagement.logic.api.to; | ||
|
||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
|
||
|
||
public class LineWithBusIdsCto extends LineEto { | ||
|
||
|
||
private List<BusEto> buses; | ||
public List<Long> getBusids() { | ||
|
||
List<Long> returnlist = new ArrayList<Long>(); | ||
|
||
for(BusEto bus:this.buses) | ||
returnlist.add(bus.getId()); | ||
return returnlist; | ||
} | ||
|
||
|
||
|
||
public void setBuses(List<BusEto> buses) { | ||
|
||
this.buses = buses; | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters