use of org.akaza.openclinica.bean.service.StudyParameterValueBean in project OpenClinica by OpenClinica.
the class SubjectService method createStudySubject.
private StudySubjectBean createStudySubject(SubjectBean subject, StudyBean studyBean, Date enrollmentDate, String secondaryId) {
StudySubjectBean studySubject = new StudySubjectBean();
studySubject.setSecondaryLabel(secondaryId);
studySubject.setOwner(getUserAccount());
studySubject.setEnrollmentDate(enrollmentDate);
studySubject.setSubjectId(subject.getId());
studySubject.setStudyId(studyBean.getId());
studySubject.setStatus(Status.AVAILABLE);
int handleStudyId = studyBean.getParentStudyId() > 0 ? studyBean.getParentStudyId() : studyBean.getId();
StudyParameterValueBean subjectIdGenerationParameter = getStudyParameterValueDAO().findByHandleAndStudy(handleStudyId, "subjectIdGeneration");
String idSetting = subjectIdGenerationParameter.getValue();
if (idSetting.equals("auto editable") || idSetting.equals("auto non-editable")) {
// Warning: Here we have a race condition.
// At least, a uniqueness constraint should be set on the database! Better provide an atomic method which stores a new label in the database and returns it.
int nextLabel = getStudySubjectDao().findTheGreatestLabel() + 1;
studySubject.setLabel(Integer.toString(nextLabel));
} else {
studySubject.setLabel(subject.getLabel());
subject.setLabel(null);
}
return studySubject;
}
use of org.akaza.openclinica.bean.service.StudyParameterValueBean in project OpenClinica by OpenClinica.
the class StudyConfigService method hasDefinedParameterValue.
/**
* true if the study has a value defined for this parameter o if studyId
* is a parent study, then this is true iff there is a row for this
* study/parameter pair in the study_parameter_value table o if studyId is a
* site, then this is true if: ? * the parameter is inheritable and the
* studys parent has a defined parameter value; OR ? * the parameter is not
* inheritable and there is a row for this studyId/parameter pair in the
* study_parameter_value table
*
* @param studyId
* @param parameterHandle
* @return
*/
public String hasDefinedParameterValue(int studyId, String parameterHandle) {
StudyDAO sdao = new StudyDAO(ds);
StudyParameterValueDAO spvdao = new StudyParameterValueDAO(ds);
if (studyId <= 0 || StringUtil.isBlank(parameterHandle)) {
return null;
}
StudyParameterValueBean spv = spvdao.findByHandleAndStudy(studyId, parameterHandle);
StudyParameter sp = spvdao.findParameterByHandle(parameterHandle);
StudyBean study = (StudyBean) sdao.findByPK(studyId);
if (spv.getId() > 0) {
// top study or not
return spv.getValue();
}
int parentId = study.getParentStudyId();
if (parentId > 0) {
StudyParameterValueBean spvParent = spvdao.findByHandleAndStudy(parentId, parameterHandle);
if (spvParent.getId() > 0 && sp.isInheritable()) {
return spvParent.getValue();
}
}
return null;
}
use of org.akaza.openclinica.bean.service.StudyParameterValueBean in project OpenClinica by OpenClinica.
the class StudyModuleController method registerParticipate.
@RequestMapping(value = "/{study}/register", method = RequestMethod.POST)
public String registerParticipate(@PathVariable("study") String studyOid, HttpServletRequest request) throws Exception {
studyDao = new StudyDAO(dataSource);
StudyBean study = studyDao.findByOid(studyOid);
StudyParameterValueDAO spvdao = new StudyParameterValueDAO(dataSource);
StudyParameterValueBean spv = spvdao.findByHandleAndStudy(study.getId(), "participantPortal");
ParticipantPortalRegistrar registrar = new ParticipantPortalRegistrar();
Locale locale = LocaleResolver.getLocale(request);
ResourceBundleProvider.updateLocale(locale);
respage = ResourceBundleProvider.getPageMessagesBundle(locale);
// Check if desired hostName is available. If so, send OCUI registration request
String hostName = request.getParameter("hostName");
if (hostName == null || hostName.equals("")) {
addRegMessage(request, respage.getString("participate_hostname_invalid"));
return "redirect:/pages/studymodule";
}
String status = "";
String nameAvailability = registrar.getHostNameAvailability(hostName);
if (nameAvailability.equals(ParticipantPortalRegistrar.UNAVAILABLE)) {
addRegMessage(request, respage.getString("participate_hostname_not_available"));
return "redirect:/pages/studymodule";
} else if (nameAvailability.equals(ParticipantPortalRegistrar.UNKNOWN)) {
addRegMessage(request, respage.getString("participate_not_available"));
return "redirect:/pages/studymodule";
} else if (nameAvailability.equals(ParticipantPortalRegistrar.INVALID)) {
addRegMessage(request, respage.getString("participate_hostname_invalid"));
return "redirect:/pages/studymodule";
} else {
// Returned status was 'available'. Proceed with registration.
status = registrar.registerStudy(study.getOid(), hostName, study.getIdentifier());
}
// parameter.
if (status.equals("")) {
addRegMessage(request, respage.getString("participate_not_available"));
} else {
// Update OC Study configuration
spv.setStudyId(study.getId());
spv.setParameter("participantPortal");
spv.setValue("enabled");
if (spv.getId() > 0)
spvdao.update(spv);
else
spvdao.create(spv);
StudyBean currentStudy = (StudyBean) request.getSession().getAttribute("study");
currentStudy.getStudyParameterConfig().setParticipantPortal("enabled");
}
return "redirect:/pages/studymodule";
}
use of org.akaza.openclinica.bean.service.StudyParameterValueBean in project OpenClinica by OpenClinica.
the class StudyModuleController method deactivateRandomization.
@RequestMapping(value = "/{study}/deactivaterandomization", method = RequestMethod.GET)
public String deactivateRandomization(@PathVariable("study") String studyOid, HttpServletRequest request) throws Exception {
studyDao = new StudyDAO(dataSource);
StudyBean study = studyDao.findByOid(studyOid);
StudyParameterValueDAO spvdao = new StudyParameterValueDAO(dataSource);
StudyParameterValueBean spv = spvdao.findByHandleAndStudy(study.getId(), "randomization");
spv.setStudyId(study.getId());
spv.setParameter("randomization");
spv.setValue("disabled");
if (spv.getId() > 0)
spvdao.update(spv);
else
spvdao.create(spv);
StudyBean currentStudy = (StudyBean) request.getSession().getAttribute("study");
currentStudy.getStudyParameterConfig().setRandomization("disabled");
return "redirect:/pages/studymodule";
}
use of org.akaza.openclinica.bean.service.StudyParameterValueBean in project OpenClinica by OpenClinica.
the class StudyModuleController method reactivateRandomization.
@RequestMapping(value = "/{study}/reactivaterandomization", method = RequestMethod.GET)
public String reactivateRandomization(@PathVariable("study") String studyOid, HttpServletRequest request) throws Exception {
studyDao = new StudyDAO(dataSource);
StudyBean study = studyDao.findByOid(studyOid);
StudyParameterValueDAO spvdao = new StudyParameterValueDAO(dataSource);
StudyParameterValueBean spv = spvdao.findByHandleAndStudy(study.getId(), "randomization");
spv.setStudyId(study.getId());
spv.setParameter("randomization");
spv.setValue("enabled");
if (spv.getId() > 0)
spvdao.update(spv);
else
spvdao.create(spv);
StudyBean currentStudy = (StudyBean) request.getSession().getAttribute("study");
currentStudy.getStudyParameterConfig().setRandomization("enabled");
return "redirect:/pages/studymodule";
}
Aggregations