Search in sources :

Example 6 with ArrayListValuedHashMap

use of org.apache.commons.collections4.multimap.ArrayListValuedHashMap in project dhis2-core by dhis2.

the class QueryPlannerTest method testGetPermutationDimensionalItemValueMapCocDisabled.

@Test
void testGetPermutationDimensionalItemValueMapCocDisabled() {
    MultiValuedMap<String, DimensionItemObjectValue> aggregatedDataMap = new ArrayListValuedHashMap<>();
    aggregatedDataMap.put(deA.getUid() + DIMENSION_SEP + ouA.getUid() + DIMENSION_SEP + "200101", new DimensionItemObjectValue(deA, 1d));
    aggregatedDataMap.put(deA.getUid() + DIMENSION_SEP + ouA.getUid() + DIMENSION_SEP + "200102", new DimensionItemObjectValue(deA, 2d));
    aggregatedDataMap.put(deA.getUid() + DIMENSION_SEP + ouB.getUid() + DIMENSION_SEP + "200101", new DimensionItemObjectValue(deA, 3d));
    aggregatedDataMap.put(deA.getUid() + DIMENSION_SEP + ouB.getUid() + DIMENSION_SEP + "200102", new DimensionItemObjectValue(deA, 4d));
    aggregatedDataMap.put(deB.getUid() + DIMENSION_SEP + ouA.getUid() + DIMENSION_SEP + "200101", new DimensionItemObjectValue(deB, 5d));
    aggregatedDataMap.put(deB.getUid() + DIMENSION_SEP + ouA.getUid() + DIMENSION_SEP + "200102", new DimensionItemObjectValue(deB, 6d));
    aggregatedDataMap.put(deB.getUid() + DIMENSION_SEP + ouB.getUid() + DIMENSION_SEP + "200101", new DimensionItemObjectValue(deB, 7d));
    aggregatedDataMap.put(deB.getUid() + DIMENSION_SEP + ouB.getUid() + DIMENSION_SEP + "200102", new DimensionItemObjectValue(deB, 8d));
    Map<String, List<DimensionItemObjectValue>> permutationMap = DataQueryParams.getPermutationDimensionalItemValueMap(aggregatedDataMap);
    assertNotNull(permutationMap);
    String ouAM1Key = ouA.getUid() + DIMENSION_SEP + "200101";
    String ouAM2Key = ouA.getUid() + DIMENSION_SEP + "200102";
    String ouBM1Key = ouB.getUid() + DIMENSION_SEP + "200101";
    String ouBM2Key = ouB.getUid() + DIMENSION_SEP + "200102";
    List<DimensionItemObjectValue> ouAM1 = permutationMap.get(ouAM1Key);
    List<DimensionItemObjectValue> ouAM2 = permutationMap.get(ouAM2Key);
    List<DimensionItemObjectValue> ouBM1 = permutationMap.get(ouBM1Key);
    List<DimensionItemObjectValue> ouBM2 = permutationMap.get(ouBM2Key);
    assertEquals(2, ouAM1.size());
    assertEquals(2, ouAM2.size());
    assertEquals(2, ouBM1.size());
    assertEquals(2, ouBM2.size());
    List<DimensionItemObjectValue> ouAM1Expected = new ArrayList<>();
    ouAM1Expected.add(new DimensionItemObjectValue(deA, 1d));
    ouAM1Expected.add(new DimensionItemObjectValue(deB, 5d));
    List<DimensionItemObjectValue> ouAM2Expected = new ArrayList<>();
    ouAM2Expected.add(new DimensionItemObjectValue(deA, 2d));
    ouAM2Expected.add(new DimensionItemObjectValue(deB, 6d));
    List<DimensionItemObjectValue> ouBM1Expected = new ArrayList<>();
    ouBM1Expected.add(new DimensionItemObjectValue(deA, 3d));
    ouBM1Expected.add(new DimensionItemObjectValue(deB, 7d));
    List<DimensionItemObjectValue> ouBM2Expected = new ArrayList<>();
    ouBM2Expected.add(new DimensionItemObjectValue(deA, 4d));
    ouBM2Expected.add(new DimensionItemObjectValue(deB, 8d));
    assertCollectionsMatch(ouAM1Expected, ouAM1);
    assertCollectionsMatch(ouAM2Expected, ouAM2);
    assertCollectionsMatch(ouBM1Expected, ouBM1);
    assertCollectionsMatch(ouBM2Expected, ouBM2);
}
Also used : ArrayList(java.util.ArrayList) DimensionItemObjectValue(org.hisp.dhis.common.DimensionItemObjectValue) List(java.util.List) ArrayList(java.util.ArrayList) DimensionalObjectUtils.getList(org.hisp.dhis.common.DimensionalObjectUtils.getList) ArrayListValuedHashMap(org.apache.commons.collections4.multimap.ArrayListValuedHashMap) Test(org.junit.jupiter.api.Test) DhisSpringTest(org.hisp.dhis.DhisSpringTest)

Example 7 with ArrayListValuedHashMap

use of org.apache.commons.collections4.multimap.ArrayListValuedHashMap in project dhis2-core by dhis2.

the class QueryPlannerTest method testGetPermutationDimensionalItemValueMap.

@Test
void testGetPermutationDimensionalItemValueMap() {
    MultiValuedMap<String, DimensionItemObjectValue> aggregatedDataMap = new ArrayListValuedHashMap<>();
    aggregatedDataMap.put(deA.getUid() + DIMENSION_SEP + ouA.getUid() + DIMENSION_SEP + "2000Q1", new DimensionItemObjectValue(deA, 1d));
    aggregatedDataMap.put(deA.getUid() + DIMENSION_SEP + ouA.getUid() + DIMENSION_SEP + "2000Q2", new DimensionItemObjectValue(deA, 2d));
    aggregatedDataMap.put(deA.getUid() + DIMENSION_SEP + ouB.getUid() + DIMENSION_SEP + "2000Q1", new DimensionItemObjectValue(deA, 3d));
    aggregatedDataMap.put(deA.getUid() + DIMENSION_SEP + ouB.getUid() + DIMENSION_SEP + "2000Q2", new DimensionItemObjectValue(deA, 4d));
    aggregatedDataMap.put(makeKey(deB, coc, ouA, "2000Q1"), new DimensionItemObjectValue(deB, 5d));
    aggregatedDataMap.put(makeKey(deB, coc, ouA, "2000Q2"), new DimensionItemObjectValue(deB, 6d));
    aggregatedDataMap.put(makeKey(deB, coc, ouB, "2000Q1"), new DimensionItemObjectValue(deB, 7d));
    aggregatedDataMap.put(makeKey(deB, coc, ouB, "2000Q2"), new DimensionItemObjectValue(deB, 8d));
    Map<String, List<DimensionItemObjectValue>> permutationMap = DataQueryParams.getPermutationDimensionalItemValueMap(aggregatedDataMap);
    assertNotNull(permutationMap);
    String ouAQ1Key = ouA.getUid() + DIMENSION_SEP + "2000Q1";
    String ouAQ2Key = ouA.getUid() + DIMENSION_SEP + "2000Q2";
    String ouBQ1Key = ouB.getUid() + DIMENSION_SEP + "2000Q1";
    String ouBQ2Key = ouB.getUid() + DIMENSION_SEP + "2000Q2";
    List<DimensionItemObjectValue> ouAQ1 = permutationMap.get(ouAQ1Key);
    List<DimensionItemObjectValue> ouAQ2 = permutationMap.get(ouAQ2Key);
    List<DimensionItemObjectValue> ouBQ1 = permutationMap.get(ouBQ1Key);
    List<DimensionItemObjectValue> ouBQ2 = permutationMap.get(ouBQ2Key);
    assertEquals(2, ouAQ1.size());
    assertEquals(2, ouAQ2.size());
    assertEquals(2, ouBQ1.size());
    assertEquals(2, ouBQ2.size());
    List<DimensionItemObjectValue> ouAQ1Expected = new ArrayList<>();
    ouAQ1Expected.add(new DimensionItemObjectValue(deA, 1d));
    ouAQ1Expected.add(new DimensionItemObjectValue(deB, 5d));
    List<DimensionItemObjectValue> ouAQ2Expected = new ArrayList<>();
    ouAQ2Expected.add(new DimensionItemObjectValue(deA, 2d));
    ouAQ2Expected.add(new DimensionItemObjectValue(deB, 6d));
    List<DimensionItemObjectValue> ouBQ1Expected = new ArrayList<>();
    ouBQ1Expected.add(new DimensionItemObjectValue(deA, 3d));
    ouBQ1Expected.add(new DimensionItemObjectValue(deB, 7d));
    List<DimensionItemObjectValue> ouBQ2Expected = new ArrayList<>();
    ouBQ2Expected.add(new DimensionItemObjectValue(deA, 4d));
    ouBQ2Expected.add(new DimensionItemObjectValue(deB, 8d));
    assertCollectionsMatch(ouAQ1Expected, ouAQ1);
    assertCollectionsMatch(ouAQ2Expected, ouAQ2);
    assertCollectionsMatch(ouBQ1Expected, ouBQ1);
    assertCollectionsMatch(ouBQ2Expected, ouBQ2);
}
Also used : ArrayList(java.util.ArrayList) DimensionItemObjectValue(org.hisp.dhis.common.DimensionItemObjectValue) List(java.util.List) ArrayList(java.util.ArrayList) DimensionalObjectUtils.getList(org.hisp.dhis.common.DimensionalObjectUtils.getList) ArrayListValuedHashMap(org.apache.commons.collections4.multimap.ArrayListValuedHashMap) Test(org.junit.jupiter.api.Test) DhisSpringTest(org.hisp.dhis.DhisSpringTest)

Aggregations

ArrayListValuedHashMap (org.apache.commons.collections4.multimap.ArrayListValuedHashMap)7 DimensionItemObjectValue (org.hisp.dhis.common.DimensionItemObjectValue)4 ArrayList (java.util.ArrayList)3 List (java.util.List)3 DhisSpringTest (org.hisp.dhis.DhisSpringTest)3 DimensionalObjectUtils.getList (org.hisp.dhis.common.DimensionalObjectUtils.getList)3 Test (org.junit.jupiter.api.Test)3 QNameUtil (com.evolveum.midpoint.util.QNameUtil)1 RelationDefinitionType (com.evolveum.midpoint.xml.ns._public.common.common_3.RelationDefinitionType)1 HashMap (java.util.HashMap)1 Tuple (javax.persistence.Tuple)1 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)1 Predicate (javax.persistence.criteria.Predicate)1 QName (javax.xml.namespace.QName)1 Pair (org.apache.calcite.util.Pair)1 HashSetValuedHashMap (org.apache.commons.collections4.multimap.HashSetValuedHashMap)1 MapJoinOperator (org.apache.hadoop.hive.ql.exec.MapJoinOperator)1 Operator (org.apache.hadoop.hive.ql.exec.Operator)1 ReduceSinkOperator (org.apache.hadoop.hive.ql.exec.ReduceSinkOperator)1 TableScanOperator (org.apache.hadoop.hive.ql.exec.TableScanOperator)1