-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #909 from johnbrvc/i_900_multiple_groups_per_team
i_900: add support for multiple groups per team
- Loading branch information
Showing
84 changed files
with
7,206 additions
and
5,266 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,19 @@ | ||
// Copyright (C) 1989-2019 PC2 Development Team: John Clevenger, Douglas Lane, Samir Ashoo, and Troy Boudreau. | ||
package edu.csus.ecs.pc2.api; | ||
|
||
import java.util.HashMap; | ||
|
||
import edu.csus.ecs.pc2.core.model.ElementId; | ||
|
||
/** | ||
* This interface describes the PC<sup>2</sup> API view of a contest <I>Team</i>. | ||
* Note that every <I>Team</i> in the API view is a subclass of {@link IClient}, | ||
* so a "team view" also contains the general information described by | ||
* {@link IClient}. | ||
* | ||
* | ||
* <p> | ||
* This documentation describes the current <I>draft</i> of the PC<sup>2</sup> API, which is subject to change. | ||
* | ||
* | ||
* @author [email protected] | ||
* @version $Id$ | ||
*/ | ||
|
@@ -19,9 +23,16 @@ public interface ITeam extends IClient { | |
|
||
/** | ||
* Get the group associate with this team. | ||
* | ||
* | ||
* @see IGroup | ||
* @return group information. | ||
*/ | ||
IGroup getGroup(); | ||
public HashMap<ElementId, IGroup> getGroups(); | ||
|
||
/** | ||
* Get the primary (cms) group for a team | ||
* | ||
* @return id of the CMS supplied group (so-called primary group) | ||
*/ | ||
public IGroup getPrimaryGroup(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,18 @@ | ||
// Copyright (C) 1989-2019 PC2 Development Team: John Clevenger, Douglas Lane, Samir Ashoo, and Troy Boudreau. | ||
package edu.csus.ecs.pc2.api.implementation; | ||
|
||
import java.util.HashMap; | ||
|
||
import edu.csus.ecs.pc2.api.IGroup; | ||
import edu.csus.ecs.pc2.api.ITeam; | ||
import edu.csus.ecs.pc2.core.model.Account; | ||
import edu.csus.ecs.pc2.core.model.ClientId; | ||
import edu.csus.ecs.pc2.core.model.ElementId; | ||
import edu.csus.ecs.pc2.core.model.IInternalContest; | ||
|
||
/** | ||
* Implementation for ITeam. | ||
* | ||
* | ||
* @author [email protected] | ||
* @version $Id$ | ||
*/ | ||
|
@@ -21,7 +24,8 @@ public class TeamImplementation extends ClientImplementation implements ITeam { | |
|
||
private String shortName; | ||
|
||
private IGroup group = null; | ||
private HashMap<ElementId, IGroup> groups = null; | ||
private IGroup primaryGroup = null; | ||
|
||
public TeamImplementation(ClientId submitter, IInternalContest internalContest) { | ||
super(submitter, internalContest); | ||
|
@@ -38,12 +42,21 @@ public TeamImplementation(ClientId submitter, IInternalContest internalContest) | |
private void setAccountValues(Account account, IInternalContest contest) { | ||
displayName = account.getDisplayName(); | ||
shortName = account.getClientId().getName(); | ||
if (account.getGroupId() != null) { | ||
// SOMEDAY ensure that groupId is not null | ||
// this happened on load of teams.tsv and groups.tsv | ||
if (contest.getGroup(account.getGroupId()) != null){ | ||
group = new GroupImplementation(account.getGroupId(), contest); | ||
if (account.getGroupIds() != null) { | ||
for(ElementId elementId: account.getGroupIds()) { | ||
if (contest.getGroup(elementId) != null){ | ||
if(groups == null) { | ||
groups = new HashMap<ElementId, IGroup>(); | ||
} | ||
GroupImplementation group = new GroupImplementation(elementId, contest); | ||
groups.put(elementId, group); | ||
if(primaryGroup == null && account.getPrimaryGroupId() == elementId) { | ||
primaryGroup = group; | ||
} | ||
} | ||
} | ||
} else { | ||
groups = null; | ||
} | ||
} | ||
|
||
|
@@ -52,16 +65,24 @@ public TeamImplementation(Account account, IInternalContest contest) { | |
setAccountValues(account, contest); | ||
} | ||
|
||
@Override | ||
public String getDisplayName() { | ||
return displayName; | ||
} | ||
|
||
public IGroup getGroup() { | ||
return group; | ||
@Override | ||
public HashMap<ElementId, IGroup> getGroups() { | ||
return groups; | ||
} | ||
|
||
@Override | ||
public String getLoginName() { | ||
return shortName; | ||
} | ||
|
||
@Override | ||
public IGroup getPrimaryGroup() { | ||
return primaryGroup; | ||
} | ||
|
||
} |
Oops, something went wrong.