Search in sources :

Example 1 with FormLayoutDAO

use of org.akaza.openclinica.dao.submit.FormLayoutDAO in project OpenClinica by OpenClinica.

the class StudySubjectServiceImpl method populateUncompletedCRFsWithCRFAndVersions.

@SuppressWarnings({ "rawtypes", "unchecked" })
public void populateUncompletedCRFsWithCRFAndVersions(ArrayList<DisplayEventDefinitionCRFBean> uncompletedEventDefinitionCRFs, Map<Integer, FormLayoutBean> formLayoutById, Map<Integer, CRFBean> crfById) {
    FormLayoutDAO formLayoutDAo = new FormLayoutDAO(dataSource);
    int size = uncompletedEventDefinitionCRFs.size();
    for (int i = 0; i < size; i++) {
        DisplayEventDefinitionCRFBean dedcrf = uncompletedEventDefinitionCRFs.get(i);
        CRFBean cb = crfById.get(dedcrf.getEdc().getCrfId());
        dedcrf.getEdc().setCrf(cb);
        ArrayList<FormLayoutBean> theVersions = (ArrayList<FormLayoutBean>) formLayoutDAo.findAllActiveByCRF(dedcrf.getEdc().getCrfId());
        ArrayList<FormLayoutBean> versions = new ArrayList<FormLayoutBean>();
        HashMap<String, FormLayoutBean> formLayoutIds = new HashMap<String, FormLayoutBean>();
        for (int j = 0; j < theVersions.size(); j++) {
            FormLayoutBean formLayout = theVersions.get(j);
            formLayoutIds.put(String.valueOf(formLayout.getId()), formLayout);
        }
        if (!dedcrf.getEdc().getSelectedVersionIds().equals("")) {
            String[] kk = dedcrf.getEdc().getSelectedVersionIds().split(",");
            for (String string : kk) {
                if (formLayoutIds.get(string) != null) {
                    versions.add(formLayoutIds.get(string));
                }
            }
        } else {
            versions = theVersions;
        }
        dedcrf.getEdc().setVersions(versions);
        uncompletedEventDefinitionCRFs.set(i, dedcrf);
    }
}
Also used : HashMap(java.util.HashMap) FormLayoutDAO(org.akaza.openclinica.dao.submit.FormLayoutDAO) ArrayList(java.util.ArrayList) FormLayoutBean(org.akaza.openclinica.bean.submit.FormLayoutBean) DisplayEventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.DisplayEventDefinitionCRFBean) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) DisplayEventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.DisplayEventDefinitionCRFBean) CRFBean(org.akaza.openclinica.bean.admin.CRFBean) DisplayEventCRFBean(org.akaza.openclinica.bean.submit.DisplayEventCRFBean) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean)

Aggregations

ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 CRFBean (org.akaza.openclinica.bean.admin.CRFBean)1 DisplayEventDefinitionCRFBean (org.akaza.openclinica.bean.managestudy.DisplayEventDefinitionCRFBean)1 EventDefinitionCRFBean (org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean)1 DisplayEventCRFBean (org.akaza.openclinica.bean.submit.DisplayEventCRFBean)1 EventCRFBean (org.akaza.openclinica.bean.submit.EventCRFBean)1 FormLayoutBean (org.akaza.openclinica.bean.submit.FormLayoutBean)1 FormLayoutDAO (org.akaza.openclinica.dao.submit.FormLayoutDAO)1