use of org.akaza.openclinica.bean.submit.CRFVersionBean in project OpenClinica by OpenClinica.
the class ViewNoteServlet method processRequest.
@Override
protected void processRequest() throws Exception {
FormProcessor fp = new FormProcessor(request);
Locale locale = LocaleResolver.getLocale(request);
DateFormat dateFormatter = DateFormat.getDateInstance(DateFormat.DEFAULT, locale);
DiscrepancyNoteDAO dndao = new DiscrepancyNoteDAO(sm.getDataSource());
dndao.setFetchMapping(true);
int noteId = fp.getInt(NOTE_ID, true);
DiscrepancyNoteBean note = (DiscrepancyNoteBean) dndao.findByPK(noteId);
String entityType = note.getEntityType();
if (note.getEntityId() > 0 && !entityType.equals("")) {
if (!StringUtil.isBlank(entityType)) {
if ("itemData".equalsIgnoreCase(entityType)) {
ItemDataDAO iddao = new ItemDataDAO(sm.getDataSource());
ItemDataBean itemData = (ItemDataBean) iddao.findByPK(note.getEntityId());
ItemDAO idao = new ItemDAO(sm.getDataSource());
ItemBean item = (ItemBean) idao.findByPK(itemData.getItemId());
note.setEntityValue(itemData.getValue());
note.setEntityName(item.getName());
//Mantis Issue 5165. It should be itemData.getId() instead of item.getId()
note.setEntityId(itemData.getId());
EventCRFDAO ecdao = new EventCRFDAO(sm.getDataSource());
EventCRFBean ec = (EventCRFBean) ecdao.findByPK(itemData.getEventCRFId());
StudyEventDAO sed = new StudyEventDAO(sm.getDataSource());
StudyEventBean se = (StudyEventBean) sed.findByPK(ec.getStudyEventId());
StudySubjectDAO ssdao = new StudySubjectDAO(sm.getDataSource());
StudySubjectBean ssub = (StudySubjectBean) ssdao.findByPK(se.getStudySubjectId());
note.setStudySub(ssub);
StudyEventDefinitionDAO seddao = new StudyEventDefinitionDAO(sm.getDataSource());
StudyEventDefinitionBean sedb = (StudyEventDefinitionBean) seddao.findByPK(se.getStudyEventDefinitionId());
se.setName(sedb.getName());
note.setEvent(se);
CRFVersionDAO cvdao = new CRFVersionDAO(sm.getDataSource());
CRFVersionBean cv = (CRFVersionBean) cvdao.findByPK(ec.getCRFVersionId());
CRFDAO cdao = new CRFDAO(sm.getDataSource());
CRFBean crf = (CRFBean) cdao.findByPK(cv.getCrfId());
note.setCrfName(crf.getName());
} else if ("studySub".equalsIgnoreCase(entityType)) {
StudySubjectDAO ssdao = new StudySubjectDAO(sm.getDataSource());
StudySubjectBean ssub = (StudySubjectBean) ssdao.findByPK(note.getEntityId());
note.setStudySub(ssub);
// System.out.println("column" + note.getColumn());
SubjectDAO sdao = new SubjectDAO(sm.getDataSource());
SubjectBean sub = (SubjectBean) sdao.findByPK(ssub.getSubjectId());
if (!StringUtil.isBlank(note.getColumn())) {
if ("enrollment_date".equalsIgnoreCase(note.getColumn())) {
if (ssub.getEnrollmentDate() != null) {
note.setEntityValue(dateFormatter.format(ssub.getEnrollmentDate()));
}
note.setEntityName(resword.getString("enrollment_date"));
} else if ("gender".equalsIgnoreCase(note.getColumn())) {
note.setEntityValue(sub.getGender() + "");
note.setEntityName(resword.getString("gender"));
} else if ("date_of_birth".equalsIgnoreCase(note.getColumn())) {
if (sub.getDateOfBirth() != null) {
note.setEntityValue(dateFormatter.format(sub.getDateOfBirth()));
}
note.setEntityName(resword.getString("date_of_birth"));
}
}
} else if ("subject".equalsIgnoreCase(entityType)) {
SubjectDAO sdao = new SubjectDAO(sm.getDataSource());
SubjectBean sub = (SubjectBean) sdao.findByPK(note.getEntityId());
StudySubjectBean ssub = new StudySubjectBean();
ssub.setLabel(sub.getUniqueIdentifier());
note.setStudySub(ssub);
if (!StringUtil.isBlank(note.getColumn())) {
if ("gender".equalsIgnoreCase(note.getColumn())) {
note.setEntityValue(sub.getGender() + "");
note.setEntityName(resword.getString("gender"));
} else if ("date_of_birth".equalsIgnoreCase(note.getColumn())) {
if (sub.getDateOfBirth() != null) {
note.setEntityValue(dateFormatter.format(sub.getDateOfBirth()));
}
note.setEntityName(resword.getString("date_of_birth"));
} else if ("unique_identifier".equalsIgnoreCase(note.getColumn())) {
note.setEntityName(resword.getString("unique_identifier"));
note.setEntityValue(sub.getUniqueIdentifier());
}
}
} else if ("studyEvent".equalsIgnoreCase(entityType)) {
StudyEventDAO sed = new StudyEventDAO(sm.getDataSource());
StudyEventBean se = (StudyEventBean) sed.findByPK(note.getEntityId());
StudySubjectDAO ssdao = new StudySubjectDAO(sm.getDataSource());
StudySubjectBean ssub = (StudySubjectBean) ssdao.findByPK(se.getStudySubjectId());
note.setStudySub(ssub);
StudyEventDefinitionDAO seddao = new StudyEventDefinitionDAO(sm.getDataSource());
StudyEventDefinitionBean sedb = (StudyEventDefinitionBean) seddao.findByPK(se.getStudyEventDefinitionId());
se.setName(sedb.getName());
note.setEvent(se);
if (!StringUtil.isBlank(note.getColumn())) {
if ("location".equalsIgnoreCase(note.getColumn())) {
request.setAttribute("entityValue", se.getLocation());
request.setAttribute("entityName", resword.getString("location"));
note.setEntityName(resword.getString("location"));
note.setEntityValue(se.getLocation());
} else if ("date_start".equalsIgnoreCase(note.getColumn())) {
if (se.getDateStarted() != null) {
note.setEntityValue(dateFormatter.format(se.getDateStarted()));
}
note.setEntityName(resword.getString("start_date"));
} else if ("date_end".equalsIgnoreCase(note.getColumn())) {
if (se.getDateEnded() != null) {
note.setEntityValue(dateFormatter.format(se.getDateEnded()));
}
note.setEntityName(resword.getString("end_date"));
}
}
} else if ("eventCrf".equalsIgnoreCase(entityType)) {
EventCRFDAO ecdao = new EventCRFDAO(sm.getDataSource());
EventCRFBean ec = (EventCRFBean) ecdao.findByPK(note.getEntityId());
StudySubjectBean ssub = (StudySubjectBean) new StudySubjectDAO(sm.getDataSource()).findByPK(ec.getStudySubjectId());
note.setStudySub(ssub);
StudyEventBean event = (StudyEventBean) new StudyEventDAO(sm.getDataSource()).findByPK(ec.getStudyEventId());
note.setEvent(event);
if (!StringUtil.isBlank(note.getColumn())) {
if ("date_interviewed".equals(note.getColumn())) {
if (ec.getDateInterviewed() != null) {
note.setEntityValue(dateFormatter.format(ec.getDateInterviewed()));
}
note.setEntityName(resword.getString("date_interviewed"));
} else if ("interviewer_name".equals(note.getColumn())) {
note.setEntityValue(ec.getInterviewerName());
note.setEntityName(resword.getString("interviewer_name"));
}
}
}
}
}
// Mantis Issue 8495.
if (note.getStudyId() != currentStudy.getId()) {
if (currentStudy.getParentStudyId() > 0) {
if (currentStudy.getId() != note.getStudySub().getStudyId()) {
addPageMessage(respage.getString("no_have_correct_privilege_current_study") + " " + respage.getString("change_active_study_or_contact"));
forwardPage(Page.MENU_SERVLET);
return;
}
} else {
// The SubjectStudy is not belong to currentstudy and current study is not a site.
StudyDAO studydao = new StudyDAO(sm.getDataSource());
Collection sites;
sites = studydao.findOlnySiteIdsByStudy(currentStudy);
if (!sites.contains(note.getStudySub().getStudyId())) {
addPageMessage(respage.getString("no_have_correct_privilege_current_study") + " " + respage.getString("change_active_study_or_contact"));
forwardPage(Page.MENU_SERVLET);
return;
}
}
}
// Check end
UserAccountDAO udao = new UserAccountDAO(sm.getDataSource());
ArrayList<DiscrepancyNoteBean> notes = dndao.findAllEntityByPK(note.getEntityType(), noteId);
Date lastUpdatedDate = note.getCreatedDate();
UserAccountBean lastUpdator = (UserAccountBean) udao.findByPK(note.getOwnerId());
/*
* for (int i = 0; i < notes.size(); i++) { DiscrepancyNoteBean n =
* (DiscrepancyNoteBean) notes.get(i); int pId = n.getParentDnId(); if
* (pId == 0) { note = n; note.setLastUpdator((UserAccountBean)
* udao.findByPK(n.getOwnerId()));
* note.setLastDateUpdated(n.getCreatedDate()); lastUpdatedDate =
* note.getLastDateUpdated(); lastUpdator = note.getLastUpdator(); } }
*/
// BWP 3029 >> This algorithm needs to be changed to properly set
// the parent note's status and updated date
// First sort the notes on their ID; this will put the parent note
// first; and
// the note with the latest status and updated date last
java.util.Collections.sort(notes);
DiscrepancyNoteBean lastChild = notes.get(notes.size() - 1);
lastUpdatedDate = lastChild.getCreatedDate();
lastUpdator = (UserAccountBean) udao.findByPK(lastChild.getOwnerId());
note.setLastUpdator(lastUpdator);
note.setLastDateUpdated(lastUpdatedDate);
note.setUpdatedDate(lastUpdatedDate);
for (DiscrepancyNoteBean dnBean : notes) {
if (dnBean.getParentDnId() > 0) {
note.getChildren().add(dnBean);
}
}
/*
* for (int i = 0; i < notes.size(); i++) { DiscrepancyNoteBean n =
* (DiscrepancyNoteBean) notes.get(i); int pId = n.getParentDnId(); if
* (pId > 0) { note.getChildren().add(n);
*
* if (!n.getCreatedDate().before(lastUpdatedDate)) { lastUpdatedDate =
* n.getCreatedDate(); lastUpdator = (UserAccountBean)
* udao.findByPK(n.getOwnerId()); note.setLastUpdator(lastUpdator);
* note.setLastDateUpdated(lastUpdatedDate);
* note.setResolutionStatusId(n.getResolutionStatusId());
* note.setResStatus(ResolutionStatus.get(n.getResolutionStatusId())); } } }
*/
note.setNumChildren(note.getChildren().size());
note.setDisType(DiscrepancyNoteType.get(note.getDiscrepancyNoteTypeId()));
request.setAttribute(DIS_NOTE, note);
forwardPage(Page.VIEW_SINGLE_NOTE);
}
use of org.akaza.openclinica.bean.submit.CRFVersionBean in project OpenClinica by OpenClinica.
the class ViewCRFVersionPreview method processRequest.
@Override
public void processRequest() throws Exception {
FormProcessor fp = new FormProcessor(request);
int crfId = fp.getInt("crfId");
// CRFVersionBean
// SectionBean
CRFVersionBean version = new CRFVersionBean();
List sections;
Map<String, Map> crfMap = (Map) session.getAttribute("preview_crf");
Map<String, String> crfIdnameInfo = null;
if (crfMap != null) {
crfIdnameInfo = crfMap.get("crf_info");
} else {
logger.info("The crfMap session attribute has expired or gone out of scope in: " + this.getClass().getName());
}
String crfName = "";
String verNumber = "";
if (crfIdnameInfo != null) {
Map.Entry mapEnt = null;
for (Iterator iter = crfIdnameInfo.entrySet().iterator(); iter.hasNext(); ) {
mapEnt = (Map.Entry) iter.next();
if (((String) mapEnt.getKey()).equalsIgnoreCase("crf_name")) {
crfName = (String) mapEnt.getValue();
}
if (((String) mapEnt.getKey()).equalsIgnoreCase("version")) {
verNumber = (String) mapEnt.getValue();
}
}
}
version.setName(verNumber);
version.setCrfId(crfId);
// A Map containing the section names as the index
Map<Integer, Map<String, String>> sectionsMap = null;
if (crfMap != null)
sectionsMap = crfMap.get("sections");
// The itemsMap contains the index of the spreadsheet table items row,
// followed by a map of the column names/values; it contains values for
// display
// such as 'left item text'
Map<Integer, Map<String, String>> itemsMap = null;
if (crfMap != null)
itemsMap = crfMap.get("items");
// Get groups meta info
Map<Integer, Map<String, String>> groupsMap = null;
if (crfMap != null)
groupsMap = crfMap.get("groups");
// Set up sections for the preview
BeanFactory beanFactory = new BeanFactory();
sections = beanFactory.createSectionBeanList(sectionsMap, itemsMap, crfName, groupsMap);
request.setAttribute("sections", sections);
request.setAttribute("version", version);
forwardPage(Page.VIEW_CRF_VERSION);
}
use of org.akaza.openclinica.bean.submit.CRFVersionBean in project OpenClinica by OpenClinica.
the class ViewEventDefinitionReadOnlyServlet method processRequest.
@Override
public void processRequest() throws Exception {
StudyEventDefinitionDAO sdao = new StudyEventDefinitionDAO(sm.getDataSource());
FormProcessor fp = new FormProcessor(request);
int defId = fp.getInt(EVENT_ID, true);
String eventOid = fp.getString(EVENT_OID);
if (defId == 0 && eventOid == null) {
addPageMessage(respage.getString("please_choose_a_definition_to_view"));
forwardPage(Page.LIST_DEFINITION_SERVLET);
return;
}
// definition id
StudyEventDefinitionBean sed = defId > 0 ? (StudyEventDefinitionBean) sdao.findByPK(defId) : (StudyEventDefinitionBean) sdao.findByOid(eventOid);
EventDefinitionCRFDAO edao = new EventDefinitionCRFDAO(sm.getDataSource());
ArrayList eventDefinitionCRFs = (ArrayList) edao.findAllByDefinition(this.currentStudy, sed.getId());
CRFVersionDAO cvdao = new CRFVersionDAO(sm.getDataSource());
CRFDAO cdao = new CRFDAO(sm.getDataSource());
for (int i = 0; i < eventDefinitionCRFs.size(); i++) {
EventDefinitionCRFBean edc = (EventDefinitionCRFBean) eventDefinitionCRFs.get(i);
ArrayList versions = (ArrayList) cvdao.findAllByCRF(edc.getCrfId());
edc.setVersions(versions);
CRFBean crf = (CRFBean) cdao.findByPK(edc.getCrfId());
// edc.setCrfLabel(crf.getLabel());
edc.setCrfName(crf.getName());
// to show/hide edit action on jsp page
if (crf.getStatus().equals(Status.AVAILABLE)) {
edc.setOwner(crf.getOwner());
}
CRFBean cBean = (CRFBean) cdao.findByPK(edc.getCrfId());
String crfPath = sed.getOid() + "." + cBean.getOid();
edc.setOffline(getEventDefinitionCrfTagService().getEventDefnCrfOfflineStatus(2, crfPath, true));
CRFVersionBean defaultVersion = (CRFVersionBean) cvdao.findByPK(edc.getDefaultVersionId());
edc.setDefaultVersionName(defaultVersion.getName());
}
StudyParameterValueDAO spvdao = new StudyParameterValueDAO(sm.getDataSource());
String participateFormStatus = spvdao.findByHandleAndStudy(sed.getStudyId(), "participantPortal").getValue();
request.setAttribute("participateFormStatus", participateFormStatus);
request.setAttribute("definition", sed);
request.setAttribute("eventDefinitionCRFs", eventDefinitionCRFs);
request.setAttribute("defSize", new Integer(eventDefinitionCRFs.size()));
// ArrayList(tm.values()));
if (defId > 0) {
forwardPage(Page.VIEW_EVENT_DEFINITION_READONLY);
} else {
forwardPage(Page.VIEW_EVENT_DEFINITION_NOSIDEBAR);
}
}
use of org.akaza.openclinica.bean.submit.CRFVersionBean in project OpenClinica by OpenClinica.
the class ViewEventDefinitionServlet method processRequest.
@Override
public void processRequest() throws Exception {
StudyEventDefinitionDAO sdao = new StudyEventDefinitionDAO(sm.getDataSource());
StudyDAO studyDao = new StudyDAO(sm.getDataSource());
FormProcessor fp = new FormProcessor(request);
int defId = fp.getInt("id", true);
if (defId == 0) {
addPageMessage(respage.getString("please_choose_a_definition_to_view"));
forwardPage(Page.LIST_DEFINITION_SERVLET);
} else {
// definition id
StudyEventDefinitionBean sed = (StudyEventDefinitionBean) sdao.findByPK(defId);
if (currentStudy.getId() != sed.getStudyId()) {
addPageMessage(respage.getString("no_have_correct_privilege_current_study") + " " + respage.getString("change_active_study_or_contact"));
forwardPage(Page.MENU_SERVLET);
return;
}
checkRoleByUserAndStudy(ub, sed.getStudyId(), 0);
EventDefinitionCRFDAO edao = new EventDefinitionCRFDAO(sm.getDataSource());
ArrayList eventDefinitionCRFs = (ArrayList) edao.findAllByDefinition(this.currentStudy, defId);
CRFVersionDAO cvdao = new CRFVersionDAO(sm.getDataSource());
CRFDAO cdao = new CRFDAO(sm.getDataSource());
for (int i = 0; i < eventDefinitionCRFs.size(); i++) {
EventDefinitionCRFBean edc = (EventDefinitionCRFBean) eventDefinitionCRFs.get(i);
ArrayList versions = (ArrayList) cvdao.findAllByCRF(edc.getCrfId());
edc.setVersions(versions);
CRFBean crf = (CRFBean) cdao.findByPK(edc.getCrfId());
// edc.setCrfLabel(crf.getLabel());
edc.setCrfName(crf.getName());
// to show/hide edit action on jsp page
if (crf.getStatus().equals(Status.AVAILABLE)) {
edc.setOwner(crf.getOwner());
}
CRFVersionBean defaultVersion = (CRFVersionBean) cvdao.findByPK(edc.getDefaultVersionId());
edc.setDefaultVersionName(defaultVersion.getName());
CRFBean cBean = (CRFBean) cdao.findByPK(edc.getCrfId());
String crfPath = sed.getOid() + "." + cBean.getOid();
edc.setOffline(getEventDefinitionCrfTagService().getEventDefnCrfOfflineStatus(2, crfPath, true));
}
StudyParameterValueDAO spvdao = new StudyParameterValueDAO(sm.getDataSource());
String participateFormStatus = spvdao.findByHandleAndStudy(sed.getStudyId(), "participantPortal").getValue();
request.setAttribute("participateFormStatus", participateFormStatus);
if (participateFormStatus.equals("enabled"))
baseUrl();
request.setAttribute("participateFormStatus", participateFormStatus);
request.setAttribute("definition", sed);
request.setAttribute("eventDefinitionCRFs", eventDefinitionCRFs);
request.setAttribute("defSize", new Integer(eventDefinitionCRFs.size()));
// request.setAttribute("eventDefinitionCRFs", new
// ArrayList(tm.values()));
forwardPage(Page.VIEW_EVENT_DEFINITION);
}
}
use of org.akaza.openclinica.bean.submit.CRFVersionBean in project OpenClinica by OpenClinica.
the class ViewTableOfContentServlet method getDisplayBean.
public static DisplayTableOfContentsBean getDisplayBean(DataSource ds, int crfVersionId) {
DisplayTableOfContentsBean answer = new DisplayTableOfContentsBean();
SectionDAO sdao = new SectionDAO(ds);
ArrayList sections = getSections(crfVersionId, ds);
answer.setSections(sections);
CRFVersionDAO cvdao = new CRFVersionDAO(ds);
CRFVersionBean cvb = (CRFVersionBean) cvdao.findByPK(crfVersionId);
answer.setCrfVersion(cvb);
CRFDAO cdao = new CRFDAO(ds);
CRFBean cb = (CRFBean) cdao.findByPK(cvb.getCrfId());
answer.setCrf(cb);
answer.setEventCRF(new EventCRFBean());
answer.setStudyEventDefinition(new StudyEventDefinitionBean());
return answer;
}
Aggregations