();
+
+ private boolean filteringGroups = false;
+
/**
* filtering for this site only
*/
@@ -180,6 +194,12 @@ public class Filter implements Serializable {
private boolean filteringDeleted = false;
+ public void setContestAndController(IInternalContest inContest, IInternalController inController) {
+ this.contest = inContest;
+ this.controller = inController;
+ log = controller.getLog();
+ }
+
private ElementId getJudgementId(Run run) {
JudgementRecord judgementRecord = run.getJudgementRecord();
if (judgementRecord != null) {
@@ -187,10 +207,10 @@ private ElementId getJudgementId(Run run) {
}
return null;
}
-
+
/**
* Returns true ("matching") if Run matches filter criteria.
- *
+ *
* @param run
* @return true if the Run maches the filter, false otherwise.
*/
@@ -222,13 +242,13 @@ public boolean isFilteringDeleted() {
/**
* Match criteria against a clar.
- *
+ *
* @param clarification
* @return true if the clarifications matches the filter
*/
public boolean matches(Clarification clarification) {
if (filterEnabled){
- return matchesSites(clarification) && matchesAccount(clarification.getSubmitter()) && matchesClarificationState(clarification.getState())
+ return matchesSites(clarification) && matchesAccount(clarification.getSubmitter()) && matchesClarificationState(clarification.getState())
&& matchesProblem(clarification.getProblemId()) && matchesLanguage(clarification.getLanguageId()) && matchesElapsedTimeSubmission(clarification);
} else {
@@ -238,7 +258,7 @@ public boolean matches(Clarification clarification) {
/**
* Match criteria against a clientId.
- *
+ *
* @param clientId
* @return true if the sites match
*/
@@ -281,7 +301,7 @@ public void setUsingJudgementFilter(boolean turnOn) {
/**
* Is filtering using judgement list.
- *
+ *
* @return true if filter judgements.
*/
public boolean isFilteringJudgements() {
@@ -290,7 +310,7 @@ public boolean isFilteringJudgements() {
/**
* Add a judgement to match against.
- *
+ *
* @param judgement
*/
public void addJudgement(Judgement judgement) {
@@ -299,9 +319,9 @@ public void addJudgement(Judgement judgement) {
/**
* Add a judgement to match against.
- *
+ *
* Also turns filtering on for judgement list.
- *
+ *
* @param elementId
*/
private void addJudgement(ElementId elementId) {
@@ -311,24 +331,25 @@ private void addJudgement(ElementId elementId) {
/**
* Return true if judgement filter ON and matches a judgement in the filter list.
- *
+ *
* @param judgement
*/
public boolean matches(Judgement judgement) {
return matchesJudgement(judgement.getElementId());
}
/**
- *
+ *
* @param judgement
* @deprecated use {@link #matches(Judgement)}
*/
+ @Deprecated
public boolean matchesJudgement(Judgement judgement) {
return matchesJudgement(judgement.getElementId());
}
/**
* Return true if judgement filter ON and matches a judgement in the filter list.
- *
+ *
* @param judgementId
*/
public boolean matchesJudgement(ElementId judgementId) {
@@ -351,7 +372,7 @@ public void setUsingProblemFilter(boolean turnOn) {
/**
* Is filtering using problem list.
- *
+ *
* @return true if filter problems.
*/
public boolean isFilteringProblems() {
@@ -360,7 +381,7 @@ public boolean isFilteringProblems() {
/**
* Add a problem to match against.
- *
+ *
* @param problem
*/
public void addProblem(Problem problem) {
@@ -369,19 +390,19 @@ public void addProblem(Problem problem) {
/**
* Add a problem to match against.
- *
+ *
* Also turns filtering on for problem list.
- *
+ *
* @param elementId
*/
private void addProblem(ElementId elementId) {
problemIdHash.put(elementId, new Date());
filteringProblems = true;
}
-
+
/**
* Add a permission type to match against.
- *
+ *
* @param type
*/
public void addPermission(Permission.Type type) {
@@ -391,31 +412,49 @@ public void addPermission(Permission.Type type) {
/**
* Return true if problem filter ON and matches a problem in the filter list.
- *
+ *
* @param problem
* @deprecated use {@link #matches(Problem)}
*/
+ @Deprecated
public boolean matchesProblem(Problem problem) {
return matches(problem);
}
-
+
public boolean matches(Problem problem) {
return matchesProblem(problem.getElementId());
}
/**
* Return true if problem filter ON and matches a problem in the filter list.
- *
+ *
* @param problemId
*/
public boolean matchesProblem(ElementId problemId) {
+ boolean match = true;
if (filteringProblems) {
- return problemIdHash.containsKey(problemId);
- } else {
- return true;
+ match = problemIdHash.containsKey(problemId);
+ if(!match) {
+ return(false);
+ }
}
+ if(filteringGroups) {
+ if(contest != null) {
+ Problem problem = contest.getProblem(problemId);
+ if(problem != null) {
+ match = false;
+ for(ElementId groupElementId : groupIdHash) {
+ if(problem.canView(contest.getGroup(groupElementId))) {
+ match = true;
+ break;
+ }
+ }
+ }
+ }
+ }
+ return(match);
}
-
+
public boolean matches(Permission.Type type) {
if (filteringPermissions) {
return permissionsHash.containsKey(type);
@@ -423,8 +462,8 @@ public boolean matches(Permission.Type type) {
return true;
}
}
-
-
+
+
public void setUsingPermissionFilter (boolean turnOn){
filteringPermissions = turnOn;
}
@@ -435,14 +474,14 @@ public void setUsingLanguageFilter(boolean turnOn) {
/**
* Turn the sites filter on or off.
- *
+ *
* This does not clear the sites filter information,
* the {@link #matches(Run)} and other matches
* methods will ignore the sites criteria.
*
* The {@link #addSite(int)} and {@link #addSite(Site)} will
* effectively invoke a setUsingSitesFilter(true).
- *
+ *
* @param turnOn true means ignore site criteria
*/
public void setUsingSitesFilter(boolean turnOn) {
@@ -452,19 +491,36 @@ public void setUsingSitesFilter(boolean turnOn) {
public boolean isFilteringSites() {
return filteringSites;
}
-
+
+ /**
+ * Enable or disable the filtering based on groups
+ * @param turnOn
+ */
+ public void setUsingGroupsFilter(boolean turnOn) {
+ filteringGroups = turnOn;
+ }
+
+ /**
+ * Return indicating if filtering on groups is desired
+ *
+ * @return true if filtering by groups, false otherwise
+ */
+ public boolean isFilteringGroups() {
+ return filteringGroups;
+ }
+
/**
* Is filtering using permissions list.
- *
+ *
* @return true if filter languages.
*/
public boolean isFilteringPermissions() {
return filteringPermissions;
}
-
+
/**
* Is filtering using language list.
- *
+ *
* @return true if filter languages.
*/
public boolean isFilteringLanguages() {
@@ -473,7 +529,7 @@ public boolean isFilteringLanguages() {
/**
* Add a language to match against.
- *
+ *
* @param language
*/
public void addLanguage(Language language) {
@@ -482,9 +538,9 @@ public void addLanguage(Language language) {
/**
* Add a language to match against.
- *
+ *
* Also turns filtering on for language list.
- *
+ *
* @param elementId
*/
private void addLanguage(ElementId elementId) {
@@ -494,22 +550,23 @@ private void addLanguage(ElementId elementId) {
/**
* Return true if language filter ON and matches a language in the filter list.
- *
+ *
* @param language
* @deprecated use {@link #matches(Language)}
*/
-
+
+ @Deprecated
public boolean matchesLanguage(Language language) {
return matchesLanguage(language.getElementId());
}
-
+
public boolean matches(Language language) {
return matchesLanguage(language.getElementId());
}
/**
* Return true if language filter ON and matches a language in the filter list.
- *
+ *
* @param languageId
*/
public boolean matchesLanguage(ElementId languageId) {
@@ -522,7 +579,7 @@ public boolean matchesLanguage(ElementId languageId) {
/**
* Add a site to match against.
- *
+ *
* @param site
*/
public void addSite(Site site) {
@@ -531,16 +588,16 @@ public void addSite(Site site) {
/**
* Add a site to match against.
- *
+ *
* Also turns filtering on for site list.
- *
+ *
* @param siteNumber
*/
public void addSite(int siteNumber) {
siteIdHash.put(new Integer(siteNumber), new Date());
filteringSites = true;
}
-
+
/**
* Returns true if submission matches sites filter.
* @param submission a run or clarification
@@ -561,41 +618,102 @@ private boolean matchesSites(int siteNumber) {
/**
* Return true if site filter ON and matches a site in the filter list.
- *
+ *
* @param site
* @deprecated use {@link #matches(Site)}
*/
+ @Deprecated
public boolean matchesSite(Site site) {
return matches(site);
}
-
+
public boolean matches(Site site) {
return matchesSites(site.getSiteNumber());
}
/**
- *
+ * Add a group to match against.
+ *
+ * Also turns filtering on for groups hashset.
+ *
+ * @param group the group to add to the filter
+ */
+ public void addGroup(Group group) {
+ if(group != null) {
+ addGroup(group.getElementId());
+ }
+ }
+
+ /**
+ * Add a group element to match against.
+ *
+ * Also turns filtering on for groups hashset.
+ *
+ * @param groupElementId
+ */
+ public void addGroup(ElementId groupElementId) {
+ groupIdHash.add(groupElementId);
+ filteringGroups = true;
+ }
+
+ private boolean matchesGroups(ElementId groupElementId) {
+ if(filteringGroups) {
+ return groupIdHash.contains(groupElementId);
+ }
+ return(true);
+ }
+
+ /**
+ * Determine if any groups in the supplied set are groups in the filter.
+ *
+ * @param groups to check
+ * @return true if there is any group in groups that's allowed by the filter, false otherwise
+ */
+ public boolean matches(Collection groups) {
+ if(filteringGroups && groups != null) {
+ return !Collections.disjoint(groups, groupIdHash);
+ }
+ return(true);
+ }
+
+ /**
+ * Determine if the supplied group is allowed by the filter
+ *
+ * @param group
+ * @return true if the group is allowed, false otherwise
+ */
+ public boolean matches(Group group) {
+ return matchesGroups(group.getElementId());
+ }
+
+ /**
+ *
* @param account
* @return
* @deprecated use {@link #matches(Account)}
*/
+ @Deprecated
public boolean matchesAccount(Account account) {
return matches(account);
}
-
-
+
+
public boolean matches(Account account) {
-
+
ClientId clientId = account.getClientId();
-
+
if (! matchesSites(clientId.getSiteNumber())) {
return false;
}
-
+
+ if (! matches(account.getGroupIds())) {
+ return false;
+ }
+
if (! matchesPermission(account)) {
return false;
}
-
+
if (filteringAccounts) {
if (matches(clientId)) {
return matches(clientId.getClientType());
@@ -605,13 +723,13 @@ public boolean matches(Account account) {
return true;
}
}
-
+
public Permission.Type[] getPermissionsList() {
Permission.Type[] permList = new Permission.Type[permissionsHash.size()];
Enumeration enumeration = permissionsHash.keys();
int i = 0;
while (enumeration.hasMoreElements()) {
- Permission.Type element = (Permission.Type) enumeration.nextElement();
+ Permission.Type element = enumeration.nextElement();
permList[i] = element;
i++;
}
@@ -619,12 +737,12 @@ public Permission.Type[] getPermissionsList() {
}
private boolean matchesPermission(Account account) {
-
+
if (filteringPermissions) {
Enumeration enumeration = permissionsHash.keys();
while (enumeration.hasMoreElements()) {
- Permission.Type type = (Permission.Type) enumeration.nextElement();
+ Permission.Type type = enumeration.nextElement();
if (!account.isAllowed(type)) {
return false;
}
@@ -656,28 +774,32 @@ public boolean matches(Type type) {
/**
* Client Id matches both account filter and sites filter.
- *
+ *
* @param clientId
* @return true if matches filter criteria
*/
public boolean matchesAccount(ClientId clientId) {
+ if(!matchesSites(clientId)) {
+ return false;
+ }
if (filteringAccounts) {
// System.out.println(new FilterFormatter().getClientsShortList(getAccountList()));
-
- if (matchesSites(clientId)) {
- if (clientIdHash.size() == 0) {
- return true;
- } else {
- return clientIdHash.containsKey(clientId);
- }
- } else {
+
+ if (clientIdHash.size() != 0 && !clientIdHash.containsKey(clientId)) {
return false;
}
- } else {
- return matchesSites(clientId);
}
+ if(filteringGroups) {
+ if(contest != null) {
+ Account account = contest.getAccount(clientId);
+ if(account != null && !matches(account.getGroupIds())) {
+ return false;
+ }
+ }
+ }
+ return true;
}
-
+
/**
* Clear judgements and turn judgement filtering off.
*
@@ -697,7 +819,7 @@ public void clearAccountList() {
filteringAccounts = false;
clientIdHash = new Hashtable();
}
-
+
public void clearClientTypesList() {
clientTypeHash = new Hashtable();
}
@@ -710,11 +832,11 @@ public void clearProblemList() {
filteringProblems = false;
problemIdHash = new Hashtable();
}
-
+
public void clearPermissionsList() {
permissionsHash = new Hashtable();
}
-
+
/**
* Clear language and turn language filtering off.
*
@@ -723,7 +845,7 @@ public void clearLanguageList() {
filteringLanguages = false;
languageIdHash = new Hashtable();
}
-
+
/**
* Clear site and turn site filtering off.
*
@@ -733,6 +855,14 @@ public void clearSiteList() {
siteIdHash = new Hashtable();
}
+ /**
+ * Clear groups filter and turn of group filtering
+ */
+ public void clearGroupsList() {
+ filteringGroups = false;
+ groupIdHash.clear();
+ }
+
/**
* Remove the input site from the site filter.
* @param site
@@ -740,7 +870,7 @@ public void clearSiteList() {
public void removeSite(Site site) {
if (siteIdHash.containsKey(site.getSiteNumber())) {
siteIdHash.remove(site.getSiteNumber());
- // TODO add setUsingSitesFilter(false);
+ // TODO add setUsingSitesFilter(false);
}
}
@@ -751,10 +881,10 @@ public void removeSite(Site site) {
public void removeProblem(Problem problem) {
if (problemIdHash.containsKey(problem.getElementId())) {
problemIdHash.remove(problem.getElementId());
- // TODO add setUsingProblemFilter(false);
+ // TODO add setUsingProblemFilter(false);
}
}
-
+
/**
* Remove permission from the permission filter.
* @param permission
@@ -764,10 +894,10 @@ public void removePermission(Permission.Type type) {
permissionsHash.remove(type);
}
}
-
+
/**
* Remove language from the language filter.
- *
+ *
* @param language
*/
public void removeLanguage(Language language) {
@@ -776,10 +906,16 @@ public void removeLanguage(Language language) {
}
}
-
+ public void removeGroup(Group group) {
+ groupIdHash.remove(group.getElementId());
+ if(filteringGroups && groupIdHash.isEmpty()) {
+ filteringGroups = false;
+ }
+ }
+
/**
* Get list of ElementIds for the judgement in the filter list.
- *
+ *
* @return list of element ids.
*/
public ElementId[] getJudgementIdList() {
@@ -787,17 +923,17 @@ public ElementId[] getJudgementIdList() {
Enumeration enumeration = judgementIdHash.keys();
int i = 0;
while (enumeration.hasMoreElements()) {
- ElementId element = (ElementId) enumeration.nextElement();
+ ElementId element = enumeration.nextElement();
elementIds[i] = element;
i++;
}
return elementIds;
}
-
+
/**
* Get list of ElementIds for the problems in the filter list.
- *
+ *
* @return list of element ids.
*/
public ElementId[] getProblemIdList() {
@@ -805,16 +941,16 @@ public ElementId[] getProblemIdList() {
Enumeration enumeration = problemIdHash.keys();
int i = 0;
while (enumeration.hasMoreElements()) {
- ElementId element = (ElementId) enumeration.nextElement();
+ ElementId element = enumeration.nextElement();
elementIds[i] = element;
i++;
}
return elementIds;
}
-
+
/**
* Get list of ElementIds for the languages in the filter list.
- *
+ *
* @return list of element ids.
*/
public ElementId[] getLanguageIdList() {
@@ -822,7 +958,7 @@ public ElementId[] getLanguageIdList() {
Enumeration enumeration = languageIdHash.keys();
int i = 0;
while (enumeration.hasMoreElements()) {
- ElementId element = (ElementId) enumeration.nextElement();
+ ElementId element = enumeration.nextElement();
elementIds[i] = element;
i++;
}
@@ -831,7 +967,7 @@ public ElementId[] getLanguageIdList() {
/**
* Get list of ElementIds for the sites in the filter list.
- *
+ *
* @return list of element ids.
*/
public Integer[] getSiteIdList() {
@@ -839,16 +975,16 @@ public Integer[] getSiteIdList() {
Enumeration enumeration = siteIdHash.keys();
int i = 0;
while (enumeration.hasMoreElements()) {
- Integer element = (Integer) enumeration.nextElement();
+ Integer element = enumeration.nextElement();
elementIds[i] = element;
i++;
}
return elementIds;
}
-
+
/**
* Get list of ClientIds for the accounts in the filter list.
- *
+ *
* @return list of ClientId.
*/
public ClientId[] getAccountList() {
@@ -856,16 +992,16 @@ public ClientId[] getAccountList() {
Enumeration enumeration = clientIdHash.keys();
int i = 0;
while (enumeration.hasMoreElements()) {
- ClientId element = (ClientId) enumeration.nextElement();
+ ClientId element = enumeration.nextElement();
clientIds[i] = element;
i++;
}
return clientIds;
}
-
+
/**
* Get list of Types in filter.
- *
+ *
* @return
*/
public ClientType.Type[] getClientTypes() {
@@ -873,14 +1009,30 @@ public ClientType.Type[] getClientTypes() {
Enumeration enumeration = clientTypeHash.keys();
int i = 0;
while (enumeration.hasMoreElements()) {
- ClientType.Type value = (ClientType.Type) enumeration.nextElement();
+ ClientType.Type value = enumeration.nextElement();
types[i] = value;
i++;
}
return types;
-
+
}
-
+
+
+ /**
+ * Get list of ElementIds for the groups in the filter list.
+ *
+ * @return list of element ids.
+ */
+ public ElementId [] getGroupIdList() {
+ ElementId [] elementIds = new ElementId[groupIdHash.size()];
+ int i = 0;
+ for(ElementId groupElementId : groupIdHash) {
+ elementIds[i] = groupElementId;
+ i++;
+ }
+ return elementIds;
+ }
+
public void setUsingRunStatesFilter(boolean turnOn) {
filteringRunStates = turnOn;
}
@@ -888,7 +1040,7 @@ public void setUsingRunStatesFilter(boolean turnOn) {
public boolean isFilteringRunStates() {
return filteringRunStates;
}
-
+
/**
* Add an account to filter with.
* @param account
@@ -939,11 +1091,12 @@ public void addRunState(RunStates runStates) {
}
/**
- *
+ *
* @param runStates
* @return
* @deprecated use {@link #matches(RunStates)}
*/
+ @Deprecated
public boolean matchesRunState(RunStates runStates) {
return matches(runStates);
}
@@ -956,7 +1109,7 @@ public boolean matches(RunStates runStates) {
}
}
-
+
public boolean matchesElapsedTime(Run run) {
return matchesElapsedTimeSubmission(run);
}
@@ -969,7 +1122,7 @@ public boolean matchesElapsedTimeSubmission(Submission submission) {
long elapsedTime = submission.getElapsedMins();
return matchesElapsedTime(elapsedTime);
}
-
+
protected boolean matchesElapsedTime(long elapsedTimeMinutes) {
if (filteringElapsedTime) {
if (startElapsedTimeMinutes != -1) {
@@ -1013,7 +1166,7 @@ public ClarificationStates[] getClarificationStatesList() {
Enumeration enumeration = clarificationStateHash.keys();
int i = 0;
while (enumeration.hasMoreElements()) {
- clarificationStates[i] = (ClarificationStates) enumeration.nextElement();
+ clarificationStates[i] = enumeration.nextElement();
i++;
}
return clarificationStates;
@@ -1024,17 +1177,18 @@ public RunStates[] getRunStates() {
Enumeration enumeration = runStateHash.keys();
int i = 0;
while (enumeration.hasMoreElements()) {
- runStates[i] = (RunStates) enumeration.nextElement();
+ runStates[i] = enumeration.nextElement();
i++;
}
return runStates;
}
/**
- *
+ *
* @param clarificationStates
* @return
* @deprecated use {@link #matches(ClarificationStates)}
*/
+ @Deprecated
public boolean matchesClarificationState(ClarificationStates clarificationStates) {
return matches(clarificationStates);
}
@@ -1056,12 +1210,13 @@ public void clearClarificationStateList() {
clarificationStateHash = new Hashtable();
}
+ @Override
public String toString() {
if (filterEnabled) {
-
+
String filterInfo = "Filter ON";
-
+
if (thisSiteOnly || filteringSites) {
filterInfo += " Site(s) ";
}
@@ -1081,10 +1236,13 @@ public String toString() {
filterInfo += " clar state(s)";
}
if (filteringAccounts) {
- filterInfo += " account(s))";
+ filterInfo += " account(s)";
}
if (filteringPermissions) {
- filterInfo += " permissions(s))";
+ filterInfo += " permissions(s)";
+ }
+ if (filteringGroups) {
+ filterInfo += " groups(s)";
}
return filterInfo;
@@ -1146,22 +1304,23 @@ public void setFilterOff() {
public void setFilter (boolean filterOn){
filterEnabled = filterOn;
}
-
+
public void setFilterOn () {
filterEnabled = true;
}
/**
* Is one of the filters active?.
- *
+ *
* @return true if filter is on, false if not filtering.
*/
public boolean isFilterOn() {
if (filterEnabled) {
- return filteringSites || filteringAccounts || filteringClarificationStates || filteringProblems
+ return filteringSites || filteringAccounts || filteringClarificationStates || filteringProblems
|| filteringJudgements || filteringLanguages || filteringElapsedTime || filteringRunStates
|| filteringPermissions
- || thisSiteOnly;
+ || thisSiteOnly
+ || filteringGroups;
} else {
return false;
}
@@ -1179,10 +1338,10 @@ public void clearElapsedTimeRange() {
endElapsedTimeMinutes = -1;
filteringElapsedTime = false;
}
-
+
/**
* Count the runs that match this filter.
- *
+ *
* @param runs - list of runs
* @return number of runs that match this filter.
*/
@@ -1210,7 +1369,7 @@ public int countClarifications(Clarification[] clarifications) {
}
return count;
}
-
+
/**
* Count the accounts that match this filter.
* @param accounts
@@ -1225,7 +1384,7 @@ public int countAccounts (Account [] accounts) {
}
return count;
}
-
+
/**
* Count the ClientIds that match this filter.
* @param clientIds
@@ -1240,10 +1399,10 @@ public int countClientIds (ClientId [] clientIds) {
}
return count;
}
-
+
/**
* Returns list of runs for current filter.
- *
+ *
* @param runs
* @return list of runs which match this filter.
*/
@@ -1257,12 +1416,12 @@ public Run[] getRuns(Run[] runs) {
}
}
- return (Run[]) listOfRuns.toArray(new Run[listOfRuns.size()]);
+ return listOfRuns.toArray(new Run[listOfRuns.size()]);
}
/**
* Returns list of clarifications for current filter.
- *
+ *
* @param clarifications
* @return list of clarifications which match this filter.
*/
@@ -1276,7 +1435,7 @@ public Clarification[] getClarifications(Clarification[] clarifications) {
}
}
- return (Clarification[]) list.toArray(new Clarification[list.size()]);
+ return list.toArray(new Clarification[list.size()]);
}
public boolean matchesElapsedTime(RunTestCase runTestCaseResult) {
@@ -1286,7 +1445,7 @@ public boolean matchesElapsedTime(RunTestCase runTestCaseResult) {
public void setFilteringDeleted(boolean b) {
filteringDeleted = b;
-
+
}
}
diff --git a/src/edu/csus/ecs/pc2/core/report/EventFeedJSONReport.java b/src/edu/csus/ecs/pc2/core/report/EventFeedJSONReport.java
index 96506a652..656183989 100644
--- a/src/edu/csus/ecs/pc2/core/report/EventFeedJSONReport.java
+++ b/src/edu/csus/ecs/pc2/core/report/EventFeedJSONReport.java
@@ -17,13 +17,13 @@
/**
* Event Feed JSON report.
- *
+ *
* @author Douglas A. Lane, PC^2 Team, pc2@ecs.csus.edu
*/
public class EventFeedJSONReport implements IReport {
/**
- *
+ *
*/
private static final long serialVersionUID = -3444824680719793748L;
@@ -34,7 +34,7 @@ public class EventFeedJSONReport implements IReport {
private Log log;
private Filter filter = new Filter();
-
+
private void writeContestTime(PrintWriter printWriter) {
printWriter.println();
GregorianCalendar resumeTime = contest.getContestTime().getResumeTime();
@@ -46,31 +46,38 @@ private void writeContestTime(PrintWriter printWriter) {
}
}
+ @Override
public void writeReport(PrintWriter printWriter) throws IllegalContestState {
-
+
EventFeedJSON efEventFeedJSON = new EventFeedJSON(contest);
-
+
+ if(filter != null) {
+ efEventFeedJSON.setFilter(filter);
+ }
String s = efEventFeedJSON.createJSON(contest, null, null);
-
+
printWriter.print(s);
}
+ @Override
public void printHeader(PrintWriter printWriter) {
printWriter.println(new VersionInfo().getSystemName());
printWriter.println("Date: " + Utilities.getL10nDateTime());
printWriter.println(new VersionInfo().getSystemVersionInfo());
printWriter.println();
printWriter.println(getReportTitle() + " Report");
-
+
writeContestTime(printWriter);
printWriter.println();
}
+ @Override
public void printFooter(PrintWriter printWriter) {
printWriter.println();
printWriter.println("end report");
}
+ @Override
public void createReportFile(String filename, Filter inFilter) throws IOException {
PrintWriter printWriter = new PrintWriter(new FileOutputStream(filename, false), true);
@@ -79,11 +86,11 @@ public void createReportFile(String filename, Filter inFilter) throws IOExceptio
try {
printHeader(printWriter);
-
+
writeReport(printWriter);
-
+
printFooter(printWriter);
-
+
} catch (Exception e) {
printWriter.println("Exception in report: " + e.getMessage());
e.printStackTrace(printWriter);
@@ -99,32 +106,39 @@ public void createReportFile(String filename, Filter inFilter) throws IOExceptio
}
}
+ @Override
public String[] createReport(Filter inFilter) {
throw new SecurityException("Not implemented");
}
+ @Override
public String createReportXML(Filter inFilter) throws IOException {
return Reports.notImplementedXML(this);
}
+ @Override
public String getReportTitle() {
return "Event Feed JSON";
}
+ @Override
public void setContestAndController(IInternalContest inContest, IInternalController inController) {
this.contest = inContest;
this.controller = inController;
log = controller.getLog();
}
+ @Override
public String getPluginTitle() {
return getReportTitle() + " Report";
}
+ @Override
public Filter getFilter() {
return filter;
}
+ @Override
public void setFilter(Filter filter) {
this.filter = filter;
}
diff --git a/src/edu/csus/ecs/pc2/services/core/EventFeedJSON.java b/src/edu/csus/ecs/pc2/services/core/EventFeedJSON.java
index 871bade1a..897b9be60 100644
--- a/src/edu/csus/ecs/pc2/services/core/EventFeedJSON.java
+++ b/src/edu/csus/ecs/pc2/services/core/EventFeedJSON.java
@@ -22,6 +22,7 @@
import edu.csus.ecs.pc2.core.model.ClientId;
import edu.csus.ecs.pc2.core.model.ClientType;
import edu.csus.ecs.pc2.core.model.ElementId;
+import edu.csus.ecs.pc2.core.model.Filter;
import edu.csus.ecs.pc2.core.model.Group;
import edu.csus.ecs.pc2.core.model.IInternalContest;
import edu.csus.ecs.pc2.core.model.Judgement;
@@ -75,6 +76,8 @@ public EventFeedJSON(IInternalContest contest) {
private JSONTool jsonTool;
+ private Filter filter = null;
+
private HashSet ignoreGroup = new HashSet();
private HashSet ignoreTeam = new HashSet();
@@ -166,7 +169,7 @@ public String getProblemJSON(IInternalContest contest) {
Problem[] problems = contest.getProblems();
int id = 1;
for (Problem problem : problems) {
- if (problem.isActive()) {
+ if (problem.isActive() && (filter == null || filter.matches(problem))) {
appendJSONEvent(stringBuilder, PROBLEM_KEY, ++eventIdSequence, EventFeedOperation.CREATE, getProblemJSON(contest, problem, id));
stringBuilder.append(NL);
id++;
@@ -188,7 +191,7 @@ public String getGroupJSON(IInternalContest contest) {
Arrays.sort(groups, new GroupComparator());
for (Group group : groups) {
- if (group.isDisplayOnScoreboard()) {
+ if (group.isDisplayOnScoreboard() && (filter == null || filter.matches(group))) {
appendJSONEvent(stringBuilder, GROUPS_KEY, ++eventIdSequence, EventFeedOperation.CREATE, getGroupJSON(contest, group));
stringBuilder.append(NL);
} else {
@@ -213,7 +216,7 @@ public String getOrganizationJSON(IInternalContest contest) {
Hashtable organizations = new Hashtable();
for (Account account : accounts) {
- if (account.getClientId().getClientType().equals(ClientType.Type.TEAM) && !account.getInstitutionCode().equals("undefined")) {
+ if (account.getClientId().getClientType().equals(ClientType.Type.TEAM) && (filter == null || filter.matches(account)) && !account.getInstitutionCode().equals("undefined")) {
if (!organizations.containsKey(account.getInstitutionCode())) {
organizations.put(account.getInstitutionCode(), account);
appendJSONEvent(stringBuilder, ORGANIZATION_KEY, ++eventIdSequence, EventFeedOperation.CREATE, jsonTool.convertOrganizationsToJSON(account).toString());
@@ -248,7 +251,7 @@ public String getTeamJSON(IInternalContest contest) {
for (Account account : accounts) {
- if (account.isAllowed(Permission.Type.DISPLAY_ON_SCOREBOARD) && isDisplayAccountGroupOnScoreboard(account)) {
+ if (account.isAllowed(Permission.Type.DISPLAY_ON_SCOREBOARD) && isDisplayAccountGroupOnScoreboard(account) && (filter == null || filter.matches(account))) {
appendJSONEvent(stringBuilder, TEAM_KEY, ++eventIdSequence, EventFeedOperation.CREATE, getTeamJSON(contest, account));
stringBuilder.append(NL);
} else {
@@ -676,4 +679,12 @@ public long getEventIdSequence() {
public void setEventIdSequence(long eventIdSequence) {
this.eventIdSequence = eventIdSequence;
}
+
+ public Filter getFilter() {
+ return filter;
+ }
+
+ public void setFilter(Filter filter) {
+ this.filter = filter;
+ }
}
diff --git a/src/edu/csus/ecs/pc2/ui/EditFilterPane.java b/src/edu/csus/ecs/pc2/ui/EditFilterPane.java
index 9dece06ec..bfa7c87a5 100644
--- a/src/edu/csus/ecs/pc2/ui/EditFilterPane.java
+++ b/src/edu/csus/ecs/pc2/ui/EditFilterPane.java
@@ -19,6 +19,7 @@
import edu.csus.ecs.pc2.core.IInternalController;
import edu.csus.ecs.pc2.core.list.AccountComparator;
+import edu.csus.ecs.pc2.core.list.GroupComparator;
import edu.csus.ecs.pc2.core.list.PermissionByDescriptionComparator;
import edu.csus.ecs.pc2.core.list.SiteComparatorBySiteNumber;
import edu.csus.ecs.pc2.core.model.Account;
@@ -30,8 +31,10 @@
import edu.csus.ecs.pc2.core.model.ContestInformation;
import edu.csus.ecs.pc2.core.model.ContestInformationEvent;
import edu.csus.ecs.pc2.core.model.DisplayTeamName;
+import edu.csus.ecs.pc2.core.model.ElementId;
import edu.csus.ecs.pc2.core.model.Filter;
import edu.csus.ecs.pc2.core.model.FilterFormatter;
+import edu.csus.ecs.pc2.core.model.Group;
import edu.csus.ecs.pc2.core.model.IContestInformationListener;
import edu.csus.ecs.pc2.core.model.IInternalContest;
import edu.csus.ecs.pc2.core.model.Judgement;
@@ -43,7 +46,7 @@
/**
* Edit Filter GUI.
- *
+ *
* @author pc2@ecs.csus.edu
* @version $Id$
*/
@@ -52,7 +55,7 @@
public class EditFilterPane extends JPanePlugin {
/**
- *
+ *
*/
private static final long serialVersionUID = 1866852944568248601L;
@@ -66,6 +69,8 @@ public class EditFilterPane extends JPanePlugin {
private JPanel teamsPane = null; // @jve:decl-index=0:visual-constraint="589,115"
+ private JPanel groupsPane = null; // @jve:decl-index=0:visual-constraint="589,115"
+
private JPanel judgementsPane = null; // @jve:decl-index=0:visual-constraint="349,385"
private JPanel listsPanel = null;
@@ -76,6 +81,8 @@ public class EditFilterPane extends JPanePlugin {
private JScrollPane teamsScroll = null;
+ private JScrollPane groupsScroll = null;
+
private JScrollPane problemsScroll = null;
private JScrollPane languagesScroll = null;
@@ -88,6 +95,10 @@ public class EditFilterPane extends JPanePlugin {
private DefaultListModel teamListModel = new DefaultListModel();
+ private JCheckBoxJList groupListBox = null;
+
+ private DefaultListModel groupListModel = new DefaultListModel();
+
private JCheckBoxJList problemsListBox = null;
private DefaultListModel problemListModel = new DefaultListModel();
@@ -105,13 +116,13 @@ public class EditFilterPane extends JPanePlugin {
private JCheckBoxJList runStatesListBox = null;
private DefaultListModel runStatesListModel = new DefaultListModel();
-
+
private DefaultListModel clarificationStatesListModel = new DefaultListModel();
private DefaultListModel sitesListModel = new DefaultListModel();
private DefaultListModel permissionsListModel = new DefaultListModel();
-
+
private JPanel timeRangePane = null;
private JLabel fromTimeLabel = null;
@@ -121,11 +132,11 @@ public class EditFilterPane extends JPanePlugin {
private JLabel toTimeLabel = null;
private JTextField toTimeTextField = null;
-
+
private DisplayTeamName displayTeamName = null; // @jve:decl-index=0:
private boolean isJudgeModule = false;
-
+
private boolean filteringClarifications = false;
private JPanel clarificationStatesPane = null; // @jve:decl-index=0:visual-constraint="642,361"
@@ -136,37 +147,37 @@ public class EditFilterPane extends JPanePlugin {
private JPanel sitesPane = null; // @jve:decl-index=0:visual-constraint="649,76"
- private JPanel permissionsPane = null;
+ private JPanel permissionsPane = null;
private JScrollPane sitesScroll = null;
-
+
private JScrollPane permissionScroll = null;
private JCheckBoxJList siteListBox = null;
-
+
private JCheckBoxJList permissionListBox = null;
-
+
private JPanel accountsPane = null;
private DefaultListModel accountListModel = new DefaultListModel();
private JCheckBoxJList accountListBox = null;
-
+
private JScrollPane accountScroll = null;
private JPanel clientTypePane = null;
private JScrollPane clientTypeScroll = null;
-
+
private DefaultListModel clientTypeListModel = new DefaultListModel();
private JCheckBoxJList clientTypesListBox; // @jve:decl-index=0:
private Permission permission = new Permission();
-
+
/**
* JList names in EditFilterPane.
- *
+ *
* @author pc2@ecs.csus.edu
* @version $Id$
*/
@@ -191,17 +202,23 @@ public enum ListNames {
/**
* Clarification States JList.
*/
- CLARIFICATION_STATES,
+ CLARIFICATION_STATES,
/**
* Accounts JList.
*/
ALL_ACCOUNTS,
/**
- *
+ *
*/
TEAM_ACCOUNTS,
+
+ /**
+ *
+ */
+ GROUPS,
+
/**
- * Elapsed Time (both From and To)
+ * Elapsed Time (both From and To)
*/
TIME_RANGE,
/**
@@ -209,11 +226,11 @@ public enum ListNames {
*/
SITES,
/**
- *
+ *
*/
PERMISSIONS,
/**
- *
+ *
*/
CLIENT_TYPES,
}
@@ -236,7 +253,7 @@ private void initialize() {
this.setSize(new java.awt.Dimension(493, 337));
this.add(getMainPane(), java.awt.BorderLayout.CENTER);
}
-
+
@Override
public String getPluginTitle() {
return "Edit Filter";
@@ -244,7 +261,7 @@ public String getPluginTitle() {
/**
* This method initializes filterOnCheckBox
- *
+ *
* @return javax.swing.JCheckBox
*/
private JCheckBox getFilterOnCheckBox() {
@@ -258,7 +275,7 @@ private JCheckBox getFilterOnCheckBox() {
/**
* This method initializes problemFrame
- *
+ *
* @return javax.swing.JPanel
*/
private JPanel getProblemsPane() {
@@ -275,7 +292,7 @@ private JPanel getProblemsPane() {
/**
* This method initializes bottomPanel
- *
+ *
* @return javax.swing.JPanel
*/
private JPanel getBottomPanel() {
@@ -288,7 +305,7 @@ private JPanel getBottomPanel() {
/**
* This method initializes languagePane
- *
+ *
* @return javax.swing.JPanel
*/
private JPanel getLanguagesPane() {
@@ -305,7 +322,7 @@ private JPanel getLanguagesPane() {
/**
* This method initializes teamFrame
- *
+ *
* @return javax.swing.JPanel
*/
private JPanel getTeamsPane() {
@@ -319,10 +336,27 @@ private JPanel getTeamsPane() {
}
return teamsPane;
}
-
+
+ /**
+ * This method initializes teamFrame
+ *
+ * @return javax.swing.JPanel
+ */
+ private JPanel getGroupsPane() {
+ if (groupsPane == null) {
+ groupsPane = new JPanel();
+ groupsPane.setLayout(new BorderLayout());
+ groupsPane.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Groups", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION,
+ null, null));
+ groupsPane.setName("groupFrame");
+ groupsPane.add(getGroupsScroll(), java.awt.BorderLayout.CENTER);
+ }
+ return groupsPane;
+ }
+
/**
* This method initializes teamFrame
- *
+ *
* @return javax.swing.JPanel
*/
private JPanel getAccountsPane() {
@@ -339,7 +373,7 @@ private JPanel getAccountsPane() {
/**
* This method initializes judgementFrame
- *
+ *
* @return javax.swing.JPanel
*/
private JPanel getJudgementsPane() {
@@ -356,7 +390,7 @@ private JPanel getJudgementsPane() {
/**
* This method initializes otherPanel
- *
+ *
* @return javax.swing.JPanel
*/
private JPanel getListsPanel() {
@@ -365,7 +399,7 @@ private JPanel getListsPanel() {
gridLayout.setRows(1);
listsPanel = new JPanel();
listsPanel.setLayout(gridLayout);
-
+
// TODO remove this
// listsPanel.add(getTimeRangePane(), null);
}
@@ -374,7 +408,7 @@ private JPanel getListsPanel() {
/**
* This method initializes mainPane
- *
+ *
* @return javax.swing.JPanel
*/
private JPanel getMainPane() {
@@ -389,7 +423,7 @@ private JPanel getMainPane() {
/**
* This method initializes judgementsScroll
- *
+ *
* @return javax.swing.JScrollPane
*/
private JScrollPane getJudgementsScroll() {
@@ -402,7 +436,7 @@ private JScrollPane getJudgementsScroll() {
/**
* This method initializes teamsScroll
- *
+ *
* @return javax.swing.JScrollPane
*/
private JScrollPane getTeamsScroll() {
@@ -414,8 +448,21 @@ private JScrollPane getTeamsScroll() {
}
/**
- * This method initializes teamsScroll
- *
+ * This method initializes groupsScroll
+ *
+ * @return javax.swing.JScrollPane
+ */
+ private JScrollPane getGroupsScroll() {
+ if (groupsScroll == null) {
+ groupsScroll = new JScrollPane();
+ groupsScroll.setViewportView(getGroupListBox());
+ }
+ return groupsScroll;
+ }
+
+ /**
+ * This method initializes accountsScroll
+ *
* @return javax.swing.JScrollPane
*/
private JScrollPane getAccountScroll() {
@@ -427,7 +474,7 @@ private JScrollPane getAccountScroll() {
}
/**
* This method initializes problemsScroll
- *
+ *
* @return javax.swing.JScrollPane
*/
private JScrollPane getProblemsScroll() {
@@ -440,7 +487,7 @@ private JScrollPane getProblemsScroll() {
/**
* This method initializes languagesScroll
- *
+ *
* @return javax.swing.JScrollPane
*/
private JScrollPane getLanguagesScroll() {
@@ -453,7 +500,7 @@ private JScrollPane getLanguagesScroll() {
/**
* This method initializes judgementListBox
- *
+ *
* @return javax.swing.JList
*/
private JCheckBoxJList getJudgementListBox() {
@@ -465,7 +512,7 @@ private JCheckBoxJList getJudgementListBox() {
/**
* This method initializes teamListBox
- *
+ *
* @return javax.swing.JTextArea
*/
private JCheckBoxJList getTeamListBox() {
@@ -474,10 +521,22 @@ private JCheckBoxJList getTeamListBox() {
}
return teamListBox;
}
-
+
+ /**
+ * This method initializes groupListBox
+ *
+ * @return javax.swing.JTextArea
+ */
+ private JCheckBoxJList getGroupListBox() {
+ if (groupListBox == null) {
+ groupListBox = new JCheckBoxJList(groupListModel);
+ }
+ return groupListBox;
+ }
+
/**
* This method initializes teamListBox
- *
+ *
* @return javax.swing.JTextArea
*/
private JCheckBoxJList getAccountListBox() {
@@ -486,11 +545,11 @@ private JCheckBoxJList getAccountListBox() {
}
return accountListBox;
}
-
+
/**
* This method initializes problemsListBox
- *
+ *
* @return javax.swing.JList
*/
private JCheckBoxJList getProblemsListBox() {
@@ -502,7 +561,7 @@ private JCheckBoxJList getProblemsListBox() {
/**
* This method initializes languagesListBox
- *
+ *
* @return javax.swing.JList
*/
private JCheckBoxJList getLanguagesListBox() {
@@ -514,7 +573,7 @@ private JCheckBoxJList getLanguagesListBox() {
/**
* Populate the values for all JLists.
- *
+ *
*/
public void populateFields() {
@@ -530,10 +589,10 @@ public void populateFields() {
wrapperJCheckBox.setSelected(filter.matches(category));
}
problemListModel.addElement(wrapperJCheckBox);
-
+
}
}
-
+
for (Problem problem : getContest().getProblems()) {
WrapperJCheckBox wrapperJCheckBox = new WrapperJCheckBox(problem);
if (filter.isFilteringProblems()) {
@@ -550,7 +609,7 @@ public void populateFields() {
}
languageListModel.addElement(wrapperJCheckBox);
}
-
+
sitesListModel.removeAllElements();
Site [] sites = getContest().getSites();
Arrays.sort (sites, new SiteComparatorBySiteNumber());
@@ -561,8 +620,8 @@ public void populateFields() {
}
sitesListModel.addElement(wrapperJCheckBox);
}
-
-
+
+
permissionsListModel.removeAllElements();
Permission.Type[] types = Permission.Type.values();
Arrays.sort(types, new PermissionByDescriptionComparator());
@@ -573,7 +632,7 @@ public void populateFields() {
}
permissionsListModel.addElement(wrapperJCheckBox);
}
-
+
clientTypeListModel.removeAllElements();
for (Type type : Type.values()) {
WrapperJCheckBox wrapperJCheckBox = new WrapperJCheckBox(type);
@@ -591,11 +650,13 @@ public void populateFields() {
}
judgementListModel.addElement(wrapperJCheckBox);
}
-
+
loadTeamNames (filter);
-
+
+ loadGroupNames (filter);
+
loadAccountNames(filter);
-
+
runStatesListModel.removeAllElements();
RunStates[] runStates = RunStates.values();
for (RunStates runState : runStates) {
@@ -615,7 +676,7 @@ public void populateFields() {
}
clarificationStatesListModel.addElement(wrapperJCheckBox);
}
-
+
getFromTimeTextField().setText("");
getToTimeTextField().setText("");
if (filter.isFilteringElapsedTime()) {
@@ -627,16 +688,16 @@ public void populateFields() {
}
}
}
-
+
/**
* Populate the team names when with display mask.
- *
+ *
* This method also retains and re-populates the teams selected
* not based on the input filter, but based on what the user has
* selected.
*/
protected void populateTeamNamesWithDisplayMask(){
-
+
if (isJudgeModule) {
ContestInformation contestInformation = getContest().getContestInformation();
@@ -668,7 +729,7 @@ protected void populateTeamNamesWithDisplayMask(){
private void loadTeamNames(Filter inFilter) {
Vector vector = getContest().getAccounts(ClientType.Type.TEAM);
- Account[] accounts = (Account[]) vector.toArray(new Account[vector.size()]);
+ Account[] accounts = vector.toArray(new Account[vector.size()]);
Arrays.sort(accounts, new AccountComparator());
teamListModel.removeAllElements();
@@ -686,6 +747,22 @@ private void loadTeamNames(Filter inFilter) {
}
}
+ private void loadGroupNames(Filter inFilter) {
+ Group [] groups = getContest().getGroups();
+ Arrays.sort(groups, new GroupComparator());
+
+ groupListModel.removeAllElements();
+ WrapperJCheckBox wrapperJCheckBox = null;
+ for (Group group : groups) {
+ ElementId groupElementId = group.getElementId();
+ wrapperJCheckBox = new WrapperJCheckBox(groupElementId, group.getDisplayName());
+ if (inFilter.isFilteringGroups()) {
+ wrapperJCheckBox.setSelected(inFilter.matches(group));
+ }
+ groupListModel.addElement(wrapperJCheckBox);
+ }
+ }
+
private void loadAccountNames(Filter inFilter) {
Account[] accounts = getContest().getAccounts();
Arrays.sort(accounts, new AccountComparator());
@@ -707,17 +784,18 @@ private void loadAccountNames(Filter inFilter) {
}
-
+
@Override
public void setContestAndController(IInternalContest inContest, IInternalController inController) {
super.setContestAndController(inContest, inController);
-
+
getContest().addContestInformationListener(new ContestInformationListenerImplementation());
isJudgeModule = getContest().getClientId().getClientType().equals(Type.JUDGE);
SwingUtilities.invokeLater(new Runnable() {
+ @Override
public void run() {
populateFields();
}
@@ -759,7 +837,7 @@ public Filter getFilter() {
filter.addAccount((ClientId) object);
}
}
-
+
enumeration = accountListModel.elements();
while (enumeration.hasMoreElements()) {
WrapperJCheckBox element = (WrapperJCheckBox) enumeration.nextElement();
@@ -768,7 +846,7 @@ public Filter getFilter() {
filter.addAccount((ClientId) object);
}
}
-
+
filter.clearRunStatesList();
enumeration = runStatesListModel.elements();
@@ -789,7 +867,7 @@ public Filter getFilter() {
filter.addClarificationState((ClarificationStates) object);
}
}
-
+
filter.clearJudgementList();
enumeration = judgementListModel.elements();
while (enumeration.hasMoreElements()) {
@@ -799,7 +877,7 @@ public Filter getFilter() {
filter.addJudgement((Judgement) object);
}
}
-
+
filter.clearSiteList();
enumeration = sitesListModel.elements();
while (enumeration.hasMoreElements()) {
@@ -809,7 +887,7 @@ public Filter getFilter() {
filter.addSite((Site) object);
}
}
-
+
filter.clearPermissionsList();
enumeration = permissionsListModel.elements();
while (enumeration.hasMoreElements()) {
@@ -819,7 +897,18 @@ public Filter getFilter() {
filter.addPermission((Permission.Type) object);
}
}
-
+
+ filter.clearGroupsList();
+ enumeration = groupListModel.elements();
+ while (enumeration.hasMoreElements()) {
+ WrapperJCheckBox element = (WrapperJCheckBox) enumeration.nextElement();
+ if (element.isSelected()) {
+ Object object = element.getContents();
+ filter.addGroup((ElementId)object);
+ }
+ }
+
+
filter.clearClientTypesList();
enumeration = clientTypeListModel.elements();
while (enumeration.hasMoreElements()) {
@@ -834,22 +923,23 @@ public Filter getFilter() {
if (getFromTimeTextField().getText().length() > 0){
filter.setStartElapsedTime(Long.parseLong(getFromTimeTextField().getText()));
}
-
+
if (getToTimeTextField().getText().length() > 0){
filter.setEndElapsedTime(Long.parseLong(getToTimeTextField().getText()));
}
-
+
return filter;
}
/**
* Assigns filter and repopulates fields.
- *
+ *
* @param filter
*/
public void setFilter(Filter filter) {
this.filter = filter;
SwingUtilities.invokeLater(new Runnable() {
+ @Override
public void run() {
populateFields();
}
@@ -861,7 +951,7 @@ protected void printAllSpecifiers(String prefix, IInternalContest contest, Filte
FilterFormatter.NUMBER_JUDGEMENTS_SPECIFIER, FilterFormatter.NUMBER_LANGUAGES_SPECIFIER, FilterFormatter.NUMBER_PROBLEMS_SPECIFIER, FilterFormatter.PROBLEMS_SPECIFIER,
FilterFormatter.SHORT_ACCOUNT_NAMES_SPECIFIER, FilterFormatter.TEAM_LIST_SPECIFIER, FilterFormatter.TEAM_LONG_LIST_SPECIFIER, FilterFormatter.START_TIME_RANGE_SPECIFIER,
FilterFormatter.END_TIME_RANGE_SPECIFIER };
-
+
Arrays.sort(names);
FilterFormatter filterFormatter = new FilterFormatter();
@@ -873,7 +963,7 @@ protected void printAllSpecifiers(String prefix, IInternalContest contest, Filte
/**
* This method initializes jScrollPane
- *
+ *
* @return javax.swing.JScrollPane
*/
private JScrollPane getJScrollPane() {
@@ -886,7 +976,7 @@ private JScrollPane getJScrollPane() {
/**
* This method initializes runStatesPane
- *
+ *
* @return javax.swing.JPanel
*/
private JPanel getRunStatesPane() {
@@ -902,7 +992,7 @@ private JPanel getRunStatesPane() {
/**
* This method initializes runStatesListBox
- *
+ *
* @return edu.csus.ecs.pc2.ui.JCheckBoxJList
*/
private JCheckBoxJList getRunStatesListBox() {
@@ -911,10 +1001,10 @@ private JCheckBoxJList getRunStatesListBox() {
}
return runStatesListBox;
}
-
+
/**
* Add a list to the criteria.
- *
+ *
* @param listName
*/
public void addList (ListNames listName){
@@ -925,6 +1015,9 @@ public void addList (ListNames listName){
case TEAM_ACCOUNTS:
listsPanel.add(getTeamsPane(), 0);
break;
+ case GROUPS:
+ listsPanel.add(getGroupsPane(), 0);
+ break;
case LANGUAGES:
listsPanel.add(getLanguagesPane(), 0);
break;
@@ -959,7 +1052,7 @@ public void addList (ListNames listName){
/**
* This method initializes timeRangePane
- *
+ *
* @return javax.swing.JPanel
*/
private JPanel getTimeRangePane() {
@@ -981,7 +1074,7 @@ private JPanel getTimeRangePane() {
/**
* This method initializes fromTimeTextField
- *
+ *
* @return javax.swing.JTextField
*/
private JTextField getFromTimeTextField() {
@@ -995,7 +1088,7 @@ private JTextField getFromTimeTextField() {
/**
* This method initializes toTimeTextField
- *
+ *
* @return javax.swing.JTextField
*/
private JTextField getToTimeTextField() {
@@ -1014,35 +1107,40 @@ public DisplayTeamName getDisplayTeamName() {
public void setDisplayTeamName(DisplayTeamName displayTeamName) {
this.displayTeamName = displayTeamName;
}
-
+
/**
* Contest Listener for Edit Filter Pane.
- *
- * This listens for changes in the way the team display is to
+ *
+ * This listens for changes in the way the team display is to
* displayed aka the Team Information Displayed to Judges setting
- *
+ *
* @author pc2@ecs.csus.edu
* @version $Id$
*/
public class ContestInformationListenerImplementation implements IContestInformationListener {
+ @Override
public void contestInformationAdded(ContestInformationEvent event) {
populateTeamNamesWithDisplayMask();
}
+ @Override
public void contestInformationChanged(ContestInformationEvent event) {
populateTeamNamesWithDisplayMask();
}
+ @Override
public void contestInformationRemoved(ContestInformationEvent event) {
populateTeamNamesWithDisplayMask();
}
+ @Override
public void contestInformationRefreshAll(ContestInformationEvent contestInformationEvent) {
populateTeamNamesWithDisplayMask();
}
+ @Override
public void finalizeDataChanged(ContestInformationEvent contestInformationEvent) {
// Not used
}
@@ -1050,7 +1148,7 @@ public void finalizeDataChanged(ContestInformationEvent contestInformationEvent)
/**
* This method initializes clarificationsPane
- *
+ *
* @return javax.swing.JPanel
*/
private JPanel getClarificationStatesPane() {
@@ -1067,7 +1165,7 @@ private JPanel getClarificationStatesPane() {
/**
* This method initializes clarificationStateScrollPane
- *
+ *
* @return javax.swing.JScrollPane
*/
private JScrollPane getClarificationStateScrollPane() {
@@ -1080,7 +1178,7 @@ private JScrollPane getClarificationStateScrollPane() {
/**
* This method initializes clarificationStatesListBox
- *
+ *
* @return javax.swing.JList
*/
private JList> getClarificationStatesListBox() {
@@ -1100,7 +1198,7 @@ public void setFilteringClarifications(boolean filteringClarifications) {
/**
* This method initializes jPanel
- *
+ *
* @return javax.swing.JPanel
*/
private JPanel getSitesPane() {
@@ -1115,8 +1213,8 @@ private JPanel getSitesPane() {
}
return sitesPane;
}
-
-
+
+
public JPanel getClientTypePane() {
if (clientTypePane == null) {
clientTypePane = new JPanel();
@@ -1146,8 +1244,8 @@ private JCheckBoxJList getClientTypesListBox () {
return clientTypesListBox;
}
-
-
+
+
public JPanel getPermissionsPane() {
if (permissionsPane == null) {
permissionsPane = new JPanel();
@@ -1161,7 +1259,7 @@ public JPanel getPermissionsPane() {
return permissionsPane;
}
-
+
/**
* @return javax.swing.JScrollPane
*/
@@ -1172,10 +1270,10 @@ private JScrollPane getPermissionsScroll() {
}
return permissionScroll;
}
-
+
/**
* This method initializes permissionListBox
- *
+ *
* @return edu.csus.ecs.pc2.ui.JCheckBoxJList
*/
private JCheckBoxJList getPermissionsListBox() {
@@ -1184,11 +1282,11 @@ private JCheckBoxJList getPermissionsListBox() {
}
return permissionListBox;
}
-
+
/**
* This method initializes siteSCroll
- *
+ *
* @return javax.swing.JScrollPane
*/
private JScrollPane getSitesScroll() {
@@ -1201,7 +1299,7 @@ private JScrollPane getSitesScroll() {
/**
* This method initializes siteListBox
- *
+ *
* @return edu.csus.ecs.pc2.ui.JCheckBoxJList
*/
private JCheckBoxJList getSiteListBox() {
diff --git a/src/edu/csus/ecs/pc2/ui/ReportPane.java b/src/edu/csus/ecs/pc2/ui/ReportPane.java
index e6e6e6b02..ad0958b15 100644
--- a/src/edu/csus/ecs/pc2/ui/ReportPane.java
+++ b/src/edu/csus/ecs/pc2/ui/ReportPane.java
@@ -1,4 +1,3 @@
-// Copyright (C) 1989-2023 PC2 Development Team: John Clevenger, Douglas Lane, Samir Ashoo, and Troy Boudreau.
package edu.csus.ecs.pc2.ui;
import java.awt.BorderLayout;
@@ -119,14 +118,14 @@
/**
* Report Pane, allows picking and viewing reports.
- *
+ *
* @author pc2@ecs.csus.edu
*/
public class ReportPane extends JPanePlugin {
/**
- *
+ *
*/
private static final long serialVersionUID = -5165297328068331675L;
@@ -180,7 +179,7 @@ public String getReportDirectory() {
/**
* This method can change the directory that the reports will be written to. The default is "reports".
- *
+ *
* @param reportDirectory
* what directory to write the reports to
*/
@@ -190,7 +189,7 @@ public void setReportDirectory(String reportDirectory) {
/**
* This method initializes
- *
+ *
*/
public ReportPane() {
super();
@@ -199,7 +198,7 @@ public ReportPane() {
/**
* This method initializes this
- *
+ *
*/
private void initialize() {
this.setLayout(new BorderLayout());
@@ -303,38 +302,41 @@ private void populateReports() {
reports.add(new JudgingAnalysisReport());
reports.add(new JSON2016Report());
-
+
reports.add(new ProblemsGroupReport());
-
+
reports.add(new ProblemGroupAssignmentReport());
-
+
reports.add(new ContestCompareReport());
-
+
reports.add(new CLICSAwardsReport());
-
+
if (isServer()){
- // SOMEDAY Bug 1166 remove this isServer when added to Admin.
+ // SOMEDAY Bug 1166 remove this isServer when added to Admin.
reports.add(new CDPReport());
}
-
+
reports.add(new EventFeedJSONReport());
-
+
reports.add(new StandingsNSAReport());
-
+
reports.add(new ResultsCompareReport());
-
+
reports.add(new ResultsExportReport());
-
+
reports.add(new ResultsTSVReport());
- listOfReports = (IReport[]) reports.toArray(new IReport[reports.size()]);
-
+ listOfReports = reports.toArray(new IReport[reports.size()]);
+
Arrays.sort(listOfReports,new ReportComparator());
}
+ @Override
public void setContestAndController(IInternalContest inContest, IInternalController inController) {
super.setContestAndController(inContest, inController);
+ filter.setContestAndController(inContest, inController);
+
this.log = getController().getLog();
if (isServer()) {
@@ -347,6 +349,7 @@ public void setContestAndController(IInternalContest inContest, IInternalControl
initializePermissions();
SwingUtilities.invokeLater(new Runnable() {
+ @Override
public void run() {
getEditFilterFrame().setContestAndController(getContest(), getController());
populateReports();
@@ -365,6 +368,7 @@ private void updateGUIperPermissions() {
protected void refreshGUI() {
SwingUtilities.invokeLater(new Runnable() {
+ @Override
public void run() {
refreshReportComboBox();
showXMLCheckbox();
@@ -375,7 +379,7 @@ public void run() {
private void refreshReportComboBox() {
getReportsComboBox().removeAllItems();
-
+
Arrays.sort(listOfReports,new ReportComparator());
for (IReport report : listOfReports) {
@@ -393,7 +397,7 @@ public String getPluginTitle() {
/**
* This method initializes topPane
- *
+ *
* @return javax.swing.JPanel
*/
private JPanel getTopPane() {
@@ -411,7 +415,7 @@ private JPanel getTopPane() {
/**
* This method initializes buttonPane
- *
+ *
* @return javax.swing.JPanel
*/
private JPanel getButtonPane() {
@@ -430,7 +434,7 @@ private JPanel getButtonPane() {
/**
* This method initializes mainPane
- *
+ *
* @return javax.swing.JPanel
*/
private JPanel getMainPane() {
@@ -448,7 +452,7 @@ private JPanel getMainPane() {
/**
* This method initializes viewReportButton
- *
+ *
* @return javax.swing.JButton
*/
private JButton getViewReportButton() {
@@ -458,6 +462,7 @@ private JButton getViewReportButton() {
viewReportButton.setToolTipText("View the selected Report");
viewReportButton.setMnemonic(java.awt.event.KeyEvent.VK_V);
viewReportButton.addActionListener(new java.awt.event.ActionListener() {
+ @Override
public void actionPerformed(java.awt.event.ActionEvent e) {
if (getBreakdownBySiteCheckbox().isSelected()) {
generateSelectedReportBySite();
@@ -547,6 +552,8 @@ public void createReportFile(IReport report, boolean suppressHeaderFooter, Strin
PrintWriter printWriter = new PrintWriter(new FileOutputStream(filename, false), true);
filter = inFilter;
+ filter.setContestAndController(getContest(), getController());
+
try {
if (!suppressHeaderFooter) {
@@ -600,11 +607,11 @@ protected void generateSelectedReport(boolean includeHeaderFooter) {
if (writeXML) {
extension = "xml";
}
-
+
if (selectedReport.getReportTitle().toLowerCase().indexOf("json") != -1) {
extension = "json";
}
-
+
String filename = getFileName(selectedReport, extension);
File reportDirectoryFile = new File(getReportDirectory());
@@ -633,7 +640,7 @@ protected void generateSelectedReport(boolean includeHeaderFooter) {
IReportFile reportFile = (IReportFile) selectedReport;
suppressHeaderFooter = reportFile.suppressHeaderFooter();
}
-
+
if (! includeHeaderFooter) {
suppressHeaderFooter = true;
}
@@ -798,12 +805,13 @@ protected void generateSelectedReportBySite() {
/**
* show message to user
- *
+ *
* @param string
*/
private void showMessage(final String string) {
SwingUtilities.invokeLater(new Runnable() {
+ @Override
public void run() {
messageLabel.setText(string);
}
@@ -813,7 +821,7 @@ public void run() {
/**
* This method initializes thisSiteCheckBox
- *
+ *
* @return javax.swing.JCheckBox
*/
private JCheckBox getBreakdownBySiteCheckbox() {
@@ -824,6 +832,7 @@ private JCheckBox getBreakdownBySiteCheckbox() {
breakdownBySiteCheckbox.setToolTipText("Break down by site");
breakdownBySiteCheckbox.setText("Breakdown by site");
breakdownBySiteCheckbox.addActionListener(new java.awt.event.ActionListener() {
+ @Override
public void actionPerformed(java.awt.event.ActionEvent e) {
changeSiteFiltering();
}
@@ -846,7 +855,7 @@ protected void changeSiteFiltering() {
/**
* This method initializes reportChoicePane
- *
+ *
* @return javax.swing.JPanel
*/
private JPanel getReportChoicePane() {
@@ -863,13 +872,14 @@ private JPanel getReportChoicePane() {
/**
* This method initializes reportsComboBox
- *
+ *
* @return javax.swing.JComboBox
*/
private JComboBox getReportsComboBox() {
if (reportsComboBox == null) {
reportsComboBox = new JComboBox();
reportsComboBox.addKeyListener(new java.awt.event.KeyAdapter() {
+ @Override
public void keyPressed(java.awt.event.KeyEvent e) {
if (e.getKeyCode() == java.awt.event.KeyEvent.VK_ENTER) {
if (getBreakdownBySiteCheckbox().isSelected()) {
@@ -886,7 +896,7 @@ public void keyPressed(java.awt.event.KeyEvent e) {
/**
* This method initializes thisClientFilterButton
- *
+ *
* @return javax.swing.JCheckBox
*/
private JCheckBox getThisClientFilterButton() {
@@ -897,6 +907,7 @@ private JCheckBox getThisClientFilterButton() {
thisClientFilterButton.setText("Filter for this client only");
thisClientFilterButton.setVisible(false);
thisClientFilterButton.addActionListener(new java.awt.event.ActionListener() {
+ @Override
public void actionPerformed(java.awt.event.ActionEvent e) {
changeThisClientFiltering();
}
@@ -920,7 +931,7 @@ protected void changeThisClientFiltering() {
/**
* This method initializes filterPane
- *
+ *
* @return javax.swing.JPanel
*/
private JPanel getFilterPane() {
@@ -941,7 +952,7 @@ private JPanel getFilterPane() {
/**
* This method initializes filterButtonPane
- *
+ *
* @return javax.swing.JPanel
*/
private JPanel getFilterButtonPane() {
@@ -954,7 +965,7 @@ private JPanel getFilterButtonPane() {
/**
* This method initializes editReportFilter
- *
+ *
* @return javax.swing.JButton
*/
private JButton getEditReportFilter() {
@@ -964,6 +975,7 @@ private JButton getEditReportFilter() {
editReportFilter.setMnemonic(KeyEvent.VK_F);
editReportFilter.setToolTipText("Edit Filter");
editReportFilter.addActionListener(new java.awt.event.ActionListener() {
+ @Override
public void actionPerformed(java.awt.event.ActionEvent e) {
showReportFilter();
}
@@ -980,6 +992,7 @@ protected void showReportFilter() {
getEditFilterFrame().addList(ListNames.TEAM_ACCOUNTS);
getEditFilterFrame().addList(ListNames.RUN_STATES);
getEditFilterFrame().addList(ListNames.JUDGEMENTS);
+ getEditFilterFrame().addList(ListNames.GROUPS);
getEditFilterFrame().addList(ListNames.SITES);
getEditFilterFrame().setFilter(filter);
@@ -991,6 +1004,7 @@ protected void showReportFilter() {
public EditFilterFrame getEditFilterFrame() {
if (editFilterFrame == null) {
Runnable callback = new Runnable() {
+ @Override
public void run() {
refreshFilterLabel();
};
@@ -1006,7 +1020,7 @@ private void refreshFilterLabel() {
/**
* This method initializes xmlOutputCheckbox
- *
+ *
* @return javax.swing.JCheckBox
*/
private JCheckBox getXmlOutputCheckbox() {
@@ -1021,7 +1035,7 @@ private JCheckBox getXmlOutputCheckbox() {
/**
* This method initializes generateSummaryButton
- *
+ *
* @return javax.swing.JButton
*/
private JButton getGenerateSummaryButton() {
@@ -1031,6 +1045,7 @@ private JButton getGenerateSummaryButton() {
generateSummaryButton.setMnemonic(KeyEvent.VK_G);
generateSummaryButton.setToolTipText("Generate Summary Reports");
generateSummaryButton.addActionListener(new java.awt.event.ActionListener() {
+ @Override
public void actionPerformed(java.awt.event.ActionEvent e) {
generateSummaryReport();
}
@@ -1054,16 +1069,18 @@ protected void generateSummaryReport() {
/**
* Account Listener Implementation.
- *
+ *
* @author pc2@ecs.csus.edu
* @version $Id$
*/
public class AccountListenerImplementation implements IAccountListener {
+ @Override
public void accountAdded(AccountEvent accountEvent) {
// ignored
}
+ @Override
public void accountModified(AccountEvent accountEvent) {
// check if is this account
Account account = accountEvent.getAccount();
@@ -1074,6 +1091,7 @@ public void accountModified(AccountEvent accountEvent) {
// They modified us!!
initializePermissions();
SwingUtilities.invokeLater(new Runnable() {
+ @Override
public void run() {
updateGUIperPermissions();
}
@@ -1082,10 +1100,12 @@ public void run() {
}
}
+ @Override
public void accountsAdded(AccountEvent accountEvent) {
// ignore
}
+ @Override
public void accountsModified(AccountEvent accountEvent) {
Account[] accounts = accountEvent.getAccounts();
for (Account account : accounts) {
@@ -1097,6 +1117,7 @@ public void accountsModified(AccountEvent accountEvent) {
// They modified us!!
initializePermissions();
SwingUtilities.invokeLater(new Runnable() {
+ @Override
public void run() {
updateGUIperPermissions();
}
@@ -1105,11 +1126,13 @@ public void run() {
}
}
+ @Override
public void accountsRefreshAll(AccountEvent accountEvent) {
initializePermissions();
SwingUtilities.invokeLater(new Runnable() {
+ @Override
public void run() {
updateGUIperPermissions();
}
@@ -1121,7 +1144,8 @@ private JButton getExportDataButton() {
if (exportDataButton == null) {
exportDataButton = new JButton("Export Report Contents");
exportDataButton.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
+ @Override
+ public void actionPerformed(ActionEvent e) {
generateSelectedReport(false);
}
});