use of org.akaza.openclinica.dao.managestudy.StudyGroupClassDAO in project OpenClinica by OpenClinica.
the class SecureController method getStudyGroupClassesByCurrentStudy.
public ArrayList getStudyGroupClassesByCurrentStudy() {
StudyDAO studyDAO = new StudyDAO(sm.getDataSource());
StudyGroupClassDAO studyGroupClassDAO = new StudyGroupClassDAO(sm.getDataSource());
StudyGroupDAO studyGroupDAO = new StudyGroupDAO(sm.getDataSource());
int parentStudyId = currentStudy.getParentStudyId();
ArrayList studyGroupClasses = new ArrayList();
if (parentStudyId > 0) {
StudyBean parentStudy = (StudyBean) studyDAO.findByPK(parentStudyId);
studyGroupClasses = studyGroupClassDAO.findAllActiveByStudy(parentStudy);
} else {
parentStudyId = currentStudy.getId();
studyGroupClasses = studyGroupClassDAO.findAllActiveByStudy(currentStudy);
}
for (int i = 0; i < studyGroupClasses.size(); i++) {
StudyGroupClassBean sgc = (StudyGroupClassBean) studyGroupClasses.get(i);
ArrayList groups = studyGroupDAO.findAllByGroupClass(sgc);
sgc.setStudyGroups(groups);
}
return studyGroupClasses;
}
use of org.akaza.openclinica.dao.managestudy.StudyGroupClassDAO in project OpenClinica by OpenClinica.
the class CreateDatasetServlet method setUpStudyGroups.
/*
* public void setUpStudyGroups() { StudyDAO studydao = new
* StudyDAO(sm.getDataSource()); StudyGroupClassDAO sgclassdao = new
* StudyGroupClassDAO(sm.getDataSource()); StudyBean theStudy =
* (StudyBean)studydao.findByPK(sm.getUserBean().getActiveStudyId());
* ArrayList sgclasses = sgclassdao.findAllActiveByStudy(theStudy);
* //StudyGroupClassBean sgclass = (StudyGroupClassBean)sgclasses.get(0);
* //get the first one and test its name //logger.info("found study class
* "+sgclass.getName()); request.setAttribute("sgclasses", sgclasses); }
*/
public ArrayList setUpStudyGroups() {
StudyDAO studydao = new StudyDAO(sm.getDataSource());
StudyGroupClassDAO sgclassdao = new StudyGroupClassDAO(sm.getDataSource());
StudyBean theStudy = (StudyBean) studydao.findByPK(sm.getUserBean().getActiveStudyId());
ArrayList sgclasses = sgclassdao.findAllActiveByStudy(theStudy);
// logger.info("found study class "+sgclass.getName());
return sgclasses;
}
use of org.akaza.openclinica.dao.managestudy.StudyGroupClassDAO 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.StudyGroupClassDAO 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.StudyGroupClassDAO 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;
}
Aggregations