Merge remote-tracking branch 'server/master'

This commit is contained in:
Axel Uhl committed 2014-11-18 16:49:53 +01:00
commit 11a4133e76
11 files changed
+57 -29

No files matched your search

@@ -3,8 +3,9 @@ package com.sap.sailing.domain.common.dto;
import java.io.Serializable;
import com.sap.sailing.domain.common.Color;
import com.sap.sailing.domain.common.racelog.tracking.MappableToDevice;
public interface CompetitorDTO extends Serializable {
public interface CompetitorDTO extends Serializable, MappableToDevice {
String getTwoLetterIsoCountryCode();
@@ -0,0 +1,13 @@
package com.sap.sailing.domain.common.racelog.tracking;
/**
* Marker interface that can be applied to DTOs that represent domain objects
* that can be mapped to a device for racelog-tracking (see {@link DeviceMapping}.
* By doing so, they can be referred without having to use {@link Serializable}
* as type - which has a considerable performance impact for GWT.
* @author Fredrik Teschke
*
*/
public interface MappableToDevice {
}
@@ -31,7 +31,7 @@ public class DeviceMappingImpl<ItemType extends WithID> implements DeviceMapping
if (originalRaceLogEventId != null) originalRaceLogEventIds.add(originalRaceLogEventId);
}
public DeviceMappingImpl(ItemType mappedTo, DeviceIdentifier device, TimeRange timeRange, List<Serializable> originalRaceLogEventIds) {
public DeviceMappingImpl(ItemType mappedTo, DeviceIdentifier device, TimeRange timeRange, List<? extends Serializable> originalRaceLogEventIds) {
this(mappedTo, device, timeRange);
if (originalRaceLogEventIds != null) this.originalRaceLogEventIds.addAll(originalRaceLogEventIds);
}
@@ -1,6 +1,5 @@
package com.sap.sailing.gwt.ui.adminconsole;
import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import java.util.List;
@@ -24,6 +23,7 @@ import com.google.gwt.view.client.SelectionModel;
import com.google.gwt.view.client.SingleSelectionModel;
import com.sap.sailing.domain.common.dto.CompetitorDTO;
import com.sap.sailing.domain.common.racelog.tracking.DeviceMappingConstants;
import com.sap.sailing.domain.common.racelog.tracking.MappableToDevice;
import com.sap.sailing.gwt.ui.client.SailingServiceAsync;
import com.sap.sailing.gwt.ui.client.StringMessages;
import com.sap.sailing.gwt.ui.shared.BetterDateTimeBox;
@@ -43,7 +43,7 @@ public class AddDeviceMappingDialog extends DataEntryDialog<DeviceMappingDTO> {
private final MarkTableWrapper<SingleSelectionModel<MarkDTO>> markTable;
private final StringMessages stringMessages;
private Serializable selectedItem;
private MappableToDevice selectedItem;
public AddDeviceMappingDialog(SailingServiceAsync sailingService, final ErrorReporter errorReporter,
final StringMessages stringMessages, String leaderboardName, String raceColumnName, String fleetName,
@@ -1,6 +1,5 @@
package com.sap.sailing.gwt.ui.adminconsole;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
@@ -15,6 +14,7 @@ import com.google.gwt.user.client.ui.Widget;
import com.google.gwt.view.client.SelectionChangeEvent;
import com.google.gwt.view.client.SingleSelectionModel;
import com.sap.sailing.domain.common.dto.CompetitorDTO;
import com.sap.sailing.domain.common.racelog.tracking.MappableToDevice;
import com.sap.sailing.gwt.ui.client.SailingServiceAsync;
import com.sap.sailing.gwt.ui.client.StringMessages;
import com.sap.sailing.gwt.ui.shared.DeviceIdentifierDTO;
@@ -31,7 +31,7 @@ public class ImportFixesAndAddMappingsDialog extends DataEntryDialog<Collection<
private final MarkTableWrapper<SingleSelectionModel<MarkDTO>> markTable;
private final StringMessages stringMessages;
private final Map<TrackFileImportDeviceIdentifierDTO, Serializable> mappings = new HashMap<>();
private final Map<TrackFileImportDeviceIdentifierDTO, MappableToDevice> mappings = new HashMap<>();
private TrackFileImportDeviceIdentifierDTO deviceToSelect;
private CompetitorDTO compToSelect;
@@ -130,7 +130,7 @@ public class ImportFixesAndAddMappingsDialog extends DataEntryDialog<Collection<
}
}
private void mappedToSelectionChanged(Serializable mappedTo) {
private void mappedToSelectionChanged(MappableToDevice mappedTo) {
if (! inInstableTransitionState) {
TrackFileImportDeviceIdentifierDTO device = deviceIdTable.getSelectionModel().getSelectedObject();
if (device != null) {
@@ -155,7 +155,7 @@ public class ImportFixesAndAddMappingsDialog extends DataEntryDialog<Collection<
markToSelect = null;
if (deviceId != null) {
Serializable mappedTo = mappings.get(deviceId);
MappableToDevice mappedTo = mappings.get(deviceId);
if (mappedTo instanceof CompetitorDTO) {
compToSelect = (CompetitorDTO) mappedTo;
} else if (mappedTo instanceof MarkDTO) {
@@ -192,7 +192,7 @@ public class ImportFixesAndAddMappingsDialog extends DataEntryDialog<Collection<
List<DeviceMappingDTO> result = new ArrayList<>();
for (TrackFileImportDeviceIdentifierDTO device : mappings.keySet()) {
DeviceIdentifierDTO deviceIdDto = new DeviceIdentifierDTO("FILE", device.uuidAsString);
Serializable mappedTo = mappings.get(device);
MappableToDevice mappedTo = mappings.get(device);
DeviceMappingDTO mapping = new DeviceMappingDTO(deviceIdDto, device.from, device.to,
mappedTo, null);
result.add(mapping);
@@ -1,6 +1,5 @@
package com.sap.sailing.gwt.ui.client;
import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import java.util.List;
@@ -490,7 +489,7 @@ public interface SailingService extends RemoteService {
* Revoke the events in the {@code RaceLog} that are identified by the {@code eventIds}.
* This only affects such events that implement {@link Revokable}.
*/
void revokeRaceLogEvents(String leaderboardName, String raceColumnName, String fleetName, List<Serializable> eventIds)
void revokeRaceLogEvents(String leaderboardName, String raceColumnName, String fleetName, List<UUID> eventIds)
throws NotRevokableException;
Collection<String> getGPSFixImporterTypes();
@@ -1,6 +1,5 @@
package com.sap.sailing.gwt.ui.client;
import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import java.util.List;
@@ -598,7 +597,7 @@ public interface SailingServiceAsync extends BuildVersionRetriever {
void closeOpenEndedDeviceMapping(String leaderboardName, String raceColumnName, String fleetName,
DeviceMappingDTO mapping, Date closingTimePoint, AsyncCallback<Void> callback);
void revokeRaceLogEvents(String leaderboardName, String raceColumnName, String fleetName, List<Serializable> eventIds,
void revokeRaceLogEvents(String leaderboardName, String raceColumnName, String fleetName, List<UUID> eventIds,
AsyncCallback<Void> callback);
void removeSeries(RegattaIdentifier regattaIdentifier, String seriesName, AsyncCallback<Void> callback);
@@ -169,6 +169,7 @@ import com.sap.sailing.domain.common.racelog.FlagPole;
import com.sap.sailing.domain.common.racelog.Flags;
import com.sap.sailing.domain.common.racelog.RaceLogRaceStatus;
import com.sap.sailing.domain.common.racelog.RacingProcedureType;
import com.sap.sailing.domain.common.racelog.tracking.MappableToDevice;
import com.sap.sailing.domain.common.racelog.tracking.NoCorrespondingServiceRegisteredException;
import com.sap.sailing.domain.common.racelog.tracking.NotDenotedForRaceLogTrackingException;
import com.sap.sailing.domain.common.racelog.tracking.NotRevokableException;
@@ -4863,7 +4864,7 @@ public class SailingServiceImpl extends ProxiedRemoteServiceServlet implements S
null : mapping.getTimeRange().from().asDate();
Date to = mapping.getTimeRange().to() == null || mapping.getTimeRange().to().asMillis() == Long.MAX_VALUE ?
null : mapping.getTimeRange().to().asDate();
Serializable item = null;
MappableToDevice item = null;
if (mapping.getMappedTo() instanceof Competitor) {
item = baseDomainFactory.convertToCompetitorDTO((Competitor) mapping.getMappedTo());
} else if (mapping.getMappedTo() instanceof Mark) {
@@ -4871,8 +4872,20 @@ public class SailingServiceImpl extends ProxiedRemoteServiceServlet implements S
} else {
throw new RuntimeException("Can only handle Competitor or Mark as mapped item type");
}
//Only deal with UUIDs - otherwise we would have to pass Serializable to browser context - which
//has a large performance implact for GWT.
//As any Serializable subclass is converted to String by the BaseRaceLogEventSerializer, and only UUIDs are
//recovered by the BaseRaceLogEventDeserializer, only UUIDs are safe to use anyway.
List<UUID> originalRaceLogEventUUIDs = new ArrayList<UUID>();
for (Serializable id : mapping.getOriginalRaceLogEventIds()) {
if (! (id instanceof UUID)) {
logger.log(Level.WARNING, "Got RaceLogEvent with id that was not UUID, but " + id.getClass().getName());
throw new TransformationException("Could not send device mapping to browser: can only deal with UUIDs");
}
originalRaceLogEventUUIDs.add((UUID) id);
}
return new DeviceMappingDTO(new DeviceIdentifierDTO(mapping.getDevice().getIdentifierType(),
deviceId), from, to, item, mapping.getOriginalRaceLogEventIds());
deviceId), from, to, item, originalRaceLogEventUUIDs);
}
@Override
@@ -4943,8 +4956,9 @@ public class SailingServiceImpl extends ProxiedRemoteServiceServlet implements S
TimePoint to = dto.to == null ? null : new MillisecondsTimePoint(dto.to);
TimeRange timeRange = new TimeRangeImpl(from, to);
if (dto.mappedTo instanceof MarkDTO) {
Mark mark = convertToMark(((MarkDTO) dto.mappedTo), true);
return new DeviceMappingImpl<Mark>(mark, device, timeRange,dto.originalRaceLogEventIds);
Mark mark = convertToMark(((MarkDTO) dto.mappedTo), true);
//expect UUIDs
return new DeviceMappingImpl<Mark>(mark, device, timeRange, dto.originalRaceLogEventIds);
} else if (dto.mappedTo instanceof CompetitorDTO) {
Competitor competitor = getService().getCompetitorStore().getExistingCompetitorByIdAsString(
((CompetitorDTO) dto.mappedTo).getIdAsString());
@@ -4970,7 +4984,7 @@ public class SailingServiceImpl extends ProxiedRemoteServiceServlet implements S
@Override
public void revokeRaceLogEvents(String leaderboardName, String raceColumnName, String fleetName,
List<Serializable> eventIds) throws NotRevokableException {
List<UUID> eventIds) throws NotRevokableException {
RaceLog raceLog = getRaceLog(leaderboardName, raceColumnName, fleetName);
for (Serializable idToRevoke : eventIds) {
raceLog.lockForRead();
@@ -1,9 +1,8 @@
package com.sap.sailing.gwt.ui.shared;
import java.io.Serializable;
import com.google.gwt.user.client.rpc.IsSerializable;
public class DeviceIdentifierDTO implements Serializable {
private static final long serialVersionUID = 1171014272760543228L;
public class DeviceIdentifierDTO implements IsSerializable {
public String deviceType;
public String deviceId;
@@ -1,21 +1,23 @@
package com.sap.sailing.gwt.ui.shared;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import java.util.UUID;
public class DeviceMappingDTO implements Serializable {
private static final long serialVersionUID = -3272980620254526040L;
import com.google.gwt.user.client.rpc.IsSerializable;
import com.sap.sailing.domain.common.racelog.tracking.MappableToDevice;
public class DeviceMappingDTO implements IsSerializable {
public DeviceIdentifierDTO deviceIdentifier;
public Date from;
public Date to;
public Serializable mappedTo;
public List<Serializable> originalRaceLogEventIds;
public MappableToDevice mappedTo;
public List<UUID> originalRaceLogEventIds;
protected DeviceMappingDTO() {}
public DeviceMappingDTO(DeviceIdentifierDTO deviceId, Date from, Date to, Serializable mappedTo,
List<Serializable> originalRaceLogEventIds) {
public DeviceMappingDTO(DeviceIdentifierDTO deviceId, Date from, Date to, MappableToDevice mappedTo,
List<UUID> originalRaceLogEventIds) {
this.deviceIdentifier = deviceId;
this.from = from;
this.to = to;
@@ -4,8 +4,9 @@ import java.util.Collections;
import com.sap.sailing.domain.common.MarkType;
import com.sap.sailing.domain.common.dto.PositionDTO;
import com.sap.sailing.domain.common.racelog.tracking.MappableToDevice;
public class MarkDTO extends ControlPointDTO {
public class MarkDTO extends ControlPointDTO implements MappableToDevice {
private static final long serialVersionUID = -8031499997812618751L;
public PositionDTO position;
public String color;