/** * This method is responsible for retrieving MM, list of RegistrantInfo and list of SubmissionInfo * given round id, pageSize, pageNumber, sortingOrder, sortingField * * @return a <code>String</code> that represent the state of execute result. * @throws Exception if any error occurred. */ public String execute() throws Exception { final String signature = CLASS_NAME + "#execute()"; try { if (projectId <= 0) { throw new DirectException("project less than 0 or not defined."); } TCSubject currentUser = DirectUtils.getTCSubjectFromSession(); softwareCompetition = contestServiceFacade.getSoftwareContestByProjectId( DirectStrutsActionsHelper.getTCSubjectFromSession(), projectId); // Get the round id from the project info. String roundIdStr = softwareCompetition.getProjectHeader().getProperty("Marathon Match Id"); hasRoundId = !(roundIdStr == null); viewData = new MMResultsInfoDTO(); if (hasRoundId) { viewData.setRoundId(Long.valueOf(roundIdStr)); } // If the contest don't have the round id or the contest is a active contest then throw an // exception. if (!hasRoundId || MarathonMatchHelper.isMarathonMatchActive( viewData.getRoundId(), marathonMatchAnalyticsService)) { throw new Exception("The contest is either don't have round id or is an active contest"); } MarathonMatchHelper.getMarathonMatchDetails( viewData.getRoundId().toString(), marathonMatchAnalyticsService, timelineInterval, viewData); // Get the common data for contest page. MarathonMatchHelper.getCommonData( projectId, currentUser, softwareCompetition, viewData, contestServiceFacade, getSessionData()); if (type == null) { // results page. viewResults(); } else if (type.equals(RESULT_DETAIL)) { // result detail page. viewSystemTestResults(); } return SUCCESS; } catch (Exception e) { LoggingWrapperUtility.logException(logger, signature, e); throw new Exception("Error when executing action : " + getAction() + " : " + e.getMessage()); } }
/** * Creates draft copilot posting for the newly created project. * * @param directProject the direct project. * @return the created competition * @throws Exception if error happens when creating the contest. * @since 1.1 */ private SoftwareCompetition createCopilotDraftPosting(ProjectData directProject) throws Exception { SoftwareCompetition cp = new SoftwareCompetition(); cp.setAssetDTO(getAssetDTOForNewSoftware()); String name = getAssetDTO().getName(); if (name == null || name.equals("")) { name = directProject.getName(); } cp.getAssetDTO().setName(name); GregorianCalendar c = new GregorianCalendar(); c.setTime(new Date()); c.add(Calendar.DAY_OF_MONTH, 2); XMLGregorianCalendar contestStartDate = DatatypeFactory.newInstance().newXMLGregorianCalendar(c); cp.getAssetDTO().setProductionDate(contestStartDate); // build the project header Project projectHeader = new Project(); ProjectCategory projectCategory = new ProjectCategory(); projectCategory.setId(29); projectCategory.setName("Copilot Posting"); projectCategory.setProjectType(ProjectType.APPLICATION); projectHeader.setProjectCategory(projectCategory); projectHeader.setId(-1L); if (projectData.getProjectBillingAccountId() > 0) { projectHeader.setProperty( ProjectPropertyType.BILLING_PROJECT_PROJECT_PROPERTY_KEY, String.valueOf(projectData.getProjectBillingAccountId())); } else { projectHeader.setProperty(ProjectPropertyType.BILLING_PROJECT_PROJECT_PROPERTY_KEY, "0"); } projectHeader.setProperty("Confidentiality Type", "public"); projectHeader.setProperty("Copilot Cost", "0"); projectHeader.setProperty("Project Name", name); projectHeader.setTcDirectProjectId(directProject.getProjectId()); projectHeader.setTcDirectProjectName(directProject.getName()); // set spec info - do not need spec review ProjectSpec projectSpec = new ProjectSpec(); projectSpec.setProjectSpecId(0L); if (getProjectHeader() != null && getProjectHeader().getProjectSpec() != null) { projectSpec.setDetailedRequirements( getProjectHeader().getProjectSpec().getDetailedRequirements()); } projectHeader.setProjectSpec(projectSpec); // add prize List<Prize> prizes = new ArrayList<Prize>(); Prize firstPlace = new Prize(); firstPlace.setNumberOfSubmissions(1); firstPlace.setPlace(1); firstPlace.setPrizeAmount(150); firstPlace.setProjectId(directProject.getProjectId()); Prize secondPlace = new Prize(); secondPlace.setNumberOfSubmissions(1); secondPlace.setPlace(2); secondPlace.setPrizeAmount(75); secondPlace.setProjectId(directProject.getProjectId()); com.topcoder.management.project.PrizeType prizeType = new com.topcoder.management.project.PrizeType(); prizeType.setDescription("Contest Prize"); prizeType.setId(15L); firstPlace.setPrizeType(prizeType); prizes.add(firstPlace); secondPlace.setPrizeType(prizeType); prizes.add(secondPlace); projectHeader.setPrizes(prizes); projectHeader.setProperty(ProjectPropertyType.ADMIN_FEE_PROJECT_PROPERTY_KEY, "0"); projectHeader.setProperty(ProjectPropertyType.COPILOT_COST_PROJECT_PROPERTY_KEY, "0"); projectHeader.setProperty(ProjectPropertyType.DR_POINTS_PROJECT_PROPERTY_KEY, "0"); projectHeader.setProperty(ProjectPropertyType.PAYMENTS_PROJECT_PROPERTY_KEY, "150"); projectHeader.setProperty(ProjectPropertyType.FIRST_PLACE_COST_PROJECT_PROPERTY_KEY, "150"); projectHeader.setProperty(ProjectPropertyType.RELIABILITY_BONUS_COST_PROJECT_PROPERTY_KEY, "0"); projectHeader.setProperty(ProjectPropertyType.CHECKPOINT_BONUS_COST_PROJECT_PROPERTY_KEY, "0"); projectHeader.setProperty(ProjectPropertyType.SPEC_REVIEW_COSTS_PROJECT_PROPERTY_KEY, "0"); projectHeader.setProperty(ProjectPropertyType.SECOND_PLACE_COST_PROJECT_PROPERTY_KEY, "75"); projectHeader.setProperty(ProjectPropertyType.REVIEW_COSTS_PROJECT_PROPERTY_KEY, "0"); cp.setId(-1L); cp.setProjectHeader(projectHeader); initializeCompetition(cp); populateCompetition(cp); cp = getContestServiceFacade() .createSoftwareContest( DirectUtils.getTCSubjectFromSession(), cp, directProject.getProjectId(), null, null); return cp; }