Search in sources :

Example 6 with Submission

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);
    }
}
Also used : Submission(site.model.Submission) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) IOException(java.io.IOException) File(java.io.File) MultipartFile(org.springframework.web.multipart.MultipartFile) FileInputStream(java.io.FileInputStream) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 7 with Submission

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";
}
Also used : Submission(site.model.Submission) URISyntaxException(java.net.URISyntaxException) MessagingException(javax.mail.MessagingException) IOException(java.io.IOException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 8 with Submission

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);
    }
}
Also used : Submission(site.model.Submission) CellProcessor(org.supercsv.cellprocessor.ift.CellProcessor)

Example 9 with Submission

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"));
}
Also used : MockMultipartFile(org.springframework.mock.web.MockMultipartFile) Submission(site.model.Submission) Ignore(org.junit.Ignore) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

Submission (site.model.Submission)9 IOException (java.io.IOException)3 Test (org.junit.Test)3 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)3 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)3 URISyntaxException (java.net.URISyntaxException)2 MessagingException (javax.mail.MessagingException)2 Before (org.junit.Before)2 Ignore (org.junit.Ignore)2 MockMultipartFile (org.springframework.mock.web.MockMultipartFile)2 Session (site.model.Session)2 Speaker (site.model.Speaker)2 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 InputStream (java.io.InputStream)1 DateTime (org.joda.time.DateTime)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1 MultipartFile (org.springframework.web.multipart.MultipartFile)1 CellProcessor (org.supercsv.cellprocessor.ift.CellProcessor)1 VenueHall (site.model.VenueHall)1