package org.cbioportal.web.util;

import org.apache.commons.collections.map.MultiKeyMap;
import org.cbioportal.model.ClinicalData;
import org.cbioportal.service.ClinicalDataService;
import org.cbioportal.service.PatientService;
import org.cbioportal.web.parameter.ClinicalDataFilter;
import org.cbioportal.web.parameter.ClinicalDataFilterValue;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;

@Component
public class ClinicalDataEqualityFilterApplier extends ClinicalDataFilterApplier {
    @Autowired
    public ClinicalDataEqualityFilterApplier(PatientService patientService,
                                             ClinicalDataService clinicalDataService,
                                             StudyViewFilterUtil studyViewFilterUtil) {
        super(patientService, clinicalDataService, studyViewFilterUtil);
    }

    @Override
    public Integer apply(List<ClinicalDataFilter> attributes,
                         MultiKeyMap clinicalDataMap,
                         String entityId,
                         String studyId,
                         Boolean negateFilters) {
        Integer count = 0;

        for (ClinicalDataFilter s : attributes) {
            List<ClinicalData> entityClinicalData = (List<ClinicalData>)clinicalDataMap.get(entityId, studyId);
            List<String> clinicalAttrs = s.getValues();
            s.getValues().replaceAll(String::toUpperCase);
            List<String> filteredValues = clinicalAttrs.stream().map(ClinicalDataFilterValue::getValue)
                    .collect(Collectors.toList());
            if (entityClinicalData != null) {
                Optional<ClinicalData> clinicalData = entityClinicalData.stream().filter(c -> c.getAttrId()
                    .equals(s.getAttributeId().toUpperCase())).findFirst();
                if (clinicalData.isPresent() && (negateFilters ^ filteredValues.contains(clinicalData.get().getAttrValue()))) {
                    count++;
                } else if (!clinicalData.isPresent() && (negateFilters ^ filteredValues.contains("NA"))) {
                    count++;
                }
            } else if (negateFilters ^ filteredValues.contains("NA")) {
                count++;
            }
        }

        return count;
    }
}

@@ -1459,153 +1459,38 @@
 ng%3E 
-clinicalAttrs = s.getValues();%0A            s.getValues().replaceAll(String::toUpperCase);%0A            List%3CString%3E filteredValues = clinicalAttrs
+filteredValues = s.getValues()
 .str
@@ -1585,16 +1585,76 @@
 ist());%0A
+            filteredValues.replaceAll(String::toUpperCase);%0A
         

Fix compile error due to incorrectly sovled merge