use of org.akaza.openclinica.bean.managestudy.StudyGroupBean in project OpenClinica by OpenClinica.
the class CreateSubjectGroupClassServlet method confirmGroup.
/**
* Validates the first section of study inputs and save it into study bean
*
* @param request
* @param response
* @throws Exception
*/
private void confirmGroup() throws Exception {
Validator v = new Validator(request);
FormProcessor fp = new FormProcessor(request);
v.addValidation("name", Validator.NO_BLANKS);
v.addValidation("subjectAssignment", Validator.NO_BLANKS);
v.addValidation("name", Validator.LENGTH_NUMERIC_COMPARISON, NumericComparisonOperator.LESS_THAN_OR_EQUAL_TO, 30);
v.addValidation("subjectAssignment", Validator.LENGTH_NUMERIC_COMPARISON, NumericComparisonOperator.LESS_THAN_OR_EQUAL_TO, 30);
ArrayList studyGroups = new ArrayList();
for (int i = 0; i < 10; i++) {
String name = fp.getString("studyGroup" + i);
String description = fp.getString("studyGroupDescription" + i);
if (!StringUtil.isBlank(name)) {
StudyGroupBean group = new StudyGroupBean();
group.setName(name);
group.setDescription(description);
studyGroups.add(group);
if (name.length() > 255) {
request.setAttribute("studyGroupError", respage.getString("group_name_cannot_be_more_255"));
break;
}
if (description.length() > 1000) {
request.setAttribute("studyGroupError", respage.getString("group_description_cannot_be_more_100"));
break;
}
}
}
errors = v.validate();
if (fp.getInt("groupClassTypeId") == 0) {
Validator.addError(errors, "groupClassTypeId", resexception.getString("group_class_type_is_required"));
}
StudyGroupClassBean group = new StudyGroupClassBean();
group.setName(fp.getString("name"));
group.setGroupClassTypeId(fp.getInt("groupClassTypeId"));
group.setSubjectAssignment(fp.getString("subjectAssignment"));
session.setAttribute("group", group);
session.setAttribute("studyGroups", studyGroups);
if (errors.isEmpty()) {
logger.info("no errors in the first section");
group.setGroupClassTypeName(GroupClassType.get(group.getGroupClassTypeId()).getName());
forwardPage(Page.CREATE_SUBJECT_GROUP_CLASS_CONFIRM);
} else {
logger.info("has validation errors in the first section");
request.setAttribute("formMessages", errors);
request.setAttribute("groupTypes", GroupClassType.toArrayList());
forwardPage(Page.CREATE_SUBJECT_GROUP_CLASS);
}
}
use of org.akaza.openclinica.bean.managestudy.StudyGroupBean in project OpenClinica by OpenClinica.
the class CreateSubjectGroupClassServlet method processRequest.
@Override
public void processRequest() throws Exception {
String action = request.getParameter("action");
if (StringUtil.isBlank(action)) {
ArrayList studyGroups = new ArrayList();
for (int i = 0; i < 10; i++) {
studyGroups.add(new StudyGroupBean());
}
StudyGroupClassBean group = new StudyGroupClassBean();
request.setAttribute("groupTypes", GroupClassType.toArrayList());
session.setAttribute("group", group);
session.setAttribute("studyGroups", studyGroups);
forwardPage(Page.CREATE_SUBJECT_GROUP_CLASS);
} else {
if ("confirm".equalsIgnoreCase(action)) {
confirmGroup();
} else if ("submit".equalsIgnoreCase(action)) {
submitGroup();
}
}
}
use of org.akaza.openclinica.bean.managestudy.StudyGroupBean in project OpenClinica by OpenClinica.
the class ViewSubjectGroupClassServlet method processRequest.
@Override
public void processRequest() throws Exception {
String action = request.getParameter("action");
FormProcessor fp = new FormProcessor(request);
int classId = fp.getInt("id");
if (classId == 0) {
addPageMessage(respage.getString("please_choose_a_subject_group_class_to_view"));
forwardPage(Page.SUBJECT_GROUP_CLASS_LIST_SERVLET);
} else {
StudyGroupClassDAO sgcdao = new StudyGroupClassDAO(sm.getDataSource());
StudyGroupDAO sgdao = new StudyGroupDAO(sm.getDataSource());
SubjectGroupMapDAO sgmdao = new SubjectGroupMapDAO(sm.getDataSource());
StudyDAO studyDao = new StudyDAO(sm.getDataSource());
StudyGroupClassBean sgcb = (StudyGroupClassBean) sgcdao.findByPK(classId);
StudyBean study = (StudyBean) studyDao.findByPK(sgcb.getStudyId());
checkRoleByUserAndStudy(ub, sgcb.getStudyId(), study.getParentStudyId());
// YW 09-19-2007 <<
sgcb.setGroupClassTypeName(GroupClassType.get(sgcb.getGroupClassTypeId()).getName());
// YW >>
ArrayList groups = sgdao.findAllByGroupClass(sgcb);
ArrayList studyGroups = new ArrayList();
for (int i = 0; i < groups.size(); i++) {
StudyGroupBean sg = (StudyGroupBean) groups.get(i);
ArrayList subjectMaps = sgmdao.findAllByStudyGroupClassAndGroup(sgcb.getId(), sg.getId());
sg.setSubjectMaps(subjectMaps);
// YW<<
studyGroups.add(sg);
// YW>>
}
request.setAttribute("group", sgcb);
// request.setAttribute("studyGroups", groups);
request.setAttribute("studyGroups", studyGroups);
forwardPage(Page.VIEW_SUBJECT_GROUP_CLASS);
}
}
use of org.akaza.openclinica.bean.managestudy.StudyGroupBean in project OpenClinica by OpenClinica.
the class SubjectIdSDVFactory method getRow.
private SubjectAggregateContainer getRow(StudySubjectBean studySubjectBean) {
SubjectAggregateContainer row = new SubjectAggregateContainer();
EventCRFDAO eventCRFDAO = new EventCRFDAO(dataSource);
StudyDAO studyDAO = new StudyDAO(dataSource);
StudySubjectDAO studySubjectDAO = new StudySubjectDAO(dataSource);
StudyGroupDAO studyGroupDAO = new StudyGroupDAO(dataSource);
row.setStudySubjectId(studySubjectBean.getLabel());
row.setPersonId(studySubjectBean.getUniqueIdentifier());
row.setStudySubjectStatus(studySubjectBean.getStatus().getName());
int numberEventCRFs = eventCRFDAO.countEventCRFsByStudySubject(studySubjectBean.getId(), studySubjectBean.getStudyId(), studySubjectBean.getStudyId());
row.setTotalEventCRF(numberEventCRFs + "");
StudyBean studyBean = (StudyBean) studyDAO.findByPK(studySubjectBean.getStudyId());
row.setSiteId(studyBean.getIdentifier());
List<EventCRFBean> eventCRFBeans = eventCRFDAO.getEventCRFsByStudySubject(studySubjectBean.getId(), studySubjectBean.getStudyId(), studySubjectBean.getStudyId());
HashMap<String, Integer> stats = getEventCRFStats(eventCRFBeans, studySubjectBean);
// int numberCRFComplete = getNumberCompletedEventCRFs(eventCRFBeans);
// row.setNumberCRFComplete(numberCRFComplete + "");
row.setNumberCRFComplete(stats.get("numberOfCompletedEventCRFs") + "");
row.setNumberOfCRFsSDV(stats.get("numberOfSDVdEventCRFs") + "");
// row.setNumberOfCRFsSDV(getNumberSDVdEventCRFs(eventCRFBeans) + "");
// boolean studySubjectSDVd =
// eventCRFDAO.countEventCRFsByByStudySubjectCompleteOrLockedAndNotSDVd(studySubjectBean.getId()) == 0 &&
// numberCRFComplete > 0;
boolean studySubjectSDVd = stats.get("areEventCRFsSDVd") == -1 || stats.get("areEventCRFsSDVd") == 1 ? false : true;
StringBuilder sdvStatus = new StringBuilder("");
if (stats.get("shouldDisplaySDVButton") == 0) {
sdvStatus.append("");
} else if (studySubjectSDVd) {
sdvStatus.append("<center><a href='javascript:void(0)' onclick='prompt(document.sdvForm,");
sdvStatus.append(studySubjectBean.getId());
sdvStatus.append(")'>");
sdvStatus.append(getIconForCrfStatusPrefix()).append("DoubleCheck").append(ICON_FORCRFSTATUS_SUFFIX).append("</a></center>");
} else {
sdvStatus.append("<center><input style='margin-right: 5px' type='checkbox' ").append("class='sdvCheck'").append(" name='").append("sdvCheck_").append(studySubjectBean.getId()).append("' /></center>");
}
row.setSdvStatus(sdvStatus.toString());
List<StudyGroupBean> studyGroupBeans = studyGroupDAO.getGroupByStudySubject(studySubjectBean.getId(), studySubjectBean.getStudyId(), studySubjectBean.getStudyId());
if (studyGroupBeans != null && !studyGroupBeans.isEmpty()) {
row.setGroup(studyGroupBeans.get(0).getName());
}
StringBuilder actions = new StringBuilder("<table><tr><td>");
StringBuilder urlPrefix = new StringBuilder("<a href=\"");
StringBuilder path = new StringBuilder(contextPath).append("/pages/viewAllSubjectSDVtmp?studyId=").append(studyId).append("&sdv_f_studySubjectId=");
path.append(studySubjectBean.getLabel());
urlPrefix.append(path).append("\">");
actions.append(urlPrefix).append(SDVUtil.VIEW_ICON_HTML).append("</a></td>");
if (!studySubjectSDVd && stats.get("shouldDisplaySDVButton") == 1) {
StringBuilder jsCodeString = new StringBuilder("this.form.method='GET'; this.form.action='").append(contextPath).append("/pages/sdvStudySubject").append("';").append("this.form.theStudySubjectId.value='").append(studySubjectBean.getId()).append("';").append("this.form.submit();");
if (!studyBean.getStatus().isLocked()) {
actions.append("<td><input type=\"submit\" class=\"button\" value=\"SDV\" name=\"sdvSubmit\" ").append("onclick=\"").append(jsCodeString.toString()).append("\" /></td>");
}
} else if (!studySubjectSDVd) {
actions.append("<td> SDV N/A</td>");
}
actions.append("</tr></table>");
row.setActions(actions.toString());
return row;
}
use of org.akaza.openclinica.bean.managestudy.StudyGroupBean in project OpenClinica by OpenClinica.
the class StudyGroupDAO method create.
/**
* Creates a new StudyGroup
*/
public EntityBean create(EntityBean eb) {
StudyGroupBean sb = (StudyGroupBean) eb;
HashMap variables = new HashMap();
variables.put(new Integer(1), sb.getName());
variables.put(new Integer(2), sb.getDescription());
variables.put(new Integer(3), new Integer(sb.getStudyGroupClassId()));
this.execute(digester.getQuery("create"), variables);
return sb;
}
Aggregations