Search in sources :

Example 1 with InstantOnChangeFrontStrParcel

use of org.akaza.openclinica.service.crfdata.front.InstantOnChangeFrontStrParcel in project OpenClinica by OpenClinica.

the class DataEntryServlet method populateInstantOnChange.

protected void populateInstantOnChange(HttpSession session, EventCRFBean ecb, DisplaySectionBean section) {
    int cvId = ecb.getCRFVersionId();
    int sectionId = section.getSection().getId();
    InstantOnChangeService ins = (InstantOnChangeService) SpringServletAccess.getApplicationContext(getServletContext()).getBean("instantOnChangeService");
    InstantOnChangeFrontStrParcel strsInSec = new InstantOnChangeFrontStrParcel();
    HashMap<Integer, InstantOnChangeFrontStrGroup> nonRepOri = null;
    HashMap<String, Map<Integer, InstantOnChangeFrontStrGroup>> grpOri = null;
    HashMap<Integer, InstantOnChangeFrontStrParcel> instantOnChangeFrontStrParcels = (HashMap<Integer, InstantOnChangeFrontStrParcel>) session.getAttribute(CV_INSTANT_META + cvId);
    if (instantOnChangeFrontStrParcels != null && instantOnChangeFrontStrParcels.containsKey(sectionId)) {
        strsInSec = instantOnChangeFrontStrParcels.get(sectionId);
        nonRepOri = (HashMap<Integer, InstantOnChangeFrontStrGroup>) strsInSec.getNonRepOrigins();
        grpOri = (HashMap<String, Map<Integer, InstantOnChangeFrontStrGroup>>) strsInSec.getRepOrigins();
    } else if (instantOnChangeFrontStrParcels == null || instantOnChangeFrontStrParcels.size() == 0) {
        //if(ins.needRunInstantInSection(sectionId)) {
        boolean shouldSetAtt = false;
        instantOnChangeFrontStrParcels = (HashMap<Integer, InstantOnChangeFrontStrParcel>) ins.instantOnChangeFrontStrParcelInCrfVersion(cvId);
        if (instantOnChangeFrontStrParcels.size() > 0) {
            session.setAttribute(CV_INSTANT_META + cvId, instantOnChangeFrontStrParcels);
            if (instantOnChangeFrontStrParcels.containsKey(sectionId)) {
                strsInSec = instantOnChangeFrontStrParcels.get(sectionId);
                if (strsInSec != null) {
                    grpOri = (HashMap<String, Map<Integer, InstantOnChangeFrontStrGroup>>) strsInSec.getRepOrigins();
                    nonRepOri = (HashMap<Integer, InstantOnChangeFrontStrGroup>) strsInSec.getNonRepOrigins();
                }
            }
        }
    //}
    }
    if (grpOri != null && grpOri.size() > 0) {
        ins.itemGroupsInstantUpdate(section.getDisplayItemGroups(), grpOri);
    }
    if (nonRepOri != null && nonRepOri.size() > 0) {
        ins.itemsInstantUpdate(section.getDisplayItemGroups(), nonRepOri);
    }
}
Also used : InstantOnChangeFrontStrParcel(org.akaza.openclinica.service.crfdata.front.InstantOnChangeFrontStrParcel) InstantOnChangeFrontStrGroup(org.akaza.openclinica.service.crfdata.front.InstantOnChangeFrontStrGroup) HashMap(java.util.HashMap) Map(java.util.Map) HashMap(java.util.HashMap) InstantOnChangeService(org.akaza.openclinica.service.crfdata.InstantOnChangeService)

Example 2 with InstantOnChangeFrontStrParcel

use of org.akaza.openclinica.service.crfdata.front.InstantOnChangeFrontStrParcel 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 Map (java.util.Map)2 InstantOnChangeFrontStrGroup (org.akaza.openclinica.service.crfdata.front.InstantOnChangeFrontStrGroup)2 InstantOnChangeFrontStrParcel (org.akaza.openclinica.service.crfdata.front.InstantOnChangeFrontStrParcel)2 List (java.util.List)1 InstantOnChangePairContainer (org.akaza.openclinica.domain.crfdata.InstantOnChangePairContainer)1 InstantOnChangeService (org.akaza.openclinica.service.crfdata.InstantOnChangeService)1