Commit 24b2364c by Antti Tonkyra

ActionLogMessageResponse adding

1 parent 1902653c
......@@ -65,6 +65,21 @@ public class ActionLogBean implements ActionLogBeanLocal {
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
public ActionLogMessage find(Integer id) {
return actionLogFacade.find(id);
......
......@@ -68,4 +68,9 @@ public class ActionLogFacade extends GenericFacade<Integer,ActionLogMessage> {
TypedQuery<ActionLogMessageResponse> tq = em.createQuery(cq);
return tq.getResultList();
}
public void saveActionLogResponse(ActionLogMessageResponse almr) {
em.persist(almr);
em.flush();
}
}
......@@ -3,6 +3,7 @@ import java.util.List;
import javax.ejb.Local;
import fi.insomnia.bortal.enums.ActionLogMessageState;
import fi.insomnia.bortal.model.ActionLogMessage;
import fi.insomnia.bortal.model.ActionLogMessageResponse;
import fi.insomnia.bortal.model.Role;
......@@ -14,4 +15,5 @@ public interface ActionLogBeanLocal {
public void createActionLogEvent(String message, Role crew, boolean isTask);
public ActionLogMessage find(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!