Skip to content

Commit 367fc9c

Browse files
Change isSurvey from Boolean to boolean.
Requires db changes: update runs set isSurvey=false where isSurvey is null; alter table runs add column isSurvey bit(1) not null default 0;
1 parent 1a73072 commit 367fc9c

10 files changed

Lines changed: 43 additions & 37 deletions

File tree

src/main/java/org/wise/portal/domain/run/Run.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public interface Run extends Persistable {
120120

121121
/**
122122
* Returns the period with periodName that is associated with this run
123-
*
123+
*
124124
* @param periodName
125125
* @return Group the period with the periodName that is associated with this run
126126
* @throws <code>PeriodNotFoundException</code>
@@ -214,41 +214,41 @@ public interface Run extends Persistable {
214214

215215
/**
216216
* Sets whether or not student asset uploading is enabled for this run.
217-
*
217+
*
218218
* @return
219219
*/
220220
void setStudentAssetUploaderEnabled(boolean isStudentAssetUploaderEnabled);
221221

222222
/**
223223
* Returns whether or not student asset uploading is enabled for this run.
224-
*
224+
*
225225
* @return
226226
*/
227227
boolean isStudentAssetUploaderEnabled();
228228

229229
/**
230230
* Sets whether or not idea manager is enabled for this run.
231-
*
231+
*
232232
* @return
233233
*/
234234
void setIdeaManagerEnabled(boolean isIdeaManagerEnabled);
235235

236236
/**
237237
* Returns whether or not idea manager is enabled for this run.
238-
*
238+
*
239239
* @return
240240
*/
241241
boolean isIdeaManagerEnabled();
242242

243243
/**
244-
* @return Whether or not the run a survey
244+
* @return Whether or not the run a survey
245245
*/
246-
Boolean getIsSurvey();
246+
boolean isSurvey();
247247

248248
/**
249-
* @param isSurvey
249+
* @param isSurvey
250250
*/
251-
void setIsSurvey(Boolean isSurvey);
251+
void setIsSurvey(boolean isSurvey);
252252

253253
/**
254254
* @return <code>Integer</code> maxWorkgroupSize
@@ -351,7 +351,7 @@ public interface Run extends Persistable {
351351

352352
/**
353353
* sets student attendance for this run
354-
*
354+
*
355355
* @param studentAttendance
356356
*/
357357
void setStudentAttendance(List<StudentAttendance> studentAttendance);
@@ -363,29 +363,29 @@ public interface Run extends Persistable {
363363

364364
/**
365365
* Gets private notes for this run
366-
*
366+
*
367367
* @return String private notes for this run
368368
*/
369369
String getPrivateNotes();
370370

371371
/**
372372
* Sets private notes for this run
373-
*
373+
*
374374
* @param privateNotes
375375
* private notes for this run
376376
*/
377377
void setPrivateNotes(String privateNotes);
378378

379379
/**
380380
* Gets survey for this run
381-
*
381+
*
382382
* @return String survey for this run
383383
*/
384384
String getSurvey();
385385

386386
/**
387387
* Sets survey for this run
388-
*
388+
*
389389
* @return String survey for this run
390390
*/
391391
void setSurvey(String survey);

src/main/java/org/wise/portal/domain/run/impl/RunImpl.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -203,9 +203,7 @@ public class RunImpl implements Run {
203203
private String info; // other info pertaining to the run
204204

205205
@Column(name = COLUMN_NAME_IS_SURVEY)
206-
@Getter
207-
@Setter
208-
private Boolean isSurvey;
206+
private boolean isSurvey;
209207

210208
@Column(name = COLUMN_NAME_MAX_WORKGROUP_SIZE, nullable = true)
211209
@Getter
@@ -435,7 +433,7 @@ public static class UserAlphabeticalComparator implements Comparator<User> {
435433

436434
/**
437435
* Compares the user names of two User objects
438-
*
436+
*
439437
* @param user1
440438
* a user object
441439
* @param user2
@@ -488,4 +486,12 @@ public boolean isLockedAfterEndDate() {
488486
public void setLockedAfterEndDate(boolean isLockedAfterEndDate) {
489487
this.isLockedAfterEndDate = isLockedAfterEndDate;
490488
}
489+
490+
public boolean isSurvey() {
491+
return isSurvey;
492+
}
493+
494+
public void setIsSurvey(boolean isSurvey) {
495+
this.isSurvey = isSurvey;
496+
}
491497
}

src/main/java/org/wise/portal/domain/run/impl/RunParameters.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import org.wise.portal.domain.project.Project;
3131
import org.wise.portal.domain.user.User;
3232

33-
import java.io.Serializable;
3433
import java.util.*;
3534

3635
/**
@@ -70,7 +69,7 @@ public class RunParameters implements Serializable {
7069

7170
private Boolean isLockedAfterEndDate = false;
7271

73-
private Boolean isSurvey = false;
72+
private boolean isSurvey = false;
7473

7574
public String printAllPeriods() {
7675
String allPeriods = null;

src/main/java/org/wise/portal/presentation/web/controllers/run/RunInfoAPIController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ private HashMap<String, Object> getRunInfo(Run run) {
6262
info.put("teacherFirstName", owner.getUserDetails().getFirstname());
6363
info.put("teacherLastName", owner.getUserDetails().getLastname());
6464
info.put("wiseVersion", run.getProject().getWiseVersion());
65-
info.put("isSurvey", run.getIsSurvey());
65+
info.put("isSurvey", run.isSurvey());
6666
return info;
6767
}
6868

src/main/java/org/wise/portal/presentation/web/controllers/survey/SurveyAPIController.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public void launchSurveyRun(@PathVariable String code, HttpServletResponse respo
6565

6666
Projectcode projectCode = new Projectcode(code);
6767
Run run = runService.retrieveRunByRuncode(projectCode.getRuncode());
68-
if (run.getIsSurvey()) {
68+
if (run.isSurvey()) {
6969
handleSurveyLaunched(response, request, run, projectCode);
7070
} else {
7171
sendRedirect(response, "/");
@@ -76,9 +76,9 @@ private void handleSurveyLaunched(HttpServletResponse response, HttpServletReque
7676
Run run, Projectcode projectCode) throws AuthorityNotFoundException, IOException,
7777
DuplicateUsernameException, ObjectNotFoundException, PeriodNotFoundException,
7878
StudentUserAlreadyAssociatedWithRunException, RunHasEndedException {
79-
79+
8080
Object principal = getSecurityContextHolderPrincipal();
81-
if (principal instanceof StudentUserDetails
81+
if (principal instanceof StudentUserDetails
8282
&& isStudentAssociatedWithRun(run, (StudentUserDetails) principal)) {
8383
sendRedirect(response, "/student/unit/" + run.getId());
8484
return;

src/main/java/org/wise/portal/presentation/web/controllers/teacher/TeacherAPIController.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ private List<Integer> getSharedOwnerPermissionsList(Run run, User user) {
255255
@PostMapping("/run/create")
256256
HashMap<String, Object> createRun(Authentication auth, HttpServletRequest request,
257257
@RequestParam("projectId") Long projectId, @RequestParam("periods") String periods,
258-
@RequestParam("isSurvey") Boolean isSurvey,
258+
@RequestParam boolean isSurvey,
259259
@RequestParam("maxStudentsPerTeam") Integer maxStudentsPerTeam,
260260
@RequestParam("startDate") Long startDate,
261261
@RequestParam(value = "endDate", required = false) Long endDate,
@@ -264,8 +264,8 @@ HashMap<String, Object> createRun(Authentication auth, HttpServletRequest reques
264264
User user = userService.retrieveUserByUsername(auth.getName());
265265
Locale locale = request.getLocale();
266266
Set<String> periodNames = createPeriodNamesSet(periods);
267-
Run run = runService.createRun(projectId, user, periodNames, isSurvey, maxStudentsPerTeam, startDate,
268-
endDate, isLockedAfterEndDate, locale);
267+
Run run = runService.createRun(projectId, user, periodNames, isSurvey, maxStudentsPerTeam,
268+
startDate, endDate, isLockedAfterEndDate, locale);
269269
return getRunMap(user, run);
270270
}
271271

src/main/java/org/wise/portal/presentation/web/controllers/user/UserAPIController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ protected HashMap<String, Object> getRunMap(User user, Run run) {
261261
HashMap<String, Object> map = new HashMap<String, Object>();
262262
map.put("id", run.getId());
263263
map.put("name", run.getName());
264-
map.put("isSurvey", run.getIsSurvey());
264+
map.put("isSurvey", run.isSurvey());
265265
map.put("maxStudentsPerTeam", run.getMaxWorkgroupSize());
266266
map.put("runCode", run.getRuncode());
267267
map.put("startTime", run.getStartTimeMilliseconds());

src/main/java/org/wise/portal/service/run/RunService.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,9 @@ public interface RunService {
5858
*/
5959
Run createRun(RunParameters runParameters) throws ObjectNotFoundException;
6060

61-
Run createRun(Long projectId, User user, Set<String> periodNames, Boolean isSurvey, Integer maxStudentsPerTeam,
62-
Long startDate, Long endDate, Boolean isLockedAfterEndDate, Locale locale) throws Exception;
61+
Run createRun(Long projectId, User user, Set<String> periodNames, boolean isSurvey,
62+
Integer maxStudentsPerTeam, Long startDate, Long endDate, Boolean isLockedAfterEndDate,
63+
Locale locale) throws Exception;
6364

6465
/**
6566
* Ends this run. The side effect is that the run's endtime gets set. A Run that has ended is no

src/main/java/org/wise/portal/service/run/impl/RunServiceImpl.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ public Run createRun(RunParameters runParameters) {
199199
run.setStarttime(runParameters.getStartTime());
200200
run.setRuncode(generateUniqueRunCode(runParameters.getLocale()));
201201
run.setOwner(runParameters.getOwner());
202-
run.setIsSurvey(runParameters.getIsSurvey());
202+
run.setIsSurvey(runParameters.isSurvey());
203203
run.setMaxWorkgroupSize(runParameters.getMaxWorkgroupSize());
204204
run.setProject(project);
205205
run.setName("" + runParameters.getProject().getName());
@@ -240,7 +240,7 @@ public Run createRun(RunParameters runParameters) {
240240
}
241241

242242
@Transactional()
243-
public Run createRun(Long projectId, User user, Set<String> periodNames, Boolean isSurvey,
243+
public Run createRun(Long projectId, User user, Set<String> periodNames, boolean isSurvey,
244244
Integer maxStudentsPerTeam, Long startDate, Long endDate, Boolean isLockedAfterEndDate,
245245
Locale locale) throws Exception {
246246
Project project = projectService.copyProject(projectId, user);
@@ -252,17 +252,17 @@ public Run createRun(Long projectId, User user, Set<String> periodNames, Boolean
252252
return run;
253253
}
254254

255-
public RunParameters createRunParameters(Project project, User user, Set<String> periodNames, Boolean isSurvey,
256-
Integer maxStudentsPerTeam, Long startDate, Long endDate, Boolean isLockedAfterEndDate,
257-
Locale locale) {
255+
public RunParameters createRunParameters(Project project, User user, Set<String> periodNames,
256+
boolean isSurvey, Integer maxStudentsPerTeam, Long startDate, Long endDate,
257+
Boolean isLockedAfterEndDate, Locale locale) {
258258
RunParameters runParameters = new RunParameters();
259259
runParameters.setOwner(user);
260260
runParameters.setName(project.getName());
261261
runParameters.setProject(project);
262262
runParameters.setLocale(locale);
263263
runParameters.setPostLevel(5);
264264
runParameters.setPeriodNames(periodNames);
265-
runParameters.setIsSurvey(isSurvey);
265+
runParameters.setSurvey(isSurvey);
266266
runParameters.setMaxWorkgroupSize(maxStudentsPerTeam);
267267
runParameters.setStartTime(new Date(startDate));
268268
if (endDate == null || endDate <= startDate) {

src/main/resources/wise_db_init.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ create table runs (
330330
end_time datetime,
331331
extras mediumtext,
332332
info varchar(255),
333-
isSurvey bit,
333+
isSurvey bit not null default 0,
334334
lastRun datetime,
335335
loggingLevel integer,
336336
maxWorkgroupSize integer,

0 commit comments

Comments
 (0)