use of org.akaza.openclinica.dao.managestudy.StudyDAO in project OpenClinica by OpenClinica.
the class EditDatasetServlet method initializeAttributes.
/**
* Initialize data of a DatasetBean and set session attributes for displaying selected data of this DatasetBean
*
* @param db
* @return
*/
// @author ywang (Feb, 2008)
public DatasetBean initializeAttributes(int datasetId) {
DatasetDAO dsdao = new DatasetDAO(sm.getDataSource());
DatasetBean db = dsdao.initialDatasetData(datasetId);
session.setAttribute("newDataset", db);
session.setAttribute("allItems", db.getItemDefCrf().clone());
session.setAttribute("allSelectedItems", db.getItemDefCrf().clone());
StudyGroupClassDAO sgcdao = new StudyGroupClassDAO(sm.getDataSource());
StudyDAO studydao = new StudyDAO(sm.getDataSource());
StudyBean theStudy = (StudyBean) studydao.findByPK(sm.getUserBean().getActiveStudyId());
ArrayList<StudyGroupClassBean> allSelectedGroups = sgcdao.findAllActiveByStudy(theStudy);
ArrayList<Integer> selectedSubjectGroupIds = db.getSubjectGroupIds();
if (selectedSubjectGroupIds != null && allSelectedGroups != null) {
for (Integer id : selectedSubjectGroupIds) {
for (int i = 0; i < allSelectedGroups.size(); ++i) {
if (allSelectedGroups.get(i).getId() == id) {
allSelectedGroups.get(i).setSelected(true);
break;
}
}
}
}
session.setAttribute("allSelectedGroups", allSelectedGroups);
return db;
}
use of org.akaza.openclinica.dao.managestudy.StudyDAO in project OpenClinica by OpenClinica.
the class EditSelectedServlet method setUpStudyGroups.
/*
* TODO this function exists in four different places... needs to be added to an additional superclass for Submit Data Control Servlets, tbh July 2007
*/
public void setUpStudyGroups() {
ArrayList sgclasses = (ArrayList) session.getAttribute("allSelectedGroups");
if (sgclasses == null || sgclasses.size() == 0) {
StudyDAO studydao = new StudyDAO(sm.getDataSource());
StudyGroupClassDAO sgclassdao = new StudyGroupClassDAO(sm.getDataSource());
StudyBean theStudy = (StudyBean) studydao.findByPK(sm.getUserBean().getActiveStudyId());
sgclasses = sgclassdao.findAllActiveByStudy(theStudy);
}
session.setAttribute("allSelectedGroups", sgclasses);
request.setAttribute("allSelectedGroups", sgclasses);
}
use of org.akaza.openclinica.dao.managestudy.StudyDAO in project OpenClinica by OpenClinica.
the class ViewDatasetsServlet method initializeAttributes.
/**
* Initialize data of a DatasetBean and set session attributes for
* displaying selected data of this DatasetBean
*
* @param db
* @return
*/
// @author ywang (Feb, 2008)
public DatasetBean initializeAttributes(int datasetId) {
DatasetDAO dsdao = new DatasetDAO(sm.getDataSource());
DatasetBean db = dsdao.initialDatasetData(datasetId);
session.setAttribute("newDataset", db);
session.setAttribute("allItems", db.getItemDefCrf().clone());
session.setAttribute("allSelectedItems", db.getItemDefCrf().clone());
StudyGroupClassDAO sgcdao = new StudyGroupClassDAO(sm.getDataSource());
StudyDAO studydao = new StudyDAO(sm.getDataSource());
StudyBean theStudy = (StudyBean) studydao.findByPK(sm.getUserBean().getActiveStudyId());
ArrayList<StudyGroupClassBean> allSelectedGroups = sgcdao.findAllActiveByStudy(theStudy);
ArrayList<Integer> selectedSubjectGroupIds = db.getSubjectGroupIds();
if (selectedSubjectGroupIds != null && allSelectedGroups != null) {
for (Integer id : selectedSubjectGroupIds) {
for (int i = 0; i < allSelectedGroups.size(); ++i) {
if (allSelectedGroups.get(i).getId() == id) {
allSelectedGroups.get(i).setSelected(true);
break;
}
}
}
}
session.setAttribute("allSelectedGroups", allSelectedGroups);
return db;
}
use of org.akaza.openclinica.dao.managestudy.StudyDAO in project OpenClinica by OpenClinica.
the class ViewSelectedServlet method setUpStudyGroups.
/*
* setup study groups, tbh, added july 2007 FIXME in general a repeated set
* of code -- need to create a superclass which will contain this class, tbh
*/
public void setUpStudyGroups() {
ArrayList sgclasses = (ArrayList) session.getAttribute("allSelectedGroups");
if (sgclasses == null || sgclasses.size() == 0) {
StudyDAO studydao = new StudyDAO(sm.getDataSource());
StudyGroupClassDAO sgclassdao = new StudyGroupClassDAO(sm.getDataSource());
StudyBean theStudy = (StudyBean) studydao.findByPK(sm.getUserBean().getActiveStudyId());
sgclasses = sgclassdao.findAllActiveByStudy(theStudy);
}
session.setAttribute("allSelectedGroups", sgclasses);
session.setAttribute("numberOfStudyGroups", sgclasses.size());
request.setAttribute("allSelectedGroups", sgclasses);
}
use of org.akaza.openclinica.dao.managestudy.StudyDAO in project OpenClinica by OpenClinica.
the class ViewStudyServlet method processRequest.
@Override
public void processRequest() throws Exception {
StudyDAO sdao = new StudyDAO(sm.getDataSource());
FormProcessor fp = new FormProcessor(request);
int studyId = fp.getInt("id");
if (studyId == 0) {
addPageMessage(respage.getString("please_choose_a_study_to_view"));
forwardPage(Page.STUDY_LIST_SERVLET);
} else {
if (currentStudy.getId() != studyId && currentStudy.getParentStudyId() != studyId) {
checkRoleByUserAndStudy(ub, studyId, 0);
}
String viewFullRecords = fp.getString("viewFull");
StudyBean study = (StudyBean) sdao.findByPK(studyId);
StudyConfigService scs = new StudyConfigService(sm.getDataSource());
study = scs.setParametersForStudy(study);
StudyParameterValueDAO spvdao = new StudyParameterValueDAO(sm.getDataSource());
String randomizationStatusInOC = spvdao.findByHandleAndStudy(study.getId(), "randomization").getValue();
String participantStatusInOC = spvdao.findByHandleAndStudy(study.getId(), "participantPortal").getValue();
if (participantStatusInOC == "")
participantStatusInOC = "disabled";
if (randomizationStatusInOC == "")
randomizationStatusInOC = "disabled";
RandomizationRegistrar randomizationRegistrar = new RandomizationRegistrar();
SeRandomizationDTO seRandomizationDTO = randomizationRegistrar.getCachedRandomizationDTOObject(study.getOid(), false);
if (seRandomizationDTO != null && seRandomizationDTO.getStatus().equalsIgnoreCase("ACTIVE") && randomizationStatusInOC.equalsIgnoreCase("enabled")) {
study.getStudyParameterConfig().setRandomization("enabled");
} else {
study.getStudyParameterConfig().setRandomization("disabled");
}
;
ParticipantPortalRegistrar participantPortalRegistrar = new ParticipantPortalRegistrar();
String pStatus = participantPortalRegistrar.getCachedRegistrationStatus(study.getOid(), session);
if (participantPortalRegistrar != null && pStatus.equalsIgnoreCase("ACTIVE") && participantStatusInOC.equalsIgnoreCase("enabled")) {
study.getStudyParameterConfig().setParticipantPortal("enabled");
} else {
study.getStudyParameterConfig().setParticipantPortal("disabled");
}
;
request.setAttribute("studyToView", study);
if ("yes".equalsIgnoreCase(viewFullRecords)) {
UserAccountDAO udao = new UserAccountDAO(sm.getDataSource());
StudySubjectDAO ssdao = new StudySubjectDAO(sm.getDataSource());
ArrayList sites = new ArrayList();
ArrayList userRoles = new ArrayList();
ArrayList subjects = new ArrayList();
if (this.currentStudy.getParentStudyId() > 0 && this.currentRole.getRole().getId() > 3) {
sites.add(this.currentStudy);
userRoles = udao.findAllUsersByStudy(currentStudy.getId());
subjects = ssdao.findAllByStudy(currentStudy);
} else {
sites = (ArrayList) sdao.findAllByParent(studyId);
userRoles = udao.findAllUsersByStudy(studyId);
subjects = ssdao.findAllByStudy(study);
}
// find all subjects in the study, include ones in sites
StudyEventDefinitionDAO seddao = new StudyEventDefinitionDAO(sm.getDataSource());
EventDefinitionCRFDAO edcdao = new EventDefinitionCRFDAO(sm.getDataSource());
// StudyEventDAO sedao = new StudyEventDAO(sm.getDataSource());
// ArrayList displayStudySubs = new ArrayList();
// for (int i = 0; i < subjects.size(); i++) {
// StudySubjectBean studySub = (StudySubjectBean) subjects.get(i);
// // find all events
// ArrayList events = sedao.findAllByStudySubject(studySub);
//
// // find all eventcrfs for each event
// EventCRFDAO ecdao = new EventCRFDAO(sm.getDataSource());
//
// DisplayStudySubjectBean dssb = new DisplayStudySubjectBean();
// dssb.setStudyEvents(events);
// dssb.setStudySubject(studySub);
// displayStudySubs.add(dssb);
// }
// find all events in the study, include ones in sites
ArrayList definitions = seddao.findAllByStudy(study);
for (int i = 0; i < definitions.size(); i++) {
StudyEventDefinitionBean def = (StudyEventDefinitionBean) definitions.get(i);
ArrayList crfs = (ArrayList) edcdao.findAllActiveParentsByEventDefinitionId(def.getId());
def.setCrfNum(crfs.size());
}
String moduleManager = CoreResources.getField("moduleManager");
request.setAttribute("moduleManager", moduleManager);
String portalURL = CoreResources.getField("portalURL");
request.setAttribute("portalURL", portalURL);
request.setAttribute("config", study);
request.setAttribute("sitesToView", sites);
request.setAttribute("siteNum", sites.size() + "");
request.setAttribute("userRolesToView", userRoles);
request.setAttribute("userNum", userRoles.size() + "");
// request.setAttribute("subjectsToView", displayStudySubs);
// request.setAttribute("subjectNum", subjects.size() + "");
request.setAttribute("definitionsToView", definitions);
request.setAttribute("defNum", definitions.size() + "");
forwardPage(Page.VIEW_FULL_STUDY);
} else {
forwardPage(Page.VIEW_STUDY);
}
}
}
Aggregations