Skip to content
This repository was archived by the owner on Jan 23, 2025. It is now read-only.

Commit 54c7e3c

Browse files
author
Dushyant Bhalgami
authored
Merge pull request #513 from appirio-tech/feature/v5-groups-api
changes to integrate v5-groups-api in direct
2 parents 8b47e52 + 4390d51 commit 54c7e3c

File tree

10 files changed

+258
-87
lines changed

10 files changed

+258
-87
lines changed

components/project_management/src/java/main/com/topcoder/management/project/ProjectGroup.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,16 @@
1717
* @author TCSCODER
1818
* @version 1.0
1919
*/
20+
21+
/**
22+
* <p>
23+
* Changes related to v5-groups-api
24+
* </p>
25+
*
26+
* @author dushyantb
27+
* @version 1.1
28+
*/
29+
2030
public class ProjectGroup implements Serializable {
2131
/**
2232
* Represents group id
@@ -27,6 +37,11 @@ public class ProjectGroup implements Serializable {
2737
* Represents group name
2838
*/
2939
private String name;
40+
41+
/**
42+
* Represent new Id format
43+
*/
44+
private String newId;
3045

3146
/**
3247
* Constructor
@@ -76,4 +91,20 @@ public String getName() {
7691
public void setName(String name) {
7792
this.name = name;
7893
}
94+
95+
/**
96+
* Getter for {@link #newId}
97+
* @return
98+
*/
99+
public String getNewId() {
100+
return newId;
101+
}
102+
103+
/**
104+
* Setter for {@link #newId}
105+
* @param newId
106+
*/
107+
public void setNewId(String newId) {
108+
this.newId = newId;
109+
}
79110
}

conf/web/WEB-INF/applicationContext.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,7 @@
467467
parent="contestAction" scope="prototype">
468468
<property name="type" value="CONTEST_JSON" />
469469
<property name="timelineInterval" value="1"/>
470+
<property name="userGroupsApiEndpoint" value="@userGroupsApiEndpoint@"/>
470471
<!--
471472
<property name="marathonMatchAnalyticsService" ref="marathonMatchAnalyticsService"/>
472473
-->

src/java/main/com/topcoder/direct/services/view/action/contest/launch/CommonAction.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,15 @@
9999
* <li>Add enable effort hours</li>
100100
* </ul>
101101
* </p>
102+
*
103+
* <p>
104+
* Version 1.11 (Topcoder - Integrate Direct with Groups V5)
105+
* <ul>
106+
* <li>Refactor projectGroup to comply with v5</li>
107+
* </ul>
108+
* </p>
102109
*
103-
* @author BeBetter, pvmagacho, GreatKevin, bugbuka, GreatKevin
110+
* @author BeBetter, pvmagacho, GreatKevin, bugbuka, GreatKevin, dushyantb
104111
* @version 1.10
105112
*/
106113
public class CommonAction extends BaseContestFeeAction {
@@ -575,7 +582,7 @@ public void setCategoryId(long categoryId) {
575582
public String getGroups() {
576583
try {
577584
TCSubject tcSubject = DirectUtils.getTCSubjectFromSession();
578-
Set<ProjectGroup> projectGroups = DirectUtils.getGroups(tcSubject, userGroupsApiEndpoint);
585+
Set<Map<String, String>> projectGroups = DirectUtils.getGroups(tcSubject, userGroupsApiEndpoint);
579586
setResult(projectGroups);
580587
} catch (Throwable e) {
581588
if (getModel() != null) {

src/java/main/com/topcoder/direct/services/view/action/contest/launch/GetContestAction.java

Lines changed: 40 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import com.topcoder.direct.services.view.util.SessionData;
2222
import com.topcoder.management.deliverable.Submission;
2323
import com.topcoder.management.project.Prize;
24+
import com.topcoder.management.project.ProjectGroup;
2425
import com.topcoder.management.resource.Resource;
2526
import com.topcoder.management.resource.ResourceRole;
2627
import com.topcoder.security.TCSubject;
@@ -37,13 +38,7 @@
3738

3839
import javax.servlet.http.HttpServletRequest;
3940
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.*;
4742

4843
/**
4944
* <p>
@@ -274,6 +269,14 @@
274269
*
275270
* @author fabrizyo, FireIce, isv, morehappiness, GreatKevin, minhu, Veve, Ghost_141, GreatKevin, Veve, GreatKevin, TCSCODER
276271
* @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
277280
*/
278281
public class GetContestAction extends ContestAction {
279282
/**
@@ -401,6 +404,11 @@ public class GetContestAction extends ContestAction {
401404
*/
402405
private boolean showSaveChallengeConfirmation;
403406

407+
/**
408+
* Endpoint to group of a user
409+
*/
410+
private String userGroupsApiEndpoint;
411+
404412
/**
405413
* <p>
406414
* Creates a <code>GetContestAction</code> instance.
@@ -463,8 +471,23 @@ protected void executeAction() throws Exception {
463471
if (DirectUtils.isStudio(softwareCompetition)) {
464472
softwareCompetition.setType(CompetionType.STUDIO);
465473
}
466-
softwareCompetition.getProjectHeader().setGroups(DirectUtils.getGroupIdAndName(
467-
softwareCompetition.getProjectHeader().getGroups()));
474+
List<ProjectGroup> projectGroups = DirectUtils.getGroupIdAndName(
475+
softwareCompetition.getProjectHeader().getGroups());
476+
477+
if (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);
468491

469492
setResult(softwareCompetition);
470493
regEndDate = DirectUtils.getDateString(DirectUtils.getRegistrationEndDate(softwareCompetition));
@@ -974,4 +997,12 @@ public boolean isShowSaveChallengeConfirmation() {
974997
return showSaveChallengeConfirmation;
975998
}
976999

1000+
public String getUserGroupsApiEndpoint() {
1001+
return userGroupsApiEndpoint;
1002+
}
1003+
1004+
public void setUserGroupsApiEndpoint(String userGroupsApiEndpoint) {
1005+
this.userGroupsApiEndpoint = userGroupsApiEndpoint;
1006+
}
1007+
9771008
}

0 commit comments

Comments
 (0)