Search in sources :

Example 1 with InstantOnChangePairContainer

use of org.akaza.openclinica.domain.crfdata.InstantOnChangePairContainer in project OpenClinica by OpenClinica.

the class ItemFormMetadataDAO method sectionInstantMapInSameSection.

public Map<Integer, List<InstantOnChangePairContainer>> sectionInstantMapInSameSection(int crfVersionId) {
    Map<Integer, List<InstantOnChangePairContainer>> pairs = new HashMap<Integer, List<InstantOnChangePairContainer>>();
    this.setInstantTypesExpected();
    HashMap variables = new HashMap();
    variables.put(new Integer(1), crfVersionId);
    variables.put(new Integer(2), crfVersionId);
    variables.put(new Integer(3), crfVersionId);
    variables.put(new Integer(4), crfVersionId);
    variables.put(new Integer(5), crfVersionId);
    String sql = digester.getQuery("findInstantItemsByCrfVersionId");
    ArrayList alist = this.select(sql, variables);
    Iterator it = alist.iterator();
    while (it.hasNext()) {
        InstantOnChangePairContainer instantItemPair = new InstantOnChangePairContainer();
        HashMap row = (HashMap) it.next();
        Integer sectionId = (Integer) row.get("o_sec_id");
        instantItemPair.setOriginSectionId(sectionId);
        instantItemPair.setOriginItemId((Integer) row.get("o_item_id"));
        instantItemPair.setOriginItemGroupOid((String) row.get("o_ig_oid"));
        Boolean isUng = Boolean.FALSE;
        if ("Ungrouped".equalsIgnoreCase((String) row.get("o_ig_name"))) {
            isUng = Boolean.TRUE;
        }
        instantItemPair.setOriginUngrouped(isUng);
        Boolean isRep = (Boolean) row.get("o_repeating");
        isRep = isRep == null ? Boolean.FALSE : isRep;
        instantItemPair.setOriginRepeating(isRep);
        instantItemPair.setDestSectionId((Integer) row.get("d_sec_id"));
        instantItemPair.setDestItemId((Integer) row.get("d_item_id"));
        instantItemPair.setDestItemGroupOid((String) row.get("d_ig_oid"));
        isUng = Boolean.FALSE;
        if ("Ungrouped".equalsIgnoreCase((String) row.get("d_ig_name"))) {
            isUng = Boolean.TRUE;
        }
        instantItemPair.setDestUngrouped(isUng);
        isRep = (Boolean) row.get("d_repeating");
        isRep = isRep == null ? Boolean.FALSE : isRep;
        instantItemPair.setDestRepeating(isRep);
        instantItemPair.setDestItemFormMetadataId((Integer) row.get("d_ifm_id"));
        instantItemPair.setOptionValue((String) row.get("option_name"));
        if (pairs.containsKey(sectionId)) {
            ((ArrayList<InstantOnChangePairContainer>) pairs.get(sectionId)).add(instantItemPair);
        } else {
            List<InstantOnChangePairContainer> ins = new ArrayList<InstantOnChangePairContainer>();
            ins.add(instantItemPair);
            pairs.put(sectionId, ins);
        }
    }
    return pairs;
}
Also used : InstantOnChangePairContainer(org.akaza.openclinica.domain.crfdata.InstantOnChangePairContainer) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List)

Example 2 with InstantOnChangePairContainer

use of org.akaza.openclinica.domain.crfdata.InstantOnChangePairContainer in project OpenClinica by OpenClinica.

the class InstantOnChangeService method instantOnChangeFrontStrParcelInCrfVersion.

public Map<Integer, InstantOnChangeFrontStrParcel> instantOnChangeFrontStrParcelInCrfVersion(Integer crfVersionId) {
    Map<Integer, InstantOnChangeFrontStrParcel> parcels = new HashMap<Integer, InstantOnChangeFrontStrParcel>();
    Map<Integer, List<InstantOnChangePairContainer>> insMap = getItemFormMetadataDAO().sectionInstantMapInSameSection(crfVersionId);
    if (insMap == null || insMap.size() == 0) {
        logger.debug("cannot find instant-calculation item in crf_version =" + crfVersionId);
    } else {
        for (Integer sectionId : insMap.keySet()) {
            Map<String, Map<Integer, InstantOnChangeFrontStrGroup>> repOrigins = new HashMap<String, Map<Integer, InstantOnChangeFrontStrGroup>>();
            Map<Integer, InstantOnChangeFrontStrGroup> nonRepOrigins = new HashMap<Integer, InstantOnChangeFrontStrGroup>();
            List<InstantOnChangePairContainer> instantPairs = insMap.get(sectionId);
            if (instantPairs == null || instantPairs.size() == 0) {
                logger.debug("get empty instantPair list in section_id = " + sectionId);
            } else {
                for (InstantOnChangePairContainer meta : instantPairs) {
                    if (meta.getOriginRepeating().equals(Boolean.TRUE)) {
                        addToRepOrigins(repOrigins, meta);
                    } else {
                        addToNonRepOrigins(nonRepOrigins, meta);
                    }
                }
            }
            InstantOnChangeFrontStrParcel parcel = new InstantOnChangeFrontStrParcel();
            boolean doSet = false;
            if (repOrigins.size() > 0) {
                parcel.setRepOrigins(repOrigins);
                doSet = true;
            }
            if (nonRepOrigins.size() > 0) {
                parcel.setNonRepOrigins(nonRepOrigins);
                doSet = true;
            }
            if (doSet) {
                parcel.setCrfVersionId(crfVersionId);
                parcel.setSectionId(sectionId);
                parcels.put(sectionId, parcel);
            }
        }
    }
    return parcels;
}
Also used : InstantOnChangePairContainer(org.akaza.openclinica.domain.crfdata.InstantOnChangePairContainer) InstantOnChangeFrontStrParcel(org.akaza.openclinica.service.crfdata.front.InstantOnChangeFrontStrParcel) InstantOnChangeFrontStrGroup(org.akaza.openclinica.service.crfdata.front.InstantOnChangeFrontStrGroup) HashMap(java.util.HashMap) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

HashMap (java.util.HashMap)2 List (java.util.List)2 InstantOnChangePairContainer (org.akaza.openclinica.domain.crfdata.InstantOnChangePairContainer)2 ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1 Map (java.util.Map)1 InstantOnChangeFrontStrGroup (org.akaza.openclinica.service.crfdata.front.InstantOnChangeFrontStrGroup)1 InstantOnChangeFrontStrParcel (org.akaza.openclinica.service.crfdata.front.InstantOnChangeFrontStrParcel)1