Skip to content

Commit

Permalink
i_843 Rebase changes
Browse files Browse the repository at this point in the history
  • Loading branch information
johnbrvc committed Dec 10, 2024
1 parent 57db0a6 commit e0b0bec
Show file tree
Hide file tree
Showing 25 changed files with 804 additions and 376 deletions.
6 changes: 3 additions & 3 deletions src/edu/csus/ecs/pc2/clics/API202306/AccessService.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

/**
* WebService to handle "state" REST endpoint as described by the CLICS wiki.
*
*
* @author John Buck
*
*/
Expand All @@ -41,7 +41,7 @@ public AccessService(IInternalContest inModel, IInternalController inController)

/**
* This method returns a representation of the access that the connected user has
*
*
* @return a {@link Response} object containing a JSON String giving the access information for the connected user
*/
@GET
Expand All @@ -52,7 +52,7 @@ public Response getAccess(@Context SecurityContext sc, @PathParam("contestId") S
if(contestId.equals(model.getContestIdentifier()) == true) {
return Response.ok(new CLICSContestAccess(sc, model, controller, contestId).toJSON(), MediaType.APPLICATION_JSON).build();
}
return Response.status(Response.Status.NOT_FOUND).build();
return Response.status(Response.Status.NOT_FOUND).build();
}

@Override
Expand Down
7 changes: 3 additions & 4 deletions src/edu/csus/ecs/pc2/clics/API202306/CLICSContestInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.ObjectMapper;

import edu.csus.ecs.pc2.core.Utilities;
import edu.csus.ecs.pc2.core.model.ContestInformation;
import edu.csus.ecs.pc2.core.model.ContestTime;
Expand All @@ -16,7 +15,7 @@

/**
* CLICS Contest Info.
*
*
* @author John Buck
*
*/
Expand Down Expand Up @@ -54,12 +53,12 @@ public class CLICSContestInfo {

/**
* Fill in properties for a contest.
*
*
* @param model The contest to use
*/
public CLICSContestInfo(IInternalContest model) {
ContestInformation ci = model.getContestInformation();

id = model.getContestIdentifier();
name = ci.getContestShortName();
formal_name = ci.getContestTitle();
Expand Down
4 changes: 2 additions & 2 deletions src/edu/csus/ecs/pc2/clics/API202306/CLICSEndpoint.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
/**
* CLICS Endpoint
* Contains information about an API endpoint that is supported
*
*
* @author John Buck
*
*/
Expand All @@ -24,7 +24,7 @@ public class CLICSEndpoint {

/**
* For use with the access endpoint. This describes the properties of a single endpoint.
*
*
* @param type String representing the name of the endpoint, eg. "teams", "groups", etc.
* @param properties List of supported properties
*/
Expand Down
6 changes: 3 additions & 3 deletions src/edu/csus/ecs/pc2/clics/API202306/CLICSProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
/**
* CLICS Provider
* Contains information about the system providing the API feed (PC2, in this case)
*
*
* @author John Buck
*
*/
Expand All @@ -28,12 +28,12 @@ public class CLICSProvider {

/**
* Fill in API Provider information properties (for the version endpoint)
*
*
* @param versionInfo
*/
public CLICSProvider(VersionInfo versionInfo) {
name = "pc2";
version = versionInfo.getPC2Version() + " build " + versionInfo.getBuildNumber();
version = versionInfo.getPC2Version() + " build " + versionInfo.getBuildNumber();
}

public String toJSON() {
Expand Down
26 changes: 16 additions & 10 deletions src/edu/csus/ecs/pc2/clics/API202306/CLICSScoreboard.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
/**
* CLICS Scoreboard
* Contains information about the scoreboard
*
*
* @author John Buck
*
*/
Expand All @@ -49,22 +49,28 @@ public class CLICSScoreboard {

@JsonProperty
private CLICSScoreboardRow [] rows;

/**
* Fill in the scoreboard information
*
*
*/
public CLICSScoreboard(IInternalContest model, IInternalController controller, Group group, Integer division) throws IllegalContestState, JAXBException, IOException {

DefaultScoringAlgorithm scoringAlgorithm = new DefaultScoringAlgorithm();

Properties properties = ScoreboardUtilities.getScoringProperties(model);

// legacy - standings are created as XML, and we convert that to JSON.
String xml = scoringAlgorithm.getStandings(model, null, division, group, properties, StaticLog.getLog());

ArrayList<Group> groupList = null;

if(group != null) {
groupList = new ArrayList<Group>();
groupList.add(group);
}
// legacy - standings are created as XML, and we convert that to JSON.
String xml = scoringAlgorithm.getStandings(model, null, division, groupList, properties, StaticLog.getLog());

ContestStandings contestStandings = ScoreboardUtilities.createContestStandings(xml);

// This is what we want to return:
// {
// "time": "2014-06-25T14:13:07.832+01",
Expand All @@ -90,10 +96,10 @@ public CLICSScoreboard(IInternalContest model, IInternalController controller, G
time = ZonedDateTime.now( ZoneOffset.UTC ).format( DateTimeFormatter.ISO_INSTANT);
contest_time = model.getContestTime().getElapsedTimeStr();
state = new CLICSContestState(model);

ArrayList<CLICSScoreboardRow>rowsArray = new ArrayList<CLICSScoreboardRow>();
HashMap<String, String> probEleToShort = new HashMap<String, String>();

// create a mapping of each problem's element ID to its shortname.
// we will use shortname as the problem id in the problem list for each team's solutions
for(Problem problem: model.getProblems()) {
Expand Down
37 changes: 24 additions & 13 deletions src/edu/csus/ecs/pc2/clics/API202306/CLICSTeam.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
Expand All @@ -17,6 +18,7 @@
import edu.csus.ecs.pc2.core.model.ClientId;
import edu.csus.ecs.pc2.core.model.ClientType;
import edu.csus.ecs.pc2.core.model.ClientType.Type;
import edu.csus.ecs.pc2.core.model.ElementId;
import edu.csus.ecs.pc2.core.model.Group;
import edu.csus.ecs.pc2.core.model.IInternalContest;
import edu.csus.ecs.pc2.core.security.Permission;
Expand Down Expand Up @@ -85,10 +87,14 @@ public CLICSTeam(IInternalContest model, Account account) {
if (JSONTool.notEmpty(account.getInstitutionCode()) && !account.getInstitutionCode().equals("undefined")) {
organization_id = JSONTool.getOrganizationId(account);
}
if (account.getGroupId() != null) {
group_ids = new String[1];
// FIXME eventually accounts should have more then 1 groupId, make sure add them
group_ids[0] = JSONTool.getGroupId(model.getGroup(account.getGroupId()));
if (account.getGroupIds() != null) {
HashSet<ElementId> groups = account.getGroupIds();
ArrayList<String> groupList = new ArrayList<String>();

for(ElementId ele : groups) {
groupList.add(JSONTool.getGroupId(model.getGroup(ele)));
}
group_ids = (String [])groupList.toArray();
}
hidden = !account.isAllowed(Permission.Type.DISPLAY_ON_SCOREBOARD);
}
Expand Down Expand Up @@ -197,16 +203,21 @@ public String toJSON() {
}
// now fill in any other fields we can
if(team.group_ids != null && team.group_ids.length > 0) {
Group group = jsontool.getGroupFromNumber(team.group_ids[0]);
if(group == null) {
log.log(Log.SEVERE, "No group has been defined with GroupId=" + team.group_ids[0]);
error = true;
break;
Group group;
boolean bFirst = true;
// team has a list of group names
for(String groupName : team.group_ids) {
group = jsontool.getGroupFromNumber(groupName);
if(group == null) {
log.log(Log.SEVERE, "No group has been defined with GroupId=" + groupName);
error = true;
break;
}
account.addGroupId(group.getElementId(), bFirst);
bFirst = false;
}
account.setGroupId(group.getElementId());
//TODO fix this when PC2 supports multiple groups per account
if(team.group_ids.length > 1) {
log.log(Log.INFO, account.getDisplayName() + " has " + team.group_ids.length + " groups assigned - only using first one");
if(error) {
break;
}
}
if(team.hidden) {
Expand Down
6 changes: 3 additions & 3 deletions src/edu/csus/ecs/pc2/clics/API202306/CLICSVerionInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

/**
* CLICS Version Info.
*
*
* @author Douglas A. Lane <[email protected]>
* @author John Buck
*
Expand All @@ -24,10 +24,10 @@ public class CLICSVerionInfo {

@JsonProperty
private CLICSProvider provider;

/**
* Fill in the API version information properties
*
*
* @param versionInfo
*/
public CLICSVerionInfo(VersionInfo versionInfo) {
Expand Down
Loading

0 comments on commit e0b0bec

Please sign in to comment.