Commit 24b2364c by Antti Tonkyra

ActionLogMessageResponse adding

1 parent 1902653c
...@@ -64,6 +64,21 @@ public class ActionLogBean implements ActionLogBeanLocal { ...@@ -64,6 +64,21 @@ public class ActionLogBean implements ActionLogBeanLocal {
public List<ActionLogMessageResponse> getActionLogMessageResponsesByID(Integer id) { public List<ActionLogMessageResponse> getActionLogMessageResponsesByID(Integer id) {
return actionLogFacade.getActionLogMessageResponsesByID(id); return actionLogFacade.getActionLogMessageResponsesByID(id);
} }
public void addActionLogMessageResponse(Integer actionLogMessageId, String message, ActionLogMessageState state) {
ActionLogMessage alm = actionLogFacade.find(actionLogMessageId);
if(alm.getState() != state) {
alm.setState(state);
}
ActionLogMessageResponse almr = new ActionLogMessageResponse();
almr.setMessage(message);
almr.setActionLogMessage(actionLogFacade.find(actionLogMessageId));
almr.setStateChange(state);
almr.setUser(permissionBean.getCurrentUser());
actionLogFacade.saveActionLogResponse(almr);
}
@Override @Override
public ActionLogMessage find(Integer id) { public ActionLogMessage find(Integer id) {
......
...@@ -68,4 +68,9 @@ public class ActionLogFacade extends GenericFacade<Integer,ActionLogMessage> { ...@@ -68,4 +68,9 @@ public class ActionLogFacade extends GenericFacade<Integer,ActionLogMessage> {
TypedQuery<ActionLogMessageResponse> tq = em.createQuery(cq); TypedQuery<ActionLogMessageResponse> tq = em.createQuery(cq);
return tq.getResultList(); return tq.getResultList();
} }
public void saveActionLogResponse(ActionLogMessageResponse almr) {
em.persist(almr);
em.flush();
}
} }
...@@ -3,6 +3,7 @@ import java.util.List; ...@@ -3,6 +3,7 @@ import java.util.List;
import javax.ejb.Local; import javax.ejb.Local;
import fi.insomnia.bortal.enums.ActionLogMessageState;
import fi.insomnia.bortal.model.ActionLogMessage; import fi.insomnia.bortal.model.ActionLogMessage;
import fi.insomnia.bortal.model.ActionLogMessageResponse; import fi.insomnia.bortal.model.ActionLogMessageResponse;
import fi.insomnia.bortal.model.Role; import fi.insomnia.bortal.model.Role;
...@@ -14,4 +15,5 @@ public interface ActionLogBeanLocal { ...@@ -14,4 +15,5 @@ public interface ActionLogBeanLocal {
public void createActionLogEvent(String message, Role crew, boolean isTask); public void createActionLogEvent(String message, Role crew, boolean isTask);
public ActionLogMessage find(Integer id); public ActionLogMessage find(Integer id);
public List<ActionLogMessageResponse> getActionLogMessageResponsesByID(Integer id); public List<ActionLogMessageResponse> getActionLogMessageResponsesByID(Integer id);
public void addActionLogMessageResponse(Integer actionLogMessageId, String message, ActionLogMessageState state);
} }
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!