use of org.akaza.openclinica.dao.managestudy.StudyDAO in project OpenClinica by OpenClinica.
the class AdminSystemServlet method processRequest.
// < ResourceBundleresword,resexception;
/*
* (non-Javadoc)
*
* @see org.akaza.openclinica.control.core.SecureController#processRequest()
*/
@Override
protected void processRequest() throws Exception {
// find last 5 modifed studies
StudyDAO sdao = new StudyDAO(sm.getDataSource());
ArrayList studies = (ArrayList) sdao.findAllByLimit(true);
request.setAttribute("studies", studies);
ArrayList allStudies = (ArrayList) sdao.findAll();
request.setAttribute("allStudyNumber", new Integer(allStudies.size()));
UserAccountDAO udao = new UserAccountDAO(sm.getDataSource());
ArrayList users = (ArrayList) udao.findAllByLimit(true);
request.setAttribute("users", users);
ArrayList allUsers = (ArrayList) udao.findAll();
request.setAttribute("allUserNumber", new Integer(allUsers.size()));
SubjectDAO subdao = new SubjectDAO(sm.getDataSource());
ArrayList subjects = (ArrayList) subdao.findAllByLimit(true);
request.setAttribute("subjects", subjects);
ArrayList allSubjects = (ArrayList) subdao.findAll();
request.setAttribute("allSubjectNumber", new Integer(allSubjects.size()));
CRFDAO cdao = new CRFDAO(sm.getDataSource());
ArrayList crfs = (ArrayList) cdao.findAllByLimit(true);
request.setAttribute("crfs", crfs);
ArrayList allCrfs = (ArrayList) cdao.findAll();
request.setAttribute("allCrfNumber", new Integer(allCrfs.size()));
resetPanel();
panel.setOrderedData(true);
setToPanel(resword.getString("in_the_application"), "");
if (allSubjects.size() > 0) {
setToPanel(resword.getString("subjects"), new Integer(allSubjects.size()).toString());
}
if (allUsers.size() > 0) {
setToPanel(resword.getString("users"), new Integer(allUsers.size()).toString());
}
if (allStudies.size() > 0) {
setToPanel(resword.getString("studies"), new Integer(allStudies.size()).toString());
}
if (allCrfs.size() > 0) {
setToPanel(resword.getString("CRFs"), new Integer(allCrfs.size()).toString());
}
panel.setStudyInfoShown(false);
forwardPage(Page.ADMIN_SYSTEM);
}
use of org.akaza.openclinica.dao.managestudy.StudyDAO in project OpenClinica by OpenClinica.
the class AuditLogStudyServlet method processRequest.
/*
* (non-Javadoc) Assume that we get the user id automatically. We will jump
* from the edit user page if the user is an admin, they can get to see the
* users' log
*
* @see org.akaza.openclinica.control.core.SecureController#processRequest()
*/
/*
* (non-Javadoc) redo this servlet to run the audits per study subject for
* the study; need to add a studyId param and then use the
* StudySubjectDAO.findAllByStudyOrderByLabel() method to grab a lot of
* study subject beans and then return them much like in
* ViewStudySubjectAuditLogServet.process()
*
* currentStudy instead of studyId?
*/
@Override
protected void processRequest() throws Exception {
int studyId = currentStudy.getId();
StudySubjectDAO subdao = new StudySubjectDAO(sm.getDataSource());
SubjectDAO sdao = new SubjectDAO(sm.getDataSource());
AuditDAO adao = new AuditDAO(sm.getDataSource());
FormProcessor fp = new FormProcessor(request);
StudyEventDAO sedao = new StudyEventDAO(sm.getDataSource());
StudyEventDefinitionDAO seddao = new StudyEventDefinitionDAO(sm.getDataSource());
EventDefinitionCRFDAO edcdao = new EventDefinitionCRFDAO(sm.getDataSource());
EventCRFDAO ecdao = new EventCRFDAO(sm.getDataSource());
StudyDAO studydao = new StudyDAO(sm.getDataSource());
CRFDAO cdao = new CRFDAO(sm.getDataSource());
CRFVersionDAO cvdao = new CRFVersionDAO(sm.getDataSource());
HashMap eventCRFAuditsHashMap = new HashMap();
HashMap eventsHashMap = new HashMap();
HashMap studySubjectAuditsHashMap = new HashMap();
HashMap subjectHashMap = new HashMap();
ArrayList studySubjects = subdao.findAllByStudyOrderByLabel(currentStudy);
logger.info("found " + studySubjects.size() + " study subjects");
request.setAttribute("studySubjects", studySubjects);
for (int ss = 0; ss < studySubjects.size(); ss++) {
ArrayList studySubjectAudits = new ArrayList();
ArrayList eventCRFAudits = new ArrayList();
StudySubjectBean studySubject = (StudySubjectBean) studySubjects.get(ss);
// request.setAttribute("studySub"+ss, studySubject);
SubjectBean subject = (SubjectBean) sdao.findByPK(studySubject.getSubjectId());
subjectHashMap.put(new Integer(studySubject.getId()), subject);
// logger.info("just set a subject with a status of
// "+subject.getStatus().getName());
// request.setAttribute("subject"+ss, subject);
StudyBean study = (StudyBean) studydao.findByPK(studySubject.getStudyId());
request.setAttribute("study", study);
// hmm, repetitive work?
// Show both study subject and subject audit events together
// Study
studySubjectAudits.addAll(adao.findStudySubjectAuditEvents(studySubject.getId()));
// subject
// value
// changed
// Global
studySubjectAudits.addAll(adao.findSubjectAuditEvents(subject.getId()));
// subject
// value
// changed
studySubjectAuditsHashMap.put(new Integer(studySubject.getId()), studySubjectAudits);
// request.setAttribute("studySubjectAudits"+ss,
// studySubjectAudits);
// Get the list of events
ArrayList events = sedao.findAllByStudySubject(studySubject);
for (int i = 0; i < events.size(); i++) {
// Link study event definitions
StudyEventBean studyEvent = (StudyEventBean) events.get(i);
studyEvent.setStudyEventDefinition((StudyEventDefinitionBean) seddao.findByPK(studyEvent.getStudyEventDefinitionId()));
// Link event CRFs
studyEvent.setEventCRFs(ecdao.findAllByStudyEvent(studyEvent));
}
// for (int i = 0; i < events.size(); i++) {
// StudyEventBean studyEvent = (StudyEventBean) events.get(i);
// ArrayList eventCRFs = studyEvent.getEventCRFs();
// for (int j = 0; j < eventCRFs.size(); j++) {
// //Link CRF and CRF Versions
// EventCRFBean eventCRF = (EventCRFBean) eventCRFs.get(j);
// eventCRF.setCrfVersion((CRFVersionBean)
// cvdao.findByPK(eventCRF.getCRFVersionId()));
// eventCRF.setCrf((CRFBean)
// cdao.findByVersionId(eventCRF.getCRFVersionId()));
// //Get the event crf audits
// eventCRFAudits.addAll(adao.findEventCRFAuditEvents(eventCRF.getId()));
// }
// }
eventsHashMap.put(new Integer(studySubject.getId()), events);
// request.setAttribute("events"+ss, events);
// eventCRFAuditsHashMap.put(new Integer(studySubject.getId()),
// eventCRFAudits);
// request.setAttribute("eventCRFAudits"+ss, eventCRFAudits);
}
// request.setAttribute("eventCRFAudits", eventCRFAuditsHashMap);
request.setAttribute("events", eventsHashMap);
request.setAttribute("studySubjectAudits", studySubjectAuditsHashMap);
request.setAttribute("study", currentStudy);
request.setAttribute("subjects", subjectHashMap);
// FormProcessor fp = new FormProcessor(request);
//
// AuditEventDAO aeDAO = new AuditEventDAO(sm.getDataSource());
// ArrayList al = aeDAO.findAllByStudyId(currentStudy.getId());
//
// EntityBeanTable table = fp.getEntityBeanTable();
// ArrayList allRows = AuditEventStudyRow.generateRowsFromBeans(al);
// String[] columns = { "Date and Time", "Action", "Entity/Operation",
// "Record ID", "Changes and Additions","Other Info" };
// table.setColumns(new ArrayList(Arrays.asList(columns)));
// table.hideColumnLink(4);
// table.hideColumnLink(1);
// table.hideColumnLink(5);
// table.setQuery("AuditLogUser?userLogId="+userId, new HashMap());
// String[] columns =
// {resword.getString("date_and_time"),resword.getString("action_message"),
// resword.getString("entity_operation"),
// resword.getString("updated_by"),resword.getString("subject_unique_ID"),resword.getString("changes_and_additions"),
// //"Other Info",
// resword.getString("actions")};
// table.setColumns(new ArrayList(Arrays.asList(columns)));
// table.setAscendingSort(false);
// table.hideColumnLink(1);
// table.hideColumnLink(5);
// table.hideColumnLink(6);
// //table.hideColumnLink(7);
// table.setQuery("AuditLogStudy", new HashMap());
// table.setRows(allRows);
// table.computeDisplay();
//
//
// request.setAttribute("table", table);
logger.warn("*** found servlet, sending to page ***");
String pattn = "";
String pattern2 = "";
pattn = ResourceBundleProvider.getFormatBundle().getString("date_format_string");
pattern2 = ResourceBundleProvider.getFormatBundle().getString("date_time_format_string");
request.setAttribute("dateFormatPattern", pattn);
request.setAttribute("dateTimeFormatPattern", pattern2);
forwardPage(Page.AUDIT_LOG_STUDY);
}
use of org.akaza.openclinica.dao.managestudy.StudyDAO in project OpenClinica by OpenClinica.
the class CreateJobImportServlet method setUpServlet.
/*
* Find all the form items and re-populate as necessary
*/
private void setUpServlet() throws Exception {
String directory = SQLInitServlet.getField("filePath") + DIR_PATH + File.separator;
logger.debug("found directory: " + directory);
// find all the form items and re-populate them if necessary
FormProcessor fp2 = new FormProcessor(request);
UserAccountDAO udao = new UserAccountDAO(sm.getDataSource());
StudyDAO sdao = new StudyDAO(sm.getDataSource());
// ArrayList studies = udao.findStudyByUser(ub.getName(), (ArrayList)
// sdao.findAll());
// request.setAttribute("studies", studies);
// tbh, replacing the above with another version, 06/2009
ArrayList<StudyBean> all = (ArrayList<StudyBean>) sdao.findAll();
ArrayList<StudyBean> finalList = new ArrayList<StudyBean>();
for (StudyBean sb : all) {
if (!(sb.getParentStudyId() > 0)) {
finalList.add(sb);
// System.out.println("found study name: " + sb.getName());
finalList.addAll(sdao.findAllByParent(sb.getId()));
}
}
// System.out.println("found list of studies: " + finalList.toString());
addEntityList("studies", finalList, respage.getString("a_user_cannot_be_created_no_study_as_active"), Page.ADMIN_SYSTEM);
// YW >>
// << tbh
request.setAttribute("filePath", directory);
// request.setAttribute("activeStudy", activeStudy);
request.setAttribute(JOB_NAME, fp2.getString(JOB_NAME));
request.setAttribute(JOB_DESC, fp2.getString(JOB_DESC));
request.setAttribute(EMAIL, fp2.getString(EMAIL));
request.setAttribute(HOURS, new Integer(fp2.getInt(HOURS)).toString());
request.setAttribute(MINUTES, new Integer(fp2.getInt(MINUTES)).toString());
}
use of org.akaza.openclinica.dao.managestudy.StudyDAO in project OpenClinica by OpenClinica.
the class SecureController method entityIncluded.
/**
* <p>Check if an entity with passed entity id is included in studies of current user.</p>
*
* <p>Note: This method called AuditableEntityDAO.findByPKAndStudy which required
* "The subclass must define findByPKAndStudyName before calling this
* method. Otherwise an inactive AuditableEntityBean will be returned."</p>
* @author ywang 10-18-2007
* @param entityId int
* @param userName String
* @param adao AuditableEntityDAO
* @param ds javax.sql.DataSource
*/
protected boolean entityIncluded(int entityId, String userName, AuditableEntityDAO adao, DataSource ds) {
StudyDAO sdao = new StudyDAO(ds);
ArrayList<StudyBean> studies = (ArrayList<StudyBean>) sdao.findAllByUserNotRemoved(userName);
for (int i = 0; i < studies.size(); ++i) {
if (adao.findByPKAndStudy(entityId, studies.get(i)).getId() > 0) {
return true;
}
// visible to parent studies.
if (studies.get(i).getParentStudyId() <= 0) {
ArrayList<StudyBean> sites = (ArrayList<StudyBean>) sdao.findAllByParent(studies.get(i).getId());
if (sites.size() > 0) {
for (int j = 0; j < sites.size(); ++j) {
if (adao.findByPKAndStudy(entityId, sites.get(j)).getId() > 0) {
return true;
}
}
}
}
}
return false;
}
use of org.akaza.openclinica.dao.managestudy.StudyDAO 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;
}
Aggregations