Search in sources :

Example 11 with DatasetBean

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

the class RemoveDatasetServlet method processRequest.

@Override
public void processRequest() throws Exception {
    FormProcessor fp = new FormProcessor(request);
    int dsId = fp.getInt("dsId");
    DatasetDAO dsDAO = new DatasetDAO(sm.getDataSource());
    DatasetBean dataset = (DatasetBean) dsDAO.findByPK(dsId);
    StudyDAO sdao = new StudyDAO(sm.getDataSource());
    StudyBean study = (StudyBean) sdao.findByPK(dataset.getStudyId());
    checkRoleByUserAndStudy(ub, study.getParentStudyId(), study.getId());
    if (study.getId() != currentStudy.getId() && study.getParentStudyId() != currentStudy.getId()) {
        addPageMessage(respage.getString("no_have_correct_privilege_current_study") + " " + respage.getString("change_active_study_or_contact"));
        forwardPage(Page.MENU_SERVLET);
        return;
    }
    if (!ub.isSysAdmin() && dataset.getOwnerId() != ub.getId()) {
        addPageMessage(respage.getString("no_have_correct_privilege_current_study") + " " + respage.getString("change_active_study_or_contact"));
        forwardPage(Page.MENU_SERVLET);
        return;
    }
    String action = request.getParameter("action");
    if (resword.getString("remove_this_dataset").equalsIgnoreCase(action)) {
        dataset.setStatus(Status.DELETED);
        dsDAO.update(dataset);
        // +
        addPageMessage(respage.getString("dataset_removed"));
        // "System Administrators can "+
        // "restore it if necessary.");
        request.setAttribute("table", getDatasetTable());
        forwardPage(Page.VIEW_DATASETS);
    } else if (resword.getString("cancel").equalsIgnoreCase(action)) {
        request.setAttribute("table", getDatasetTable());
        forwardPage(Page.VIEW_DATASETS);
    } else {
        request.setAttribute("dataset", dataset);
        forwardPage(Page.REMOVE_DATASET);
    }
}
Also used : FormProcessor(org.akaza.openclinica.control.form.FormProcessor) DatasetBean(org.akaza.openclinica.bean.extract.DatasetBean) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) DatasetDAO(org.akaza.openclinica.dao.extract.DatasetDAO) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO)

Example 12 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 13 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 14 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 15 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)

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