mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-04 11:23:50 +00:00
Changed Dates to TimePoints because of the protocol. Added
MessageFileService classes, which is usable with the MessageScriptService Interface to repository.
This commit is contained in:
1 parent
910667d061
commit
df42b55603
22 files changed
+1017
-42
No files matched your search
+44
@@ -53,4 +53,48 @@ public class ABSMessage {
|
||||
public String toString() {
|
||||
return "ABS|" + raceId + ";" + leg + ";" + sailNumber + ";" + speed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((leg == null) ? 0 : leg.hashCode());
|
||||
result = prime * result + ((raceId == null) ? 0 : raceId.hashCode());
|
||||
result = prime * result + ((sailNumber == null) ? 0 : sailNumber.hashCode());
|
||||
long temp;
|
||||
temp = Double.doubleToLongBits(speed);
|
||||
result = prime * result + (int) (temp ^ (temp >>> 32));
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
ABSMessage other = (ABSMessage) obj;
|
||||
if (leg == null) {
|
||||
if (other.leg != null)
|
||||
return false;
|
||||
} else if (!leg.equals(other.leg))
|
||||
return false;
|
||||
if (raceId == null) {
|
||||
if (other.raceId != null)
|
||||
return false;
|
||||
} else if (!raceId.equals(other.raceId))
|
||||
return false;
|
||||
if (sailNumber == null) {
|
||||
if (other.sailNumber != null)
|
||||
return false;
|
||||
} else if (!sailNumber.equals(other.sailNumber))
|
||||
return false;
|
||||
if (Double.doubleToLongBits(speed) != Double.doubleToLongBits(other.speed))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+33
-4
@@ -1,11 +1,7 @@
|
||||
package com.sap.sailing.domain.swisstimingadapter.classes.messages;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.sap.sailing.domain.swisstimingadapter.Mark;
|
||||
import com.sap.sailing.domain.swisstimingadapter.Race;
|
||||
|
||||
public class CAMMessage {
|
||||
private String raceId;
|
||||
private List<ClockAtMarkElement> markList;
|
||||
@@ -46,4 +42,37 @@ public class CAMMessage {
|
||||
return "CAM|" + markList.size() + s;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((markList == null) ? 0 : markList.hashCode());
|
||||
result = prime * result + ((raceId == null) ? 0 : raceId.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
CAMMessage other = (CAMMessage) obj;
|
||||
if (markList == null) {
|
||||
if (other.markList != null)
|
||||
return false;
|
||||
} else if (!markList.equals(other.markList))
|
||||
return false;
|
||||
if (raceId == null) {
|
||||
if (other.raceId != null)
|
||||
return false;
|
||||
} else if (!raceId.equals(other.raceId))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
+33
@@ -36,4 +36,37 @@ public class CBSMessage {
|
||||
public String toString() {
|
||||
return "CBS|" + raceId + ";" + sailNumber + ";" + speed;
|
||||
}
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + raceId;
|
||||
result = prime * result + ((sailNumber == null) ? 0 : sailNumber.hashCode());
|
||||
long temp;
|
||||
temp = Double.doubleToLongBits(speed);
|
||||
result = prime * result + (int) (temp ^ (temp >>> 32));
|
||||
return result;
|
||||
}
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
CBSMessage other = (CBSMessage) obj;
|
||||
if (raceId != other.raceId)
|
||||
return false;
|
||||
if (sailNumber == null) {
|
||||
if (other.sailNumber != null)
|
||||
return false;
|
||||
} else if (!sailNumber.equals(other.sailNumber))
|
||||
return false;
|
||||
if (Double.doubleToLongBits(speed) != Double.doubleToLongBits(other.speed))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+30
-1
@@ -4,7 +4,6 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.sap.sailing.domain.swisstimingadapter.Mark;
|
||||
import com.sap.sailing.domain.swisstimingadapter.Race;
|
||||
|
||||
public class CCGMessage {
|
||||
private String raceId;
|
||||
@@ -44,4 +43,34 @@ public class CCGMessage {
|
||||
s = s.substring(0, s.length()-2);
|
||||
return "CCG|" + markList.size() + s;
|
||||
}
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((markList == null) ? 0 : markList.hashCode());
|
||||
result = prime * result + ((raceId == null) ? 0 : raceId.hashCode());
|
||||
return result;
|
||||
}
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
CCGMessage other = (CCGMessage) obj;
|
||||
if (markList == null) {
|
||||
if (other.markList != null)
|
||||
return false;
|
||||
} else if (!markList.equals(other.markList))
|
||||
return false;
|
||||
if (raceId == null) {
|
||||
if (other.raceId != null)
|
||||
return false;
|
||||
} else if (!raceId.equals(other.raceId))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
+42
-5
@@ -1,14 +1,15 @@
|
||||
package com.sap.sailing.domain.swisstimingadapter.classes.messages;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
import com.sap.sailing.domain.base.TimePoint;
|
||||
|
||||
public class ClockAtMarkElement {
|
||||
private int markindex;
|
||||
private Date marktime;
|
||||
private TimePoint marktime;
|
||||
private String sailnumber;
|
||||
|
||||
public ClockAtMarkElement(int markindex, Date marktime, String sailnumber) {
|
||||
public ClockAtMarkElement(int markindex, TimePoint marktime, String sailnumber) {
|
||||
super();
|
||||
this.markindex = markindex;
|
||||
this.marktime = marktime;
|
||||
@@ -27,11 +28,11 @@ public class ClockAtMarkElement {
|
||||
this.markindex = markindex;
|
||||
}
|
||||
|
||||
public Date getMarktime() {
|
||||
public TimePoint getMarktime() {
|
||||
return marktime;
|
||||
}
|
||||
|
||||
public void setMarktime(Date marktime) {
|
||||
public void setMarktime(TimePoint marktime) {
|
||||
this.marktime = marktime;
|
||||
}
|
||||
|
||||
@@ -48,4 +49,40 @@ public class ClockAtMarkElement {
|
||||
return "|" + markindex + ";" + sd.format(marktime) + ";" + sailnumber;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + markindex;
|
||||
result = prime * result + ((marktime == null) ? 0 : marktime.hashCode());
|
||||
result = prime * result + ((sailnumber == null) ? 0 : sailnumber.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
ClockAtMarkElement other = (ClockAtMarkElement) obj;
|
||||
if (markindex != other.markindex)
|
||||
return false;
|
||||
if (marktime == null) {
|
||||
if (other.marktime != null)
|
||||
return false;
|
||||
} else if (!marktime.equals(other.marktime))
|
||||
return false;
|
||||
if (sailnumber == null) {
|
||||
if (other.sailnumber != null)
|
||||
return false;
|
||||
} else if (!sailnumber.equals(other.sailnumber))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
+42
@@ -44,4 +44,46 @@ public class DBBMessage {
|
||||
public String toString() {
|
||||
return "DBB|" + raceId + ";" + sailNumber + ";" + sailNumber2;
|
||||
}
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
long temp;
|
||||
temp = Double.doubleToLongBits(distance);
|
||||
result = prime * result + (int) (temp ^ (temp >>> 32));
|
||||
result = prime * result + ((raceId == null) ? 0 : raceId.hashCode());
|
||||
result = prime * result + ((sailNumber == null) ? 0 : sailNumber.hashCode());
|
||||
result = prime * result + ((sailNumber2 == null) ? 0 : sailNumber2.hashCode());
|
||||
return result;
|
||||
}
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
DBBMessage other = (DBBMessage) obj;
|
||||
if (Double.doubleToLongBits(distance) != Double.doubleToLongBits(other.distance))
|
||||
return false;
|
||||
if (raceId == null) {
|
||||
if (other.raceId != null)
|
||||
return false;
|
||||
} else if (!raceId.equals(other.raceId))
|
||||
return false;
|
||||
if (sailNumber == null) {
|
||||
if (other.sailNumber != null)
|
||||
return false;
|
||||
} else if (!sailNumber.equals(other.sailNumber))
|
||||
return false;
|
||||
if (sailNumber2 == null) {
|
||||
if (other.sailNumber2 != null)
|
||||
return false;
|
||||
} else if (!sailNumber2.equals(other.sailNumber2))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+41
@@ -55,4 +55,45 @@ public class DTMMessage {
|
||||
return "DTM|" + raceId + ";" + markIndex + ";" + sailNumber;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
long temp;
|
||||
temp = Double.doubleToLongBits(distance);
|
||||
result = prime * result + (int) (temp ^ (temp >>> 32));
|
||||
result = prime * result + markIndex;
|
||||
result = prime * result + ((raceId == null) ? 0 : raceId.hashCode());
|
||||
result = prime * result + ((sailNumber == null) ? 0 : sailNumber.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
DTMMessage other = (DTMMessage) obj;
|
||||
if (Double.doubleToLongBits(distance) != Double.doubleToLongBits(other.distance))
|
||||
return false;
|
||||
if (markIndex != other.markIndex)
|
||||
return false;
|
||||
if (raceId == null) {
|
||||
if (other.raceId != null)
|
||||
return false;
|
||||
} else if (!raceId.equals(other.raceId))
|
||||
return false;
|
||||
if (sailNumber == null) {
|
||||
if (other.sailNumber != null)
|
||||
return false;
|
||||
} else if (!sailNumber.equals(other.sailNumber))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
+26
@@ -33,5 +33,31 @@ public class RACMessage {
|
||||
}
|
||||
return "RAC|" + raceList.size() + s;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((raceList == null) ? 0 : raceList.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
RACMessage other = (RACMessage) obj;
|
||||
if (raceList == null) {
|
||||
if (other.raceList != null)
|
||||
return false;
|
||||
} else if (!raceList.equals(other.raceList))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+70
-16
@@ -5,18 +5,22 @@ import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import com.sap.sailing.domain.base.TimePoint;
|
||||
|
||||
public class RPDMessage {
|
||||
private String raceId;
|
||||
private int status;
|
||||
private Date dataTime;
|
||||
private Date startTime;
|
||||
private TimePoint dataTime;
|
||||
private TimePoint startTime;
|
||||
private Date raceTime;
|
||||
private int nextMarkLeader;
|
||||
private double distanceToNextMarkLeader;
|
||||
private List<RacePositionDataElement> racePositionElements;
|
||||
|
||||
public RPDMessage(String raceId, int status, Date dataTime, Date startTime, Date raceTime, int nextMarkLeader,
|
||||
double distanceToNextMarkLeader, List<RacePositionDataElement> racePositionElements) {
|
||||
|
||||
|
||||
public RPDMessage(String raceId, int status, TimePoint dataTime, TimePoint startTime, Date raceTime,
|
||||
int nextMarkLeader, double distanceToNextMarkLeader, List<RacePositionDataElement> racePositionElements) {
|
||||
super();
|
||||
this.raceId = raceId;
|
||||
this.status = status;
|
||||
@@ -42,18 +46,6 @@ public class RPDMessage {
|
||||
public void setStatus(int status) {
|
||||
this.status = status;
|
||||
}
|
||||
public Date getDataTime() {
|
||||
return dataTime;
|
||||
}
|
||||
public void setDataTime(Date dataTime) {
|
||||
this.dataTime = dataTime;
|
||||
}
|
||||
public Date getStartTime() {
|
||||
return startTime;
|
||||
}
|
||||
public void setStartTime(Date startTime) {
|
||||
this.startTime = startTime;
|
||||
}
|
||||
public Date getRaceTime() {
|
||||
return raceTime;
|
||||
}
|
||||
@@ -79,6 +71,19 @@ public class RPDMessage {
|
||||
this.racePositionElements = racePositionElements;
|
||||
}
|
||||
|
||||
|
||||
public TimePoint getDataTime() {
|
||||
return dataTime;
|
||||
}
|
||||
public void setDataTime(TimePoint dataTime) {
|
||||
this.dataTime = dataTime;
|
||||
}
|
||||
public TimePoint getStartTime() {
|
||||
return startTime;
|
||||
}
|
||||
public void setStartTime(TimePoint startTime) {
|
||||
this.startTime = startTime;
|
||||
}
|
||||
public String toString(){
|
||||
SimpleDateFormat sdataTime = new SimpleDateFormat("yyyy.MM.dd");
|
||||
SimpleDateFormat sstartTime = new SimpleDateFormat("yyyy.MM.dd");
|
||||
@@ -91,5 +96,54 @@ public class RPDMessage {
|
||||
|
||||
return "RPD|" + raceId + "|" + status + "|" + sdataTime.format(dataTime) + "|" + sstartTime.format(startTime) + "|" + sraceTime.format(raceTime) + "|" + racePositionElements.size() + elements;
|
||||
}
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
long temp;
|
||||
temp = Double.doubleToLongBits(distanceToNextMarkLeader);
|
||||
result = prime * result + (int) (temp ^ (temp >>> 32));
|
||||
result = prime * result + nextMarkLeader;
|
||||
result = prime * result + ((raceId == null) ? 0 : raceId.hashCode());
|
||||
result = prime * result + ((racePositionElements == null) ? 0 : racePositionElements.hashCode());
|
||||
result = prime * result + ((raceTime == null) ? 0 : raceTime.hashCode());
|
||||
result = prime * result + status;
|
||||
return result;
|
||||
}
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
RPDMessage other = (RPDMessage) obj;
|
||||
if (Double.doubleToLongBits(distanceToNextMarkLeader) != Double
|
||||
.doubleToLongBits(other.distanceToNextMarkLeader))
|
||||
return false;
|
||||
if (nextMarkLeader != other.nextMarkLeader)
|
||||
return false;
|
||||
if (raceId == null) {
|
||||
if (other.raceId != null)
|
||||
return false;
|
||||
} else if (!raceId.equals(other.raceId))
|
||||
return false;
|
||||
if (racePositionElements == null) {
|
||||
if (other.racePositionElements != null)
|
||||
return false;
|
||||
} else if (!racePositionElements.equals(other.racePositionElements))
|
||||
return false;
|
||||
if (raceTime == null) {
|
||||
if (other.raceTime != null)
|
||||
return false;
|
||||
} else if (!raceTime.equals(other.raceTime))
|
||||
return false;
|
||||
if (status != other.status)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
+79
-6
@@ -10,7 +10,7 @@ public class RacePositionDataElement {
|
||||
private double vmg;
|
||||
private double als;
|
||||
private double cog;
|
||||
private String nextMark;
|
||||
private int nextMark;
|
||||
private int rank;
|
||||
private double distanceToLeader;
|
||||
private double distanceToNextMark;
|
||||
@@ -18,7 +18,7 @@ public class RacePositionDataElement {
|
||||
|
||||
|
||||
public RacePositionDataElement(String sailNumber, int boatType, long ageOfData, double latitude, double longitude,
|
||||
double sog, double vmg, double als, double cog, String nextMark, int rank, double distanceToLeader,
|
||||
double sog, double vmg, double als, double cog, int nextMarkIndex, int rank, double distanceToLeader,
|
||||
double distanceToNextMark) {
|
||||
super();
|
||||
this.sailNumber = sailNumber;
|
||||
@@ -30,7 +30,7 @@ public class RacePositionDataElement {
|
||||
this.vmg = vmg;
|
||||
this.als = als;
|
||||
this.cog = cog;
|
||||
this.nextMark = nextMark;
|
||||
this.nextMark = nextMarkIndex;
|
||||
this.rank = rank;
|
||||
this.distanceToLeader = distanceToLeader;
|
||||
this.distanceToNextMark = distanceToNextMark;
|
||||
@@ -39,7 +39,7 @@ public class RacePositionDataElement {
|
||||
public RacePositionDataElement() {
|
||||
super();
|
||||
}
|
||||
|
||||
|
||||
public String getSailNumber() {
|
||||
return sailNumber;
|
||||
}
|
||||
@@ -137,15 +137,88 @@ public class RacePositionDataElement {
|
||||
}
|
||||
|
||||
|
||||
public String getNextMark() {
|
||||
|
||||
public int getNextMark() {
|
||||
return nextMark;
|
||||
}
|
||||
|
||||
public void setNextMark(String nextMark) {
|
||||
public void setNextMark(int nextMark) {
|
||||
this.nextMark = nextMark;
|
||||
}
|
||||
|
||||
public String toString(){
|
||||
return "|" + sailNumber + ";" + boatType + ";" + ageOfData + ";" + latitude + ";" + longitude + ";" + sog + ";" + vmg + ";" + als + ";" + cog + ";" +nextMark + ";" + rank + ";" + distanceToLeader + ";" + distanceToNextMark;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + (int) (ageOfData ^ (ageOfData >>> 32));
|
||||
long temp;
|
||||
temp = Double.doubleToLongBits(als);
|
||||
result = prime * result + (int) (temp ^ (temp >>> 32));
|
||||
result = prime * result + boatType;
|
||||
temp = Double.doubleToLongBits(cog);
|
||||
result = prime * result + (int) (temp ^ (temp >>> 32));
|
||||
temp = Double.doubleToLongBits(distanceToLeader);
|
||||
result = prime * result + (int) (temp ^ (temp >>> 32));
|
||||
temp = Double.doubleToLongBits(distanceToNextMark);
|
||||
result = prime * result + (int) (temp ^ (temp >>> 32));
|
||||
temp = Double.doubleToLongBits(latitude);
|
||||
result = prime * result + (int) (temp ^ (temp >>> 32));
|
||||
temp = Double.doubleToLongBits(longitude);
|
||||
result = prime * result + (int) (temp ^ (temp >>> 32));
|
||||
result = prime * result + nextMark;
|
||||
result = prime * result + rank;
|
||||
result = prime * result + ((sailNumber == null) ? 0 : sailNumber.hashCode());
|
||||
temp = Double.doubleToLongBits(sog);
|
||||
result = prime * result + (int) (temp ^ (temp >>> 32));
|
||||
temp = Double.doubleToLongBits(vmg);
|
||||
result = prime * result + (int) (temp ^ (temp >>> 32));
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
RacePositionDataElement other = (RacePositionDataElement) obj;
|
||||
if (ageOfData != other.ageOfData)
|
||||
return false;
|
||||
if (Double.doubleToLongBits(als) != Double.doubleToLongBits(other.als))
|
||||
return false;
|
||||
if (boatType != other.boatType)
|
||||
return false;
|
||||
if (Double.doubleToLongBits(cog) != Double.doubleToLongBits(other.cog))
|
||||
return false;
|
||||
if (Double.doubleToLongBits(distanceToLeader) != Double.doubleToLongBits(other.distanceToLeader))
|
||||
return false;
|
||||
if (Double.doubleToLongBits(distanceToNextMark) != Double.doubleToLongBits(other.distanceToNextMark))
|
||||
return false;
|
||||
if (Double.doubleToLongBits(latitude) != Double.doubleToLongBits(other.latitude))
|
||||
return false;
|
||||
if (Double.doubleToLongBits(longitude) != Double.doubleToLongBits(other.longitude))
|
||||
return false;
|
||||
if (nextMark != other.nextMark)
|
||||
return false;
|
||||
if (rank != other.rank)
|
||||
return false;
|
||||
if (sailNumber == null) {
|
||||
if (other.sailNumber != null)
|
||||
return false;
|
||||
} else if (!sailNumber.equals(other.sailNumber))
|
||||
return false;
|
||||
if (Double.doubleToLongBits(sog) != Double.doubleToLongBits(other.sog))
|
||||
return false;
|
||||
if (Double.doubleToLongBits(vmg) != Double.doubleToLongBits(other.vmg))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+30
-1
@@ -4,7 +4,6 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.sap.sailing.domain.swisstimingadapter.Competitor;
|
||||
import com.sap.sailing.domain.swisstimingadapter.Race;
|
||||
|
||||
public class STLMessage {
|
||||
private String raceId;
|
||||
@@ -39,4 +38,34 @@ public class STLMessage {
|
||||
}
|
||||
return "STL|" + competitorList.size() + s;
|
||||
}
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((competitorList == null) ? 0 : competitorList.hashCode());
|
||||
result = prime * result + ((raceId == null) ? 0 : raceId.hashCode());
|
||||
return result;
|
||||
}
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
STLMessage other = (STLMessage) obj;
|
||||
if (competitorList == null) {
|
||||
if (other.competitorList != null)
|
||||
return false;
|
||||
} else if (!competitorList.equals(other.competitorList))
|
||||
return false;
|
||||
if (raceId == null) {
|
||||
if (other.raceId != null)
|
||||
return false;
|
||||
} else if (!raceId.equals(other.raceId))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
+31
@@ -33,4 +33,35 @@ public class STTMessage {
|
||||
SimpleDateFormat sd = new SimpleDateFormat("yyyy.MM.dd");
|
||||
return "STT|" + raceId + sd.format(startTime);
|
||||
}
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((raceId == null) ? 0 : raceId.hashCode());
|
||||
result = prime * result + ((startTime == null) ? 0 : startTime.hashCode());
|
||||
return result;
|
||||
}
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
STTMessage other = (STTMessage) obj;
|
||||
if (raceId == null) {
|
||||
if (other.raceId != null)
|
||||
return false;
|
||||
} else if (!raceId.equals(other.raceId))
|
||||
return false;
|
||||
if (startTime == null) {
|
||||
if (other.startTime != null)
|
||||
return false;
|
||||
} else if (!startTime.equals(other.startTime))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+39
-2
@@ -3,8 +3,6 @@ package com.sap.sailing.domain.swisstimingadapter.classes.messages;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.sap.sailing.domain.swisstimingadapter.Race;
|
||||
|
||||
public class TMDMessage {
|
||||
private String raceId;
|
||||
private String sailNumber;
|
||||
@@ -55,4 +53,43 @@ public class TMDMessage {
|
||||
return "TMD|" + list.size() + s;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((list == null) ? 0 : list.hashCode());
|
||||
result = prime * result + ((raceId == null) ? 0 : raceId.hashCode());
|
||||
result = prime * result + ((sailNumber == null) ? 0 : sailNumber.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
TMDMessage other = (TMDMessage) obj;
|
||||
if (list == null) {
|
||||
if (other.list != null)
|
||||
return false;
|
||||
} else if (!list.equals(other.list))
|
||||
return false;
|
||||
if (raceId == null) {
|
||||
if (other.raceId != null)
|
||||
return false;
|
||||
} else if (!raceId.equals(other.raceId))
|
||||
return false;
|
||||
if (sailNumber == null) {
|
||||
if (other.sailNumber != null)
|
||||
return false;
|
||||
} else if (!sailNumber.equals(other.sailNumber))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
+40
-5
@@ -1,14 +1,15 @@
|
||||
package com.sap.sailing.domain.swisstimingadapter.classes.messages;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
import com.sap.sailing.domain.base.TimePoint;
|
||||
|
||||
public class TimingDataElement {
|
||||
private int markIndex;
|
||||
private int rank;
|
||||
private Date timeSinceStart;
|
||||
private TimePoint timeSinceStart;
|
||||
|
||||
public TimingDataElement(int markIndex, int rank, Date timeSinceStart) {
|
||||
public TimingDataElement(int markIndex, int rank, TimePoint timeSinceStart) {
|
||||
super();
|
||||
this.markIndex = markIndex;
|
||||
this.rank = rank;
|
||||
@@ -19,6 +20,7 @@ public class TimingDataElement {
|
||||
super();
|
||||
}
|
||||
|
||||
|
||||
public int getMarkIndex() {
|
||||
return markIndex;
|
||||
}
|
||||
@@ -35,11 +37,11 @@ public class TimingDataElement {
|
||||
this.rank = rank;
|
||||
}
|
||||
|
||||
public Date getTimeSinceStart() {
|
||||
public TimePoint getTimeSinceStart() {
|
||||
return timeSinceStart;
|
||||
}
|
||||
|
||||
public void setTimeSinceStart(Date timeSinceStart) {
|
||||
public void setTimeSinceStart(TimePoint timeSinceStart) {
|
||||
this.timeSinceStart = timeSinceStart;
|
||||
}
|
||||
|
||||
@@ -48,4 +50,37 @@ public class TimingDataElement {
|
||||
SimpleDateFormat sd = new SimpleDateFormat("yyyy.MM.dd");
|
||||
return "|" + markIndex + ";" + rank + ";" + sd.format(timeSinceStart);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + markIndex;
|
||||
result = prime * result + rank;
|
||||
result = prime * result + ((timeSinceStart == null) ? 0 : timeSinceStart.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
TimingDataElement other = (TimingDataElement) obj;
|
||||
if (markIndex != other.markIndex)
|
||||
return false;
|
||||
if (rank != other.rank)
|
||||
return false;
|
||||
if (timeSinceStart == null) {
|
||||
if (other.timeSinceStart != null)
|
||||
return false;
|
||||
} else if (!timeSinceStart.equals(other.timeSinceStart))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+26
@@ -23,4 +23,30 @@ public class VERMessage {
|
||||
public String toString(){
|
||||
return "VER|" + version;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((version == null) ? 0 : version.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
VERMessage other = (VERMessage) obj;
|
||||
if (version == null) {
|
||||
if (other.version != null)
|
||||
return false;
|
||||
} else if (!version.equals(other.version))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
+43
@@ -43,4 +43,47 @@ public class WEAMessage {
|
||||
public String toString(){
|
||||
return "WEA|" + raceId + ";" + conditions + ";" + temperature + ";" +humidity;
|
||||
}
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((conditions == null) ? 0 : conditions.hashCode());
|
||||
result = prime * result + ((humidity == null) ? 0 : humidity.hashCode());
|
||||
result = prime * result + ((raceId == null) ? 0 : raceId.hashCode());
|
||||
result = prime * result + ((temperature == null) ? 0 : temperature.hashCode());
|
||||
return result;
|
||||
}
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
WEAMessage other = (WEAMessage) obj;
|
||||
if (conditions == null) {
|
||||
if (other.conditions != null)
|
||||
return false;
|
||||
} else if (!conditions.equals(other.conditions))
|
||||
return false;
|
||||
if (humidity == null) {
|
||||
if (other.humidity != null)
|
||||
return false;
|
||||
} else if (!humidity.equals(other.humidity))
|
||||
return false;
|
||||
if (raceId == null) {
|
||||
if (other.raceId != null)
|
||||
return false;
|
||||
} else if (!raceId.equals(other.raceId))
|
||||
return false;
|
||||
if (temperature == null) {
|
||||
if (other.temperature != null)
|
||||
return false;
|
||||
} else if (!temperature.equals(other.temperature))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+39
@@ -53,4 +53,43 @@ public class WNDMessage {
|
||||
public String toString(){
|
||||
return "WND|" + raceId + ";" + markIndex + ";" + windDirection+ ";" +windSpeed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + markIndex;
|
||||
result = prime * result + ((raceId == null) ? 0 : raceId.hashCode());
|
||||
long temp;
|
||||
temp = Double.doubleToLongBits(windDirection);
|
||||
result = prime * result + (int) (temp ^ (temp >>> 32));
|
||||
temp = Double.doubleToLongBits(windSpeed);
|
||||
result = prime * result + (int) (temp ^ (temp >>> 32));
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
WNDMessage other = (WNDMessage) obj;
|
||||
if (markIndex != other.markIndex)
|
||||
return false;
|
||||
if (raceId == null) {
|
||||
if (other.raceId != null)
|
||||
return false;
|
||||
} else if (!raceId.equals(other.raceId))
|
||||
return false;
|
||||
if (Double.doubleToLongBits(windDirection) != Double.doubleToLongBits(other.windDirection))
|
||||
return false;
|
||||
if (Double.doubleToLongBits(windSpeed) != Double.doubleToLongBits(other.windSpeed))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
package com.sap.sailing.domain.swisstimingadapter.classes.services.Exceptions;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class MessageScriptParsingException extends Exception {
|
||||
|
||||
/**
|
||||
*???
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private File file;
|
||||
private String line;
|
||||
|
||||
public MessageScriptParsingException(String line, File file) {
|
||||
super("Parsing Exception while parsing a line from MessageScript");
|
||||
this.file = file;
|
||||
this.line = line;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "MessageScriptParsingException [file=" + file + ", line=" + line + ", toString()=" + super.toString()
|
||||
+ "]";
|
||||
}
|
||||
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
package com.sap.sailing.domain.swisstimingadapter.classes.services;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.sap.sailing.domain.swisstimingadapter.classes.services.Exceptions.MessageScriptParsingException;
|
||||
|
||||
public interface MessageFileService {
|
||||
void writeListToFile(String path, List<Object> msgList) throws IOException;
|
||||
List<Object> readListFromFile(String path) throws MessageScriptParsingException, IOException, ParseException;
|
||||
}
|
||||
+280
@@ -0,0 +1,280 @@
|
||||
package com.sap.sailing.domain.swisstimingadapter.classes.services;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.text.DateFormat;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import com.sap.sailing.domain.base.Distance;
|
||||
import com.sap.sailing.domain.base.Speed;
|
||||
import com.sap.sailing.domain.base.SpeedWithBearing;
|
||||
import com.sap.sailing.domain.base.TimePoint;
|
||||
import com.sap.sailing.domain.base.impl.DegreeBearingImpl;
|
||||
import com.sap.sailing.domain.base.impl.KnotSpeedImpl;
|
||||
import com.sap.sailing.domain.base.impl.KnotSpeedWithBearingImpl;
|
||||
import com.sap.sailing.domain.base.impl.MeterDistance;
|
||||
import com.sap.sailing.domain.base.impl.MillisecondsTimePoint;
|
||||
import com.sap.sailing.domain.swisstimingadapter.Competitor;
|
||||
import com.sap.sailing.domain.swisstimingadapter.Mark;
|
||||
import com.sap.sailing.domain.swisstimingadapter.Race;
|
||||
import com.sap.sailing.domain.swisstimingadapter.SailMasterMessage;
|
||||
import com.sap.sailing.domain.swisstimingadapter.classes.messages.CAMMessage;
|
||||
import com.sap.sailing.domain.swisstimingadapter.classes.messages.CCGMessage;
|
||||
import com.sap.sailing.domain.swisstimingadapter.classes.messages.ClockAtMarkElement;
|
||||
import com.sap.sailing.domain.swisstimingadapter.classes.messages.RACMessage;
|
||||
import com.sap.sailing.domain.swisstimingadapter.classes.messages.RPDMessage;
|
||||
import com.sap.sailing.domain.swisstimingadapter.classes.messages.RacePositionDataElement;
|
||||
import com.sap.sailing.domain.swisstimingadapter.classes.messages.STLMessage;
|
||||
import com.sap.sailing.domain.swisstimingadapter.classes.messages.TMDMessage;
|
||||
import com.sap.sailing.domain.swisstimingadapter.classes.messages.TimingDataElement;
|
||||
import com.sap.sailing.domain.swisstimingadapter.classes.services.Exceptions.MessageScriptParsingException;
|
||||
|
||||
import com.sap.sailing.domain.swisstimingadapter.impl.CompetitorImpl;
|
||||
import com.sap.sailing.domain.swisstimingadapter.impl.MarkImpl;
|
||||
import com.sap.sailing.domain.swisstimingadapter.impl.RaceImpl;
|
||||
import com.sap.sailing.domain.swisstimingadapter.impl.SailMasterMessageImpl;
|
||||
|
||||
public class MessageFileServiceImpl implements MessageFileService {
|
||||
|
||||
private File file;
|
||||
private BufferedWriter writer;
|
||||
private BufferedReader reader;
|
||||
private String lastTimeZoneSuffix;
|
||||
private final DateFormat dateFormat;
|
||||
|
||||
public MessageFileServiceImpl() {
|
||||
dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ssZ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeListToFile(String path, List<Object> msgList) throws IOException {
|
||||
file = new File(path);
|
||||
writer = new BufferedWriter(new FileWriter(path));
|
||||
String tmp = "";
|
||||
for (Object object : msgList) {
|
||||
tmp = tmp + object.toString() + "\n";
|
||||
}
|
||||
System.out.println(tmp);
|
||||
writer.write(tmp);
|
||||
writer.flush();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Object> readListFromFile(String path) throws MessageScriptParsingException, IOException, ParseException {
|
||||
file = new File(path);
|
||||
List<Object> resultList = new ArrayList<Object>();
|
||||
|
||||
reader = new BufferedReader(new FileReader(path));
|
||||
List<String> strList = getFileIntoArrayListString(reader);
|
||||
List<SailMasterMessage> sailMasterMessageList = getSailMasterMessageList(strList);
|
||||
|
||||
// Iterate throug sailmastermessagelist
|
||||
for (SailMasterMessage sailMasterMessage : sailMasterMessageList) {
|
||||
// Switch Case for all kinds of actions, just used
|
||||
switch (sailMasterMessage.getType()) {
|
||||
case RPD:
|
||||
resultList.add(getRPDMessage(sailMasterMessage));
|
||||
break;
|
||||
case RAC:
|
||||
resultList.add(getRACMessage(sailMasterMessage));
|
||||
break;
|
||||
case CCG:
|
||||
resultList.add(getCCGMessage(sailMasterMessage));
|
||||
break;
|
||||
case STL:
|
||||
resultList.add(getSTLMessage(sailMasterMessage));
|
||||
break;
|
||||
case CAM:
|
||||
resultList.add(getCAMMessage(sailMasterMessage));
|
||||
break;
|
||||
case TMD:
|
||||
resultList.add(getTMDMessage(sailMasterMessage));
|
||||
break;
|
||||
default:
|
||||
throw new MessageScriptParsingException(sailMasterMessage.getMessage(), file);
|
||||
}
|
||||
}
|
||||
return resultList;
|
||||
}
|
||||
|
||||
private RPDMessage getRPDMessage(SailMasterMessage message) throws ParseException {
|
||||
String[] sections = message.getSections();
|
||||
|
||||
String raceID = sections[1];
|
||||
int status = Integer.valueOf(sections[2]);
|
||||
TimePoint timePoint = new MillisecondsTimePoint(parseTimeAndDateISO(sections[3]));
|
||||
TimePoint startTimeEstimatedStartTime = sections[4].trim().length() == 0 ? null : new MillisecondsTimePoint(
|
||||
parseTimePrefixedWithISOToday(sections[4]));
|
||||
Long millisecondsSinceRaceStart = sections[5].trim().length() == 0 ? null
|
||||
: parseHHMMSSToMilliseconds(sections[5]);
|
||||
Integer nextMarkIndexForLeader = sections[6].trim().length() == 0 ? null : Integer.valueOf(sections[6]);
|
||||
Distance distanceToNextMarkForLeader = sections[7].trim().length() == 0 ? null : new MeterDistance(
|
||||
Double.valueOf(sections[7]));
|
||||
int count = Integer.valueOf(sections[8]);
|
||||
|
||||
List<RacePositionDataElement> racePositionElements = new ArrayList<RacePositionDataElement>();
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
int fixDetailIndex = 0;
|
||||
String[] fixSections = sections[9 + i].split(";");
|
||||
if (fixSections.length > 2) {
|
||||
String boatID = fixSections[fixDetailIndex++];
|
||||
int trackerTypeInt = Integer.valueOf(fixSections[fixDetailIndex++]);
|
||||
Long ageOfDataInMilliseconds = 1000l * Long.valueOf(fixSections[fixDetailIndex++]);
|
||||
double longitude = Double.valueOf(fixSections[fixDetailIndex++]);
|
||||
double latitude = Double.valueOf(fixSections[fixDetailIndex++]);
|
||||
Double speedOverGroundInKnots = Double.valueOf(fixSections[fixDetailIndex++]);
|
||||
Speed averageSpeedOverGround = fixSections[fixDetailIndex].trim().length() == 0 ? null
|
||||
: new KnotSpeedImpl(Double.valueOf(fixSections[fixDetailIndex]));
|
||||
fixDetailIndex++;
|
||||
Speed velocityMadeGood = fixSections[fixDetailIndex].trim().length() == 0 ? null : new KnotSpeedImpl(
|
||||
Double.valueOf(fixSections[fixDetailIndex]));
|
||||
fixDetailIndex++;
|
||||
SpeedWithBearing speed = new KnotSpeedWithBearingImpl(speedOverGroundInKnots, new DegreeBearingImpl(
|
||||
Double.valueOf(fixSections[fixDetailIndex++])));
|
||||
|
||||
Integer nextMarkIndex = fixSections.length <= fixDetailIndex
|
||||
|| fixSections[fixDetailIndex].trim().length() == 0 ? null : Integer
|
||||
.valueOf(fixSections[fixDetailIndex]);
|
||||
fixDetailIndex++;
|
||||
Integer rank = fixSections.length <= fixDetailIndex || fixSections[fixDetailIndex].trim().length() == 0 ? null
|
||||
: Integer.valueOf(fixSections[fixDetailIndex]);
|
||||
fixDetailIndex++;
|
||||
Distance distanceToLeader = fixSections.length <= fixDetailIndex
|
||||
|| fixSections[fixDetailIndex].trim().length() == 0 ? null : new MeterDistance(
|
||||
Double.valueOf(fixSections[fixDetailIndex]));
|
||||
fixDetailIndex++;
|
||||
Distance distanceToNextMark = fixSections.length <= fixDetailIndex
|
||||
|| fixSections[fixDetailIndex].trim().length() == 0 ? null : new MeterDistance(
|
||||
Double.valueOf(fixSections[fixDetailIndex]));
|
||||
fixDetailIndex++;
|
||||
|
||||
racePositionElements.add(new RacePositionDataElement(boatID, trackerTypeInt, ageOfDataInMilliseconds.longValue(), latitude, longitude, speedOverGroundInKnots.doubleValue(), velocityMadeGood.getKnots(), speed.getKnots(), speed.getBearing().getDegrees(), nextMarkIndex.intValue(), rank.intValue(), distanceToLeader.getMeters(), distanceToNextMark.getMeters()));
|
||||
}
|
||||
}
|
||||
return new RPDMessage(raceID, status, timePoint, startTimeEstimatedStartTime, new Date(millisecondsSinceRaceStart), nextMarkIndexForLeader.intValue(), distanceToNextMarkForLeader.getMeters(), racePositionElements);
|
||||
}
|
||||
|
||||
private RACMessage getRACMessage(SailMasterMessage message) {
|
||||
int count = Integer.valueOf(message.getSections()[1]);
|
||||
List<Race> result = new ArrayList<Race>();
|
||||
for (int i=0; i<count; i++) {
|
||||
String[] idAndDescription = message.getSections()[2+i].split(";");
|
||||
result.add(new RaceImpl(idAndDescription[0], idAndDescription[1]));
|
||||
}
|
||||
return new RACMessage(result);
|
||||
}
|
||||
|
||||
private CCGMessage getCCGMessage(SailMasterMessage message) {
|
||||
String raceId = message.getSections()[1];
|
||||
int count = Integer.valueOf(message.getSections()[2]);
|
||||
List<Mark> marks = new ArrayList<Mark>();
|
||||
for (int i=0; i<count; i++) {
|
||||
String[] markDetails = message.getSections()[3+i].split(";");
|
||||
marks.add(new MarkImpl(markDetails[1], Integer.valueOf(markDetails[0]), Arrays.asList(markDetails).subList(2, markDetails.length)));
|
||||
}
|
||||
return new CCGMessage(raceId, marks);
|
||||
}
|
||||
|
||||
private STLMessage getSTLMessage(SailMasterMessage message) {
|
||||
String raceId = message.getSections()[1];
|
||||
ArrayList<Competitor> competitors = new ArrayList<Competitor>();
|
||||
int count = Integer.valueOf(message.getSections()[2]);
|
||||
for (int i=0; i<count; i++) {
|
||||
String[] competitorDetails = message.getSections()[3+i].split(";");
|
||||
competitors.add(new CompetitorImpl(competitorDetails[0], competitorDetails[1], competitorDetails[2]));
|
||||
}
|
||||
return new STLMessage(raceId, competitors);
|
||||
}
|
||||
|
||||
private CAMMessage getCAMMessage(SailMasterMessage message) throws ParseException {
|
||||
String raceId = message.getSections()[1];
|
||||
List<ClockAtMarkElement> result = new ArrayList<ClockAtMarkElement>();
|
||||
int count = Integer.valueOf(message.getSections()[2]);
|
||||
for (int i=0; i<count; i++) {
|
||||
String[] clockAtMarkDetail = message.getSections()[3+i].split(";");
|
||||
int markIndex = Integer.valueOf(clockAtMarkDetail[0]);
|
||||
TimePoint timePoint = clockAtMarkDetail.length <= 1 || clockAtMarkDetail[1].trim().length() == 0 ? null :
|
||||
new MillisecondsTimePoint(parseTimePrefixedWithISOToday(clockAtMarkDetail[1]));
|
||||
result.add(new ClockAtMarkElement(markIndex, timePoint, clockAtMarkDetail.length <= 2 ? null : clockAtMarkDetail[2]));
|
||||
}
|
||||
return new CAMMessage(raceId, result);
|
||||
}
|
||||
|
||||
private TMDMessage getTMDMessage(SailMasterMessage message) throws ParseException {
|
||||
String raceID = message.getSections()[1];
|
||||
String boatID = message.getSections()[2];
|
||||
int count = Integer.valueOf(message.getSections()[3]);
|
||||
List<TimingDataElement> timingDataelementList = new ArrayList<TimingDataElement>();
|
||||
for (int i = 0; i < count; i++) {
|
||||
String[] details = message.getSections()[4+i].split(";");
|
||||
Integer markIndex = details.length <= 0 || details[0].trim().length() == 0 ? null : Integer.valueOf(details[0]);
|
||||
Integer rank = details.length <= 1 || details[1].trim().length() == 0 ? null : Integer.valueOf(details[1]);
|
||||
TimePoint timeSinceStart = details[4].trim().length() == 0 ? null : new MillisecondsTimePoint(
|
||||
parseTimePrefixedWithISOToday(details[4]));
|
||||
timingDataelementList.add(new TimingDataElement(markIndex, rank, timeSinceStart));
|
||||
}
|
||||
return new TMDMessage(raceID, boatID, timingDataelementList);
|
||||
}
|
||||
|
||||
private Date parseTimeAndDateISO(String timeAndDateISO) throws ParseException {
|
||||
char timeZoneIndicator = timeAndDateISO.charAt(timeAndDateISO.length()-6);
|
||||
if ((timeZoneIndicator == '+' || timeZoneIndicator == '-') && timeAndDateISO.charAt(timeAndDateISO.length()-3) == ':') {
|
||||
timeAndDateISO = timeAndDateISO.substring(0, timeAndDateISO.length()-3)+timeAndDateISO.substring(timeAndDateISO.length()-2);
|
||||
lastTimeZoneSuffix = timeAndDateISO.substring(timeAndDateISO.length()-5);
|
||||
}
|
||||
synchronized(dateFormat) {
|
||||
return dateFormat.parse(timeAndDateISO);
|
||||
}
|
||||
}
|
||||
|
||||
private Date parseTimePrefixedWithISOToday(String timeHHMMSS) throws ParseException {
|
||||
synchronized(dateFormat) {
|
||||
return dateFormat.parse(prefixTimeWithISOTodayAndSuffixWithTimezoneIndicator(timeHHMMSS));
|
||||
}
|
||||
}
|
||||
|
||||
private String prefixTimeWithISOTodayAndSuffixWithTimezoneIndicator(String time) {
|
||||
synchronized (dateFormat) {
|
||||
return dateFormat.format(new Date()).substring(0, "yyyy-mm-ddT".length())+time+lastTimeZoneSuffix;
|
||||
}
|
||||
}
|
||||
|
||||
private long parseHHMMSSToMilliseconds(String hhmmss) {
|
||||
String[] timeDetail = hhmmss.split(":");
|
||||
long millisecondsSinceStart = 1000 * (Long.valueOf(timeDetail[2]) + 60 * Long.valueOf(timeDetail[1]) + 3600 * Long
|
||||
.valueOf(timeDetail[0]));
|
||||
return millisecondsSinceStart;
|
||||
}
|
||||
|
||||
private List<SailMasterMessage> getSailMasterMessageList(List<String> strList) {
|
||||
// Add Strings of stringmessageList into a ArrayList of type SailMasterMessage
|
||||
List<SailMasterMessage> sailMasterMessageList = new ArrayList<SailMasterMessage>();
|
||||
for (String s : strList) {
|
||||
sailMasterMessageList.add(new SailMasterMessageImpl(s, new Long(0)));
|
||||
}
|
||||
return sailMasterMessageList;
|
||||
}
|
||||
|
||||
private List<String> getFileIntoArrayListString(BufferedReader reader) throws IOException {
|
||||
// List<Object> list = new ArrayList<Object>();
|
||||
List<String> strList = new ArrayList<String>();
|
||||
|
||||
// Read Lines into ArrayList
|
||||
String tmp = "";
|
||||
while ((tmp = reader.readLine()) != null) {
|
||||
strList.add(reader.readLine());
|
||||
}
|
||||
return strList;
|
||||
}
|
||||
|
||||
}
|
||||
+4
-1
@@ -1,8 +1,11 @@
|
||||
package com.sap.sailing.domain.swisstimingadapter.classes.services;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
import java.util.List;
|
||||
|
||||
import com.sap.sailing.domain.swisstimingadapter.classes.services.Exceptions.MessageScriptParsingException;
|
||||
|
||||
public interface MessageScriptService {
|
||||
void updateMessage(Object message);
|
||||
void createMessagePosition(int positoin, Object message);
|
||||
@@ -12,5 +15,5 @@ public interface MessageScriptService {
|
||||
Object getMessageId(int id);
|
||||
|
||||
void saveToFile(String path) throws IOException;
|
||||
void readFromFile(String path);
|
||||
void readFromFile(String path) throws IOException, ParseException, MessageScriptParsingException;
|
||||
}
|
||||
+4
-1
@@ -1,9 +1,12 @@
|
||||
package com.sap.sailing.domain.swisstimingadapter.classes.services;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.sap.sailing.domain.swisstimingadapter.classes.services.Exceptions.MessageScriptParsingException;
|
||||
|
||||
public class MessageScriptServiceImpl implements MessageScriptService{
|
||||
|
||||
private List<Object> messageList;
|
||||
@@ -60,7 +63,7 @@ public class MessageScriptServiceImpl implements MessageScriptService{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromFile(String path) {
|
||||
public void readFromFile(String path) throws IOException, ParseException, MessageScriptParsingException {
|
||||
fileService.readListFromFile(path);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user