use of org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean in project OpenClinica by OpenClinica.
the class DefineStudyEventServlet method submitDefinition.
/**
* Inserts the new study into database NullPointer catch added by tbh
* 092007, mean to fix task #1642 in Mantis
*/
private void submitDefinition() throws NullPointerException {
StudyEventDefinitionDAO edao = new StudyEventDefinitionDAO(sm.getDataSource());
StudyEventDefinitionBean sed = (StudyEventDefinitionBean) session.getAttribute("definition");
// added tbh 092007, to catch bug # 1531
if (sed.getName() == "" || sed.getName() == null) {
throw new NullPointerException();
}
logger.debug("Definition bean to be created:" + sed.getName() + sed.getStudyId());
// fine the last one's ordinal
ArrayList defs = edao.findAllByStudy(currentStudy);
if (defs == null || defs.isEmpty()) {
sed.setOrdinal(1);
} else {
int lastCount = defs.size() - 1;
StudyEventDefinitionBean last = (StudyEventDefinitionBean) defs.get(lastCount);
sed.setOrdinal(last.getOrdinal() + 1);
}
sed.setOwner(ub);
sed.setCreatedDate(new Date());
sed.setStatus(Status.AVAILABLE);
StudyEventDefinitionBean sed1 = (StudyEventDefinitionBean) edao.create(sed);
EventDefinitionCRFDAO cdao = new EventDefinitionCRFDAO(sm.getDataSource());
CRFDAO crfdao = new CRFDAO(sm.getDataSource());
StudyEventDefinitionDAO seddao = new StudyEventDefinitionDAO(sm.getDataSource());
ArrayList eventDefinitionCRFs = new ArrayList();
if (session.getAttribute("edCRFs") != null) {
eventDefinitionCRFs = (ArrayList) session.getAttribute("edCRFs");
}
for (int i = 0; i < eventDefinitionCRFs.size(); i++) {
EventDefinitionCRFBean edc = (EventDefinitionCRFBean) eventDefinitionCRFs.get(i);
edc.setOwner(ub);
edc.setCreatedDate(new Date());
edc.setStatus(Status.AVAILABLE);
edc.setStudyEventDefinitionId(sed1.getId());
edc.setOrdinal(i + 1);
StudyEventDefinitionBean sedBean = (StudyEventDefinitionBean) seddao.findByPK(sed.getId());
CRFBean cBean = (CRFBean) crfdao.findByPK(edc.getCrfId());
String crfPath = sedBean.getOid() + "." + cBean.getOid();
getEventDefinitionCrfTagService().saveEventDefnCrfOfflineTag(2, crfPath, edc, sedBean);
cdao.create(edc);
}
session.removeAttribute("definition");
session.removeAttribute("edCRFs");
session.removeAttribute("crfsWithVersion");
addPageMessage(respage.getString("the_new_event_definition_created_succesfully"));
}
use of org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean in project OpenClinica by OpenClinica.
the class InitUpdateEventDefinitionServlet method processRequest.
@Override
public void processRequest() throws Exception {
StudyEventDefinitionDAO sdao = new StudyEventDefinitionDAO(sm.getDataSource());
String idString = request.getParameter("id");
logger.info("definition id: " + idString);
if (StringUtil.isBlank(idString)) {
addPageMessage(respage.getString("please_choose_a_definition_to_edit"));
forwardPage(Page.LIST_DEFINITION_SERVLET);
} else {
// definition id
int defId = Integer.valueOf(idString.trim()).intValue();
StudyEventDefinitionBean sed = (StudyEventDefinitionBean) sdao.findByPK(defId);
StudyParameterValueDAO spvdao = new StudyParameterValueDAO(sm.getDataSource());
String participateFormStatus = spvdao.findByHandleAndStudy(sed.getStudyId(), "participantPortal").getValue();
if (participateFormStatus.equals("enabled"))
baseUrl();
request.setAttribute("participateFormStatus", participateFormStatus);
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;
}
EventDefinitionCRFDAO edao = new EventDefinitionCRFDAO(sm.getDataSource());
ArrayList eventDefinitionCRFs = (ArrayList) edao.findAllParentsByDefinition(defId);
CRFVersionDAO cvdao = new CRFVersionDAO(sm.getDataSource());
CRFDAO cdao = new CRFDAO(sm.getDataSource());
ArrayList newEventDefinitionCRFs = new ArrayList();
for (int i = 0; i < eventDefinitionCRFs.size(); i++) {
EventDefinitionCRFBean edc = (EventDefinitionCRFBean) eventDefinitionCRFs.get(i);
ArrayList versions = (ArrayList) cvdao.findAllActiveByCRF(edc.getCrfId());
edc.setVersions(versions);
CRFBean crf = (CRFBean) cdao.findByPK(edc.getCrfId());
edc.setCrfName(crf.getName());
edc.setCrf(crf);
edc.setParticipantForm(edc.isParticipantForm());
// TO DO: use a better way on JSP page,eg.function tag
edc.setNullFlags(processNullValues(edc));
CRFVersionBean defaultVersion = (CRFVersionBean) cvdao.findByPK(edc.getDefaultVersionId());
edc.setDefaultVersionName(defaultVersion.getName());
String crfPath = sed.getOid() + "." + edc.getCrf().getOid();
edc.setOffline(getEventDefinitionCrfTagService().getEventDefnCrfOfflineStatus(2, crfPath, true));
newEventDefinitionCRFs.add(edc);
}
session.setAttribute("definition", sed);
session.setAttribute("eventDefinitionCRFs", newEventDefinitionCRFs);
// changed above to new list because static, in-place updating is
// updating all EDCs, tbh 102007
ArrayList<String> sdvOptions = new ArrayList<String>();
sdvOptions.add(SourceDataVerification.AllREQUIRED.toString());
sdvOptions.add(SourceDataVerification.PARTIALREQUIRED.toString());
sdvOptions.add(SourceDataVerification.NOTREQUIRED.toString());
sdvOptions.add(SourceDataVerification.NOTAPPLICABLE.toString());
request.setAttribute("sdvOptions", sdvOptions);
forwardPage(Page.UPDATE_EVENT_DEFINITION1);
}
}
use of org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean in project OpenClinica by OpenClinica.
the class InitUpdateSubStudyServlet method createEventDefinitions.
private void createEventDefinitions(StudyBean parentStudy) throws MalformedURLException {
FormProcessor fp = new FormProcessor(request);
StudyParameterValueDAO spvdao = new StudyParameterValueDAO(sm.getDataSource());
int siteId = Integer.valueOf(request.getParameter("id").trim());
ArrayList<StudyEventDefinitionBean> seds = new ArrayList<StudyEventDefinitionBean>();
StudyEventDefinitionDAO sedDao = new StudyEventDefinitionDAO(sm.getDataSource());
EventDefinitionCRFDAO edcdao = new EventDefinitionCRFDAO(sm.getDataSource());
CRFVersionDAO cvdao = new CRFVersionDAO(sm.getDataSource());
CRFDAO cdao = new CRFDAO(sm.getDataSource());
seds = sedDao.findAllByStudy(parentStudy);
int start = 0;
for (StudyEventDefinitionBean sed : seds) {
String participateFormStatus = spvdao.findByHandleAndStudy(sed.getStudyId(), "participantPortal").getValue();
if (participateFormStatus.equals("enabled"))
baseUrl();
request.setAttribute("participateFormStatus", participateFormStatus);
int defId = sed.getId();
ArrayList<EventDefinitionCRFBean> edcs = (ArrayList<EventDefinitionCRFBean>) edcdao.findAllByDefinitionAndSiteIdAndParentStudyId(defId, siteId, parentStudy.getId());
ArrayList<EventDefinitionCRFBean> defCrfs = new ArrayList<EventDefinitionCRFBean>();
// sed.setCrfNum(edcs.size());
for (EventDefinitionCRFBean edcBean : edcs) {
CRFBean cBean = (CRFBean) cdao.findByPK(edcBean.getCrfId());
String crfPath = sed.getOid() + "." + cBean.getOid();
edcBean.setOffline(getEventDefinitionCrfTagService().getEventDefnCrfOfflineStatus(2, crfPath, true));
int edcStatusId = edcBean.getStatus().getId();
CRFBean crf = (CRFBean) cdao.findByPK(edcBean.getCrfId());
int crfStatusId = crf.getStatusId();
if (edcStatusId == 5 || edcStatusId == 7 || crfStatusId == 5 || crfStatusId == 7) {
} else {
ArrayList<CRFVersionBean> versions = (ArrayList<CRFVersionBean>) cvdao.findAllActiveByCRF(edcBean.getCrfId());
edcBean.setVersions(versions);
edcBean.setCrfName(crf.getName());
if (edcBean.getParentId() == 0)
edcBean.setSubmissionUrl("");
CRFVersionBean defaultVersion = (CRFVersionBean) cvdao.findByPK(edcBean.getDefaultVersionId());
edcBean.setDefaultVersionName(defaultVersion.getName());
String sversionIds = edcBean.getSelectedVersionIds();
ArrayList<Integer> idList = new ArrayList<Integer>();
if (sversionIds.length() > 0) {
String[] ids = sversionIds.split("\\,");
for (String id : ids) {
idList.add(Integer.valueOf(id));
}
}
edcBean.setSelectedVersionIdList(idList);
defCrfs.add(edcBean);
++start;
}
}
logger.debug("definitionCrfs size=" + defCrfs.size() + " total size=" + edcs.size());
sed.setCrfs(defCrfs);
sed.setCrfNum(defCrfs.size());
}
// not sure if request is better, since not sure if there is another
// process using this.
session.setAttribute("definitions", seds);
session.setAttribute("sdvOptions", this.setSDVOptions());
}
use of org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean in project OpenClinica by OpenClinica.
the class ChangeDefinitionOrdinalServlet method increase.
/**
* increase the ordinal for current object and decrease the ordinal of the
* previous one
*
* @param idCurrent
* @param idPrevious
*/
private void increase(int idCurrent, int idPrevious, StudyEventDefinitionDAO dao) {
if (idCurrent > 0) {
StudyEventDefinitionBean current = (StudyEventDefinitionBean) dao.findByPK(idCurrent);
int currentOrdinal = current.getOrdinal();
current.setOrdinal(currentOrdinal - 1);
dao.update(current);
}
if (idPrevious > 0) {
StudyEventDefinitionBean previous = (StudyEventDefinitionBean) dao.findByPK(idPrevious);
int previousOrdinal = previous.getOrdinal();
previous.setOrdinal(previousOrdinal + 1);
dao.update(previous);
}
}
use of org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean in project OpenClinica by OpenClinica.
the class CreateSubStudyServlet method initDefinitions.
private ArrayList<StudyEventDefinitionBean> initDefinitions(StudyBean site) throws MalformedURLException {
StudyParameterValueDAO spvdao = new StudyParameterValueDAO(sm.getDataSource());
ArrayList<StudyEventDefinitionBean> seds = new ArrayList<StudyEventDefinitionBean>();
StudyEventDefinitionDAO sedDao = new StudyEventDefinitionDAO(sm.getDataSource());
EventDefinitionCRFDAO edcdao = new EventDefinitionCRFDAO(sm.getDataSource());
CRFVersionDAO cvdao = new CRFVersionDAO(sm.getDataSource());
CRFDAO cdao = new CRFDAO(sm.getDataSource());
StudyBean parentStudy = (StudyBean) new StudyDAO(sm.getDataSource()).findByPK(site.getParentStudyId());
seds = sedDao.findAllByStudy(parentStudy);
int start = 0;
for (StudyEventDefinitionBean sed : seds) {
String participateFormStatus = spvdao.findByHandleAndStudy(sed.getStudyId(), "participantPortal").getValue();
if (participateFormStatus.equals("enabled"))
baseUrl();
request.setAttribute("participateFormStatus", participateFormStatus);
int defId = sed.getId();
ArrayList<EventDefinitionCRFBean> edcs = (ArrayList<EventDefinitionCRFBean>) edcdao.findAllByDefinitionAndSiteIdAndParentStudyId(defId, site.getId(), parentStudy.getId());
ArrayList<EventDefinitionCRFBean> defCrfs = new ArrayList<EventDefinitionCRFBean>();
// sed.setCrfNum(edcs.size());
for (EventDefinitionCRFBean edcBean : edcs) {
CRFBean cBean = (CRFBean) cdao.findByPK(edcBean.getCrfId());
String crfPath = sed.getOid() + "." + cBean.getOid();
edcBean.setOffline(getEventDefinitionCrfTagService().getEventDefnCrfOfflineStatus(2, crfPath, true));
int edcStatusId = edcBean.getStatus().getId();
CRFBean crf = (CRFBean) cdao.findByPK(edcBean.getCrfId());
int crfStatusId = crf.getStatusId();
if (edcStatusId == 5 || edcStatusId == 7 || crfStatusId == 5 || crfStatusId == 7) {
} else {
ArrayList<CRFVersionBean> versions = (ArrayList<CRFVersionBean>) cvdao.findAllActiveByCRF(edcBean.getCrfId());
edcBean.setVersions(versions);
edcBean.setCrfName(crf.getName());
CRFVersionBean defaultVersion = (CRFVersionBean) cvdao.findByPK(edcBean.getDefaultVersionId());
edcBean.setDefaultVersionName(defaultVersion.getName());
edcBean.setSubmissionUrl("");
/* EventDefinitionCRFBean eBean = (EventDefinitionCRFBean) edcdao.findByPK(edcBean.getId());
if (eBean.isActive()){
edcBean.setSubmissionUrl(eBean.getSubmissionUrl());
}else{
edcBean.setSubmissionUrl("");
}
*/
String sversionIds = edcBean.getSelectedVersionIds();
ArrayList<Integer> idList = new ArrayList<Integer>();
if (sversionIds.length() > 0) {
String[] ids = sversionIds.split("\\,");
for (String id : ids) {
idList.add(Integer.valueOf(id));
}
}
edcBean.setSelectedVersionIdList(idList);
defCrfs.add(edcBean);
++start;
}
}
logger.debug("definitionCrfs size=" + defCrfs.size() + " total size=" + edcs.size());
sed.setCrfs(defCrfs);
sed.setCrfNum(defCrfs.size());
}
return seds;
}
Aggregations