use of org.akaza.openclinica.bean.submit.SubjectGroupMapBean in project OpenClinica by OpenClinica.
the class StudySubjectDAO method create.
/**
* Create a study subject (that is, enroll a subject in a study).
*
* @param sb
* The study subject to create.
* @param withGroup
* <code>true</code> if the group id has been set (primarily
* for use with genetic studies); <code>false</false> otherwise.
* @return The study subject with id set to the insert id if the operation
* was successful, or 0 otherwise.
*/
public StudySubjectBean create(StudySubjectBean sb, boolean withGroup) {
HashMap variables = new HashMap();
HashMap nullVars = new HashMap();
int ind = 1;
variables.put(new Integer(ind), sb.getLabel());
ind++;
variables.put(new Integer(ind), new Integer(sb.getSubjectId()));
ind++;
variables.put(new Integer(ind), new Integer(sb.getStudyId()));
ind++;
variables.put(new Integer(ind), new Integer(sb.getStatus().getId()));
ind++;
// Date_created is now()
variables.put(new Integer(ind), new Integer(sb.getOwner().getId()));
ind++;
// if (withGroup) {
// variables.put(new Integer(ind), new Integer(sb.getStudyGroupId()));
// ind++;
// } else {
// nullVars.put(new Integer(ind), new Integer(TypeNames.INT));
// variables.put(new Integer(ind), null);
// ind++;
// }
Date enrollmentDate = sb.getEnrollmentDate();
if (enrollmentDate == null) {
nullVars.put(new Integer(ind), new Integer(Types.DATE));
variables.put(new Integer(ind), null);
ind++;
} else {
variables.put(new Integer(ind), enrollmentDate);
ind++;
}
variables.put(new Integer(ind), sb.getSecondaryLabel());
ind++;
variables.put(new Integer(ind), getValidOid(sb));
ind++;
this.executeWithPK(digester.getQuery("create"), variables, nullVars);
if (isQuerySuccessful()) {
sb.setId(getLatestPK());
}
SubjectGroupMapDAO sgmdao = new SubjectGroupMapDAO(ds);
ArrayList groupMaps = sb.getStudyGroupMaps();
for (int i = 0; i < groupMaps.size(); i++) {
SubjectGroupMapBean sgmb = (SubjectGroupMapBean) groupMaps.get(i);
sgmb = (SubjectGroupMapBean) sgmdao.create(sgmb);
if (sgmdao.isQuerySuccessful()) {
sgmb.setId(sgmdao.getCurrentPK());
}
}
return sb;
}
use of org.akaza.openclinica.bean.submit.SubjectGroupMapBean in project OpenClinica by OpenClinica.
the class SubjectGroupMapDAO method getEntityFromHashMap.
/**
* <p>
* getEntityFromHashMap, the method that gets the object from the database
* query.
*/
public Object getEntityFromHashMap(HashMap hm) {
SubjectGroupMapBean eb = new SubjectGroupMapBean();
super.setEntityAuditInformation(eb, hm);
// subject_group_map_id serial NOT NULL,
// study_group_class_id numeric,
// study_subject_id numeric,
// study_group_id numeric,
// status_id numeric,
// owner_id numeric,
// date_created date,
// date_updated date,
// update_id numeric,
// notes varchar(255),
eb.setId(((Integer) hm.get("subject_group_map_id")).intValue());
eb.setStudyGroupId(((Integer) hm.get("study_group_id")).intValue());
eb.setStudySubjectId(((Integer) hm.get("study_subject_id")).intValue());
eb.setStudyGroupClassId(((Integer) hm.get("study_group_class_id")).intValue());
eb.setNotes((String) hm.get("notes"));
return eb;
}
use of org.akaza.openclinica.bean.submit.SubjectGroupMapBean in project OpenClinica by OpenClinica.
the class SubjectGroupMapDAO method findAllByStudyGroupClassAndGroup.
public ArrayList findAllByStudyGroupClassAndGroup(int studyGroupClassId, int studyGroupId) {
setTypesExpected();
this.setTypeExpected(11, TypeNames.STRING);
HashMap variables = new HashMap();
variables.put(new Integer(1), new Integer(studyGroupClassId));
variables.put(new Integer(2), new Integer(studyGroupId));
ArrayList alist = this.select(digester.getQuery("findAllByStudyGroupClassAndGroup"), variables);
ArrayList al = new ArrayList();
Iterator it = alist.iterator();
while (it.hasNext()) {
HashMap hm = (HashMap) it.next();
SubjectGroupMapBean eb = (SubjectGroupMapBean) this.getEntityFromHashMap(hm);
eb.setSubjectLabel(((String) hm.get("label")));
al.add(eb);
}
return al;
}
use of org.akaza.openclinica.bean.submit.SubjectGroupMapBean in project OpenClinica by OpenClinica.
the class SubjectGroupMapDAO method create.
/**
* Creates a new subject
*/
public EntityBean create(EntityBean eb) {
SubjectGroupMapBean sb = (SubjectGroupMapBean) eb;
HashMap variables = new HashMap();
// INSERT INTO SUBJECT_GROUP_MAP (study_group_class_id,
// study_subject_id, study_group_id,
// status_id, owner_id,date_created,
// notes) VALUES (?,?,?,?,?,NOW(),?)
variables.put(new Integer(1), new Integer(sb.getStudyGroupClassId()));
variables.put(new Integer(2), new Integer(sb.getStudySubjectId()));
variables.put(new Integer(3), new Integer(sb.getStudyGroupId()));
variables.put(new Integer(4), new Integer(sb.getStatus().getId()));
variables.put(new Integer(5), new Integer(sb.getOwner().getId()));
variables.put(new Integer(6), sb.getNotes());
// DATE_CREATED is now()
this.execute(digester.getQuery("create"), variables);
return sb;
}
use of org.akaza.openclinica.bean.submit.SubjectGroupMapBean in project OpenClinica by OpenClinica.
the class SubjectGroupMapDAO method findAllByStudySubjectAndStudyGroupClass.
public SubjectGroupMapBean findAllByStudySubjectAndStudyGroupClass(int studySubjectId, int studyGroupClassId) {
setTypesExpected();
this.setTypeExpected(11, TypeNames.STRING);
this.setTypeExpected(12, TypeNames.STRING);
HashMap variables = new HashMap();
variables.put(new Integer(1), new Integer(studySubjectId));
variables.put(new Integer(2), new Integer(studyGroupClassId));
ArrayList alist = this.select(digester.getQuery("findByStudySubjectAndStudyGroupClass"), variables);
SubjectGroupMapBean eb = null;
Iterator it = alist.iterator();
while (it.hasNext()) {
HashMap hm = (HashMap) it.next();
eb = (SubjectGroupMapBean) this.getEntityFromHashMap(hm);
eb.setStudyGroupName(((String) hm.get("group_name")));
eb.setGroupClassName(((String) hm.get("class_name")));
}
return eb;
}
Aggregations