Commit 0dd8c8a6 by Antti Tönkyrä

actionlog is now bound to event, closes postit number 2 starting from left!

1 parent ad1c00cd
......@@ -51,14 +51,15 @@ public class ActionLogBean implements ActionLogBeanLocal {
}
alm.setTime(new Date());
alm.setMessage(message);
alm.setUser(permissionBean.getCurrentUser().getUser());
alm.setUser(permissionBean.getCurrentUser());
alm.setLanEvent(permissionBean.getCurrentUser().getEvent());
actionLogFacade.saveToActionLog(alm);
}
@RolesAllowed(ContentPermission.S_MANAGE_ACTIONLOG)
public List<ActionLogMessage> getAllActionLogEvents() {
return actionLogFacade.getAllSortedByTimestamp();
return actionLogFacade.getAllSortedByTimestamp(permissionBean.getCurrentUser().getEvent());
}
@RolesAllowed(ContentPermission.S_MANAGE_ACTIONLOG)
......@@ -68,11 +69,14 @@ public class ActionLogBean implements ActionLogBeanLocal {
@RolesAllowed(ContentPermission.S_MANAGE_ACTIONLOG)
public List<ActionLogMessageResponse> getActionLogMessageResponses(ActionLogMessage alm) {
if(!alm.getLanEvent().equals(permissionBean.getCurrentUser().getEvent())) return null;
return actionLogFacade.getActionLogMessageResponses(alm);
}
@RolesAllowed(ContentPermission.S_MANAGE_ACTIONLOG)
public void addActionLogMessageResponse(ActionLogMessage alm, String message, ActionLogMessageState state) {
if(!alm.getLanEvent().equals(permissionBean.getCurrentUser().getEvent())) return;
if (alm.getState() != state && state != null) {
alm = actionLogFacade.merge(alm);
alm.setState(state);
......@@ -90,7 +94,8 @@ public class ActionLogBean implements ActionLogBeanLocal {
@Override
@RolesAllowed(ContentPermission.S_MANAGE_ACTIONLOG)
public ActionLogMessage find(Integer id) {
return actionLogFacade.find(id);
ActionLogMessage alm = actionLogFacade.find(id);
if(!alm.getLanEvent().equals(permissionBean.getCurrentUser().getEvent())) return null;
else return alm;
}
}
......@@ -12,6 +12,8 @@ import javax.persistence.criteria.Root;
import fi.codecrew.moya.model.ActionLogMessageResponse_;
import fi.codecrew.moya.model.ActionLogMessage;
import fi.codecrew.moya.model.ActionLogMessageResponse;
import fi.codecrew.moya.model.ActionLogMessage_;
import fi.codecrew.moya.model.LanEvent;
@Stateless
@LocalBean
......@@ -22,10 +24,11 @@ public class ActionLogFacade extends IntegerPkGenericFacade<ActionLogMessage> {
super(ActionLogMessage.class);
}
public List<ActionLogMessage> getAllSortedByTimestamp() {
public List<ActionLogMessage> getAllSortedByTimestamp(LanEvent event) {
CriteriaBuilder cb = getEm().getCriteriaBuilder();
CriteriaQuery<ActionLogMessage> cq = cb.createQuery(ActionLogMessage.class);
Root<ActionLogMessage> root = cq.from(ActionLogMessage.class);
cq.where(cb.equal(root.get(ActionLogMessage_.lanEvent), event));
cq.orderBy(cb.desc(root.get("time")));
TypedQuery<ActionLogMessage> tq = getEm().createQuery(cq);
......
......@@ -33,7 +33,10 @@ public class ActionLogMessage extends GenericEntity {
private Date time = new Date();
@JoinColumn(name = "user_id")
private User user;
private EventUser user;
@JoinColumn(name = "lan_event_id")
private LanEvent lanEvent;
@JoinColumn(name = "crew", nullable = false)
private Role crew;
......@@ -50,6 +53,14 @@ public class ActionLogMessage extends GenericEntity {
@Enumerated(EnumType.STRING)
private ActionLogMessageState state;
public LanEvent getLanEvent() {
return lanEvent;
}
public void setLanEvent(LanEvent lanEvent) {
this.lanEvent = lanEvent;
}
public Date getTime() {
return time;
}
......@@ -58,11 +69,11 @@ public class ActionLogMessage extends GenericEntity {
this.time = time;
}
public User getUser() {
public EventUser getUser() {
return user;
}
public void setUser(User user) {
public void setUser(EventUser user) {
this.user = user;
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!