use of site.model.Submission in project jprime by bgjug.
the class SubmissionController method exportSubmissionsToCSV.
@RequestMapping(value = "/exportCSV", method = RequestMethod.GET, produces = PRODUCES_TYPE)
@ResponseBody
public void exportSubmissionsToCSV(HttpServletResponse response) {
List<Submission> findAllSubmitedSubmissionsForCurrentBranch = adminFacade.findAllSubmitedSubmissionsForCurrentBranch();
File submissionsCSVFile;
try {
submissionsCSVFile = csvFacade.exportSubmissions(findAllSubmitedSubmissionsForCurrentBranch);
} catch (IOException e) {
logger.error("Could not create submissions file", e);
return;
}
try (InputStream inputStream = new FileInputStream(submissionsCSVFile)) {
response.setContentType(PRODUCES_TYPE);
response.setHeader("Content-Disposition", "attachment; filename=" + submissionsCSVFile.getName());
response.setHeader("Content-Length", String.valueOf(submissionsCSVFile.length()));
FileCopyUtils.copy(inputStream, response.getOutputStream());
if (!submissionsCSVFile.delete()) {
logger.warn("Submission file: " + submissionsCSVFile.getAbsolutePath() + " cannot be deleted");
}
} catch (IOException e) {
logger.error("Could not download file: " + submissionsCSVFile.getAbsolutePath(), e);
}
}
use of site.model.Submission in project jprime by bgjug.
the class SubmissionController method reject.
@RequestMapping(value = "/reject/{submissionId}", method = RequestMethod.GET)
public String reject(@PathVariable("submissionId") Long submissionId) {
Submission submission = adminFacade.findOneSubmission(submissionId);
adminFacade.rejectSubmission(submission);
try {
sendEmails(submission, "/rejectSubmission.html");
} catch (Exception e) {
logger.error("Could not send rejection email", e);
}
return REDIRECT + "/admin/submission/view";
}
use of site.model.Submission in project jprime by bgjug.
the class CSVService method writeSubmissions.
private void writeSubmissions(List<Submission> submissions, ICsvMapWriter mapWriter) throws IOException {
CellProcessor[] processors = new CellProcessor[] { null, null, null, null, null, null, null, null };
Map<String, Object> submissionRow;
mapWriter.writeHeader(submissionHeader);
for (Submission submission : submissions) {
submissionRow = new HashMap<String, Object>();
submissionRow.put(submissionHeader[0], submission.getTitle());
submissionRow.put(submissionHeader[1], submission.getDescription());
submissionRow.put(submissionHeader[2], submission.getLevel());
submissionRow.put(submissionHeader[3], submission.getType());
submissionRow.put(submissionHeader[4], submission.getSpeaker().getFirstName());
submissionRow.put(submissionHeader[5], submission.getSpeaker().getBio());
if (submission.getCoSpeaker() != null) {
submissionRow.put(submissionHeader[6], submission.getCoSpeaker().getFirstName());
submissionRow.put(submissionHeader[7], submission.getCoSpeaker().getBio());
}
mapWriter.write(submissionRow, submissionHeader, processors);
}
}
use of site.model.Submission in project jprime by bgjug.
the class CfpControllerTest method shouldSubmitSessionWithSingleSpeaker.
@Test
@Ignore("ignored since adding captcha, has to be updated")
public void shouldSubmitSessionWithSingleSpeaker() throws Exception {
mockMvc.perform(fileUpload("/cfp").file(new MockMultipartFile("speakerImage", new byte[] {})).file(new MockMultipartFile("coSpeakerImage", new byte[] {})).param("title", "JBoss Forge").param("description", "This is the best tool").param("level", SessionLevel.BEGINNER.toString().toUpperCase()).param("speaker.firstName", "Ivan").param("speaker.lastName", "Ivanov").param("speaker.email", "ivan@jprime.io").param("speaker.twitter", "@ivan_stefanov").param("speaker.bio", "Ordinary decent nerd")).andExpect(status().isFound()).andExpect(view().name("redirect:/"));
final List<Submission> allSubmissions = submissionRepository.findAll();
assertThat(allSubmissions.size(), is(1));
Submission submission = allSubmissions.get(0);
assertThat(submission.getTitle(), is("JBoss Forge"));
assertThat(submission.getStatus(), is(SubmissionStatus.SUBMITTED));
assertThat(submission.getSpeaker().getEmail(), is("ivan@jprime.io"));
assertThat(submission.getCoSpeaker(), is(nullValue()));
assertThat(mailer.recipientAddresses.size(), is(2));
assertThat(mailer.recipientAddresses, contains("ivan@jprime.io", "conference@jprime.io"));
}
Aggregations