mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-11-14 06:18:12 +00:00
fixed prefiltering of competitors for regattas with changing boats for the CompetitorRegistrationDialog
This commit is contained in:
1 parent
6db8ab4050
commit
5de4d8367b
18 files changed
+58
-29
No files matched your search
+8
-3
@@ -70,15 +70,20 @@ public interface CompetitorStore extends CompetitorFactory, BoatFactory {
|
||||
void clearCompetitors();
|
||||
|
||||
/**
|
||||
* Obtains a non-live snapshot of the list of competitors managed by this store.
|
||||
* Obtains a non-live snapshot of the list of all (with and without boat) competitors managed by this store.
|
||||
*/
|
||||
Iterable<? extends Competitor> getCompetitors();
|
||||
Iterable<? extends Competitor> getAllCompetitors();
|
||||
|
||||
/**
|
||||
* Obtains a non-live snapshot of the list of competitors with a assigned boat.
|
||||
* Obtains a non-live snapshot of the list of competitors with an assigned boat.
|
||||
*/
|
||||
Iterable<CompetitorWithBoat> getCompetitorsWithBoat();
|
||||
|
||||
/**
|
||||
* Obtains a non-live snapshot of the list of competitors without an assigned boat.
|
||||
*/
|
||||
Iterable<Competitor> getCompetitorsWithoutBoat();
|
||||
|
||||
/**
|
||||
* Updates the competitor with {@link Competitor#getId() ID} <code>id</code> by setting the name, sail ID and nationality to
|
||||
* the values provided. Doing so will not fire any events nor will it replicate this change from a master to any replicas.
|
||||
|
||||
+19
-3
@@ -258,7 +258,7 @@ public class TransientCompetitorStoreImpl implements CompetitorStore, Serializab
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Competitor> getCompetitors() {
|
||||
public Iterable<Competitor> getAllCompetitors() {
|
||||
LockUtil.lockForRead(lock);
|
||||
try {
|
||||
return new ArrayList<Competitor>(competitorCache.values());
|
||||
@@ -273,7 +273,7 @@ public class TransientCompetitorStoreImpl implements CompetitorStore, Serializab
|
||||
try {
|
||||
List<CompetitorWithBoat> competitors = new ArrayList<>();
|
||||
for (Competitor c: competitorCache.values()) {
|
||||
if (isValidCompetitorWithBoat(c)) {
|
||||
if (c.hasBoat()) {
|
||||
competitors.add((CompetitorWithBoat) c);
|
||||
}
|
||||
}
|
||||
@@ -282,7 +282,23 @@ public class TransientCompetitorStoreImpl implements CompetitorStore, Serializab
|
||||
LockUtil.unlockAfterRead(lock);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Iterable<Competitor> getCompetitorsWithoutBoat() {
|
||||
LockUtil.lockForRead(lock);
|
||||
try {
|
||||
List<Competitor> competitors = new ArrayList<>();
|
||||
for (Competitor c: competitorCache.values()) {
|
||||
if (!c.hasBoat()) {
|
||||
competitors.add(c);
|
||||
}
|
||||
}
|
||||
return competitors;
|
||||
} finally {
|
||||
LockUtil.unlockAfterRead(lock);
|
||||
}
|
||||
}
|
||||
|
||||
protected void removeCompetitor(Competitor competitor) {
|
||||
LockUtil.lockForWrite(lock);
|
||||
try {
|
||||
|
||||
+1
-1
@@ -806,7 +806,7 @@ public class DomainFactoryImpl implements DomainFactory {
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -16,6 +16,6 @@ public interface DynamicCompetitorStore extends CompetitorStore {
|
||||
DynamicTeam team, Double timeOnTimeFactor, Duration timeOnDistanceAllowancePerNauticalMile, String searchTag);
|
||||
|
||||
@Override
|
||||
Iterable<? extends DynamicCompetitor> getCompetitors();
|
||||
Iterable<? extends DynamicCompetitor> getAllCompetitors();
|
||||
|
||||
}
|
||||
+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().getCompetitors();
|
||||
Iterable<? extends Competitor> allCompetitors = ctx.getRacingEventService().getCompetitorStore().getAllCompetitors();
|
||||
return competitorFilter.applyFilter(queryTokens, Util.addAll(allCompetitors, new ArrayList<Competitor>()));
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -66,7 +66,7 @@ public class AbstractRegattaLogFixesAddMappingsDialog extends DataEntryDialog<Co
|
||||
}
|
||||
});
|
||||
competitorTable = new CompetitorTableWrapper<>(sailingService, stringMessages, errorReporter,
|
||||
/* multiSelection */ false, /* enable pager */ true, /* show only competitors with boat */ false);
|
||||
/* multiSelection */ false, /* enable pager */ true, /* filterCompetitorWithBoat */ false, /* filterCompetitorsWithoutBoat */ false);
|
||||
markTable = new MarkTableWrapper<RefreshableSingleSelectionModel<MarkDTO>>(
|
||||
/* multiSelection */ false, sailingService, stringMessages, errorReporter);
|
||||
|
||||
|
||||
+2
-2
@@ -54,8 +54,8 @@ public abstract class AbstractRegattaLogSensorDataAddMappingsDialog extends Data
|
||||
}
|
||||
}
|
||||
});
|
||||
competitorTable = new CompetitorTableWrapper<>(sailingService, stringMessages, errorReporter,
|
||||
/* multiSelection */ false, /* enablePager */ true, /* show only competitors with boat */ false);
|
||||
competitorTable = new CompetitorTableWrapper<>( sailingService, stringMessages, errorReporter,
|
||||
/* multiSelection */ false, /* enablePager */ true, /* filterCompetitorWithBoat */ false, /* filterCompetitorsWithoutBoat */ false);
|
||||
competitorTable.getSelectionModel().addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
|
||||
@Override
|
||||
public void onSelectionChange(SelectionChangeEvent event) {
|
||||
|
||||
+1
-1
@@ -222,7 +222,7 @@ public class CompetitorImportProviderSelectionDialog extends DataEntryDialog<Com
|
||||
};
|
||||
// trigger both calls, allowing for parallel execution, synchronizing with the parallel execution holder above:
|
||||
sailingService.getCompetitorDescriptors(competitorProviderName, eventName, regattaName, new MarkedAsyncCallback<>(getCompetitorDescriptorsCallback));
|
||||
sailingService.getCompetitors(false, new MarkedAsyncCallback<>(getCompetitorsCallback));
|
||||
sailingService.getCompetitors(false, false, new MarkedAsyncCallback<>(getCompetitorsCallback));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -45,7 +45,8 @@ public class CompetitorPanel extends SimplePanel implements BusyDisplay {
|
||||
final StringMessages stringMessages, final ErrorReporter errorReporter) {
|
||||
super();
|
||||
this.leaderboardName = leaderboardName;
|
||||
this.competitorTable = new CompetitorTableWrapper<>(sailingService, stringMessages, errorReporter, /* multiSelection */ true, /* enablePager */ true, /* showOnlyCompetitorsWithBoat */ false);
|
||||
this.competitorTable = new CompetitorTableWrapper<>(sailingService, stringMessages, errorReporter, /* multiSelection */ true, /* enablePager */ true,
|
||||
/* filterCompetitorWithBoat */ false, /* filterCompetitorsWithoutBoat */ false);
|
||||
this.refreshableCompetitorSelectionModel = (RefreshableMultiSelectionModel<CompetitorDTO>) competitorTable.getSelectionModel();
|
||||
|
||||
busyIndicator = new SimpleBusyIndicator(false, 0.8f);
|
||||
|
||||
+2
-2
@@ -143,9 +143,9 @@ public class CompetitorRegistrationsPanel extends FlowPanel implements BusyDispl
|
||||
final CaptionPanel allCompetitorsPanel = new CaptionPanel(stringMessages.competitorPool());
|
||||
final CaptionPanel registeredCompetitorsPanel = new CaptionPanel(stringMessages.registeredCompetitors());
|
||||
allCompetitorsTable = new CompetitorTableWrapper<>(sailingService, stringMessages, errorReporter, /* multiSelection */
|
||||
true, /* enablePager */true, /* showOnlyCompetitorsWithBoat */ !canBoatsOfCompetitorsChangePerRace);
|
||||
true, /* enablePager */true, /* filterCompetitorWithBoat */ canBoatsOfCompetitorsChangePerRace, /* filterCompetitorsWithoutBoat */ !canBoatsOfCompetitorsChangePerRace);
|
||||
registeredCompetitorsTable = new CompetitorTableWrapper<>(sailingService, stringMessages, errorReporter, /* multiSelection */
|
||||
true, /* enablePager */false, /* showOnlyCompetitorsWithBoat */ false);
|
||||
true, /* enablePager */false, /* filterCompetitorWithBoat */ false, /* filterCompetitorsWithoutBoat */ false);
|
||||
allCompetitorsPanel.add(allCompetitorsTable);
|
||||
registeredCompetitorsPanel.add(registeredCompetitorsTable);
|
||||
VerticalPanel movePanel = new VerticalPanel();
|
||||
|
||||
+6
-4
@@ -50,7 +50,8 @@ import com.sap.sse.gwt.client.panels.LabeledAbstractFilterablePanel;
|
||||
*/
|
||||
public class CompetitorTableWrapper<S extends RefreshableSelectionModel<CompetitorDTO>> extends TableWrapper<CompetitorDTO, S> {
|
||||
private final LabeledAbstractFilterablePanel<CompetitorDTO> filterField;
|
||||
private final boolean showOnlyCompetitorsWithBoat;
|
||||
private final boolean filterCompetitorsWithBoat;
|
||||
private final boolean filterCompetitorsWithoutBoat;
|
||||
|
||||
private static final Template TEMPLATE = GWT.create(Template.class);
|
||||
|
||||
@@ -62,7 +63,7 @@ public class CompetitorTableWrapper<S extends RefreshableSelectionModel<Competit
|
||||
}
|
||||
|
||||
public CompetitorTableWrapper(SailingServiceAsync sailingService, StringMessages stringMessages, ErrorReporter errorReporter,
|
||||
boolean multiSelection, boolean enablePager, boolean showOnlyCompetitorsWithBoat) {
|
||||
boolean multiSelection, boolean enablePager, boolean filterCompetitorsWithBoat, boolean filterCompetitorsWithoutBoat) {
|
||||
super(sailingService, stringMessages, errorReporter, multiSelection, enablePager,
|
||||
new EntityIdentityComparator<CompetitorDTO>() {
|
||||
@Override
|
||||
@@ -74,7 +75,8 @@ public class CompetitorTableWrapper<S extends RefreshableSelectionModel<Competit
|
||||
return t.getIdAsString().hashCode();
|
||||
}
|
||||
});
|
||||
this.showOnlyCompetitorsWithBoat = showOnlyCompetitorsWithBoat;
|
||||
this.filterCompetitorsWithBoat = filterCompetitorsWithBoat;
|
||||
this.filterCompetitorsWithoutBoat = filterCompetitorsWithoutBoat;
|
||||
ListHandler<CompetitorDTO> competitorColumnListHandler = getColumnSortHandler();
|
||||
|
||||
// competitors table
|
||||
@@ -388,7 +390,7 @@ public class CompetitorTableWrapper<S extends RefreshableSelectionModel<Competit
|
||||
if (leaderboardName != null) {
|
||||
sailingService.getCompetitorsOfLeaderboard(leaderboardName, myCallback);
|
||||
} else {
|
||||
sailingService.getCompetitors(showOnlyCompetitorsWithBoat, myCallback);
|
||||
sailingService.getCompetitors(filterCompetitorsWithBoat, filterCompetitorsWithoutBoat, myCallback);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -34,7 +34,8 @@ public class ItemToMapToDeviceSelectionPanel implements IsWidget {
|
||||
ErrorReporter errorReporter, final SelectionChangedHandler handler, MappableToDevice selected) {
|
||||
this.selected = selected;
|
||||
this.errorReporter = errorReporter;
|
||||
competitorTable = new CompetitorTableWrapper<>(sailingService, stringMessages, errorReporter, /* multiSelection */ false, /* enablePager */ true, /* showOnlyCompetitorsWithBoat */ false);
|
||||
competitorTable = new CompetitorTableWrapper<>(sailingService, stringMessages, errorReporter, /* multiSelection */ false,
|
||||
/* enablePager */ true, /* filterCompetitorWithBoat */ false, /* filterCompetitorsWithoutBoat */ false);
|
||||
markTable = new MarkTableWrapper<RefreshableSingleSelectionModel<MarkDTO>>(/* multiSelection */ false, sailingService,
|
||||
stringMessages, errorReporter);
|
||||
final SingleSelectionModel<MarkDTO> markSelectionModel = markTable.getSelectionModel();
|
||||
|
||||
+1
-1
@@ -91,7 +91,7 @@ public class MatchImportedCompetitorsDialog extends DataEntryDialog<Pair<Map<Com
|
||||
protected Widget getAdditionalWidget() {
|
||||
existingCompetitorsTable = new CompetitorTableWrapper<>(sailingService, stringMessages,
|
||||
errorReporter, /* multiSelection */
|
||||
false, /* enablePager */true, /* showOnlyCompetitorsWithBoat */ false);
|
||||
false, /* enablePager */true, /* filterCompetitorWithBoat */ false, /* filterCompetitorsWithoutBoat */ false);
|
||||
final CompetitorsToImportToExistingLinking linker = new CompetitorsToImportToExistingLinking() {
|
||||
@Override
|
||||
public void unlinkCompetitor(CompetitorDescriptor competitor) {
|
||||
|
||||
+1
-1
@@ -437,7 +437,7 @@ public interface SailingService extends RemoteService, FileStorageManagementGwtS
|
||||
|
||||
DataImportProgress getImportOperationProgress(UUID id);
|
||||
|
||||
Iterable<CompetitorDTO> getCompetitors(boolean onlyCompetitorsWithBoat);
|
||||
Iterable<CompetitorDTO> getCompetitors(boolean filterCompetitorsWithBoat, boolean filterCompetitorsWithoutBoat);
|
||||
|
||||
Iterable<CompetitorDTO> getCompetitorsOfLeaderboard(String leaderboardName);
|
||||
|
||||
|
||||
+1
-1
@@ -595,7 +595,7 @@ public interface SailingServiceAsync extends ServerInfoRetriever, FileStorageMan
|
||||
|
||||
void getLeaderboardGroupNamesFromRemoteServer(String host, AsyncCallback<List<String>> leaderboardGroupNames);
|
||||
|
||||
void getCompetitors(boolean onlyCompetitorsWithBoat, AsyncCallback<Iterable<CompetitorDTO>> asyncCallback);
|
||||
void getCompetitors(boolean filterCompetitorsWithBoat, boolean filterCompetitorsWithoutBoat, AsyncCallback<Iterable<CompetitorDTO>> asyncCallback);
|
||||
|
||||
void getCompetitorsOfLeaderboard(String leaderboardName, AsyncCallback<Iterable<CompetitorDTO>> asyncCallback);
|
||||
|
||||
|
||||
+7
-3
@@ -4937,13 +4937,17 @@ public class SailingServiceImpl extends ProxiedRemoteServiceServlet implements S
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<CompetitorDTO> getCompetitors(boolean onlyCompetitorsWithBoat) {
|
||||
public Iterable<CompetitorDTO> getCompetitors(boolean filterCompetitorsWithBoat, boolean filterCompetitorsWithoutBoat) {
|
||||
Iterable<CompetitorDTO> result;
|
||||
CompetitorStore competitorStore = getService().getBaseDomainFactory().getCompetitorStore();
|
||||
if (onlyCompetitorsWithBoat) {
|
||||
if (filterCompetitorsWithBoat == false && filterCompetitorsWithoutBoat == false) {
|
||||
result = convertToCompetitorDTOs(competitorStore.getAllCompetitors());
|
||||
} else if (filterCompetitorsWithBoat == true && filterCompetitorsWithoutBoat == false) {
|
||||
result = convertToCompetitorDTOs(competitorStore.getCompetitorsWithoutBoat());
|
||||
} else if (filterCompetitorsWithBoat == false && filterCompetitorsWithoutBoat == true) {
|
||||
result = convertToCompetitorDTOs(competitorStore.getCompetitorsWithBoat());
|
||||
} else {
|
||||
result = convertToCompetitorDTOs(competitorStore.getCompetitors());
|
||||
result = Collections.emptyList();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
+1
-1
@@ -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().getCompetitors().spliterator(), /* parallel */ false).anyMatch(
|
||||
assertTrue(StreamSupport.stream(replica.getBaseDomainFactory().getCompetitorStore().getAllCompetitors().spliterator(), /* parallel */ false).anyMatch(
|
||||
c->
|
||||
c.getId().equals(competitor.getId())));
|
||||
}
|
||||
|
||||
+1
-1
@@ -3032,7 +3032,7 @@ public class RacingEventServiceImpl implements RacingEventService, ClearStateTes
|
||||
// only copy the competitors from the deserialized competitor store; don't use it because it will have set
|
||||
// a default Mongo object factory
|
||||
logger.info("Reading competitors...");
|
||||
for (Competitor competitor : ((CompetitorStore) ois.readObject()).getCompetitors()) {
|
||||
for (Competitor competitor : ((CompetitorStore) ois.readObject()).getAllCompetitors()) {
|
||||
DynamicCompetitor dynamicCompetitor = (DynamicCompetitor) competitor;
|
||||
// the following should actually be redundant because during de-serialization the Competitor objects,
|
||||
// whose classes implement IsManagedByCache, should already have been got/created from/in the
|
||||
|
||||
Reference in new issue
Block a user