use of org.akaza.openclinica.bean.service.StudyParameter in project OpenClinica by OpenClinica.
the class StudyParameterValueDAO method findParamConfigByStudy.
public ArrayList findParamConfigByStudy(StudyBean study) {
this.unsetTypeExpected();
this.setTypeExpected(1, TypeNames.INT);
this.setTypeExpected(2, TypeNames.INT);
this.setTypeExpected(3, TypeNames.STRING);
this.setTypeExpected(4, TypeNames.STRING);
this.setTypeExpected(5, TypeNames.INT);
this.setTypeExpected(6, TypeNames.STRING);
this.setTypeExpected(7, TypeNames.STRING);
this.setTypeExpected(8, TypeNames.STRING);
this.setTypeExpected(9, TypeNames.STRING);
this.setTypeExpected(10, TypeNames.BOOL);
this.setTypeExpected(11, TypeNames.BOOL);
HashMap variables = new HashMap();
variables.put(new Integer(1), new Integer(study.getId()));
ArrayList alist = this.select(digester.getQuery("findParamConfigByStudy"), variables);
ArrayList al = new ArrayList();
Iterator it = alist.iterator();
while (it.hasNext()) {
HashMap hm = (HashMap) it.next();
StudyParameterValueBean spvb = new StudyParameterValueBean();
spvb.setValue((String) hm.get("value"));
spvb.setStudyId(((Integer) hm.get("study_id")).intValue());
spvb.setId(((Integer) hm.get("study_parameter_value_id")).intValue());
StudyParameter sp = new StudyParameter();
sp.setId(((Integer) hm.get("study_parameter_id")).intValue());
sp.setHandle((String) hm.get("handle"));
sp.setName((String) hm.get("name"));
sp.setDescription((String) hm.get("description"));
sp.setDefaultValue((String) hm.get("default_value"));
sp.setInheritable(((Boolean) hm.get("inheritable")).booleanValue());
sp.setOverridable(((Boolean) hm.get("overridable")).booleanValue());
StudyParamsConfig config = new StudyParamsConfig();
config.setParameter(sp);
config.setValue(spvb);
al.add(config);
}
return al;
}
use of org.akaza.openclinica.bean.service.StudyParameter in project OpenClinica by OpenClinica.
the class StudyParameterValueDAO method findAllParameters.
public ArrayList findAllParameters() {
this.setTypesExpectedForParameter();
ArrayList alist = this.select(digester.getQuery("findAllParameters"));
ArrayList al = new ArrayList();
Iterator it = alist.iterator();
while (it.hasNext()) {
StudyParameter eb = (StudyParameter) this.getParameterEntityFromHashMap((HashMap) it.next());
al.add(eb);
}
return al;
}
use of org.akaza.openclinica.bean.service.StudyParameter in project OpenClinica by OpenClinica.
the class StudyParameterValueDAO method findParameterByHandle.
public StudyParameter findParameterByHandle(String handle) {
StudyParameter sp = new StudyParameter();
this.setTypesExpected();
HashMap variables = new HashMap();
variables.put(new Integer(1), handle);
String sql = digester.getQuery("findParameterByHandle");
ArrayList alist = this.select(sql, variables);
Iterator it = alist.iterator();
if (it.hasNext()) {
sp = (StudyParameter) this.getEntityFromHashMap((HashMap) it.next());
}
return sp;
}
use of org.akaza.openclinica.bean.service.StudyParameter in project OpenClinica by OpenClinica.
the class StudyConfigService method setParametersForStudy.
/**
* This method construct an object which has all the study parameter values
*
* @param study
* @return
*/
public StudyBean setParametersForStudy(StudyBean study) {
StudyParameterValueDAO spvdao = new StudyParameterValueDAO(ds);
ArrayList parameters = spvdao.findAllParameters();
StudyParameterConfig spc = new StudyParameterConfig();
for (int i = 0; i < parameters.size(); i++) {
StudyParameter sp = (StudyParameter) parameters.get(i);
String handle = sp.getHandle();
// logger.info("handle:" + handle);
StudyParameterValueBean spv = spvdao.findByHandleAndStudy(study.getId(), handle);
// TO DO: will change to use java reflection later
if (spv.getId() > 0) {
if (handle.equalsIgnoreCase("collectDob")) {
spc.setCollectDob(spv.getValue());
} else if (handle.equalsIgnoreCase("genderRequired")) {
spc.setGenderRequired(spv.getValue());
} else if (handle.equalsIgnoreCase("discrepancyManagement")) {
spc.setDiscrepancyManagement(spv.getValue());
} else if (handle.equalsIgnoreCase("subjectPersonIdRequired")) {
spc.setSubjectPersonIdRequired(spv.getValue());
// logger.info("subjectPersonIdRequired" +
// spc.getSubjectPersonIdRequired());
} else if (handle.equalsIgnoreCase("interviewerNameRequired")) {
spc.setInterviewerNameRequired(spv.getValue());
} else if (handle.equalsIgnoreCase("interviewerNameDefault")) {
spc.setInterviewerNameDefault(spv.getValue());
} else if (handle.equalsIgnoreCase("interviewerNameEditable")) {
spc.setInterviewerNameEditable(spv.getValue());
} else if (handle.equalsIgnoreCase("interviewDateRequired")) {
spc.setInterviewDateRequired(spv.getValue());
} else if (handle.equalsIgnoreCase("interviewDateDefault")) {
spc.setInterviewDateDefault(spv.getValue());
} else if (handle.equalsIgnoreCase("interviewDateEditable")) {
spc.setInterviewDateEditable(spv.getValue());
} else if (handle.equalsIgnoreCase("subjectIdGeneration")) {
spc.setSubjectIdGeneration(spv.getValue());
logger.debug("subjectIdGeneration" + spc.getSubjectIdGeneration());
} else if (handle.equalsIgnoreCase("subjectIdPrefixSuffix")) {
spc.setSubjectIdPrefixSuffix(spv.getValue());
} else if (handle.equalsIgnoreCase("personIdShownOnCRF")) {
spc.setPersonIdShownOnCRF(spv.getValue());
} else if (handle.equalsIgnoreCase("secondaryLabelViewable")) {
spc.setSecondaryLabelViewable(spv.getValue());
} else if (handle.equalsIgnoreCase("adminForcedReasonForChange")) {
spc.setAdminForcedReasonForChange(spv.getValue());
} else if (handle.equalsIgnoreCase("eventLocationRequired")) {
spc.setEventLocationRequired(spv.getValue());
} else if (handle.equalsIgnoreCase("participantPortal")) {
spc.setParticipantPortal(spv.getValue());
} else if (handle.equalsIgnoreCase("randomization")) {
spc.setRandomization(spv.getValue());
}
}
}
study.setStudyParameterConfig(spc);
return study;
}
use of org.akaza.openclinica.bean.service.StudyParameter 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;
}
Aggregations