mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-11 14:50:56 +00:00
added methods on SailingService to manage race columns in Series
This commit is contained in:
1 parent
62fbf08d68
commit
d8a28bbfaa
14 files changed
+189
-6
No files matched your search
@@ -167,10 +167,10 @@ public interface RacingEventService extends TrackedRegattaRegistry, RegattaFetch
|
||||
void stopTracking(Regatta regatta) throws MalformedURLException, IOException, InterruptedException;
|
||||
|
||||
/**
|
||||
* Removes <code>race</code> and any corresponding {@link #getTrackedRace(Regatta, RaceDefinition) tracked race} from
|
||||
* this service. If it was the last {@link RaceDefinition} in its {@link Regatta}, the <code>regatta</code> is removed
|
||||
* as well and will no longer be returned by {@link #getAllRegattas()}. The wind tracking is stopped for
|
||||
* <code>race</code>.
|
||||
* Removes <code>race</code> and any corresponding {@link #getTrackedRace(Regatta, RaceDefinition) tracked race}
|
||||
* from this service. If it was the last {@link RaceDefinition} in its {@link Regatta} and the regatta
|
||||
* {@link Regatta#isPersistent() is not stored persistently}, the <code>regatta</code> is removed as well and will no
|
||||
* longer be returned by {@link #getAllRegattas()}. The wind tracking is stopped for <code>race</code>.
|
||||
* <p>
|
||||
*
|
||||
* Any {@link RaceTracker} for which <code>race</race> is the last race tracked that is still reachable
|
||||
|
||||
+5
-2
@@ -893,6 +893,9 @@ public class RacingEventServiceImpl implements RacingEventService, RegattaListen
|
||||
for (RaceDefinition race : regatta.getAllRaces()) {
|
||||
removeRace(regatta, race);
|
||||
}
|
||||
if (regatta.isPersistent()) {
|
||||
// TODO remove regatta from database; or should this probably happen inside RacingEventServiceImpl.removeRegatta?
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -925,9 +928,9 @@ public class RacingEventServiceImpl implements RacingEventService, RegattaListen
|
||||
}
|
||||
}
|
||||
}
|
||||
// remove the race from the regatta
|
||||
// remove the race from the regatta if the regatta is not persistently stored
|
||||
regatta.removeRace(race);
|
||||
if (Util.isEmpty(regatta.getAllRaces())) {
|
||||
if (!regatta.isPersistent() && Util.isEmpty(regatta.getAllRaces())) {
|
||||
logger.info("Removing regatta "+regatta.getName()+" from service "+this);
|
||||
regattasByName.remove(regatta.getName());
|
||||
regatta.removeRegattaListener(this);
|
||||
|
||||
+3
@@ -19,6 +19,9 @@ public class AddColumnToSeries extends AbstractColumnInSeriesOperation<RaceColum
|
||||
Series series = getSeries(toState);
|
||||
if (series != null) {
|
||||
result = series.addRaceColumn(getColumnName());
|
||||
if (series.getRegatta().isPersistent()) {
|
||||
// TODO update regatta in DB
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
+1
@@ -31,6 +31,7 @@ public class CreateLeaderboardGroup extends AbstractLeaderboardGroupOperation<Le
|
||||
|
||||
@Override
|
||||
public LeaderboardGroup internalApplyTo(RacingEventService toState) {
|
||||
// TODO see bug 729: try to move addLeaderboardGroup implementation here and synthesize and apply this operation there
|
||||
return toState.addLeaderboardGroup(getLeaderboardGroupName(), description, leaderboardNames);
|
||||
}
|
||||
|
||||
|
||||
+3
@@ -17,6 +17,9 @@ public class MoveColumnInSeriesDown extends AbstractColumnInSeriesOperation<Void
|
||||
Series series = getSeries(toState);
|
||||
if (series != null) {
|
||||
series.moveRaceColumnDown(getColumnName());
|
||||
if (series.getRegatta().isPersistent()) {
|
||||
// TODO update regatta in DB
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
+3
@@ -17,6 +17,9 @@ public class MoveColumnInSeriesUp extends AbstractColumnInSeriesOperation<Void>
|
||||
Series series = getSeries(toState);
|
||||
if (series != null) {
|
||||
series.moveRaceColumnUp(getColumnName());
|
||||
if (series.getRegatta().isPersistent()) {
|
||||
// TODO update regatta in DB
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
+3
@@ -17,6 +17,9 @@ public class RemoveColumnFromSeries extends AbstractColumnInSeriesOperation<Void
|
||||
Series series = getSeries(toState);
|
||||
if (series != null) {
|
||||
series.removeRaceColumn(getColumnName());
|
||||
if (series.getRegatta().isPersistent()) {
|
||||
// TODO update regatta in DB
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
+1
@@ -24,6 +24,7 @@ public class RemoveLeaderboardGroup extends AbstractLeaderboardGroupOperation<Vo
|
||||
|
||||
@Override
|
||||
public Void internalApplyTo(RacingEventService toState) {
|
||||
// TODO see bug 729: try to move addLeaderboardGroup implementation here and synthesize and apply this operation there
|
||||
toState.removeLeaderboardGroup(getLeaderboardGroupName());
|
||||
return null;
|
||||
}
|
||||
|
||||
Executable
+43
@@ -0,0 +1,43 @@
|
||||
package com.sap.sailing.server.operationaltransformation;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.sap.sailing.domain.base.Regatta;
|
||||
import com.sap.sailing.domain.common.RegattaIdentifier;
|
||||
import com.sap.sailing.server.RacingEventService;
|
||||
import com.sap.sailing.server.RacingEventServiceOperation;
|
||||
|
||||
public class RemoveRegatta extends AbstractRacingEventServiceOperation<Void> {
|
||||
private static final long serialVersionUID = -2232723085937305299L;
|
||||
private static final Logger logger = Logger.getLogger(RemoveRegatta.class.getName());
|
||||
private final RegattaIdentifier regattaIdentifier;
|
||||
|
||||
public RemoveRegatta(RegattaIdentifier regattaIdentifier) {
|
||||
super();
|
||||
this.regattaIdentifier = regattaIdentifier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void internalApplyTo(RacingEventService toState) throws Exception {
|
||||
Regatta regatta = toState.getRegatta(regattaIdentifier);
|
||||
if (regatta != null) {
|
||||
toState.removeRegatta(regatta);
|
||||
} else {
|
||||
logger.warning("Couldn't find regatta "+regattaIdentifier);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RacingEventServiceOperation<?> transformClientOp(RacingEventServiceOperation<?> serverOp) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RacingEventServiceOperation<?> transformServerOp(RacingEventServiceOperation<?> clientOp) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
package com.sap.sailing.server.operationaltransformation;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.sap.sailing.domain.base.RaceColumnInSeries;
|
||||
import com.sap.sailing.domain.base.Series;
|
||||
import com.sap.sailing.domain.common.RegattaIdentifier;
|
||||
import com.sap.sailing.server.RacingEventService;
|
||||
import com.sap.sailing.server.RacingEventServiceOperation;
|
||||
|
||||
public class RenameColumnInSeries extends AbstractColumnInSeriesOperation<Void> {
|
||||
private static final long serialVersionUID = -6772077267645894432L;
|
||||
private final static Logger logger = Logger.getLogger(RenameColumnInSeries.class.getName());
|
||||
private final String newColumnName;
|
||||
|
||||
public RenameColumnInSeries(RegattaIdentifier regattaIdentifier, String seriesName, String columnName, String newColumnName) {
|
||||
super(regattaIdentifier, seriesName, columnName);
|
||||
this.newColumnName = newColumnName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void internalApplyTo(RacingEventService toState) throws Exception {
|
||||
Series series = getSeries(toState);
|
||||
if (series != null) {
|
||||
RaceColumnInSeries raceColumn = series.getRaceColumnByName(getColumnName());
|
||||
if (raceColumn != null) {
|
||||
RaceColumnInSeries existingRaceColumnWithNewName = series.getRaceColumnByName(newColumnName);
|
||||
if (existingRaceColumnWithNewName != null) {
|
||||
logger.info("Not renaming column "+getColumnName()+" in series "+series.getName()+" in regatta "+series.getRegatta().getName()+
|
||||
" to "+newColumnName+" because a column of that name already exists");
|
||||
} else {
|
||||
raceColumn.setName(newColumnName);
|
||||
if (series.getRegatta().isPersistent()) {
|
||||
// TODO update regatta in DB
|
||||
}
|
||||
}
|
||||
} else {
|
||||
logger.warning("Didn't find race column " + getColumnName() + " in series " + series.getName()
|
||||
+ " in regatta " + series.getRegatta().getName());
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RacingEventServiceOperation<?> transformClientOp(RacingEventServiceOperation<?> serverOp) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RacingEventServiceOperation<?> transformServerOp(RacingEventServiceOperation<?> clientOp) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
+1
@@ -14,6 +14,7 @@ public class RenameLeaderboardGroup extends AbstractLeaderboardGroupOperation<Vo
|
||||
|
||||
@Override
|
||||
public Void internalApplyTo(RacingEventService toState) {
|
||||
// TODO see bug 729: try to move addLeaderboardGroup implementation here and synthesize and apply this operation there
|
||||
if (!getLeaderboardGroupName().equals(newLeaderboardGroupName)) {
|
||||
toState.renameLeaderboardGroup(getLeaderboardGroupName(), newLeaderboardGroupName);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user