Search in sources :

Example 1 with DatasetBean

use of org.akaza.openclinica.bean.extract.DatasetBean in project OpenClinica by OpenClinica.

the class DatasetDAO method findByNameAndStudy.

/**
     *
     * @param name
     * @return
     */
public EntityBean findByNameAndStudy(String name, StudyBean study) {
    DatasetBean eb = new DatasetBean();
    this.setTypesExpected();
    HashMap variables = new HashMap();
    variables.put(Integer.valueOf(1), name);
    variables.put(Integer.valueOf(2), Integer.valueOf(study.getId()));
    String sql = digester.getQuery("findByNameAndStudy");
    ArrayList alist = this.select(sql, variables);
    Iterator it = alist.iterator();
    if (it.hasNext()) {
        eb = (DatasetBean) this.getEntityFromHashMap((HashMap) it.next());
    } else {
        logger.warn("found no object: " + sql + " " + name);
    }
    return eb;
}
Also used : HashMap(java.util.HashMap) DatasetBean(org.akaza.openclinica.bean.extract.DatasetBean) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator)

Example 2 with DatasetBean

use of org.akaza.openclinica.bean.extract.DatasetBean in project OpenClinica by OpenClinica.

the class DatasetDAO method updateAll.

/**
     * Update all columns of the dataset table except owner_id
     *
     * @param eb
     * @return
     *
     * @author ywang (Feb., 2008)
     */
public EntityBean updateAll(EntityBean eb) {
    eb.setActive(false);
    DatasetBean db = (DatasetBean) eb;
    HashMap variables = new HashMap();
    HashMap nullVars = new HashMap();
    variables.put(Integer.valueOf(1), Integer.valueOf(db.getStudyId()));
    variables.put(Integer.valueOf(2), Integer.valueOf(db.getStatus().getId()));
    variables.put(Integer.valueOf(3), db.getName());
    variables.put(Integer.valueOf(4), db.getDescription());
    variables.put(Integer.valueOf(5), db.getSQLStatement());
    variables.put(Integer.valueOf(6), db.getDateLastRun());
    variables.put(Integer.valueOf(7), Integer.valueOf(db.getNumRuns()));
    variables.put(Integer.valueOf(8), Integer.valueOf(db.getUpdaterId()));
    if (db.getApproverId() <= 0) {
        // nullVars.put(Integer.valueOf(9), null);
        // ABOVE IS WRONG; follow the example below:
        nullVars.put(Integer.valueOf(9), Integer.valueOf(Types.NUMERIC));
        variables.put(Integer.valueOf(9), null);
    } else {
        variables.put(Integer.valueOf(9), Integer.valueOf(db.getApproverId()));
    }
    variables.put(Integer.valueOf(10), db.getDateStart());
    variables.put(Integer.valueOf(11), db.getDateEnd());
    variables.put(Integer.valueOf(12), new Boolean(db.isShowEventLocation()));
    variables.put(Integer.valueOf(13), new Boolean(db.isShowEventStart()));
    variables.put(Integer.valueOf(14), new Boolean(db.isShowEventEnd()));
    variables.put(Integer.valueOf(15), new Boolean(db.isShowSubjectDob()));
    variables.put(Integer.valueOf(16), new Boolean(db.isShowSubjectGender()));
    variables.put(Integer.valueOf(17), new Boolean(db.isShowEventStatus()));
    variables.put(Integer.valueOf(18), new Boolean(db.isShowSubjectStatus()));
    variables.put(Integer.valueOf(19), new Boolean(db.isShowSubjectUniqueIdentifier()));
    variables.put(Integer.valueOf(20), new Boolean(db.isShowSubjectAgeAtEvent()));
    variables.put(Integer.valueOf(21), new Boolean(db.isShowCRFstatus()));
    variables.put(Integer.valueOf(22), new Boolean(db.isShowCRFversion()));
    variables.put(Integer.valueOf(23), new Boolean(db.isShowCRFinterviewerName()));
    variables.put(Integer.valueOf(24), new Boolean(db.isShowCRFinterviewerDate()));
    variables.put(Integer.valueOf(25), new Boolean(db.isShowSubjectGroupInformation()));
    variables.put(Integer.valueOf(26), new Boolean(false));
    variables.put(Integer.valueOf(27), db.getODMMetaDataVersionName());
    variables.put(Integer.valueOf(28), db.getODMMetaDataVersionOid());
    variables.put(Integer.valueOf(29), db.getODMPriorStudyOid());
    variables.put(Integer.valueOf(30), db.getODMPriorMetaDataVersionOid());
    variables.put(Integer.valueOf(31), new Boolean(db.isShowSubjectSecondaryId()));
    variables.put(Integer.valueOf(32), Integer.valueOf(db.getDatasetItemStatus().getId()));
    variables.put(Integer.valueOf(33), Integer.valueOf(db.getId()));
    this.execute(digester.getQuery("updateAll"), variables, nullVars);
    if (isQuerySuccessful()) {
        eb.setActive(true);
    }
    return eb;
}
Also used : HashMap(java.util.HashMap) DatasetBean(org.akaza.openclinica.bean.extract.DatasetBean)

Example 3 with DatasetBean

use of org.akaza.openclinica.bean.extract.DatasetBean in project OpenClinica by OpenClinica.

the class DatasetDAO method update.

public EntityBean update(EntityBean eb) {
    DatasetBean db = (DatasetBean) eb;
    HashMap variables = new HashMap();
    HashMap nullVars = new HashMap();
    variables.put(Integer.valueOf(1), Integer.valueOf(db.getStudyId()));
    variables.put(Integer.valueOf(2), Integer.valueOf(db.getStatus().getId()));
    variables.put(Integer.valueOf(3), db.getName());
    variables.put(Integer.valueOf(4), db.getDescription());
    variables.put(Integer.valueOf(5), db.getSQLStatement());
    variables.put(Integer.valueOf(6), db.getDateLastRun());
    variables.put(Integer.valueOf(7), Integer.valueOf(db.getNumRuns()));
    variables.put(Integer.valueOf(8), Integer.valueOf(db.getUpdaterId()));
    if (db.getApproverId() <= 0) {
        // nullVars.put(Integer.valueOf(9), null);
        // ABOVE IS WRONG; follow the example below:
        nullVars.put(Integer.valueOf(9), Integer.valueOf(Types.NUMERIC));
        variables.put(Integer.valueOf(9), null);
    } else {
        variables.put(Integer.valueOf(9), Integer.valueOf(db.getApproverId()));
    }
    variables.put(Integer.valueOf(10), db.getDateStart());
    variables.put(Integer.valueOf(11), db.getDateEnd());
    variables.put(Integer.valueOf(12), Integer.valueOf(db.getId()));
    this.execute(digester.getQuery("update"), variables, nullVars);
    return eb;
}
Also used : HashMap(java.util.HashMap) DatasetBean(org.akaza.openclinica.bean.extract.DatasetBean)

Example 4 with DatasetBean

use of org.akaza.openclinica.bean.extract.DatasetBean in project OpenClinica by OpenClinica.

the class DatasetDAO method findAll.

public Collection findAll() {
    this.setTypesExpected();
    ArrayList alist = this.select(digester.getQuery("findAll"));
    ArrayList al = new ArrayList();
    Iterator it = alist.iterator();
    while (it.hasNext()) {
        DatasetBean eb = (DatasetBean) this.getEntityFromHashMap((HashMap) it.next());
        al.add(eb);
    }
    return al;
}
Also used : HashMap(java.util.HashMap) DatasetBean(org.akaza.openclinica.bean.extract.DatasetBean) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator)

Example 5 with DatasetBean

use of org.akaza.openclinica.bean.extract.DatasetBean in project OpenClinica by OpenClinica.

the class DatasetDAO method create.

public EntityBean create(EntityBean eb) {
    /*
         * INSERT INTO DATASET (STUDY_ID, STATUS_ID, NAME, DESCRIPTION,
         * SQL_STATEMENT, OWNER_ID, DATE_CREATED, DATE_LAST_RUN, NUM_RUNS,
         * DATE_START, DATE_END,
         * SHOW_EVENT_LOCATION,SHOW_EVENT_START,SHOW_EVENT_END,
         * SHOW_SUBJECT_DOB,SHOW_SUBJECT_GENDER) VALUES
         * (?,?,?,?,?,?,NOW(),NOW(),?,NOW(),'2005-11-15', ?,?,?,?,?) ADDED THE
         * COLUMNS 7-2007, TBH ALTER TABLE dataset ADD COLUMN show_event_status
         * bool DEFAULT false; ALTER TABLE dataset ADD COLUMN
         * show_subject_status bool DEFAULT false; ALTER TABLE dataset ADD
         * COLUMN show_subject_unique_id bool DEFAULT false; ALTER TABLE dataset
         * ADD COLUMN show_subject_age_at_event bool DEFAULT false; ALTER TABLE
         * dataset ADD COLUMN show_crf_status bool DEFAULT false; ALTER TABLE
         * dataset ADD COLUMN show_crf_version bool DEFAULT false; ALTER TABLE
         * dataset ADD COLUMN show_crf_int_name bool DEFAULT false; ALTER TABLE
         * dataset ADD COLUMN show_crf_int_date bool DEFAULT false; ALTER TABLE
         * dataset ADD COLUMN show_group_info bool DEFAULT false; ALTER TABLE
         * dataset ADD COLUMN show_disc_info bool DEFAULT false; added table
         * mapping dataset id to study group classes id, tbh
         *
         */
    DatasetBean db = (DatasetBean) eb;
    HashMap<Integer, Object> variables = new HashMap<Integer, Object>();
    HashMap nullVars = new HashMap();
    variables.put(Integer.valueOf(1), Integer.valueOf(db.getStudyId()));
    variables.put(Integer.valueOf(2), Integer.valueOf(db.getStatus().getId()));
    variables.put(Integer.valueOf(3), db.getName());
    variables.put(Integer.valueOf(4), db.getDescription());
    variables.put(Integer.valueOf(5), db.getSQLStatement());
    variables.put(Integer.valueOf(6), Integer.valueOf(db.getOwnerId()));
    variables.put(Integer.valueOf(7), Integer.valueOf(db.getNumRuns()));
    variables.put(Integer.valueOf(8), new Boolean(db.isShowEventLocation()));
    variables.put(Integer.valueOf(9), new Boolean(db.isShowEventStart()));
    variables.put(Integer.valueOf(10), new Boolean(db.isShowEventEnd()));
    variables.put(Integer.valueOf(11), new Boolean(db.isShowSubjectDob()));
    variables.put(Integer.valueOf(12), new Boolean(db.isShowSubjectGender()));
    variables.put(Integer.valueOf(13), new Boolean(db.isShowEventStatus()));
    variables.put(Integer.valueOf(14), new Boolean(db.isShowSubjectStatus()));
    variables.put(Integer.valueOf(15), new Boolean(db.isShowSubjectUniqueIdentifier()));
    variables.put(Integer.valueOf(16), new Boolean(db.isShowSubjectAgeAtEvent()));
    variables.put(Integer.valueOf(17), new Boolean(db.isShowCRFstatus()));
    variables.put(Integer.valueOf(18), new Boolean(db.isShowCRFversion()));
    variables.put(Integer.valueOf(19), new Boolean(db.isShowCRFinterviewerName()));
    variables.put(Integer.valueOf(20), new Boolean(db.isShowCRFinterviewerDate()));
    variables.put(Integer.valueOf(21), new Boolean(db.isShowSubjectGroupInformation()));
    // variables.put(Integer.valueOf(22), new
    // Boolean(db.isShowDiscrepancyInformation()));
    variables.put(Integer.valueOf(22), new Boolean(false));
    // currently not changing structure to allow for disc notes to be added
    // in the future
    variables.put(Integer.valueOf(23), db.getODMMetaDataVersionName());
    variables.put(Integer.valueOf(24), db.getODMMetaDataVersionOid());
    variables.put(Integer.valueOf(25), db.getODMPriorStudyOid());
    variables.put(Integer.valueOf(26), db.getODMPriorMetaDataVersionOid());
    variables.put(Integer.valueOf(27), db.isShowSubjectSecondaryId());
    variables.put(Integer.valueOf(28), db.getDatasetItemStatus().getId());
    this.executeWithPK(digester.getQuery("create"), variables, nullVars);
    if (isQuerySuccessful()) {
        eb.setId(getLatestPK());
        if (db.isShowSubjectGroupInformation()) {
            // add additional information here
            for (int i = 0; i < db.getSubjectGroupIds().size(); i++) {
                createGroupMap(eb.getId(), ((Integer) db.getSubjectGroupIds().get(i)).intValue(), nullVars);
            }
        }
    }
    return eb;
}
Also used : HashMap(java.util.HashMap) DatasetBean(org.akaza.openclinica.bean.extract.DatasetBean)

Aggregations

DatasetBean (org.akaza.openclinica.bean.extract.DatasetBean)40 ArrayList (java.util.ArrayList)24 HashMap (java.util.HashMap)21 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)19 DatasetDAO (org.akaza.openclinica.dao.extract.DatasetDAO)19 FormProcessor (org.akaza.openclinica.control.form.FormProcessor)17 StudyDAO (org.akaza.openclinica.dao.managestudy.StudyDAO)16 Iterator (java.util.Iterator)8 StudyEventDefinitionDAO (org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO)8 SimpleDateFormat (java.text.SimpleDateFormat)7 Date (java.util.Date)7 StudyEventDefinitionBean (org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean)7 LinkedHashMap (java.util.LinkedHashMap)6 UserAccountDAO (org.akaza.openclinica.dao.login.UserAccountDAO)6 StudyEventDAO (org.akaza.openclinica.dao.managestudy.StudyEventDAO)6 EventCRFDAO (org.akaza.openclinica.dao.submit.EventCRFDAO)6 UserAccountBean (org.akaza.openclinica.bean.login.UserAccountBean)5 StudyGroupClassBean (org.akaza.openclinica.bean.managestudy.StudyGroupClassBean)5 StudySubjectBean (org.akaza.openclinica.bean.managestudy.StudySubjectBean)5 EventCRFBean (org.akaza.openclinica.bean.submit.EventCRFBean)5