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 {
"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')",
});
dbUpdates.add(new String[] {
"alter table compos add hidden boolean default false not null"
});
}
......
......@@ -477,8 +477,9 @@ public class UserBean implements UserBeanLocal {
@Override
@RolesAllowed(UserPermission.S_INVITE_USERS)
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) {
return false;
}
......@@ -486,7 +487,7 @@ public class UserBean implements UserBeanLocal {
LanEvent ev = eventBean.getCurrentEvent();
PlaceGroup pg = new PlaceGroup(ev, Calendar.getInstance(), Calendar.getInstance(), false);
pg.setCreator(creator);
pg.setName("Invitebean");
pg.setName("Invite to " + invitemail);
String token = PasswordFunctions.generateRandomString(30, PasswordFunctions.ALL_CHARS);
pg.getMembers().add(new GroupMembership(pg, null, token));
pgfacade.create(pg);
......@@ -526,6 +527,8 @@ public class UserBean implements UserBeanLocal {
@Override
@PermitAll
public boolean createFromInviteToken(EventUser user, String token) {
if (user == null || user.getLogin() == null)
return false;
GroupMembership gm = findToken(token);
// Check that invite has not already been accepted!
if (gm == null || gm.getUser() != null || gm.getInviteAccepted() != null) {
......
......@@ -59,6 +59,7 @@ public class VotingBean implements VotingBeanLocal {
voteFacade.create(v);
}
@RolesAllowed(CompoPermission.S_MANAGE)
public void createCompo(Compo c) {
c.setEvent(eventBean.getCurrentEvent());
compoFacade.create(c);
......@@ -73,15 +74,15 @@ public class VotingBean implements VotingBeanLocal {
c.getCompoEntries().add(compoEntry);
compoFacade.flush();
compoEntryFile.setEntriesId(compoEntry);
compoEntry.getFiles().add(compoEntryFile);
// compoEntry.getFiles().add(compoEntryFile);
}
public Compo getCompoById(Integer compoId) {
return compoFacade.find(compoId);
}
public List<Compo> getCompoList() {
return compoFacade.getList();
public List<Compo> getCompoList(boolean showHidden) {
return compoFacade.getList(showHidden);
}
@Override
......@@ -129,16 +130,17 @@ public class VotingBean implements VotingBeanLocal {
return compoEntryFacade.find(entryId);
}
@Override
public CompoEntry findEntryWithFiles(Integer entryId) {
CompoEntry ret = compoEntryFacade.find(entryId);
logger.debug("Found files {}", ret.getFiles().size());
return ret;
}
// @Override
// public CompoEntry findEntryWithFiles(Integer entryId) {
// CompoEntry ret = compoEntryFacade.find(entryId);
// // logger.debug("Found files {}", ret.getFiles().size());
//
// return ret;
//
// }
@Override
@RolesAllowed(CompoPermission.S_MANAGE)
public CompoEntry saveSort(CompoEntry e) {
CompoEntry entry = compoEntryFacade.find(e.getId());
entry.setSort(e.getSort());
......@@ -177,4 +179,15 @@ public class VotingBean implements VotingBeanLocal {
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;
import java.util.ArrayList;
import java.util.List;
import javax.ejb.EJB;
......@@ -7,11 +8,12 @@ import javax.ejb.LocalBean;
import javax.ejb.Stateless;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import fi.codecrew.moya.model.Compo_;
import fi.codecrew.moya.beans.EventBeanLocal;
import fi.codecrew.moya.model.Compo;
import fi.codecrew.moya.model.Compo_;
@Stateless
@LocalBean
......@@ -23,11 +25,17 @@ public class CompoFacade extends IntegerPkGenericFacade<Compo> {
super(Compo.class);
}
public List<Compo> getList() {
public List<Compo> getList(boolean showHidden) {
CriteriaBuilder cb = getEm().getCriteriaBuilder();
CriteriaQuery<Compo> cq = cb.createQuery(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)));
List<Compo> ret = getEm().createQuery(cq).getResultList();
return ret;
......
......@@ -9,10 +9,10 @@ import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Root;
import fi.codecrew.moya.model.OrgRole_;
import fi.codecrew.moya.beans.EventBeanLocal;
import fi.codecrew.moya.model.EventOrganiser;
import fi.codecrew.moya.model.OrgRole;
import fi.codecrew.moya.model.OrgRole_;
import fi.codecrew.moya.model.User;
/**
......@@ -29,17 +29,19 @@ public class OrgRoleFacade extends IntegerPkGenericFacade<OrgRole> {
super(OrgRole.class);
}
public List<OrgRole> findForUser(User user) {
public List<OrgRole> findForUser(User user, EventOrganiser organisation) {
CriteriaBuilder cb = getEm().getCriteriaBuilder();
CriteriaQuery<OrgRole> cq = cb.createQuery(OrgRole.class);
Root<OrgRole> root = cq.from(OrgRole.class);
cq.where(cb.equal(root.get(OrgRole_.eventOrganisation), eventBean
.getCurrentEvent().getOrganiser()), cb.isMember(user,
root.get(OrgRole_.users)));
cq.where(cb.equal(root.get(OrgRole_.eventOrganisation), organisation), cb.isMember(user, root.get(OrgRole_.users)));
return getEm().createQuery(cq).getResultList();
}
public List<OrgRole> findForUser(User user) {
return findForUser(user, eventBean.getCurrentEvent().getOrganiser());
}
public OrgRole createRole(EventOrganiser org, String roleName) {
OrgRole ret = new OrgRole();
ret.setEventOrganisation(org);
......
......@@ -15,7 +15,7 @@ public interface VotingBeanLocal {
public void addEntry(CompoEntry compoEntry, CompoEntryFile compoEntryFile);
public List<Compo> getCompoList();
public List<Compo> getCompoList(boolean showHidden);
public Compo getCompoById(Integer compoId);
......@@ -33,6 +33,10 @@ public interface VotingBeanLocal {
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 @@
package fi.codecrew.moya.model;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
......@@ -91,7 +90,18 @@ public class Compo extends GenericEntity {
* {@link #voteStart}
*/
@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.
......@@ -109,13 +119,13 @@ public class Compo extends GenericEntity {
public boolean isSubmit()
{
Calendar now = Calendar.getInstance();
Date now = new Date();
return now.after(getSubmitStart()) && now.before(getSubmitEnd());
}
public boolean isVote()
{
Calendar now = Calendar.getInstance();
Date now = new Date();
return !getHoldVoting() &&
now.after(getVoteStart()) &&
now.before(getVoteEnd());
......@@ -227,4 +237,5 @@ public class Compo extends GenericEntity {
public void setEndTime(Date endTime) {
this.endTime = endTime;
}
}
......@@ -11,7 +11,6 @@ import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
......@@ -23,7 +22,6 @@ import javax.persistence.TemporalType;
import org.eclipse.persistence.annotations.OptimisticLocking;
import org.eclipse.persistence.annotations.OptimisticLockingType;
import org.eclipse.persistence.annotations.PrivateOwned;
/**
*
......@@ -68,10 +66,11 @@ public class CompoEntry extends GenericEntity {
@OneToMany(mappedBy = "compoEntry")
private List<Vote> votes;
@PrivateOwned
@OneToMany(cascade = CascadeType.ALL, mappedBy = "entry", fetch = FetchType.LAZY)
private List<CompoEntryFile> files;
//
// @PrivateOwned
// @OneToMany(cascade = CascadeType.ALL, mappedBy = "entry", fetch =
// FetchType.LAZY)
// private List<CompoEntryFile> files;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "entry")
private List<CompoEntryParticipant> participants;
......@@ -133,14 +132,6 @@ public class CompoEntry extends GenericEntity {
this.votes = voteList;
}
public List<CompoEntryFile> getFiles() {
return files;
}
public void setFiles(List<CompoEntryFile> compoEntryFileList) {
this.files = compoEntryFileList;
}
public List<CompoEntryParticipant> getParticipants() {
return participants;
}
......@@ -174,14 +165,6 @@ public class CompoEntry extends GenericEntity {
return finalPosition;
}
public void setCurrentFile(CompoEntryFile currentFile) {
this.currentFile = currentFile;
}
public CompoEntryFile getCurrentFile() {
return currentFile;
}
public String getTitle() {
return title;
}
......
......@@ -5,10 +5,14 @@
package fi.codecrew.moya.model;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Calendar;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
......@@ -16,8 +20,11 @@ import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import org.apache.commons.codec.binary.Hex;
import org.eclipse.persistence.annotations.OptimisticLocking;
import org.eclipse.persistence.annotations.OptimisticLockingType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
*
......@@ -37,11 +44,12 @@ public class CompoEntryFile extends GenericEntity {
@Column(name = "description")
private String description;
@Column(name = "hash")
@Column(name = "hash", updatable = false)
private String hash;
@Lob
@Column(name = "file_data")
@Column(name = "file_data", updatable = false)
@Basic(fetch = FetchType.LAZY)
private byte[] fileData;
@Column(name = "uploaded", nullable = false)
......@@ -51,6 +59,7 @@ public class CompoEntryFile extends GenericEntity {
@JoinColumn(name = "entry_id", referencedColumnName = "id", nullable = false, updatable = false)
@ManyToOne(optional = false)
private CompoEntry entry;
private static final Logger logger = LoggerFactory.getLogger(CompoEntryFile.class);
public CompoEntryFile() {
super();
......@@ -98,6 +107,7 @@ public class CompoEntryFile extends GenericEntity {
public void setFileData(byte[] fileData) {
this.fileData = fileData;
this.hash = getShaChecksum(fileData);
}
public Calendar getUploaded() {
......@@ -116,4 +126,17 @@ public class CompoEntryFile extends GenericEntity {
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 @@
<h:body>
<ui:composition template="#{sessionHandler.template}">
<f:metadata>
<f:event type="preRenderView" listener="#{compoView.initListView()}" />
<f:event type="preRenderView" listener="#{compoView.initAdminListView()}" />
</f:metadata>
<ui:define name="content">
<h:outputStylesheet library="style" name="insomnia2/css/actionlog.css" />
......@@ -15,13 +15,10 @@
<p>#{i18n['voting.allcompos.description']}</p>
<h:form>
<h:dataTable styleClass="bordertable" rowClasses="roweven,rowodd" id="compolisttable" value="#{compoView.compos}" var="compo">
<h:column>
<f:facet name="header">
<h:outputText value="#{i18n['voting.allcompos.name']}" />
</f:facet>
<p:dataTable styleClass="bordertable" rowClasses="roweven,rowodd" id="compolisttable" value="#{compoView.compos}" var="compo">
<p:column headerText="#{i18n['voting.allcompos.name']}">
<h:outputText value="#{compo.name}" />
</h:column>
</p:column>
<!-- <h:column rendered="#{compoView.curEntries}"> -->
<!-- <f:facet name="header"> -->
......@@ -35,45 +32,42 @@
<!-- </f:facet> -->
<!-- <h:outputText value="#{compo.maxParticipantCount}" /> -->
<!-- </h:column> -->
<h:column>
<f:facet name="header">
<h:outputText value="#{i18n['voting.allcompos.startTime']}" />
</f:facet>
<p:column headerText="#{i18n['voting.allcompos.startTime']}">
<h:outputText value="#{compo.startTime.time}">
<f:convertDateTime pattern="#{sessionHandler.datetimeFormat}" timeZone="#{sessionHandler.timezone}" />
</h:outputText>
</h:column>
</p:column>
<h:column>
<f:facet name="header">
<h:outputText value="#{i18n['voting.allcompos.voteEnd']}" />
</f:facet>
<p:column headerText="#{i18n['voting.allcompos.voteEnd']}">
<h:outputText value="#{compo.voteEnd.time}">
<f:convertDateTime pattern="#{sessionHandler.datetimeFormat}" timeZone="#{sessionHandler.timezone}" />
</h:outputText>
</h:column>
</p:column>
<h:column>
<f:facet name="header">
<h:outputText value="#{i18n['voting.allcompos.submitEnd']}" />
</f:facet>
<p:column headerText="#{i18n['voting.allcompos.submitEnd']}">
<h:outputText value="#{compo.submitEnd.time}">
<f:convertDateTime pattern="#{sessionHandler.datetimeFormat}" timeZone="#{sessionHandler.timezone}" />
</h:outputText>
</h:column>
<h:column>
</p: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:column>
<h:column>
</p:column>
<p:column>
<h:commandButton rendered="#{compo.submit or compoView.manage}" action="#{compoView.submitEntry()}" value="#{i18n['voting.compo.submit']}" />
</h:column>
<h:column rendered="#{compoView.manage}">
</p:column>
<p:column rendered="#{compoView.manage}">
<h:link outcome="details" value="#{i18n['compo.edit']}">
<f:param name="compoId" value="#{compo.id}" />
</h:link>
</h:column>
</h:dataTable>
</p:column>
</p:dataTable>
</h:form>
</ui:define>
......
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"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"
xmlns:tools="http://java.sun.com/jsf/composite/cditools" xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui">
<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: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">
<h:body>
<ui:composition template="#{sessionHandler.template}">
<f:metadata>
<f:event type="preRenderView" listener="#{votingCreateView.initCreate}" />
<f:event type="preRenderView" listener="#{compoMgmtView.initCreate}" />
</f:metadata>
<ui:define name="content">
<!-- <h:outputStylesheet library="style" name="insomnia2/css/actionlog.css" /> -->
<h1>#{i18n['voting.create.header']}</h1>
<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"/>
<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>
<compo:editCompo commitAction="#{compoMgmtView.createCompo}" commitValue="#{i18n['voting.create.createButton']}" />
</ui:define>
</ui:composition>
......
......@@ -2,23 +2,26 @@
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"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"
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>
<ui:composition template="#{sessionHandler.template}">
<f:metadata>
<f:viewParam name="compoId" value="#{votingDetailsView.compoId}" />
<!-- <f:viewParam name="compoId" value="#{votingDetailsView.compoId2}" /> -->
<f:event type="preRenderView" listener="#{votingDetailsView.initView}" />
<f:viewParam name="compoId" value="#{compoMgmtView.compoId}" />
<!-- <f:viewParam name="compoId" value="#{compoMgmtView.compoId2}" /> -->
<f:event type="preRenderView" listener="#{compoMgmtView.initView}" />
</f:metadata>
<ui:define name="content">
<!-- <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>
<compo:editCompo commitAction="#{compoMgmtView.saveCompo}" commitValue="#{i18n['voting.create.saveCompo']}" />
<h2>#{i18n['compoMgmtView.compo.entries']}</h2>
<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>
<f:facet name="header">
<h:outputText value="Title" />
......@@ -77,7 +80,7 @@
</h:column>
</h:dataTable>
<h:commandButton action="#{votingDetailsView.saveSort}" value="#{i18n['compo.savesort']}" />
<h:commandButton action="#{compoMgmtView.saveSort}" value="#{i18n['compo.savesort']}" />
</h:form>
......
......@@ -14,12 +14,15 @@
<ui:define name="content">
<!-- <h:outputStylesheet library="style" name="insomnia2/css/actionlog.css" /> -->
<h1>#{i18n['voting.compoentryadd.title']}</h1>
<p>#{i18n['voting.compoentryadd.description']}<h:outputText value="#{compoView.compo.name}" /></p>
<p>
<h:outputText value="#{compoView.compo.description}" />
</p>
<p>
#{i18n['voting.compoentryadd.description']}
<h:outputText value="#{compoView.compo.name}" />
</p>
<p>
<h:outputText value="#{compoView.compo.description}" />
</p>
<h:form>
<!-- <h:panelGrid columns="3">
<h:panelGrid columns="3">
<h:outputLabel value="Title" for="name" />
<h:inputText value="#{compoView.entry.title}" id="name" />
<h:message for="name" />
......@@ -39,14 +42,14 @@
<h:commandButton rendered="#{!empty compoView.entry.id}" action="#{compoView.saveEntry()}" value="#{i18n['voting.compoentrysave.button']}" />
</h:panelGrid>
-->
<h:commandButton rendered="#{empty compoView.entry.id}" action="#{compoView.createEntry()}" value="Ilmoittaudu kilpailuun" />
</h:form>
<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" />
<h:commandButton action="#{compoView.submitEntryfile}" value="#{i18n['compofile.upload']}" />
</h:form>
......@@ -54,15 +57,25 @@
<h2>
<h:outputText value="#{i18n['compofile.download.header']}" />
</h2>
<h:selectOneRadio layout="pageDirection" value="#{compoFileDownloadView.file}" converter="#{compoFileConverter}">
<f:selectItems var="fi" value="#{compoFileDownloadView.files}" itemLabel="#{fi.fileName} / #{fi.uploaded.time}" />
</h:selectOneRadio>
<h:commandButton value="#{i18n['compofile.download']}">
<p:dataTable value="#{compoFileDownloadView.files}" var="fi">
<p:column headerText="#{i18n['compofile.fileName']}">
<h:outputText value="#{fi.fileName}" />
</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}" />
</h:commandButton>
</p:commandButton>
</p:column>
</p:dataTable>
</h:form>
-->
Ilmoittautuminen otettu vastaan.
</ui:fragment>
</ui:define>
......
......@@ -223,9 +223,14 @@ compo.saveVotes = Save votes
compo.savesort = Save order
compo.votesSaved = Votes saved
compoMgmtView.compo.entries = Entries
compofile.download = Download
compofile.download.header = Download file
compofile.fileName = Filename
compofile.shaChecksum = SHA checksum
compofile.upload = Upload file
compofile.uploadTime = Upload time
content.showContentEditLinks = Show content edit links
......@@ -1297,6 +1302,8 @@ voting.allcompos.descri = Description
voting.allcompos.description = List of all compos and theirs information.
voting.allcompos.endTime = End time
voting.allcompos.header = All compos
voting.allcompos.hidden = Hidden
voting.allcompos.holdVoting = Hold voting
voting.allcompos.maxParts = Max participants
voting.allcompos.name = Name
voting.allcompos.startTime = Start time
......@@ -1322,8 +1329,11 @@ voting.create.createButton = Create
voting.create.dateValidatorEndDate = End time before start time.
voting.create.description = Description
voting.create.header = Create compo
voting.create.hidden = Hidden
voting.create.holdVoting = Hold voting
voting.create.maxParticipants = Max participants
voting.create.name = Name
voting.create.saveCompo = Save compo
voting.create.submitEnd = Submit close
voting.create.submitStart = Submit start
voting.create.voteEnd = Voting close
......
......@@ -225,9 +225,14 @@ compo.saveVotes = Tallenna \u00E4\u00E4net
compo.savesort = Tallenna j\u00E4rjestys
compo.votesSaved = \u00C4\u00E4net tallennettu
compofile.download = lataa
compoMgmtView.compo.entries = Entryt
compofile.download = Lataa
compofile.download.header = Lataa tiedosto
compofile.fileName = Tiedoston nimi
compofile.shaChecksum = SHA tarkistesumma
compofile.upload = L\u00E4het\u00E4 tiedosto
compofile.uploadTime = Tallennusaika
content.showContentEditLinks = N\u00E4yt\u00E4 sis\u00E4ll\u00F6nmuokkauslinkit
......@@ -1278,6 +1283,8 @@ voting.allcompos.descri = Kuvaus
voting.allcompos.description = Compojen informaatiot.
voting.allcompos.endTime = Lopetusaika
voting.allcompos.header = Kaikki compot
voting.allcompos.hidden = Piilotettu
voting.allcompos.holdVoting = Hold voting
voting.allcompos.maxParts = Max osallistujam\u00E4\u00E4r\u00E4
voting.allcompos.name = Nimi
voting.allcompos.startTime = Aloitusaika
......@@ -1303,8 +1310,11 @@ voting.create.createButton = Luo
voting.create.dateValidatorEndDate = Loppumisaika ennen alkua.
voting.create.description = Kuvaus
voting.create.header = Compon luonti
voting.create.hidden = Piilotettu
voting.create.holdVoting = Hold voting
voting.create.maxParticipants = Max osallistujat
voting.create.name = Nimi
voting.create.saveCompo = Tallenna
voting.create.submitEnd = Submit kiinni
voting.create.submitStart = Submit auki
voting.create.voteEnd = \u00C4\u00E4nestys kiinni
......
......@@ -82,8 +82,10 @@ public class EventOrgView extends GenericCDIView {
}
public void initEdit() {
if ((super.requirePermissions(eventorgbean.hasOrgPermission(orgId) || user.getUser().isSuperadmin())) && eventorg == null) {
if (orgId == null) {
orgId = eventbean.getCurrentEvent().getOrganiser().getId();
}
if (super.requirePermissions(eventorgbean.hasOrgPermission(orgId) || user.getUser().isSuperadmin()) && eventorg == null) {
eventorg = eventorgbean.find(orgId);
super.beginConversation();
}
......
......@@ -46,6 +46,12 @@ public class CompoFileDownloadView extends GenericCDIView {
return file;
}
public void selectDownloadedFile()
{
file = files.getRowData();
dlfile = new DefaultStreamedContent(new ByteArrayInputStream(file.getFileData()), file.getMimeType(), file.getFileName());
}
public void setFile(CompoEntryFile file) {
this.file = file;
if (file != null)
......
package fi.codecrew.moya.web.cdiview.voting;
import java.util.Date;
import javax.ejb.EJB;
import javax.enterprise.context.ConversationScoped;
import javax.faces.model.ListDataModel;
......@@ -16,7 +18,7 @@ import fi.codecrew.moya.web.cdiview.GenericCDIView;
@Named
@ConversationScoped
public class VotingDetailsView extends GenericCDIView {
public class CompoMgmtView extends GenericCDIView {
/**
*
......@@ -34,12 +36,40 @@ public class VotingDetailsView extends GenericCDIView {
private transient ListDataModel<CompoEntry> entries;
@SuppressWarnings("unused")
private static final Logger logger = LoggerFactory.getLogger(VotingDetailsView.class);
private static final Logger logger = LoggerFactory.getLogger(CompoMgmtView.class);
public Integer getCompoId() {
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()
{
for (CompoEntry e : entries)
......
package fi.codecrew.moya.web.cdiview.voting;
import java.io.IOException;
import java.util.ArrayList;
import javax.ejb.EJB;
import javax.enterprise.context.ConversationScoped;
......@@ -155,8 +154,10 @@ public class CompoView extends GenericCDIView {
byte[] contents = null;
if (file.getContents() != null) {
contents = file.getContents();
logger.info("Got file contents from .confents()");
} else {
contents = new byte[(int) file.getSize()];
logger.info("Read {} bytes from stream in file {}", file.getSize(), file.getFileName());
try {
file.getInputstream().read(contents);
} catch (IOException e) {
......@@ -176,21 +177,31 @@ public class CompoView extends GenericCDIView {
logger.info("Got file name {} length {}", getUploadedFile().getFileName(), cef.getFileData().length);
cef.setFileName(getUploadedFile().getFileName());
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;
}
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() {
if (requirePermissions(CompoPermission.VIEW_COMPOS) && compolist == null) {
compolist = new ListDataModel<Compo>(votbean.getCompoList());
compolist = new ListDataModel<Compo>(votbean.getCompoList(false));
setManage(hasPermission(CompoPermission.MANAGE));
logger.info("Permission to view full compo listing.");
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;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.validator.ValidatorException;
import javax.inject.Inject;
import javax.inject.Named;
import org.slf4j.Logger;
......@@ -22,9 +21,6 @@ public class VotingDateValidator implements Serializable {
private static final long serialVersionUID = 8006543114365700277L;
@Inject
private VotingCreateView view;
@SuppressWarnings("unused")
private static final Logger logger = LoggerFactory.getLogger(VotingDateValidator.class);
......@@ -75,12 +71,4 @@ public class VotingDateValidator implements Serializable {
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!