use of fi.otavanopisto.pyramus.dao.drafts.DraftDAO in project pyramus by otavanopisto.
the class RetrieveFormDraftJSONRequestController method process.
public void process(JSONRequestContext requestContext) {
StaffMemberDAO userDAO = DAOFactory.getInstance().getStaffMemberDAO();
DraftDAO draftDAO = DAOFactory.getInstance().getDraftDAO();
String url = requestContext.getRequest().getHeader("Referer");
User loggedUser = userDAO.findById(requestContext.getLoggedUserId());
FormDraft formDraft = draftDAO.findByUserAndURL(loggedUser, url);
if (formDraft == null) {
requestContext.addResponseParameter("draftDeleted", true);
} else {
requestContext.addResponseParameter("draftDeleted", false);
requestContext.addResponseParameter("url", formDraft.getUrl());
requestContext.addResponseParameter("draftData", formDraft.getData());
requestContext.addResponseParameter("draftCreated", formDraft.getCreated());
requestContext.addResponseParameter("draftModified", formDraft.getModified());
}
}
use of fi.otavanopisto.pyramus.dao.drafts.DraftDAO in project pyramus by otavanopisto.
the class RemoveDeprecatedDrafts method removeDeprecatedDrafts.
/**
* Removes the deprecated drafts from the repository.
* This method is called automatically every 5 minutes.
*/
@Schedule(second = "0", minute = "0/5", hour = "*", persistent = false)
public void removeDeprecatedDrafts() {
DraftDAO draftDAO = DAOFactory.getInstance().getDraftDAO();
draftDAO.removeDeprecatedDrafts();
}
use of fi.otavanopisto.pyramus.dao.drafts.DraftDAO in project pyramus by otavanopisto.
the class DeleteFormDraftJSONRequestController method process.
public void process(JSONRequestContext requestContext) {
StaffMemberDAO userDAO = DAOFactory.getInstance().getStaffMemberDAO();
DraftDAO draftDAO = DAOFactory.getInstance().getDraftDAO();
String url = requestContext.getRequest().getHeader("Referer");
User loggedUser = userDAO.findById(requestContext.getLoggedUserId());
FormDraft formDraft = draftDAO.findByUserAndURL(loggedUser, url);
if (formDraft != null) {
draftDAO.delete(formDraft);
}
}
use of fi.otavanopisto.pyramus.dao.drafts.DraftDAO in project pyramus by otavanopisto.
the class SaveFormDraftJSONRequestController method process.
public void process(JSONRequestContext requestContext) {
StaffMemberDAO userDAO = DAOFactory.getInstance().getStaffMemberDAO();
DraftDAO draftDAO = DAOFactory.getInstance().getDraftDAO();
String url = requestContext.getRequest().getHeader("Referer");
String draftData = requestContext.getString("draftData");
if (draftData != null) {
User loggedUser = userDAO.findById(requestContext.getLoggedUserId());
FormDraft formDraft = draftDAO.findByUserAndURL(loggedUser, url);
if (formDraft == null)
formDraft = draftDAO.create(loggedUser, url, draftData);
else
draftDAO.update(formDraft, draftData);
requestContext.addResponseParameter("url", formDraft.getUrl());
requestContext.addResponseParameter("draftCreated", formDraft.getCreated());
requestContext.addResponseParameter("draftModified", formDraft.getModified());
}
}
Aggregations