WIP: Allow supervisors to request improvements from final seminar opponents #78
@ -4,12 +4,18 @@ import jakarta.inject.Inject;
|
||||
import jakarta.inject.Provider;
|
||||
import jakarta.persistence.EntityManager;
|
||||
import jakarta.transaction.Transactional;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalTime;
|
||||
import java.time.Month;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import se.su.dsv.scipro.checklist.ChecklistCategory;
|
||||
import se.su.dsv.scipro.file.FileReference;
|
||||
import se.su.dsv.scipro.file.FileService;
|
||||
import se.su.dsv.scipro.file.FileUpload;
|
||||
import se.su.dsv.scipro.finalseminar.FinalSeminar;
|
||||
import se.su.dsv.scipro.finalseminar.FinalSeminarOpposition;
|
||||
import se.su.dsv.scipro.match.ApplicationPeriod;
|
||||
@ -42,6 +48,9 @@ public class DataInitializer implements Lifecycle {
|
||||
@Inject
|
||||
private MilestoneActivityTemplateService milestoneActivityTemplateService;
|
||||
|
||||
@Inject
|
||||
private FileService fileService;
|
||||
|
||||
@Inject
|
||||
private CurrentProfile profile;
|
||||
|
||||
@ -102,11 +111,17 @@ public class DataInitializer implements Lifecycle {
|
||||
}
|
||||
|
||||
private void createPastFinalSeminar() {
|
||||
FileReference document = fileService.storeFile(
|
||||
new SimpleTextFile(sture_student, "document.txt", "Hello World")
|
||||
);
|
||||
|
||||
FinalSeminar finalSeminar = new FinalSeminar();
|
||||
finalSeminar.setStartDate(Date.from(ZonedDateTime.now().minusDays(1).toInstant()));
|
||||
finalSeminar.setProject(project1);
|
||||
finalSeminar.setRoom("zoom");
|
||||
finalSeminar.setPresentationLanguage(Language.ENGLISH);
|
||||
finalSeminar.setDocument(document);
|
||||
finalSeminar.setDocumentUploadDate(document.getFileDescription().getDateCreated());
|
||||
|
||||
FinalSeminarOpposition opponent = new FinalSeminarOpposition();
|
||||
opponent.setProject(project2);
|
||||
@ -1924,4 +1939,42 @@ public class DataInitializer implements Lifecycle {
|
||||
em.get().persist(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