@@ -2354,6 +2354,22 @@ private XMLGregorianCalendar getXMLGregorianCalendar(Date date) {
2354
2354
}
2355
2355
}
2356
2356
2357
+ /**
2358
+ * <p>
2359
+ * Adds the specified number of minutes to the given date and returns the result.
2360
+ * </p>
2361
+ *
2362
+ * @param date The Date to which to add the given minutes amount
2363
+ * @param minutes The number of minutes to add to the given date (Can be negative)
2364
+ * @return The resulting date = input date + number of minutes
2365
+ */
2366
+ private Date addMinutesToDate (Date date , int minutes ) {
2367
+ Calendar cal = Calendar .getInstance ();
2368
+ cal .setTime (date );
2369
+ cal .add (Calendar .MINUTE , minutes );
2370
+ return cal .getTime ();
2371
+ }
2372
+
2357
2373
/**
2358
2374
* <p>
2359
2375
* Processes the contest sale.
@@ -4043,13 +4059,18 @@ else if (isDevContest) {
4043
4059
if (useExistingAsset && assetDTO .getForum () != null ) {
4044
4060
forumId = assetDTO .getForum ().getJiveCategoryId ();
4045
4061
} else {
4046
- if (!isStudio (contest )) {
4047
- // software contest
4048
- forumId = createForum (tcSubject , assetDTO , tcSubject .getUserId (),
4049
- contest .getProjectHeader ().getProjectCategory ().getId ());
4062
+ if (isPrivateProject (contest )) { // no forum to be created for private tasks
4063
+ logger .debug ("Skip forum creation for private task: " +assetDTO .getName ());
4064
+ forumId = -1 ;
4050
4065
} else {
4051
- // studio contest
4052
- forumId = createStudioForum (assetDTO .getName (), tcSubject .getUserId ());
4066
+ if (!isStudio (contest )) {
4067
+ // software contest
4068
+ forumId = createForum (tcSubject , assetDTO , tcSubject .getUserId (),
4069
+ contest .getProjectHeader ().getProjectCategory ().getId ());
4070
+ } else {
4071
+ // studio contest
4072
+ forumId = createStudioForum (assetDTO .getName (), tcSubject .getUserId ());
4073
+ }
4053
4074
}
4054
4075
}
4055
4076
}
@@ -5516,8 +5537,9 @@ public Set<Long> updatePreRegister(TCSubject tcSubject, SoftwareCompetition cont
5516
5537
5517
5538
removedUsers = uploadExternalServices .removeSubmitters (contest .getId (), removedUsers ,
5518
5539
String .valueOf (tcSubject .getUserId ()));
5519
- // remove forum
5520
- if (createForum ) {
5540
+ // remove forum user permissions for public projects.
5541
+ // private tasks do not have forums created
5542
+ if (createForum && !isPrivateProject (contest )) {
5521
5543
try {
5522
5544
forumId = contest .getAssetDTO ().getForum ().getJiveCategoryId ();
5523
5545
forum = getSoftwareForums ();
@@ -5536,7 +5558,7 @@ public Set<Long> updatePreRegister(TCSubject tcSubject, SoftwareCompetition cont
5536
5558
for (Long member : preRegisterMembers ) {
5537
5559
try {
5538
5560
this .addSubmitter (tcSubject , contest .getId (), member );
5539
- if (createForum ) {
5561
+ if (createForum && ! isPrivateProject ( contest ) ) {
5540
5562
forum .assignRole (member , userRoleId );
5541
5563
}
5542
5564
addedUsers .add (member );
@@ -9862,25 +9884,30 @@ public void closeSoftwareContest(TCSubject tcSubject, long projectId, long winne
9862
9884
DataHandler dataHandler = new DataHandler (new FileDataSource (mockSubmissionFilePath + mockSubmissionFileName ));
9863
9885
long submissionId = uploadSubmission (winnerId , contest .getId (), mockSubmissionFileName , dataHandler );
9864
9886
9865
- // close submission and review phase
9887
+ Date currentDate = new Date ();
9888
+ // subtract one minute from the current date
9889
+ // this will be used to set the registration start/end dates
9890
+ Date oneMinuteEarlier = addMinutesToDate (currentDate , -1 );
9891
+
9892
+ // close registration, submission and review phases
9866
9893
com .topcoder .project .phases .Phase submissionPhase = null ;
9867
9894
com .topcoder .project .phases .Phase reviewPhase = null ;
9868
9895
for (com .topcoder .project .phases .Phase phase : phases ) {
9869
9896
if (PROJECT_SUBMISSION_PHASE_NAME .equals (phase .getPhaseType ().getName ())) {
9870
9897
if (phaseNeedToUpdate && !phaseHasClosed ) {
9871
9898
// submission is scheduled
9872
- phase .setActualStartDate (new Date () );
9873
- phase .setActualEndDate (new Date () );
9899
+ phase .setActualStartDate (currentDate );
9900
+ phase .setActualEndDate (currentDate );
9874
9901
} else if (!phaseNeedToUpdate ) {
9875
9902
// phase already open
9876
- phase .setActualEndDate (new Date () );
9903
+ phase .setActualEndDate (currentDate );
9877
9904
}
9878
9905
phase .setPhaseStatus (PhaseStatus .CLOSED );
9879
9906
submissionPhase = phase ;
9880
9907
} else if (PROJECT_REVIEW_PHASE_NAME .equals (phase .getPhaseType ().getName ())
9881
9908
|| PROJECT_ITERATIVE_REVIEW_PHASE_NAME .equals (phase .getPhaseType ().getName ())) {
9882
9909
if (phase .getPhaseStatus ().getId () == PhaseStatus .SCHEDULED .getId ()) {
9883
- phase .setActualStartDate (new Date () );
9910
+ phase .setActualStartDate (currentDate );
9884
9911
phase .setScheduledEndDate (null );
9885
9912
phase .setScheduledStartDate (phase .calcStartDate ());
9886
9913
phase .setScheduledEndDate (phase .calcEndDate ());
@@ -9890,6 +9917,21 @@ public void closeSoftwareContest(TCSubject tcSubject, long projectId, long winne
9890
9917
// skiping closed iterative review
9891
9918
reviewPhase = phase ;
9892
9919
}
9920
+ } else if (PROJECT_REGISTRATION_PHASE_NAME .equals (phase .getPhaseType ().getName ())) {
9921
+ if (phase .getActualStartDate () != null ) {
9922
+ // The registration phase is already started, we only need to set the end date if not set already
9923
+ // The actual end date is set to one minute earlier than the submission phase
9924
+ // This will ensure that the phases are shown in the correct order in Online Review
9925
+ if (phase .getActualEndDate () == null ) {
9926
+ phase .setActualEndDate (oneMinuteEarlier );
9927
+ }
9928
+ } else {
9929
+ // The registration phase is not opened yet (start date is in the future)
9930
+ phase .setActualStartDate (oneMinuteEarlier );
9931
+ phase .setActualEndDate (oneMinuteEarlier );
9932
+ }
9933
+ // Set the registration status to closed
9934
+ phase .setPhaseStatus (PhaseStatus .CLOSED );
9893
9935
}
9894
9936
}
9895
9937
projectPhases .setPhases (new HashSet <com .topcoder .project .phases .Phase >(Arrays .asList (phases )));
0 commit comments