mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-09-30 09:26:44 +00:00
reload option works now that the team's nationality is updated upon reload
This commit is contained in:
+14
@@ -75,8 +75,22 @@ public interface SharedDomainFactory {
|
||||
*/
|
||||
BoatClass getOrCreateBoatClass(String name);
|
||||
|
||||
/**
|
||||
* If a valid competitor is returned and the caller has information available that could be used to update the competitor,
|
||||
* the caller must check the result of {@link #isCompetitorToUpdateDuringGetOrCreate(Competitor)}, and if <code>true</code>,
|
||||
* must call {@link #getOrCreateCompetitor(Serializable, String, DynamicTeam, DynamicBoat)} to cause an update of the
|
||||
* competitor's values.
|
||||
*/
|
||||
Competitor getExistingCompetitorById(Serializable competitorId);
|
||||
|
||||
/**
|
||||
* Checks if the <code>competitor</code> shall be updated from the default provided by, e.g., a tracking infrastructure.
|
||||
* Callers of {@link #getExistingCompetitorById(Serializable)} or {@link #getExistingCompetitorByIdAsString(String)}
|
||||
* must call this method in case they retrieve a valid competitor by ID and have data available that can be used to update
|
||||
* the competitor.
|
||||
*/
|
||||
boolean isCompetitorToUpdateDuringGetOrCreate(Competitor result);
|
||||
|
||||
Competitor getOrCreateCompetitor(Serializable competitorId, String name, DynamicTeam team, DynamicBoat boat);
|
||||
|
||||
/**
|
||||
|
||||
+5
-1
@@ -47,5 +47,9 @@ public class NationalityImpl implements Nationality {
|
||||
public IsManagedBySharedDomainFactory resolve(SharedDomainFactory domainFactory) {
|
||||
return domainFactory.getOrCreateNationality(getThreeLetterIOCAcronym());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getThreeLetterIOCAcronym();
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -127,7 +127,7 @@ public class DomainFactoryImpl implements DomainFactory {
|
||||
@Override
|
||||
public Competitor getOrCreateCompetitor(com.sap.sailing.domain.swisstimingadapter.Competitor competitor, RaceType raceType) {
|
||||
Competitor result = getCompetitorByBoatIDAndRaceType(competitor.getBoatID(), raceType);
|
||||
if (result == null) {
|
||||
if (result == null || baseDomainFactory.isCompetitorToUpdateDuringGetOrCreate(result)) {
|
||||
DynamicBoat boat = new BoatImpl(competitor.getName(), raceType.getBoatClass(), competitor.getBoatID());
|
||||
List<DynamicPerson> teamMembers = new ArrayList<DynamicPerson>();
|
||||
for (String teamMemberName : competitor.getName().split("[-+&]")) {
|
||||
|
||||
-7
@@ -20,7 +20,6 @@ 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;
|
||||
import com.sap.sailing.domain.base.Team;
|
||||
import com.sap.sailing.domain.base.Waypoint;
|
||||
import com.sap.sailing.domain.common.NauticalSide;
|
||||
import com.sap.sailing.domain.common.TimePoint;
|
||||
@@ -84,12 +83,6 @@ public interface DomainFactory {
|
||||
|
||||
Person getOrCreatePerson(String name, Nationality nationality, UUID id);
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
Team getOrCreateTeam(String name, Nationality nationality, UUID competitorId);
|
||||
|
||||
/**
|
||||
* Fetch a race definition previously created by a call to {@link #getOrCreateRaceDefinitionAndTrackedRace}. If no such
|
||||
* race definition was created so far, the call blocks until such a definition is provided by a call to
|
||||
|
||||
+10
-3
@@ -25,6 +25,7 @@ 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;
|
||||
@@ -235,7 +236,7 @@ public class DomainFactoryImpl implements DomainFactory {
|
||||
public Competitor getOrCreateCompetitor(final UUID competitorId, final String competitorClassName,
|
||||
final String nationalityAsString, final String name, final String shortName) {
|
||||
Competitor result = baseDomainFactory.getExistingCompetitorById(competitorId);
|
||||
if (result == null) {
|
||||
if (result == null || baseDomainFactory.isCompetitorToUpdateDuringGetOrCreate(result)) {
|
||||
BoatClass boatClass = getOrCreateBoatClass(competitorClassName);
|
||||
Nationality nationality;
|
||||
try {
|
||||
@@ -252,8 +253,12 @@ public class DomainFactoryImpl implements DomainFactory {
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DynamicTeam getOrCreateTeam(String name, Nationality nationality, UUID competitorId) {
|
||||
/**
|
||||
* 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) {
|
||||
@@ -264,6 +269,8 @@ public class DomainFactoryImpl implements DomainFactory {
|
||||
}
|
||||
result = new TeamImpl(name, sailors, /* TODO coach not known */null);
|
||||
teamCache.put(competitorId, result);
|
||||
} else {
|
||||
result.setNationality(nationality);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -14,11 +14,30 @@ import com.sap.sailing.domain.common.dto.CompetitorDTO;
|
||||
*
|
||||
*/
|
||||
public interface CompetitorStore {
|
||||
|
||||
/**
|
||||
* If a valid competitor is returned and the caller has information available that could be used to update the competitor,
|
||||
* the caller must check the result of {@link #isCompetitorToUpdateDuringGetOrCreate(Competitor)}, and if <code>true</code>,
|
||||
* must call {@link #getOrCreateCompetitor(Serializable, String, DynamicTeam, DynamicBoat)} to cause an update of the
|
||||
* competitor's values.
|
||||
*/
|
||||
Competitor getExistingCompetitorById(Serializable competitorId);
|
||||
|
||||
/**
|
||||
* If a valid competitor is returned and the caller has information available that could be used to update the competitor,
|
||||
* the caller must check the result of {@link #isCompetitorToUpdateDuringGetOrCreate(Competitor)}, and if <code>true</code>,
|
||||
* must call {@link #getOrCreateCompetitor(Serializable, String, DynamicTeam, DynamicBoat)} to cause an update of the
|
||||
* competitor's values.
|
||||
*/
|
||||
Competitor getExistingCompetitorByIdAsString(String idAsString);
|
||||
|
||||
/**
|
||||
* Checks if the <code>competitor</code> shall be updated from the default provided by, e.g., a tracking infrastructure.
|
||||
* Callers of {@link #getExistingCompetitorById(Serializable)} or {@link #getExistingCompetitorByIdAsString(String)}
|
||||
* must call this method in case they retrieve a valid competitor by ID and have data available that can be used to update
|
||||
* the competitor.
|
||||
*/
|
||||
boolean isCompetitorToUpdateDuringGetOrCreate(Competitor result);
|
||||
|
||||
Competitor getOrCreateCompetitor(Serializable competitorId, String name, DynamicTeam team, DynamicBoat boat);
|
||||
|
||||
/**
|
||||
|
||||
+5
@@ -291,6 +291,11 @@ public class DomainFactoryImpl implements DomainFactory {
|
||||
return competitorStore.getExistingCompetitorById(competitorId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCompetitorToUpdateDuringGetOrCreate(Competitor competitor) {
|
||||
return competitorStore.isCompetitorToUpdateDuringGetOrCreate(competitor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized Competitor getOrCreateCompetitor(Serializable competitorId, String name, DynamicTeam team, DynamicBoat boat) {
|
||||
return competitorStore.getOrCreateCompetitor(competitorId, name, team, boat);
|
||||
|
||||
+7
-1
@@ -85,11 +85,17 @@ public class TransientCompetitorStoreImpl implements CompetitorStore, Serializab
|
||||
}
|
||||
} else if (isCompetitorToUpdateDuringGetOrCreate(result)) {
|
||||
updateCompetitor(result.getId().toString(), name, boat.getSailID(), team.getNationality());
|
||||
competitorNoLongerToUpdateDuringGetOrCreate(result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
protected boolean isCompetitorToUpdateDuringGetOrCreate(Competitor result) {
|
||||
private void competitorNoLongerToUpdateDuringGetOrCreate(Competitor result) {
|
||||
competitorsToUpdateDuringGetOrCreate.remove(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCompetitorToUpdateDuringGetOrCreate(Competitor result) {
|
||||
return competitorsToUpdateDuringGetOrCreate.contains(result);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@ package com.sap.sailing.gwt.ui.client;
|
||||
|
||||
public interface UserAgentChecker {
|
||||
|
||||
public final UserAgentCheckerImpl INSTANCE = new UserAgentCheckerImpl();
|
||||
public final UserAgentChecker INSTANCE = new UserAgentCheckerImpl();
|
||||
|
||||
/**
|
||||
* Returns false if the given userAgent is not supported.
|
||||
|
||||
+22
-21
@@ -5,30 +5,31 @@ import java.util.HashMap;
|
||||
import com.sap.sailing.gwt.ui.client.UserAgentDetails.AgentTypes;
|
||||
|
||||
public class UserAgentCheckerImpl implements UserAgentChecker {
|
||||
|
||||
|
||||
/**
|
||||
* Version numbers indicate minimum required browser (20 = at least this version)
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
private static final HashMap<AgentTypes, Integer> MINIMUM_SUPPORTED_AGENTS = new HashMap<AgentTypes, Integer>() {{
|
||||
put(AgentTypes.MSIE, 9);
|
||||
put(AgentTypes.SAFARI, 5);
|
||||
put(AgentTypes.OPERA, 10);
|
||||
put(AgentTypes.FIREFOX, 10);
|
||||
put(AgentTypes.CHROME, 20);
|
||||
|
||||
}};
|
||||
private static final HashMap<AgentTypes, Integer> MINIMUM_SUPPORTED_AGENTS = new HashMap<AgentTypes, Integer>() {
|
||||
{
|
||||
put(AgentTypes.MSIE, 9);
|
||||
put(AgentTypes.SAFARI, 5);
|
||||
put(AgentTypes.OPERA, 10);
|
||||
put(AgentTypes.FIREFOX, 10);
|
||||
put(AgentTypes.CHROME, 20);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean isUserAgentSupported(UserAgentDetails details) {
|
||||
if (MINIMUM_SUPPORTED_AGENTS.containsKey(details.getType())) {
|
||||
if (details.getVersion()[0] < MINIMUM_SUPPORTED_AGENTS.get(details.getType())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/* returning true for entries not listed */
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUserAgentSupported(UserAgentDetails details) {
|
||||
if (MINIMUM_SUPPORTED_AGENTS.containsKey(details.getType())) {
|
||||
if (details.getVersion()[0] < MINIMUM_SUPPORTED_AGENTS.get(details.getType())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/* returning true for entries not listed */
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl} -consoleLog -console -clean"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-ea -Declipse.ignoreApp=true -Dosgi.noShutdown=true -Dexpedition.udp.port=2010 -Xmx4096m -Djetty.home=${project_loc:com.sap.sailing.server}/../target/configuration/jetty -Djava.util.logging.config.file=${project_loc:com.sap.sailing.server}/../target/configuration/logging_debug.properties -Dkiwo.results=${project_loc:com.sap.sailing.kiworesultimport.test}/resources -XX:+UseMembar"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-ea -Declipse.ignoreApp=true -Dosgi.noShutdown=true -Dexpedition.udp.port=2010 -Xmx4096m -Djetty.home=${project_loc:com.sap.sailing.server}/../target/configuration/jetty -Djava.util.logging.config.file=${project_loc:com.sap.sailing.server}/../target/configuration/logging_debug.properties -Dkiwo.results=${project_loc:com.sap.sailing.kiworesultimport.test}/resources -Dpersistentcompetitors.clear=false -XX:+UseMembar"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.WORKING_DIRECTORY" value="${workspace_loc}"/>
|
||||
<stringAttribute key="pde.version" value="3.3"/>
|
||||
<stringAttribute key="profilingTraceType-ALLOCATION_TRACE" value="KEY_SESSION_FILTER%CTX_KEY%*%CTX_ENTRY%INCREASE_COUNT%CTX_KEY%8192%CTX_ENTRY%KEY_USER_FILTER%CTX_KEY%*%CTX_ENTRY%KEY_ADAPTIVE%CTX_KEY%false%CTX_ENTRY%KEY_MIN_SIZE%CTX_KEY%32%CTX_ENTRY%KEY_REQUEST_FILTER%CTX_KEY%*%CTX_ENTRY%CLASS_FILTER%CTX_KEY%*%CTX_ENTRY%KEY_MAX_SIZE%CTX_KEY%65536%CTX_ENTRY%KEY_INC_LINE_NRS%CTX_KEY%true%CTX_ENTRY%KEY_APPLICATION_FILTER%CTX_KEY%*%CTX_ENTRY%KEY_ENABLEMENT%CTX_KEY%false%CTX_ENTRY%"/>
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl} -consoleLog -console -clean"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-ea -Declipse.ignoreApp=true -Dosgi.noShutdown=true -Dfile.encoding=cp1252 -Dexpedition.udp.port=2010 -Xmx6000m -Dhttp.proxyHost=proxy.wdf.sap.corp -Dhttp.proxyPort=8080 -Djetty.home=${project_loc:com.sap.sailing.server}/../target/configuration/jetty -Djava.util.logging.config.file=${project_loc:com.sap.sailing.server}/../target/configuration/logging_debug.properties -Dkiwo.results=${project_loc:com.sap.sailing.kiworesultimport.test}/resources -XX:+UseMembar"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-ea -Declipse.ignoreApp=true -Dosgi.noShutdown=true -Dfile.encoding=cp1252 -Dexpedition.udp.port=2010 -Xmx6000m -Dhttp.proxyHost=proxy.wdf.sap.corp -Dhttp.proxyPort=8080 -Djetty.home=${project_loc:com.sap.sailing.server}/../target/configuration/jetty -Djava.util.logging.config.file=${project_loc:com.sap.sailing.server}/../target/configuration/logging_debug.properties -Dkiwo.results=${project_loc:com.sap.sailing.kiworesultimport.test}/resources -Dpersistentcompetitors.clear=false -XX:+UseMembar"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.WORKING_DIRECTORY" value="${workspace_loc}"/>
|
||||
<stringAttribute key="pde.version" value="3.3"/>
|
||||
<booleanAttribute key="show_selected_only" value="false"/>
|
||||
|
||||
@@ -25,7 +25,7 @@ public class Activator implements BundleActivator {
|
||||
boolean clearPersistentCompetitors = Boolean.valueOf(System.getProperty(CLEAR_PERSISTENT_COMPETITORS_PROPERTY_NAME, ""+true));
|
||||
logger.log(Level.INFO, "setting "+CLEAR_PERSISTENT_COMPETITORS_PROPERTY_NAME+" to "+clearPersistentCompetitors);
|
||||
// there is exactly one instance of the racingEventService in the whole server
|
||||
racingEventService = new RacingEventServiceImpl();
|
||||
racingEventService = new RacingEventServiceImpl(clearPersistentCompetitors);
|
||||
}
|
||||
|
||||
public void start(BundleContext context) throws Exception {
|
||||
|
||||
+7
@@ -12,6 +12,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
import android.annotation.SuppressLint;
|
||||
|
||||
import com.sap.sailing.domain.base.BoatClass;
|
||||
import com.sap.sailing.domain.base.Competitor;
|
||||
import com.sap.sailing.domain.base.ControlPoint;
|
||||
import com.sap.sailing.domain.base.CourseArea;
|
||||
import com.sap.sailing.domain.base.Gate;
|
||||
@@ -136,10 +137,16 @@ public enum DomainFactoryImpl implements SharedDomainFactory {
|
||||
return getOrCreateBoatClass(name, /* typicallyStartsUpwind */!mayStartWithNoUpwindLeg.contains(name.toLowerCase()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public DynamicCompetitor getExistingCompetitorById(Serializable competitorId) {
|
||||
return competitorCache.get(competitorId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCompetitorToUpdateDuringGetOrCreate(Competitor result) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public DynamicCompetitor createCompetitor(Serializable id, String name, DynamicTeam team, DynamicBoat boat) {
|
||||
DynamicCompetitor result = new CompetitorImpl(id, name, team, boat);
|
||||
competitorCache.put(id, result);
|
||||
|
||||
Reference in New Issue
Block a user