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

Commit 637475d

Browse files
authored
Merge pull request #212 from appirio-tech/dev
Promote dev to prod
2 parents 12e3d8d + a0f1dec commit 637475d

File tree

5 files changed

+167
-30
lines changed

5 files changed

+167
-30
lines changed

components/online_review_upload_services/src/java/main/com/cronos/onlinereview/services/uploads/impl/DefaultUploadServices.java

+45-4
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,17 @@
113113
* change the other variables.
114114
* </p>
115115
*
116+
* Version 1.1.4 (TOPCODER DIRECT - FIXES FOR CLOSE PRIVATE CHALLENGE IMMEDIATELY):
117+
* <ol>
118+
* <li>Added {@link #isProjectResultCategory(long)} method</li>
119+
* </ol>
120+
* </p>
121+
* <p>
122+
* Thread safety: the thread safety is completely relied to the managers implementations because it's impossible to
123+
* change the other variables.
124+
* </p>
116125
* @author fabrizyo, saarixx, cyberjag, TCSDEVELOPER
117-
* @version 1.1.3
126+
* @version 1.1.4
118127
*/
119128
public class DefaultUploadServices implements UploadServices {
120129

@@ -1627,6 +1636,39 @@ public Resource addPrimaryScreener(long projectId, long userId) throws UploadSer
16271636
}
16281637
}
16291638

1639+
/**
1640+
* Lookup function for project categories that should have a project_result row. These rows are used
1641+
* for ratings, reliability, and the Digital Run.
1642+
*
1643+
* Copied from online_review: com/cronos/onlinereview/util/ActionsHelper.java#L205
1644+
*
1645+
* @param categoryId the category id to look up.
1646+
* @return whether the provided category id should have a project_result row.
1647+
* @since 1.1.4
1648+
*/
1649+
private static boolean isProjectResultCategory(long categoryId) {
1650+
return (categoryId == 1 // Component Design
1651+
|| categoryId == 2 // Component Development
1652+
|| categoryId == 5 // Component Testing
1653+
|| categoryId == 6 // Application Specification
1654+
|| categoryId == 7 // Application Architecture
1655+
|| categoryId == 9 // Bug Hunt
1656+
|| categoryId == 13 // Test Scenarios
1657+
|| categoryId == 26 // Test Suites
1658+
|| categoryId == 14 // Application Assembly
1659+
|| categoryId == 23 // Application Conceptualization
1660+
|| categoryId == 19 // UI Prototype
1661+
|| categoryId == 24 // RIA Build
1662+
|| categoryId == 25 // RIA Component
1663+
|| categoryId == 29 // Copilot Posting
1664+
|| categoryId == 35 // Content Creation
1665+
|| categoryId == 36 // Reporting
1666+
|| categoryId == 38 // First2Finish
1667+
|| categoryId == 39 // Code
1668+
|| categoryId == 40 // Design F2F (NEW)
1669+
);
1670+
}
1671+
16301672
/**
16311673
* Populate project_result and component_inquiry for new submitters.
16321674
*
@@ -1644,9 +1686,8 @@ private void populateProjectResult(Project project, Collection newSubmitters) th
16441686
PreparedStatement ratingStmt = null;
16451687
PreparedStatement componentInquiryStmt = null;
16461688
long categoryId = project.getProjectCategory().getId();
1647-
// Only design/development/assembly will modify the project result table.
1648-
if (categoryId != 1 && categoryId != 2 && categoryId != 14) {
1649-
// design/development/assembly project need project_result
1689+
1690+
if (!isProjectResultCategory(categoryId)) {
16501691
return;
16511692
}
16521693
LOG.log(Level.INFO, "Populating the project result table.");

services/contest_service_facade/src/java/main/com/topcoder/service/facade/contest/ejb/ContestServiceFacadeBean.java

+108-21
Original file line numberDiff line numberDiff line change
@@ -862,9 +862,14 @@
862862
* <li>Add {@link #cancelSoftwareContestByUser(TCSubject, long)}</li>
863863
* </ul>
864864
*
865+
* Version 3.6 (TOPCODER DIRECT - FIXES FOR CLOSE PRIVATE CHALLENGE IMMEDIATELY)
866+
* <ul>
867+
* <li>Refactor {@link #createReviewerResource(long, long, long, boolean, boolean)}</li>
868+
* <li>Fix {@link #closeSoftwareContest(TCSubject, long, long)} to work with auto pilot</li>
869+
* </ul>
865870
* @author snow01, pulky, murphydog, waits, BeBetter, hohosky, isv, tangzx, GreatKevin, lmmortal, minhu, GreatKevin, tangzx
866871
* @author isv, GreatKevin, Veve, deedee, TCSCODER, TCSASSEMBLER
867-
* @version 3.5
872+
* @version 3.6
868873
*/
869874
@Stateless
870875
@TransactionManagement(TransactionManagementType.CONTAINER)
@@ -963,6 +968,18 @@ public class ContestServiceFacadeBean implements ContestServiceFacadeLocal, Cont
963968
*/
964969
private static final String RESOURCE_INFO_PAYMENT_NA = "N/A";
965970

971+
/**
972+
* Resource info attribute for Manual payment
973+
* @since 3.6
974+
*/
975+
private static final String RESOURCE_INFO_MANUAL_PAYMENT = "Manual Payments";
976+
977+
/**
978+
* Scorecard ID attibute
979+
* @since 3.6
980+
*/
981+
private static final String SCORECARD_ID_ATTRIBUTE = "Scorecard ID";
982+
966983
/**
967984
* Email file template source key that is used by email generator.
968985
*/
@@ -1011,6 +1028,13 @@ public class ContestServiceFacadeBean implements ContestServiceFacadeLocal, Cont
10111028
*/
10121029
private static final String ADMIN_ROLE = "Cockpit Administrator";
10131030

1031+
/**
1032+
* Private constant specifying project registration phase name.
1033+
*
1034+
* @since 3.6
1035+
*/
1036+
private static final String PROJECT_REGISTRATION_PHASE_NAME = "Registration";
1037+
10141038
/**
10151039
* Private constant specifying project submission phase name.
10161040
*
@@ -4098,13 +4122,35 @@ private com.topcoder.management.resource.Resource createIterativeReviewerResourc
40984122
* @throws UserServiceException if error when getting resource handle.
40994123
* @since 2.5
41004124
*/
4101-
private com.topcoder.management.resource.Resource createReviewerResource(long userId, long contestId, long phaseId, boolean hasPayment) throws UserServiceException {
4125+
private com.topcoder.management.resource.Resource createReviewerResource(long userId, long contestId, long phaseId,
4126+
boolean hasPayment) throws UserServiceException {
4127+
return createReviewerResource(userId, contestId, phaseId, hasPayment, false);
4128+
}
4129+
4130+
/**
4131+
* Creates a Reviewer Resource to add to the contest
4132+
*
4133+
* @param userId the user id
4134+
* @param contestId the contest id.
4135+
* @param phaseId the phase the resource adds to, 0 for not add
4136+
* @param hasPayment whether this resource should be paid.
4137+
* @param iterativeReviewer whether this iterative review
4138+
* @return the created Reviewer resource to add.
4139+
* @throws UserServiceException if error when getting resource handle.
4140+
* @since 3.6
4141+
*/
4142+
private com.topcoder.management.resource.Resource createReviewerResource(long userId, long contestId, long phaseId,
4143+
boolean hasPayment, boolean iterativeReviewer) throws UserServiceException {
41024144
com.topcoder.management.resource.Resource resource = new com.topcoder.management.resource.Resource();
41034145
// unset id
41044146
resource.setId(-1);
41054147

41064148
// set resource to reviewer
4107-
resource.setResourceRole(new ResourceRole(ResourceRole.RESOURCE_ROLE_REVIEWER_ID));
4149+
if (iterativeReviewer){
4150+
resource.setResourceRole(new ResourceRole(ResourceRole.RESOURCE_ROLE_ITERATIVE_REVIEWER_ID));
4151+
}else {
4152+
resource.setResourceRole(new ResourceRole(ResourceRole.RESOURCE_ROLE_REVIEWER_ID));
4153+
}
41084154

41094155
resource.setProperty(RESOURCE_INFO_HANDLE, userService.getUserHandle(userId));
41104156
resource.setProperty(RESOURCE_INFO_EXTERNAL_REFERENCE_ID, String.valueOf(userId));
@@ -4121,6 +4167,7 @@ private com.topcoder.management.resource.Resource createReviewerResource(long us
41214167
if(!hasPayment) {
41224168
resource.setProperty(RESOURCE_INFO_PAYMENT_STATUS, RESOURCE_INFO_PAYMENT_STATUS_NA);
41234169
resource.setProperty(RESOURCE_INFO_PAYMENT, RESOURCE_INFO_PAYMENT_NA);
4170+
resource.setProperty(RESOURCE_INFO_MANUAL_PAYMENT, "true");
41244171
}
41254172

41264173
// set registration date to now
@@ -9083,28 +9130,45 @@ public void closeSoftwareContest(TCSubject tcSubject, long projectId, long winne
90839130

90849131
//close submission and review phase
90859132
com.topcoder.project.phases.Phase submissionPhase = null;
9133+
com.topcoder.project.phases.Phase reviewPhase = null;
90869134
for (com.topcoder.project.phases.Phase phase : phases) {
9087-
if (PROJECT_SUBMISSION_PHASE_NAME.equals(phase.getPhaseType().getName()) ||
9088-
PROJECT_ITERATIVE_REVIEW_PHASE_NAME.equals(phase.getPhaseType().getName()) ||
9089-
PROJECT_REVIEW_PHASE_NAME.equals(phase.getPhaseType().getName())) {
9090-
Date scheduleStartDate = phase.getScheduledStartDate();
9135+
if (PROJECT_REGISTRATION_PHASE_NAME.equals(phase.getPhaseType().getName()) ||
9136+
PROJECT_SUBMISSION_PHASE_NAME.equals(phase.getPhaseType().getName()) ||
9137+
PROJECT_REVIEW_PHASE_NAME.equals(phase.getPhaseType().getName()) ||
9138+
PROJECT_ITERATIVE_REVIEW_PHASE_NAME.equals(phase.getPhaseType().getName())) {
90919139
Date currentDate = new Date();
9092-
Date actualStartDate = null;
9093-
long length = 0L;
9094-
if (currentDate.before(scheduleStartDate)){
9095-
//set length to 5 minutes
9096-
length = 5 * MINUTE_IN_MILIS;
9097-
actualStartDate = new Date(currentDate.getTime() - length);
9098-
} else{
9099-
actualStartDate = scheduleStartDate;
9100-
length = currentDate.getTime() - scheduleStartDate.getTime();
9101-
}
9102-
phase.setActualStartDate(actualStartDate);
9103-
phase.setActualEndDate(currentDate);
9104-
phase.setLength(length);
9105-
phase.setPhaseStatus(PhaseStatus.CLOSED);
9140+
//length 1 hour
9141+
long length = 60 * MINUTE_IN_MILIS;
9142+
//submision start 3h before
9143+
Date regStartDate = new Date(currentDate.getTime() - 180 * MINUTE_IN_MILIS);
9144+
//submision start 2h before
9145+
Date submissionStartDate = new Date(currentDate.getTime() - 120 * MINUTE_IN_MILIS);
9146+
//submission end / review start 1h before
9147+
Date submissionEndDate = new Date(currentDate.getTime() - 60 * MINUTE_IN_MILIS);
9148+
91069149
if (PROJECT_SUBMISSION_PHASE_NAME.equals(phase.getPhaseType().getName())) {
9150+
phase.setScheduledStartDate(submissionStartDate);
9151+
phase.setActualStartDate(submissionStartDate);
9152+
phase.setScheduledEndDate(submissionEndDate);
9153+
phase.setActualEndDate(submissionEndDate);
9154+
phase.setLength(length);
9155+
phase.setPhaseStatus(PhaseStatus.CLOSED);
91079156
submissionPhase = phase;
9157+
} else if (PROJECT_REGISTRATION_PHASE_NAME.equals(phase.getPhaseType().getName())) {
9158+
phase.setScheduledStartDate(regStartDate);
9159+
phase.setFixedStartDate(regStartDate);
9160+
phase.setActualStartDate(regStartDate);
9161+
phase.setScheduledEndDate(submissionEndDate);
9162+
phase.setActualEndDate(submissionEndDate);
9163+
phase.setLength(2 * length);
9164+
phase.setPhaseStatus(PhaseStatus.CLOSED);
9165+
} else {
9166+
phase.setScheduledStartDate(submissionEndDate);
9167+
phase.setActualStartDate(submissionEndDate);
9168+
phase.setScheduledEndDate(currentDate);
9169+
phase.setLength(length);
9170+
phase.setPhaseStatus(PhaseStatus.OPEN);
9171+
reviewPhase = phase;
91089172
}
91099173
}
91109174
}
@@ -9115,14 +9179,37 @@ public void closeSoftwareContest(TCSubject tcSubject, long projectId, long winne
91159179
Submission submission = uploadManager.getSubmission(submissionId);
91169180
submission.setInitialScore(100.0);
91179181
submission.setFinalScore(100.0);
9182+
submission.setPlacement(1L);
9183+
submission.setPrize(contest.getPrizes().get(0));
91189184
uploadManager.updateSubmission(submission, String.valueOf(tcSubject.getUserId()));
91199185

9186+
//create reviewer, remove if there is
9187+
com.topcoder.management.resource.Resource[] reviewers = this.projectServices.searchResources(contest.getId(),
9188+
ResourceRole.RESOURCE_ROLE_ITERATIVE_REVIEWER_ID);
9189+
for (com.topcoder.management.resource.Resource r : reviewers) {
9190+
this.projectServices.removeResource(r, String.valueOf(tcSubject.getUserId()));
9191+
}
9192+
com.topcoder.management.resource.Resource reviewer = createReviewerResource(winnerId, contest.getId(),
9193+
reviewPhase.getId(), false, ProjectCategory.FIRST2FINISH.getName().equals(contest.getProjectCategory().getName()));
9194+
9195+
reviewer = projectServices.updateResource(reviewer, String.valueOf(tcSubject.getUserId()));
9196+
9197+
//create review
9198+
Scorecard scorecard = projectServices.getScorecard(Long.parseLong((String) reviewPhase.getAttribute(SCORECARD_ID_ATTRIBUTE)));
9199+
createReview(reviewer, submissionId, 1, scorecard, reviewPhase.getId());
9200+
91209201
Upload upload = submission.getUpload();
91219202
upload.setProjectPhase(submissionPhase.getId());
91229203
uploadManager.updateUpload(upload, String.valueOf(tcSubject.getUserId()));
91239204
} catch (IOException e) {
91249205
logger.error("Failed to create submission file");
91259206
throw new ContestServiceException("Failed to create submission file", e);
9207+
} catch (UserServiceException e) {
9208+
logger.error("User not found: " + String.valueOf(winnerId));
9209+
throw new ContestServiceException("User not found: " + String.valueOf(winnerId), e);
9210+
} catch (ReviewManagementException e) {
9211+
logger.error("Failed to create review");
9212+
throw new ContestServiceException("Failed to create review", e);
91269213
} catch (ProjectServicesException e) {
91279214
logger.error("Failed to update phase");
91289215
throw new ContestServiceException("Failed to update phase", e);

services/project_services/src/java/main/com/topcoder/project/service/impl/ProjectServicesImpl.java

+9-2
Original file line numberDiff line numberDiff line change
@@ -2083,14 +2083,17 @@ public FullProjectData updateProject(Project projectHeader, String projectHeader
20832083
if (p.getPhaseType().getId() == PhaseType.REGISTRATION_PHASE.getId() && projectHeader.getProjectStatus().getId() == ProjectStatus.DRAFT.getId()) {
20842084
if (projectHeader.getProperty(ProjectPropertyType.PRIVATE_PROJECT) != null && "1".equals(projectHeader.getProperty(ProjectPropertyType.PRIVATE_PROJECT))) {
20852085
if (p.getPhaseStatus().getId() != PhaseStatus.CLOSED.getId()) {
2086-
p.setActualStartDate(p.getScheduledStartDate());
2087-
p.setActualEndDate(p.getScheduledEndDate());
2086+
Date now = new Date();
2087+
p.setFixedStartDate(now);
2088+
p.setActualStartDate(now);
2089+
p.setActualEndDate(new Date(System.currentTimeMillis()+5*60*1000));
20882090
p.setPhaseStatus(PhaseStatus.CLOSED);
20892091
}
20902092
} else {
20912093
if (p.getPhaseStatus().getId() == PhaseStatus.CLOSED.getId()) {
20922094
p.setActualStartDate(null);
20932095
p.setActualEndDate(null);
2096+
p.setFixedStartDate(null);
20942097
p.setPhaseStatus(PhaseStatus.SCHEDULED);
20952098
}
20962099
}
@@ -5168,6 +5171,10 @@ private void setNewPhasesProperties(Project projectHeader,
51685171
if (p.getPhaseType().getId() == PhaseType.REGISTRATION_PHASE.getId()) {
51695172
if (projectHeader.getProperty(ProjectPropertyType.PRIVATE_PROJECT) != null && projectHeader.getProperty(ProjectPropertyType.PRIVATE_PROJECT).equals("1") && projectHeader.getProjectStatus().getId() == ProjectStatus.DRAFT.getId()) {
51705173
p.setPhaseStatus(PhaseStatus.CLOSED);
5174+
Date now = new Date();
5175+
p.setFixedStartDate(now);
5176+
p.setActualStartDate(now);
5177+
p.setActualEndDate(new Date(System.currentTimeMillis()+5*60*1000));
51715178
}
51725179
}
51735180
}

src/web/scripts/launch/contestDetailSoftware.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -2336,7 +2336,7 @@ function validateFieldsPrizeSection() {
23362336
validateCodePrizes(errors);
23372337
}
23382338

2339-
if (phaseOpen) {
2339+
if (disablePrizeAdjustment()) {
23402340
var newFirstPlacePrize = $('#swFirstPlace').val();
23412341
var newDigitalRun = $('#swDigitalRun').val();
23422342
if (checkNumber(newFirstPlacePrize)) {
@@ -2389,7 +2389,7 @@ function validateFieldsPrizeSection() {
23892389
}
23902390
}
23912391

2392-
if (isActiveContest) {
2392+
if (isActiveContest && !mainWidget.softwareCompetition.isPrivateProject()) {
23932393
var totalCostWithoutAdminFee = retrieveContestCostWithoutAdminFee();
23942394
if (totalCostWithoutAdminFee < preCost) {
23952395
errors.push('The cost of active challenge should not be decreased.');

src/web/scripts/launch/main.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -971,6 +971,9 @@ function isContestSaved() {
971971
return (mainWidget.softwareCompetition.projectHeader.id > 0);
972972
}
973973

974+
function disablePrizeAdjustment() {
975+
return (phaseOpen && !mainWidget.softwareCompetition.isPrivateProject())
976+
}
974977

975978
/**
976979
* Handles cancel contest.
@@ -3101,7 +3104,6 @@ function validateCodePrizes(errors) {
31013104
newPrizes.push(value);
31023105
}
31033106
}
3104-
;
31053107

31063108
if (newPrizes.length < originalPrizes.prizes.length) {
31073109
errors.push('The prizes can not be deleted');

0 commit comments

Comments
 (0)