emit nationalityISO2 and nationalityISO3 from listevents

This commit is contained in:
Axel Uhl committed 2011-06-16 23:46:50 +02:00
1 parent 09505280e9
commit f91011b480
4 files changed
+27 -10

No files matched your search

@@ -1,5 +1,9 @@
package com.sap.sailing.domain.base;
import com.sap.sailing.util.CountryCode;
public interface Nationality extends Named, WithImage {
String getThreeLetterAcronym();
String getThreeLetterIOCAcronym();
CountryCode getCountryCode();
}
@@ -3,16 +3,18 @@ package com.sap.sailing.domain.base.impl;
import java.io.InputStream;
import com.sap.sailing.domain.base.Nationality;
import com.sap.sailing.util.CountryCode;
import com.sap.sailing.util.CountryCodeFactory;
public class NationalityImpl extends NamedImpl implements Nationality {
private final String threeLetterAcronym;
private final String threeLetterIOCAcronym;
public NationalityImpl(String name, String threeLetterAcronym) {
public NationalityImpl(String name, String threeLetterIOCAcronym) {
super(name);
if (threeLetterAcronym.length() != 3) {
throw new IllegalArgumentException("Three-letter nationality acronym \""+threeLetterAcronym+"\" doesn't have three letters.");
if (threeLetterIOCAcronym.length() != 3) {
throw new IllegalArgumentException("Three-letter IOC nationality acronym \""+threeLetterIOCAcronym+"\" doesn't have three letters.");
}
this.threeLetterAcronym = threeLetterAcronym;
this.threeLetterIOCAcronym = threeLetterIOCAcronym;
}
@Override
@@ -21,8 +23,13 @@ public class NationalityImpl extends NamedImpl implements Nationality {
}
@Override
public String getThreeLetterAcronym() {
return threeLetterAcronym;
public String getThreeLetterIOCAcronym() {
return threeLetterIOCAcronym;
}
@Override
public CountryCode getCountryCode() {
return CountryCodeFactory.INSTANCE.getFromThreeLetterIOCName(getThreeLetterIOCAcronym());
}
}
@@ -32,6 +32,7 @@ import com.sap.sailing.domain.tracking.TrackedLegOfCompetitor;
import com.sap.sailing.domain.tracking.TrackedRace;
import com.sap.sailing.domain.tracking.Wind;
import com.sap.sailing.server.util.InvalidDateException;
import com.sap.sailing.util.CountryCode;
public class ModeratorApp extends Servlet {
private static final long serialVersionUID = 1333207389294903999L;
@@ -347,7 +348,10 @@ public class ModeratorApp extends Servlet {
for (Competitor competitor : event.getCompetitors()) {
JSONObject jsonCompetitor = new JSONObject();
jsonCompetitor.put("name", competitor.getName());
jsonCompetitor.put("nationality", competitor.getTeam().getNationality().getThreeLetterAcronym());
jsonCompetitor.put("nationality", competitor.getTeam().getNationality().getThreeLetterIOCAcronym());
CountryCode countryCode = competitor.getTeam().getNationality().getCountryCode();
jsonCompetitor.put("nationalityISO2", countryCode == null ? "" : countryCode.getTwoLetterISOCode());
jsonCompetitor.put("nationalityISO3", countryCode == null ? "" : countryCode.getThreeLetterISOCode());
JSONArray jsonTeam = new JSONArray();
for (Person sailor : competitor.getTeam().getSailors()) {
JSONObject jsonSailor = new JSONObject();