Skip to content

Commit

Permalink
Merge branch 'usermanagement' of https://github.com/TrackSee/Taxi-Ser…
Browse files Browse the repository at this point in the history
…vice-System into usermanagement
  • Loading branch information
Vadimka29 committed Aug 17, 2015
2 parents e83e158 + d265d6c commit caaab24
Show file tree
Hide file tree
Showing 156 changed files with 42,031 additions and 2,111 deletions.
6 changes: 1 addition & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,4 @@ hs_err_pid*
# IntelliJ
out/
target/
/bin/
storage/src/main/resources/META-INF
.gitignore
presentation/src/main/java/ua/com/tracksee/servlets/Test.java
presentation/src/main/webapp/WEB-INF/web.xml
bin/
12 changes: 12 additions & 0 deletions logic/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<properties>
<endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jackson-2-version>2.5.3</jackson-2-version>
</properties>

<dependencies>
Expand All @@ -25,6 +26,17 @@
<version>${project.parent.version}</version>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>${jackson-2-version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>${jackson-2-version}</version>
</dependency>

<!--for email notifications-->
<dependency>
<groupId>javax.mail</groupId>
Expand Down
12 changes: 12 additions & 0 deletions logic/src/main/java/ua/com/tracksee/config/ConfigManagerBean.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@
import javax.ejb.EJB;
import javax.ejb.Stateless;

import java.math.BigDecimal;

import static java.lang.Double.parseDouble;
import static ua.com.tracksee.config.ConfigName.MINIMAL_ORDER_DISTANCE;
import static ua.com.tracksee.config.ConfigName.ANIMAL_TRANSPORTATION_MULTIPLIER;

/**
* Used to guarantee fast access to configs
Expand All @@ -30,4 +33,13 @@ public double getMinimalOrderDistance() {
public void setMinimalOrderDistance(double minimalOrderDistance) {
configDao.saveConfig(new ConfigEntity(MINIMAL_ORDER_DISTANCE, Double.toString(minimalOrderDistance)));
}

public BigDecimal getAnimalTransportationMultiplier() {
String string = configDao.getConfig(ANIMAL_TRANSPORTATION_MULTIPLIER).getValue();
try {
return new BigDecimal(string);
} catch (NumberFormatException | NullPointerException e) {
throw new ConfigException("MINIMAL_ORDER_DISTANCE configured in the wrong way");
}
}
}
2 changes: 1 addition & 1 deletion logic/src/main/java/ua/com/tracksee/config/ConfigName.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
*/
public interface ConfigName {
String MINIMAL_ORDER_DISTANCE = "minimal_order_distance";
String AIR_CODITIONER = "";
String ANIMAL_TRANSPORTATION_MULTIPLIER = "animal_transportation_multiplier";
}
40 changes: 39 additions & 1 deletion logic/src/main/java/ua/com/tracksee/dto/Location.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
package ua.com.tracksee.dto;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.util.Objects;

/**
* Taxi order data transfer object class.
* Objects of this class are used for converting to and from JSON.
*
* @author Ruslan Gunavardana
*/
public class Location {
public class Location implements Cloneable {
private static final Logger logger = LogManager.getLogger(Location.class);

private double lat;
private double lng;

Expand All @@ -33,4 +40,35 @@ public double getLng() {
public void setLng(double lng) {
this.lng = lng;
}

@Override
public String toString() {
return "Location{" + "lat=" + lat + ", lng=" + lng + '}';
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Location location = (Location) o;
return Objects.equals(lat, location.lat) &&
Objects.equals(lng, location.lng);
}

@Override
public int hashCode() {
return Objects.hash(lat, lng);
}

@Override
public Location clone() {
try {
return (Location) super.clone();
} catch (CloneNotSupportedException e) {
logger.fatal("Impossible: CloneNotSupported in " + getClass());

// impossible while Cloneable
return null;
}
}
}
21 changes: 8 additions & 13 deletions logic/src/main/java/ua/com/tracksee/dto/RouteDTO.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,24 @@

import com.vividsolutions.jts.geom.LineString;

import java.util.List;
import java.math.BigDecimal;

import static ua.com.tracksee.util.GeometryConverter.decodeGooglePolylineToLineString;
import static ua.com.tracksee.util.GeometryConverter.decodeGooglePolylineToLocations;
import static ua.com.tracksee.util.GeometryConverter.encodeToGooglePolyLine;

/**
* @author Ruslan Gunavardana
*/
public class RouteDTO {
private String encodedRoute;
private float distance;
private BigDecimal distance;
private int durationInMin;

public RouteDTO() {

}

public List<Location> getRouteLocations() {
return decodeGooglePolylineToLocations(encodedRoute);
}

public LineString getRouteLineString() {
return decodeGooglePolylineToLineString(encodedRoute);
public RouteDTO(LineString lineString, BigDecimal distance) {
this.encodedRoute = encodeToGooglePolyLine(lineString);
this.distance = distance;
}

public String getEncodedRoute() {
Expand All @@ -35,11 +30,11 @@ public void setEncodedRoute(String encodedRoute) {
this.encodedRoute = encodedRoute;
}

public float getDistance() {
public BigDecimal getDistance() {
return distance;
}

public void setDistance(float distance) {
public void setDistance(BigDecimal distance) {
this.distance = distance;
}

Expand Down
Loading

0 comments on commit caaab24

Please sign in to comment.