use of org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean in project OpenClinica by OpenClinica.
the class ParticipantEventService method getEventDefCrfsForStudyEvent.
public List<EventDefinitionCRFBean> getEventDefCrfsForStudyEvent(StudySubjectBean studySubject, StudyEventBean studyEvent) {
Integer studyId = studySubject.getStudyId();
StudyBean studyBean = (StudyBean) getStudyDAO().findByPK(studyId);
ArrayList<EventDefinitionCRFBean> eventDefCrfs = null;
ArrayList<EventDefinitionCRFBean> parentEventDefCrfs = new ArrayList<EventDefinitionCRFBean>();
ArrayList<EventDefinitionCRFBean> netEventDefinitionCrfs = new ArrayList<EventDefinitionCRFBean>();
eventDefCrfs = (ArrayList<EventDefinitionCRFBean>) getEventDefCRFDAO().findAllDefIdandStudyId(studyEvent.getStudyEventDefinitionId(), studyId);
StudyBean parentStudy = null;
if (studyBean.getParentStudyId() == 0)
parentStudy = studyBean;
else
parentStudy = (StudyBean) getStudyDAO().findByPK(studyBean.getParentStudyId());
parentEventDefCrfs = (ArrayList<EventDefinitionCRFBean>) getEventDefCRFDAO().findAllDefIdandStudyId(studyEvent.getStudyEventDefinitionId(), parentStudy.getId());
boolean found;
for (EventDefinitionCRFBean parentEventDefinitionCrf : parentEventDefCrfs) {
found = false;
for (EventDefinitionCRFBean eventDefinitionCrf : eventDefCrfs) {
if (parentEventDefinitionCrf.getId() == eventDefinitionCrf.getParentId()) {
//
found = true;
netEventDefinitionCrfs.add(eventDefinitionCrf);
break;
}
}
if (!found)
netEventDefinitionCrfs.add(parentEventDefinitionCrf);
}
return netEventDefinitionCrfs;
}
use of org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean in project OpenClinica by OpenClinica.
the class RemoveCRFFromDefinitionServlet method processRequest.
@Override
public void processRequest() throws Exception {
ArrayList edcs = (ArrayList) session.getAttribute("eventDefinitionCRFs");
ArrayList updatedEdcs = new ArrayList();
String crfName = "";
StudyEventDefinitionBean sed = (StudyEventDefinitionBean) session.getAttribute("definition");
StudyParameterValueDAO spvdao = new StudyParameterValueDAO(sm.getDataSource());
String participateFormStatus = spvdao.findByHandleAndStudy(sed.getStudyId(), "participantPortal").getValue();
request.setAttribute("participateFormStatus", participateFormStatus);
if (edcs != null && edcs.size() > 1) {
String idString = request.getParameter("id");
logger.info("crf id:" + idString);
if (StringUtil.isBlank(idString)) {
addPageMessage(respage.getString("please_choose_a_crf_to_remove"));
forwardPage(Page.UPDATE_EVENT_DEFINITION1);
} else {
// crf id
int id = Integer.valueOf(idString.trim()).intValue();
for (int i = 0; i < edcs.size(); i++) {
EventDefinitionCRFBean edc = (EventDefinitionCRFBean) edcs.get(i);
if (edc.getCrfId() == id) {
edc.setStatus(Status.DELETED);
crfName = edc.getCrfName();
}
if (edc.getId() > 0 || !edc.getStatus().equals(Status.DELETED)) {
updatedEdcs.add(edc);
logger.info("\nversion:" + edc.getDefaultVersionId());
}
}
session.setAttribute("eventDefinitionCRFs", updatedEdcs);
addPageMessage(respage.getString("has_been_removed_need_confirmation"));
forwardPage(Page.UPDATE_EVENT_DEFINITION1);
}
} else {
addPageMessage(respage.getString("an_ED_needs_to_have_least_one_CRF"));
forwardPage(Page.UPDATE_EVENT_DEFINITION1);
}
}
use of org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean in project OpenClinica by OpenClinica.
the class RemoveStudyEventServlet method getDisplayEventCRFs.
/**
* Each of the event CRFs with its corresponding CRFBean. Then generates a
* list of DisplayEventCRFBeans, one for each event CRF.
*
* @param eventCRFs
* The list of event CRFs for this study event.
* @param eventDefinitionCRFs
* The list of event definition CRFs for this study event.
* @return The list of DisplayEventCRFBeans for this study event.
*/
private ArrayList getDisplayEventCRFs(ArrayList eventCRFs, ArrayList eventDefinitionCRFs) {
ArrayList answer = new ArrayList();
HashMap definitionsById = new HashMap();
int i;
for (i = 0; i < eventDefinitionCRFs.size(); i++) {
EventDefinitionCRFBean edc = (EventDefinitionCRFBean) eventDefinitionCRFs.get(i);
definitionsById.put(new Integer(edc.getStudyEventDefinitionId()), edc);
}
StudyEventDAO sedao = new StudyEventDAO(sm.getDataSource());
CRFDAO cdao = new CRFDAO(sm.getDataSource());
CRFVersionDAO cvdao = new CRFVersionDAO(sm.getDataSource());
for (i = 0; i < eventCRFs.size(); i++) {
EventCRFBean ecb = (EventCRFBean) eventCRFs.get(i);
// populate the event CRF with its crf bean
int crfVersionId = ecb.getCRFVersionId();
CRFBean cb = cdao.findByVersionId(crfVersionId);
ecb.setCrf(cb);
CRFVersionBean cvb = (CRFVersionBean) cvdao.findByPK(crfVersionId);
ecb.setCrfVersion(cvb);
// then get the definition so we can call
// DisplayEventCRFBean.setFlags
int studyEventId = ecb.getStudyEventId();
int studyEventDefinitionId = sedao.getDefinitionIdFromStudyEventId(studyEventId);
EventDefinitionCRFBean edc = (EventDefinitionCRFBean) definitionsById.get(new Integer(studyEventDefinitionId));
DisplayEventCRFBean dec = new DisplayEventCRFBean();
dec.setFlags(ecb, ub, currentRole, edc.isDoubleEntry());
answer.add(dec);
}
return answer;
}
use of org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean in project OpenClinica by OpenClinica.
the class LockCRFVersionServlet method processRequest.
@Override
public void processRequest() throws Exception {
FormProcessor fp = new FormProcessor(request);
int crfVersionId = fp.getInt("id", true);
String action = fp.getString("action");
// checks which module the requests are from
String module = fp.getString(MODULE);
request.setAttribute(MODULE, module);
if (crfVersionId == 0) {
addPageMessage(respage.getString("choose_valid_crf_version"));
forwardPage(Page.CRF_LIST_SERVLET);
return;
}
CRFVersionDAO cvdao = new CRFVersionDAO(sm.getDataSource());
CRFDAO cdao = new CRFDAO(sm.getDataSource());
CRFVersionBean version = (CRFVersionBean) cvdao.findByPK(crfVersionId);
// System.out.println("crf version found:" + version.getName());
CRFBean crf = (CRFBean) cdao.findByPK(version.getCrfId());
if (!ub.isSysAdmin() && (version.getOwnerId() != ub.getId())) {
addPageMessage(respage.getString("no_have_correct_privilege_current_study") + " " + respage.getString("change_active_study_or_contact"));
forwardPage(Page.MENU_SERVLET);
return;
}
EventCRFDAO ecdao = new EventCRFDAO(sm.getDataSource());
ArrayList eventCRFs = ecdao.findAllStudySubjectByCRFVersion(crfVersionId);
if (StringUtil.isBlank(action)) {
request.setAttribute("crfVersionToLock", version);
request.setAttribute("crf", crf);
request.setAttribute("eventSubjectsUsingVersion", eventCRFs);
forwardPage(Page.CONFIRM_LOCKING_CRF_VERSION);
} else if ("confirm".equalsIgnoreCase(action)) {
version.setStatus(Status.LOCKED);
version.setUpdater(ub);
cvdao.update(version);
ArrayList versionList = (ArrayList) cvdao.findAllByCRF(version.getCrfId());
if (versionList.size() > 0) {
EventDefinitionCRFDAO edCRFDao = new EventDefinitionCRFDAO(sm.getDataSource());
ArrayList edcList = (ArrayList) edCRFDao.findAllByCRF(version.getCrfId());
for (int i = 0; i < edcList.size(); i++) {
EventDefinitionCRFBean edcBean = (EventDefinitionCRFBean) edcList.get(i);
// @pgawade 18-May-2011 #5414 - Changes for setting the correct
// default crf version Id to event
// when existing default version is locked
// RemoveCRFVersionServlet.updateEventDef(edcBean, edCRFDao,
// versionList);
RemoveCRFVersionServlet.updateEventDef(edcBean, edCRFDao, versionList, crfVersionId);
}
}
addPageMessage(respage.getString("crf_version_archived_successfully"));
forwardPage(Page.CRF_LIST_SERVLET);
}
}
use of org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean in project OpenClinica by OpenClinica.
the class UnlockEventDefinitionServlet method processRequest.
@Override
public void processRequest() throws Exception {
String idString = request.getParameter("id");
int defId = Integer.valueOf(idString.trim()).intValue();
StudyEventDefinitionDAO sdao = new StudyEventDefinitionDAO(sm.getDataSource());
StudyEventDefinitionBean sed = (StudyEventDefinitionBean) sdao.findByPK(defId);
// find all CRFs
EventDefinitionCRFDAO edao = new EventDefinitionCRFDAO(sm.getDataSource());
ArrayList eventDefinitionCRFs = (ArrayList) edao.findAllByDefinition(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.setCrfName(crf.getName());
}
// finds all events
StudyEventDAO sedao = new StudyEventDAO(sm.getDataSource());
ArrayList events = (ArrayList) sedao.findAllByDefinition(sed.getId());
String action = request.getParameter("action");
if (StringUtil.isBlank(idString)) {
addPageMessage(respage.getString("please_choose_a_SED_to_unlock"));
forwardPage(Page.LIST_DEFINITION_SERVLET);
} else {
if ("confirm".equalsIgnoreCase(action)) {
if (!sed.getStatus().equals(Status.LOCKED)) {
addPageMessage(respage.getString("this_SED_cannot_be_unlocked") + " " + respage.getString("please_contact_sysadmin_for_more_information"));
forwardPage(Page.LIST_DEFINITION_SERVLET);
return;
}
request.setAttribute("definitionToUnlock", sed);
request.setAttribute("eventDefinitionCRFs", eventDefinitionCRFs);
request.setAttribute("events", events);
forwardPage(Page.UNLOCK_DEFINITION);
} else {
logger.info("submit to lock the definition");
// unlock definition
sed.setStatus(Status.AVAILABLE);
sed.setUpdater(ub);
sed.setUpdatedDate(new Date());
sdao.update(sed);
// lock all crfs
for (int j = 0; j < eventDefinitionCRFs.size(); j++) {
EventDefinitionCRFBean edc = (EventDefinitionCRFBean) eventDefinitionCRFs.get(j);
edc.setStatus(Status.AVAILABLE);
edc.setUpdater(ub);
edc.setUpdatedDate(new Date());
edao.update(edc);
}
// unlock all events
EventCRFDAO ecdao = new EventCRFDAO(sm.getDataSource());
for (int j = 0; j < events.size(); j++) {
StudyEventBean event = (StudyEventBean) events.get(j);
event.setStatus(Status.AVAILABLE);
event.setUpdater(ub);
event.setUpdatedDate(new Date());
sedao.update(event);
ArrayList eventCRFs = ecdao.findAllByStudyEvent(event);
// unlock all the item data
ItemDataDAO iddao = new ItemDataDAO(sm.getDataSource());
for (int k = 0; k < eventCRFs.size(); k++) {
EventCRFBean eventCRF = (EventCRFBean) eventCRFs.get(k);
eventCRF.setStatus(Status.AVAILABLE);
eventCRF.setUpdater(ub);
eventCRF.setUpdatedDate(new Date());
ecdao.update(eventCRF);
ArrayList itemDatas = iddao.findAllByEventCRFId(eventCRF.getId());
for (int a = 0; a < itemDatas.size(); a++) {
ItemDataBean item = (ItemDataBean) itemDatas.get(a);
item.setStatus(Status.AVAILABLE);
item.setUpdater(ub);
item.setUpdatedDate(new Date());
iddao.update(item);
}
}
}
String emailBody = respage.getString("the_SED") + " " + sed.getName() + respage.getString("has_been_unlocked_for_the_study") + " " + currentStudy.getName() + ". " + respage.getString("subject_event_data_is_as_it_was_before");
addPageMessage(emailBody);
sendEmail(emailBody);
forwardPage(Page.LIST_DEFINITION_SERVLET);
}
}
}
Aggregations