use of org.akaza.openclinica.bean.login.UserAccountBean in project OpenClinica by OpenClinica.
the class PrintDataEntryServlet method mayProceed.
// < ResourceBundleresword, resworkflow, respage,resexception;
/**
* Checks whether the user has the correct privilege
*/
@Override
public void mayProceed(HttpServletRequest request, HttpServletResponse response) throws InsufficientPermissionException {
StudyUserRoleBean currentRole = (StudyUserRoleBean) request.getSession().getAttribute("userRole");
locale = LocaleResolver.getLocale(request);
UserAccountBean ub = (UserAccountBean) request.getSession().getAttribute(USER_BEAN_NAME);
if (ub.isSysAdmin()) {
return;
}
if (SubmitDataServlet.mayViewData(ub, currentRole)) {
return;
}
addPageMessage(respage.getString("no_have_correct_privilege_current_study") + respage.getString("change_study_contact_sysadmin"), request);
throw new InsufficientPermissionException(Page.MENU_SERVLET, resexception.getString("not_director"), "1");
}
use of org.akaza.openclinica.bean.login.UserAccountBean in project OpenClinica by OpenClinica.
the class AdministrativeEditingServlet method mayProceed.
/*
* (non-Javadoc)
*
* @see org.akaza.openclinica.control.core.SecureController#mayProceed()
*/
@Override
protected void mayProceed(HttpServletRequest request, HttpServletResponse response) throws InsufficientPermissionException {
mayAccess(request);
locale = LocaleResolver.getLocale(request);
HttpSession session = request.getSession();
FormProcessor fp = new FormProcessor(request);
UserAccountBean ub = (UserAccountBean) request.getSession().getAttribute(USER_BEAN_NAME);
StudyUserRoleBean currentRole = (StudyUserRoleBean) request.getSession().getAttribute("userRole");
// <
// resexception=ResourceBundle.getBundle(
// "org.akaza.openclinica.i18n.exceptions",locale);
// < respage =
// ResourceBundle.getBundle("org.akaza.openclinica.i18n.page_messages",
// locale);
getInputBeans(request);
EventCRFBean ecb = (EventCRFBean) request.getAttribute(INPUT_EVENT_CRF);
String fromResolvingNotes = fp.getString("fromResolvingNotes", true);
if (StringUtil.isBlank(fromResolvingNotes)) {
session.removeAttribute(ViewNotesServlet.WIN_LOCATION);
session.removeAttribute(ViewNotesServlet.NOTES_TABLE);
checkStudyLocked(Page.LIST_STUDY_SUBJECTS, respage.getString("current_study_locked"), request, response);
checkStudyFrozen(Page.LIST_STUDY_SUBJECTS, respage.getString("current_study_frozen"), request, response);
}
request.setAttribute("fromResolvingNotes", fromResolvingNotes);
LOGGER.debug(" +++++++++++++++++++ " + ecb.getStudyEventId());
// StudyEventDAO sedao = new StudyEventDAO(sm.getDataSource());
// StudyEventBean sEvent = (StudyEventBean)
// sedao.findByPK(ecb.getStudyEventId());
// if (sEvent.getSubjectEventStatus().equals(SubjectEventStatus.SIGNED))
// {
// sEvent.setSubjectEventStatus(SubjectEventStatus.COMPLETED);
// sEvent.setUpdater(ub);
// sEvent.setUpdatedDate(new Date());
// sedao.update(sEvent);
// }
DataEntryStage stage = ecb.getStage();
Role r = currentRole.getRole();
session.setAttribute("mayProcessUploading", "true");
if (!SubmitDataServlet.maySubmitData(ub, currentRole)) {
session.setAttribute("mayProcessUploading", "false");
String exceptionName = resexception.getString("no_permission_validation");
String noAccessMessage = respage.getString("not_perform_administrative_editing_CRF");
addPageMessage(noAccessMessage, request);
throw new InsufficientPermissionException(Page.MENU, exceptionName, "1");
}
LOGGER.info("stage name:" + stage.getName());
if (stage.equals(DataEntryStage.DOUBLE_DATA_ENTRY_COMPLETE)) {
// {
if (r.equals(Role.MONITOR)) {
session.setAttribute("mayProcessUploading", "false");
addPageMessage(respage.getString("no_have_correct_privilege_current_study") + respage.getString("change_study_contact_sysadmin"), request);
throw new InsufficientPermissionException(Page.LIST_STUDY_SUBJECTS_SERVLET, resexception.getString("no_permission_administrative_editing"), "1");
}
} else {
session.setAttribute("mayProcessUploading", "false");
addPageMessage(respage.getString("not_perform_administrative_editing_because"), request);
throw new InsufficientPermissionException(Page.LIST_STUDY_SUBJECTS_SERVLET, resexception.getString("not_correct_stage"), "1");
}
return;
}
use of org.akaza.openclinica.bean.login.UserAccountBean in project OpenClinica by OpenClinica.
the class ViewStudyUserServlet method processRequest.
@Override
public void processRequest() throws Exception {
UserAccountDAO udao = new UserAccountDAO(sm.getDataSource());
String name = request.getParameter("name");
String studyIdString = request.getParameter("studyId");
//if(request.getParameter("submit")!=null)
{
if (StringUtil.isBlank(name) || StringUtil.isBlank(studyIdString)) {
addPageMessage(respage.getString("please_choose_a_user_to_view"));
forwardPage(Page.LIST_USER_IN_STUDY_SERVLET);
} else {
int studyId = Integer.valueOf(studyIdString.trim()).intValue();
UserAccountBean user = (UserAccountBean) udao.findByUserName(name);
request.setAttribute("user", user);
StudyUserRoleBean uRole = udao.findRoleByUserNameAndStudyId(name, studyId);
request.setAttribute("uRole", uRole);
StudyDAO sdao = new StudyDAO(sm.getDataSource());
StudyBean study = (StudyBean) sdao.findByPK(studyId);
request.setAttribute("uStudy", study);
request.setAttribute("siteRoleMap", Role.siteRoleMap);
// BWP 12/7/07 >>To provide the view with the correct date format
// pattern, locale sensitive
String pattn = "";
pattn = ResourceBundleProvider.getFormatBundle().getString("date_format_string");
request.setAttribute("dateFormatPattern", pattn);
request.setAttribute("action", "");
forwardPage(Page.VIEW_USER_IN_STUDY);
}
}
}
use of org.akaza.openclinica.bean.login.UserAccountBean in project OpenClinica by OpenClinica.
the class DataEntryServlet method writeToDB.
protected boolean writeToDB(ItemDataBean itemData, DisplayItemBean dib, ItemDataDAO iddao, int ordinal, HttpServletRequest request) {
ItemDataBean idb = itemData;
UserAccountBean ub = (UserAccountBean) request.getSession().getAttribute(USER_BEAN_NAME);
StudyBean currentStudy = (StudyBean) request.getSession().getAttribute("study");
EventCRFBean ecb = (EventCRFBean) request.getAttribute(INPUT_EVENT_CRF);
idb.setItemId(dib.getItem().getId());
idb.setEventCRFId(ecb.getId());
if (idb.getValue().equals("")) {
idb.setStatus(getBlankItemStatus());
} else {
idb.setStatus(getNonBlankItemStatus(request));
}
if (StringUtils.isBlank(dib.getEditFlag())) {
if (!idb.isActive()) {
// will this need to change for double data entry?
idb.setOrdinal(ordinal);
idb.setCreatedDate(new Date());
idb.setOwner(ub);
idb = (ItemDataBean) iddao.create(idb);
} else {
idb.setUpdater(ub);
// tbh 5990: should we update the logic here for nonrepeats?
// //System.out.println("string util is blank: update an item data " + idb.getId() + " :" + idb.getValue());
LOGGER.debug("update item update_id " + idb.getUpdater().getId());
idb = (ItemDataBean) iddao.updateValue(idb);
}
} else {
// for the items in group, they have editFlag
if ("add".equalsIgnoreCase(dib.getEditFlag())) {
idb.setOrdinal(ordinal);
idb.setCreatedDate(new Date());
idb.setOwner(ub);
LOGGER.debug("create a new item data" + idb.getItemId() + idb.getValue());
// idb = (ItemDataBean) iddao.create(idb);
// >>tbh 08/2008
idb.setUpdater(ub);
// idb = (ItemDataBean) iddao.updateValue(idb);
// instead of two hits to the db, we perform an 'upsert'
// combining them into one
idb = (ItemDataBean) iddao.upsert(idb);
// <<tbh
} else if ("edit".equalsIgnoreCase(dib.getEditFlag())) {
idb.setUpdater(ub);
// //System.out.println("update an item data - running update value " + idb.getId() + " :" + idb.getValue());
LOGGER.debug("update item update_id " + idb.getUpdater().getId());
// to make sure we are running the correct command on the db
if (idb.getId() != 0) {
idb.setUpdatedDate(new Date());
idb = (ItemDataBean) iddao.updateValue(idb);
} else {
idb.setCreatedDate(new Date());
idb.setOrdinal(ordinal);
idb.setOwner(ub);
idb = (ItemDataBean) iddao.upsert(idb);
LOGGER.debug("just ran upsert! " + idb.getId());
}
}
// else if ("remove".equalsIgnoreCase(dib.getEditFlag())) {
// LOGGER.debug("REMOVE an item data" + idb.getItemId() + idb.getValue());
// idb.setUpdater(ub);
// idb.setStatus(Status.DELETED);
// idb = (ItemDataBean) iddao.updateValueForRemoved(idb);
//
// DiscrepancyNoteDAO dnDao = new DiscrepancyNoteDAO(getDataSource());
// List dnNotesOfRemovedItem = dnDao.findExistingNotesForItemData(idb.getId());
// if (!dnNotesOfRemovedItem.isEmpty()) {
// DiscrepancyNoteBean itemParentNote = null;
// for (Object obj : dnNotesOfRemovedItem) {
// if (((DiscrepancyNoteBean) obj).getParentDnId() == 0) {
// itemParentNote = (DiscrepancyNoteBean) obj;
// }
// }
// DiscrepancyNoteBean dnb = new DiscrepancyNoteBean();
// if (itemParentNote != null) {
// dnb.setParentDnId(itemParentNote.getId());
// dnb.setDiscrepancyNoteTypeId(itemParentNote.getDiscrepancyNoteTypeId());
// }
// dnb.setResolutionStatusId(ResolutionStatus.CLOSED.getId());
// dnb.setStudyId(currentStudy.getId());
// dnb.setAssignedUserId(ub.getId());
// dnb.setOwner(ub);
// dnb.setEntityType(DiscrepancyNoteBean.ITEM_DATA);
// dnb.setEntityId(idb.getId());
// dnb.setCreatedDate(new Date());
// dnb.setColumn("value");
// dnb.setDescription("The item has been removed, this Discrepancy Note has been Closed.");
// dnDao.create(dnb);
// dnDao.createMapping(dnb);
// itemParentNote.setResolutionStatusId(ResolutionStatus.CLOSED.getId());
// dnDao.update(itemParentNote);
// }
// }
}
return idb.isActive();
}
use of org.akaza.openclinica.bean.login.UserAccountBean in project OpenClinica by OpenClinica.
the class DataEntryServlet method createEventCRF.
/**
* Creates a new Event CRF or update the exsiting one, that is, an event CRF can be created but not item data yet, in this case, still consider it is not
* started(called uncompleted before)
* @param request TODO
* @param fp TODO
*
* @return
* @throws Exception
*/
private EventCRFBean createEventCRF(HttpServletRequest request, FormProcessor fp) throws InconsistentStateException {
locale = LocaleResolver.getLocale(request);
// < resmessage =
// ResourceBundle.getBundle("org.akaza.openclinica.i18n.page_messages",
// locale);
// < restext =
// ResourceBundle.getBundle("org.akaza.openclinica.i18n.notes",locale);
// <
// resexception=ResourceBundle.getBundle(
// "org.akaza.openclinica.i18n.exceptions",locale);
UserAccountBean ub = (UserAccountBean) request.getSession().getAttribute(USER_BEAN_NAME);
StudyBean currentStudy = (StudyBean) request.getSession().getAttribute("study");
EventCRFBean ecb;
EventCRFDAO ecdao = new EventCRFDAO(getDataSource());
int crfVersionId = fp.getInt(INPUT_CRF_VERSION_ID);
LOGGER.trace("***FOUND*** crfversionid: " + crfVersionId);
int studyEventId = fp.getInt(INPUT_STUDY_EVENT_ID);
int eventDefinitionCRFId = fp.getInt(INPUT_EVENT_DEFINITION_CRF_ID);
int subjectId = fp.getInt(INPUT_SUBJECT_ID);
int eventCRFId = fp.getInt(INPUT_EVENT_CRF_ID);
LOGGER.trace("look specifically wrt event crf id: " + eventCRFId);
LOGGER.trace("Creating event CRF. Study id: " + currentStudy.getId() + "; CRF Version id: " + crfVersionId + "; Study Event id: " + studyEventId + "; Event Definition CRF id: " + eventDefinitionCRFId + "; Subject: " + subjectId);
StudySubjectDAO ssdao = new StudySubjectDAO(getDataSource());
StudySubjectBean ssb = ssdao.findBySubjectIdAndStudy(subjectId, currentStudy);
if (ssb.getId() <= 0) {
LOGGER.trace("throwing ISE with study subject bean id of " + ssb.getId());
// "begin_data_entry_without_event_but_subject"));
throw new InconsistentStateException(Page.LIST_STUDY_SUBJECTS_SERVLET, resexception.getString("begin_data_entry_without_event_but_subject"));
}
StudyEventDefinitionDAO seddao = new StudyEventDefinitionDAO(getDataSource());
StudyEventDefinitionBean sedb = seddao.findByEventDefinitionCRFId(eventDefinitionCRFId);
// logger.trace("study event definition:" + sedb.getId());
if (sedb.getId() <= 0) {
addPageMessage(resexception.getString("begin_data_entry_without_event_but_study"), request);
throw new InconsistentStateException(Page.LIST_STUDY_SUBJECTS_SERVLET, resexception.getString("begin_data_entry_without_event_but_study"));
}
CRFVersionDAO cvdao = new CRFVersionDAO(getDataSource());
EntityBean eb = cvdao.findByPK(crfVersionId);
if (eb.getId() <= 0) {
//addPageMessage(resexception.getString("begin_data_entry_without_event_but_CRF"));
throw new InconsistentStateException(Page.LIST_STUDY_SUBJECTS_SERVLET, resexception.getString("begin_data_entry_without_event_but_CRF"));
}
StudyEventDAO sedao = new StudyEventDAO(getDataSource());
StudyEventBean sEvent = (StudyEventBean) sedao.findByPK(studyEventId);
StudyBean studyWithSED = currentStudy;
if (currentStudy.getParentStudyId() > 0) {
studyWithSED = new StudyBean();
studyWithSED.setId(currentStudy.getParentStudyId());
}
AuditableEntityBean aeb = sedao.findByPKAndStudy(studyEventId, studyWithSED);
if (aeb.getId() <= 0) {
addPageMessage(resexception.getString("begin_data_entry_without_event_but_especified_event"), request);
throw new InconsistentStateException(Page.LIST_STUDY_SUBJECTS_SERVLET, resexception.getString("begin_data_entry_without_event_but_especified_event"));
}
ecb = new EventCRFBean();
if (eventCRFId == 0) {
// no event CRF created yet
ArrayList ecList = ecdao.findByEventSubjectVersion(sEvent, ssb, (CRFVersionBean) eb);
if (ecList.size() > 0) {
ecb = (EventCRFBean) ecList.get(0);
} else {
ecb.setAnnotations("");
ecb.setCreatedDate(new Date());
ecb.setCRFVersionId(crfVersionId);
if (currentStudy.getStudyParameterConfig().getInterviewerNameDefault().equals("blank")) {
ecb.setInterviewerName("");
} else {
// default will be event's owner name
ecb.setInterviewerName(sEvent.getOwner().getName());
}
if (!currentStudy.getStudyParameterConfig().getInterviewDateDefault().equals("blank")) {
if (sEvent.getDateStarted() != null) {
// default
ecb.setDateInterviewed(sEvent.getDateStarted());
// date
} else {
// logger.trace("evnet start date is null, so date
// interviewed is null");
ecb.setDateInterviewed(null);
}
} else {
ecb.setDateInterviewed(null);
// logger.trace("date interviewed is
// null,getInterviewDateDefault() is blank");
}
// ecb.setOwnerId(ub.getId());
// above depreciated, try without it, tbh
ecb.setOwner(ub);
ecb.setStatus(Status.AVAILABLE);
ecb.setCompletionStatusId(1);
ecb.setStudySubjectId(ssb.getId());
ecb.setStudyEventId(studyEventId);
ecb.setValidateString("");
ecb.setValidatorAnnotations("");
ecb = (EventCRFBean) ecdao.create(ecb);
LOGGER.debug("*********CREATED EVENT CRF");
}
} else {
// there is an event CRF already, only need to update
ecb = (EventCRFBean) ecdao.findByPK(eventCRFId);
ecb.setCRFVersionId(crfVersionId);
ecb.setUpdatedDate(new Date());
ecb.setUpdater(ub);
ecb = updateECB(sEvent, request);
ecb = (EventCRFBean) ecdao.update(ecb);
}
if (ecb.getId() <= 0) {
addPageMessage(resexception.getString("new_event_CRF_not_created"), request);
throw new InconsistentStateException(Page.LIST_STUDY_SUBJECTS_SERVLET, resexception.getString("new_event_CRF_not_created"));
} else {
if (sEvent.getSubjectEventStatus().equals(SubjectEventStatus.SIGNED)) {
sEvent.setSubjectEventStatus(SubjectEventStatus.COMPLETED);
sEvent.setUpdater(ub);
sEvent.setUpdatedDate(new Date());
sedao.update(sEvent);
} else {
sEvent.setSubjectEventStatus(SubjectEventStatus.DATA_ENTRY_STARTED);
sEvent.setUpdater(ub);
sEvent.setUpdatedDate(new Date());
sedao.update(sEvent);
}
}
return ecb;
}
Aggregations