Commit eff35ee1 by Tuomas Riihimäki

Compostuff

 * Fix creation functions
 * Refactor minor views to one file
 * Add 'hidden' boolean to compo
1 parent 7ee4efc0
...@@ -57,6 +57,9 @@ public class BootstrapBean implements BootstrapBeanLocal { ...@@ -57,6 +57,9 @@ public class BootstrapBean implements BootstrapBeanLocal {
"delete from menu_navigation where item_id in (select id from menuitem where url in ( '/actionlog/messagelist'))", "delete from menu_navigation where item_id in (select id from menuitem where url in ( '/actionlog/messagelist'))",
"delete from menuitem where url in ('/actionlog/messagelist')", "delete from menuitem where url in ('/actionlog/messagelist')",
}); });
dbUpdates.add(new String[] {
"alter table compos add hidden boolean default false not null"
});
} }
......
...@@ -59,6 +59,7 @@ public class VotingBean implements VotingBeanLocal { ...@@ -59,6 +59,7 @@ public class VotingBean implements VotingBeanLocal {
voteFacade.create(v); voteFacade.create(v);
} }
@RolesAllowed(CompoPermission.S_MANAGE)
public void createCompo(Compo c) { public void createCompo(Compo c) {
c.setEvent(eventBean.getCurrentEvent()); c.setEvent(eventBean.getCurrentEvent());
compoFacade.create(c); compoFacade.create(c);
...@@ -73,15 +74,15 @@ public class VotingBean implements VotingBeanLocal { ...@@ -73,15 +74,15 @@ public class VotingBean implements VotingBeanLocal {
c.getCompoEntries().add(compoEntry); c.getCompoEntries().add(compoEntry);
compoFacade.flush(); compoFacade.flush();
compoEntryFile.setEntriesId(compoEntry); compoEntryFile.setEntriesId(compoEntry);
compoEntry.getFiles().add(compoEntryFile); // compoEntry.getFiles().add(compoEntryFile);
} }
public Compo getCompoById(Integer compoId) { public Compo getCompoById(Integer compoId) {
return compoFacade.find(compoId); return compoFacade.find(compoId);
} }
public List<Compo> getCompoList() { public List<Compo> getCompoList(boolean showHidden) {
return compoFacade.getList(); return compoFacade.getList(showHidden);
} }
@Override @Override
...@@ -129,16 +130,17 @@ public class VotingBean implements VotingBeanLocal { ...@@ -129,16 +130,17 @@ public class VotingBean implements VotingBeanLocal {
return compoEntryFacade.find(entryId); return compoEntryFacade.find(entryId);
} }
@Override // @Override
public CompoEntry findEntryWithFiles(Integer entryId) { // public CompoEntry findEntryWithFiles(Integer entryId) {
CompoEntry ret = compoEntryFacade.find(entryId); // CompoEntry ret = compoEntryFacade.find(entryId);
logger.debug("Found files {}", ret.getFiles().size()); // // logger.debug("Found files {}", ret.getFiles().size());
//
return ret; // return ret;
//
} // }
@Override @Override
@RolesAllowed(CompoPermission.S_MANAGE)
public CompoEntry saveSort(CompoEntry e) { public CompoEntry saveSort(CompoEntry e) {
CompoEntry entry = compoEntryFacade.find(e.getId()); CompoEntry entry = compoEntryFacade.find(e.getId());
entry.setSort(e.getSort()); entry.setSort(e.getSort());
...@@ -177,4 +179,15 @@ public class VotingBean implements VotingBeanLocal { ...@@ -177,4 +179,15 @@ public class VotingBean implements VotingBeanLocal {
return voteEntity; return voteEntity;
} }
@Override
@RolesAllowed(CompoPermission.S_MANAGE)
public Compo saveCompo(Compo compo) {
return compoFacade.merge(compo);
}
@Override
public void create(CompoEntryFile cef) {
compoEntryFileFacade.create(cef);
}
} }
package fi.codecrew.moya.facade; package fi.codecrew.moya.facade;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import javax.ejb.EJB; import javax.ejb.EJB;
...@@ -7,11 +8,12 @@ import javax.ejb.LocalBean; ...@@ -7,11 +8,12 @@ import javax.ejb.LocalBean;
import javax.ejb.Stateless; import javax.ejb.Stateless;
import javax.persistence.criteria.CriteriaBuilder; import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery; import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root; import javax.persistence.criteria.Root;
import fi.codecrew.moya.model.Compo_;
import fi.codecrew.moya.beans.EventBeanLocal; import fi.codecrew.moya.beans.EventBeanLocal;
import fi.codecrew.moya.model.Compo; import fi.codecrew.moya.model.Compo;
import fi.codecrew.moya.model.Compo_;
@Stateless @Stateless
@LocalBean @LocalBean
...@@ -23,11 +25,17 @@ public class CompoFacade extends IntegerPkGenericFacade<Compo> { ...@@ -23,11 +25,17 @@ public class CompoFacade extends IntegerPkGenericFacade<Compo> {
super(Compo.class); super(Compo.class);
} }
public List<Compo> getList() { public List<Compo> getList(boolean showHidden) {
CriteriaBuilder cb = getEm().getCriteriaBuilder(); CriteriaBuilder cb = getEm().getCriteriaBuilder();
CriteriaQuery<Compo> cq = cb.createQuery(Compo.class); CriteriaQuery<Compo> cq = cb.createQuery(Compo.class);
Root<Compo> root = cq.from(Compo.class); Root<Compo> root = cq.from(Compo.class);
cq.where(cb.equal(root.get(Compo_.event), eventbean.getCurrentEvent()));
ArrayList<Predicate> preds = new ArrayList<>();
preds.add(cb.equal(root.get(Compo_.event), eventbean.getCurrentEvent()));
if (!showHidden) {
preds.add(cb.isFalse(root.get(Compo_.hidden)));
}
cq.where(preds.toArray(new Predicate[preds.size()]));
cq.orderBy(cb.desc(root.get(Compo_.startTime))); cq.orderBy(cb.desc(root.get(Compo_.startTime)));
List<Compo> ret = getEm().createQuery(cq).getResultList(); List<Compo> ret = getEm().createQuery(cq).getResultList();
return ret; return ret;
......
...@@ -15,7 +15,7 @@ public interface VotingBeanLocal { ...@@ -15,7 +15,7 @@ public interface VotingBeanLocal {
public void addEntry(CompoEntry compoEntry, CompoEntryFile compoEntryFile); public void addEntry(CompoEntry compoEntry, CompoEntryFile compoEntryFile);
public List<Compo> getCompoList(); public List<Compo> getCompoList(boolean showHidden);
public Compo getCompoById(Integer compoId); public Compo getCompoById(Integer compoId);
...@@ -33,6 +33,10 @@ public interface VotingBeanLocal { ...@@ -33,6 +33,10 @@ public interface VotingBeanLocal {
public Vote saveVote(CompoEntry entry, Integer vote); public Vote saveVote(CompoEntry entry, Integer vote);
public CompoEntry findEntryWithFiles(Integer entryId); //public CompoEntry findEntryWithFiles(Integer entryId);
public Compo saveCompo(Compo compo);
public void create(CompoEntryFile cef);
} }
...@@ -31,200 +31,212 @@ import org.eclipse.persistence.annotations.OptimisticLockingType; ...@@ -31,200 +31,212 @@ import org.eclipse.persistence.annotations.OptimisticLockingType;
@Table(name = "compos") @Table(name = "compos")
@OptimisticLocking(type = OptimisticLockingType.CHANGED_COLUMNS) @OptimisticLocking(type = OptimisticLockingType.CHANGED_COLUMNS)
public class Compo extends GenericEntity { public class Compo extends GenericEntity {
private static final long serialVersionUID = 2L; private static final long serialVersionUID = 2L;
/** /**
* Name of the competition. * Name of the competition.
*/ */
@Column(name = "compo_name", nullable = false) @Column(name = "compo_name", nullable = false)
private String name; private String name;
public static final String EVENT_ID_COLUMN = "event_id"; public static final String EVENT_ID_COLUMN = "event_id";
@ManyToOne() @ManyToOne()
@JoinColumn(name = EVENT_ID_COLUMN, nullable = false) @JoinColumn(name = EVENT_ID_COLUMN, nullable = false)
private LanEvent event; private LanEvent event;
/** /**
* Start time of the competition Submitting entries should be disabled after * Start time of the competition Submitting entries should be disabled after
* this time. * this time.
*/ */
@Column(name = "compo_start") @Column(name = "compo_start")
@Temporal(TemporalType.TIMESTAMP) @Temporal(TemporalType.TIMESTAMP)
private Date startTime; private Date startTime;
@Column(name = "compo_end") @Column(name = "compo_end")
@Temporal(TemporalType.TIMESTAMP) @Temporal(TemporalType.TIMESTAMP)
private Date endTime; private Date endTime;
/** /**
* When the voting should start * When the voting should start
* *
* @see {@link #holdVoting} * @see {@link #holdVoting}
*/ */
@Column(name = "vote_start") @Column(name = "vote_start")
@Temporal(TemporalType.TIMESTAMP) @Temporal(TemporalType.TIMESTAMP)
private Date voteStart; private Date voteStart;
@Column(name = "vote_end") @Column(name = "vote_end")
@Temporal(TemporalType.TIMESTAMP) @Temporal(TemporalType.TIMESTAMP)
private Date voteEnd; private Date voteEnd;
@Column(name = "submit_start") @Column(name = "submit_start")
@Temporal(TemporalType.TIMESTAMP) @Temporal(TemporalType.TIMESTAMP)
private Date submitStart; private Date submitStart;
@Column(name = "submit_end") @Column(name = "submit_end")
@Temporal(TemporalType.TIMESTAMP) @Temporal(TemporalType.TIMESTAMP)
private Date submitEnd; private Date submitEnd;
@Lob @Lob
@Column(name = "description") @Column(name = "description")
private String description; private String description;
@Column(name = "max_participant_count") @Column(name = "max_participant_count")
private int maxParticipantCount; private int maxParticipantCount;
/** /**
* If ( for some unimaginable reason ) compo is delayed hold voting can be * If ( for some unimaginable reason ) compo is delayed hold voting can be
* used to postpone the start of the voting from the time specified in * used to postpone the start of the voting from the time specified in
* {@link #voteStart} * {@link #voteStart}
*/ */
@Column(name = "hold_voting", nullable = false) @Column(name = "hold_voting", nullable = false)
private boolean holdVoting = true; private boolean holdVoting = false;
/** @Column(name = "hidden", nullable = false)
* Entries submitted to participate this compo. private boolean hidden = false;
*/
@OneToMany(cascade = CascadeType.ALL, mappedBy = "compo") public boolean isHidden() {
@OrderBy("sort") return hidden;
private List<CompoEntry> compoEntries; }
public Compo(String compoName, boolean holdVoting) { public void setHidden(boolean hidden) {
this(); this.hidden = hidden;
}
this.name = compoName;
this.holdVoting = holdVoting; /**
} * Entries submitted to participate this compo.
*/
public boolean isSubmit() @OneToMany(cascade = CascadeType.ALL, mappedBy = "compo")
{ @OrderBy("sort")
Calendar now = Calendar.getInstance(); private List<CompoEntry> compoEntries;
return now.after(getSubmitStart()) && now.before(getSubmitEnd());
} public Compo(String compoName, boolean holdVoting) {
this();
public boolean isVote()
{ this.name = compoName;
Calendar now = Calendar.getInstance(); this.holdVoting = holdVoting;
return !getHoldVoting() && }
now.after(getVoteStart()) &&
now.before(getVoteEnd()); public boolean isSubmit()
} {
Calendar now = Calendar.getInstance();
public Compo() { return now.after(getSubmitStart()) && now.before(getSubmitEnd());
super(); }
}
public boolean isVote()
public String getName() { {
return name; Calendar now = Calendar.getInstance();
} return !getHoldVoting() &&
now.after(getVoteStart()) &&
public void setName(String compoName) { now.before(getVoteEnd());
this.name = compoName; }
}
public Compo() {
public Date getStartTime() { super();
return startTime; }
}
public String getName() {
public void setStartTime(Date compoStart) { return name;
this.startTime = compoStart; }
}
public void setName(String compoName) {
public Date getVoteStart() { this.name = compoName;
return voteStart; }
}
public Date getStartTime() {
public void setVoteStart(Date voteStart) { return startTime;
this.voteStart = voteStart; }
}
public void setStartTime(Date compoStart) {
public Date getVoteEnd() { this.startTime = compoStart;
return voteEnd; }
}
public Date getVoteStart() {
public void setVoteEnd(Date voteEnd) { return voteStart;
this.voteEnd = voteEnd; }
}
public void setVoteStart(Date voteStart) {
public Date getSubmitStart() { this.voteStart = voteStart;
return submitStart; }
}
public Date getVoteEnd() {
public void setSubmitStart(Date submitStart) { return voteEnd;
this.submitStart = submitStart; }
}
public void setVoteEnd(Date voteEnd) {
public Date getSubmitEnd() { this.voteEnd = voteEnd;
return submitEnd; }
}
public Date getSubmitStart() {
public void setSubmitEnd(Date submitEnd) { return submitStart;
this.submitEnd = submitEnd; }
}
public void setSubmitStart(Date submitStart) {
public boolean getHoldVoting() { this.submitStart = submitStart;
return holdVoting; }
}
public Date getSubmitEnd() {
public void setHoldVoting(boolean holdVoting) { return submitEnd;
this.holdVoting = holdVoting; }
}
public void setSubmitEnd(Date submitEnd) {
public List<CompoEntry> getCompoEntries() { this.submitEnd = submitEnd;
return compoEntries; }
}
public boolean getHoldVoting() {
public void setCompoEntries(List<CompoEntry> compoEntryList) { return holdVoting;
this.compoEntries = compoEntryList; }
}
public void setHoldVoting(boolean holdVoting) {
public void setDescription(String description) { this.holdVoting = holdVoting;
this.description = description; }
}
public List<CompoEntry> getCompoEntries() {
public String getDescription() { return compoEntries;
return description; }
}
public void setCompoEntries(List<CompoEntry> compoEntryList) {
/** this.compoEntries = compoEntryList;
* @return the maxParticipantCount }
*/
public int getMaxParticipantCount() { public void setDescription(String description) {
return maxParticipantCount; this.description = description;
} }
/** public String getDescription() {
* @param maxParticipantCount return description;
* the maxParticipantCount to set }
*/
public void setMaxParticipantCount(int maxParticipantCount) { /**
this.maxParticipantCount = maxParticipantCount; * @return the maxParticipantCount
} */
public int getMaxParticipantCount() {
public LanEvent getEvent() { return maxParticipantCount;
return event; }
}
/**
public void setEvent(LanEvent event) { * @param maxParticipantCount
this.event = event; * the maxParticipantCount to set
} */
public void setMaxParticipantCount(int maxParticipantCount) {
public Date getEndTime() { this.maxParticipantCount = maxParticipantCount;
return endTime; }
}
public LanEvent getEvent() {
public void setEndTime(Date endTime) { return event;
this.endTime = endTime; }
}
public void setEvent(LanEvent event) {
this.event = event;
}
public Date getEndTime() {
return endTime;
}
public void setEndTime(Date endTime) {
this.endTime = endTime;
}
} }
...@@ -11,7 +11,6 @@ import java.util.List; ...@@ -11,7 +11,6 @@ import java.util.List;
import javax.persistence.CascadeType; import javax.persistence.CascadeType;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn; import javax.persistence.JoinColumn;
import javax.persistence.Lob; import javax.persistence.Lob;
import javax.persistence.ManyToOne; import javax.persistence.ManyToOne;
...@@ -23,7 +22,6 @@ import javax.persistence.TemporalType; ...@@ -23,7 +22,6 @@ import javax.persistence.TemporalType;
import org.eclipse.persistence.annotations.OptimisticLocking; import org.eclipse.persistence.annotations.OptimisticLocking;
import org.eclipse.persistence.annotations.OptimisticLockingType; import org.eclipse.persistence.annotations.OptimisticLockingType;
import org.eclipse.persistence.annotations.PrivateOwned;
/** /**
* *
...@@ -32,170 +30,155 @@ import org.eclipse.persistence.annotations.PrivateOwned; ...@@ -32,170 +30,155 @@ import org.eclipse.persistence.annotations.PrivateOwned;
@Table(name = "compo_entries") @Table(name = "compo_entries")
@OptimisticLocking(type = OptimisticLockingType.CHANGED_COLUMNS) @OptimisticLocking(type = OptimisticLockingType.CHANGED_COLUMNS)
public class CompoEntry extends GenericEntity { public class CompoEntry extends GenericEntity {
private static final long serialVersionUID = 2L; private static final long serialVersionUID = 2L;
@JoinColumn(name = "compo_id", referencedColumnName = "id", nullable = false) @JoinColumn(name = "compo_id", referencedColumnName = "id", nullable = false)
@ManyToOne(optional = false) @ManyToOne(optional = false)
private Compo compo; private Compo compo;
@Column(name = "entry_created", nullable = false) @Column(name = "entry_created", nullable = false)
@Temporal(TemporalType.TIMESTAMP) @Temporal(TemporalType.TIMESTAMP)
private Calendar created = Calendar.getInstance(); private Calendar created = Calendar.getInstance();
@Column(name = "title", nullable = false)
private String title = "";
@Column(name = "author")
private String author = "";
@Lob
@Column(name = "notes")
private String notes = "";
@Lob
@Column(name = "screen_message")
private String screenMessage = "";
@Column(name = "sort")
private Integer sort = 10;
@Column(name = "title", nullable = false) @Column(name = "final_position")
private String title = ""; private Integer finalPosition;
@Column(name = "author") @JoinColumn(name = "current_file_id", referencedColumnName = CompoEntryFile.ID_COLUMN)
private String author = ""; @OneToOne
private CompoEntryFile currentFile;
@Lob
@Column(name = "notes") @OneToMany(mappedBy = "compoEntry")
private String notes = ""; private List<Vote> votes;
//
@Lob // @PrivateOwned
@Column(name = "screen_message") // @OneToMany(cascade = CascadeType.ALL, mappedBy = "entry", fetch =
private String screenMessage = ""; // FetchType.LAZY)
// private List<CompoEntryFile> files;
@Column(name = "sort")
private Integer sort = 10; @OneToMany(cascade = CascadeType.ALL, mappedBy = "entry")
private List<CompoEntryParticipant> participants;
@Column(name = "final_position")
private Integer finalPosition; @JoinColumn(name = "creator_eventuser_id", referencedColumnName = EventUser.ID_COLUMN, nullable = false)
@ManyToOne
@JoinColumn(name = "current_file_id", referencedColumnName = CompoEntryFile.ID_COLUMN) private EventUser creator;
@OneToOne
private CompoEntryFile currentFile; public Integer getVotetotal()
{
@OneToMany(mappedBy = "compoEntry") int votetotal = 0;
private List<Vote> votes; for (Vote v : getVotes()) {
votetotal += v.getScore();
@PrivateOwned }
@OneToMany(cascade = CascadeType.ALL, mappedBy = "entry", fetch = FetchType.LAZY) return votetotal;
private List<CompoEntryFile> files; }
@OneToMany(cascade = CascadeType.ALL, mappedBy = "entry") public CompoEntry() {
private List<CompoEntryParticipant> participants; super();
}
@JoinColumn(name = "creator_eventuser_id", referencedColumnName = EventUser.ID_COLUMN, nullable = false)
@ManyToOne public Calendar getCreated() {
private EventUser creator; return created;
}
public Integer getVotetotal()
{ public void setCreated(Calendar entryCreated) {
int votetotal = 0; this.created = entryCreated;
for (Vote v : getVotes()) { }
votetotal += v.getScore();
} public String getNotes() {
return votetotal; return notes;
} }
public CompoEntry() { public void setNotes(String notes) {
super(); this.notes = notes;
} }
public Calendar getCreated() { public String getScreenMessage() {
return created; return screenMessage;
} }
public void setCreated(Calendar entryCreated) { public void setScreenMessage(String screenMessage) {
this.created = entryCreated; this.screenMessage = screenMessage;
} }
public String getNotes() { public Integer getSort() {
return notes; return sort;
} }
public void setNotes(String notes) { public void setSort(Integer sort) {
this.notes = notes; this.sort = sort;
} }
public String getScreenMessage() { public List<Vote> getVotes() {
return screenMessage; return votes;
} }
public void setScreenMessage(String screenMessage) { public void setVotes(List<Vote> voteList) {
this.screenMessage = screenMessage; this.votes = voteList;
} }
public Integer getSort() { public List<CompoEntryParticipant> getParticipants() {
return sort; return participants;
} }
public void setSort(Integer sort) { public void setParticipants(
this.sort = sort; List<CompoEntryParticipant> compoEntryParticipantList) {
} this.participants = compoEntryParticipantList;
}
public List<Vote> getVotes() {
return votes; public Compo getCompo() {
} return compo;
}
public void setVotes(List<Vote> voteList) {
this.votes = voteList; public void setCompo(Compo composId) {
} this.compo = composId;
}
public List<CompoEntryFile> getFiles() {
return files; public EventUser getCreator() {
} return creator;
}
public void setFiles(List<CompoEntryFile> compoEntryFileList) {
this.files = compoEntryFileList; public void setCreator(EventUser creator) {
} this.creator = creator;
}
public List<CompoEntryParticipant> getParticipants() {
return participants; public void setFinalPosition(Integer finalPosition) {
} this.finalPosition = finalPosition;
}
public void setParticipants(
List<CompoEntryParticipant> compoEntryParticipantList) { public Integer getFinalPosition() {
this.participants = compoEntryParticipantList; return finalPosition;
} }
public Compo getCompo() { public String getTitle() {
return compo; return title;
} }
public void setCompo(Compo composId) { public void setTitle(String title) {
this.compo = composId; this.title = title;
} }
public EventUser getCreator() { public String getAuthor() {
return creator; return author;
} }
public void setCreator(EventUser creator) { public void setAuthor(String author) {
this.creator = creator; this.author = author;
} }
public void setFinalPosition(Integer finalPosition) {
this.finalPosition = finalPosition;
}
public Integer getFinalPosition() {
return finalPosition;
}
public void setCurrentFile(CompoEntryFile currentFile) {
this.currentFile = currentFile;
}
public CompoEntryFile getCurrentFile() {
return currentFile;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getAuthor() {
return author;
}
public void setAuthor(String author) {
this.author = author;
}
} }
...@@ -5,10 +5,14 @@ ...@@ -5,10 +5,14 @@
package fi.codecrew.moya.model; package fi.codecrew.moya.model;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Calendar; import java.util.Calendar;
import javax.persistence.Basic;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn; import javax.persistence.JoinColumn;
import javax.persistence.Lob; import javax.persistence.Lob;
import javax.persistence.ManyToOne; import javax.persistence.ManyToOne;
...@@ -16,8 +20,11 @@ import javax.persistence.Table; ...@@ -16,8 +20,11 @@ import javax.persistence.Table;
import javax.persistence.Temporal; import javax.persistence.Temporal;
import javax.persistence.TemporalType; import javax.persistence.TemporalType;
import org.apache.commons.codec.binary.Hex;
import org.eclipse.persistence.annotations.OptimisticLocking; import org.eclipse.persistence.annotations.OptimisticLocking;
import org.eclipse.persistence.annotations.OptimisticLockingType; import org.eclipse.persistence.annotations.OptimisticLockingType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* *
...@@ -26,94 +33,110 @@ import org.eclipse.persistence.annotations.OptimisticLockingType; ...@@ -26,94 +33,110 @@ import org.eclipse.persistence.annotations.OptimisticLockingType;
@Table(name = "compo_entry_files") @Table(name = "compo_entry_files")
@OptimisticLocking(type = OptimisticLockingType.CHANGED_COLUMNS) @OptimisticLocking(type = OptimisticLockingType.CHANGED_COLUMNS)
public class CompoEntryFile extends GenericEntity { public class CompoEntryFile extends GenericEntity {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@Column(name = "mime_type") @Column(name = "mime_type")
private String mimeType; private String mimeType;
@Column(name = "file_name") @Column(name = "file_name")
private String fileName; private String fileName;
@Lob @Lob
@Column(name = "description") @Column(name = "description")
private String description; private String description;
@Column(name = "hash") @Column(name = "hash", updatable = false)
private String hash; private String hash;
@Lob @Lob
@Column(name = "file_data") @Column(name = "file_data", updatable = false)
private byte[] fileData; @Basic(fetch = FetchType.LAZY)
private byte[] fileData;
@Column(name = "uploaded", nullable = false)
@Temporal(TemporalType.TIMESTAMP) @Column(name = "uploaded", nullable = false)
private Calendar uploaded = Calendar.getInstance(); @Temporal(TemporalType.TIMESTAMP)
private Calendar uploaded = Calendar.getInstance();
@JoinColumn(name = "entry_id", referencedColumnName = "id", nullable = false, updatable = false)
@ManyToOne(optional = false) @JoinColumn(name = "entry_id", referencedColumnName = "id", nullable = false, updatable = false)
private CompoEntry entry; @ManyToOne(optional = false)
private CompoEntry entry;
public CompoEntryFile() { private static final Logger logger = LoggerFactory.getLogger(CompoEntryFile.class);
super();
} public CompoEntryFile() {
super();
public CompoEntryFile(CompoEntry entry) { }
this.entry = entry;
} public CompoEntryFile(CompoEntry entry) {
this.entry = entry;
public String getMimeType() { }
return mimeType;
} public String getMimeType() {
return mimeType;
public void setMimeType(String mimeType) { }
this.mimeType = mimeType;
} public void setMimeType(String mimeType) {
this.mimeType = mimeType;
public String getFileName() { }
return fileName;
} public String getFileName() {
return fileName;
public void setFileName(String fileName) { }
this.fileName = fileName;
} public void setFileName(String fileName) {
this.fileName = fileName;
public String getDescription() { }
return description;
} public String getDescription() {
return description;
public void setDescription(String description) { }
this.description = description;
} public void setDescription(String description) {
this.description = description;
public String getHash() { }
return hash;
} public String getHash() {
return hash;
public void setHash(String hash) { }
this.hash = hash;
} public void setHash(String hash) {
this.hash = hash;
public byte[] getFileData() { }
return fileData;
} public byte[] getFileData() {
return fileData;
public void setFileData(byte[] fileData) { }
this.fileData = fileData;
} public void setFileData(byte[] fileData) {
this.fileData = fileData;
public Calendar getUploaded() { this.hash = getShaChecksum(fileData);
return uploaded; }
}
public Calendar getUploaded() {
public void setUploaded(Calendar uploaded) { return uploaded;
this.uploaded = uploaded; }
}
public void setUploaded(Calendar uploaded) {
public CompoEntry getEntriesId() { this.uploaded = uploaded;
return entry; }
}
public CompoEntry getEntriesId() {
public void setEntriesId(CompoEntry entriesId) { return entry;
this.entry = entriesId; }
}
public void setEntriesId(CompoEntry entriesId) {
this.entry = entriesId;
}
public static String getShaChecksum(byte[] data)
{
String ret = "ERROR CALCULATING CHECKSUM!";
try {
MessageDigest algo = MessageDigest.getInstance("SHA");
algo.update(data);
ret = new String(Hex.encodeHex(algo.digest())).toLowerCase();
} catch (NoSuchAlgorithmException e) {
logger.warn("Error calculating checksum", e);
}
return ret;
}
} }
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:composite="http://java.sun.com/jsf/composite"
xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:tools="http://java.sun.com/jsf/composite/tools" xmlns:p="http://primefaces.org/ui">
<composite:interface>
<composite:attribute name="commitValue" required="true" />
<composite:attribute name="commitAction" method-signature="java.lang.String action()" required="true" />
</composite:interface>
<composite:implementation>
<h:form>
<h:panelGrid columns="3">
<h:outputLabel value="#{i18n['voting.create.name']}:" for="name" />
<h:inputText value="#{compoMgmtView.compo.name}" id="name" />
<h:message for="name" />
<h:outputLabel value="#{i18n['voting.create.description']}:" for="desc" />
<h:inputText value="#{compoMgmtView.compo.description}" id="desc" />
<h:message for="desc" />
<h:outputLabel value="#{i18n['voting.create.maxParticipants']}:" for="maxPar" />
<h:inputText value="#{compoMgmtView.compo.maxParticipantCount}" id="maxPar" />
<h:message for="maxPar" />
<h:outputLabel value="#{i18n['voting.create.holdVoting']}:" for="holdVoting" />
<h:selectBooleanCheckbox value="#{compoMgmtView.compo.holdVoting}" id="holdVoting" />
<h:message for="holdVoting" />
<h:outputLabel value="#{i18n['voting.create.hidden']}:" for="hidden" />
<h:selectBooleanCheckbox value="#{compoMgmtView.compo.hidden}" id="hidden" />
<h:message for="hidden" />
<h:outputLabel value="#{i18n['voting.create.compoStart']}:" for="cStart" />
<p:calendar validator="#{votingDateValidator.saveCStart}" value="#{compoMgmtView.compo.startTime}" pattern="dd/MM/yyyy HH:mm" id="cStart" />
<h:message for="cStart" />
<h:outputLabel value="#{i18n['voting.create.compoEnd']}:" for="cEnd" />
<p:calendar validator="#{votingDateValidator.validateCompo}" value="#{compoMgmtView.compo.endTime}" pattern="dd/MM/yyyy HH:mm" id="cEnd" />
<h:message for="cEnd" />
<h:outputLabel value="#{i18n['voting.create.voteStart']}:" for="vStart" />
<p:calendar validator="#{votingDateValidator.saveVStart}" value="#{compoMgmtView.compo.voteStart}" pattern="dd/MM/yyyy HH:mm" id="vStart" />
<h:message for="vStart" />
<h:outputLabel value="#{i18n['voting.create.voteEnd']}:" for="vEnd" />
<p:calendar validator="#{votingDateValidator.validateVote}" value="#{compoMgmtView.compo.voteEnd}" pattern="dd/MM/yyyy HH:mm" id="vEnd" />
<h:message for="vEnd" />
<h:outputLabel value="#{i18n['voting.create.submitStart']}:" for="sStart" />
<p:calendar validator="#{votingDateValidator.saveSStart}" value="#{compoMgmtView.compo.submitStart}" pattern="dd/MM/yyyy HH:mm" id="sStart" />
<h:message for="sStart" />
<h:outputLabel value="#{i18n['voting.create.submitEnd']}:" for="sEnd" />
<p:calendar validator="#{votingDateValidator.validateSubmit}" value="#{compoMgmtView.compo.submitEnd}" pattern="dd/MM/yyyy HH:mm" id="sEnd" />
<h:message for="sEnd" />
<h:commandButton action="#{cc.attrs.commitAction}" id="commitbutton" value="#{cc.attrs.commitValue}" />
</h:panelGrid>
</h:form>
</composite:implementation>
</html>
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
<h:body> <h:body>
<ui:composition template="#{sessionHandler.template}"> <ui:composition template="#{sessionHandler.template}">
<f:metadata> <f:metadata>
<f:event type="preRenderView" listener="#{compoView.initListView()}" /> <f:event type="preRenderView" listener="#{compoView.initAdminListView()}" />
</f:metadata> </f:metadata>
<ui:define name="content"> <ui:define name="content">
<h:outputStylesheet library="style" name="insomnia2/css/actionlog.css" /> <h:outputStylesheet library="style" name="insomnia2/css/actionlog.css" />
...@@ -15,13 +15,10 @@ ...@@ -15,13 +15,10 @@
<p>#{i18n['voting.allcompos.description']}</p> <p>#{i18n['voting.allcompos.description']}</p>
<h:form> <h:form>
<h:dataTable styleClass="bordertable" rowClasses="roweven,rowodd" id="compolisttable" value="#{compoView.compos}" var="compo"> <p:dataTable styleClass="bordertable" rowClasses="roweven,rowodd" id="compolisttable" value="#{compoView.compos}" var="compo">
<h:column> <p:column headerText="#{i18n['voting.allcompos.name']}">
<f:facet name="header">
<h:outputText value="#{i18n['voting.allcompos.name']}" />
</f:facet>
<h:outputText value="#{compo.name}" /> <h:outputText value="#{compo.name}" />
</h:column> </p:column>
<!-- <h:column rendered="#{compoView.curEntries}"> --> <!-- <h:column rendered="#{compoView.curEntries}"> -->
<!-- <f:facet name="header"> --> <!-- <f:facet name="header"> -->
...@@ -35,45 +32,42 @@ ...@@ -35,45 +32,42 @@
<!-- </f:facet> --> <!-- </f:facet> -->
<!-- <h:outputText value="#{compo.maxParticipantCount}" /> --> <!-- <h:outputText value="#{compo.maxParticipantCount}" /> -->
<!-- </h:column> --> <!-- </h:column> -->
<h:column> <p:column headerText="#{i18n['voting.allcompos.startTime']}">
<f:facet name="header">
<h:outputText value="#{i18n['voting.allcompos.startTime']}" />
</f:facet>
<h:outputText value="#{compo.startTime.time}"> <h:outputText value="#{compo.startTime.time}">
<f:convertDateTime pattern="#{sessionHandler.datetimeFormat}" timeZone="#{sessionHandler.timezone}" /> <f:convertDateTime pattern="#{sessionHandler.datetimeFormat}" timeZone="#{sessionHandler.timezone}" />
</h:outputText> </h:outputText>
</h:column> </p:column>
<h:column> <p:column headerText="#{i18n['voting.allcompos.voteEnd']}">
<f:facet name="header">
<h:outputText value="#{i18n['voting.allcompos.voteEnd']}" />
</f:facet>
<h:outputText value="#{compo.voteEnd.time}"> <h:outputText value="#{compo.voteEnd.time}">
<f:convertDateTime pattern="#{sessionHandler.datetimeFormat}" timeZone="#{sessionHandler.timezone}" /> <f:convertDateTime pattern="#{sessionHandler.datetimeFormat}" timeZone="#{sessionHandler.timezone}" />
</h:outputText> </h:outputText>
</h:column> </p:column>
<h:column> <p:column headerText="#{i18n['voting.allcompos.submitEnd']}">
<f:facet name="header">
<h:outputText value="#{i18n['voting.allcompos.submitEnd']}" />
</f:facet>
<h:outputText value="#{compo.submitEnd.time}"> <h:outputText value="#{compo.submitEnd.time}">
<f:convertDateTime pattern="#{sessionHandler.datetimeFormat}" timeZone="#{sessionHandler.timezone}" /> <f:convertDateTime pattern="#{sessionHandler.datetimeFormat}" timeZone="#{sessionHandler.timezone}" />
</h:outputText> </h:outputText>
</h:column> </p:column>
<h:column> <p:column headerText="#{i18n['voting.allcompos.holdVoting']}">
<h:outputText value="#{compo.holdVoting}" />
</p:column>
<p:column headerText="#{i18n['voting.allcompos.hidden']}">
<h:outputText value="#{compo.hidden}" />
</p:column>
<p:column>
<h:commandButton rendered="#{compo.vote or compoView.manage}" action="#{compoView.startVote()}" value="#{i18n['voting.compo.vote']}" /> <h:commandButton rendered="#{compo.vote or compoView.manage}" action="#{compoView.startVote()}" value="#{i18n['voting.compo.vote']}" />
</h:column> </p:column>
<h:column> <p:column>
<h:commandButton rendered="#{compo.submit or compoView.manage}" action="#{compoView.submitEntry()}" value="#{i18n['voting.compo.submit']}" /> <h:commandButton rendered="#{compo.submit or compoView.manage}" action="#{compoView.submitEntry()}" value="#{i18n['voting.compo.submit']}" />
</h:column> </p:column>
<h:column rendered="#{compoView.manage}"> <p:column rendered="#{compoView.manage}">
<h:link outcome="details" value="#{i18n['compo.edit']}"> <h:link outcome="details" value="#{i18n['compo.edit']}">
<f:param name="compoId" value="#{compo.id}" /> <f:param name="compoId" value="#{compo.id}" />
</h:link> </h:link>
</h:column> </p:column>
</h:dataTable> </p:dataTable>
</h:form> </h:form>
</ui:define> </ui:define>
......
<!DOCTYPE html <!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" <html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html"
xmlns:h="http://java.sun.com/jsf/html" xmlns:users="http://java.sun.com/jsf/composite/cditools/user" xmlns:tools="http://java.sun.com/jsf/composite/cditools" xmlns:compo="http://java.sun.com/jsf/composite/cditools/compo" xmlns:f="http://java.sun.com/jsf/core" xmlns:p="http://primefaces.org/ui">
xmlns:tools="http://java.sun.com/jsf/composite/cditools" xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui">
<h:body> <h:body>
<ui:composition template="#{sessionHandler.template}"> <ui:composition template="#{sessionHandler.template}">
<f:metadata> <f:metadata>
<f:event type="preRenderView" listener="#{votingCreateView.initCreate}" /> <f:event type="preRenderView" listener="#{compoMgmtView.initCreate}" />
</f:metadata> </f:metadata>
<ui:define name="content"> <ui:define name="content">
<!-- <h:outputStylesheet library="style" name="insomnia2/css/actionlog.css" /> -->
<h1>#{i18n['voting.create.header']}</h1> <h1>#{i18n['voting.create.header']}</h1>
<p>#{i18n['voting.create.description']}</p> <p>#{i18n['voting.create.description']}</p>
<div>
<h:form>
<h:panelGrid columns="3">
<h:outputLabel value="#{i18n['voting.create.name']}:" for="name"/>
<h:inputText value="#{votingCreateView.compo.name}" id="name" />
<h:message for="name" />
<h:outputLabel value="#{i18n['voting.create.description']}:" for="desc"/> <compo:editCompo commitAction="#{compoMgmtView.createCompo}" commitValue="#{i18n['voting.create.createButton']}" />
<h:inputText value="#{votingCreateView.compo.description}" id="desc" />
<h:message for="desc" />
<h:outputLabel value="#{i18n['voting.create.maxParticipants']}:" for="maxPar" />
<h:inputText value="#{votingCreateView.compo.maxParticipantCount}" id="maxPar" />
<h:message for="maxPar" />
<h:outputLabel value="#{i18n['voting.create.compoStart']}:" for="cStart" />
<p:calendar validator="#{votingDateValidator.saveCStart}" value="#{votingCreateView.compo.startTime}" pattern="dd/MM/yyyy HH:mm" id="cStart" />
<h:message for="cStart" />
<h:outputLabel value="#{i18n['voting.create.compoEnd']}:" for="cEnd"/>
<p:calendar validator="#{votingDateValidator.validateCompo}" value="#{votingCreateView.compo.endTime}" pattern="dd/MM/yyyy HH:mm" id="cEnd" />
<h:message for="cEnd" />
<h:outputLabel value="#{i18n['voting.create.voteStart']}:" for="vStart" />
<p:calendar validator="#{votingDateValidator.saveVStart}" value="#{votingCreateView.compo.voteStart}" pattern="dd/MM/yyyy HH:mm" id="vStart" />
<h:message for="vStart" />
<h:outputLabel value="#{i18n['voting.create.voteEnd']}:" for="vEnd" />
<p:calendar validator="#{votingDateValidator.validateVote}" value="#{votingCreateView.compo.voteEnd}" pattern="dd/MM/yyyy HH:mm" id="vEnd" />
<h:message for="vEnd" />
<h:outputLabel value="#{i18n['voting.create.submitStart']}:" for="sStart" />
<p:calendar validator="#{votingDateValidator.saveSStart}" value="#{votingCreateView.compo.submitStart}" pattern="dd/MM/yyyy HH:mm" id="sStart" />
<h:message for="sStart" />
<h:outputLabel value="#{i18n['voting.create.submitEnd']}:" for="sEnd" />
<p:calendar validator="#{votingDateValidator.validateSubmit}" value="#{votingCreateView.compo.submitEnd}" pattern="dd/MM/yyyy HH:mm" id="sEnd" />
<h:message for="sEnd" />
<h:commandButton action="#{votingCreateView.create}" value="#{i18n['voting.create.createButton']}" />
</h:panelGrid>
</h:form>
</div>
<div class="clearfix"></div>
</ui:define> </ui:define>
</ui:composition> </ui:composition>
</h:body> </h:body>
......
...@@ -2,23 +2,26 @@ ...@@ -2,23 +2,26 @@
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:users="http://java.sun.com/jsf/composite/cditools/user" <html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:users="http://java.sun.com/jsf/composite/cditools/user"
xmlns:tools="http://java.sun.com/jsf/composite/cditools" xmlns:f="http://java.sun.com/jsf/core" xmlns:p="http://primefaces.org/ui"> xmlns:compo="http://java.sun.com/jsf/composite/cditools/compo" xmlns:tools="http://java.sun.com/jsf/composite/cditools" xmlns:f="http://java.sun.com/jsf/core" xmlns:p="http://primefaces.org/ui">
<h:body> <h:body>
<ui:composition template="#{sessionHandler.template}"> <ui:composition template="#{sessionHandler.template}">
<f:metadata> <f:metadata>
<f:viewParam name="compoId" value="#{votingDetailsView.compoId}" /> <f:viewParam name="compoId" value="#{compoMgmtView.compoId}" />
<!-- <f:viewParam name="compoId" value="#{votingDetailsView.compoId2}" /> --> <!-- <f:viewParam name="compoId" value="#{compoMgmtView.compoId2}" /> -->
<f:event type="preRenderView" listener="#{votingDetailsView.initView}" /> <f:event type="preRenderView" listener="#{compoMgmtView.initView}" />
</f:metadata> </f:metadata>
<ui:define name="content"> <ui:define name="content">
<!-- <h:outputStylesheet library="style" name="insomnia2/css/actionlog.css" /> --> <!-- <h:outputStylesheet library="style" name="insomnia2/css/actionlog.css" /> -->
<h1>Compo: #{votingDetailsView.compo.name}</h1> <h1>Compo: #{compoMgmtView.compo.name}</h1>
<p>Infoa compon entryistä</p> <p>Infoa compon entryistä</p>
<compo:editCompo commitAction="#{compoMgmtView.saveCompo}" commitValue="#{i18n['voting.create.saveCompo']}" />
<h2>#{i18n['compoMgmtView.compo.entries']}</h2>
<h:form> <h:form>
<h:dataTable styleClass="bordertable" rowClasses="roweven,rowodd" id="compolisttable" value="#{votingDetailsView.entries}" var="entry"> <h:dataTable styleClass="bordertable" rowClasses="roweven,rowodd" id="compolisttable" value="#{compoMgmtView.entries}" var="entry">
<h:column> <h:column>
<f:facet name="header"> <f:facet name="header">
<h:outputText value="Title" /> <h:outputText value="Title" />
...@@ -77,7 +80,7 @@ ...@@ -77,7 +80,7 @@
</h:column> </h:column>
</h:dataTable> </h:dataTable>
<h:commandButton action="#{votingDetailsView.saveSort}" value="#{i18n['compo.savesort']}" /> <h:commandButton action="#{compoMgmtView.saveSort}" value="#{i18n['compo.savesort']}" />
</h:form> </h:form>
......
...@@ -57,15 +57,25 @@ ...@@ -57,15 +57,25 @@
<h2> <h2>
<h:outputText value="#{i18n['compofile.download.header']}" /> <h:outputText value="#{i18n['compofile.download.header']}" />
</h2> </h2>
<h:selectOneRadio layout="pageDirection" value="#{compoFileDownloadView.file}" converter="#{compoFileConverter}"> <p:dataTable value="#{compoFileDownloadView.files}" var="fi">
<f:selectItems var="fi" value="#{compoFileDownloadView.files}" itemLabel="#{fi.fileName} / #{fi.uploaded.time}" /> <p:column headerText="#{i18n['compofile.fileName']}">
</h:selectOneRadio> <h:outputText value="#{fi.fileName}" />
<h:commandButton value="#{i18n['compofile.download']}"> </p:column>
<p:fileDownload value="#{compoFileDownloadView.dlfile}" /> <p:column headerText="#{i18n['compofile.uploadTime']}">
</h:commandButton> <h:outputText value="#{fi.uploaded.time}">
<f:convertDateTime pattern="#{sessionHandler.shortDatetimeFormat}" />
</h:outputText>
</p:column>
<p:column headerText="#{i18n['compofile.shaChecksum']}">
<h:outputText value="#{fi.hash}" />
</p:column>
<p:column>
<p:commandButton ajax="false" value="#{i18n['compofile.download']}" actionListener="#{compoFileDownloadView.selectDownloadedFile}">
<p:fileDownload value="#{compoFileDownloadView.dlfile}" />
</p:commandButton>
</p:column>
</p:dataTable>
</h:form> </h:form>
<!-- Ilmoittautuminen otettu vastaan.-->
</ui:fragment> </ui:fragment>
</ui:define> </ui:define>
......
...@@ -218,14 +218,19 @@ checkout.return.successMessage = Payment confirmed. Your products have been paid ...@@ -218,14 +218,19 @@ checkout.return.successMessage = Payment confirmed. Your products have been paid
code.inputfield = Give readercode code.inputfield = Give readercode
compo.edit = Edit compo compo.edit = Edit compo
compo.saveVotes = Save votes compo.saveVotes = Save votes
compo.savesort = Save order compo.savesort = Save order
compo.votesSaved = Votes saved compo.votesSaved = Votes saved
compoMgmtView.compo.entries = Entries
compofile.download = Download compofile.download = Download
compofile.download.header = Download file compofile.download.header = Download file
compofile.fileName = Filename
compofile.shaChecksum = SHA checksum
compofile.upload = Upload file compofile.upload = Upload file
compofile.uploadTime = Upload time
content.showContentEditLinks = Show content edit links content.showContentEditLinks = Show content edit links
...@@ -1297,6 +1302,8 @@ voting.allcompos.descri = Description ...@@ -1297,6 +1302,8 @@ voting.allcompos.descri = Description
voting.allcompos.description = List of all compos and theirs information. voting.allcompos.description = List of all compos and theirs information.
voting.allcompos.endTime = End time voting.allcompos.endTime = End time
voting.allcompos.header = All compos voting.allcompos.header = All compos
voting.allcompos.hidden = Hidden
voting.allcompos.holdVoting = Hold voting
voting.allcompos.maxParts = Max participants voting.allcompos.maxParts = Max participants
voting.allcompos.name = Name voting.allcompos.name = Name
voting.allcompos.startTime = Start time voting.allcompos.startTime = Start time
...@@ -1322,8 +1329,11 @@ voting.create.createButton = Create ...@@ -1322,8 +1329,11 @@ voting.create.createButton = Create
voting.create.dateValidatorEndDate = End time before start time. voting.create.dateValidatorEndDate = End time before start time.
voting.create.description = Description voting.create.description = Description
voting.create.header = Create compo voting.create.header = Create compo
voting.create.hidden = Hidden
voting.create.holdVoting = Hold voting
voting.create.maxParticipants = Max participants voting.create.maxParticipants = Max participants
voting.create.name = Name voting.create.name = Name
voting.create.saveCompo = Save compo
voting.create.submitEnd = Submit close voting.create.submitEnd = Submit close
voting.create.submitStart = Submit start voting.create.submitStart = Submit start
voting.create.voteEnd = Voting close voting.create.voteEnd = Voting close
......
...@@ -220,14 +220,19 @@ checkout.return.successMessage = Maksu vahvistettu. Tuotteet on maksettu. Voit s ...@@ -220,14 +220,19 @@ checkout.return.successMessage = Maksu vahvistettu. Tuotteet on maksettu. Voit s
code.inputfield = Sy\u00F6t\u00E4 viivakoodi code.inputfield = Sy\u00F6t\u00E4 viivakoodi
compo.edit = Muokkaa compoa compo.edit = Muokkaa compoa
compo.saveVotes = Tallenna \u00E4\u00E4net compo.saveVotes = Tallenna \u00E4\u00E4net
compo.savesort = Tallenna j\u00E4rjestys compo.savesort = Tallenna j\u00E4rjestys
compo.votesSaved = \u00C4\u00E4net tallennettu compo.votesSaved = \u00C4\u00E4net tallennettu
compofile.download = lataa compoMgmtView.compo.entries = Entryt
compofile.download = Lataa
compofile.download.header = Lataa tiedosto compofile.download.header = Lataa tiedosto
compofile.fileName = Tiedoston nimi
compofile.shaChecksum = SHA tarkistesumma
compofile.upload = L\u00E4het\u00E4 tiedosto compofile.upload = L\u00E4het\u00E4 tiedosto
compofile.uploadTime = Tallennusaika
content.showContentEditLinks = N\u00E4yt\u00E4 sis\u00E4ll\u00F6nmuokkauslinkit content.showContentEditLinks = N\u00E4yt\u00E4 sis\u00E4ll\u00F6nmuokkauslinkit
...@@ -1278,6 +1283,8 @@ voting.allcompos.descri = Kuvaus ...@@ -1278,6 +1283,8 @@ voting.allcompos.descri = Kuvaus
voting.allcompos.description = Compojen informaatiot. voting.allcompos.description = Compojen informaatiot.
voting.allcompos.endTime = Lopetusaika voting.allcompos.endTime = Lopetusaika
voting.allcompos.header = Kaikki compot voting.allcompos.header = Kaikki compot
voting.allcompos.hidden = Piilotettu
voting.allcompos.holdVoting = Hold voting
voting.allcompos.maxParts = Max osallistujam\u00E4\u00E4r\u00E4 voting.allcompos.maxParts = Max osallistujam\u00E4\u00E4r\u00E4
voting.allcompos.name = Nimi voting.allcompos.name = Nimi
voting.allcompos.startTime = Aloitusaika voting.allcompos.startTime = Aloitusaika
...@@ -1303,8 +1310,11 @@ voting.create.createButton = Luo ...@@ -1303,8 +1310,11 @@ voting.create.createButton = Luo
voting.create.dateValidatorEndDate = Loppumisaika ennen alkua. voting.create.dateValidatorEndDate = Loppumisaika ennen alkua.
voting.create.description = Kuvaus voting.create.description = Kuvaus
voting.create.header = Compon luonti voting.create.header = Compon luonti
voting.create.hidden = Piilotettu
voting.create.holdVoting = Hold voting
voting.create.maxParticipants = Max osallistujat voting.create.maxParticipants = Max osallistujat
voting.create.name = Nimi voting.create.name = Nimi
voting.create.saveCompo = Tallenna
voting.create.submitEnd = Submit kiinni voting.create.submitEnd = Submit kiinni
voting.create.submitStart = Submit auki voting.create.submitStart = Submit auki
voting.create.voteEnd = \u00C4\u00E4nestys kiinni voting.create.voteEnd = \u00C4\u00E4nestys kiinni
......
...@@ -46,6 +46,12 @@ public class CompoFileDownloadView extends GenericCDIView { ...@@ -46,6 +46,12 @@ public class CompoFileDownloadView extends GenericCDIView {
return file; return file;
} }
public void selectDownloadedFile()
{
file = files.getRowData();
dlfile = new DefaultStreamedContent(new ByteArrayInputStream(file.getFileData()), file.getMimeType(), file.getFileName());
}
public void setFile(CompoEntryFile file) { public void setFile(CompoEntryFile file) {
this.file = file; this.file = file;
if (file != null) if (file != null)
......
package fi.codecrew.moya.web.cdiview.voting; package fi.codecrew.moya.web.cdiview.voting;
import java.util.Date;
import javax.ejb.EJB; import javax.ejb.EJB;
import javax.enterprise.context.ConversationScoped; import javax.enterprise.context.ConversationScoped;
import javax.faces.model.ListDataModel; import javax.faces.model.ListDataModel;
...@@ -16,7 +18,7 @@ import fi.codecrew.moya.web.cdiview.GenericCDIView; ...@@ -16,7 +18,7 @@ import fi.codecrew.moya.web.cdiview.GenericCDIView;
@Named @Named
@ConversationScoped @ConversationScoped
public class VotingDetailsView extends GenericCDIView { public class CompoMgmtView extends GenericCDIView {
/** /**
* *
...@@ -34,12 +36,40 @@ public class VotingDetailsView extends GenericCDIView { ...@@ -34,12 +36,40 @@ public class VotingDetailsView extends GenericCDIView {
private transient ListDataModel<CompoEntry> entries; private transient ListDataModel<CompoEntry> entries;
@SuppressWarnings("unused") @SuppressWarnings("unused")
private static final Logger logger = LoggerFactory.getLogger(VotingDetailsView.class); private static final Logger logger = LoggerFactory.getLogger(CompoMgmtView.class);
public Integer getCompoId() { public Integer getCompoId() {
return compoId; return compoId;
} }
public void initCreate()
{
if (super.requirePermissions(fi.codecrew.moya.enums.apps.CompoPermission.MANAGE) && compo == null)
{
compo = new Compo();
Date now = new Date();
compo.setStartTime(now);
compo.setEndTime(now);
compo.setSubmitStart(now);
compo.setSubmitEnd(now);
compo.setVoteStart(now);
compo.setVoteEnd(now);
super.beginConversation();
}
}
public String createCompo() {
votingBean.createCompo(compo);
return "details";
}
public String saveCompo()
{
compo = votingBean.saveCompo(compo);
return null;
}
public String saveSort() public String saveSort()
{ {
for (CompoEntry e : entries) for (CompoEntry e : entries)
......
package fi.codecrew.moya.web.cdiview.voting; package fi.codecrew.moya.web.cdiview.voting;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList;
import javax.ejb.EJB; import javax.ejb.EJB;
import javax.enterprise.context.ConversationScoped; import javax.enterprise.context.ConversationScoped;
...@@ -155,8 +154,10 @@ public class CompoView extends GenericCDIView { ...@@ -155,8 +154,10 @@ public class CompoView extends GenericCDIView {
byte[] contents = null; byte[] contents = null;
if (file.getContents() != null) { if (file.getContents() != null) {
contents = file.getContents(); contents = file.getContents();
logger.info("Got file contents from .confents()");
} else { } else {
contents = new byte[(int) file.getSize()]; contents = new byte[(int) file.getSize()];
logger.info("Read {} bytes from stream in file {}", file.getSize(), file.getFileName());
try { try {
file.getInputstream().read(contents); file.getInputstream().read(contents);
} catch (IOException e) { } catch (IOException e) {
...@@ -176,21 +177,31 @@ public class CompoView extends GenericCDIView { ...@@ -176,21 +177,31 @@ public class CompoView extends GenericCDIView {
logger.info("Got file name {} length {}", getUploadedFile().getFileName(), cef.getFileData().length); logger.info("Got file name {} length {}", getUploadedFile().getFileName(), cef.getFileData().length);
cef.setFileName(getUploadedFile().getFileName()); cef.setFileName(getUploadedFile().getFileName());
cef.setMimeType(getUploadedFile().getContentType()); cef.setMimeType(getUploadedFile().getContentType());
if (getEntry().getFiles() == null) {
getEntry().setFiles(new ArrayList<CompoEntryFile>());
}
getEntry().getFiles().add(cef);
getEntry().setCurrentFile(cef);
setEntry(votbean.saveEntry(getEntry())); // getEntry().setCurrentFile(cef);
votbean.create(cef);
return null; return null;
} }
public void initAdminListView() {
if (requirePermissions(CompoPermission.MANAGE) && compolist == null) {
compolist = new ListDataModel<Compo>(votbean.getCompoList(true));
setManage(hasPermission(CompoPermission.MANAGE));
logger.info("Permission to view full compo listing.");
super.beginConversation();
}
else {
logger.info("Not enough rights to view full compo listing.");
}
}
public void initListView() { public void initListView() {
if (requirePermissions(CompoPermission.VIEW_COMPOS) && compolist == null) { if (requirePermissions(CompoPermission.VIEW_COMPOS) && compolist == null) {
compolist = new ListDataModel<Compo>(votbean.getCompoList()); compolist = new ListDataModel<Compo>(votbean.getCompoList(false));
setManage(hasPermission(CompoPermission.MANAGE)); setManage(hasPermission(CompoPermission.MANAGE));
logger.info("Permission to view full compo listing."); logger.info("Permission to view full compo listing.");
super.beginConversation(); super.beginConversation();
......
package fi.codecrew.moya.web.cdiview.voting;
import javax.ejb.EJB;
import javax.enterprise.context.ConversationScoped;
import javax.inject.Named;
import fi.codecrew.moya.beans.VotingBeanLocal;
import fi.codecrew.moya.model.Compo;
import fi.codecrew.moya.web.cdiview.GenericCDIView;
@Named
@ConversationScoped
public class VotingCreateView extends GenericCDIView {
/**
*
*/
private static final long serialVersionUID = 4677679766671547462L;
@EJB
private transient VotingBeanLocal votbean;
private Compo compo;
public void initCreate()
{
if (super.requirePermissions(fi.codecrew.moya.enums.apps.CompoPermission.MANAGE) && compo == null)
{
compo = new Compo();
super.beginConversation();
}
}
public String create() {
votbean.createCompo(compo);
return "success";
}
public Compo getCompo() {
return compo;
}
public void setCompo(Compo compo) {
this.compo = compo;
}
}
...@@ -8,7 +8,6 @@ import javax.faces.application.FacesMessage; ...@@ -8,7 +8,6 @@ import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent; import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext; import javax.faces.context.FacesContext;
import javax.faces.validator.ValidatorException; import javax.faces.validator.ValidatorException;
import javax.inject.Inject;
import javax.inject.Named; import javax.inject.Named;
import org.slf4j.Logger; import org.slf4j.Logger;
...@@ -21,10 +20,7 @@ import fi.codecrew.moya.utilities.I18n; ...@@ -21,10 +20,7 @@ import fi.codecrew.moya.utilities.I18n;
public class VotingDateValidator implements Serializable { public class VotingDateValidator implements Serializable {
private static final long serialVersionUID = 8006543114365700277L; private static final long serialVersionUID = 8006543114365700277L;
@Inject
private VotingCreateView view;
@SuppressWarnings("unused") @SuppressWarnings("unused")
private static final Logger logger = LoggerFactory.getLogger(VotingDateValidator.class); private static final Logger logger = LoggerFactory.getLogger(VotingDateValidator.class);
...@@ -75,12 +71,4 @@ public class VotingDateValidator implements Serializable { ...@@ -75,12 +71,4 @@ public class VotingDateValidator implements Serializable {
throw new ValidatorException(msg); throw new ValidatorException(msg);
} }
public VotingCreateView getView() {
return view;
}
public void setView(VotingCreateView view) {
this.view = view;
}
} }
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!