Commit 2fb04eec by Juho Juopperi

Merge branch 'compostuff' into 'master'

Compostuff
2 parents e0c7dc90 7bc2dc0c
Showing with 317 additions and 227 deletions
...@@ -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"
});
} }
......
...@@ -477,8 +477,9 @@ public class UserBean implements UserBeanLocal { ...@@ -477,8 +477,9 @@ public class UserBean implements UserBeanLocal {
@Override @Override
@RolesAllowed(UserPermission.S_INVITE_USERS) @RolesAllowed(UserPermission.S_INVITE_USERS)
public boolean invite(String invitemail, String url) { public boolean invite(String invitemail, String url) {
invitemail = invitemail.trim();
List<User> usercheck = userFacade.findByEmail(invitemail.trim()); List<User> usercheck = userFacade.findByEmail(invitemail);
if (usercheck.size() > 0) { if (usercheck.size() > 0) {
return false; return false;
} }
...@@ -486,7 +487,7 @@ public class UserBean implements UserBeanLocal { ...@@ -486,7 +487,7 @@ public class UserBean implements UserBeanLocal {
LanEvent ev = eventBean.getCurrentEvent(); LanEvent ev = eventBean.getCurrentEvent();
PlaceGroup pg = new PlaceGroup(ev, Calendar.getInstance(), Calendar.getInstance(), false); PlaceGroup pg = new PlaceGroup(ev, Calendar.getInstance(), Calendar.getInstance(), false);
pg.setCreator(creator); pg.setCreator(creator);
pg.setName("Invitebean"); pg.setName("Invite to " + invitemail);
String token = PasswordFunctions.generateRandomString(30, PasswordFunctions.ALL_CHARS); String token = PasswordFunctions.generateRandomString(30, PasswordFunctions.ALL_CHARS);
pg.getMembers().add(new GroupMembership(pg, null, token)); pg.getMembers().add(new GroupMembership(pg, null, token));
pgfacade.create(pg); pgfacade.create(pg);
...@@ -526,6 +527,8 @@ public class UserBean implements UserBeanLocal { ...@@ -526,6 +527,8 @@ public class UserBean implements UserBeanLocal {
@Override @Override
@PermitAll @PermitAll
public boolean createFromInviteToken(EventUser user, String token) { public boolean createFromInviteToken(EventUser user, String token) {
if (user == null || user.getLogin() == null)
return false;
GroupMembership gm = findToken(token); GroupMembership gm = findToken(token);
// Check that invite has not already been accepted! // Check that invite has not already been accepted!
if (gm == null || gm.getUser() != null || gm.getInviteAccepted() != null) { if (gm == null || gm.getUser() != null || gm.getInviteAccepted() != 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;
......
...@@ -9,10 +9,10 @@ import javax.persistence.criteria.CriteriaBuilder; ...@@ -9,10 +9,10 @@ import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery; import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Root; import javax.persistence.criteria.Root;
import fi.codecrew.moya.model.OrgRole_;
import fi.codecrew.moya.beans.EventBeanLocal; import fi.codecrew.moya.beans.EventBeanLocal;
import fi.codecrew.moya.model.EventOrganiser; import fi.codecrew.moya.model.EventOrganiser;
import fi.codecrew.moya.model.OrgRole; import fi.codecrew.moya.model.OrgRole;
import fi.codecrew.moya.model.OrgRole_;
import fi.codecrew.moya.model.User; import fi.codecrew.moya.model.User;
/** /**
...@@ -29,17 +29,19 @@ public class OrgRoleFacade extends IntegerPkGenericFacade<OrgRole> { ...@@ -29,17 +29,19 @@ public class OrgRoleFacade extends IntegerPkGenericFacade<OrgRole> {
super(OrgRole.class); super(OrgRole.class);
} }
public List<OrgRole> findForUser(User user) { public List<OrgRole> findForUser(User user, EventOrganiser organisation) {
CriteriaBuilder cb = getEm().getCriteriaBuilder(); CriteriaBuilder cb = getEm().getCriteriaBuilder();
CriteriaQuery<OrgRole> cq = cb.createQuery(OrgRole.class); CriteriaQuery<OrgRole> cq = cb.createQuery(OrgRole.class);
Root<OrgRole> root = cq.from(OrgRole.class); Root<OrgRole> root = cq.from(OrgRole.class);
cq.where(cb.equal(root.get(OrgRole_.eventOrganisation), eventBean cq.where(cb.equal(root.get(OrgRole_.eventOrganisation), organisation), cb.isMember(user, root.get(OrgRole_.users)));
.getCurrentEvent().getOrganiser()), cb.isMember(user,
root.get(OrgRole_.users)));
return getEm().createQuery(cq).getResultList(); return getEm().createQuery(cq).getResultList();
} }
public List<OrgRole> findForUser(User user) {
return findForUser(user, eventBean.getCurrentEvent().getOrganiser());
}
public OrgRole createRole(EventOrganiser org, String roleName) { public OrgRole createRole(EventOrganiser org, String roleName) {
OrgRole ret = new OrgRole(); OrgRole ret = new OrgRole();
ret.setEventOrganisation(org); ret.setEventOrganisation(org);
......
...@@ -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);
} }
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
package fi.codecrew.moya.model; package fi.codecrew.moya.model;
import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
...@@ -91,7 +90,18 @@ public class Compo extends GenericEntity { ...@@ -91,7 +90,18 @@ public class Compo extends GenericEntity {
* {@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)
private boolean hidden = false;
public boolean isHidden() {
return hidden;
}
public void setHidden(boolean hidden) {
this.hidden = hidden;
}
/** /**
* Entries submitted to participate this compo. * Entries submitted to participate this compo.
...@@ -109,13 +119,13 @@ public class Compo extends GenericEntity { ...@@ -109,13 +119,13 @@ public class Compo extends GenericEntity {
public boolean isSubmit() public boolean isSubmit()
{ {
Calendar now = Calendar.getInstance(); Date now = new Date();
return now.after(getSubmitStart()) && now.before(getSubmitEnd()); return now.after(getSubmitStart()) && now.before(getSubmitEnd());
} }
public boolean isVote() public boolean isVote()
{ {
Calendar now = Calendar.getInstance(); Date now = new Date();
return !getHoldVoting() && return !getHoldVoting() &&
now.after(getVoteStart()) && now.after(getVoteStart()) &&
now.before(getVoteEnd()); now.before(getVoteEnd());
...@@ -227,4 +237,5 @@ public class Compo extends GenericEntity { ...@@ -227,4 +237,5 @@ public class Compo extends GenericEntity {
public void setEndTime(Date endTime) { public void setEndTime(Date endTime) {
this.endTime = 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;
/** /**
* *
...@@ -68,10 +66,11 @@ public class CompoEntry extends GenericEntity { ...@@ -68,10 +66,11 @@ public class CompoEntry extends GenericEntity {
@OneToMany(mappedBy = "compoEntry") @OneToMany(mappedBy = "compoEntry")
private List<Vote> votes; private List<Vote> votes;
//
@PrivateOwned // @PrivateOwned
@OneToMany(cascade = CascadeType.ALL, mappedBy = "entry", fetch = FetchType.LAZY) // @OneToMany(cascade = CascadeType.ALL, mappedBy = "entry", fetch =
private List<CompoEntryFile> files; // FetchType.LAZY)
// private List<CompoEntryFile> files;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "entry") @OneToMany(cascade = CascadeType.ALL, mappedBy = "entry")
private List<CompoEntryParticipant> participants; private List<CompoEntryParticipant> participants;
...@@ -133,14 +132,6 @@ public class CompoEntry extends GenericEntity { ...@@ -133,14 +132,6 @@ public class CompoEntry extends GenericEntity {
this.votes = voteList; this.votes = voteList;
} }
public List<CompoEntryFile> getFiles() {
return files;
}
public void setFiles(List<CompoEntryFile> compoEntryFileList) {
this.files = compoEntryFileList;
}
public List<CompoEntryParticipant> getParticipants() { public List<CompoEntryParticipant> getParticipants() {
return participants; return participants;
} }
...@@ -174,14 +165,6 @@ public class CompoEntry extends GenericEntity { ...@@ -174,14 +165,6 @@ public class CompoEntry extends GenericEntity {
return finalPosition; return finalPosition;
} }
public void setCurrentFile(CompoEntryFile currentFile) {
this.currentFile = currentFile;
}
public CompoEntryFile getCurrentFile() {
return currentFile;
}
public String getTitle() { public String getTitle() {
return title; return title;
} }
......
...@@ -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;
/** /**
* *
...@@ -37,11 +44,12 @@ public class CompoEntryFile extends GenericEntity { ...@@ -37,11 +44,12 @@ public class CompoEntryFile extends GenericEntity {
@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)
@Basic(fetch = FetchType.LAZY)
private byte[] fileData; private byte[] fileData;
@Column(name = "uploaded", nullable = false) @Column(name = "uploaded", nullable = false)
...@@ -51,6 +59,7 @@ public class CompoEntryFile extends GenericEntity { ...@@ -51,6 +59,7 @@ public class CompoEntryFile extends GenericEntity {
@JoinColumn(name = "entry_id", referencedColumnName = "id", nullable = false, updatable = false) @JoinColumn(name = "entry_id", referencedColumnName = "id", nullable = false, updatable = false)
@ManyToOne(optional = false) @ManyToOne(optional = false)
private CompoEntry entry; private CompoEntry entry;
private static final Logger logger = LoggerFactory.getLogger(CompoEntryFile.class);
public CompoEntryFile() { public CompoEntryFile() {
super(); super();
...@@ -98,6 +107,7 @@ public class CompoEntryFile extends GenericEntity { ...@@ -98,6 +107,7 @@ public class CompoEntryFile extends GenericEntity {
public void setFileData(byte[] fileData) { public void setFileData(byte[] fileData) {
this.fileData = fileData; this.fileData = fileData;
this.hash = getShaChecksum(fileData);
} }
public Calendar getUploaded() { public Calendar getUploaded() {
...@@ -116,4 +126,17 @@ public class CompoEntryFile extends GenericEntity { ...@@ -116,4 +126,17 @@ public class CompoEntryFile extends GenericEntity {
this.entry = 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> <compo:editCompo commitAction="#{compoMgmtView.createCompo}" commitValue="#{i18n['voting.create.createButton']}" />
<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"/>
<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>
......
...@@ -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>
......
...@@ -14,12 +14,15 @@ ...@@ -14,12 +14,15 @@
<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>#{i18n['voting.compoentryadd.title']}</h1> <h1>#{i18n['voting.compoentryadd.title']}</h1>
<p>#{i18n['voting.compoentryadd.description']}<h:outputText value="#{compoView.compo.name}" /></p> <p>
<p> #{i18n['voting.compoentryadd.description']}
<h:outputText value="#{compoView.compo.description}" /> <h:outputText value="#{compoView.compo.name}" />
</p> </p>
<p>
<h:outputText value="#{compoView.compo.description}" />
</p>
<h:form> <h:form>
<!-- <h:panelGrid columns="3"> <h:panelGrid columns="3">
<h:outputLabel value="Title" for="name" /> <h:outputLabel value="Title" for="name" />
<h:inputText value="#{compoView.entry.title}" id="name" /> <h:inputText value="#{compoView.entry.title}" id="name" />
<h:message for="name" /> <h:message for="name" />
...@@ -39,14 +42,14 @@ ...@@ -39,14 +42,14 @@
<h:commandButton rendered="#{!empty compoView.entry.id}" action="#{compoView.saveEntry()}" value="#{i18n['voting.compoentrysave.button']}" /> <h:commandButton rendered="#{!empty compoView.entry.id}" action="#{compoView.saveEntry()}" value="#{i18n['voting.compoentrysave.button']}" />
</h:panelGrid> </h:panelGrid>
-->
<h:commandButton rendered="#{empty compoView.entry.id}" action="#{compoView.createEntry()}" value="Ilmoittaudu kilpailuun" /> <h:commandButton rendered="#{empty compoView.entry.id}" action="#{compoView.createEntry()}" value="Ilmoittaudu kilpailuun" />
</h:form> </h:form>
<ui:fragment rendered="#{!empty compoView.entry.id}"> <ui:fragment rendered="#{!empty compoView.entry.id}">
<!-- <h:form enctype="multipart/form-data"> <h:form enctype="multipart/form-data">
<p:fileUpload value="#{compoView.uploadedFile}" id="uploadedfile" mode="simple" /> <p:fileUpload value="#{compoView.uploadedFile}" id="uploadedfile" mode="simple" />
<h:commandButton action="#{compoView.submitEntryfile}" value="#{i18n['compofile.upload']}" /> <h:commandButton action="#{compoView.submitEntryfile}" value="#{i18n['compofile.upload']}" />
</h:form> </h:form>
...@@ -54,15 +57,25 @@ ...@@ -54,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:column headerText="#{i18n['compofile.uploadTime']}">
<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:fileDownload value="#{compoFileDownloadView.dlfile}" />
</h:commandButton> </p:commandButton>
</p:column>
</p:dataTable>
</h:form> </h:form>
-->
Ilmoittautuminen otettu vastaan.
</ui:fragment> </ui:fragment>
</ui:define> </ui:define>
......
...@@ -223,9 +223,14 @@ compo.saveVotes = Save votes ...@@ -223,9 +223,14 @@ 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
......
...@@ -225,9 +225,14 @@ compo.saveVotes = Tallenna \u00E4\u00E4net ...@@ -225,9 +225,14 @@ 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
......
...@@ -82,8 +82,10 @@ public class EventOrgView extends GenericCDIView { ...@@ -82,8 +82,10 @@ public class EventOrgView extends GenericCDIView {
} }
public void initEdit() { public void initEdit() {
if (orgId == null) {
if ((super.requirePermissions(eventorgbean.hasOrgPermission(orgId) || user.getUser().isSuperadmin())) && eventorg == null) { orgId = eventbean.getCurrentEvent().getOrganiser().getId();
}
if (super.requirePermissions(eventorgbean.hasOrgPermission(orgId) || user.getUser().isSuperadmin()) && eventorg == null) {
eventorg = eventorgbean.find(orgId); eventorg = eventorgbean.find(orgId);
super.beginConversation(); super.beginConversation();
} }
......
...@@ -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;
...@@ -22,9 +21,6 @@ public class VotingDateValidator implements Serializable { ...@@ -22,9 +21,6 @@ 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!