Skip to content
This repository was archived by the owner on Jan 23, 2025. It is now read-only.
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
Original file line number Diff line number Diff line change
Expand Up @@ -1572,5 +1572,5 @@ Set<Long> updatePreRegister(TCSubject tcSubject, SoftwareCompetition contest,
* @throws ContestServiceException if any database related exception occur
* @since 1.8.6
*/
public ProjectGroup[] getAllProjectGroups() throws ContestServiceException;
public ProjectGroup[] getAllProjectGroups(TCSubject tcSubject) throws ContestServiceException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -9312,9 +9312,13 @@ public void cancelSoftwareContestByUser(TCSubject tcSubject, long projectId) thr
* @throws ContestServiceException if any database related exception occur
* @since 3.7
*/
public ProjectGroup[] getAllProjectGroups() throws ContestServiceException {
public ProjectGroup[] getAllProjectGroups(TCSubject tcSubject) throws ContestServiceException {
logger.debug("getAllProjectGroups");

if (!isRole(tcSubject, ADMIN_ROLE) && !isRole(tcSubject, TC_STAFF_ROLE)) {
return new ProjectGroup[0];
}

try {
return projectServices.getAllProjectGroups();
} catch (ProjectServicesException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import java.util.List;
import java.util.Map;

import com.topcoder.management.project.ProjectGroup;
import com.topcoder.management.project.ProjectPlatform;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.InitializingBean;
Expand All @@ -28,15 +27,7 @@
* </ul>
* </p>
*
* <p>
* Version 1.2 (TOPCODER - SUPPORT GROUPS CONCEPT FOR CHALLENGES) :
* <ul>
* <li>Added {@link #groups}list of all project_group_lu</li>
* <li>Added {@link #groupMap}map project_group_id to its object</li>
* <li>Updated {@link #afterPropertiesSet()} to set groups and groupMap</li>
* </ul>
* </p>
* @version 1.2
* @version 1.1
* @author GreatKevin, TCSCODER
*/
public class ReferenceDataBean implements InitializingBean {
Expand Down Expand Up @@ -145,20 +136,6 @@ public class ReferenceDataBean implements InitializingBean {
*/
private Map<Long, List<Category>> catalogToCategoriesMap;

/**
* Challenge groups
*
* @since 1.2
*/
private List<ProjectGroup> groups;

/**
* Map of challenge group if to its object
*
* @since 1.2
*/
private Map<Long, ProjectGroup> groupMap;

/**
* <p>
* Gets the contest service facade.
Expand Down Expand Up @@ -335,36 +312,6 @@ public Map<Long, List<Category>> getCatalogToCategoriesMap() {
return catalogToCategoriesMap;
}

/**
* Getter for {@link #groups}
*
* @return groups
* @since 1.2
*/
public List<ProjectGroup> getGroups() {
return groups;
}

/**
* Setter for {@link #groups}
*
* @param groups list of ProjectGroup
* @since 1.2
*/
public void setGroups(List<ProjectGroup> groups) {
this.groups = groups;
}

/**
* Getter for {@link #groupMap}
*
* @return groupMap
* @since 1.2
*/
public Map<Long, ProjectGroup> getGroupMap() {
return groupMap;
}

/**
* <p>
* Initialization function. It will be called by Spring context.
Expand Down Expand Up @@ -393,12 +340,6 @@ public void afterPropertiesSet() throws Exception {
platformMap.put(platform.getId(), platform);
}

groups = Arrays.asList(getContestServiceFacade().getAllProjectGroups());
groupMap = new HashMap<Long, ProjectGroup>();
for (ProjectGroup group : groups) {
groupMap.put(group.getId(), group);
}

// categories
categories = new ArrayList<Category>();
categoryMap = new HashMap<Long, Category>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import com.topcoder.service.facade.project.DAOFault;
import org.apache.commons.lang3.StringEscapeUtils;
import org.codehaus.jackson.map.ObjectMapper;
import com.topcoder.management.project.ProjectGroup;

/**
* <p>
Expand Down Expand Up @@ -324,7 +325,7 @@ public String getContestConfigs() throws Exception {

configs.put("copilotFees", ConfigUtils.getCopilotFees());
configs.put("billingInfos", getBillingProjectInfos());
configs.put("groups", getReferenceDataBean().getGroups());
configs.put("groups", getAllProjectGroups());
setResult(configs);
return SUCCESS;
}
Expand Down Expand Up @@ -446,6 +447,18 @@ private List<Map<String, Object>> getBillingProjectInfos() throws DAOFault {
return billings;
}

/**
* <p>
* Gets all project groups
* </p>
*
* @return the billing project information. each project is represented in a map object.
* @throws ContestServiceException if contest service exception occurs
*/
private List<ProjectGroup> getAllProjectGroups() throws ContestServiceException {
return Arrays.asList(getContestServiceFacade().getAllProjectGroups(DirectStrutsActionsHelper.getTCSubjectFromSession()));
}


/**
* <p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1011,11 +1011,18 @@ public boolean evaluate(Object object) {
populateSoftwareCompetition(softwareCompetition);
}

//set group
//set groups
if (groups != null && groups.size() > 0) {
List<ProjectGroup> groupsList = new ArrayList<ProjectGroup>();
// get the TCSubject from session
ProjectGroup[] allProjectGroups = getContestServiceFacade().getAllProjectGroups(DirectStrutsActionsHelper.getTCSubjectFromSession());
for (String groupId : groups) {
groupsList.add(getReferenceDataBean().getGroupMap().get(Long.valueOf(groupId)));
for (ProjectGroup projectGroup : allProjectGroups) {
if (Long.valueOf(projectGroup.getId()).equals(groupId)) {
groupsList.add(projectGroup);
}
}

}
softwareCompetition.getProjectHeader().setGroups(groupsList);
} else {
Expand Down