Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CDS/src/org/icpc/tools/cds/util/PlaybackContest.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public class PlaybackContest extends Contest {
private static final String FILES = "files";
private static final String REACTION = "reaction";
private static final String COUNTRY_FLAG = "country_flag";
private static final String COUNTRY_SUBDIVISION_FLAG = "country_subdivison_flag";
private static final String PACKAGE = "package";
private static final String STATEMENT = "statement";
private static final String BACKUP = "backup";
Expand Down Expand Up @@ -172,6 +173,8 @@ protected void downloadAndSync(RESTContestSource src, IContestObject obj) {
Organization o = (Organization) obj;
o.setLogo(downloadMissingFiles(src, obj, LOGO, o.getLogo()));
o.setCountryFlag(downloadMissingFiles(src, obj, COUNTRY_FLAG, o.getCountryFlag()));
o.setCountrySubdivisionFlag(
downloadMissingFiles(src, obj, COUNTRY_SUBDIVISION_FLAG, o.getCountrySubdivisionFlag()));
} else if (obj instanceof Submission) {
Submission s = (Submission) obj;
s.setFiles(downloadMissingFiles(src, obj, FILES, s.getFiles()));
Expand Down
33 changes: 31 additions & 2 deletions ContestModel/src/org/icpc/tools/contest/model/IOrganization.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ public interface IOrganization extends IContestObject {
String getActualFormalName();

/**
* The nationality of the organization.
* The country of the organization.
*
* @return the nationality
* @return the country
*/
String getCountry();

Expand All @@ -66,6 +66,35 @@ public interface IOrganization extends IContestObject {
*/
BufferedImage getCountryFlagImage(int width, int height, boolean forceLoad, boolean resizeToFit);

/**
* The country subdivision of the organization.
*
* @return the country subdivision
*/
String getCountrySubdivision();

/**
* The file references for the country subdivision flag, which clients can use to see exactly
* what resolutions of country subdivision flags are available.
*
* @return the file reference list
*/
FileReferenceList getCountrySubdivisionFlag();

/**
* The country subdivision flag of the organization.
*
* @return the country flag
*/
File getCountrySubdivisionFlag(int width, int height, boolean force);

/**
* The country subdivision flag of the organization.
*
* @return the country flag
*/
BufferedImage getCountrySubdivisionFlagImage(int width, int height, boolean forceLoad, boolean resizeToFit);

/**
* The url of the organization.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public class DiskContestSource extends ContestSource {
private static final String FILES = "files";
private static final String REACTION = "reaction";
private static final String COUNTRY_FLAG = "country_flag";
private static final String COUNTRY_SUBDIVISON_FLAG = "country_subdivision_flag";
private static final String PACKAGE = "package";
private static final String STATEMENT = "statement";

Expand Down Expand Up @@ -939,6 +940,12 @@ protected void scanForResourceChanges() {
newOrg.setCountryFlag(deleteAndMergeFiles(org.getCountryFlag(), refsOnDisk, addedFiles, removedFiles));
changed = true;
}
refsOnDisk = getFilesWithPattern(newOrg, COUNTRY_SUBDIVISON_FLAG);
if (hasChange(org.getCountrySubdivisionFlag(), refsOnDisk, modifiedFiles)) {
newOrg.setCountrySubdivisionFlag(
deleteAndMergeFiles(org.getCountrySubdivisionFlag(), refsOnDisk, addedFiles, removedFiles));
changed = true;
}

if (changed)
contest.addDirect(newOrg);
Expand Down Expand Up @@ -1131,6 +1138,8 @@ protected FilePattern getLocalPattern(IContestObject.ContestType type, String id
return new FilePattern(type, id, property, LOGO_EXTENSIONS);
if (COUNTRY_FLAG.equals(property))
return new FilePattern(type, id, property, LOGO_EXTENSIONS);
if (COUNTRY_SUBDIVISON_FLAG.equals(property))
return new FilePattern(type, id, property, LOGO_EXTENSIONS);
} else if (type == ContestType.SUBMISSION) {
if (FILES.equals(property))
return new FilePattern(type, id, property, "zip");
Expand Down Expand Up @@ -1213,6 +1222,8 @@ public void attachLocalResources(IContestObject obj) {
Organization org = (Organization) obj;
org.setLogo(mergeRefs(org.getLogo(), getFilesWithPattern(obj, LOGO)));
org.setCountryFlag(mergeRefs(org.getCountryFlag(), getFilesWithPattern(obj, COUNTRY_FLAG)));
org.setCountrySubdivisionFlag(
mergeRefs(org.getCountrySubdivisionFlag(), getFilesWithPattern(obj, COUNTRY_SUBDIVISON_FLAG)));
} else if (obj instanceof Team) {
Team team = (Team) obj;
team.setPhoto(mergeRefs(team.getPhoto(), getFilesWithPattern(obj, PHOTO), defaultTeam.getPhoto()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,28 @@ public class Organization extends ContestObject implements IOrganization {
private static final String ICPC_ID = "icpc_id";
private static final String NAME = "name";
private static final String FORMAL_NAME = "formal_name";
private static final String COUNTRY = "country";
private static final String URL = "url";
private static final String HASHTAG = "twitter_hashtag";
private static final String ACCOUNT = "twitter_account";
private static final String LOCATION = "location";
private static final String LOGO = "logo";
private static final String COUNTRY = "country";
private static final String COUNTRY_FLAG = "country_flag";
private static final String COUNTRY_SUBDIVISION = "country_subdivison";
private static final String COUNTRY_SUBDIVISION_FLAG = "country_subdivision_flag";

private String icpcId;
private String name;
private String formalName;
private String country;
private String url;
private String hashtag;
private String account;
private Location location;
private FileReferenceList logo;
private String country;
private FileReferenceList countryFlag;
private String countrySubdivision;
private FileReferenceList countrySubdivisionFlag;

@Override
public ContestType getType() {
Expand Down Expand Up @@ -63,6 +67,11 @@ public String getCountry() {
return country;
}

@Override
public String getCountrySubdivision() {
return countrySubdivision;
}

@Override
public String getURL() {
return url;
Expand Down Expand Up @@ -130,6 +139,26 @@ public void setCountryFlag(FileReferenceList list) {
countryFlag = list;
}

@Override
public File getCountrySubdivisionFlag(int width, int height, boolean force) {
return getFile(getBestFileReference(countrySubdivisionFlag, new ImageSizeFit(width, height)),
COUNTRY_SUBDIVISION_FLAG, force);
}

@Override
public BufferedImage getCountrySubdivisionFlagImage(int width, int height, boolean forceLoad, boolean resizeToFit) {
return getRefImage(COUNTRY_SUBDIVISION_FLAG, countrySubdivisionFlag, width, height, forceLoad, resizeToFit);
}

@Override
public FileReferenceList getCountrySubdivisionFlag() {
return countrySubdivisionFlag;
}

public void setCountrySubdivisionFlag(FileReferenceList list) {
countrySubdivisionFlag = list;
}

@Override
public Object resolveFileReference(String url2) {
return FileReferenceList.resolve(url2, logo, countryFlag);
Expand All @@ -154,6 +183,10 @@ protected boolean addImpl(String name2, Object value) throws Exception {
country = (String) value;
return true;
}
case COUNTRY_SUBDIVISION: {
countrySubdivision = (String) value;
return true;
}
case URL: {
url = (String) value;
return true;
Expand All @@ -178,6 +211,10 @@ protected boolean addImpl(String name2, Object value) throws Exception {
countryFlag = parseFileReference(value);
return true;
}
case COUNTRY_SUBDIVISION_FLAG: {
countrySubdivisionFlag = parseFileReference(value);
return true;
}
}

return false;
Expand All @@ -193,6 +230,8 @@ public IContestObject clone() {
o.formalName = formalName;
o.country = country;
o.countryFlag = countryFlag;
o.countrySubdivision = countrySubdivision;
o.countrySubdivisionFlag = countrySubdivisionFlag;
o.url = url;
o.hashtag = hashtag;
o.account = account;
Expand All @@ -208,6 +247,8 @@ protected void getProperties(Properties props) {
props.addString(FORMAL_NAME, formalName);
props.addString(COUNTRY, country);
props.addFileRef(COUNTRY_FLAG, countryFlag);
props.addString(COUNTRY_SUBDIVISION, countrySubdivision);
props.addFileRef(COUNTRY_SUBDIVISION_FLAG, countrySubdivisionFlag);
props.addString(URL, url);
props.addString(HASHTAG, hashtag);
props.addString(ACCOUNT, account);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ protected IOrganization filterOrganization(IOrganization org) {
Organization o = (Organization) ((Organization) org).clone();
o.add("country", null);
o.setCountryFlag(null);
o.setCountrySubdivisionFlag(null);
return o;
}

Expand Down
Loading