use of org.akaza.openclinica.dao.service.StudyConfigService in project OpenClinica by OpenClinica.
the class MetadataUnit method collectMetaDataVersion.
private void collectMetaDataVersion() {
ArrayList<StudyEventDefinitionBean> sedBeansInStudy = (ArrayList<StudyEventDefinitionBean>) studyBase.getSedBeansInStudy();
if (sedBeansInStudy == null || sedBeansInStudy.size() < 1) {
logger.info("null, because there is no study event definition in this study.");
return;
}
StudyBean study = studyBase.getStudy();
StudyConfigService studyConfig = new StudyConfigService(this.ds);
study = studyConfig.setParametersForStudy(study);
MetaDataVersionBean metadata = this.odmStudy.getMetaDataVersion();
metadata.setStudy(study);
StudyParameterValueDAO spvdao = new StudyParameterValueDAO(this.ds);
int parentId = study.getParentStudyId() > 0 ? study.getParentStudyId() : study.getId();
StudyParameterValueBean spv = spvdao.findByHandleAndStudy(parentId, "discrepancyManagement");
metadata.setSoftHard(spv.getValue().equalsIgnoreCase("true") ? "Hard" : "Soft");
OdmExtractDAO oedao = new OdmExtractDAO(this.ds);
int studyId = study.getId();
int parentStudyId = study.getParentStudyId() > 0 ? study.getParentStudyId() : studyId;
if (this.getCategory() == 1 && study.isSite(study.getParentStudyId())) {
// populate MetaDataVersion attributes
if (dataset != null) {
metadata.setOid(dataset.getODMMetaDataVersionOid() + "-" + study.getOid());
metadata.setName(dataset.getODMMetaDataVersionName() + "-" + study.getOid());
this.setParentMetaDataVersionOid(dataset.getODMMetaDataVersionOid());
}
if (metadata.getOid() == null || metadata.getOid().length() <= 0) {
metadata.setOid("v1.0.0" + "-" + study.getOid());
this.setParentMetaDataVersionOid("v1.0.0");
}
if (metadata.getName() == null || metadata.getName().length() <= 0) {
metadata.setName("MetaDataVersion_v1.0.0" + "-" + study.getOid());
}
// populate Include
this.collectIncludeFromParentInSameFile();
// populate protocol
oedao.getUpdatedSiteMetadata(parentStudyId, studyId, metadata, this.odmBean.getODMVersion());
} else {
if (dataset != null) {
metadata.setOid(dataset.getODMMetaDataVersionOid());
metadata.setName(dataset.getODMMetaDataVersionName());
}
if (metadata.getOid() == null || metadata.getOid().length() <= 0) {
metadata.setOid("v1.0.0");
}
if (metadata.getName() == null || metadata.getName().length() <= 0) {
metadata.setName("MetaDataVersion_v1.0.0");
}
// populate Include
String psOid = new String();
String pmOid = new String();
if (dataset != null) {
psOid = dataset.getODMPriorStudyOid();
pmOid = dataset.getODMPriorMetaDataVersionOid();
}
if (pmOid != null && pmOid.length() > 0) {
MetaDataVersionIncludeBean ib = metadata.getInclude();
ib.setMetaDataVersionOID(pmOid);
if (psOid != null && psOid.length() > 0) {
ib.setStudyOID(psOid);
} else {
ib.setStudyOID(study.getOid());
}
}
// populate protocol
// Set<Integer> nullCodeSet = oedao.getMetadata(parentStudyId,
// studyId,
// metadata, this.getODMBean().getODMVersion());
// studyBase.setNullClSet(nullCodeSet);
oedao.getMetadata(parentStudyId, studyId, metadata, this.odmBean.getODMVersion());
metadata.setRuleSetRules(getRuleSetRuleDao().findByRuleSetStudyIdAndStatusAvail(parentStudyId));
}
}
use of org.akaza.openclinica.dao.service.StudyConfigService in project OpenClinica by OpenClinica.
the class InitUpdateStudyServlet method processRequest.
/**
* Processes the request
*/
@Override
public void processRequest() throws Exception {
StudyDAO sdao = new StudyDAO(sm.getDataSource());
String idString = request.getParameter("id");
logger.info("study id:" + idString);
if (StringUtil.isBlank(idString)) {
addPageMessage(respage.getString("please_choose_a_study_to_edit"));
forwardPage(Page.STUDY_LIST_SERVLET);
} else {
int studyId = Integer.valueOf(idString.trim()).intValue();
StudyBean study = (StudyBean) sdao.findByPK(studyId);
StudyConfigService scs = new StudyConfigService(sm.getDataSource());
study = scs.setParametersForStudy(study);
logger.info("date created:" + study.getCreatedDate());
logger.info("protocol Type:" + study.getProtocolType());
session.setAttribute("newStudy", study);
request.setAttribute("facRecruitStatusMap", CreateStudyServlet.facRecruitStatusMap);
request.setAttribute("statuses", Status.toActiveArrayList());
resetPanel();
panel.setStudyInfoShown(false);
panel.setOrderedData(true);
panel.setExtractData(false);
panel.setSubmitDataModule(false);
panel.setCreateDataset(false);
panel.setIconInfoShown(true);
panel.setManageSubject(false);
forwardPage(Page.UPDATE_STUDY1);
}
}
use of org.akaza.openclinica.dao.service.StudyConfigService in project OpenClinica by OpenClinica.
the class MetadataCollectorResource method populateStudyBean.
private StudyBean populateStudyBean(StudyBean studyBean) {
StudyParameterValueDAO spvdao = new StudyParameterValueDAO(this.dataSource);
@SuppressWarnings("rawtypes") ArrayList studyParameters = spvdao.findParamConfigByStudy(studyBean);
studyBean.setStudyParameters(studyParameters);
StudyConfigService scs = new StudyConfigService(this.dataSource);
if (studyBean.getParentStudyId() <= 0) {
// top study
studyBean = scs.setParametersForStudy(studyBean);
} else {
// YW <<
studyBean.setParentStudyName(((StudyBean) getStudyDao().findByPK(studyBean.getParentStudyId())).getName());
// YW >>
studyBean = scs.setParametersForSite(studyBean);
}
return studyBean;
}
use of org.akaza.openclinica.dao.service.StudyConfigService in project OpenClinica by OpenClinica.
the class SecureController method process.
private void process(HttpServletRequest request, HttpServletResponse response) throws OpenClinicaException, UnsupportedEncodingException {
request.setCharacterEncoding("UTF-8");
session = request.getSession();
// BWP >> 1/8/2008
try {
// YW 10-03-2007 <<
session.setMaxInactiveInterval(Integer.parseInt(SQLInitServlet.getField("max_inactive_interval")));
// YW >>
} catch (NumberFormatException nfe) {
// BWP>>3600 is the datainfo.properties maxInactiveInterval on
// 1/8/2008
session.setMaxInactiveInterval(3600);
}
// If the session already has a value with key SUPPORT_URL don't reset
if (session.getAttribute(SUPPORT_URL) == null) {
session.setAttribute(SUPPORT_URL, SQLInitServlet.getSupportURL());
}
ub = (UserAccountBean) session.getAttribute(USER_BEAN_NAME);
currentStudy = (StudyBean) session.getAttribute("study");
currentRole = (StudyUserRoleBean) session.getAttribute("userRole");
// Set current language preferences
Locale locale = LocaleResolver.getLocale(request);
ResourceBundleProvider.updateLocale(locale);
resadmin = ResourceBundleProvider.getAdminBundle(locale);
resaudit = ResourceBundleProvider.getAuditEventsBundle(locale);
resexception = ResourceBundleProvider.getExceptionsBundle(locale);
resformat = ResourceBundleProvider.getFormatBundle(locale);
restext = ResourceBundleProvider.getTextsBundle(locale);
resterm = ResourceBundleProvider.getTermsBundle(locale);
resword = ResourceBundleProvider.getWordsBundle(locale);
respage = ResourceBundleProvider.getPageMessagesBundle(locale);
resworkflow = ResourceBundleProvider.getWorkflowBundle(locale);
local_df = I18nFormatUtil.getDateFormat(locale);
try {
String userName = request.getRemoteUser();
// BWP 1/8/08<< the sm variable may already be set with a mock
// object,
// from the perspective of
// JUnit servlets tests
/*
* if(sm==null && (!StringUtil.isBlank(userName))) {//check if user logged in, then create a new sessionmanger to
* get ub //create a new sm in order to get a new ub object sm = new SessionManager(ub, userName); }
*/
// BWP 01/08 >>
// sm = new SessionManager(ub, userName);
sm = new SessionManager(ub, userName, SpringServletAccess.getApplicationContext(context));
ub = sm.getUserBean();
session.setAttribute("userBean", ub);
StudyDAO sdao = new StudyDAO(sm.getDataSource());
if (currentStudy == null || currentStudy.getId() <= 0) {
if (ub.getId() > 0 && ub.getActiveStudyId() > 0) {
StudyParameterValueDAO spvdao = new StudyParameterValueDAO(sm.getDataSource());
currentStudy = (StudyBean) sdao.findByPK(ub.getActiveStudyId());
ArrayList studyParameters = spvdao.findParamConfigByStudy(currentStudy);
currentStudy.setStudyParameters(studyParameters);
StudyConfigService scs = new StudyConfigService(sm.getDataSource());
if (currentStudy.getParentStudyId() <= 0) {
// top study
scs.setParametersForStudy(currentStudy);
} else {
// YW <<
currentStudy.setParentStudyName(((StudyBean) sdao.findByPK(currentStudy.getParentStudyId())).getName());
// YW >>
scs.setParametersForSite(currentStudy);
}
// set up the panel here, tbh
panel.reset();
/*
* panel.setData("Study", currentStudy.getName()); panel.setData("Summary", currentStudy.getSummary());
* panel.setData("Start Date", sdf.format(currentStudy.getDatePlannedStart())); panel.setData("End Date",
* sdf.format(currentStudy.getDatePlannedEnd())); panel.setData("Principal Investigator",
* currentStudy.getPrincipalInvestigator());
*/
session.setAttribute(STUDY_INFO_PANEL, panel);
} else {
currentStudy = new StudyBean();
}
session.setAttribute("study", currentStudy);
} else if (currentStudy.getId() > 0) {
// restored
if (currentStudy.getParentStudyId() > 0) {
currentStudy.setParentStudyName(((StudyBean) sdao.findByPK(currentStudy.getParentStudyId())).getName());
}
// YW >>
}
if (currentStudy.getParentStudyId() > 0) {
/*
* The Role decription will be set depending on whether the user logged in at study lever or site level.
* issue-2422
*/
List roles = Role.toArrayList();
for (Iterator it = roles.iterator(); it.hasNext(); ) {
Role role = (Role) it.next();
switch(role.getId()) {
case 2:
role.setDescription("site_Study_Coordinator");
break;
case 3:
role.setDescription("site_Study_Director");
break;
case 4:
role.setDescription("site_investigator");
break;
case 5:
role.setDescription("site_Data_Entry_Person");
break;
case 6:
role.setDescription("site_monitor");
break;
case 7:
role.setDescription("site_Data_Entry_Person2");
break;
default:
}
}
} else {
/*
* If the current study is a site, we will change the role description. issue-2422
*/
List roles = Role.toArrayList();
for (Iterator it = roles.iterator(); it.hasNext(); ) {
Role role = (Role) it.next();
switch(role.getId()) {
case 2:
role.setDescription("Study_Coordinator");
break;
case 3:
role.setDescription("Study_Director");
break;
case 4:
role.setDescription("Investigator");
break;
case 5:
role.setDescription("Data_Entry_Person");
break;
case 6:
role.setDescription("Monitor");
break;
default:
}
}
}
if (currentRole == null || currentRole.getId() <= 0) {
// kept as "invalid" -- YW 06-21-2007
if (ub.getId() > 0 && currentStudy.getId() > 0 && !currentStudy.getStatus().getName().equals("removed")) {
currentRole = ub.getRoleByStudy(currentStudy.getId());
// logger.info("currentRole:" + currentRole.getRoleName());
} else {
currentRole = new StudyUserRoleBean();
}
session.setAttribute("userRole", currentRole);
} else // active study has been removed.
if (currentRole.getId() > 0 && (currentStudy.getStatus().equals(Status.DELETED) || currentStudy.getStatus().equals(Status.AUTO_DELETED))) {
currentRole.setRole(Role.INVALID);
currentRole.setStatus(Status.DELETED);
session.setAttribute("userRole", currentRole);
}
// YW 06-19-2007 >>
request.setAttribute("isAdminServlet", getAdminServlet());
this.request = request;
this.response = response;
// logger.info(rq_names);
if (!request.getRequestURI().endsWith("ResetPassword")) {
passwdTimeOut();
}
mayProceed();
pingJobServer(request);
processRequest();
} catch (InconsistentStateException ise) {
ise.printStackTrace();
logger.warn("InconsistentStateException: org.akaza.openclinica.control.SecureController: " + ise.getMessage());
addPageMessage(ise.getOpenClinicaMessage());
forwardPage(ise.getGoTo());
} catch (InsufficientPermissionException ipe) {
ipe.printStackTrace();
logger.warn("InsufficientPermissionException: org.akaza.openclinica.control.SecureController: " + ipe.getMessage());
// addPageMessage(ipe.getOpenClinicaMessage());
forwardPage(ipe.getGoTo());
} catch (OutOfMemoryError ome) {
ome.printStackTrace();
long heapSize = Runtime.getRuntime().totalMemory();
session.setAttribute("ome", "yes");
} catch (Exception e) {
e.printStackTrace();
logger.error(SecureController.getStackTrace(e));
forwardPage(Page.ERROR);
}
}
use of org.akaza.openclinica.dao.service.StudyConfigService 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