Deadline visible in "Rough draft approval" page #106
@ -4,11 +4,15 @@ import jakarta.inject.Inject;
|
|||||||
import jakarta.inject.Provider;
|
import jakarta.inject.Provider;
|
||||||
import jakarta.persistence.EntityManager;
|
import jakarta.persistence.EntityManager;
|
||||||
import jakarta.transaction.Transactional;
|
import jakarta.transaction.Transactional;
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.InputStream;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.LocalTime;
|
import java.time.LocalTime;
|
||||||
import java.time.Month;
|
import java.time.Month;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.function.Function;
|
||||||
import se.su.dsv.scipro.checklist.ChecklistCategory;
|
import se.su.dsv.scipro.checklist.ChecklistCategory;
|
||||||
|
import se.su.dsv.scipro.file.FileUpload;
|
||||||
import se.su.dsv.scipro.match.ApplicationPeriod;
|
import se.su.dsv.scipro.match.ApplicationPeriod;
|
||||||
import se.su.dsv.scipro.match.Keyword;
|
import se.su.dsv.scipro.match.Keyword;
|
||||||
import se.su.dsv.scipro.milestones.dataobjects.MilestoneActivityTemplate;
|
import se.su.dsv.scipro.milestones.dataobjects.MilestoneActivityTemplate;
|
||||||
@ -20,6 +24,8 @@ import se.su.dsv.scipro.project.Project;
|
|||||||
import se.su.dsv.scipro.report.AbstractGradingCriterion;
|
import se.su.dsv.scipro.report.AbstractGradingCriterion;
|
||||||
import se.su.dsv.scipro.report.GradingCriterionPointTemplate;
|
import se.su.dsv.scipro.report.GradingCriterionPointTemplate;
|
||||||
import se.su.dsv.scipro.report.GradingReportTemplate;
|
import se.su.dsv.scipro.report.GradingReportTemplate;
|
||||||
|
import se.su.dsv.scipro.reviewing.ReviewerAssignmentService;
|
||||||
|
import se.su.dsv.scipro.reviewing.RoughDraftApprovalService;
|
||||||
import se.su.dsv.scipro.security.auth.roles.Roles;
|
import se.su.dsv.scipro.security.auth.roles.Roles;
|
||||||
import se.su.dsv.scipro.system.*;
|
import se.su.dsv.scipro.system.*;
|
||||||
|
|
||||||
@ -45,6 +51,12 @@ public class DataInitializer implements Lifecycle {
|
|||||||
@Inject
|
@Inject
|
||||||
private Provider<EntityManager> em;
|
private Provider<EntityManager> em;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private RoughDraftApprovalService roughDraftApprovalService;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private ReviewerAssignmentService reviewerAssignmentService;
|
||||||
|
|
||||||
private static final String MAIL = "@example.com";
|
private static final String MAIL = "@example.com";
|
||||||
|
|
||||||
private static final String ADMIN = "admin";
|
private static final String ADMIN = "admin";
|
||||||
@ -75,6 +87,7 @@ public class DataInitializer implements Lifecycle {
|
|||||||
private ResearchArea researchArea2;
|
private ResearchArea researchArea2;
|
||||||
private ProjectType masterClass;
|
private ProjectType masterClass;
|
||||||
private ProjectType magisterClass;
|
private ProjectType magisterClass;
|
||||||
|
private Project project2;
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
@Override
|
@Override
|
||||||
@ -89,12 +102,23 @@ public class DataInitializer implements Lifecycle {
|
|||||||
createMilestonesIfNotDone();
|
createMilestonesIfNotDone();
|
||||||
createUsers();
|
createUsers();
|
||||||
createProjects();
|
createProjects();
|
||||||
|
createRoughDraftApproval();
|
||||||
}
|
}
|
||||||
if (profile.getCurrentProfile() == Profiles.DEV && noAdminUser()) {
|
if (profile.getCurrentProfile() == Profiles.DEV && noAdminUser()) {
|
||||||
createAdmin();
|
createAdmin();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void createRoughDraftApproval() {
|
||||||
|
roughDraftApprovalService.requestApproval(
|
||||||
|
project2,
|
||||||
|
new SimpleTextFile(project2.getHeadSupervisor(), "thesis.txt", "text/plain"),
|
||||||
|
"Please approve"
|
||||||
|
);
|
||||||
|
|
||||||
|
reviewerAssignmentService.assignReviewer(project2, eric_employee);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void stop() {}
|
public void stop() {}
|
||||||
|
|
||||||
@ -146,10 +170,10 @@ public class DataInitializer implements Lifecycle {
|
|||||||
|
|
||||||
private void createProjects() {
|
private void createProjects() {
|
||||||
createProject(PROJECT_1, eric_employee, sture_student, stina_student, eve_employee);
|
createProject(PROJECT_1, eric_employee, sture_student, stina_student, eve_employee);
|
||||||
createProject(PROJECT_2, eve_employee, sid_student, simon_student, eric_employee);
|
project2 = createProject(PROJECT_2, eve_employee, sid_student, simon_student, eric_employee);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createProject(String title, User headSupervisor, User student1, User student2, User reviewer) {
|
private Project createProject(String title, User headSupervisor, User student1, User student2, User reviewer) {
|
||||||
Project project = Project.builder()
|
Project project = Project.builder()
|
||||||
.title(title)
|
.title(title)
|
||||||
.projectType(bachelorClass)
|
.projectType(bachelorClass)
|
||||||
@ -160,6 +184,7 @@ public class DataInitializer implements Lifecycle {
|
|||||||
project.addProjectParticipant(student1);
|
project.addProjectParticipant(student1);
|
||||||
project.addReviewer(reviewer);
|
project.addReviewer(reviewer);
|
||||||
save(project);
|
save(project);
|
||||||
|
return project;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createUsers() {
|
private void createUsers() {
|
||||||
@ -1907,4 +1932,42 @@ public class DataInitializer implements Lifecycle {
|
|||||||
em.get().persist(entity);
|
em.get().persist(entity);
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final class SimpleTextFile implements FileUpload {
|
||||||
|
|
||||||
|
private final User uploader;
|
||||||
|
private final String fileName;
|
||||||
|
private final String content;
|
||||||
|
|
||||||
|
private SimpleTextFile(User uploader, String fileName, String content) {
|
||||||
|
this.uploader = uploader;
|
||||||
|
this.fileName = fileName;
|
||||||
|
this.content = content;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getFileName() {
|
||||||
|
return fileName;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getContentType() {
|
||||||
|
return "text/plain";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public User getUploader() {
|
||||||
|
return uploader;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getSize() {
|
||||||
|
return content.length();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <T> T handleData(Function<InputStream, T> handler) {
|
||||||
|
return handler.apply(new ByteArrayInputStream(content.getBytes()));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user