mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-11-12 13:45:30 +00:00
Print competitor short name and enable sorting
This commit is contained in:
1 parent
a373c5ff77
commit
7d7f6a742e
12 files changed
+285
-229
No files matched your search
+7
-9
@@ -1,7 +1,5 @@
|
||||
package com.sap.sailing.domain.base;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import com.sap.sailing.domain.abstractlog.regatta.RegattaLog;
|
||||
import com.sap.sse.common.Color;
|
||||
import com.sap.sse.common.Duration;
|
||||
@@ -10,7 +8,13 @@ import com.sap.sse.common.NamedWithID;
|
||||
import com.sap.sse.datamining.annotations.Connector;
|
||||
import com.sap.sse.datamining.annotations.Dimension;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
public interface Competitor extends NamedWithID, IsManagedByCache<SharedDomainFactory> {
|
||||
|
||||
String DELIMITER_SHORT_NAME = " / ";
|
||||
String DELIMITER_SAIL_ID = " - ";
|
||||
|
||||
Team getTeam();
|
||||
|
||||
/**
|
||||
@@ -27,13 +31,7 @@ public interface Competitor extends NamedWithID, IsManagedByCache<SharedDomainFa
|
||||
|
||||
String getShortName();
|
||||
|
||||
/**
|
||||
* Returns a derived short information about a competitor depending on the information available
|
||||
* If we have a short name set on the competitor this name will be returned.
|
||||
* If no short name exist but a boat the either the sailId or the boat name will returned.
|
||||
* If all these attributes have no value null is returned.
|
||||
*/
|
||||
String getShortInfo();
|
||||
String getDisplayName();
|
||||
|
||||
/**
|
||||
* A helper to know if the competitor has a boat attached.
|
||||
|
||||
+22
-26
@@ -1,12 +1,5 @@
|
||||
package com.sap.sailing.domain.base.impl;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.Serializable;
|
||||
import java.net.URI;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import com.sap.sailing.domain.base.Competitor;
|
||||
import com.sap.sailing.domain.base.CompetitorChangeListener;
|
||||
import com.sap.sailing.domain.base.Nationality;
|
||||
@@ -15,6 +8,13 @@ import com.sap.sse.common.Color;
|
||||
import com.sap.sse.common.Duration;
|
||||
import com.sap.sse.common.Util;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.Serializable;
|
||||
import java.net.URI;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class CompetitorImpl implements DynamicCompetitor {
|
||||
private static final long serialVersionUID = 294603681016643157L;
|
||||
private final DynamicTeam team;
|
||||
@@ -28,7 +28,7 @@ public class CompetitorImpl implements DynamicCompetitor {
|
||||
private URI flagImage;
|
||||
private Double timeOnTimeFactor;
|
||||
private Duration timeOnDistanceAllowancePerNauticalMile;
|
||||
|
||||
|
||||
public CompetitorImpl(Serializable id, String name, String shortName, Color color, String email, URI flagImage, DynamicTeam team, Double timeOnTimeFactor, Duration timeOnDistanceAllowancePerNauticalMile, String searchTag) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
@@ -42,7 +42,7 @@ public class CompetitorImpl implements DynamicCompetitor {
|
||||
this.searchTag = searchTag;
|
||||
this.listeners = new HashSet<CompetitorChangeListener>();
|
||||
}
|
||||
|
||||
|
||||
private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException {
|
||||
ois.defaultReadObject();
|
||||
listeners = new HashSet<CompetitorChangeListener>();
|
||||
@@ -58,17 +58,6 @@ public class CompetitorImpl implements DynamicCompetitor {
|
||||
return shortName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getShortInfo() {
|
||||
final String result;
|
||||
if (getShortName() != null) {
|
||||
result = getShortName();
|
||||
} else {
|
||||
result = null;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasBoat() {
|
||||
return false;
|
||||
@@ -78,7 +67,7 @@ public class CompetitorImpl implements DynamicCompetitor {
|
||||
public String toString() {
|
||||
return getName();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setName(String newName) {
|
||||
final String oldName = this.name;
|
||||
@@ -100,13 +89,20 @@ public class CompetitorImpl implements DynamicCompetitor {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
if (shortName == null || shortName.length() == 0) {
|
||||
return name;
|
||||
}
|
||||
return shortName + Competitor.DELIMITER_SAIL_ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Serializable getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public DynamicTeam getTeam() {
|
||||
return team;
|
||||
@@ -153,7 +149,7 @@ public class CompetitorImpl implements DynamicCompetitor {
|
||||
}
|
||||
getTeam().removeNationalityChangeListener(listener);
|
||||
}
|
||||
|
||||
|
||||
private Iterable<CompetitorChangeListener> getListeners() {
|
||||
synchronized (listeners) {
|
||||
return new HashSet<CompetitorChangeListener>(listeners);
|
||||
@@ -189,9 +185,9 @@ public class CompetitorImpl implements DynamicCompetitor {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean hasEmail(){
|
||||
public boolean hasEmail() {
|
||||
return email != null && !email.isEmpty();
|
||||
}
|
||||
|
||||
|
||||
+30
-20
@@ -1,27 +1,27 @@
|
||||
package com.sap.sailing.domain.base.impl;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.net.URI;
|
||||
|
||||
import com.sap.sailing.domain.base.Competitor;
|
||||
import com.sap.sailing.domain.base.SharedDomainFactory;
|
||||
import com.sap.sse.common.Color;
|
||||
import com.sap.sse.common.Duration;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.net.URI;
|
||||
|
||||
public class CompetitorWithBoatImpl extends CompetitorImpl implements DynamicCompetitorWithBoat {
|
||||
private static final long serialVersionUID = 22679449208503264L;
|
||||
private DynamicBoat boat;
|
||||
|
||||
|
||||
public CompetitorWithBoatImpl(Serializable id, String name, String shortName, Color color, String email,
|
||||
URI flagImage, DynamicTeam team, Double timeOnTimeFactor, Duration timeOnDistanceAllowancePerNauticalMile,
|
||||
String searchTag, DynamicBoat boat) {
|
||||
URI flagImage, DynamicTeam team, Double timeOnTimeFactor, Duration timeOnDistanceAllowancePerNauticalMile,
|
||||
String searchTag, DynamicBoat boat) {
|
||||
super(id, name, shortName, color, email, flagImage, team, timeOnTimeFactor, timeOnDistanceAllowancePerNauticalMile,
|
||||
searchTag);
|
||||
this.boat = boat;
|
||||
}
|
||||
|
||||
public CompetitorWithBoatImpl(Competitor competitor, DynamicBoat boat) {
|
||||
this(competitor.getId(), competitor.getName(), competitor.getShortName(), competitor.getColor(), competitor.getEmail(),
|
||||
this(competitor.getId(), competitor.getName(), competitor.getShortName(), competitor.getColor(), competitor.getEmail(),
|
||||
competitor.getFlagImage(), (DynamicTeam) competitor.getTeam(), competitor.getTimeOnTimeFactor(),
|
||||
competitor.getTimeOnDistanceAllowancePerNauticalMile(), competitor.getSearchTag(), boat);
|
||||
}
|
||||
@@ -51,28 +51,38 @@ public class CompetitorWithBoatImpl extends CompetitorImpl implements DynamicCom
|
||||
public void clearBoat() {
|
||||
this.boat = null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean hasBoat() {
|
||||
return boat != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getShortInfo() {
|
||||
final String superResult = super.getShortInfo();
|
||||
final String result;
|
||||
if (superResult != null) {
|
||||
result = superResult;
|
||||
} else if (getBoat() != null) {
|
||||
result = getBoat().getSailID() != null ? getBoat().getSailID() : getBoat().getName();
|
||||
} else {
|
||||
result = null;
|
||||
private String getShortInfo() {
|
||||
String shortName = getShortName();
|
||||
if (!hasBoat()) {
|
||||
return shortName;
|
||||
}
|
||||
return result;
|
||||
String boatInfo = getBoat().getSailID() != null ? getBoat().getSailID() : getBoat().getName();
|
||||
if (shortName == null || shortName.length() == 0) {
|
||||
return boatInfo;
|
||||
}
|
||||
if (boatInfo == null || boatInfo.length() == 0) {
|
||||
return shortName;
|
||||
}
|
||||
return shortName + Competitor.DELIMITER_SHORT_NAME + boatInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
String shortInfo = getShortInfo();
|
||||
if (shortInfo == null || shortInfo.length() == 0) {
|
||||
return getName();
|
||||
}
|
||||
return getShortInfo() + Competitor.DELIMITER_SAIL_ID + getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return super.toString()+" with boat "+getBoat();
|
||||
return super.toString() + " with boat " + getBoat();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user