diff --git a/migrate-add-videos.sql b/migrate-add-videos.sql new file mode 100644 index 00000000..09f7c0ad --- /dev/null +++ b/migrate-add-videos.sql @@ -0,0 +1 @@ +ALTER TABLE USER ADD COLUMN VIDEOS VARCHAR(1024); \ No newline at end of file diff --git a/src/main/java/site/controller/AbstractCfpController.java b/src/main/java/site/controller/AbstractCfpController.java index de525158..4cf22a40 100644 --- a/src/main/java/site/controller/AbstractCfpController.java +++ b/src/main/java/site/controller/AbstractCfpController.java @@ -15,17 +15,19 @@ import site.facade.MailService; import site.facade.ThumbnailService; import site.facade.UserService; +import site.facade.StringSanitizer; import site.model.Branch; import site.model.SessionLevel; +import site.model.SessionType; import site.model.Speaker; import site.model.Submission; -import site.model.SessionType; /** * @author Ivan St. Ivanov */ public class AbstractCfpController { + @Autowired @Qualifier(UserService.NAME) protected UserService userFacade; @@ -75,6 +77,9 @@ private Speaker handleSubmittedSpeaker(Speaker speaker, MultipartFile image) { fixTwitterHandle(speaker); speaker.setBranch(Globals.CURRENT_BRANCH); formatPicture(speaker, image); + if (speaker.getVideos() != null) { + speaker.setVideos(StringSanitizer.formatString(speaker.getVideos())); + } return speaker; } } diff --git a/src/main/java/site/facade/AdminService.java b/src/main/java/site/facade/AdminService.java index 95186580..0202886d 100644 --- a/src/main/java/site/facade/AdminService.java +++ b/src/main/java/site/facade/AdminService.java @@ -1,5 +1,7 @@ package site.facade; +import java.util.List; + import javax.transaction.Transactional; import org.springframework.beans.factory.annotation.Autowired; @@ -9,10 +11,30 @@ import org.springframework.stereotype.Service; import site.config.Globals; -import site.model.*; -import site.repository.*; - -import java.util.List; +import site.model.Article; +import site.model.Branch; +import site.model.Partner; +import site.model.Registrant; +import site.model.Session; +import site.model.Speaker; +import site.model.Sponsor; +import site.model.Submission; +import site.model.SubmissionStatus; +import site.model.Tag; +import site.model.User; +import site.model.VenueHall; +import site.model.Visitor; +import site.repository.ArticleRepository; +import site.repository.PartnerRepository; +import site.repository.RegistrantRepository; +import site.repository.SessionRepository; +import site.repository.SpeakerRepository; +import site.repository.SponsorRepository; +import site.repository.SubmissionRepository; +import site.repository.TagRepository; +import site.repository.UserRepository; +import site.repository.VenueHallRepository; +import site.repository.VisitorRepository; @Service(AdminService.NAME) @Transactional @@ -141,6 +163,11 @@ public void deleteSpeaker(Long id){ } public Speaker saveSpeaker(Speaker speaker){ + if (speaker.getVideos() != null) { + speaker.setVideos(StringSanitizer. + formatString(speaker.getVideos())); + } + return speakerRepository.save(speaker); } diff --git a/src/main/java/site/facade/CSVService.java b/src/main/java/site/facade/CSVService.java index b07a200a..36a9eb73 100644 --- a/src/main/java/site/facade/CSVService.java +++ b/src/main/java/site/facade/CSVService.java @@ -22,7 +22,7 @@ public class CSVService { private static final Logger logger = LogManager.getLogger(CSVService.class); public static final String NAME = "csvFacade"; final String[] submissionHeader = new String[] { "Title", "Abstract", "Session level", "Session type", "Speaker Name", "Speaker Bio", - "Co-Speaker Name", "Co-Speaker Bio" }; + "Co-Speaker Name", "Co-Speaker Bio" , "Speaker Videos", "Co-Speaker Videos"}; public File exportSubmissions(List submissions) throws IOException{ File submissionsCSVFile = File.createTempFile("submissions.", ".csv"); @@ -34,7 +34,7 @@ public File exportSubmissions(List submissions) throws IOException{ } private void writeSubmissions(List submissions, ICsvMapWriter mapWriter) throws IOException{ - CellProcessor[] processors = new CellProcessor[] {null, null, null, null, null, null, null, null}; + CellProcessor[] processors = new CellProcessor[] {null, null, null, null, null, null, null, null, null, null}; Map submissionRow; mapWriter.writeHeader(submissionHeader); @@ -50,6 +50,11 @@ private void writeSubmissions(List submissions, ICsvMapWriter mapWri submissionRow.put(submissionHeader[6], submission.getCoSpeaker().getFirstName()); submissionRow.put(submissionHeader[7], submission.getCoSpeaker().getBio()); } + submissionRow.put(submissionHeader[8] , submission.getSpeaker().getVideos()); + if(submission.getCoSpeaker() != null) { + submissionRow.put(submissionHeader[9] , submission.getCoSpeaker().getVideos()); + } + mapWriter.write(submissionRow, submissionHeader, processors); } } diff --git a/src/main/java/site/facade/StringSanitizer.java b/src/main/java/site/facade/StringSanitizer.java new file mode 100644 index 00000000..362f7334 --- /dev/null +++ b/src/main/java/site/facade/StringSanitizer.java @@ -0,0 +1,9 @@ +package site.facade; + + +public class StringSanitizer { + + public static String formatString(String video) { + return video.replaceAll("(\t|\n|,| |;)+", " "); + } +} \ No newline at end of file diff --git a/src/main/java/site/model/Speaker.java b/src/main/java/site/model/Speaker.java index 113284a5..bb969a9d 100644 --- a/src/main/java/site/model/Speaker.java +++ b/src/main/java/site/model/Speaker.java @@ -1,5 +1,8 @@ package site.model; +import java.util.HashSet; +import java.util.Set; + import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; @@ -13,9 +16,6 @@ import site.config.Globals; -import java.util.HashSet; -import java.util.Set; - @Entity @Inheritance(strategy = InheritanceType.SINGLE_TABLE) public class Speaker extends User { @@ -23,6 +23,7 @@ public class Speaker extends User { /** * */ + private static final long serialVersionUID = 1L; @Column(length = 1024) @@ -38,6 +39,8 @@ public class Speaker extends User { @Lob private byte[] picture; + + private String videos; @OneToMany(mappedBy = "speaker", cascade = CascadeType.REMOVE, fetch = FetchType.LAZY, targetEntity = Submission.class) private Set submissions = new HashSet<>(); @@ -57,6 +60,17 @@ public Speaker(String firstName, String lastName, String email, String headline, this.featured = featured; this.accepted = accepted; } + + public Speaker(String firstName, String lastName, String email, String headline, String twitter, boolean featured, boolean accepted, String videos) { + setFirstName(firstName); + setLastName(lastName); + setEmail(email); + this.headline = headline; + this.twitter = twitter; + this.featured = featured; + this.accepted = accepted; + setVideos(videos); + } public byte[] getPicture() { return picture; @@ -81,6 +95,13 @@ public String getBio() { public void setBio(String bio) { this.bio = bio; } + + public String getVideos() { + return videos; + } + public void setVideos(String videos) { + this.videos = videos; + } public String getTwitter() { return twitter; diff --git a/src/main/webapp/WEB-INF/tags/user/speaker.tag b/src/main/webapp/WEB-INF/tags/user/speaker.tag index d10e3964..5b6a8fe7 100644 --- a/src/main/webapp/WEB-INF/tags/user/speaker.tag +++ b/src/main/webapp/WEB-INF/tags/user/speaker.tag @@ -44,6 +44,14 @@ +
+
+ +
+
+ +
+
diff --git a/src/main/webapp/admin/speaker/edit.jsp b/src/main/webapp/admin/speaker/edit.jsp index 5b4055c2..7adeb48c 100644 --- a/src/main/webapp/admin/speaker/edit.jsp +++ b/src/main/webapp/admin/speaker/edit.jsp @@ -117,6 +117,14 @@
+
+
+ +
+
+ +
+
diff --git a/src/main/webapp/admin/speaker/view.jsp b/src/main/webapp/admin/speaker/view.jsp index b796c7a7..1e264dfc 100644 --- a/src/main/webapp/admin/speaker/view.jsp +++ b/src/main/webapp/admin/speaker/view.jsp @@ -29,6 +29,7 @@ Accepted? Branch? Picture + Video Operations @@ -42,6 +43,7 @@ ${speaker.accepted} ${speaker.branch} + ${speaker.videos} Edit   Remove diff --git a/src/main/webapp/admin/submission/view.jsp b/src/main/webapp/admin/submission/view.jsp index 83ce1167..b6b7696a 100644 --- a/src/main/webapp/admin/submission/view.jsp +++ b/src/main/webapp/admin/submission/view.jsp @@ -33,7 +33,9 @@ Level Type Speaker + Speaker video Co-Speaker + Co-Speaker video Branch Status Operations @@ -45,7 +47,9 @@ ${submission.level} ${submission.type != null ? submission.type.toString() : "Conference session"} ${submission.speaker.firstName} ${submission.speaker.lastName} + ${submission.speaker.videos} ${submission.coSpeaker.firstName} ${submission.coSpeaker.lastName} + ${submission.coSpeaker.videos} ${submission.branch} ${submission.status} diff --git a/src/main/webapp/speaker.jsp b/src/main/webapp/speaker.jsp index b5a9cf38..5c1477cf 100644 --- a/src/main/webapp/speaker.jsp +++ b/src/main/webapp/speaker.jsp @@ -50,7 +50,7 @@ Back

-
+
@@ -64,10 +64,20 @@
- -

- -

+
+

+ +

+
+
+
+ +
+ +
+