Allow supervisors to request improvements from final seminar opponents #78
@ -156,7 +156,6 @@ import se.su.dsv.scipro.report.GradingReportTemplateRepoImpl;
|
||||
import se.su.dsv.scipro.report.OppositionReportRepo;
|
||||
import se.su.dsv.scipro.report.OppositionReportService;
|
||||
import se.su.dsv.scipro.report.OppositionReportServiceImpl;
|
||||
import se.su.dsv.scipro.report.ReportServiceImpl;
|
||||
import se.su.dsv.scipro.report.SupervisorGradingReportRepository;
|
||||
import se.su.dsv.scipro.reviewing.DecisionRepository;
|
||||
import se.su.dsv.scipro.reviewing.FinalSeminarApprovalService;
|
||||
@ -875,11 +874,6 @@ public class CoreConfig {
|
||||
);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ReportServiceImpl reportService(Provider<EntityManager> em, FileService fileService) {
|
||||
return new ReportServiceImpl(em, fileService);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ResearchAreaServiceImpl researchAreaService(Provider<EntityManager> em) {
|
||||
return new ResearchAreaServiceImpl(em);
|
||||
|
@ -1,5 +1,7 @@
|
||||
package se.su.dsv.scipro.report;
|
||||
|
||||
import java.util.Optional;
|
||||
import se.su.dsv.scipro.file.FileUpload;
|
||||
import se.su.dsv.scipro.finalseminar.FinalSeminarOpposition;
|
||||
|
||||
public interface OppositionReportService {
|
||||
@ -7,4 +9,10 @@ public interface OppositionReportService {
|
||||
void save(OppositionReport oppositionReport);
|
||||
void deleteOppositionReport(FinalSeminarOpposition finalSeminarOpposition);
|
||||
void deleteOpponentReport(FinalSeminarOpposition modelObject);
|
||||
|
||||
AttachmentReport submit(OppositionReport report);
|
||||
|
||||
void save(OppositionReport report, Optional<FileUpload> fileUpload);
|
||||
|
||||
void deleteAttachment(OppositionReport report);
|
||||
}
|
||||
|
@ -3,8 +3,10 @@ package se.su.dsv.scipro.report;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.inject.Named;
|
||||
import jakarta.transaction.Transactional;
|
||||
import java.util.Optional;
|
||||
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.FinalSeminarOpposition;
|
||||
import se.su.dsv.scipro.finalseminar.FinalSeminarOppositionRepo;
|
||||
|
||||
@ -74,4 +76,34 @@ public class OppositionReportServiceImpl implements OppositionReportService {
|
||||
finalSeminarOppositionRepo.save(finalSeminarOpposition);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public OppositionReport submit(OppositionReport report) {
|
||||
report.submit();
|
||||
return oppositionReportRepo.save(report);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void save(OppositionReport report, Optional<FileUpload> fileUpload) {
|
||||
storeReportFile(report, fileUpload);
|
||||
save(report);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void deleteAttachment(OppositionReport report) {
|
||||
FileReference attachment = report.getAttachment();
|
||||
report.setAttachment(null);
|
||||
fileService.delete(attachment);
|
||||
oppositionReportRepo.save(report);
|
||||
}
|
||||
|
||||
private void storeReportFile(OppositionReport report, Optional<FileUpload> fileUpload) {
|
||||
if (fileUpload.isPresent()) {
|
||||
final FileReference reference = fileService.storeFile(fileUpload.get());
|
||||
report.setAttachment(reference);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +0,0 @@
|
||||
package se.su.dsv.scipro.report;
|
||||
|
||||
import java.util.Optional;
|
||||
import se.su.dsv.scipro.file.FileUpload;
|
||||
import se.su.dsv.scipro.system.GenericService;
|
||||
|
||||
public interface ReportService extends GenericService<Report, Long> {
|
||||
AttachmentReport submit(AttachmentReport report);
|
||||
|
||||
void save(AttachmentReport report, Optional<FileUpload> fileUpload);
|
||||
|
||||
void deleteAttachment(AttachmentReport report);
|
||||
}
|
@ -1,52 +0,0 @@
|
||||
package se.su.dsv.scipro.report;
|
||||
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.inject.Provider;
|
||||
import jakarta.persistence.EntityManager;
|
||||
import jakarta.transaction.Transactional;
|
||||
import java.util.Optional;
|
||||
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.system.AbstractServiceImpl;
|
||||
|
||||
public class ReportServiceImpl extends AbstractServiceImpl<Report, Long> implements ReportService {
|
||||
|
||||
private final FileService fileDescriptionService;
|
||||
|
||||
@Inject
|
||||
public ReportServiceImpl(Provider<EntityManager> em, final FileService fileDescriptionService) {
|
||||
super(em, Report.class, QReport.report);
|
||||
this.fileDescriptionService = fileDescriptionService;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public AttachmentReport submit(AttachmentReport report) {
|
||||
report.submit();
|
||||
return save(report);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void save(AttachmentReport report, Optional<FileUpload> fileUpload) {
|
||||
storeReportFile(report, fileUpload);
|
||||
save(report);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void deleteAttachment(AttachmentReport report) {
|
||||
FileReference attachment = report.getAttachment();
|
||||
report.setAttachment(null);
|
||||
fileDescriptionService.delete(attachment);
|
||||
save(report);
|
||||
}
|
||||
|
||||
private void storeReportFile(AttachmentReport report, Optional<FileUpload> fileUpload) {
|
||||
if (fileUpload.isPresent()) {
|
||||
final FileReference reference = fileDescriptionService.storeFile(fileUpload.get());
|
||||
report.setAttachment(reference);
|
||||
}
|
||||
}
|
||||
}
|
@ -83,7 +83,7 @@ public class OppositionReportPage extends AbstractProjectDetailsPage implements
|
||||
);
|
||||
|
||||
add(
|
||||
new FillOutReportPanel<>(FILL_OUT_REPORT, report) {
|
||||
new FillOutReportPanel(FILL_OUT_REPORT, report) {
|
||||
{
|
||||
TextArea<String> textArea = new TextArea<>(
|
||||
THESIS_SUMMARY,
|
||||
|
@ -25,12 +25,12 @@ import se.su.dsv.scipro.files.WicketFileUpload;
|
||||
import se.su.dsv.scipro.report.AttachmentReport;
|
||||
import se.su.dsv.scipro.report.Criterion;
|
||||
import se.su.dsv.scipro.report.OppositionReport;
|
||||
import se.su.dsv.scipro.report.ReportService;
|
||||
import se.su.dsv.scipro.report.OppositionReportService;
|
||||
import se.su.dsv.scipro.repository.panels.ViewAttachmentPanel;
|
||||
import se.su.dsv.scipro.system.Language;
|
||||
import se.su.dsv.scipro.util.JavascriptEventConfirmation;
|
||||
|
||||
public class FillOutReportPanel<T extends OppositionReport> extends Border {
|
||||
public class FillOutReportPanel extends Border {
|
||||
|
||||
public static final String FORM = "form";
|
||||
public static final String GRADING_CRITERIA = "criteria";
|
||||
@ -42,20 +42,20 @@ public class FillOutReportPanel<T extends OppositionReport> extends Border {
|
||||
public static final String FEEDBACK_PANEL = "feedbackPanel";
|
||||
|
||||
@Inject
|
||||
private ReportService reportService;
|
||||
private OppositionReportService reportService;
|
||||
|
||||
public FillOutReportPanel(String id, final IModel<T> model) {
|
||||
public FillOutReportPanel(String id, final IModel<OppositionReport> model) {
|
||||
super(id, model);
|
||||
ReportForm form = new ReportForm(FORM, model);
|
||||
addToBorder(new ScrollingSaveButtonPanel(SAVE, form));
|
||||
addToBorder(form);
|
||||
}
|
||||
|
||||
private class ReportForm extends StatelessForm<T> {
|
||||
private class ReportForm extends StatelessForm<OppositionReport> {
|
||||
|
||||
private final FileUploadField attachment;
|
||||
|
||||
public ReportForm(String id, final IModel<T> model) {
|
||||
public ReportForm(String id, final IModel<OppositionReport> model) {
|
||||
super(id, model);
|
||||
add(new ComponentFeedbackPanel(FEEDBACK_PANEL, this));
|
||||
IModel<Language> language = model.map(OppositionReport::getLanguage);
|
||||
@ -139,9 +139,9 @@ public class FillOutReportPanel<T extends OppositionReport> extends Border {
|
||||
}
|
||||
}
|
||||
|
||||
private class DeleteAttachmentLink extends Link<T> {
|
||||
private class DeleteAttachmentLink extends Link<OppositionReport> {
|
||||
|
||||
public DeleteAttachmentLink(String id, IModel<T> model) {
|
||||
public DeleteAttachmentLink(String id, IModel<OppositionReport> model) {
|
||||
super(id, model);
|
||||
add(new JavascriptEventConfirmation("click", new ResourceModel("delete.attachment")));
|
||||
}
|
||||
|
@ -17,7 +17,6 @@ import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.ArgumentMatchers;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.Mockito;
|
||||
import se.su.dsv.scipro.SciProTest;
|
||||
import se.su.dsv.scipro.file.FileDescription;
|
||||
@ -28,7 +27,6 @@ import se.su.dsv.scipro.project.pages.ProjectDetailsPage;
|
||||
import se.su.dsv.scipro.report.GradingCriterionPointTemplate;
|
||||
import se.su.dsv.scipro.report.GradingReportTemplate;
|
||||
import se.su.dsv.scipro.report.OppositionReport;
|
||||
import se.su.dsv.scipro.report.ReportService;
|
||||
import se.su.dsv.scipro.system.DegreeType;
|
||||
import se.su.dsv.scipro.system.ProjectType;
|
||||
import se.su.dsv.scipro.system.User;
|
||||
@ -41,9 +39,6 @@ public class OppositionReportPageTest extends SciProTest {
|
||||
public static final String CRITERION_DESCRIPTION = "For 1 point: Be nice to your supervisor";
|
||||
public static final String CRITERTION_TITLE = "U1 Sammanfattning";
|
||||
|
||||
@Mock
|
||||
private ReportService reportService;
|
||||
|
||||
private FinalSeminarOpposition finalSeminarOpposition;
|
||||
private User user;
|
||||
private ProjectType bachelor;
|
||||
@ -139,7 +134,7 @@ public class OppositionReportPageTest extends SciProTest {
|
||||
formTester.submit();
|
||||
|
||||
ArgumentCaptor<OppositionReport> captor = ArgumentCaptor.forClass(OppositionReport.class);
|
||||
Mockito.verify(reportService).save(captor.capture(), eq(Optional.empty()));
|
||||
Mockito.verify(oppositionReportService).save(captor.capture(), eq(Optional.empty()));
|
||||
|
||||
Assertions.assertEquals(summary, captor.getValue().getThesisSummary());
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ public class FillOutReportPanelTest extends SciProTest {
|
||||
private FillOutReportPanel panel;
|
||||
|
||||
@Mock
|
||||
private ReportService reportService;
|
||||
private OppositionReportService reportService;
|
||||
|
||||
@BeforeEach
|
||||
public void setUp() throws Exception {
|
||||
@ -197,6 +197,6 @@ public class FillOutReportPanelTest extends SciProTest {
|
||||
}
|
||||
|
||||
private void startPanel() {
|
||||
panel = tester.startComponentInPage(new FillOutReportPanel<>("id", Model.of(oppositionReport)));
|
||||
panel = tester.startComponentInPage(new FillOutReportPanel("id", Model.of(oppositionReport)));
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user