mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-29 23:37:10 +00:00
Merge branch 'master' into feature/procedure_wizard
This commit is contained in:
commit
197b4e039e
204 files changed
+3079
-1336
No files matched your search
+4
@@ -15,6 +15,10 @@ public interface Competitor extends Named, WithID, IsManagedByCache<SharedDomain
|
||||
|
||||
Color getColor();
|
||||
|
||||
String getEmail();
|
||||
|
||||
boolean hasEmail();
|
||||
|
||||
/**
|
||||
* Adds a listener to this competitor. The listener is also added to the boat and the team for changes.
|
||||
* Adding a listener that is already part of this competitor's listeners set remains without effect.
|
||||
|
||||
+2
@@ -6,4 +6,6 @@ public interface CompetitorChangeListener extends BoatChangeListener, Nationalit
|
||||
void colorChanged(Color oldColor, Color newColor);
|
||||
|
||||
void nameChanged(String oldName, String newName);
|
||||
|
||||
void emailChanged(String oldEmail, String newEmail);
|
||||
}
|
||||
+1
-1
@@ -26,5 +26,5 @@ public interface CompetitorFactory {
|
||||
*/
|
||||
boolean isCompetitorToUpdateDuringGetOrCreate(Competitor result);
|
||||
|
||||
Competitor getOrCreateCompetitor(Serializable competitorId, String name, Color displayColor, DynamicTeam team, DynamicBoat boat);
|
||||
Competitor getOrCreateCompetitor(Serializable competitorId, String name, Color displayColor, String email, DynamicTeam team, DynamicBoat boat);
|
||||
}
|
||||
+1
-1
@@ -63,7 +63,7 @@ public interface CompetitorStore extends CompetitorFactory {
|
||||
*
|
||||
* If no competitor with the ID requested is found, the call is a no-op, doing nothing, not even throwing an exception.
|
||||
*/
|
||||
Competitor updateCompetitor(String idAsString, String newName, Color newDisplayColor, String newSailId,
|
||||
Competitor updateCompetitor(String idAsString, String newName, Color newDisplayColor, String newEmail, String newSailId,
|
||||
Nationality newNationality, URI newTeamImageUri);
|
||||
|
||||
CompetitorDTO convertToCompetitorDTO(Competitor c);
|
||||
|
||||
+22
-2
@@ -20,13 +20,15 @@ public class CompetitorImpl implements DynamicCompetitor {
|
||||
private String name;
|
||||
private Color color;
|
||||
private transient Set<CompetitorChangeListener> listeners;
|
||||
private String email;
|
||||
|
||||
public CompetitorImpl(Serializable id, String name, Color color, DynamicTeam team, DynamicBoat boat) {
|
||||
public CompetitorImpl(Serializable id, String name, Color color, String email, DynamicTeam team, DynamicBoat boat) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.team = team;
|
||||
this.boat = boat;
|
||||
this.color = color;
|
||||
this.email = email;
|
||||
this.listeners = new HashSet<CompetitorChangeListener>();
|
||||
}
|
||||
|
||||
@@ -73,7 +75,7 @@ public class CompetitorImpl implements DynamicCompetitor {
|
||||
|
||||
@Override
|
||||
public Competitor resolve(SharedDomainFactory domainFactory) {
|
||||
Competitor result = domainFactory.getOrCreateCompetitor(getId(), getName(), getColor(), getTeam(), getBoat());
|
||||
Competitor result = domainFactory.getOrCreateCompetitor(getId(), getName(), getColor(), getEmail(), getTeam(), getBoat());
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -114,4 +116,22 @@ public class CompetitorImpl implements DynamicCompetitor {
|
||||
return new HashSet<CompetitorChangeListener>(listeners);
|
||||
}
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String newEmail) {
|
||||
final String oldEmail = this.email;
|
||||
if (!Util.equalsWithNull(oldEmail, newEmail)) {
|
||||
this.email = newEmail;
|
||||
for (CompetitorChangeListener listener : getListeners()) {
|
||||
listener.emailChanged(oldEmail, newEmail);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasEmail(){
|
||||
return email != null && !email.isEmpty();
|
||||
}
|
||||
}
|
||||
+4
-1
@@ -6,7 +6,10 @@ import com.sap.sse.common.Color;
|
||||
|
||||
public interface DynamicCompetitor extends Competitor, Renamable {
|
||||
DynamicBoat getBoat();
|
||||
|
||||
DynamicTeam getTeam();
|
||||
|
||||
|
||||
void setColor(Color displayColor);
|
||||
|
||||
void setEmail(String email);
|
||||
}
|
||||
+2
-2
@@ -332,11 +332,11 @@ public class SharedDomainFactoryImpl implements SharedDomainFactory {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Competitor getOrCreateCompetitor(Serializable competitorId, String name, Color displayColor, DynamicTeam team, DynamicBoat boat) {
|
||||
public Competitor getOrCreateCompetitor(Serializable competitorId, String name, Color displayColor, String email, DynamicTeam team, DynamicBoat boat) {
|
||||
if (logger.isLoggable(Level.FINEST)) {
|
||||
logger.log(Level.FINEST, "getting or creating competitor "+name+" with ID "+competitorId+" in domain factory "+this);
|
||||
}
|
||||
return getCompetitorStore().getOrCreateCompetitor(competitorId, name, displayColor, team, boat);
|
||||
return getCompetitorStore().getOrCreateCompetitor(competitorId, name, displayColor, email, team, boat);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+8
-7
@@ -68,8 +68,8 @@ public class TransientCompetitorStoreImpl implements CompetitorStore, Serializab
|
||||
listeners.remove(listener);
|
||||
}
|
||||
|
||||
private Competitor createCompetitor(Serializable id, String name, Color displayColor, DynamicTeam team, DynamicBoat boat) {
|
||||
Competitor result = new CompetitorImpl(id, name, displayColor, team, boat);
|
||||
private Competitor createCompetitor(Serializable id, String name, Color displayColor, String email, DynamicTeam team, DynamicBoat boat) {
|
||||
Competitor result = new CompetitorImpl(id, name, displayColor, email, team, boat);
|
||||
addNewCompetitor(id, result);
|
||||
if (logger.isLoggable(Level.FINEST)) {
|
||||
logger.log(Level.FINEST, "Created competitor "+name+" with ID "+id, new Exception("Here is where it happened"));
|
||||
@@ -93,20 +93,20 @@ public class TransientCompetitorStoreImpl implements CompetitorStore, Serializab
|
||||
}
|
||||
|
||||
@Override
|
||||
public Competitor getOrCreateCompetitor(Serializable competitorId, String name, Color displayColor, DynamicTeam team, DynamicBoat boat) {
|
||||
public Competitor getOrCreateCompetitor(Serializable competitorId, String name, Color displayColor, String email, DynamicTeam team, DynamicBoat boat) {
|
||||
Competitor result = getExistingCompetitorById(competitorId); // avoid synchronization for successful read access
|
||||
if (result == null) {
|
||||
LockUtil.lockForWrite(lock);
|
||||
try {
|
||||
result = getExistingCompetitorById(competitorId); // try again, now while holding the write lock
|
||||
if (result == null) {
|
||||
result = createCompetitor(competitorId, name, displayColor, team, boat);
|
||||
result = createCompetitor(competitorId, name, displayColor, email, team, boat);
|
||||
}
|
||||
} finally {
|
||||
LockUtil.unlockAfterWrite(lock);
|
||||
}
|
||||
} else if (isCompetitorToUpdateDuringGetOrCreate(result)) {
|
||||
updateCompetitor(result.getId().toString(), name, displayColor, boat.getSailID(), team.getNationality(),
|
||||
updateCompetitor(result.getId().toString(), name, displayColor, email, boat.getSailID(), team.getNationality(),
|
||||
team.getImage());
|
||||
competitorNoLongerToUpdateDuringGetOrCreate(result);
|
||||
}
|
||||
@@ -191,7 +191,7 @@ public class TransientCompetitorStoreImpl implements CompetitorStore, Serializab
|
||||
}
|
||||
|
||||
@Override
|
||||
public Competitor updateCompetitor(String idAsString, String newName, Color newDisplayColor, String newSailId,
|
||||
public Competitor updateCompetitor(String idAsString, String newName, Color newDisplayColor, String newEmail, String newSailId,
|
||||
Nationality newNationality, URI newTeamImageUri) {
|
||||
DynamicCompetitor competitor = (DynamicCompetitor) getExistingCompetitorByIdAsString(idAsString);
|
||||
if (competitor != null) {
|
||||
@@ -199,6 +199,7 @@ public class TransientCompetitorStoreImpl implements CompetitorStore, Serializab
|
||||
try {
|
||||
competitor.setName(newName);
|
||||
competitor.setColor(newDisplayColor);
|
||||
competitor.setEmail(newEmail);
|
||||
competitor.getBoat().setSailId(newSailId);
|
||||
competitor.getTeam().setNationality(newNationality);
|
||||
competitor.getTeam().setImage(newTeamImageUri);
|
||||
@@ -229,7 +230,7 @@ public class TransientCompetitorStoreImpl implements CompetitorStore, Serializab
|
||||
if (competitorDTO == null) {
|
||||
final Nationality nationality = c.getTeam().getNationality();
|
||||
CountryCode countryCode = nationality == null ? null : nationality.getCountryCode();
|
||||
competitorDTO = new CompetitorDTOImpl(c.getName(), c.getColor(), countryCode == null ? ""
|
||||
competitorDTO = new CompetitorDTOImpl(c.getName(), c.getColor(), c.getEmail(), countryCode == null ? ""
|
||||
: countryCode.getTwoLetterISOCode(), countryCode == null ? ""
|
||||
: countryCode.getThreeLetterIOCCode(), countryCode == null ? "" : countryCode.getName(), c
|
||||
.getBoat().getSailID(), c.getId().toString(), new BoatClassDTO(c.getBoat().getBoatClass()
|
||||
|
||||
Reference in new issue
Block a user