Merge branch 'design2015' into design2015-races

Conflicts:
	java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/shared/dispatch/event/LiveRaceDTO.java
This commit is contained in:
Steffen Schaefer committed 2015-07-06 10:06:45 +02:00
commit 94ba11188a
2 files changed
+56 -59

No files matched your search

@@ -1,14 +1,10 @@
package com.sap.sailing.gwt.ui.shared.dispatch.event;
import java.util.Date;
import com.sap.sailing.gwt.ui.shared.race.FlagStateDTO;
import com.sap.sailing.gwt.ui.shared.race.FleetMetadataDTO;
import com.sap.sailing.gwt.ui.shared.race.RaceMetadataDTO;
import com.sap.sailing.gwt.ui.shared.race.RaceProgressDTO;
import com.sap.sse.common.Util;
public class LiveRaceDTO extends RaceMetadataDTO implements Comparable<LiveRaceDTO> {
public class LiveRaceDTO extends RaceMetadataDTO {
private FlagStateDTO flagState;
@@ -37,57 +33,4 @@ public class LiveRaceDTO extends RaceMetadataDTO implements Comparable<LiveRaceD
public void setProgress(RaceProgressDTO progress) {
this.progress = progress;
}
@Override
public int compareTo(LiveRaceDTO o) {
Date thisStart = getStart();
Date otherStart = o.getStart();
if(Util.equalsWithNull(thisStart, otherStart)) {
// cases where both start times are == null or equal
return compareBySecondaryCriteria(o);
}
if(thisStart == null) {
return 1;
}
if(otherStart == null) {
return -1;
}
return -thisStart.compareTo(otherStart);
}
private int compareBySecondaryCriteria(LiveRaceDTO o) {
String thisRegattaName = getRegattaName();
String otherRegattaName = o.getRegattaName();
if(thisRegattaName != otherRegattaName) {
if(thisRegattaName == null) {
return 1;
}
if(otherRegattaName == null) {
return -1;
}
int compareByRegatta = thisRegattaName.compareTo(otherRegattaName);
if(compareByRegatta != 0) {
return compareByRegatta;
}
}
int compareByRace = getRaceName().compareTo(o.getRaceName());
if(compareByRace != 0) {
return compareByRace;
}
FleetMetadataDTO thisFleet = getFleet();
FleetMetadataDTO otherFleet = o.getFleet();
if(thisFleet != otherFleet) {
if(thisFleet == null) {
return 1;
}
if(otherFleet == null) {
return -1;
}
int compareByFleet = thisFleet.compareTo(otherFleet);
if(compareByFleet != 0) {
return compareByFleet;
}
}
return getViewState().compareTo(o.getViewState());
}
}
@@ -4,8 +4,9 @@ import java.util.Date;
import com.google.gwt.user.client.rpc.IsSerializable;
import com.sap.sailing.gwt.ui.client.StringMessages;
import com.sap.sse.common.Util;
public class RaceMetadataDTO implements IsSerializable {
public class RaceMetadataDTO implements IsSerializable, Comparable<RaceMetadataDTO> {
public enum RaceViewState {
PLANNED { // no start time set
@@ -162,4 +163,57 @@ public class RaceMetadataDTO implements IsSerializable {
public void setRegattaDisplayName(String regattaDisplayName) {
this.regattaDisplayName = regattaDisplayName;
}
@Override
public int compareTo(RaceMetadataDTO o) {
Date thisStart = getStart();
Date otherStart = o.getStart();
if(Util.equalsWithNull(thisStart, otherStart)) {
// cases where both start times are == null or equal
return compareBySecondaryCriteria(o);
}
if(thisStart == null) {
return 1;
}
if(otherStart == null) {
return -1;
}
return -thisStart.compareTo(otherStart);
}
private int compareBySecondaryCriteria(RaceMetadataDTO o) {
String thisRegattaName = getRegattaName();
String otherRegattaName = o.getRegattaName();
if(thisRegattaName != otherRegattaName) {
if(thisRegattaName == null) {
return 1;
}
if(otherRegattaName == null) {
return -1;
}
int compareByRegatta = thisRegattaName.compareTo(otherRegattaName);
if(compareByRegatta != 0) {
return compareByRegatta;
}
}
int compareByRace = getRaceName().compareTo(o.getRaceName());
if(compareByRace != 0) {
return compareByRace;
}
FleetMetadataDTO thisFleet = getFleet();
FleetMetadataDTO otherFleet = o.getFleet();
if(thisFleet != otherFleet) {
if(thisFleet == null) {
return 1;
}
if(otherFleet == null) {
return -1;
}
int compareByFleet = thisFleet.compareTo(otherFleet);
if(compareByFleet != 0) {
return compareByFleet;
}
}
return getViewState().compareTo(o.getViewState());
}
}