mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-11-13 22:15:26 +00:00
fixed updating of team object with new nationality when a competitor is updated; replaced getOrCreateTeam by createTeam; teams are not really re-used
This commit is contained in:
1 parent
16579217b7
commit
97a3fe6473
1 file changed
+9
-24
+9
-24
@@ -28,7 +28,6 @@ import com.sap.sailing.domain.base.ControlPoint;
|
||||
import com.sap.sailing.domain.base.Course;
|
||||
import com.sap.sailing.domain.base.Mark;
|
||||
import com.sap.sailing.domain.base.Nationality;
|
||||
import com.sap.sailing.domain.base.Person;
|
||||
import com.sap.sailing.domain.base.RaceDefinition;
|
||||
import com.sap.sailing.domain.base.Regatta;
|
||||
import com.sap.sailing.domain.base.Sideline;
|
||||
@@ -104,8 +103,6 @@ public class DomainFactoryImpl implements DomainFactory {
|
||||
|
||||
private final Map<com.sap.sse.common.Util.Pair<String, UUID>, DynamicPerson> personCache = new HashMap<>();
|
||||
|
||||
private final Map<Serializable, DynamicTeam> teamCache = new HashMap<>();
|
||||
|
||||
/**
|
||||
* Caches regattas by their name and their boat class's name
|
||||
*/
|
||||
@@ -261,7 +258,7 @@ public class DomainFactoryImpl implements DomainFactory {
|
||||
nationality = null;
|
||||
logger.log(Level.SEVERE, "Unknown nationality "+nationalityAsString+" for competitor "+name+"; leaving null", iae);
|
||||
}
|
||||
DynamicTeam team = getOrCreateTeam(name, nationality, competitorId);
|
||||
DynamicTeam team = createTeam(name, nationality, competitorId);
|
||||
DynamicBoat boat = new BoatImpl(shortName, boatClass, shortName);
|
||||
result = competitorStore.getOrCreateCompetitor(competitorId, name, null /* displayColor */,
|
||||
null /* email */, null /* flagImag */, team, boat, (double) timeOnTimeFactor,
|
||||
@@ -270,27 +267,15 @@ public class DomainFactoryImpl implements DomainFactory {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* If a team called <code>name</code> already is known by this domain factory, it is returned. Otherwise, the team name
|
||||
* is split along "+" signs with one {@link Person} object created for each part. If an existing team is found, its
|
||||
* nationality will be updated to match <code>nationality</code>.
|
||||
*/
|
||||
private DynamicTeam getOrCreateTeam(String name, Nationality nationality, UUID competitorId) {
|
||||
synchronized (teamCache) {
|
||||
DynamicTeam result = teamCache.get(competitorId);
|
||||
if (result == null) {
|
||||
String[] sailorNames = name.split("\\b*\\+\\b*");
|
||||
List<DynamicPerson> sailors = new ArrayList<DynamicPerson>();
|
||||
for (String sailorName : sailorNames) {
|
||||
sailors.add(getOrCreatePerson(sailorName.trim(), nationality, competitorId));
|
||||
}
|
||||
result = new TeamImpl(name, sailors, /* TODO coach not known */null);
|
||||
teamCache.put(competitorId, result);
|
||||
} else {
|
||||
result.setNationality(nationality);
|
||||
}
|
||||
return result;
|
||||
private DynamicTeam createTeam(String name, Nationality nationality, UUID competitorId) {
|
||||
DynamicTeam result;
|
||||
String[] sailorNames = name.split("\\b*\\+\\b*");
|
||||
List<DynamicPerson> sailors = new ArrayList<DynamicPerson>();
|
||||
for (String sailorName : sailorNames) {
|
||||
sailors.add(getOrCreatePerson(sailorName.trim(), nationality, competitorId));
|
||||
}
|
||||
result = new TeamImpl(name, sailors, /* TODO coach not known */null);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user