Search in sources :

Example 11 with SubjectGroupMapBean

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;
}
Also used : SubjectGroupMapBean(org.akaza.openclinica.bean.submit.SubjectGroupMapBean) HashMap(java.util.HashMap) SubjectGroupMapDAO(org.akaza.openclinica.dao.submit.SubjectGroupMapDAO) ArrayList(java.util.ArrayList) Date(java.util.Date)

Example 12 with SubjectGroupMapBean

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;
}
Also used : SubjectGroupMapBean(org.akaza.openclinica.bean.submit.SubjectGroupMapBean)

Example 13 with SubjectGroupMapBean

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;
}
Also used : SubjectGroupMapBean(org.akaza.openclinica.bean.submit.SubjectGroupMapBean) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator)

Example 14 with SubjectGroupMapBean

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;
}
Also used : SubjectGroupMapBean(org.akaza.openclinica.bean.submit.SubjectGroupMapBean) HashMap(java.util.HashMap)

Example 15 with SubjectGroupMapBean

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;
}
Also used : SubjectGroupMapBean(org.akaza.openclinica.bean.submit.SubjectGroupMapBean) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator)

Aggregations

SubjectGroupMapBean (org.akaza.openclinica.bean.submit.SubjectGroupMapBean)22 ArrayList (java.util.ArrayList)19 HashMap (java.util.HashMap)14 SubjectGroupMapDAO (org.akaza.openclinica.dao.submit.SubjectGroupMapDAO)12 StudySubjectBean (org.akaza.openclinica.bean.managestudy.StudySubjectBean)11 StudyGroupClassBean (org.akaza.openclinica.bean.managestudy.StudyGroupClassBean)10 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)9 FormProcessor (org.akaza.openclinica.control.form.FormProcessor)9 StudyDAO (org.akaza.openclinica.dao.managestudy.StudyDAO)9 StudySubjectDAO (org.akaza.openclinica.dao.managestudy.StudySubjectDAO)9 StudyEventBean (org.akaza.openclinica.bean.managestudy.StudyEventBean)8 StudyGroupClassDAO (org.akaza.openclinica.dao.managestudy.StudyGroupClassDAO)8 StudyGroupDAO (org.akaza.openclinica.dao.managestudy.StudyGroupDAO)8 Date (java.util.Date)7 Iterator (java.util.Iterator)7 StudyEventDAO (org.akaza.openclinica.dao.managestudy.StudyEventDAO)6 StudyEventDefinitionDAO (org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO)6 StudyEventDefinitionBean (org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean)5 EventCRFBean (org.akaza.openclinica.bean.submit.EventCRFBean)5 EventDefinitionCRFDAO (org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO)5