mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-03 19:03:52 +00:00
Fixed bug parsing the color of a buoy from the name of a buoy for an TracTrac race.
This hack will anyway replaced later when the new metadata facility of TracTrac is ready to use
This commit is contained in:
1 parent
04f8548081
commit
ebb662c052
4 files changed
+42
-17
No files matched your search
+33
-3
@@ -139,12 +139,26 @@ public class DomainFactoryImpl implements DomainFactory {
|
||||
synchronized (controlPointCache) {
|
||||
com.sap.sailing.domain.base.ControlPoint domainControlPoint = controlPointCache.get(controlPoint);
|
||||
if (domainControlPoint == null) {
|
||||
String controlPointName = controlPoint.getName();
|
||||
Pair<String, String> parsedControlPoint = parseControlPointForColor(controlPointName);
|
||||
if(parsedControlPoint != null) {
|
||||
controlPointName = parsedControlPoint.getA();
|
||||
}
|
||||
if (controlPoint.getHasTwoPoints()) {
|
||||
// it's a gate
|
||||
domainControlPoint = baseDomainFactory.createGate(baseDomainFactory.getOrCreateBuoy(controlPoint.getName() + " (left)"),
|
||||
baseDomainFactory.getOrCreateBuoy(controlPoint.getName() + " (right)"), controlPoint.getName());
|
||||
Buoy leftBuoy = baseDomainFactory.getOrCreateBuoy(controlPointName + " (left)");
|
||||
Buoy rightBuoy = baseDomainFactory.getOrCreateBuoy(controlPointName + " (right)");
|
||||
domainControlPoint = baseDomainFactory.createGate(leftBuoy, rightBuoy, controlPointName);
|
||||
if(parsedControlPoint != null) {
|
||||
leftBuoy.setDisplayColor(parsedControlPoint.getB());
|
||||
rightBuoy.setDisplayColor(parsedControlPoint.getB());
|
||||
}
|
||||
} else {
|
||||
domainControlPoint = baseDomainFactory.getOrCreateBuoy(controlPoint.getName());
|
||||
Buoy buoy = baseDomainFactory.getOrCreateBuoy(controlPointName);
|
||||
if(parsedControlPoint != null) {
|
||||
buoy.setDisplayColor(parsedControlPoint.getB());
|
||||
}
|
||||
domainControlPoint = buoy;
|
||||
}
|
||||
controlPointCache.put(controlPoint, domainControlPoint);
|
||||
}
|
||||
@@ -152,6 +166,22 @@ public class DomainFactoryImpl implements DomainFactory {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: This is a special hack for the extreme sailing series event where we encoded the buoy color directly into the buoy name
|
||||
// this will be replaced later with the new 'metadata' facility of the TTCM
|
||||
private Pair<String, String> parseControlPointForColor(final String controlPointNameWithColor) {
|
||||
Pair<String, String> result = null;
|
||||
String parsedControlPointName = controlPointNameWithColor;
|
||||
|
||||
String colorTag = "_COLOR:";
|
||||
if(controlPointNameWithColor.contains(colorTag)) {
|
||||
int index = controlPointNameWithColor.indexOf(colorTag);
|
||||
String color = controlPointNameWithColor.substring(index + colorTag.length(), controlPointNameWithColor.length());
|
||||
parsedControlPointName = controlPointNameWithColor.substring(0, index);
|
||||
result = new Pair<String, String>(parsedControlPointName, color);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Course createCourse(String name, Iterable<ControlPoint> controlPoints) {
|
||||
List<Waypoint> waypointList = new ArrayList<Waypoint>();
|
||||
|
||||
@@ -10,4 +10,6 @@ package com.sap.sailing.domain.base;
|
||||
*/
|
||||
public interface Buoy extends WithID, ControlPoint, IsManagedByDomainFactory {
|
||||
public String getDisplayColor();
|
||||
|
||||
public void setDisplayColor(String displayColor);
|
||||
}
|
||||
@@ -43,4 +43,8 @@ public class BuoyImpl extends NamedImpl implements Buoy {
|
||||
public String getDisplayColor() {
|
||||
return displayColor;
|
||||
}
|
||||
|
||||
public void setDisplayColor(String displayColor) {
|
||||
this.displayColor = displayColor;
|
||||
}
|
||||
}
|
||||
+3
-14
@@ -110,21 +110,10 @@ public class DomainFactoryImpl implements DomainFactory {
|
||||
*/
|
||||
@Override
|
||||
public Buoy getOrCreateBuoy(String id) {
|
||||
String parsedId = id;
|
||||
String color = null;
|
||||
|
||||
// This is a special hack for the extreme sailing series event where we encoded the buoy color directly into the buoy name
|
||||
String colorTag = "_COLOR:";
|
||||
if(id.contains(colorTag)) {
|
||||
int index = id.indexOf(colorTag);
|
||||
color = id.substring(index + colorTag.length(), id.length());
|
||||
parsedId = id.substring(0, index);
|
||||
}
|
||||
|
||||
Buoy result = buoyCache.get(parsedId);
|
||||
Buoy result = buoyCache.get(id);
|
||||
if (result == null) {
|
||||
result = new BuoyImpl(parsedId, color);
|
||||
buoyCache.put(parsedId, result);
|
||||
result = new BuoyImpl(id);
|
||||
buoyCache.put(id, result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user