-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add videos field to speaker #118
base: master
Are you sure you want to change the base?
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ALTER TABLE USER ADD COLUMN VIDEOS VARCHAR(255); | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
package site.facade; | ||
|
||
import java.util.List; | ||
|
||
import javax.transaction.Transactional; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
|
@@ -9,17 +11,40 @@ | |
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 | ||
public class AdminService { | ||
|
||
public static final String NAME = "adminFacade"; | ||
|
||
@Autowired | ||
private VideoSanitizerService videoSanitizerService; | ||
|
||
@Autowired | ||
@Qualifier(ArticleRepository.NAME) | ||
private ArticleRepository articleRepository; | ||
|
@@ -141,6 +166,10 @@ public void deleteSpeaker(Long id){ | |
} | ||
|
||
public Speaker saveSpeaker(Speaker speaker){ | ||
if(speaker.getVideos() != null) | ||
speaker.setVideos(videoSanitizerService. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. missing { } There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed formatting and {} |
||
formatString(speaker.getVideos())); | ||
|
||
return speakerRepository.save(speaker); | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package site.facade; | ||
|
||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
public class VideoSanitizerService { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This looks like Util method for me. Also it doesn't work with a Video actually, it is more like working with a String name. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed: Not a service anymore, but a class StringSanitizer |
||
|
||
public String formatString(String video) { | ||
return video.replaceAll("(\t|\n|,| |;)+", " "); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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,31 +16,31 @@ | |
|
||
import site.config.Globals; | ||
|
||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
@Entity | ||
@Inheritance(strategy = InheritanceType.SINGLE_TABLE) | ||
public class Speaker extends User { | ||
|
||
/** | ||
* | ||
*/ | ||
|
||
private static final long serialVersionUID = 1L; | ||
|
||
@Column(length = 1024) | ||
private String bio; | ||
|
||
private String headline; | ||
|
||
private String twitter; | ||
private String twitter; | ||
gochev marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
private Boolean featured = false; | ||
|
||
private Boolean accepted = false; | ||
|
||
@Lob | ||
private byte[] picture; | ||
|
||
private String videos; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm wondering why did you prefer to have them as comma separated values, instead of a List coming from a 1 to many relation? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @I-Mircheva can you make videos to be "videoLink" and to be just one URL mapped with @column(length = 500) for example so we dont need a migrate sql. |
||
|
||
@OneToMany(mappedBy = "speaker", cascade = CascadeType.REMOVE, fetch = FetchType.LAZY, targetEntity = Submission.class) | ||
private Set<Submission> 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; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, sometimes URLs are huge and with the comma separated approach 255 might not b enough in some cases
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made it VARCHAR(1024)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@I-Mircheva why do we need this SQL ? The schema should be updated automatically anyway.