Search in sources :

Example 1 with ItemGroupCrvVersionUtil

use of org.akaza.openclinica.core.util.ItemGroupCrvVersionUtil in project OpenClinica by OpenClinica.

the class ItemDAO method findAllWithItemGroupCRFVersionMetadataByCRFId.

/*
 * select  distinct item.name as item_name, item_group.name as group_name,  item_group.oc_oid as group_oid ,
crf_version.name as version_name, crf_version.status_id as v_status
 from item, item_group  , item_group_metadata, crf_version
 where    item.item_id= item_group_metadata.item_id  and item_group_metadata.item_group_id =  item_group.item_group_id
 and item_group_metadata.crf_version_id = crf_version.crf_version_id
 and    item_group.crf_id =(select crf_id from CRF where name=?) order by item.name;
 
 */
public ArrayList<ItemGroupCrvVersionUtil> findAllWithItemGroupCRFVersionMetadataByCRFId(String crfName) {
    this.unsetTypeExpected();
    // (crf)name
    this.setTypeExpected(1, TypeNames.STRING);
    // (crf)name
    this.setTypeExpected(2, TypeNames.STRING);
    // (crf)name
    this.setTypeExpected(3, TypeNames.STRING);
    // (crf)name
    this.setTypeExpected(4, TypeNames.STRING);
    // (crf)name
    this.setTypeExpected(5, TypeNames.INT);
    HashMap variables = new HashMap();
    variables.put(new Integer(1), crfName);
    String sql = digester.getQuery("findAllWithItemGroupCRFVersionMetadataByCRFId");
    ArrayList rows = this.select(sql, variables);
    ItemGroupCrvVersionUtil item = null;
    ArrayList<ItemGroupCrvVersionUtil> item_group_crfversion_info = new ArrayList<ItemGroupCrvVersionUtil>();
    Iterator it = rows.iterator();
    while (it.hasNext()) {
        HashMap row = (HashMap) it.next();
        item = new ItemGroupCrvVersionUtil();
        item.setItemName((String) row.get("item_name"));
        item.setCrfVersionName((String) row.get("version_name"));
        item.setCrfVersionStatus(((Integer) row.get("v_status")).intValue());
        item.setGroupName((String) row.get("group_name"));
        item.setGroupOID((String) row.get("group_oid"));
        item_group_crfversion_info.add(item);
    }
    return item_group_crfversion_info;
}
Also used : HashMap(java.util.HashMap) ItemGroupCrvVersionUtil(org.akaza.openclinica.core.util.ItemGroupCrvVersionUtil) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator)

Example 2 with ItemGroupCrvVersionUtil

use of org.akaza.openclinica.core.util.ItemGroupCrvVersionUtil in project OpenClinica by OpenClinica.

the class SpreadSheetItemUtil method verifyUniqueItemPlacementInGroups.

public static void verifyUniqueItemPlacementInGroups(ArrayList<SpreadSheetItemUtil> row_items, ArrayList<String> ver_errors, HashMap<String, String> htmlErrors, int sheetNumber, ResourceBundle resPageMsg, String crfName, javax.sql.DataSource ds) {
    /*ver_errors.add(resPageMsg.getString("duplicate") + " " + resPageMsg.getString("item_name_column") + " " + itemName + " "
                + resPageMsg.getString("was_detected_at_row") + " " + k + ", " + resPageMsg.getString("items_worksheet_with_dot") );
            htmlErrors.put(sheetNumber + "," + k + ","+CrfTemplateColumnNameEnum.ITEM_NAME.getCellNumber(),
            		resPageMsg.getString("INVALID_FIELD"));
            		*/
    // get all items with group / version info from db
    ItemDAO idao = new ItemDAO(ds);
    int row_count = 1;
    int check_group_count = 0;
    StringBuffer item_messages = null;
    ArrayList<ItemGroupCrvVersionUtil> item_group_crf_records = idao.findAllWithItemGroupCRFVersionMetadataByCRFId(crfName);
    for (SpreadSheetItemUtil row_item : row_items) {
        item_messages = new StringBuffer();
        for (ItemGroupCrvVersionUtil check_group : item_group_crf_records) {
            check_group_count++;
            // we expect no more than one hit
            if (check_group.getItemName().equals(row_item.getItemName()) && !(row_item.getGroupLabel().equals("") && check_group.getGroupName().equals("Ungrouped"))) {
                if (!row_item.getGroupLabel().equals(check_group.getGroupName()) && check_group.getCrfVersionStatus() == 1) {
                    item_messages.append(resPageMsg.getString("verifyUniqueItemPlacementInGroups_4") + check_group.getGroupName());
                    item_messages.append(resPageMsg.getString("verifyUniqueItemPlacementInGroups_5"));
                    item_messages.append(check_group.getCrfVersionName());
                    if (check_group_count != item_group_crf_records.size()) {
                        item_messages.append("', ");
                    }
                }
            }
        }
        if (item_messages.length() > 0) {
            htmlErrors.put(sheetNumber + "," + row_count + "," + CrfTemplateColumnNameEnum.GROUP_LABEL.getCellNumber(), resPageMsg.getString("INVALID_FIELD"));
            ver_errors.add(resPageMsg.getString("verifyUniqueItemPlacementInGroups_1") + row_item.getItemName() + "' " + resPageMsg.getString("at_row") + " '" + row_count + resPageMsg.getString("verifyUniqueItemPlacementInGroups_2") + row_item.getItemName() + resPageMsg.getString("verifyUniqueItemPlacementInGroups_3") + item_messages.toString() + ").");
        }
        row_count++;
    }
}
Also used : ItemDAO(org.akaza.openclinica.dao.submit.ItemDAO) ItemGroupCrvVersionUtil(org.akaza.openclinica.core.util.ItemGroupCrvVersionUtil)

Example 3 with ItemGroupCrvVersionUtil

use of org.akaza.openclinica.core.util.ItemGroupCrvVersionUtil in project OpenClinica by OpenClinica.

the class ViewCRFServlet method processRequest.

@Override
public void processRequest() throws Exception {
    resetPanel();
    panel.setStudyInfoShown(false);
    panel.setOrderedData(true);
    panel.setSubmitDataModule(false);
    panel.setExtractData(false);
    panel.setCreateDataset(false);
    setToPanel(resword.getString("create_CRF"), respage.getString("br_create_new_CRF_entering"));
    setToPanel(resword.getString("create_CRF_version"), respage.getString("br_create_new_CRF_uploading"));
    setToPanel(resword.getString("revise_CRF_version"), respage.getString("br_if_you_owner_CRF_version"));
    setToPanel(resword.getString("CRF_spreadsheet_template"), respage.getString("br_download_blank_CRF_spreadsheet_from"));
    setToPanel(resword.getString("example_CRF_br_spreadsheets"), respage.getString("br_download_example_CRF_instructions_from"));
    FormProcessor fp = new FormProcessor(request);
    // checks which module the requests are from, manage or admin
    String module = fp.getString(MODULE);
    request.setAttribute(MODULE, module);
    int crfId = fp.getInt(CRF_ID);
    List<StudyBean> studyBeans = null;
    if (crfId == 0) {
        addPageMessage(respage.getString("please_choose_a_CRF_to_view"));
        forwardPage(Page.CRF_LIST);
    } else {
        CRFDAO cdao = new CRFDAO(sm.getDataSource());
        CRFVersionDAO vdao = new CRFVersionDAO(sm.getDataSource());
        CRFBean crf = (CRFBean) cdao.findByPK(crfId);
        request.setAttribute("crfName", crf.getName());
        ArrayList<CRFVersionBean> versions = (ArrayList<CRFVersionBean>) vdao.findAllByCRF(crfId);
        crf.setVersions(versions);
        ArrayList<ItemGroupCrvVersionUtil> items_verified = verifyUniqueItemPlacementInGroups(crf.getName());
        request.setAttribute("items", items_verified);
        if ("admin".equalsIgnoreCase(module)) {
            // BWP 3279: generate a table showing a list of studies associated with the CRF>>
            StudyDAO studyDAO = new StudyDAO(sm.getDataSource());
            studyBeans = findStudiesForCRFId(crfId, studyDAO);
            // Create the Jmesa table for the studies associated with the CRF
            String studyHtml = renderStudiesTable(studyBeans);
            request.setAttribute("studiesTableHTML", studyHtml);
        // >>
        }
        Collection<TableColumnHolder> items = populate(crf, versions);
        request.setAttribute(CRF, crf);
        forwardPage(Page.VIEW_CRF);
    }
}
Also used : CRFDAO(org.akaza.openclinica.dao.admin.CRFDAO) CRFVersionDAO(org.akaza.openclinica.dao.submit.CRFVersionDAO) FormProcessor(org.akaza.openclinica.control.form.FormProcessor) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) ArrayList(java.util.ArrayList) CRFBean(org.akaza.openclinica.bean.admin.CRFBean) ItemGroupCrvVersionUtil(org.akaza.openclinica.core.util.ItemGroupCrvVersionUtil) CRFVersionBean(org.akaza.openclinica.bean.submit.CRFVersionBean) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO)

Example 4 with ItemGroupCrvVersionUtil

use of org.akaza.openclinica.core.util.ItemGroupCrvVersionUtil in project OpenClinica by OpenClinica.

the class ViewCRFServlet method verifyUniqueItemPlacementInGroups.

private ArrayList<ItemGroupCrvVersionUtil> verifyUniqueItemPlacementInGroups(String crfName) {
    // get all items with group / version info from db
    ItemDAO idao = new ItemDAO(sm.getDataSource());
    int check_group_count = 0;
    // use for first record in the group
    StringBuffer item_messages = null;
    // use for first record in the group
    String temp_buffer = null;
    ArrayList<ItemGroupCrvVersionUtil> results = new ArrayList<ItemGroupCrvVersionUtil>();
    ItemGroupCrvVersionUtil cur_item = null;
    StringBuffer error_message = null;
    ArrayList<ItemGroupCrvVersionUtil> item_group_crf_records = idao.findAllWithItemDetailsGroupCRFVersionMetadataByCRFId(crfName);
    for (ItemGroupCrvVersionUtil check_group : item_group_crf_records) {
        if (results.size() == 0 || !check_group.getItemName().equals(cur_item.getItemName())) {
            // delete ',' from versions property
            cur_item = new ItemGroupCrvVersionUtil(check_group.getItemName(), check_group.getGroupName(), check_group.getGroupOID(), check_group.getCrfVersionName(), check_group.getCrfVersionStatus(), check_group.getItemOID(), check_group.getItemDescription(), check_group.getItemDataType(), check_group.getId());
            cur_item.setVersions(check_group.getCrfVersionName());
            temp_buffer = respage.getString("verifyUniqueItemPlacementInGroups_4") + check_group.getGroupName() + respage.getString("verifyUniqueItemPlacementInGroups_5") + check_group.getCrfVersionName() + "'";
            results.add(cur_item);
        } else {
            if (check_group.getItemName().equals(cur_item.getItemName()) && !check_group.getGroupName().equals(cur_item.getGroupName())) {
                // add message for the first item
                error_message = new StringBuffer();
                error_message.append(respage.getString("verifyUniqueItemPlacementInGroups_4") + check_group.getGroupName());
                error_message.append(respage.getString("verifyUniqueItemPlacementInGroups_5"));
                error_message.append(check_group.getCrfVersionName());
                // if ( temp_buffer != null){cur_item.setErrorMesages(cur_item.getErrorMesages() + temp_buffer);}
                if (temp_buffer != null) {
                    cur_item.getArrErrorMesages().add(temp_buffer);
                }
                temp_buffer = null;
                cur_item.getArrErrorMesages().add(error_message);
                if (check_group.getCrfVersionStatus() == 1 && cur_item.getCrfVersionStatus() != 1) {
                    cur_item.setCrfVersionStatus(1);
                }
            }
            cur_item.setVersions(cur_item.getVersions() + "," + check_group.getCrfVersionName());
        }
    }
    return results;
}
Also used : ItemDAO(org.akaza.openclinica.dao.submit.ItemDAO) ItemGroupCrvVersionUtil(org.akaza.openclinica.core.util.ItemGroupCrvVersionUtil) ArrayList(java.util.ArrayList)

Example 5 with ItemGroupCrvVersionUtil

use of org.akaza.openclinica.core.util.ItemGroupCrvVersionUtil in project OpenClinica by OpenClinica.

the class ItemDAO method findAllWithItemDetailsGroupCRFVersionMetadataByCRFId.

/*
     * select  distinct item.name as item_name, item.description as description, item.item_id as item_id, 
item.item_data_type_id as data_type, item.oc_oid as item_oid,
item_group.name as group_name,  item_group.oc_oid as group_oid ,
crf_version.name as version_name, crf_version.status_id as v_status
     */
public ArrayList<ItemGroupCrvVersionUtil> findAllWithItemDetailsGroupCRFVersionMetadataByCRFId(String crfName) {
    this.unsetTypeExpected();
    // (crf)name
    this.setTypeExpected(1, TypeNames.STRING);
    // (crf)description
    this.setTypeExpected(2, TypeNames.STRING);
    // (crf)item_id
    this.setTypeExpected(3, TypeNames.INT);
    // (crf)data_type
    this.setTypeExpected(4, TypeNames.INT);
    // (crf)item_oid
    this.setTypeExpected(5, TypeNames.STRING);
    // (crf)group_name
    this.setTypeExpected(6, TypeNames.STRING);
    // (crf)group_oid
    this.setTypeExpected(7, TypeNames.STRING);
    // (crf)version_name
    this.setTypeExpected(8, TypeNames.STRING);
    // (crf)v_status
    this.setTypeExpected(9, TypeNames.INT);
    HashMap variables = new HashMap();
    variables.put(new Integer(1), crfName);
    String sql = digester.getQuery("findAllWithItemDetailsGroupCRFVersionMetadataByCRFId");
    ArrayList rows = this.select(sql, variables);
    ItemGroupCrvVersionUtil item = null;
    ItemDataType itemDT = null;
    ArrayList<ItemGroupCrvVersionUtil> item_group_crfversion_info = new ArrayList<ItemGroupCrvVersionUtil>();
    Iterator it = rows.iterator();
    while (it.hasNext()) {
        HashMap row = (HashMap) it.next();
        item = new ItemGroupCrvVersionUtil();
        item.setItemName((String) row.get("item_name"));
        item.setCrfVersionName((String) row.get("version_name"));
        item.setCrfVersionStatus(((Integer) row.get("v_status")).intValue());
        item.setGroupName((String) row.get("group_name"));
        item.setGroupOID((String) row.get("group_oid"));
        // (crf)
        this.setTypeExpected(2, TypeNames.STRING);
        // (crf)item_id
        this.setTypeExpected(3, TypeNames.INT);
        // (crf)data_type
        this.setTypeExpected(4, TypeNames.INT);
        // (crf)item_oid
        this.setTypeExpected(5, TypeNames.STRING);
        item.setItemDescription((String) row.get("description"));
        item.setItemOID((String) row.get("item_oid"));
        itemDT = ItemDataType.get((Integer) row.get("data_type"));
        item.setItemDataType(itemDT.getDescription());
        item.setId((Integer) row.get("item_id"));
        item_group_crfversion_info.add(item);
    }
    return item_group_crfversion_info;
}
Also used : ItemDataType(org.akaza.openclinica.bean.core.ItemDataType) HashMap(java.util.HashMap) ItemGroupCrvVersionUtil(org.akaza.openclinica.core.util.ItemGroupCrvVersionUtil) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator)

Aggregations

ItemGroupCrvVersionUtil (org.akaza.openclinica.core.util.ItemGroupCrvVersionUtil)5 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)2 Iterator (java.util.Iterator)2 ItemDAO (org.akaza.openclinica.dao.submit.ItemDAO)2 CRFBean (org.akaza.openclinica.bean.admin.CRFBean)1 ItemDataType (org.akaza.openclinica.bean.core.ItemDataType)1 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)1 CRFVersionBean (org.akaza.openclinica.bean.submit.CRFVersionBean)1 FormProcessor (org.akaza.openclinica.control.form.FormProcessor)1 CRFDAO (org.akaza.openclinica.dao.admin.CRFDAO)1 StudyDAO (org.akaza.openclinica.dao.managestudy.StudyDAO)1 CRFVersionDAO (org.akaza.openclinica.dao.submit.CRFVersionDAO)1