Search in sources :

Example 1 with StudyGroupItemBean

use of org.akaza.openclinica.bean.odmbeans.StudyGroupItemBean in project OpenClinica by OpenClinica.

the class MetaDataReportBean method addStudyGroupClassList.

public void addStudyGroupClassList(String currentIndent) {
    StringBuffer xml = this.getXmlOutput();
    String indent = this.getIndent();
    ArrayList<StudyGroupClassListBean> lists = (ArrayList<StudyGroupClassListBean>) odmstudy.getMetaDataVersion().getStudyGroupClassLists();
    if (lists != null) {
        if (lists.size() > 0) {
            for (StudyGroupClassListBean l : lists) {
                xml.append(currentIndent + "<OpenClinica:StudyGroupClassList ID=\"" + StringEscapeUtils.escapeXml(l.getId()) + "\" ");
                if (l.getName() != null) {
                    xml.append("Name=\"" + StringEscapeUtils.escapeXml(l.getName()) + "\" ");
                }
                if (l.getStatus() != null) {
                    xml.append("Status=\"" + l.getStatus() + "\" ");
                }
                if (l.getType() != null) {
                    xml.append("Type=\"" + StringEscapeUtils.escapeXml(l.getType()) + "\" ");
                }
                if (l.getSubjectAssignment() != null) {
                    xml.append("SubjectAssignment=\"" + StringEscapeUtils.escapeXml(l.getSubjectAssignment()) + "\" ");
                }
                xml.append(">");
                xml.append(nls);
                for (StudyGroupItemBean i : (ArrayList<StudyGroupItemBean>) l.getStudyGroupItems()) {
                    xml.append(currentIndent + indent + "<OpenClinica:StudyGroupItem ");
                    if (i.getName() != null) {
                        xml.append("Name=\"" + StringEscapeUtils.escapeXml(i.getName()) + "\" ");
                    }
                    if (i.getDescription() != null) {
                        xml.append("Description=\"" + StringEscapeUtils.escapeXml(i.getDescription()) + "\" ");
                    }
                    xml.append("/>");
                    xml.append(nls);
                }
                xml.append(currentIndent + "</OpenClinica:StudyGroupClassList>");
                xml.append(nls);
            }
        }
    }
}
Also used : StudyGroupClassListBean(org.akaza.openclinica.bean.odmbeans.StudyGroupClassListBean) ArrayList(java.util.ArrayList) StudyGroupItemBean(org.akaza.openclinica.bean.odmbeans.StudyGroupItemBean)

Example 2 with StudyGroupItemBean

use of org.akaza.openclinica.bean.odmbeans.StudyGroupItemBean in project OpenClinica by OpenClinica.

the class OdmExtractDAO method getOCMetadata.

/**
     * Metadata for ODM_1.2 OpenClinica extension and partial ODM_1.3 OpenClinica extension
     *
     * @param parentStudyId
     * @param studyId
     * @param metadata
     * @param odmVersion
     */
public void getOCMetadata(int parentStudyId, int studyId, MetaDataVersionBean metadata, String odmVersion) {
    this.getODMMetadata(parentStudyId, studyId, metadata, odmVersion);
    String cvIds = metadata.getCvIds();
    if (odmVersion.startsWith("oc")) {
        // add CRFVersions that itemDef belong to
        HashMap<String, String> itDefCVs = new HashMap<String, String>();
        this.setItemCVOIDsTypesExpected();
        ArrayList al = this.select(this.getItemCVOIDsSqlUpdated(cvIds));
        Iterator iter = al.iterator();
        while (iter.hasNext()) {
            HashMap row = (HashMap) iter.next();
            Integer cId = (Integer) row.get("crf_id");
            Integer cvId = (Integer) row.get("crf_version_id");
            Integer itId = (Integer) row.get("item_id");
            String cvOID = (String) row.get("cv_oid");
            String itOID = (String) row.get("item_oid");
            String crfOID = (String) row.get("crf_oid");
            if (itDefCVs.containsKey(itOID)) {
                String cvs = itDefCVs.get(itOID);
                if (!cvs.contains(crfOID + ",")) {
                    cvs += crfOID + ",";
                }
                itDefCVs.put(itOID, cvs);
            } else {
                itDefCVs.put(itOID, crfOID + ",");
            }
        }
        for (ItemDefBean itdef : metadata.getItemDefs()) {
            String key = itdef.getOid();
            if (itDefCVs.containsKey(key)) {
                String cvs = itDefCVs.get(key);
                itdef.setFormOIDs(cvs.substring(0, cvs.length() - 1));
            }
        }
        // add StudyGroupClassList
        this.setStudyGroupClassTypesExpected();
        logger.debug("Begin to execute GetStudyGroupClassSql");
        logger.debug("getStudyGroupClassSql=" + getStudyGroupClassSql(parentStudyId));
        ArrayList rows = select(this.getStudyGroupClassSql(parentStudyId));
        Iterator it = rows.iterator();
        ArrayList<StudyGroupClassListBean> sgcLists = (ArrayList<StudyGroupClassListBean>) metadata.getStudyGroupClassLists();
        String sgcprev = "";
        while (it.hasNext()) {
            HashMap row = (HashMap) it.next();
            Integer sgcid = (Integer) row.get("study_group_class_id");
            String sgcname = (String) row.get("sgc_name");
            String sgctype = (String) row.get("sgc_type");
            Integer statusid = (Integer) row.get("status_id");
            String subassign = (String) row.get("subject_assignment");
            String sgname = (String) row.get("sg_name");
            String des = (String) row.get("description");
            if (sgcprev.equals(sgcid + "")) {
                StudyGroupItemBean sg = new StudyGroupItemBean();
                sg.setName(sgname);
                sg.setDescription(des);
                StudyGroupClassListBean sgc = sgcLists.get(sgcLists.size() - 1);
                sgc.getStudyGroupItems().add(sg);
            } else {
                sgcprev = sgcid + "";
                StudyGroupClassListBean sgc = new StudyGroupClassListBean();
                sgc.setID("SGC_" + sgcid);
                sgc.setName(sgcname);
                sgc.setType(sgctype);
                sgc.setStatus(Status.get(statusid).getName());
                sgc.setSubjectAssignment(subassign);
                StudyGroupItemBean sg = new StudyGroupItemBean();
                sg.setName(sgname);
                sg.setDescription(des);
                sgc.getStudyGroupItems().add(sg);
                sgcLists.add(sgc);
            }
        }
    }
// return nullClSet;
}
Also used : HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) StudyGroupClassListBean(org.akaza.openclinica.bean.odmbeans.StudyGroupClassListBean) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) ItemDefBean(org.akaza.openclinica.bean.odmbeans.ItemDefBean) StudyGroupItemBean(org.akaza.openclinica.bean.odmbeans.StudyGroupItemBean)

Aggregations

ArrayList (java.util.ArrayList)2 StudyGroupClassListBean (org.akaza.openclinica.bean.odmbeans.StudyGroupClassListBean)2 StudyGroupItemBean (org.akaza.openclinica.bean.odmbeans.StudyGroupItemBean)2 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1 LinkedHashMap (java.util.LinkedHashMap)1 ItemDefBean (org.akaza.openclinica.bean.odmbeans.ItemDefBean)1