mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-09-18 11:49:09 +00:00
Merge branch 'master' into bug4509
Change-Id: Ia63ce5f964be5471b00a5429d6984e141d742b4d
This commit is contained in:
Executable
+13
@@ -0,0 +1,13 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Executes the following script on the DB server:
|
||||
##!/bin/sh
|
||||
#useremail=$1
|
||||
#for i in `echo "show dbs" | /opt/mongodb-linux-x86_64-2.6.7/bin/mongo --port 10202 | grep -v "^bye$" | awk '{print $1;'}`; do
|
||||
# match=`echo "db.USERS.find({EMAIL: '$useremail'}); db.COMPETITORS.find({email: '$useremail'})" | /opt/mongodb-linux-x86_64-2.6.7/bin/mongo --quiet --port 10202 $i`
|
||||
# if [ "$match" != "" ]; then
|
||||
# echo ${i}: $match
|
||||
# fi
|
||||
#done
|
||||
|
||||
ssh -A root@sapsailing.com ssh -A dbserver.internal.sapsailing.com finduserbyemail $1
|
||||
+1
-1
@@ -47,7 +47,7 @@ public class GetStartAnalysesAction implements DashboardAction<StartAnalysesDTO>
|
||||
try {
|
||||
Competitor competitor = null;
|
||||
if(competitorIdAsString != null) {
|
||||
competitor = dashboardDispatchContext.getRacingEventService().getBaseDomainFactory().getCompetitorStore().getExistingCompetitorByIdAsString(competitorIdAsString);
|
||||
competitor = dashboardDispatchContext.getRacingEventService().getBaseDomainFactory().getCompetitorAndBoatStore().getExistingCompetitorByIdAsString(competitorIdAsString);
|
||||
}
|
||||
Leaderboard leaderboard = dashboardDispatchContext.getRacingEventService().getLeaderboardByName(this.leaderboarName);
|
||||
if (leaderboard != null) {
|
||||
|
||||
+2
-2
@@ -61,7 +61,7 @@ public final class StartAnalysisDTOFactory extends AbstractStartAnalysisCreation
|
||||
}
|
||||
if (competitor != null) {
|
||||
Boat boatOfCompetitor = trackedRace.getBoatOfCompetitor(competitor);
|
||||
startAnalysisDTO.competitor = dashboardDispatchContext.getRacingEventService().getBaseDomainFactory().getCompetitorStore().convertToCompetitorWithBoatDTO(competitor, boatOfCompetitor);
|
||||
startAnalysisDTO.competitor = dashboardDispatchContext.getRacingEventService().getBaseDomainFactory().getCompetitorAndBoatStore().convertToCompetitorWithBoatDTO(competitor, boatOfCompetitor);
|
||||
logger.log(Level.INFO, "Created startanalysis for competitor"+competitor);
|
||||
}
|
||||
startAnalysisDTO.startAnalysisCompetitorDTOs = competitors;
|
||||
@@ -194,7 +194,7 @@ public final class StartAnalysisDTOFactory extends AbstractStartAnalysisCreation
|
||||
private static StartAnalysisCompetitorDTO createStartAnalysisCompetitorDTO(DashboardDispatchContext dashboardDispatchContext, TrackedRace trackedRace, int rank, Competitor competitor) {
|
||||
StartAnalysisCompetitorDTO startAnalysisCompetitorDTOsForRace = new StartAnalysisCompetitorDTO();
|
||||
Boat boatOfCompetitor = trackedRace.getBoatOfCompetitor(competitor);
|
||||
startAnalysisCompetitorDTOsForRace.competitorDTO = dashboardDispatchContext.getRacingEventService().getBaseDomainFactory().getCompetitorStore()
|
||||
startAnalysisCompetitorDTOsForRace.competitorDTO = dashboardDispatchContext.getRacingEventService().getBaseDomainFactory().getCompetitorAndBoatStore()
|
||||
.convertToCompetitorWithBoatDTO(competitor, boatOfCompetitor);
|
||||
startAnalysisCompetitorDTOsForRace.rankingTableEntryDTO = createRankTableEntry(trackedRace, rank, competitor);
|
||||
return startAnalysisCompetitorDTOsForRace;
|
||||
|
||||
+7
-7
@@ -430,7 +430,7 @@ public class DomainObjectFactoryImpl implements DomainObjectFactory {
|
||||
() -> (RegattaLeaderboard) leaderboardRegistry.getLeaderboardByName(wrappedRegattaLeaderboardName),
|
||||
leaderboardName);
|
||||
for (Object eliminatedCompetitorId : eliminatedCompetitorIds) {
|
||||
Competitor eliminatedCompetitor = baseDomainFactory.getCompetitorStore()
|
||||
Competitor eliminatedCompetitor = baseDomainFactory.getCompetitorAndBoatStore()
|
||||
.getExistingCompetitorById((Serializable) eliminatedCompetitorId);
|
||||
if (eliminatedCompetitor == null) {
|
||||
logger.warning("Couldn't find eliminated competitor with ID " + eliminatedCompetitorId);
|
||||
@@ -1644,7 +1644,7 @@ public class DomainObjectFactoryImpl implements DomainObjectFactory {
|
||||
final Serializable boatId = (Serializable) dbObject.get(FieldNames.RACE_LOG_BOAT_ID.name());
|
||||
// legacy RaceLogRegisterCompetitorEvent's do not have a boatId, it's expected that the
|
||||
// corresponding competitors have the type CompetitorWithBoat
|
||||
Competitor competitor = baseDomainFactory.getCompetitorStore().getExistingCompetitorById(competitorId);
|
||||
Competitor competitor = baseDomainFactory.getCompetitorAndBoatStore().getExistingCompetitorById(competitorId);
|
||||
final Optional<DBObject> dbObjectForUpdate;
|
||||
if (competitor == null) {
|
||||
logger.severe("Competitor with ID "+competitorId+" not found; can't register with boat with ID "+boatId+" for race");
|
||||
@@ -1678,7 +1678,7 @@ public class DomainObjectFactoryImpl implements DomainObjectFactory {
|
||||
TimePoint logicalTimePoint, Serializable id, Integer passId, Serializable boatId, Competitor competitor) {
|
||||
final RaceLogRegisterCompetitorEvent result;
|
||||
// a boat was explicitly specified; use it
|
||||
Boat boat = baseDomainFactory.getCompetitorStore().getExistingBoatById(boatId);
|
||||
Boat boat = baseDomainFactory.getCompetitorAndBoatStore().getExistingBoatById(boatId);
|
||||
if (boat != null) {
|
||||
result = new RaceLogRegisterCompetitorEventImpl(createdAt, logicalTimePoint, author, id, passId, competitor, boat);
|
||||
} else {
|
||||
@@ -1853,7 +1853,7 @@ public class DomainObjectFactoryImpl implements DomainObjectFactory {
|
||||
List<Competitor> competitors = new ArrayList<Competitor>();
|
||||
for (Object object : dbCompetitorList) {
|
||||
Serializable competitorId = (Serializable) object;
|
||||
Competitor competitor = baseDomainFactory.getCompetitorStore().getExistingCompetitorById(competitorId);
|
||||
Competitor competitor = baseDomainFactory.getCompetitorAndBoatStore().getExistingCompetitorById(competitorId);
|
||||
competitors.add(competitor);
|
||||
}
|
||||
return competitors;
|
||||
@@ -2013,13 +2013,13 @@ public class DomainObjectFactoryImpl implements DomainObjectFactory {
|
||||
|
||||
private Competitor getCompetitorByID(DBObject dbObject) {
|
||||
Serializable competitorId = (Serializable) dbObject.get(FieldNames.REGATTA_LOG_COMPETITOR_ID.name());
|
||||
Competitor comp = baseDomainFactory.getCompetitorStore().getExistingCompetitorById(competitorId);
|
||||
Competitor comp = baseDomainFactory.getCompetitorAndBoatStore().getExistingCompetitorById(competitorId);
|
||||
return comp;
|
||||
}
|
||||
|
||||
private Boat getBoatByID(DBObject dbObject) {
|
||||
Serializable boatId = (Serializable) dbObject.get(FieldNames.REGATTA_LOG_BOAT_ID.name());
|
||||
Boat boat = baseDomainFactory.getCompetitorStore().getExistingBoatById(boatId);
|
||||
Boat boat = baseDomainFactory.getCompetitorAndBoatStore().getExistingBoatById(boatId);
|
||||
return boat;
|
||||
}
|
||||
|
||||
@@ -2160,7 +2160,7 @@ public class DomainObjectFactoryImpl implements DomainObjectFactory {
|
||||
RegattaLikeIdentifier regattaLogIdentifier, DBObject outerDBObject) {
|
||||
return this.loadRegattaLogDeviceMappingEvent(createdAt, author, logicalTimePoint, id, dbObject,
|
||||
regattaLogIdentifier, outerDBObject,
|
||||
() -> baseDomainFactory.getCompetitorStore()
|
||||
() -> baseDomainFactory.getCompetitorAndBoatStore()
|
||||
.getExistingBoatById((Serializable) dbObject.get(FieldNames.RACE_LOG_BOAT_ID.name())),
|
||||
RegattaLogDeviceBoatMappingEventImpl::new,
|
||||
result -> new MongoObjectFactoryImpl(database, serviceFinderFactory)
|
||||
|
||||
+1
-1
@@ -103,7 +103,7 @@ public class CreateAndTrackWithRaceLogTest extends RaceLogTrackingTestHelper {
|
||||
series.addRaceColumn(columnName, /* trackedRegattaRegistry */null);
|
||||
leaderboard = service.addRegattaLeaderboard(regatta.getRegattaIdentifier(), "RegattaLeaderboard", new int[] {});
|
||||
adapter = RaceLogTrackingAdapterFactory.INSTANCE.getAdapter(DomainFactory.INSTANCE);
|
||||
DomainFactory.INSTANCE.getCompetitorStore().clear();
|
||||
DomainFactory.INSTANCE.getCompetitorAndBoatStore().clear();
|
||||
}
|
||||
|
||||
@After
|
||||
|
||||
+1
-1
@@ -84,7 +84,7 @@ public interface SharedDomainFactory extends CompetitorFactory, BoatFactory {
|
||||
/**
|
||||
* Gets the {@link CompetitorAndBoatStore} of this {@link SharedDomainFactory}.
|
||||
*/
|
||||
CompetitorAndBoatStore getCompetitorStore();
|
||||
CompetitorAndBoatStore getCompetitorAndBoatStore();
|
||||
|
||||
/**
|
||||
* If a {@link CourseArea} with the given id already exists, it is returned. Otherwise a new {@link CourseArea}
|
||||
|
||||
Regular → Executable
+9
-9
@@ -333,23 +333,23 @@ public class SharedDomainFactoryImpl implements SharedDomainFactory {
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompetitorAndBoatStore getCompetitorStore() {
|
||||
public CompetitorAndBoatStore getCompetitorAndBoatStore() {
|
||||
return competitorAndBoatStore;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Competitor getExistingCompetitorById(Serializable competitorId) {
|
||||
return getCompetitorStore().getExistingCompetitorById(competitorId);
|
||||
return getCompetitorAndBoatStore().getExistingCompetitorById(competitorId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompetitorWithBoat getExistingCompetitorWithBoatById(Serializable competitorId) {
|
||||
return getCompetitorStore().getExistingCompetitorWithBoatById(competitorId);
|
||||
return getCompetitorAndBoatStore().getExistingCompetitorWithBoatById(competitorId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCompetitorToUpdateDuringGetOrCreate(Competitor competitor) {
|
||||
return getCompetitorStore().isCompetitorToUpdateDuringGetOrCreate(competitor);
|
||||
return getCompetitorAndBoatStore().isCompetitorToUpdateDuringGetOrCreate(competitor);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -359,7 +359,7 @@ public class SharedDomainFactoryImpl implements SharedDomainFactory {
|
||||
if (logger.isLoggable(Level.FINEST)) {
|
||||
logger.log(Level.FINEST, "getting or creating competitor "+name+" with ID "+competitorId+" in domain factory "+this);
|
||||
}
|
||||
return getCompetitorStore().getOrCreateCompetitor(competitorId, name, shortname, displayColor, email, flagImage, team,
|
||||
return getCompetitorAndBoatStore().getOrCreateCompetitor(competitorId, name, shortname, displayColor, email, flagImage, team,
|
||||
timeOnTimeFactor, timeOnDistanceAllowancePerNauticalMile, searchTag);
|
||||
}
|
||||
|
||||
@@ -370,23 +370,23 @@ public class SharedDomainFactoryImpl implements SharedDomainFactory {
|
||||
if (logger.isLoggable(Level.FINEST)) {
|
||||
logger.log(Level.FINEST, "getting or creating competitor "+name+" with ID "+competitorId+" in domain factory "+this);
|
||||
}
|
||||
return getCompetitorStore().getOrCreateCompetitorWithBoat(competitorId, name, shortName, displayColor, email, flagImageURI, team,
|
||||
return getCompetitorAndBoatStore().getOrCreateCompetitorWithBoat(competitorId, name, shortName, displayColor, email, flagImageURI, team,
|
||||
timeOnTimeFactor, timeOnDistanceAllowancePerNauticalMile, searchTag, boat);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DynamicBoat getExistingBoatById(Serializable boatId) {
|
||||
return getCompetitorStore().getExistingBoatById(boatId);
|
||||
return getCompetitorAndBoatStore().getExistingBoatById(boatId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBoatToUpdateDuringGetOrCreate(Boat boat) {
|
||||
return getCompetitorStore().isBoatToUpdateDuringGetOrCreate(boat);
|
||||
return getCompetitorAndBoatStore().isBoatToUpdateDuringGetOrCreate(boat);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DynamicBoat getOrCreateBoat(Serializable id, String name, BoatClass boatClass, String sailId, Color color) {
|
||||
return getCompetitorStore().getOrCreateBoat(id, name, boatClass, sailId, color);
|
||||
return getCompetitorAndBoatStore().getOrCreateBoat(id, name, boatClass, sailId, color);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+5
-1
@@ -518,7 +518,11 @@ public class TransientCompetitorAndBoatStoreImpl implements CompetitorAndBoatSto
|
||||
protected void addNewBoat(DynamicBoat boat) {
|
||||
LockUtil.lockForWrite(lock);
|
||||
try {
|
||||
boatCache.put(boat.getId(), boat);
|
||||
final Boat existingBoatWithEqualId = boatCache.put(boat.getId(), boat);
|
||||
if (existingBoatWithEqualId != null && existingBoatWithEqualId != boat) {
|
||||
logger.warning("Replaced existing boat "+existingBoatWithEqualId+" with ID "+existingBoatWithEqualId.getId()+
|
||||
" by another boat with equal ID: "+boat);
|
||||
}
|
||||
boatsByIdAsString.put(boat.getId().toString(), boat);
|
||||
} finally {
|
||||
LockUtil.unlockAfterWrite(lock);
|
||||
|
||||
Executable → Regular
+5
-4
@@ -120,7 +120,7 @@ public class DomainFactoryImpl implements DomainFactory {
|
||||
|
||||
@Override
|
||||
public Pair<Competitor, Boat> createCompetitorWithID(com.sap.sailing.domain.swisstimingadapter.Competitor competitor, BoatClass boatClass) {
|
||||
CompetitorAndBoatStore competitorAndBoatStore = baseDomainFactory.getCompetitorStore();
|
||||
CompetitorAndBoatStore competitorAndBoatStore = baseDomainFactory.getCompetitorAndBoatStore();
|
||||
CompetitorWithBoat domainCompetitor = competitorAndBoatStore.getExistingCompetitorWithBoatByIdAsString(competitor.getID());
|
||||
if (domainCompetitor == null || competitorAndBoatStore.isCompetitorToUpdateDuringGetOrCreate(domainCompetitor)) {
|
||||
List<DynamicPerson> teamMembers = new ArrayList<DynamicPerson>();
|
||||
@@ -139,7 +139,7 @@ public class DomainFactoryImpl implements DomainFactory {
|
||||
|
||||
@Override
|
||||
public Pair<Competitor, Boat> createCompetitorWithoutID(com.sap.sailing.domain.swisstimingadapter.Competitor competitor, String raceId, BoatClass boatClass) {
|
||||
CompetitorAndBoatStore competitorAndBoatStore = baseDomainFactory.getCompetitorStore();
|
||||
CompetitorAndBoatStore competitorAndBoatStore = baseDomainFactory.getCompetitorAndBoatStore();
|
||||
List<DynamicPerson> teamMembers = new ArrayList<DynamicPerson>();
|
||||
for (String teamMemberName : competitor.getName().split("[-+&]")) {
|
||||
teamMembers.add(new PersonImpl(teamMemberName.trim(), getOrCreateNationality(competitor.getThreeLetterIOCCode()),
|
||||
@@ -147,11 +147,12 @@ public class DomainFactoryImpl implements DomainFactory {
|
||||
}
|
||||
DynamicTeam team = new TeamImpl(competitor.getName(), teamMembers, /* coach */ null);
|
||||
String competitorID = getCompetitorID(competitor.getBoatID(), competitor.getName(), raceId, boatClass);
|
||||
// TODO wouldn't the boat also need to be constructed using competitorAndBoatStore.getOrCreateBoat...?
|
||||
DynamicBoat domainBoat = new BoatImpl(UUID.randomUUID(), null, boatClass, competitor.getBoatID(), null);
|
||||
Competitor domainCompetitor = competitorAndBoatStore.getOrCreateCompetitorWithBoat(competitorID,
|
||||
CompetitorWithBoat domainCompetitor = competitorAndBoatStore.getOrCreateCompetitorWithBoat(competitorID,
|
||||
competitor.getName(), null /* short name */, null /*displayColor*/, null /*email*/, null, team,
|
||||
/* timeOnTimeFactor */ null, /* timeOnDistanceAllowancePerNauticalMile */ null, null, domainBoat);
|
||||
return new Pair<Competitor, Boat>(domainCompetitor, domainBoat);
|
||||
return new Pair<Competitor, Boat>(domainCompetitor, domainCompetitor.getBoat());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
-1
@@ -471,7 +471,7 @@ public class SwissTimingRaceTrackerImpl extends AbstractRaceTrackerImpl
|
||||
this.notifyAll();
|
||||
}
|
||||
// temp
|
||||
CompetitorAndBoatStore competitorStore = domainFactory.getBaseDomainFactory().getCompetitorStore();
|
||||
CompetitorAndBoatStore competitorStore = domainFactory.getBaseDomainFactory().getCompetitorAndBoatStore();
|
||||
for (com.sap.sailing.domain.swisstimingadapter.Competitor c : startList.getCompetitors()) {
|
||||
Competitor existingCompetitor = competitorStore.getExistingCompetitorByIdAsString(c.getID());
|
||||
if (existingCompetitor != null) {
|
||||
|
||||
+6
-6
@@ -258,7 +258,7 @@ public class DomainFactoryImpl implements DomainFactory {
|
||||
|
||||
@Override
|
||||
public Competitor resolveCompetitor(ICompetitor competitor) {
|
||||
return baseDomainFactory.getCompetitorStore().getExistingCompetitorById(competitor.getId());
|
||||
return baseDomainFactory.getCompetitorAndBoatStore().getExistingCompetitorById(competitor.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -296,7 +296,7 @@ public class DomainFactoryImpl implements DomainFactory {
|
||||
private CompetitorWithBoat getOrCreateCompetitorWithBoat(final UUID competitorId,
|
||||
final String nationalityAsString, final String name, final String shortName, float timeOnTimeFactor,
|
||||
float timeOnDistanceAllowanceInSecondsPerNauticalMile, String searchTag, String competitorClassName, String sailId) {
|
||||
CompetitorAndBoatStore competitorStore = baseDomainFactory.getCompetitorStore();
|
||||
CompetitorAndBoatStore competitorStore = baseDomainFactory.getCompetitorAndBoatStore();
|
||||
CompetitorWithBoat domainCompetitor = competitorStore.getExistingCompetitorWithBoatById(competitorId);
|
||||
if (domainCompetitor == null || competitorStore.isCompetitorToUpdateDuringGetOrCreate(domainCompetitor)) {
|
||||
BoatClass boatClass = getOrCreateBoatClass(competitorClassName);
|
||||
@@ -321,7 +321,7 @@ public class DomainFactoryImpl implements DomainFactory {
|
||||
private Competitor getOrCreateCompetitor(final UUID competitorId, final String nationalityAsString,
|
||||
final String name, final String shortName, float timeOnTimeFactor,
|
||||
float timeOnDistanceAllowanceInSecondsPerNauticalMile, String searchTag) {
|
||||
CompetitorAndBoatStore competitorStore = baseDomainFactory.getCompetitorStore();
|
||||
CompetitorAndBoatStore competitorStore = baseDomainFactory.getCompetitorAndBoatStore();
|
||||
Competitor domainCompetitor = competitorStore.getExistingCompetitorById(competitorId);
|
||||
if (domainCompetitor == null || competitorStore.isCompetitorToUpdateDuringGetOrCreate(domainCompetitor)) {
|
||||
Nationality nationality;
|
||||
@@ -341,10 +341,10 @@ public class DomainFactoryImpl implements DomainFactory {
|
||||
}
|
||||
|
||||
public Boat getOrCreateBoat(Serializable boatId, String boatName, BoatClass boatClass, String sailId, Color boatColor) {
|
||||
CompetitorAndBoatStore competitorStore = baseDomainFactory.getCompetitorStore();
|
||||
CompetitorAndBoatStore competitorStore = baseDomainFactory.getCompetitorAndBoatStore();
|
||||
Boat domainBoat = competitorStore.getExistingBoatById(boatId);
|
||||
if (domainBoat == null) {
|
||||
domainBoat = baseDomainFactory.getCompetitorStore().getOrCreateBoat(boatId, boatName, boatClass, sailId, boatColor);
|
||||
domainBoat = baseDomainFactory.getCompetitorAndBoatStore().getOrCreateBoat(boatId, boatName, boatClass, sailId, boatColor);
|
||||
}
|
||||
return domainBoat;
|
||||
}
|
||||
@@ -708,7 +708,7 @@ public class DomainFactoryImpl implements DomainFactory {
|
||||
@Override
|
||||
public Map<Competitor, Boat> getOrCreateCompetitorsAndTheirBoats(DynamicTrackedRegatta trackedRegatta, LeaderboardGroupResolver leaderboardGroupResolver,
|
||||
IRace race, BoatClass defaultBoatClass) {
|
||||
final CompetitorAndBoatStore competitorAndBoatStore = baseDomainFactory.getCompetitorStore();
|
||||
final CompetitorAndBoatStore competitorAndBoatStore = baseDomainFactory.getCompetitorAndBoatStore();
|
||||
final Map<Competitor, Boat> competitorsAndBoats = new HashMap<>();
|
||||
Regatta regatta = trackedRegatta.getRegatta();
|
||||
LeaderboardGroup leaderboardGroup = leaderboardGroupResolver.resolveLeaderboardGroupByRegattaName(regatta.getName());
|
||||
|
||||
+1
-1
@@ -63,7 +63,7 @@ public class GetCompetitorSuggestionAction implements SailingAction<CompetitorSu
|
||||
|
||||
@GwtIncompatible
|
||||
private Iterable<Competitor> getFilteredCompetitors(SailingDispatchContext ctx) {
|
||||
Iterable<? extends Competitor> allCompetitors = ctx.getRacingEventService().getCompetitorStore().getAllCompetitors();
|
||||
Iterable<? extends Competitor> allCompetitors = ctx.getRacingEventService().getCompetitorAndBoatStore().getAllCompetitors();
|
||||
return competitorFilter.applyFilter(queryTokens, Util.addAll(allCompetitors, new ArrayList<Competitor>()));
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -37,7 +37,7 @@ public class GetCompetitorsAction implements SailingAction<SortedSetResult<Simpl
|
||||
@Override
|
||||
@GwtIncompatible
|
||||
public SortedSetResult<SimpleCompetitorWithIdDTO> execute(SailingDispatchContext ctx) throws DispatchException {
|
||||
CompetitorAndBoatStore competitorStore = ctx.getRacingEventService().getCompetitorStore();
|
||||
CompetitorAndBoatStore competitorStore = ctx.getRacingEventService().getCompetitorAndBoatStore();
|
||||
SortedSetResult<SimpleCompetitorWithIdDTO> result = new SortedSetResult<>();
|
||||
for (String id : ids) {
|
||||
Competitor competitor = competitorStore.getExistingCompetitorByIdAsString(id);
|
||||
|
||||
+1
-1
@@ -33,7 +33,7 @@ public class SaveFavoriteCompetitorsAction implements SailingAction<VoidResult>
|
||||
public VoidResult execute(SailingDispatchContext ctx) throws DispatchException {
|
||||
CompetitorNotificationPreferences prefs = new CompetitorNotificationPreferences(ctx.getRacingEventService());
|
||||
List<CompetitorNotificationPreference> competitorPreferences = new ArrayList<>();
|
||||
CompetitorAndBoatStore competitorStore = ctx.getRacingEventService().getCompetitorStore();
|
||||
CompetitorAndBoatStore competitorStore = ctx.getRacingEventService().getCompetitorAndBoatStore();
|
||||
for (SimpleCompetitorWithIdDTO competitorDTO : favorites.getSelectedCompetitors()) {
|
||||
Competitor competitor = competitorStore.getExistingCompetitorByIdAsString(competitorDTO.getIdAsString());
|
||||
competitorPreferences.add(new CompetitorNotificationPreference(competitorStore, competitor,
|
||||
|
||||
+28
-31
@@ -236,8 +236,8 @@ import com.sap.sailing.domain.common.abstractlog.NotRevokableException;
|
||||
import com.sap.sailing.domain.common.abstractlog.TimePointSpecificationFoundInLog;
|
||||
import com.sap.sailing.domain.common.dto.BoatClassDTO;
|
||||
import com.sap.sailing.domain.common.dto.BoatDTO;
|
||||
import com.sap.sailing.domain.common.dto.CompetitorWithBoatDTO;
|
||||
import com.sap.sailing.domain.common.dto.CompetitorDTO;
|
||||
import com.sap.sailing.domain.common.dto.CompetitorWithBoatDTO;
|
||||
import com.sap.sailing.domain.common.dto.FleetDTO;
|
||||
import com.sap.sailing.domain.common.dto.FullLeaderboardDTO;
|
||||
import com.sap.sailing.domain.common.dto.IncrementalLeaderboardDTO;
|
||||
@@ -4770,15 +4770,13 @@ public class SailingServiceImpl extends ProxiedRemoteServiceServlet implements S
|
||||
final String query = null;
|
||||
URL serverAddress = null;
|
||||
InputStream inputStream = null;
|
||||
HttpURLConnection connection = null;
|
||||
URLConnection connection = null;
|
||||
try {
|
||||
URL base = createBaseUrl(url);
|
||||
serverAddress = createUrl(base, path, query);
|
||||
connection = HttpUrlConnectionHelper.redirectConnection(serverAddress);
|
||||
serverAddress = createUrl(base, path, query);
|
||||
connection = HttpUrlConnectionHelper.redirectConnection(serverAddress);
|
||||
inputStream = connection.getInputStream();
|
||||
|
||||
InputStreamReader in = new InputStreamReader(inputStream, "UTF-8");
|
||||
|
||||
org.json.simple.parser.JSONParser parser = new org.json.simple.parser.JSONParser();
|
||||
org.json.simple.JSONArray array = (org.json.simple.JSONArray) parser.parse(in);
|
||||
List<String> names = new ArrayList<String>();
|
||||
@@ -4790,8 +4788,8 @@ public class SailingServiceImpl extends ProxiedRemoteServiceServlet implements S
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
// close the connection
|
||||
if (connection != null) {
|
||||
connection.disconnect();
|
||||
if (connection != null && connection instanceof HttpURLConnection) {
|
||||
((HttpURLConnection) connection).disconnect();
|
||||
}
|
||||
try {
|
||||
if (inputStream != null) {
|
||||
@@ -4843,8 +4841,7 @@ public class SailingServiceImpl extends ProxiedRemoteServiceServlet implements S
|
||||
} catch (UnsupportedEncodingException e1) {
|
||||
throw new RuntimeException(e1);
|
||||
}
|
||||
HttpURLConnection connection = null;
|
||||
|
||||
URLConnection connection = null;
|
||||
URL serverAddress = null;
|
||||
InputStream inputStream = null;
|
||||
try {
|
||||
@@ -4879,8 +4876,8 @@ public class SailingServiceImpl extends ProxiedRemoteServiceServlet implements S
|
||||
} finally {
|
||||
// close the connection, set all objects to null
|
||||
getService().setDataImportDeleteProgressFromMapTimerWithReplication(importOperationId);
|
||||
if (connection != null) {
|
||||
connection.disconnect();
|
||||
if (connection != null && connection instanceof HttpURLConnection) {
|
||||
((HttpURLConnection) connection).disconnect();
|
||||
}
|
||||
connection = null;
|
||||
long timeToImport = System.currentTimeMillis() - startTime;
|
||||
@@ -4933,7 +4930,7 @@ public class SailingServiceImpl extends ProxiedRemoteServiceServlet implements S
|
||||
@Override
|
||||
public Iterable<CompetitorWithBoatDTO> getCompetitors(boolean filterCompetitorsWithBoat, boolean filterCompetitorsWithoutBoat) {
|
||||
Iterable<CompetitorWithBoatDTO> result;
|
||||
CompetitorAndBoatStore competitorStore = getService().getBaseDomainFactory().getCompetitorStore();
|
||||
CompetitorAndBoatStore competitorStore = getService().getBaseDomainFactory().getCompetitorAndBoatStore();
|
||||
if (filterCompetitorsWithBoat == false && filterCompetitorsWithoutBoat == false) {
|
||||
result = convertToCompetitorDTOs(competitorStore.getAllCompetitors());
|
||||
} else if (filterCompetitorsWithBoat == true && filterCompetitorsWithoutBoat == false) {
|
||||
@@ -4969,7 +4966,7 @@ public class SailingServiceImpl extends ProxiedRemoteServiceServlet implements S
|
||||
|
||||
private CompetitorWithBoat addOrUpdateCompetitorWithBoatInternal(CompetitorWithBoatDTO competitor) throws URISyntaxException {
|
||||
CompetitorWithBoat result;
|
||||
CompetitorWithBoat existingCompetitor = getService().getCompetitorStore().getExistingCompetitorWithBoatByIdAsString(competitor.getIdAsString());
|
||||
CompetitorWithBoat existingCompetitor = getService().getCompetitorAndBoatStore().getExistingCompetitorWithBoatByIdAsString(competitor.getIdAsString());
|
||||
Nationality nationality = (competitor.getThreeLetterIocCountryCode() == null || competitor.getThreeLetterIocCountryCode().isEmpty()) ? null :
|
||||
getBaseDomainFactory().getOrCreateNationality(competitor.getThreeLetterIocCountryCode());
|
||||
if (competitor.getIdAsString() == null || competitor.getIdAsString().isEmpty() || existingCompetitor == null) {
|
||||
@@ -5004,7 +5001,7 @@ public class SailingServiceImpl extends ProxiedRemoteServiceServlet implements S
|
||||
|
||||
private Competitor addOrUpdateCompetitorWithoutBoatInternal(CompetitorWithBoatDTO competitor) throws URISyntaxException {
|
||||
Competitor result;
|
||||
Competitor existingCompetitor = getService().getCompetitorStore().getExistingCompetitorByIdAsString(competitor.getIdAsString());
|
||||
Competitor existingCompetitor = getService().getCompetitorAndBoatStore().getExistingCompetitorByIdAsString(competitor.getIdAsString());
|
||||
Nationality nationality = (competitor.getThreeLetterIocCountryCode() == null || competitor.getThreeLetterIocCountryCode().isEmpty()) ? null :
|
||||
getBaseDomainFactory().getOrCreateNationality(competitor.getThreeLetterIocCountryCode());
|
||||
if (competitor.getIdAsString() == null || competitor.getIdAsString().isEmpty() || existingCompetitor == null) {
|
||||
@@ -5048,7 +5045,7 @@ public class SailingServiceImpl extends ProxiedRemoteServiceServlet implements S
|
||||
for (final CompetitorDescriptor competitorDescriptor : competitorDescriptors) {
|
||||
competitorsForSaving.add(getService().convertCompetitorDescriptorToCompetitorWithBoat(competitorDescriptor, searchTag));
|
||||
}
|
||||
getBaseDomainFactory().getCompetitorStore().addNewCompetitorsWithBoat(competitorsForSaving);
|
||||
getBaseDomainFactory().getCompetitorAndBoatStore().addNewCompetitorsWithBoat(competitorsForSaving);
|
||||
return convertToCompetitorDTOs(competitorsForSaving);
|
||||
}
|
||||
|
||||
@@ -5063,12 +5060,12 @@ public class SailingServiceImpl extends ProxiedRemoteServiceServlet implements S
|
||||
|
||||
@Override
|
||||
public Iterable<BoatDTO> getAllBoats() {
|
||||
return convertToBoatDTOs(getService().getBaseDomainFactory().getCompetitorStore().getBoats());
|
||||
return convertToBoatDTOs(getService().getBaseDomainFactory().getCompetitorAndBoatStore().getBoats());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<BoatDTO> getStandaloneBoats() {
|
||||
return convertToBoatDTOs(getService().getBaseDomainFactory().getCompetitorStore().getStandaloneBoats());
|
||||
return convertToBoatDTOs(getService().getBaseDomainFactory().getCompetitorAndBoatStore().getStandaloneBoats());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -5077,7 +5074,7 @@ public class SailingServiceImpl extends ProxiedRemoteServiceServlet implements S
|
||||
}
|
||||
|
||||
private Boat addOrUpdateBoatInternal(BoatDTO boat) {
|
||||
Boat existingBoat = getService().getCompetitorStore().getExistingBoatByIdAsString(boat.getIdAsString());
|
||||
Boat existingBoat = getService().getCompetitorAndBoatStore().getExistingBoatByIdAsString(boat.getIdAsString());
|
||||
final Boat result;
|
||||
if (boat.getIdAsString() == null || boat.getIdAsString().isEmpty() || existingBoat == null) {
|
||||
// new boat
|
||||
@@ -5103,8 +5100,8 @@ public class SailingServiceImpl extends ProxiedRemoteServiceServlet implements S
|
||||
@Override
|
||||
public boolean linkBoatToCompetitorForRace(String leaderboardName, String raceColumnName, String fleetName, String competitorIdAsString, String boatIdAsString) {
|
||||
boolean result = false;
|
||||
Boat existingBoat = getService().getCompetitorStore().getExistingBoatByIdAsString(boatIdAsString);
|
||||
Competitor existingCompetitor = getService().getCompetitorStore().getExistingCompetitorByIdAsString(competitorIdAsString);
|
||||
Boat existingBoat = getService().getCompetitorAndBoatStore().getExistingBoatByIdAsString(boatIdAsString);
|
||||
Competitor existingCompetitor = getService().getCompetitorAndBoatStore().getExistingCompetitorByIdAsString(competitorIdAsString);
|
||||
RaceLog raceLog = getService().getRaceLog(leaderboardName, raceColumnName, fleetName);
|
||||
if (raceLog != null && existingCompetitor != null && existingBoat != null) {
|
||||
raceLog.add(new RaceLogRegisterCompetitorEventImpl(MillisecondsTimePoint.now(),
|
||||
@@ -5117,7 +5114,7 @@ public class SailingServiceImpl extends ProxiedRemoteServiceServlet implements S
|
||||
@Override
|
||||
public boolean unlinkBoatFromCompetitorForRace(String leaderboardName, String raceColumnName, String fleetName, String competitorIdAsString) {
|
||||
boolean result = false;
|
||||
Competitor existingCompetitor = getService().getCompetitorStore().getExistingCompetitorByIdAsString(competitorIdAsString);
|
||||
Competitor existingCompetitor = getService().getCompetitorAndBoatStore().getExistingCompetitorByIdAsString(competitorIdAsString);
|
||||
RaceLog raceLog = getService().getRaceLog(leaderboardName, raceColumnName, fleetName);
|
||||
if (raceLog != null && existingCompetitor != null) {
|
||||
List<RaceLogRegisterCompetitorEvent> linkEventsToRevoke = new ArrayList<>();
|
||||
@@ -5142,7 +5139,7 @@ public class SailingServiceImpl extends ProxiedRemoteServiceServlet implements S
|
||||
@Override
|
||||
public BoatDTO getBoatLinkedToCompetitorForRace(String leaderboardName, String raceColumnName, String fleetName, String competitorIdAsString) {
|
||||
BoatDTO result = null;
|
||||
Competitor existingCompetitor = getService().getCompetitorStore().getExistingCompetitorByIdAsString(competitorIdAsString);
|
||||
Competitor existingCompetitor = getService().getCompetitorAndBoatStore().getExistingCompetitorByIdAsString(competitorIdAsString);
|
||||
Map<Competitor, Boat> competitorToBoatMappingsForRace = getService().getCompetitorToBoatMappingsForRace(leaderboardName, raceColumnName, fleetName);
|
||||
if (existingCompetitor != null) {
|
||||
Boat boatOfCompetitor = competitorToBoatMappingsForRace.get(existingCompetitor);
|
||||
@@ -5542,9 +5539,9 @@ public class SailingServiceImpl extends ProxiedRemoteServiceServlet implements S
|
||||
// can take up to two hours.
|
||||
private static final int DEFAULT_TIMEOUT_IN_SECONDS = 60*60*2;
|
||||
|
||||
private final HttpURLConnection connection;
|
||||
private final URLConnection connection;
|
||||
|
||||
protected TimeoutExtendingInputStream(InputStream in, HttpURLConnection connection) {
|
||||
protected TimeoutExtendingInputStream(InputStream in, URLConnection connection) {
|
||||
super(in);
|
||||
this.connection = connection;
|
||||
}
|
||||
@@ -5618,11 +5615,11 @@ public class SailingServiceImpl extends ProxiedRemoteServiceServlet implements S
|
||||
}
|
||||
|
||||
private Competitor getCompetitor(CompetitorDTO dto) {
|
||||
return getService().getCompetitorStore().getExistingCompetitorByIdAsString(dto.getIdAsString());
|
||||
return getService().getCompetitorAndBoatStore().getExistingCompetitorByIdAsString(dto.getIdAsString());
|
||||
}
|
||||
|
||||
private Boat getBoat(BoatDTO dto) {
|
||||
return getService().getCompetitorStore().getExistingBoatByIdAsString(dto.getIdAsString());
|
||||
return getService().getCompetitorAndBoatStore().getExistingBoatByIdAsString(dto.getIdAsString());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -6004,7 +6001,7 @@ public class SailingServiceImpl extends ProxiedRemoteServiceServlet implements S
|
||||
event = new RegattaLogDeviceMarkMappingEventImpl(now, now, getService().getServerAuthor(), UUID.randomUUID(),
|
||||
mark, mapping.getDevice(), from, to);
|
||||
} else if (dto.mappedTo instanceof CompetitorWithBoatDTO) {
|
||||
Competitor competitor = getService().getCompetitorStore().getExistingCompetitorByIdAsString(
|
||||
Competitor competitor = getService().getCompetitorAndBoatStore().getExistingCompetitorByIdAsString(
|
||||
((CompetitorWithBoatDTO) dto.mappedTo).getIdAsString());
|
||||
if (mapping.getDevice().getIdentifierType().equals(ExpeditionSensorDeviceIdentifier.TYPE)) {
|
||||
event = new RegattaLogDeviceCompetitorExpeditionExtendedMappingEventImpl(
|
||||
@@ -6015,7 +6012,7 @@ public class SailingServiceImpl extends ProxiedRemoteServiceServlet implements S
|
||||
competitor, mapping.getDevice(), from, to);
|
||||
}
|
||||
} else if (dto.mappedTo instanceof BoatDTO) {
|
||||
final Boat boat = getService().getCompetitorStore()
|
||||
final Boat boat = getService().getCompetitorAndBoatStore()
|
||||
.getExistingBoatByIdAsString(((BoatDTO) dto.mappedTo).getIdAsString());
|
||||
event = new RegattaLogDeviceBoatMappingEventImpl(now, now, getService().getServerAuthor(), UUID.randomUUID(),
|
||||
boat, mapping.getDevice(), from, to);
|
||||
@@ -6069,11 +6066,11 @@ public class SailingServiceImpl extends ProxiedRemoteServiceServlet implements S
|
||||
//expect UUIDs
|
||||
return new DeviceMappingImpl<Mark>(mark, device, timeRange, dto.originalRaceLogEventIds, RegattaLogDeviceMarkMappingEventImpl.class);
|
||||
} else if (dto.mappedTo instanceof CompetitorWithBoatDTO) {
|
||||
Competitor competitor = getService().getCompetitorStore().getExistingCompetitorByIdAsString(
|
||||
Competitor competitor = getService().getCompetitorAndBoatStore().getExistingCompetitorByIdAsString(
|
||||
((CompetitorWithBoatDTO) dto.mappedTo).getIdAsString());
|
||||
return new DeviceMappingImpl<Competitor>(competitor, device, timeRange, dto.originalRaceLogEventIds, RegattaLogDeviceCompetitorMappingEventImpl.class);
|
||||
} else if (dto.mappedTo instanceof BoatDTO) {
|
||||
final Boat boat = getService().getCompetitorStore()
|
||||
final Boat boat = getService().getCompetitorAndBoatStore()
|
||||
.getExistingBoatByIdAsString(dto.mappedTo.getIdAsString());
|
||||
return new DeviceMappingImpl<WithID>(boat, device, timeRange, dto.originalRaceLogEventIds,
|
||||
RegattaLogDeviceBoatMappingEventImpl.class);
|
||||
|
||||
+2
-2
@@ -429,8 +429,8 @@ public class TestStoringAndLoadingEventsAndRegattas extends AbstractMongoDBTest
|
||||
DynamicCompetitorWithBoat competitorWithBoat2 = AbstractLeaderboardTest.createCompetitorWithBoat("Humba2");
|
||||
DynamicBoat boat1= AbstractLeaderboardTest.createBoat("Humba1 Boot");
|
||||
DynamicBoat boat2 = AbstractLeaderboardTest.createBoat("Humba2 Boot");
|
||||
res.getCompetitorStore().addNewCompetitors(Arrays.asList(competitorWithBoat1, competitorWithBoat2));
|
||||
res.getCompetitorStore().addNewBoats(Arrays.asList(boat1, boat2));
|
||||
res.getCompetitorAndBoatStore().addNewCompetitors(Arrays.asList(competitorWithBoat1, competitorWithBoat2));
|
||||
res.getCompetitorAndBoatStore().addNewBoats(Arrays.asList(boat1, boat2));
|
||||
regatta.getRegattaLog().add(new RegattaLogRegisterCompetitorEventImpl(MillisecondsTimePoint.now(), new LogEventAuthorImpl("Axel", 0), competitorWithBoat1));
|
||||
regatta.getRegattaLog().add(new RegattaLogRegisterCompetitorEventImpl(MillisecondsTimePoint.now(), new LogEventAuthorImpl("Axel", 0), competitorWithBoat2));
|
||||
assertTrue(Util.contains(regatta.getAllCompetitors(), competitorWithBoat1));
|
||||
|
||||
+1
-1
@@ -72,7 +72,7 @@ public class TestStoringAndRetrievingLeaderboardGroups extends AbstractMongoDBTe
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
DomainFactory.INSTANCE.getCompetitorStore().clearCompetitors();
|
||||
DomainFactory.INSTANCE.getCompetitorAndBoatStore().clearCompetitors();
|
||||
mongoObjectFactory = new MongoObjectFactoryImpl(db);
|
||||
domainObjectFactory = new DomainObjectFactoryImpl(db, DomainFactory.INSTANCE);
|
||||
}
|
||||
|
||||
+1
-1
@@ -52,7 +52,7 @@ public class TestStoringAndRetrievingLeaderboards extends AbstractMongoDBTest {
|
||||
|
||||
@Before
|
||||
public void clearCompetitorStore() {
|
||||
DomainFactory.INSTANCE.getCompetitorStore().clearCompetitors();
|
||||
DomainFactory.INSTANCE.getCompetitorAndBoatStore().clearCompetitors();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
+1
-1
@@ -52,7 +52,7 @@ public class RaceLogFinishPositioningConfirmedEventSerializerTest {
|
||||
SharedDomainFactory factory = DomainFactory.INSTANCE;
|
||||
serializer = new RaceLogFinishPositioningConfirmedEventSerializer(new CompetitorJsonSerializer(
|
||||
new TeamJsonSerializer(new PersonJsonSerializer(new NationalityJsonSerializer())), new BoatJsonSerializer(new BoatClassJsonSerializer())));
|
||||
deserializer = new RaceLogFinishPositioningConfirmedEventDeserializer(new CompetitorJsonDeserializer(factory.getCompetitorStore(), /* team deserializer */ null, /* boat deserializer */ null));
|
||||
deserializer = new RaceLogFinishPositioningConfirmedEventDeserializer(new CompetitorJsonDeserializer(factory.getCompetitorAndBoatStore(), /* team deserializer */ null, /* boat deserializer */ null));
|
||||
now = MillisecondsTimePoint.now();
|
||||
positioningList = new CompetitorResultsImpl();
|
||||
}
|
||||
|
||||
+1
-1
@@ -53,7 +53,7 @@ public class RaceLogWindFixEventSerializerTest {
|
||||
serializer = new RaceLogWindFixEventSerializer(new CompetitorJsonSerializer(new TeamJsonSerializer(
|
||||
new PersonJsonSerializer(new NationalityJsonSerializer())), new BoatJsonSerializer(new BoatClassJsonSerializer())), new WindJsonSerializer(
|
||||
new PositionJsonSerializer()));
|
||||
deserializer = new RaceLogWindFixEventDeserializer(new CompetitorJsonDeserializer(factory.getCompetitorStore(), /* team deserializer */ null, /* boat deserializer */ null),
|
||||
deserializer = new RaceLogWindFixEventDeserializer(new CompetitorJsonDeserializer(factory.getCompetitorAndBoatStore(), /* team deserializer */ null, /* boat deserializer */ null),
|
||||
new WindJsonDeserializer(new PositionJsonDeserializer()));
|
||||
now = MillisecondsTimePoint.now();
|
||||
event = new RaceLogWindFixEventImpl(now, author, 0, createWindFix(), /* isMagnetic */ false);
|
||||
|
||||
Regular → Executable
+1
-1
@@ -45,7 +45,7 @@ public class TrackingTimesEventSerializerTest {
|
||||
}
|
||||
|
||||
private JsonDeserializer<DynamicCompetitor> createCompetitorDeserializer() {
|
||||
return new CompetitorJsonDeserializer(DomainFactory.INSTANCE.getCompetitorStore());
|
||||
return new CompetitorJsonDeserializer(DomainFactory.INSTANCE.getCompetitorAndBoatStore());
|
||||
}
|
||||
|
||||
private JsonDeserializer<RaceLogEvent> createEndOfTrackingEventDeserializer() {
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ public class BoatsResource extends AbstractSailingServerResource {
|
||||
@Path("{boatId}")
|
||||
public Response getBoat(@PathParam("boatId") String boatIdAsString) {
|
||||
Response response;
|
||||
Boat boat = getService().getCompetitorStore().getExistingBoatByIdAsString(boatIdAsString);
|
||||
Boat boat = getService().getCompetitorAndBoatStore().getExistingBoatByIdAsString(boatIdAsString);
|
||||
if (boat == null) {
|
||||
response = Response.status(Status.NOT_FOUND)
|
||||
.entity("Could not find a boat with id '" + StringEscapeUtils.escapeHtml(boatIdAsString) + "'.")
|
||||
|
||||
+4
-4
@@ -75,7 +75,7 @@ public class CompetitorsResource extends AbstractSailingServerResource {
|
||||
@Path("{competitorId}")
|
||||
public Response getCompetitor(@PathParam("competitorId") String competitorIdAsString) {
|
||||
Response response;
|
||||
Competitor competitor = getService().getCompetitorStore().getExistingCompetitorByIdAsString(
|
||||
Competitor competitor = getService().getCompetitorAndBoatStore().getExistingCompetitorByIdAsString(
|
||||
competitorIdAsString);
|
||||
if (competitor == null) {
|
||||
response = Response.status(Status.NOT_FOUND)
|
||||
@@ -92,7 +92,7 @@ public class CompetitorsResource extends AbstractSailingServerResource {
|
||||
@Produces("application/json;charset=UTF-8")
|
||||
@Path("{competitor-id}/team")
|
||||
public Response getTeam(@PathParam("competitor-id") String competitorId) {
|
||||
Competitor competitor = getService().getCompetitorStore().getExistingCompetitorByIdAsString(competitorId);
|
||||
Competitor competitor = getService().getCompetitorAndBoatStore().getExistingCompetitorByIdAsString(competitorId);
|
||||
if (competitor == null) {
|
||||
return Response.status(Status.NOT_FOUND)
|
||||
.entity("Could not find a competitor with id '" + StringEscapeUtils.escapeHtml(competitorId) + "'.").type(MediaType.TEXT_PLAIN)
|
||||
@@ -126,7 +126,7 @@ public class CompetitorsResource extends AbstractSailingServerResource {
|
||||
public String setTeamImage(@PathParam("competitor-id") String competitorId, InputStream uploadedInputStream,
|
||||
@HeaderParam("Content-Type") String fileType, @HeaderParam("Content-Length") long sizeInBytes) throws IOException {
|
||||
RacingEventService service = getService();
|
||||
CompetitorAndBoatStore store = service.getCompetitorStore();
|
||||
CompetitorAndBoatStore store = service.getCompetitorAndBoatStore();
|
||||
Competitor competitor = store.getExistingCompetitorByIdAsString(competitorId);
|
||||
if (competitor == null) {
|
||||
logger.log(Level.INFO, "Could not find competitor to store image for: " + StringEscapeUtils.escapeHtml(competitorId));
|
||||
@@ -162,7 +162,7 @@ public class CompetitorsResource extends AbstractSailingServerResource {
|
||||
.entity("Could not store competitor image").type(MediaType.TEXT_PLAIN).build());
|
||||
}
|
||||
|
||||
getService().getCompetitorStore().updateCompetitor(competitorId, competitor.getName(), competitor.getShortName(),
|
||||
getService().getCompetitorAndBoatStore().updateCompetitor(competitorId, competitor.getName(), competitor.getShortName(),
|
||||
competitor.getColor(), competitor.getEmail(),
|
||||
competitor.getTeam().getNationality(), imageUri, competitor.getFlagImage(),
|
||||
/* timeOnTimeFactor */ null, /* timeOnDistanceAllowancePerNauticalMile */ null, competitor.getSearchTag());
|
||||
|
||||
+5
-5
@@ -286,7 +286,7 @@ public class LeaderboardsResource extends AbstractLeaderboardsResource {
|
||||
final Named mappedTo;
|
||||
if (competitorId != null) {
|
||||
// map to a competitor
|
||||
final Competitor mappedToCompetitor = domainFactory.getCompetitorStore().getExistingCompetitorByIdAsString(competitorId);
|
||||
final Competitor mappedToCompetitor = domainFactory.getCompetitorAndBoatStore().getExistingCompetitorByIdAsString(competitorId);
|
||||
mappedTo = mappedToCompetitor;
|
||||
if (mappedToCompetitor == null) {
|
||||
logger.warning("No competitor found for id " + competitorId);
|
||||
@@ -304,7 +304,7 @@ public class LeaderboardsResource extends AbstractLeaderboardsResource {
|
||||
from, /* to */ null);
|
||||
} else if (boatId != null) {
|
||||
// map to a boat
|
||||
final Boat mappedToBoat = domainFactory.getCompetitorStore().getExistingBoatByIdAsString(boatId);
|
||||
final Boat mappedToBoat = domainFactory.getCompetitorAndBoatStore().getExistingBoatByIdAsString(boatId);
|
||||
mappedTo = mappedToBoat;
|
||||
if (mappedToBoat == null) {
|
||||
logger.warning("No boat found for id " + boatId);
|
||||
@@ -378,7 +378,7 @@ public class LeaderboardsResource extends AbstractLeaderboardsResource {
|
||||
}
|
||||
final NamedWithID mappedTo;
|
||||
if (competitorId != null) {
|
||||
final Competitor mappedToCompetitor = getService().getCompetitorStore().getExistingCompetitorByIdAsString(competitorId);
|
||||
final Competitor mappedToCompetitor = getService().getCompetitorAndBoatStore().getExistingCompetitorByIdAsString(competitorId);
|
||||
mappedTo = mappedToCompetitor;
|
||||
if (mappedToCompetitor == null) {
|
||||
logger.warning("No competitor found for id " + competitorId);
|
||||
@@ -386,7 +386,7 @@ public class LeaderboardsResource extends AbstractLeaderboardsResource {
|
||||
.type(MediaType.TEXT_PLAIN).build();
|
||||
}
|
||||
} else if (boatId != null) {
|
||||
final Boat mappedToBoat = getService().getCompetitorStore().getExistingBoatByIdAsString(boatId);
|
||||
final Boat mappedToBoat = getService().getCompetitorAndBoatStore().getExistingBoatByIdAsString(boatId);
|
||||
mappedTo = mappedToBoat;
|
||||
if (mappedToBoat == null) {
|
||||
logger.warning("No boat found for id " + boatId);
|
||||
@@ -433,7 +433,7 @@ public class LeaderboardsResource extends AbstractLeaderboardsResource {
|
||||
@PathParam("competitorId") String competitorIdAsString) {
|
||||
Response response;
|
||||
Leaderboard leaderboard = getService().getLeaderboardByName(leaderboardName);
|
||||
Competitor competitor = getService().getCompetitorStore().getExistingCompetitorByIdAsString(
|
||||
Competitor competitor = getService().getCompetitorAndBoatStore().getExistingCompetitorByIdAsString(
|
||||
competitorIdAsString);
|
||||
|
||||
if (competitor == null) {
|
||||
|
||||
+3
-3
@@ -295,7 +295,7 @@ public class RegattasResource extends AbstractSailingServerResource {
|
||||
competitorId = competitorIdAsString;
|
||||
}
|
||||
|
||||
final Competitor competitor = getService().getCompetitorStore().getExistingCompetitorById(competitorId);
|
||||
final Competitor competitor = getService().getCompetitorAndBoatStore().getExistingCompetitorById(competitorId);
|
||||
if (competitor == null) {
|
||||
response = getBadCompetitorIdResponse(competitorId);
|
||||
} else {
|
||||
@@ -328,7 +328,7 @@ public class RegattasResource extends AbstractSailingServerResource {
|
||||
final Boat boat = new BoatImpl(UUID.randomUUID(), user.getName(),
|
||||
getService().getBaseDomainFactory().getOrCreateBoatClass(boatClassName, /* typicallyStartsUpwind */ true),
|
||||
sailId);
|
||||
final CompetitorWithBoat competitor = getService().getCompetitorStore().getOrCreateCompetitorWithBoat(UUID.randomUUID(),
|
||||
final CompetitorWithBoat competitor = getService().getCompetitorAndBoatStore().getOrCreateCompetitorWithBoat(UUID.randomUUID(),
|
||||
user.getFullName() == null ? user.getName() : user.getFullName(), /* shortName */ null,
|
||||
/* displayColor */ null, user.getEmail(), /* flagImageURI */ null,
|
||||
new TeamImpl(user.getName(), Collections.singleton(new PersonImpl(user.getFullName() == null ? user.getName() : user.getFullName(),
|
||||
@@ -363,7 +363,7 @@ public class RegattasResource extends AbstractSailingServerResource {
|
||||
competitorId = competitorIdAsString;
|
||||
}
|
||||
|
||||
final Competitor competitor = getService().getCompetitorStore().getExistingCompetitorById(competitorId);
|
||||
final Competitor competitor = getService().getCompetitorAndBoatStore().getExistingCompetitorById(competitorId);
|
||||
if (competitor == null) {
|
||||
response = getBadCompetitorIdResponse(competitorId);
|
||||
} else {
|
||||
|
||||
+2
-2
@@ -53,7 +53,7 @@ public abstract class AbstractServerReplicationTest extends com.sap.sse.replicat
|
||||
@Override public DomainObjectFactory getDomainObjectFactory() { return PersistenceFactory.INSTANCE.getDomainObjectFactory(mongoDBService, baseDomainFactory); }
|
||||
@Override public MongoObjectFactory getMongoObjectFactory() { return mongoObjectFactory; }
|
||||
@Override public DomainFactory getBaseDomainFactory() { return baseDomainFactory; }
|
||||
@Override public CompetitorAndBoatStore getCompetitorStore() { return getBaseDomainFactory().getCompetitorStore(); }
|
||||
@Override public CompetitorAndBoatStore getCompetitorAndBoatStore() { return getBaseDomainFactory().getCompetitorAndBoatStore(); }
|
||||
};
|
||||
}, MediaDBFactory.INSTANCE.getMediaDB(mongoDBService), EmptyWindStore.INSTANCE, EmptySensorFixStore.INSTANCE, null, null, /* sailingNotificationService */ null,
|
||||
/* trackedRaceStatisticsCache */ null, /* restoreTrackedRaces */ false);
|
||||
@@ -72,7 +72,7 @@ public abstract class AbstractServerReplicationTest extends com.sap.sse.replicat
|
||||
@Override public DomainObjectFactory getDomainObjectFactory() { return domainObjectFactory; }
|
||||
@Override public MongoObjectFactory getMongoObjectFactory() { return mongoObjectFactory; }
|
||||
@Override public DomainFactory getBaseDomainFactory() { return domainObjectFactory.getBaseDomainFactory(); }
|
||||
@Override public CompetitorAndBoatStore getCompetitorStore() { return getBaseDomainFactory().getCompetitorStore(); }
|
||||
@Override public CompetitorAndBoatStore getCompetitorAndBoatStore() { return getBaseDomainFactory().getCompetitorAndBoatStore(); }
|
||||
};
|
||||
}, MediaDBFactory.INSTANCE.getMediaDB(mongoDBService), EmptyWindStore.INSTANCE, EmptySensorFixStore.INSTANCE,
|
||||
/* serviceFinderFactory */ null, null, /* sailingNotificationService */ null,
|
||||
|
||||
+2
-2
@@ -121,7 +121,7 @@ public class BoatReplicationTest extends AbstractServerReplicationTest {
|
||||
// now allow for resetting to default through some event, such as receiving a GPS position
|
||||
master.apply(new AllowBoatResetToDefaults(Collections.singleton(boat.getId().toString())));
|
||||
// modify the boat on the master "from below" without an UpdateBoat operation, only locally:
|
||||
master.getBaseDomainFactory().getCompetitorStore().updateBoat(boat.getId().toString(), boatName, boat.getColor(), boat.getSailID());
|
||||
master.getBaseDomainFactory().getCompetitorAndBoatStore().updateBoat(boat.getId().toString(), boatName, boat.getColor(), boat.getSailID());
|
||||
|
||||
|
||||
final RegattaAndRaceIdentifier raceIdentifier = masterRegatta.getRaceIdentifier(raceDefinition);
|
||||
@@ -146,7 +146,7 @@ public class BoatReplicationTest extends AbstractServerReplicationTest {
|
||||
BoatClass boatClass = new BoatClassImpl("Kielzugvogel", true);
|
||||
Boat boat = master.getBaseDomainFactory().getOrCreateBoat(123, boatName, boatClass, "GER 123", null);
|
||||
Thread.sleep(1000);
|
||||
assertTrue(StreamSupport.stream(replica.getBaseDomainFactory().getCompetitorStore().getBoats().spliterator(), /* parallel */ false).anyMatch(
|
||||
assertTrue(StreamSupport.stream(replica.getBaseDomainFactory().getCompetitorAndBoatStore().getBoats().spliterator(), /* parallel */ false).anyMatch(
|
||||
b-> b.getId().equals(boat.getId())));
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -135,7 +135,7 @@ public class CompetitorReplicationTest extends AbstractServerReplicationTest {
|
||||
// now allow for resetting to default through some event, such as receiving a GPS position
|
||||
master.apply(new AllowCompetitorResetToDefaults(Collections.singleton(competitor.getId().toString())));
|
||||
// modify the competitor on the master "from below" without an UpdateCompetitor operation, only locally:
|
||||
master.getBaseDomainFactory().getCompetitorStore().updateCompetitor(competitor.getId().toString(), competitorName, competitorShortName, Color.RED, competitor.getEmail(),
|
||||
master.getBaseDomainFactory().getCompetitorAndBoatStore().updateCompetitor(competitor.getId().toString(), competitorName, competitorShortName, Color.RED, competitor.getEmail(),
|
||||
competitor.getTeam().getNationality(), competitor.getTeam().getImage(), competitor.getFlagImage(),
|
||||
/* timeOnTimeFactor */ null, /* timeOnDistanceAllowancePerNauticalMile */ null, null);
|
||||
final RegattaAndRaceIdentifier raceIdentifier = masterRegatta.getRaceIdentifier(raceDefinition);
|
||||
@@ -166,7 +166,7 @@ public class CompetitorReplicationTest extends AbstractServerReplicationTest {
|
||||
/* dateOfBirth */null, "This is Rigo, the coach")),
|
||||
/* timeOnTimeFactor */ null, /* timeOnDistanceAllowanceInSecondsPerNauticalMile */ null, null);
|
||||
Thread.sleep(1000);
|
||||
assertTrue(StreamSupport.stream(replica.getBaseDomainFactory().getCompetitorStore().getAllCompetitors().spliterator(), /* parallel */ false).anyMatch(
|
||||
assertTrue(StreamSupport.stream(replica.getBaseDomainFactory().getCompetitorAndBoatStore().getAllCompetitors().spliterator(), /* parallel */ false).anyMatch(
|
||||
c->
|
||||
c.getId().equals(competitor.getId())));
|
||||
}
|
||||
|
||||
+2
-2
@@ -77,12 +77,12 @@ public class TrackedRaceContentsReplicationTest extends AbstractServerReplicatio
|
||||
// FIXME use master DomainFactory; see bug 592
|
||||
final DomainFactory masterDomainFactory = testSetUp.getMaster().getBaseDomainFactory();
|
||||
BoatClass boatClass = masterDomainFactory.getOrCreateBoatClass(boatClassName, /* typicallyStartsUpwind */true);
|
||||
competitor = masterDomainFactory.getCompetitorStore().getOrCreateCompetitor("GER 61", "Tina Lutz", "TL", Color.RED, "someone@nowhere.de", null, new TeamImpl("Tina Lutz + Susann Beucke",
|
||||
competitor = masterDomainFactory.getCompetitorAndBoatStore().getOrCreateCompetitor("GER 61", "Tina Lutz", "TL", Color.RED, "someone@nowhere.de", null, new TeamImpl("Tina Lutz + Susann Beucke",
|
||||
(List<PersonImpl>) Arrays.asList(new PersonImpl[] { new PersonImpl("Tina Lutz", masterDomainFactory.getOrCreateNationality("GER"), null, null),
|
||||
new PersonImpl("Tina Lutz", masterDomainFactory.getOrCreateNationality("GER"), null, null) }),
|
||||
new PersonImpl("Rigo de Mas", masterDomainFactory.getOrCreateNationality("NED"), null, null)),
|
||||
/* timeOnTimeFactor */ null, /* timeOnDistanceAllowanceInSecondsPerNauticalMile */ null, null);
|
||||
Boat boat = masterDomainFactory.getCompetitorStore().getOrCreateBoat("boat123", "boat123",
|
||||
Boat boat = masterDomainFactory.getCompetitorAndBoatStore().getOrCreateBoat("boat123", "boat123",
|
||||
masterDomainFactory.getOrCreateBoatClass("470", /* typicallyStartsUpwind */ true), "GER 61", null);
|
||||
Map<Competitor, Boat> competitorAndBoats = new HashMap<>();
|
||||
competitorAndBoats.put(competitor, boat);
|
||||
|
||||
+2
-2
@@ -79,12 +79,12 @@ public class TrackedRaceWithGPSFixStoreContentsReplicationTest extends AbstractS
|
||||
final DomainFactory masterDomainFactory = testSetUp.getMaster().getBaseDomainFactory();
|
||||
BoatClass boatClass = masterDomainFactory.getOrCreateBoatClass(boatClassName, /* typicallyStartsUpwind */true);
|
||||
BoatClass boatClass470 = DomainFactory.INSTANCE.getOrCreateBoatClass("470", /* typicallyStartsUpwind */ true);
|
||||
competitor = masterDomainFactory.getCompetitorStore().getOrCreateCompetitor("GER 61", "Tina Lutz", "TL", Color.RED, "someone@nowhere.de", null, new TeamImpl("Tina Lutz + Susann Beucke",
|
||||
competitor = masterDomainFactory.getCompetitorAndBoatStore().getOrCreateCompetitor("GER 61", "Tina Lutz", "TL", Color.RED, "someone@nowhere.de", null, new TeamImpl("Tina Lutz + Susann Beucke",
|
||||
(List<PersonImpl>) Arrays.asList(new PersonImpl[] { new PersonImpl("Tina Lutz", DomainFactory.INSTANCE.getOrCreateNationality("GER"), null, null),
|
||||
new PersonImpl("Tina Lutz", DomainFactory.INSTANCE.getOrCreateNationality("GER"), null, null) }),
|
||||
new PersonImpl("Rigo de Mas", DomainFactory.INSTANCE.getOrCreateNationality("NED"), null, null)),
|
||||
/* timeOnTimeFactor */ null, /* timeOnDistanceAllowanceInSecondsPerNauticalMile */ null, null);
|
||||
Boat boat = masterDomainFactory.getCompetitorStore().getOrCreateBoat("boat", "GER 61", boatClass470, "GER 61", null);
|
||||
Boat boat = masterDomainFactory.getCompetitorAndBoatStore().getOrCreateBoat("boat", "GER 61", boatClass470, "GER 61", null);
|
||||
final String baseEventName = "Test Event";
|
||||
AddDefaultRegatta addEventOperation = new AddDefaultRegatta(RegattaImpl.getDefaultName(baseEventName, boatClassName), boatClassName,
|
||||
/*startDate*/ null, /*endDate*/ null, UUID.randomUUID());
|
||||
|
||||
+1
-1
@@ -60,7 +60,7 @@ public class ApplyScoresFromRaceLogTest extends LeaderboardScoringAndRankingTest
|
||||
competitors = new ArrayList<>();
|
||||
for (int i=0; i<numberOfCompetitors; i++) {
|
||||
final String competitorName = "C"+i;
|
||||
competitors.add(service.getBaseDomainFactory().getCompetitorStore().getOrCreateCompetitor(UUID.randomUUID(),
|
||||
competitors.add(service.getBaseDomainFactory().getCompetitorAndBoatStore().getOrCreateCompetitor(UUID.randomUUID(),
|
||||
competitorName, "c", /* displayColor */ Color.RED, /* email */ null, /* flagImageURI */ null,
|
||||
new TeamImpl("STG", Collections.singleton(
|
||||
new PersonImpl(competitorName, new NationalityImpl("GER"),
|
||||
|
||||
+5
-5
@@ -433,7 +433,7 @@ public class MasterDataImportTest {
|
||||
|
||||
// Check for suppressed competitor
|
||||
Assert.assertTrue(leaderboardOnTarget.getSuppressedCompetitors().iterator().hasNext());
|
||||
Competitor suppressedCompetitorOnTarget = domainFactory.getCompetitorStore().getExistingCompetitorById(
|
||||
Competitor suppressedCompetitorOnTarget = domainFactory.getCompetitorAndBoatStore().getExistingCompetitorById(
|
||||
competitorToSuppressUUID);
|
||||
Assert.assertEquals(suppressedCompetitorOnTarget, leaderboardOnTarget.getSuppressedCompetitors().iterator()
|
||||
.next());
|
||||
@@ -659,7 +659,7 @@ public class MasterDataImportTest {
|
||||
|
||||
Assert.assertTrue(leaderboardOnTarget.getScoreCorrection().hasCorrectionFor(raceColumnOnTarget));
|
||||
Competitor competitorOnTarget = domainFactory.getExistingCompetitorById(competitorUUID);
|
||||
Competitor competitorOnTarget2 = domainFactory.getCompetitorStore().getExistingCompetitorById(competitor2UUID);
|
||||
Competitor competitorOnTarget2 = domainFactory.getCompetitorAndBoatStore().getExistingCompetitorById(competitor2UUID);
|
||||
Set<Competitor> competitorsCreatedOnTarget = new HashSet<Competitor>();
|
||||
competitorsCreatedOnTarget.add(competitorOnTarget);
|
||||
|
||||
@@ -911,7 +911,7 @@ public class MasterDataImportTest {
|
||||
sailors2.add(new PersonImpl("Test Mustermann", new NationalityImpl("GER"), new Date(645487200000L), "desc"));
|
||||
DynamicPerson coach2 = new PersonImpl("Max Test", new NationalityImpl("GER"), new Date(645487200000L), "desc");
|
||||
DynamicTeam team2 = new TeamImpl("Pros2", sailors2, coach2);
|
||||
Competitor competitor2 = sourceDomainFactory.getCompetitorStore().getOrCreateCompetitor(competitor2UUID,
|
||||
Competitor competitor2 = sourceDomainFactory.getCompetitorAndBoatStore().getOrCreateCompetitor(competitor2UUID,
|
||||
"Froderik", "F", Color.RED, "noone@nowhere.de", null, team2, /* timeOnTimeFactor */null, /* timeOnDistanceAllowanceInSecondsPerNauticalMile */
|
||||
null, null);
|
||||
competitors.add(competitor2);
|
||||
@@ -987,7 +987,7 @@ public class MasterDataImportTest {
|
||||
Assert.assertNotNull(raceColumnOnTarget);
|
||||
|
||||
Assert.assertTrue(leaderboardOnTarget.getScoreCorrection().hasCorrectionFor(raceColumnOnTarget));
|
||||
Competitor competitorOnTarget = domainFactory.getCompetitorStore().getExistingCompetitorById(competitorUUID);
|
||||
Competitor competitorOnTarget = domainFactory.getCompetitorAndBoatStore().getExistingCompetitorById(competitorUUID);
|
||||
Set<Competitor> competitorsCreatedOnTarget = new HashSet<Competitor>();
|
||||
competitorsCreatedOnTarget.add(competitorOnTarget);
|
||||
|
||||
@@ -2306,7 +2306,7 @@ public class MasterDataImportTest {
|
||||
|
||||
// Check for suppressed competitor
|
||||
Assert.assertTrue(leaderboardOnTarget.getSuppressedCompetitors().iterator().hasNext());
|
||||
Competitor suppressedCompetitorOnTarget = domainFactory.getCompetitorStore().getExistingCompetitorById(
|
||||
Competitor suppressedCompetitorOnTarget = domainFactory.getCompetitorAndBoatStore().getExistingCompetitorById(
|
||||
competitorToSuppressUUID);
|
||||
Assert.assertEquals(suppressedCompetitorOnTarget, leaderboardOnTarget.getSuppressedCompetitors().iterator()
|
||||
.next());
|
||||
|
||||
@@ -606,7 +606,7 @@ public interface RacingEventService extends TrackedRegattaRegistry, RegattaFetch
|
||||
*/
|
||||
AbstractLogEventAuthor getServerAuthor();
|
||||
|
||||
CompetitorAndBoatStore getCompetitorStore();
|
||||
CompetitorAndBoatStore getCompetitorAndBoatStore();
|
||||
|
||||
TypeBasedServiceFinderFactory getTypeBasedServiceFinderFactory();
|
||||
|
||||
|
||||
+3
-3
@@ -50,17 +50,17 @@ public class PersistentCompetitorAndBoatStore extends TransientCompetitorAndBoat
|
||||
private static final Logger logger = Logger.getLogger(PersistentCompetitorAndBoatStore.class.getName());
|
||||
|
||||
/**
|
||||
* @param clearCompetitorsAndBaots
|
||||
* @param clearCompetitorsAndBoats
|
||||
* if <code>true</code>, the persistent competitor and boats store is initially cleared, with all persistent
|
||||
* competitor and boat data removed; use with caution!
|
||||
*/
|
||||
public PersistentCompetitorAndBoatStore(MongoObjectFactory storeTo, boolean clearCompetitorsAndBaots,
|
||||
public PersistentCompetitorAndBoatStore(MongoObjectFactory storeTo, boolean clearCompetitorsAndBoats,
|
||||
TypeBasedServiceFinderFactory serviceFinderFactory, RaceLogResolver raceLogResolver) {
|
||||
DomainFactoryImpl baseDomainFactory = new DomainFactoryImpl(this, raceLogResolver);
|
||||
this.loadFrom = PersistenceFactory.INSTANCE.getDomainObjectFactory(MongoDBService.INSTANCE, baseDomainFactory, serviceFinderFactory);
|
||||
this.storeTo = storeTo;
|
||||
migrateCompetitorsIfRequired();
|
||||
if (clearCompetitorsAndBaots) {
|
||||
if (clearCompetitorsAndBoats) {
|
||||
storeTo.removeAllBoats();
|
||||
storeTo.removeAllCompetitors();
|
||||
} else {
|
||||
|
||||
+19
-19
@@ -381,7 +381,7 @@ public class RacingEventServiceImpl implements RacingEventService, ClearStateTes
|
||||
*/
|
||||
private final NamedReentrantReadWriteLock leaderboardGroupsByNameLock;
|
||||
|
||||
private final CompetitorAndBoatStore competitorStore;
|
||||
private final CompetitorAndBoatStore competitorAndBoatStore;
|
||||
|
||||
/**
|
||||
* A set based on a concurrent hash map, therefore being thread safe
|
||||
@@ -518,11 +518,11 @@ public class RacingEventServiceImpl implements RacingEventService, ClearStateTes
|
||||
DomainObjectFactory getDomainObjectFactory();
|
||||
MongoObjectFactory getMongoObjectFactory();
|
||||
com.sap.sailing.domain.base.DomainFactory getBaseDomainFactory();
|
||||
CompetitorAndBoatStore getCompetitorStore();
|
||||
CompetitorAndBoatStore getCompetitorAndBoatStore();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a {@link DomainFactory base domain factory} that uses this object's {@link #competitorStore competitor
|
||||
* Constructs a {@link DomainFactory base domain factory} that uses this object's {@link #competitorAndBoatStore competitor
|
||||
* store} for competitor and boat management. This base domain factory is then also used for the construction of the
|
||||
* {@link DomainObjectFactory}. This constructor variant initially clears the persistent competitor and boat collections,
|
||||
* hence removes all previously persistent competitors and boats. This is the default for testing and for backward
|
||||
@@ -589,7 +589,7 @@ public class RacingEventServiceImpl implements RacingEventService, ClearStateTes
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompetitorAndBoatStore getCompetitorStore() {
|
||||
public CompetitorAndBoatStore getCompetitorAndBoatStore() {
|
||||
return competitorStore;
|
||||
}
|
||||
};
|
||||
@@ -623,7 +623,7 @@ public class RacingEventServiceImpl implements RacingEventService, ClearStateTes
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompetitorAndBoatStore getCompetitorStore() {
|
||||
public CompetitorAndBoatStore getCompetitorAndBoatStore() {
|
||||
return competitorStore;
|
||||
}
|
||||
};
|
||||
@@ -651,8 +651,8 @@ public class RacingEventServiceImpl implements RacingEventService, ClearStateTes
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompetitorAndBoatStore getCompetitorStore() {
|
||||
return getBaseDomainFactory().getCompetitorStore();
|
||||
public CompetitorAndBoatStore getCompetitorAndBoatStore() {
|
||||
return getBaseDomainFactory().getCompetitorAndBoatStore();
|
||||
}
|
||||
};
|
||||
}, mediaDB, windStore, sensorFixStore, null, null, /* sailingNotificationService */ null,
|
||||
@@ -701,14 +701,14 @@ public class RacingEventServiceImpl implements RacingEventService, ClearStateTes
|
||||
this.baseDomainFactory = constructorParameters.getBaseDomainFactory();
|
||||
this.mongoObjectFactory = constructorParameters.getMongoObjectFactory();
|
||||
this.mediaDB = mediaDb;
|
||||
this.competitorStore = constructorParameters.getCompetitorStore();
|
||||
this.competitorAndBoatStore = constructorParameters.getCompetitorAndBoatStore();
|
||||
try {
|
||||
this.windStore = windStore == null ? MongoWindStoreFactory.INSTANCE.getMongoWindStore(mongoObjectFactory,
|
||||
domainObjectFactory) : windStore;
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
this.competitorStore.addCompetitorUpdateListener(new CompetitorUpdateListener() {
|
||||
this.competitorAndBoatStore.addCompetitorUpdateListener(new CompetitorUpdateListener() {
|
||||
@Override
|
||||
public void competitorUpdated(Competitor competitor) {
|
||||
replicate(new UpdateCompetitor(competitor.getId().toString(), competitor.getName(), competitor.getShortName(), competitor
|
||||
@@ -726,7 +726,7 @@ public class RacingEventServiceImpl implements RacingEventService, ClearStateTes
|
||||
competitor.getTimeOnDistanceAllowancePerNauticalMile(), competitor.getSearchTag()));
|
||||
}
|
||||
});
|
||||
this.competitorStore.addBoatUpdateListener(new BoatUpdateListener() {
|
||||
this.competitorAndBoatStore.addBoatUpdateListener(new BoatUpdateListener() {
|
||||
@Override
|
||||
public void boatUpdated(Boat boat) {
|
||||
replicate(new UpdateBoat(boat.getId().toString(), boat.getName(), boat.getColor(), boat.getSailID()));
|
||||
@@ -869,7 +869,7 @@ public class RacingEventServiceImpl implements RacingEventService, ClearStateTes
|
||||
mediaTrackDeleted(mediaTrack);
|
||||
}
|
||||
// TODO clear user store? See bug 2430.
|
||||
this.competitorStore.clear();
|
||||
this.competitorAndBoatStore.clear();
|
||||
this.windStore.clear();
|
||||
getRaceLogStore().clear();
|
||||
getRegattaLogStore().clear();
|
||||
@@ -2937,8 +2937,8 @@ public class RacingEventServiceImpl implements RacingEventService, ClearStateTes
|
||||
logoutput.append(String.format("%3s\n", lg.toString()));
|
||||
}
|
||||
logger.info("Serializing persisted competitors...");
|
||||
oos.writeObject(competitorStore);
|
||||
logoutput.append("Serialized " + competitorStore.getCompetitorsCount() + " persisted competitors\n");
|
||||
oos.writeObject(competitorAndBoatStore);
|
||||
logoutput.append("Serialized " + competitorAndBoatStore.getCompetitorsCount() + " persisted competitors\n");
|
||||
|
||||
logger.info("Serializing configuration map...");
|
||||
oos.writeObject(configurationMap);
|
||||
@@ -3052,19 +3052,19 @@ public class RacingEventServiceImpl implements RacingEventService, ClearStateTes
|
||||
// whose classes implement IsManagedByCache, should already have been got/created from/in the
|
||||
// competitor store
|
||||
if (dynamicCompetitor.hasBoat()) {
|
||||
competitorStore.getOrCreateCompetitorWithBoat(dynamicCompetitor.getId(), dynamicCompetitor.getName(), dynamicCompetitor.getShortName(),
|
||||
competitorAndBoatStore.getOrCreateCompetitorWithBoat(dynamicCompetitor.getId(), dynamicCompetitor.getName(), dynamicCompetitor.getShortName(),
|
||||
dynamicCompetitor.getColor(), dynamicCompetitor.getEmail(), dynamicCompetitor.getFlagImage(),
|
||||
dynamicCompetitor.getTeam(), dynamicCompetitor.getTimeOnTimeFactor(),
|
||||
dynamicCompetitor.getTimeOnDistanceAllowancePerNauticalMile(), dynamicCompetitor.getSearchTag(),
|
||||
((DynamicCompetitorWithBoat) dynamicCompetitor).getBoat());
|
||||
} else {
|
||||
competitorStore.getOrCreateCompetitor(dynamicCompetitor.getId(), dynamicCompetitor.getName(), dynamicCompetitor.getShortName(),
|
||||
competitorAndBoatStore.getOrCreateCompetitor(dynamicCompetitor.getId(), dynamicCompetitor.getName(), dynamicCompetitor.getShortName(),
|
||||
dynamicCompetitor.getColor(), dynamicCompetitor.getEmail(), dynamicCompetitor.getFlagImage(),
|
||||
dynamicCompetitor.getTeam(), dynamicCompetitor.getTimeOnTimeFactor(),
|
||||
dynamicCompetitor.getTimeOnDistanceAllowancePerNauticalMile(), dynamicCompetitor.getSearchTag());
|
||||
}
|
||||
}
|
||||
logoutput.append("Received " + competitorStore.getCompetitorsCount() + " NEW competitors\n");
|
||||
logoutput.append("Received " + competitorAndBoatStore.getCompetitorsCount() + " NEW competitors\n");
|
||||
|
||||
logger.info("Reading device configurations...");
|
||||
configurationMap.putAll((DeviceConfigurationMapImpl) ois.readObject());
|
||||
@@ -3166,7 +3166,7 @@ public class RacingEventServiceImpl implements RacingEventService, ClearStateTes
|
||||
connectivityParametersByRace.clear();
|
||||
eventsById.clear();
|
||||
mediaLibrary.clear();
|
||||
competitorStore.clearCompetitors();
|
||||
competitorAndBoatStore.clearCompetitors();
|
||||
remoteSailingServerSet.clear();
|
||||
if (notificationService != null) {
|
||||
notificationService.stop();
|
||||
@@ -3701,8 +3701,8 @@ public class RacingEventServiceImpl implements RacingEventService, ClearStateTes
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompetitorAndBoatStore getCompetitorStore() {
|
||||
return competitorStore;
|
||||
public CompetitorAndBoatStore getCompetitorAndBoatStore() {
|
||||
return competitorAndBoatStore;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@ public class CompetitorNotificationPreferences extends AbstractGenericSerializab
|
||||
|
||||
public CompetitorNotificationPreferences(RacingEventService racingEventService) {
|
||||
competitors = new SettingsList<>("competitors", this,
|
||||
() -> new CompetitorNotificationPreference(racingEventService.getCompetitorStore()));
|
||||
() -> new CompetitorNotificationPreference(racingEventService.getCompetitorAndBoatStore()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
-1
@@ -65,7 +65,7 @@ public class MasterDataImporter {
|
||||
}
|
||||
|
||||
private void setAllowCompetitorsDataToBeReset(List<Serializable> competitorIds) {
|
||||
CompetitorAndBoatStore store = baseDomainFactory.getCompetitorStore();
|
||||
CompetitorAndBoatStore store = baseDomainFactory.getCompetitorAndBoatStore();
|
||||
for (Serializable id : competitorIds) {
|
||||
Competitor competitor = baseDomainFactory.getExistingCompetitorById(id);
|
||||
if (competitor != null) {
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@ public class AllowBoatResetToDefaults extends AbstractRacingEventServiceOperatio
|
||||
|
||||
@Override
|
||||
public Void internalApplyTo(RacingEventService toState) throws Exception {
|
||||
final CompetitorAndBoatStore competitorAndBoatStore = toState.getBaseDomainFactory().getCompetitorStore();
|
||||
final CompetitorAndBoatStore competitorAndBoatStore = toState.getBaseDomainFactory().getCompetitorAndBoatStore();
|
||||
for (String boatIdAsString : boatIdsAsStrings) {
|
||||
DynamicBoat boat = competitorAndBoatStore.getExistingBoatByIdAsString(boatIdAsString);
|
||||
if (boat != null) {
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@ public class AllowCompetitorResetToDefaults extends AbstractRacingEventServiceOp
|
||||
|
||||
@Override
|
||||
public Void internalApplyTo(RacingEventService toState) throws Exception {
|
||||
final CompetitorAndBoatStore competitorStore = toState.getBaseDomainFactory().getCompetitorStore();
|
||||
final CompetitorAndBoatStore competitorStore = toState.getBaseDomainFactory().getCompetitorAndBoatStore();
|
||||
for (String competitorIdAsString : competitorIdsAsStrings) {
|
||||
Competitor competitor = competitorStore.getExistingCompetitorByIdAsString(competitorIdAsString);
|
||||
if (competitor != null) {
|
||||
|
||||
+1
-1
@@ -36,7 +36,7 @@ public class CreateBoat extends AbstractRacingEventServiceOperation<Boat> {
|
||||
@Override
|
||||
public Boat internalApplyTo(RacingEventService toState) throws Exception {
|
||||
BoatClass boatClass = toState.getBaseDomainFactory().getOrCreateBoatClass(boatClassName);
|
||||
Boat result = toState.getBaseDomainFactory().getCompetitorStore().getOrCreateBoat(boatId, name, boatClass, sailId, color);
|
||||
Boat result = toState.getBaseDomainFactory().getCompetitorAndBoatStore().getOrCreateBoat(boatId, name, boatClass, sailId, color);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -59,7 +59,7 @@ public class CreateCompetitor extends AbstractRacingEventServiceOperation<Compet
|
||||
public Competitor internalApplyTo(RacingEventService toState) throws Exception {
|
||||
DynamicPerson sailor = new PersonImpl(name, nationality, null, null);
|
||||
DynamicTeam team = new TeamImpl(name + " team", Collections.singleton(sailor), null);
|
||||
final Competitor result = toState.getBaseDomainFactory().getCompetitorStore()
|
||||
final Competitor result = toState.getBaseDomainFactory().getCompetitorAndBoatStore()
|
||||
.getOrCreateCompetitor(competitorId, name, shortName, displayColor, email, flagImageUri,
|
||||
team, timeOnTimeFactor, timeOnDistanceAllowancePerNauticalMile, searchTag);
|
||||
return result;
|
||||
|
||||
+1
-1
@@ -34,7 +34,7 @@ public class UpdateBoat extends AbstractRacingEventServiceOperation<Boat> {
|
||||
|
||||
@Override
|
||||
public Boat internalApplyTo(RacingEventService toState) throws Exception {
|
||||
Boat result = toState.getBaseDomainFactory().getCompetitorStore().updateBoat(idAsString, newName, newColor, newSailId);
|
||||
Boat result = toState.getBaseDomainFactory().getCompetitorAndBoatStore().updateBoat(idAsString, newName, newColor, newSailId);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -60,7 +60,7 @@ public class UpdateCompetitor extends AbstractRacingEventServiceOperation<Compet
|
||||
|
||||
@Override
|
||||
public Competitor internalApplyTo(RacingEventService toState) throws Exception {
|
||||
Competitor result = toState.getBaseDomainFactory().getCompetitorStore()
|
||||
Competitor result = toState.getBaseDomainFactory().getCompetitorAndBoatStore()
|
||||
.updateCompetitor(idAsString, newName, newShortName, newDisplayColor, newEmail, newNationality,
|
||||
newTeamImageUri, newFlagImageUri, timeOnTimeFactor, timeOnDistanceAllowancePerNauticalMile, newSearchTag);
|
||||
return result;
|
||||
|
||||
@@ -4,6 +4,7 @@ import java.io.IOException;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
|
||||
import com.sap.sse.common.Duration;
|
||||
|
||||
@@ -14,30 +15,33 @@ public class HttpUrlConnectionHelper {
|
||||
* Redirects the connection using the <code>Location</code> header. Make sure to set
|
||||
* the timeout if you expect the response to take longer.
|
||||
*/
|
||||
public static HttpURLConnection redirectConnection(URL url, Duration timeout) throws MalformedURLException, IOException {
|
||||
HttpURLConnection connection = null;
|
||||
public static URLConnection redirectConnection(URL url, Duration timeout) throws MalformedURLException, IOException {
|
||||
URLConnection urlConnection = null;
|
||||
URL nextUrl = url;
|
||||
for (int counterOfRedirects = 0; counterOfRedirects <= HTTP_MAX_REDIRECTS; counterOfRedirects++) {
|
||||
if (connection != null) {
|
||||
connection.disconnect();
|
||||
}
|
||||
connection = (HttpURLConnection) nextUrl.openConnection();
|
||||
connection.setInstanceFollowRedirects(false);
|
||||
connection.setRequestProperty("User-Agent", "Mozilla/5.0...");
|
||||
connection.setDoOutput(true);
|
||||
connection.setReadTimeout((int) timeout.asMillis());
|
||||
if (connection.getResponseCode() == HttpURLConnection.HTTP_MOVED_PERM
|
||||
|| connection.getResponseCode() == HttpURLConnection.HTTP_MOVED_TEMP) {
|
||||
String location = connection.getHeaderField("Location");
|
||||
nextUrl = new URL(nextUrl, location);
|
||||
urlConnection = nextUrl.openConnection();
|
||||
urlConnection.setRequestProperty("User-Agent", "Mozilla/5.0...");
|
||||
urlConnection.setDoOutput(true);
|
||||
urlConnection.setReadTimeout((int) timeout.asMillis());
|
||||
if (urlConnection instanceof HttpURLConnection) {
|
||||
final HttpURLConnection connection = (HttpURLConnection) urlConnection;
|
||||
connection.setInstanceFollowRedirects(false);
|
||||
if (connection.getResponseCode() == HttpURLConnection.HTTP_MOVED_PERM
|
||||
|| connection.getResponseCode() == HttpURLConnection.HTTP_MOVED_TEMP) {
|
||||
String location = connection.getHeaderField("Location");
|
||||
nextUrl = new URL(nextUrl, location);
|
||||
connection.disconnect();
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
break; // no HTTP URL connection; we need to use what we have...
|
||||
}
|
||||
}
|
||||
return connection;
|
||||
return urlConnection;
|
||||
}
|
||||
|
||||
public static HttpURLConnection redirectConnection(URL url) throws MalformedURLException, IOException {
|
||||
public static URLConnection redirectConnection(URL url) throws MalformedURLException, IOException {
|
||||
return redirectConnection(url, Duration.ONE_MINUTE.times(10));
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -375,7 +375,7 @@ public class PenaltyFragment extends BaseFragment implements PopupMenu.OnMenuIte
|
||||
ReadonlyDataManager dataManager = OnlineDataManager.create(getActivity());
|
||||
SharedDomainFactory domainFactory = dataManager.getDataStore().getDomainFactory();
|
||||
for (Competitor competitor : getRace().getCompetitors()) {
|
||||
domainFactory.getCompetitorStore().allowCompetitorResetToDefaults(competitor);
|
||||
domainFactory.getCompetitorAndBoatStore().allowCompetitorResetToDefaults(competitor);
|
||||
}
|
||||
final Loader<?> competitorLoader = getLoaderManager()
|
||||
.initLoader(COMPETITOR_LOADER, null, dataManager.createCompetitorsLoader(getRace(), new LoadClient<Map<Competitor, Boat>>() {
|
||||
|
||||
+2
-2
@@ -467,7 +467,7 @@ public class TrackingListFragment extends BaseFragment
|
||||
ReadonlyDataManager dataManager = OnlineDataManager.create(getActivity());
|
||||
SharedDomainFactory domainFactory = dataManager.getDataStore().getDomainFactory();
|
||||
for (Competitor competitor : getRace().getCompetitors()) {
|
||||
domainFactory.getCompetitorStore().allowCompetitorResetToDefaults(competitor);
|
||||
domainFactory.getCompetitorAndBoatStore().allowCompetitorResetToDefaults(competitor);
|
||||
}
|
||||
|
||||
final Loader<?> competitorLoader = getLoaderManager()
|
||||
@@ -575,7 +575,7 @@ public class TrackingListFragment extends BaseFragment
|
||||
}
|
||||
|
||||
private CompetitorAndBoatStore getCompetitorStore() {
|
||||
return DataManager.create(getActivity()).getDataStore().getDomainFactory().getCompetitorStore();
|
||||
return DataManager.create(getActivity()).getDataStore().getDomainFactory().getCompetitorAndBoatStore();
|
||||
}
|
||||
|
||||
private CompetitorResultsList<CompetitorResultWithIdImpl> initializeFinishList() {
|
||||
|
||||
Reference in New Issue
Block a user