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
44 changes: 1 addition & 43 deletions src/edu/csus/ecs/pc2/clics/API202306/CLICSJudgement.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,11 @@

import java.util.Calendar;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import java.util.logging.Level;

import com.fasterxml.jackson.annotation.JsonFilter;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ser.FilterProvider;
import com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter;
import com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider;

import edu.csus.ecs.pc2.core.IInternalController;
import edu.csus.ecs.pc2.core.Utilities;
Expand All @@ -22,7 +16,6 @@
import edu.csus.ecs.pc2.core.model.JudgementRecord;
import edu.csus.ecs.pc2.core.model.Run;
import edu.csus.ecs.pc2.core.util.IJSONTool;
import edu.csus.ecs.pc2.services.core.JSONUtilities;

/**
* Contains the judgment for a submission (Accepted, Wrong Answer, etc).
Expand All @@ -32,7 +25,6 @@
*
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonFilter("rtFilter")
public class CLICSJudgement {

@JsonProperty
Expand All @@ -45,7 +37,7 @@ public class CLICSJudgement {
private String judgement_type_id;

@JsonProperty
private double score;
private Double score;

@JsonProperty
private String start_time;
Expand All @@ -62,8 +54,6 @@ public class CLICSJudgement {
@JsonProperty
private double max_run_time;

private boolean isPointScoring = false;

/**
* Fill in properties for a judgment description.
*
Expand All @@ -78,9 +68,6 @@ public CLICSJudgement(IInternalContest model, IInternalController controller, Ru
id = submission.getElementId().toString();
submission_id = IJSONTool.getSubmissionId(submission);

// Remember this for serialization
isPointScoring = model.getContestInformation().isScoreboardTypeScore();

Date startJudgeDate = submission.getJudgeStartDate();
if(startJudgeDate == null) {
// Yikes! Using submission time since there is no judge start date... Something is amiss, but this is a last ditch guess
Expand Down Expand Up @@ -143,33 +130,4 @@ public CLICSJudgement(IInternalContest model, IInternalController controller, Ru
}
// else not much to do here if no start date.
}

public String toJSON() {
Set<String> exceptProps = new HashSet<String>();

getExceptProps(exceptProps);
try {
ObjectMapper mapper = JSONUtilities.getObjectMapper();
// for this judgment, create filter to omit inappropriate properties,
// 'score' in this case if not Point Scoring contest
SimpleBeanPropertyFilter filter = SimpleBeanPropertyFilter.serializeAllExcept(exceptProps);
FilterProvider fp = new SimpleFilterProvider().addFilter("rtFilter", filter).setFailOnUnknownId(false);
mapper.setFilters(fp);
return mapper.writeValueAsString(this);
} catch (Exception e) {
return "Error creating JSON for judgment " + e.getMessage();
}
}

/**
* Get set of properties for which we do not want to serialize into JSON.
* This is so we don't serialize score for pass-fail contests
*
* @param exceptProps Set to fill in with property names to omit
*/
public void getExceptProps(Set<String> exceptProps) {
if(!isPointScoring){
exceptProps.add("score");
}
}
}
48 changes: 17 additions & 31 deletions src/edu/csus/ecs/pc2/clics/API202306/CLICSProblem.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
// Copyright (C) 1989-2025 PC2 Development Team: John Clevenger, Douglas Lane, Samir Ashoo, and Troy Boudreau.
package edu.csus.ecs.pc2.clics.API202306;

import java.util.HashSet;
import java.util.Set;

import com.fasterxml.jackson.annotation.JsonFilter;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ser.FilterProvider;
import com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter;
import com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider;

import edu.csus.ecs.pc2.core.StringUtilities;
import edu.csus.ecs.pc2.core.model.IInternalContest;
Expand All @@ -28,7 +21,6 @@
*
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonFilter("rtFilter")
public class CLICSProblem {

@JsonProperty
Expand Down Expand Up @@ -59,7 +51,7 @@ public class CLICSProblem {
private int test_data_count;

@JsonProperty
private double max_score;
private Double max_score;

// The next two will be 'null' for now until we implement the new json CPF
@JsonProperty("package")
Expand Down Expand Up @@ -98,40 +90,34 @@ public CLICSProblem(IInternalContest model, Problem problem, int ordinal) {
ProblemDataFiles problemDataFiles = model.getProblemDataFile(problem);
if(problemDataFiles != null) {
TestDataGroup [] testDataGroups = problemDataFiles.getJudgesDataGroups();
// Really, there's only 1 top level TestDataGruop
// Really, there's only 1 top (root) level TestDataGroup which we have to find. Start at the
// first group and walk up the tree to the root (parent being null)
if(testDataGroups != null && testDataGroups.length > 0) {
max_score = testDataGroups[0].getRangeMax();
TestDataGroup tdg = testDataGroups[0];
// Paranoia: this had better not be null.
if(tdg != null) {
TestDataGroup parentTdg = tdg.getParent();
while(parentTdg != null) {
tdg = parentTdg;
parentTdg = tdg.getParent();
}
// Departure from spec: if upper range is infinity, just leave it out (max_score will be null).
// Primarily for the Resolver as it doesn't want to see "infinity" as a value.
if(tdg.getRangeMax() != Double.POSITIVE_INFINITY) {
max_score = tdg.getRangeMax();
}
}
}
}
}
}

public String toJSON() {
Set<String> exceptProps = new HashSet<String>();

getExceptProps(exceptProps);
try {
ObjectMapper mapper = JSONUtilities.getObjectMapper();
// for this problem, create filter to omit inappropriate properties,
// 'max_score' in this case if not Point Scoring contest
SimpleBeanPropertyFilter filter = SimpleBeanPropertyFilter.serializeAllExcept(exceptProps);
FilterProvider fp = new SimpleFilterProvider().addFilter("rtFilter", filter).setFailOnUnknownId(false);
mapper.setFilters(fp);
return mapper.writeValueAsString(this);
} catch (Exception e) {
return "Error creating JSON for CLICSProblem " + e.getMessage();
}
}

/**
* Get set of properties for which we do not want to serialize into JSON.
* This is so we don't serialize max_score for pass-fail contests
*
* @param exceptProps Set to fill in with property names to omit
*/
public void getExceptProps(Set<String> exceptProps) {
if(!isPointScoring){
exceptProps.add("max_score");
}
}
}
47 changes: 2 additions & 45 deletions src/edu/csus/ecs/pc2/clics/API202306/CLICSProblemScore.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,14 @@
package edu.csus.ecs.pc2.clics.API202306;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Set;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ser.FilterProvider;
import com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter;
import com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider;

import edu.csus.ecs.pc2.core.StringUtilities;
import edu.csus.ecs.pc2.core.Utilities;
import edu.csus.ecs.pc2.core.model.IInternalContest;
import edu.csus.ecs.pc2.core.standings.ProblemSummaryInfo;
import edu.csus.ecs.pc2.services.core.JSONUtilities;

/**
* Contains information about the score a team received for a single problem.
Expand All @@ -29,7 +21,6 @@
*/

@JsonInclude(JsonInclude.Include.NON_NULL)

public class CLICSProblemScore {

@JsonProperty
Expand All @@ -45,13 +36,11 @@ public class CLICSProblemScore {
private boolean solved;

@JsonProperty
private double score;
private Double score;

@JsonProperty
private int time;

private boolean isPointScoring = false;

/**
* Provide empty constructor for Jackson deserialization
*/
Expand All @@ -66,7 +55,7 @@ public CLICSProblemScore() {
* @param probEleToShort hashmap for mapping problem elementid to shortname
* @param versionInfo
*/
public CLICSProblemScore(IInternalContest model, HashMap<String, String> probEleToShort, ProblemSummaryInfo psi) {
public CLICSProblemScore(HashMap<String, String> probEleToShort, ProblemSummaryInfo psi) {
num_judged = Utilities.nullSafeToInt(psi.getAttempts(), 0);
num_pending = Utilities.nullSafeToInt(psi.getIsPending(), 0);
problem_id = psi.getProblemId();
Expand All @@ -88,38 +77,6 @@ public CLICSProblemScore(IInternalContest model, HashMap<String, String> probEle
}
}
}
if(model != null) {
isPointScoring = model.getContestInformation().isScoreboardTypeScore();
}
}

public String toJSON() {
Set<String> exceptProps = new HashSet<String>();

getExceptProps(exceptProps);
try {
ObjectMapper mapper = JSONUtilities.getObjectMapper();
// for this problem's score, create filter to omit inappropriate properties,
// 'score' in this case if not Point Scoring contest
SimpleBeanPropertyFilter filter = SimpleBeanPropertyFilter.serializeAllExcept(exceptProps);
FilterProvider fp = new SimpleFilterProvider().addFilter("rtFilter", filter).setFailOnUnknownId(false);
mapper.setFilters(fp);
return mapper.writeValueAsString(this);
} catch (Exception e) {
return "Error creating JSON for CLICSProblemScore " + e.getMessage();
}
}

/**
* Get set of properties for which we do not want to serialize into JSON.
* This is so we don't serialize score for pass-fail contests
*
* @param exceptProps Set to fill in with property names to omit
*/
public void getExceptProps(Set<String> exceptProps) {
if(!isPointScoring){
exceptProps.add("score");
}
}

/**
Expand Down
49 changes: 2 additions & 47 deletions src/edu/csus/ecs/pc2/clics/API202306/CLICSScore.java
Original file line number Diff line number Diff line change
@@ -1,22 +1,12 @@
// Copyright (C) 1989-2025 PC2 Development Team: John Clevenger, Douglas Lane, Samir Ashoo, and Troy Boudreau.
package edu.csus.ecs.pc2.clics.API202306;

import java.util.HashSet;
import java.util.Set;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonFilter;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ser.FilterProvider;
import com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter;
import com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider;

import edu.csus.ecs.pc2.core.Utilities;
import edu.csus.ecs.pc2.core.model.IInternalContest;
import edu.csus.ecs.pc2.core.standings.TeamStanding;
import edu.csus.ecs.pc2.services.core.JSONUtilities;

/**
* Contains information about the score for a team on the scoreboard.
Expand All @@ -25,7 +15,6 @@
*
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonFilter("rtFilter")
public class CLICSScore {

@JsonProperty
Expand All @@ -35,13 +24,11 @@ public class CLICSScore {
private int total_time;

@JsonProperty
private double score;
private Double score;

@JsonProperty
private int time;

private boolean isPointScoring = false;

/**
* Provide empty constructor for Jackson deserialization
*/
Expand All @@ -56,47 +43,16 @@ public CLICSScore() {
* @param teamStanding The team's scoring information
* @throws NumberFormatException if bad scores are in the standings
*/
public CLICSScore(IInternalContest model, TeamStanding teamStanding) {
public CLICSScore(TeamStanding teamStanding) {
num_solved = Utilities.nullSafeToInt(teamStanding.getSolved(), 0);
total_time = Utilities.nullSafeToInt(teamStanding.getPoints(), 0);
if(num_solved > 0) {
// Problem solution time is in minutes.
time = Integer.parseInt(teamStanding.getLastSolved());
score = Double.parseDouble(teamStanding.getScore());
}
if(model != null) {
isPointScoring = model.getContestInformation().isScoreboardTypeScore();
}
}

public String toJSON() {
Set<String> exceptProps = new HashSet<String>();

getExceptProps(exceptProps);
try {
ObjectMapper mapper = JSONUtilities.getObjectMapper();
// for this team score, create filter to omit inappropriate properties,
// 'score' in this case if not Point Scoring contest
SimpleBeanPropertyFilter filter = SimpleBeanPropertyFilter.serializeAllExcept(exceptProps);
FilterProvider fp = new SimpleFilterProvider().addFilter("rtFilter", filter).setFailOnUnknownId(false);
mapper.setFilters(fp);
return mapper.writeValueAsString(this);
} catch (Exception e) {
return "Error creating JSON for CLICSScore " + e.getMessage();
}
}

/**
* Get set of properties for which we do not want to serialize into JSON.
* This is so we don't serialize score for pass-fail contests
*
* @param exceptProps Set to fill in with property names to omit
*/
public void getExceptProps(Set<String> exceptProps) {
if(!isPointScoring){
exceptProps.add("score");
}
}

public int getNum_solved() {
return num_solved;
Expand All @@ -113,7 +69,6 @@ public int getTime() {
/**
* @return the score
*/

public Double getScore() {
return score;
}
Expand Down
2 changes: 1 addition & 1 deletion src/edu/csus/ecs/pc2/clics/API202306/CLICSScoreboard.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public CLICSScoreboard(IInternalContest model, Group group, Integer division) t
List<TeamStanding> standings = contestStandings.getTeamStandings();
if(standings != null) {
for (TeamStanding teamStanding : standings) {
rowsArray.add(new CLICSScoreboardRow(model, probEleToShortName, teamStanding));
rowsArray.add(new CLICSScoreboardRow(probEleToShortName, teamStanding));
}
rows = rowsArray.toArray(new CLICSScoreboardRow[0]);
} else {
Expand Down
Loading
Loading