Commit aa9ff53e by Tuomas Riihimäki

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

2 parents 8ff3746a 293e3917
...@@ -71,6 +71,7 @@ public class ActionLogBean implements ActionLogBeanLocal { ...@@ -71,6 +71,7 @@ public class ActionLogBean implements ActionLogBeanLocal {
@RolesAllowed(ContentPermission.S_MANAGE_ACTIONLOG) @RolesAllowed(ContentPermission.S_MANAGE_ACTIONLOG)
public void addActionLogMessageResponse(ActionLogMessage alm, String message, ActionLogMessageState state) { public void addActionLogMessageResponse(ActionLogMessage alm, String message, ActionLogMessageState state) {
if (alm.getState() != state && state != null) { if (alm.getState() != state && state != null) {
alm = actionLogFacade.merge(alm);
alm.setState(state); alm.setState(state);
} }
......
...@@ -2,6 +2,7 @@ package fi.insomnia.bortal.beans; ...@@ -2,6 +2,7 @@ package fi.insomnia.bortal.beans;
import java.util.List; import java.util.List;
import javax.annotation.security.DeclareRoles;
import javax.ejb.EJB; import javax.ejb.EJB;
import javax.ejb.LocalBean; import javax.ejb.LocalBean;
import javax.ejb.Stateless; import javax.ejb.Stateless;
...@@ -9,6 +10,7 @@ import javax.ejb.Stateless; ...@@ -9,6 +10,7 @@ import javax.ejb.Stateless;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import fi.insomnia.bortal.enums.apps.UserPermission;
import fi.insomnia.bortal.facade.OrgRoleFacade; import fi.insomnia.bortal.facade.OrgRoleFacade;
import fi.insomnia.bortal.model.OrgRole; import fi.insomnia.bortal.model.OrgRole;
...@@ -17,6 +19,7 @@ import fi.insomnia.bortal.model.OrgRole; ...@@ -17,6 +19,7 @@ import fi.insomnia.bortal.model.OrgRole;
*/ */
@Stateless @Stateless
@LocalBean @LocalBean
@DeclareRoles({ UserPermission.S_READ_ORGROLES, UserPermission.S_WRITE_ORGROLES })
public class OrgRoleBean implements OrgRoleBeanLocal { public class OrgRoleBean implements OrgRoleBeanLocal {
private static final Logger logger = LoggerFactory private static final Logger logger = LoggerFactory
......
...@@ -44,6 +44,8 @@ import fi.insomnia.bortal.model.User; ...@@ -44,6 +44,8 @@ import fi.insomnia.bortal.model.User;
UserPermission.S_ANYUSER, UserPermission.S_ANYUSER,
UserPermission.S_MANAGE_HTTP_SESSION, UserPermission.S_MANAGE_HTTP_SESSION,
UserPermission.S_INVITE_USERS, UserPermission.S_INVITE_USERS,
UserPermission.S_READ_ORGROLES,
UserPermission.S_WRITE_ORGROLES,
MapPermission.S_VIEW, MapPermission.S_VIEW,
MapPermission.S_MANAGE_MAPS, MapPermission.S_MANAGE_MAPS,
......
...@@ -57,10 +57,11 @@ public class VotingBean implements VotingBeanLocal { ...@@ -57,10 +57,11 @@ public class VotingBean implements VotingBeanLocal {
compoEntry.setCreated(Calendar.getInstance()); compoEntry.setCreated(Calendar.getInstance());
compoEntry.setCreator(permissionBean.getCurrentUser()); compoEntry.setCreator(permissionBean.getCurrentUser());
compoEntryFacade.create(compoEntry); Compo c = compoFacade.merge(compoEntry.getCompo());
compoEntryFileFacade.create(compoEntryFile);
compoEntry.setCurrentFile(compoEntryFile); c.getCompoEntries().add(compoEntry);
compoEntry.setFiles(new ArrayList<CompoEntryFile>()); compoFacade.flush();
compoEntryFile.setEntriesId(compoEntry);
compoEntry.getFiles().add(compoEntryFile); compoEntry.getFiles().add(compoEntryFile);
} }
......
...@@ -30,7 +30,7 @@ public class CompoFacade extends IntegerPkGenericFacade<Compo> { ...@@ -30,7 +30,7 @@ public class CompoFacade extends IntegerPkGenericFacade<Compo> {
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())); cq.where(cb.equal(root.get(Compo_.event), eventbean.getCurrentEvent()));
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;
} }
......
...@@ -17,7 +17,6 @@ import org.eclipse.persistence.annotations.OptimisticLockingType; ...@@ -17,7 +17,6 @@ import org.eclipse.persistence.annotations.OptimisticLockingType;
import fi.insomnia.bortal.enums.ActionLogMessageState; import fi.insomnia.bortal.enums.ActionLogMessageState;
@Entity @Entity
@Table(name = "actionlog_message_responses") @Table(name = "actionlog_message_responses")
@OptimisticLocking(type = OptimisticLockingType.CHANGED_COLUMNS) @OptimisticLocking(type = OptimisticLockingType.CHANGED_COLUMNS)
...@@ -25,17 +24,17 @@ public class ActionLogMessageResponse extends GenericEntity { ...@@ -25,17 +24,17 @@ public class ActionLogMessageResponse extends GenericEntity {
@Column(name = "time", nullable = false) @Column(name = "time", nullable = false)
@Temporal(TemporalType.TIMESTAMP) @Temporal(TemporalType.TIMESTAMP)
private Date time = new Date(); private Date time = new Date();
@JoinColumn(name = "user_id") @JoinColumn(name = "user_id")
private IUser user; private EventUser user;
@Column(name = "message", nullable = false) @Column(name = "message", nullable = false)
private String message; private String message;
@Column(name = "state_change", nullable = true) @Column(name = "state_change", nullable = true)
@Enumerated(EnumType.STRING) @Enumerated(EnumType.STRING)
private ActionLogMessageState stateChange; private ActionLogMessageState stateChange;
@JoinColumn(name = "actionlog_message_id", referencedColumnName = "id") @JoinColumn(name = "actionlog_message_id", referencedColumnName = "id")
@ManyToOne(optional = false) @ManyToOne(optional = false)
private ActionLogMessage actionLogMessage; private ActionLogMessage actionLogMessage;
...@@ -48,11 +47,11 @@ public class ActionLogMessageResponse extends GenericEntity { ...@@ -48,11 +47,11 @@ public class ActionLogMessageResponse extends GenericEntity {
this.time = time; this.time = time;
} }
public IUser getUser() { public EventUser getUser() {
return user; return user;
} }
public void setUser(IUser user) { public void setUser(EventUser user) {
this.user = user; this.user = user;
} }
...@@ -71,11 +70,11 @@ public class ActionLogMessageResponse extends GenericEntity { ...@@ -71,11 +70,11 @@ public class ActionLogMessageResponse extends GenericEntity {
public void setStateChange(ActionLogMessageState stateChange) { public void setStateChange(ActionLogMessageState stateChange) {
this.stateChange = stateChange; this.stateChange = stateChange;
} }
public ActionLogMessage getActionLogMessage() { public ActionLogMessage getActionLogMessage() {
return actionLogMessage; return actionLogMessage;
} }
public void setActionLogMessage(ActionLogMessage message) { public void setActionLogMessage(ActionLogMessage message) {
this.actionLogMessage = message; this.actionLogMessage = message;
} }
......
...@@ -15,7 +15,10 @@ public enum UserPermission implements IAppPermission { ...@@ -15,7 +15,10 @@ public enum UserPermission implements IAppPermission {
MODIFY_ACCOUNTEVENTS("Modify Account events"), MODIFY_ACCOUNTEVENTS("Modify Account events"),
ANYUSER("All users have this anyways"), ANYUSER("All users have this anyways"),
MANAGE_HTTP_SESSION("Manage http sessions"), MANAGE_HTTP_SESSION("Manage http sessions"),
INVITE_USERS("Invite users"), ; INVITE_USERS("Invite users"),
READ_ORGROLES("View organization roles"),
WRITE_ORGROLES("Modify organization roles"),
;
public static final String S_VIEW_ALL = "USER/VIEW_ALL"; public static final String S_VIEW_ALL = "USER/VIEW_ALL";
public static final String S_MODIFY = "USER/MODIFY"; public static final String S_MODIFY = "USER/MODIFY";
...@@ -30,6 +33,8 @@ public enum UserPermission implements IAppPermission { ...@@ -30,6 +33,8 @@ public enum UserPermission implements IAppPermission {
public static final String S_ANYUSER = "USER/ANYUSER"; public static final String S_ANYUSER = "USER/ANYUSER";
public static final String S_MANAGE_HTTP_SESSION = "USER/MANAGE_HTTP_SESSION"; public static final String S_MANAGE_HTTP_SESSION = "USER/MANAGE_HTTP_SESSION";
public static final String S_INVITE_USERS = "USER/INVITE_USERS"; public static final String S_INVITE_USERS = "USER/INVITE_USERS";
public static final String S_READ_ORGROLES = "USER/READ_ORGROLES";
public static final String S_WRITE_ORGROLES = "USER/WRITE_ORGROLES";
private String description; private String description;
private String fullName; private String fullName;
......
<!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:f="http://java.sun.com/jsf/core"
xmlns:orgrole="http://java.sun.com/jsf/composite/cditools/orgrole"
xmlns:c="http://java.sun.com/jsp/jstl/core">
<ui:composition
template="/layout/#{sessionHandler.layout}/template.xhtml">
<ui:param name="thispage" value="page.orgRole.create" />
<f:metadata>
<f:event type="preRenderView"
listener="#{orgRoleView.initForCreate()}" />
</f:metadata>
<ui:define name="content">
<orgrole:create />
</ui:define>
</ui:composition>
</html>
\ No newline at end of file
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
<ui:param name="thispage" value="page.orgrole.list" /> <ui:param name="thispage" value="page.orgrole.list" />
<f:metadata> <f:metadata>
<f:event type="preRenderView" <f:event type="preRenderView"
listener="#{orgRoleView.permissionRead()}" /> listener="#{orgRoleView.permissionList()}" />
</f:metadata> </f:metadata>
<ui:define name="content"> <ui:define name="content">
<orgrole:list /> <orgrole:list />
......
<?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:orgrole="http://java.sun.com/jsf/composite/tools/orgrole">
<composite:interface>
</composite:interface>
<composite:implementation>
<h:form>
<ui:include src="form.xhtml" />
<h:commandButton id="createorgrole" value="#{i18n['orgrole.create']}"
action="#{orgRoleView.create()}" />
</h:form>
</composite:implementation>
</html>
<?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">
<ui:composition>
<h:panelGrid columns="2">
<h:outputText value="#{i18n['orgrole.name']}" />
<h:inputText value="#{orgRoleView.orgRole.name}" />
<h:outputText value="#{i18n['orgrole.parents']}" />
<h:selectManyCheckbox converter="#{roleConverter}"
layout="pageDirection" id="roleparents"
value="#{roleView.role.parents}">
<f:selectItems var="par" itemLabel="#{par.name}"
value="#{roleView.possibleParents}" />
</h:selectManyCheckbox>
<h:outputLabel value="#{i18n['role.cardtemplate']}" />
<h:selectOneMenu converter="#{cardTemplateConverter}"
value="#{roleView.role.cardTemplate}">
<f:selectItems var="role" itemLabel="#{role.name}"
value="#{cardView.templatesWithNull}" />
</h:selectOneMenu>
</h:panelGrid>
</ui:composition>
</html>
...@@ -23,31 +23,31 @@ ...@@ -23,31 +23,31 @@
<h:dataTable styleClass="bordertable" rowClasses="roweven,rowodd" id="compolisttable" value="#{votingCompoListView.compos}" var="compo"> <h:dataTable styleClass="bordertable" rowClasses="roweven,rowodd" id="compolisttable" value="#{votingCompoListView.compos}" var="compo">
<h:column> <h:column>
<f:facet name="header"> <f:facet name="header">
<h:outputText value="Name" /> <h:outputText value="#{i18n['voting.allcompos.name']}" />
</f:facet> </f:facet>
<h:outputText value="#{compo.name}" /> <h:outputText value="#{compo.name}" />
</h:column> </h:column>
<h:column> <h:column>
<f:facet name="header"> <f:facet name="header">
<h:outputText value="Kuvaus" /> <h:outputText value="#{i18n['voting.allcompos.descri']}" />
</f:facet> </f:facet>
<h:outputText value="#{compo.description}" /> <h:outputText value="#{compo.description}" />
</h:column> </h:column>
<h:column rendered="#{votingCompoListView.curEntries}"> <h:column rendered="#{votingCompoListView.curEntries}">
<f:facet name="header"> <f:facet name="header">
<h:outputText value="current entries" /> <h:outputText value="#{i18n['voting.allcompos.curEntries']}" />
</f:facet> </f:facet>
<h:outputText value="#{compo.compoEntries.size()}" /> <h:outputText value="#{compo.compoEntries.size()}" />
</h:column> </h:column>
<h:column rendered="#{votingCompoListView.maxParts}"> <h:column rendered="#{votingCompoListView.maxParts}">
<f:facet name="header"> <f:facet name="header">
<h:outputText value="Max parts" /> <h:outputText value="#{i18n['voting.allcompos.maxParts']}" />
</f:facet> </f:facet>
<h:outputText value="#{compo.maxParticipantCount}" /> <h:outputText value="#{compo.maxParticipantCount}" />
</h:column> </h:column>
<h:column> <h:column>
<f:facet name="header"> <f:facet name="header">
<h:outputText value="Start time" /> <h:outputText value="#{i18n['voting.allcompos.startTime']}" />
</f:facet> </f:facet>
<h:outputText value="#{compo.startTime.time}" > <h:outputText value="#{compo.startTime.time}" >
<f:convertDateTime type="both" pattern="dd.MM.yyyy HH:mm" /> <f:convertDateTime type="both" pattern="dd.MM.yyyy HH:mm" />
...@@ -55,7 +55,7 @@ ...@@ -55,7 +55,7 @@
</h:column> </h:column>
<h:column> <h:column>
<f:facet name="header" > <f:facet name="header" >
<h:outputText value="End time" /> <h:outputText value="#{i18n['voting.allcompos.endTime']}" />
</f:facet> </f:facet>
<h:outputText value="#{compo.endTime.time}" > <h:outputText value="#{compo.endTime.time}" >
<f:convertDateTime type="both" pattern="dd.MM.yyyy HH:mm" /> <f:convertDateTime type="both" pattern="dd.MM.yyyy HH:mm" />
...@@ -63,7 +63,7 @@ ...@@ -63,7 +63,7 @@
</h:column> </h:column>
<h:column> <h:column>
<f:facet name="header" > <f:facet name="header" >
<h:outputText value="Vote start" /> <h:outputText value="#{i18n['voting.allcompos.voteStart']}" />
</f:facet> </f:facet>
<h:outputText value="#{compo.voteStart.time}" > <h:outputText value="#{compo.voteStart.time}" >
<f:convertDateTime type="both" pattern="dd.MM.yyyy HH:mm" /> <f:convertDateTime type="both" pattern="dd.MM.yyyy HH:mm" />
...@@ -71,7 +71,7 @@ ...@@ -71,7 +71,7 @@
</h:column> </h:column>
<h:column> <h:column>
<f:facet name="header" > <f:facet name="header" >
<h:outputText value="Vote end" /> <h:outputText value="#{i18n['voting.allcompos.voteEnd']}" />
</f:facet> </f:facet>
<h:outputText value="#{compo.voteEnd.time}" > <h:outputText value="#{compo.voteEnd.time}" >
<f:convertDateTime type="both" pattern="dd.MM.yyyy HH:mm" /> <f:convertDateTime type="both" pattern="dd.MM.yyyy HH:mm" />
...@@ -79,7 +79,7 @@ ...@@ -79,7 +79,7 @@
</h:column> </h:column>
<h:column> <h:column>
<f:facet name="header"> <f:facet name="header">
<h:outputText value="Submit start" /> <h:outputText value="#{i18n['voting.allcompos.submitStart']}" />
</f:facet> </f:facet>
<h:outputText value="#{compo.submitStart.time}" > <h:outputText value="#{compo.submitStart.time}" >
<f:convertDateTime type="both" pattern="dd.MM.yyyy HH:mm" /> <f:convertDateTime type="both" pattern="dd.MM.yyyy HH:mm" />
...@@ -87,7 +87,7 @@ ...@@ -87,7 +87,7 @@
</h:column> </h:column>
<h:column> <h:column>
<f:facet name="header"> <f:facet name="header">
<h:outputText value="Submit end" /> <h:outputText value="#{i18n['voting.allcompos.submitEnd']}" />
</f:facet> </f:facet>
<h:outputText value="#{compo.submitEnd.time}" > <h:outputText value="#{compo.submitEnd.time}" >
<f:convertDateTime type="both" pattern="dd.MM.yyyy HH:mm" /> <f:convertDateTime type="both" pattern="dd.MM.yyyy HH:mm" />
...@@ -95,11 +95,11 @@ ...@@ -95,11 +95,11 @@
</h:column> </h:column>
<h:column> <h:column>
<f:facet name="header"> <f:facet name="header">
<h:outputText value="Submit entry" /> <h:outputText value="" />
</f:facet> </f:facet>
<h:link outcome="addentry"> <h:link outcome="addentry" rendered="#{compo.maxParticipantCount gt compo.compoEntries.size()}">
<f:param name="compoId" value="#{compo.id}" /> <f:param name="compoId" value="#{compo.id}" />
Submit entry #{i18n['voting.allcompos.submitEntry']}
</h:link> </h:link>
</h:column> </h:column>
</h:dataTable> </h:dataTable>
......
...@@ -526,8 +526,19 @@ userview.userExists = Username already exists! please select another. ...@@ -526,8 +526,19 @@ userview.userExists = Username already exists! please select another.
viewexpired.body = Please login again. viewexpired.body = Please login again.
viewexpired.title = Login expired. Please login again. viewexpired.title = Login expired. Please login again.
voting.allcompos.description = List of all compos and NIIDEN information. voting.allcompos.curEntries = # of entries
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.header = All compos
voting.allcompos.maxParts = Max participants
voting.allcompos.name = Name
voting.allcompos.startTime = Start time
voting.allcompos.submitEnd = Submit end
voting.allcompos.submitEntry = Submit entry
voting.allcompos.submitStart = Submit start
voting.allcompos.voteEnd = Vote end
voting.allcompos.voteStart = Vote start
voting.create.compoEnd = End time voting.create.compoEnd = End time
voting.create.compoStart = Start time voting.create.compoStart = Start time
voting.create.createButton = Create voting.create.createButton = Create
......
...@@ -516,8 +516,19 @@ userview.userExists = K\u00E4ytt\u00E4j\u00E4tunnus on jo olemassa. Ole ...@@ -516,8 +516,19 @@ userview.userExists = K\u00E4ytt\u00E4j\u00E4tunnus on jo olemassa. Ole
viewexpired.body = Ole hyv\u00E4 ja kirjaudu sis\u00E4\u00E4n uudelleen. viewexpired.body = Ole hyv\u00E4 ja kirjaudu sis\u00E4\u00E4n uudelleen.
viewexpired.title = N\u00E4kym\u00E4 on vanhentunut viewexpired.title = N\u00E4kym\u00E4 on vanhentunut
voting.allcompos.curEntries = Entryja
voting.allcompos.descri = Kuvaus
voting.allcompos.description = Compojen informaatiot. voting.allcompos.description = Compojen informaatiot.
voting.allcompos.endTime = Lopetusaika
voting.allcompos.header = Kaikki compot voting.allcompos.header = Kaikki compot
voting.allcompos.maxParts = Max osallistujam\u00E4\u00E4r\u00E4
voting.allcompos.name = Nimi
voting.allcompos.startTime = Aloitusaika
voting.allcompos.submitEnd = Lis\u00E4ys kiinni
voting.allcompos.submitEntry = L\u00E4het\u00E4 entry
voting.allcompos.submitStart = Lis\u00E4ys auki
voting.allcompos.voteEnd = \u00C4\u00E4nestys kiinni
voting.allcompos.voteStart = \u00C4\u00E4nestys auki
voting.create.compoEnd = Lopetusaika voting.create.compoEnd = Lopetusaika
voting.create.compoStart = Aloitusaika voting.create.compoStart = Aloitusaika
voting.create.createButton = Luo voting.create.createButton = Luo
......
...@@ -28,5 +28,9 @@ public class OrgRoleDataView extends GenericCDIView { ...@@ -28,5 +28,9 @@ public class OrgRoleDataView extends GenericCDIView {
return orgRoles; return orgRoles;
} }
public boolean permissionList() {
return true;
}
} }
package fi.insomnia.bortal.web.cdiview.user;
import javax.ejb.EJB;
import javax.enterprise.context.ConversationScoped;
import javax.inject.Named;
import fi.insomnia.bortal.beans.OrgRoleBeanLocal;
import fi.insomnia.bortal.enums.apps.UserPermission;
import fi.insomnia.bortal.web.cdiview.GenericCDIView;
@ConversationScoped
@Named
public class OrgRoleView extends GenericCDIView {
private static final long serialVersionUID = -2492481531713504212L;
@EJB
private OrgRoleBeanLocal orgRoleBean;
public void permissionList() {
requirePermissions(permbean.hasPermission(UserPermission.READ_ORGROLES));
}
public void initForCreate() {
requirePermissions(permbean
.hasPermission(UserPermission.WRITE_ORGROLES));
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!