mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-08 21:30:57 +00:00
Merge remote-tracking branch 'server/master'
This commit is contained in:
commit
728471c228
10 files changed
+90
-42
No files matched your search
+5
@@ -0,0 +1,5 @@
|
||||
package com.sap.sailing.domain.common;
|
||||
|
||||
public enum CompetitorGenderType {
|
||||
Men, Women, Mixed, Open
|
||||
}
|
||||
+2
-6
@@ -323,9 +323,7 @@ public abstract class TrackedRaceImpl implements TrackedRace, CourseListener {
|
||||
try {
|
||||
final Map<? extends WindSource, ? extends WindTrack> loadedWindTracks = windStore.loadWindTracks(
|
||||
trackedRegatta, TrackedRaceImpl.this, millisecondsOverWhichToAverageWind);
|
||||
synchronized (windTracks) {
|
||||
windTracks.putAll(loadedWindTracks);
|
||||
}
|
||||
windTracks.putAll(loadedWindTracks);
|
||||
} finally {
|
||||
LockUtil.unlockAfterRead(serializationLock);
|
||||
synchronized (TrackedRaceImpl.this) {
|
||||
@@ -2257,9 +2255,7 @@ public abstract class TrackedRaceImpl implements TrackedRace, CourseListener {
|
||||
public Iterable<WindSource> getWindSources() {
|
||||
while (true) {
|
||||
try {
|
||||
synchronized (windTracks) {
|
||||
return new HashSet<WindSource>(windTracks.keySet());
|
||||
}
|
||||
return new HashSet<WindSource>(windTracks.keySet());
|
||||
} catch (ConcurrentModificationException cme) {
|
||||
logger.info("Caught " + cme + "; trying again.");
|
||||
}
|
||||
|
||||
+20
-8
@@ -1,5 +1,7 @@
|
||||
package com.sap.sailing.gwt.ui.client.shared.filter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.sap.sailing.domain.common.RaceIdentifier;
|
||||
import com.sap.sailing.domain.common.dto.CompetitorDTO;
|
||||
import com.sap.sailing.domain.common.dto.LeaderboardDTO;
|
||||
@@ -32,21 +34,31 @@ public class CompetitorRaceRankFilter extends AbstractNumberFilter<CompetitorDTO
|
||||
public boolean matches(CompetitorDTO competitorDTO) {
|
||||
boolean result = false;
|
||||
if (value != null && operator != null && getLeaderboard() != null && getSelectedRace() != null) {
|
||||
RaceColumnDTO theRaceColumnDTO = null;
|
||||
RaceColumnDTO theRaceColumnDTOThatContainsCompetitorRace = null;
|
||||
for (RaceColumnDTO raceColumnDTO : getLeaderboard().getRaceList()) {
|
||||
if (raceColumnDTO.containsRace(getSelectedRace())) {
|
||||
theRaceColumnDTO = raceColumnDTO;
|
||||
theRaceColumnDTOThatContainsCompetitorRace = raceColumnDTO;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (theRaceColumnDTO != null && getLeaderboard().rows.get(competitorDTO) != null) {
|
||||
LeaderboardEntryDTO entryDTO = getLeaderboard().rows.get(competitorDTO).fieldsByRaceColumnName.get(theRaceColumnDTO.getName());
|
||||
if (entryDTO.totalPoints != null || !theRaceColumnDTO.isLiveInServerTime(entryDTO.fleet)) {
|
||||
int raceRank = getLeaderboard().getCompetitorsFromBestToWorst(theRaceColumnDTO).indexOf(competitorDTO)+1;
|
||||
if (raceRank > 0) {
|
||||
result = operator.matchValues(value, raceRank);
|
||||
List<CompetitorDTO> competitors = getLeaderboard().getCompetitorsFromBestToWorst(theRaceColumnDTOThatContainsCompetitorRace);
|
||||
if (theRaceColumnDTOThatContainsCompetitorRace != null && getLeaderboard().rows.get(competitorDTO) != null) {
|
||||
LeaderboardEntryDTO entryDTO = getLeaderboard().rows.get(competitorDTO).fieldsByRaceColumnName.get(theRaceColumnDTOThatContainsCompetitorRace.getName());
|
||||
int counter = 0; int raceRank = 0;
|
||||
for (CompetitorDTO competitorDTOIterated : competitors) {
|
||||
LeaderboardEntryDTO entryDTOIterated = getLeaderboard().rows.get(competitorDTOIterated).fieldsByRaceColumnName.get(theRaceColumnDTOThatContainsCompetitorRace.getName());
|
||||
if (entryDTOIterated.fleet.equals(entryDTO.fleet)) {
|
||||
counter += 1;
|
||||
if (competitorDTOIterated.equals(competitorDTO)) {
|
||||
raceRank = counter;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (raceRank > 0) {
|
||||
result = operator.matchValues(value, raceRank);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
||||
+16
@@ -12,6 +12,7 @@ import org.json.simple.JSONObject;
|
||||
import org.json.simple.parser.JSONParser;
|
||||
import org.json.simple.parser.ParseException;
|
||||
|
||||
import com.sap.sailing.domain.common.CompetitorGenderType;
|
||||
import com.sap.sailing.util.DateParser;
|
||||
import com.sap.sailing.util.InvalidDateException;
|
||||
|
||||
@@ -39,6 +40,7 @@ public class Manage2SailEventResultsParser {
|
||||
regattaResult.setIsafId((String) jsonRegatta.get("IsafId"));
|
||||
regattaResult.setExternalId((String) jsonRegatta.get("ExternalId"));
|
||||
regattaResult.setName((String) jsonRegatta.get("Name"));
|
||||
regattaResult.setCompetitorGenderType(parseCompetitorGenderType(jsonRegatta, "Gender"));
|
||||
regattaResult.setClassName((String) jsonRegatta.get("ClassName"));
|
||||
regattaResult.setPdfUrl(parseURL(jsonRegatta, "PdfUrl"));
|
||||
regattaResult.setXrrPreliminaryUrl(parseURL(jsonRegatta, "XrrPreliminaryUrl"));
|
||||
@@ -56,6 +58,20 @@ public class Manage2SailEventResultsParser {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private CompetitorGenderType parseCompetitorGenderType(JSONObject jsonDate, String attributeName) {
|
||||
CompetitorGenderType result = null;
|
||||
String genderTypeAsString = (String) jsonDate.get(attributeName);
|
||||
if(genderTypeAsString != null) {
|
||||
switch(genderTypeAsString) {
|
||||
case "M" : result = CompetitorGenderType.Men; break;
|
||||
case "W" : result = CompetitorGenderType.Women; break;
|
||||
case "X" : result = CompetitorGenderType.Mixed; break;
|
||||
case "Open" : result = CompetitorGenderType.Open; break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private Date parseDate(JSONObject jsonDate, String attributeName) {
|
||||
Date result = null;
|
||||
|
||||
+2
-2
@@ -40,12 +40,12 @@ public class Manage2SailResultDocumentProvider implements ResultDocumentProvider
|
||||
URLConnection regattaResultConn = regattaResult.getXrrFinalUrl().openConnection();
|
||||
result.add(new ResultDocumentDescriptorImpl((InputStream) regattaResultConn.getContent(),
|
||||
regattaResult.getXrrPreliminaryUrl().toString(), new MillisecondsTimePoint(regattaResult.getPublishedAt()),
|
||||
eventResult.getName(), regattaResult.getName(), boatClass));
|
||||
eventResult.getName(), regattaResult.getName(), boatClass, regattaResult.getCompetitorGenderType()));
|
||||
} else if (regattaResult.getXrrPreliminaryUrl() != null) {
|
||||
URLConnection regattaResultConn = regattaResult.getXrrPreliminaryUrl().openConnection();
|
||||
result.add(new ResultDocumentDescriptorImpl((InputStream) regattaResultConn.getContent(),
|
||||
regattaResult.getXrrPreliminaryUrl().toString(), new MillisecondsTimePoint(regattaResult.getPublishedAt()),
|
||||
eventResult.getName(), regattaResult.getName(), boatClass));
|
||||
eventResult.getName(), regattaResult.getName(), boatClass, regattaResult.getCompetitorGenderType()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+9
@@ -3,12 +3,15 @@ package com.sap.sailing.manage2sail.resultimport;
|
||||
import java.net.URL;
|
||||
import java.util.Date;
|
||||
|
||||
import com.sap.sailing.domain.common.CompetitorGenderType;
|
||||
|
||||
public class RegattaResultDescriptor {
|
||||
private String id;
|
||||
private String isafId;
|
||||
private String externalId;
|
||||
private String name;
|
||||
private String className;
|
||||
private CompetitorGenderType competitorGenderType;
|
||||
private URL pdfUrl;
|
||||
private URL xrrPreliminaryUrl;
|
||||
private URL xrrFinalUrl;
|
||||
@@ -82,4 +85,10 @@ public class RegattaResultDescriptor {
|
||||
public void setIsFinal(Boolean isFinal) {
|
||||
this.isFinal = isFinal;
|
||||
}
|
||||
public CompetitorGenderType getCompetitorGenderType() {
|
||||
return competitorGenderType;
|
||||
}
|
||||
public void setCompetitorGenderType(CompetitorGenderType competitorGenderType) {
|
||||
this.competitorGenderType = competitorGenderType;
|
||||
}
|
||||
}
|
||||
+15
-2
@@ -26,6 +26,7 @@ import com.sap.sailing.xrr.resultimport.ParserFactory;
|
||||
import com.sap.sailing.xrr.resultimport.impl.XRRRegattaResultsAsScoreCorrections;
|
||||
import com.sap.sailing.xrr.resultimport.schema.Division;
|
||||
import com.sap.sailing.xrr.resultimport.schema.Event;
|
||||
import com.sap.sailing.xrr.resultimport.schema.EventGender;
|
||||
import com.sap.sailing.xrr.resultimport.schema.RegattaResults;
|
||||
|
||||
public class ScoreCorrectionProviderImpl implements ScoreCorrectionProvider, ResultUrlProvider {
|
||||
@@ -63,6 +64,9 @@ public class ScoreCorrectionProviderImpl implements ScoreCorrectionProvider, Res
|
||||
String eventName = resultDocDescr.getEventName() != null ? resultDocDescr.getEventName() : resultDocDescr.getRegattaName();
|
||||
String boatClass = resultDocDescr.getBoatClass();
|
||||
if(boatClass != null && eventName != null) {
|
||||
if(resultDocDescr.getCompetitorGenderType() != null) {
|
||||
boatClass += ", " + resultDocDescr.getCompetitorGenderType().name();
|
||||
}
|
||||
Set<Pair<String, TimePoint>> eventResultsSet = result.get(eventName);
|
||||
if(eventResultsSet == null) {
|
||||
eventResultsSet = new HashSet<Pair<String, TimePoint>>();
|
||||
@@ -92,7 +96,12 @@ public class ScoreCorrectionProviderImpl implements ScoreCorrectionProvider, Res
|
||||
for (Object eventO : event.getRaceOrDivisionOrRegattaSeriesResult()) {
|
||||
if (eventO instanceof Division) {
|
||||
Division division = (Division) eventO;
|
||||
if (boatClassName.equals(parser.getBoatClassName(division))) {
|
||||
EventGender divisionGender = division.getGender();
|
||||
String divisionBoatClassAndGender = parser.getBoatClassName(division);
|
||||
if(divisionGender != null) {
|
||||
divisionBoatClassAndGender += ", " + divisionGender.name();
|
||||
}
|
||||
if (boatClassName.equalsIgnoreCase(divisionBoatClassAndGender)) {
|
||||
return new XRRRegattaResultsAsScoreCorrections(event, division, this,
|
||||
parser);
|
||||
}
|
||||
@@ -112,7 +121,11 @@ public class ScoreCorrectionProviderImpl implements ScoreCorrectionProvider, Res
|
||||
private Parser resolveParser(String eventName, String boatClassName) throws IOException {
|
||||
Parser result = null;
|
||||
for (ResultDocumentDescriptor resultDocDescr : documentProvider.getResultDocumentDescriptors()) {
|
||||
if(eventName.equals(resultDocDescr.getEventName()) && boatClassName.equals(resultDocDescr.getBoatClass())) {
|
||||
String boatClassAndGenderType = resultDocDescr.getBoatClass();
|
||||
if(resultDocDescr.getCompetitorGenderType() != null) {
|
||||
boatClassAndGenderType += ", " + resultDocDescr.getCompetitorGenderType().name();
|
||||
}
|
||||
if(eventName.equals(resultDocDescr.getEventName()) && boatClassName.equals(boatClassAndGenderType)) {
|
||||
result = parserFactory.createParser(resultDocDescr.getInputStream(), resultDocDescr.getEventName());
|
||||
break;
|
||||
}
|
||||
|
||||
+2
@@ -2,12 +2,14 @@ package com.sap.sailing.resultimport;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
import com.sap.sailing.domain.common.CompetitorGenderType;
|
||||
import com.sap.sailing.domain.common.TimePoint;
|
||||
|
||||
public interface ResultDocumentDescriptor {
|
||||
String getEventName();
|
||||
String getRegattaName();
|
||||
String getBoatClass();
|
||||
CompetitorGenderType getCompetitorGenderType();
|
||||
|
||||
TimePoint getLastModified();
|
||||
|
||||
|
||||
+15
-3
@@ -2,6 +2,7 @@ package com.sap.sailing.resultimport.impl;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
import com.sap.sailing.domain.common.CompetitorGenderType;
|
||||
import com.sap.sailing.domain.common.TimePoint;
|
||||
import com.sap.sailing.resultimport.ResultDocumentDescriptor;
|
||||
|
||||
@@ -12,29 +13,36 @@ public class ResultDocumentDescriptorImpl implements ResultDocumentDescriptor {
|
||||
private String eventName;
|
||||
private String regattaName;
|
||||
private String boatClass;
|
||||
private CompetitorGenderType competitorGenderType;
|
||||
|
||||
public ResultDocumentDescriptorImpl(InputStream inputStream, String documentName, TimePoint lastModified) {
|
||||
this(inputStream, documentName, lastModified, null, null, null);
|
||||
this(inputStream, documentName, lastModified, null, null, null, null);
|
||||
}
|
||||
|
||||
public ResultDocumentDescriptorImpl(InputStream inputStream, String documentName, TimePoint lastModified,
|
||||
String eventName) {
|
||||
this(inputStream, documentName, lastModified, eventName, null, null);
|
||||
this(inputStream, documentName, lastModified, eventName, null, null, null);
|
||||
}
|
||||
|
||||
public ResultDocumentDescriptorImpl(InputStream inputStream, String documentName, TimePoint lastModified,
|
||||
String eventName, String regattaName) {
|
||||
this(inputStream, documentName, lastModified, eventName, regattaName, null);
|
||||
this(inputStream, documentName, lastModified, eventName, regattaName, null, null);
|
||||
}
|
||||
|
||||
public ResultDocumentDescriptorImpl(InputStream inputStream, String documentName, TimePoint lastModified,
|
||||
String eventName, String regattaName, String boatClass) {
|
||||
this(inputStream, documentName, lastModified, eventName, regattaName, boatClass, null);
|
||||
}
|
||||
|
||||
public ResultDocumentDescriptorImpl(InputStream inputStream, String documentName, TimePoint lastModified,
|
||||
String eventName, String regattaName, String boatClass, CompetitorGenderType competitorGenderType) {
|
||||
this.inputStream = inputStream;
|
||||
this.lastModified = lastModified;
|
||||
this.documentName = documentName;
|
||||
this.eventName = eventName;
|
||||
this.regattaName = regattaName;
|
||||
this.boatClass = boatClass;
|
||||
this.competitorGenderType = competitorGenderType;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -66,4 +74,8 @@ public class ResultDocumentDescriptorImpl implements ResultDocumentDescriptor {
|
||||
public String getDocumentName() {
|
||||
return documentName;
|
||||
}
|
||||
|
||||
public CompetitorGenderType getCompetitorGenderType() {
|
||||
return competitorGenderType;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user