Commit 5d3fcbb0 by Antti Tonkyra

Merge branch 'master' of dev.insomnia.fi:/data/bortal

2 parents 8fdabbb1 62422ab9
package fi.insomnia.bortal.beans; package fi.insomnia.bortal.beans;
import javax.ejb.Local; import javax.ejb.Local;
@Local import fi.insomnia.bortal.model.Compo;
public interface VotingBeanLocal {
@Local
} public interface VotingBeanLocal {
public void createCompo(Compo c);
}
...@@ -51,7 +51,7 @@ public class Compo extends GenericEntity { ...@@ -51,7 +51,7 @@ public class Compo extends GenericEntity {
@Temporal(TemporalType.TIMESTAMP) @Temporal(TemporalType.TIMESTAMP)
private Calendar startTime; private Calendar startTime;
@Column(name = "compo_start") @Column(name = "compo_end")
@Temporal(TemporalType.TIMESTAMP) @Temporal(TemporalType.TIMESTAMP)
private Calendar endTime; private Calendar endTime;
......
<!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:users="http://java.sun.com/jsf/composite/cditools/user" 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:tools="http://java.sun.com/jsf/composite/cditools" xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui"> xmlns:p="http://primefaces.org/ui">
<h:body> <h:body>
<ui:composition template="/layout/#{sessionHandler.layout}/template.xhtml"> <ui:composition template="/layout/#{sessionHandler.layout}/template.xhtml">
<f:metadata> <f:metadata>
<!-- f:event type="preRenderView" listener="#{newsListView.initView}" /--> <!-- f:event type="preRenderView" listener="#{newsListView.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>#{i18n['voting.create.header']}</h1> <h1>#{i18n['voting.create.header']}</h1>
<p>#{i18n['voting.create.description']}</p> <p>#{i18n['voting.create.description']}</p>
<div> <div>
<h:form> <h:form>
<h:panelGrid columns="3"> <h:panelGrid columns="3">
<h:outputLabel value="#{i18n['voting.create.name']}:" for="name"/> <h:outputLabel value="#{i18n['voting.create.name']}:" for="name"/>
<h:inputText value="#{votingCreateView.name}" id="name" /> <h:inputText value="#{votingCreateView.name}" id="name" />
<h:message for="name" /> <h:message for="name" />
<h:outputLabel value="#{i18n['voting.create.description']}:" for="desc"/> <h:outputLabel value="#{i18n['voting.create.description']}:" for="desc"/>
<h:inputText value="#{votingCreateView.description}" id="desc" /> <h:inputText value="#{votingCreateView.description}" id="desc" />
<h:message for="desc" /> <h:message for="desc" />
<h:outputLabel value="#{i18n['voting.create.maxParticipants']}:" for="maxPar" /> <h:outputLabel value="#{i18n['voting.create.maxParticipants']}:" for="maxPar" />
<h:inputText value="#{votingCreateView.maxParticipants}" id="maxPar" /> <h:inputText value="#{votingCreateView.maxParticipants}" id="maxPar" />
<h:message for="maxPar" /> <h:message for="maxPar" />
<h:outputLabel value="#{i18n['voting.create.compoStart']}:" for="cStart" /> <h:outputLabel value="#{i18n['voting.create.compoStart']}:" for="cStart" />
<p:calendar validator="#{votingDateValidator.saveCStart}" value="#{votingCreateView.compoStart}" pattern="dd/MM/yyyy HH:mm" id="cStart" /> <p:calendar validator="#{votingDateValidator.saveCStart}" value="#{votingCreateView.compoStart}" pattern="dd/MM/yyyy HH:mm" id="cStart" />
<h:message for="cStart" /> <h:message for="cStart" />
<h:outputLabel value="#{i18n['voting.create.compoEnd']}:" for="cEnd"/> <h:outputLabel value="#{i18n['voting.create.compoEnd']}:" for="cEnd"/>
<p:calendar validator="#{votingDateValidator.validateCompo}" value="#{votingCreateView.compoEnd}" pattern="dd/MM/yyyy HH:mm" id="cEnd" /> <p:calendar validator="#{votingDateValidator.validateCompo}" value="#{votingCreateView.compoEnd}" pattern="dd/MM/yyyy HH:mm" id="cEnd" />
<h:message for="cEnd" /> <h:message for="cEnd" />
<h:outputLabel value="#{i18n['voting.create.voteStart']}:" for="vStart" /> <h:outputLabel value="#{i18n['voting.create.voteStart']}:" for="vStart" />
<p:calendar validator="#{votingDateValidator.saveVStart}" value="#{votingCreateView.voteStart}" pattern="dd/MM/yyyy HH:mm" id="vStart" /> <p:calendar validator="#{votingDateValidator.saveVStart}" value="#{votingCreateView.voteStart}" pattern="dd/MM/yyyy HH:mm" id="vStart" />
<h:message for="vStart" /> <h:message for="vStart" />
<h:outputLabel value="#{i18n['voting.create.voteEnd']}:" for="vEnd" /> <h:outputLabel value="#{i18n['voting.create.voteEnd']}:" for="vEnd" />
<p:calendar validator="#{votingDateValidator.validateVote}" value="#{votingCreateView.voteEnd}" pattern="dd/MM/yyyy HH:mm" id="vEnd" /> <p:calendar validator="#{votingDateValidator.validateVote}" value="#{votingCreateView.voteEnd}" pattern="dd/MM/yyyy HH:mm" id="vEnd" />
<h:message for="vEnd" /> <h:message for="vEnd" />
<h:outputLabel value="#{i18n['voting.create.submitStart']}:" for="sStart" /> <h:outputLabel value="#{i18n['voting.create.submitStart']}:" for="sStart" />
<p:calendar validator="#{votingDateValidator.saveSStart}" value="#{votingCreateView.submitStart}" pattern="dd/MM/yyyy HH:mm" id="sStart" /> <p:calendar validator="#{votingDateValidator.saveSStart}" value="#{votingCreateView.submitStart}" pattern="dd/MM/yyyy HH:mm" id="sStart" />
<h:message for="sStart" /> <h:message for="sStart" />
<h:outputLabel value="#{i18n['voting.create.submitEnd']}:" for="sEnd" /> <h:outputLabel value="#{i18n['voting.create.submitEnd']}:" for="sEnd" />
<p:calendar validator="#{votingDateValidator.validateSubmit}" value="#{votingCreateView.submitEnd}" pattern="dd/MM/yyyy HH:mm" id="sEnd" /> <p:calendar validator="#{votingDateValidator.validateSubmit}" value="#{votingCreateView.submitEnd}" pattern="dd/MM/yyyy HH:mm" id="sEnd" />
<h:message for="sEnd" /> <h:message for="sEnd" />
<h:commandButton value="#{i18n['voting.create.createButton']}" /> <h:commandButton action="#{votingCreateView.send}" value="#{i18n['voting.create.createButton']}" />
</h:panelGrid> </h:panelGrid>
</h:form> </h:form>
</div> </div>
<div class="clearfix"></div> <div class="clearfix"></div>
</ui:define> </ui:define>
</ui:composition> </ui:composition>
</h:body> </h:body>
</html> </html>
\ No newline at end of file
package fi.insomnia.bortal.web.cdiview.voting; package fi.insomnia.bortal.web.cdiview.voting;
import java.util.Date; import java.util.Calendar;
import java.util.Date;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean; import javax.ejb.EJB;
import javax.faces.bean.RequestScoped; import javax.enterprise.context.ConversationScoped;
import javax.inject.Named; import javax.enterprise.context.RequestScoped;
import javax.validation.constraints.Min; import javax.faces.bean.ManagedBean;
import javax.validation.constraints.Size; import javax.inject.Named;
import javax.validation.constraints.Min;
import org.hibernate.validator.constraints.Length; import javax.validation.constraints.Size;
import fi.insomnia.bortal.beans.VotingBeanLocal; import org.hibernate.validator.constraints.Length;
import fi.insomnia.bortal.web.cdiview.GenericCDIView;
import fi.insomnia.bortal.beans.VotingBeanLocal;
@ManagedBean import fi.insomnia.bortal.model.Compo;
@Named import fi.insomnia.bortal.web.cdiview.GenericCDIView;
@RequestScoped
public class VotingCreateView extends GenericCDIView { @ManagedBean
@Named
/** @RequestScoped
* public class VotingCreateView extends GenericCDIView {
*/
private static final long serialVersionUID = 4677679766671547462L; /**
*
@EJB */
private VotingBeanLocal votbean; private static final long serialVersionUID = 4677679766671547462L;
@Size(min=4, message="{voting.create.nameError}") @EJB
private String name; private VotingBeanLocal votbean;
private String description;
@Min(value=1, message="{voting.create.participantsError}") @Size(min=4, message="{voting.create.nameError}")
private Integer maxParticipants; private String name;
private Date compoStart; private String description;
@Min(value=1, message="{voting.create.participantsError}")
private Date compoEnd; private Integer maxParticipants;
private Date voteStart;
private Date voteEnd; private Date compoStart;
private Date submitStart; private Date compoEnd;
private Date submitEnd; private Date voteStart;
private Date voteEnd;
public String getName() { private Date submitStart;
return name; private Date submitEnd;
}
public void setName(String name) { public String getName() {
this.name = name; return name;
} }
public String getDescription() { public void setName(String name) {
return description; this.name = name;
} }
public void setDescription(String description) { public String getDescription() {
this.description = description; return description;
} }
public Integer getMaxParticipants() { public void setDescription(String description) {
return maxParticipants; this.description = description;
} }
public void setMaxParticipants(Integer maxParticipants) { public Integer getMaxParticipants() {
this.maxParticipants = maxParticipants; return maxParticipants;
} }
public Date getCompoStart() { public void setMaxParticipants(Integer maxParticipants) {
return compoStart; this.maxParticipants = maxParticipants;
} }
public void setCompoStart(Date compoStart) { public Date getCompoStart() {
this.compoStart = compoStart; return compoStart;
} }
public Date getCompoEnd() { public void setCompoStart(Date compoStart) {
return compoEnd; this.compoStart = compoStart;
} }
public void setCompoEnd(Date compoEnd) { public Date getCompoEnd() {
this.compoEnd = compoEnd; return compoEnd;
} }
public Date getVoteStart() { public void setCompoEnd(Date compoEnd) {
return voteStart; this.compoEnd = compoEnd;
} }
public void setVoteStart(Date voteStart) { public Date getVoteStart() {
this.voteStart = voteStart; return voteStart;
} }
public Date getVoteEnd() { public void setVoteStart(Date voteStart) {
return voteEnd; this.voteStart = voteStart;
} }
public void setVoteEnd(Date voteEnd) { public Date getVoteEnd() {
this.voteEnd = voteEnd; return voteEnd;
} }
public Date getSubmitStart() { public void setVoteEnd(Date voteEnd) {
return submitStart; this.voteEnd = voteEnd;
} }
public void setSubmitStart(Date submitStart) { public Date getSubmitStart() {
this.submitStart = submitStart; return submitStart;
} }
public Date getSubmitEnd() { public void setSubmitStart(Date submitStart) {
return submitEnd; this.submitStart = submitStart;
} }
public void setSubmitEnd(Date submitEnd) { public Date getSubmitEnd() {
this.submitEnd = submitEnd; return submitEnd;
} }
public void setSubmitEnd(Date submitEnd) {
this.submitEnd = submitEnd;
} }
public String send(){
Compo co = new Compo();
co.setName(name);
co.setDescription(description);
co.setMaxParticipantCount(maxParticipants);
Calendar ct = Calendar.getInstance();
ct.setTime(compoStart);
co.setStartTime(ct);
Calendar ce = Calendar.getInstance();
ce.setTime(compoEnd);
co.setEndTime(ce);
Calendar vs = Calendar.getInstance();
vs.setTime(voteStart);
co.setVoteStart(vs);
Calendar ve = Calendar.getInstance();
ve.setTime(voteEnd);
co.setVoteEnd(ve);
Calendar ss = Calendar.getInstance();
ss.setTime(submitStart);
co.setSubmitStart(ss);
Calendar se = Calendar.getInstance();
se.setTime(submitEnd);
co.setSubmitEnd(se);
votbean.createCompo(co);
return "success.";
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!