|
21 | 21 | import com.topcoder.direct.services.view.util.SessionData;
|
22 | 22 | import com.topcoder.management.deliverable.Submission;
|
23 | 23 | import com.topcoder.management.project.Prize;
|
| 24 | +import com.topcoder.management.project.ProjectGroup; |
24 | 25 | import com.topcoder.management.resource.Resource;
|
25 | 26 | import com.topcoder.management.resource.ResourceRole;
|
26 | 27 | import com.topcoder.security.TCSubject;
|
|
37 | 38 |
|
38 | 39 | import javax.servlet.http.HttpServletRequest;
|
39 | 40 | import javax.servlet.http.HttpSession;
|
40 |
| -import java.util.ArrayList; |
41 |
| -import java.util.Arrays; |
42 |
| -import java.util.Collections; |
43 |
| -import java.util.Comparator; |
44 |
| -import java.util.HashMap; |
45 |
| -import java.util.List; |
46 |
| -import java.util.Map; |
| 41 | +import java.util.*; |
47 | 42 |
|
48 | 43 | /**
|
49 | 44 | * <p>
|
|
274 | 269 | *
|
275 | 270 | * @author fabrizyo, FireIce, isv, morehappiness, GreatKevin, minhu, Veve, Ghost_141, GreatKevin, Veve, GreatKevin, TCSCODER
|
276 | 271 | * @version 3.5
|
| 272 | + * |
| 273 | + * * <p> |
| 274 | + * Version 3.6 - Topcoder - Integrate Direct with Groups V5 |
| 275 | + * - Refactor projectGroup to comply with v5 |
| 276 | + * </p> |
| 277 | + * |
| 278 | + * @author fabrizyo, FireIce, isv, morehappiness, GreatKevin, minhu, Veve, Ghost_141, GreatKevin, Veve, GreatKevin, TCSCODER, dushyantb |
| 279 | + * @version 3.6 |
277 | 280 | */
|
278 | 281 | public class GetContestAction extends ContestAction {
|
279 | 282 | /**
|
@@ -401,6 +404,11 @@ public class GetContestAction extends ContestAction {
|
401 | 404 | */
|
402 | 405 | private boolean showSaveChallengeConfirmation;
|
403 | 406 |
|
| 407 | + /** |
| 408 | + * Endpoint to group of a user |
| 409 | + */ |
| 410 | + private String userGroupsApiEndpoint; |
| 411 | + |
404 | 412 | /**
|
405 | 413 | * <p>
|
406 | 414 | * Creates a <code>GetContestAction</code> instance.
|
@@ -463,8 +471,23 @@ protected void executeAction() throws Exception {
|
463 | 471 | if (DirectUtils.isStudio(softwareCompetition)) {
|
464 | 472 | softwareCompetition.setType(CompetionType.STUDIO);
|
465 | 473 | }
|
466 |
| - softwareCompetition.getProjectHeader().setGroups(DirectUtils.getGroupIdAndName( |
467 |
| - softwareCompetition.getProjectHeader().getGroups())); |
| 474 | + List<ProjectGroup> projectGroups = DirectUtils.getGroupIdAndName( |
| 475 | + softwareCompetition.getProjectHeader().getGroups()); |
| 476 | + |
| 477 | + if (projectGroups != null && this.type == TYPE.CONTEST_JSON) { |
| 478 | + // get v5 id of groups |
| 479 | + Set<Map<String, String>> projectGroupUser = DirectUtils.getGroups(DirectUtils.getTCSubjectFromSession(), |
| 480 | + userGroupsApiEndpoint); |
| 481 | + for (ProjectGroup pg : projectGroups) { |
| 482 | + for (Map<String, String> pgu : projectGroupUser) { |
| 483 | + if (String.valueOf(pg.getId()).equals(pgu.get("oldId"))) { |
| 484 | + pg.setNewId(pgu.get("id")); |
| 485 | + break; |
| 486 | + } |
| 487 | + } |
| 488 | + } |
| 489 | + } |
| 490 | + softwareCompetition.getProjectHeader().setGroups(projectGroups); |
468 | 491 |
|
469 | 492 | setResult(softwareCompetition);
|
470 | 493 | regEndDate = DirectUtils.getDateString(DirectUtils.getRegistrationEndDate(softwareCompetition));
|
@@ -974,4 +997,12 @@ public boolean isShowSaveChallengeConfirmation() {
|
974 | 997 | return showSaveChallengeConfirmation;
|
975 | 998 | }
|
976 | 999 |
|
| 1000 | + public String getUserGroupsApiEndpoint() { |
| 1001 | + return userGroupsApiEndpoint; |
| 1002 | + } |
| 1003 | + |
| 1004 | + public void setUserGroupsApiEndpoint(String userGroupsApiEndpoint) { |
| 1005 | + this.userGroupsApiEndpoint = userGroupsApiEndpoint; |
| 1006 | + } |
| 1007 | + |
977 | 1008 | }
|
0 commit comments