@Test public void test_02() { DocumentType<Specimen> dt = DocumentType.SPECIMEN; MappingInfo<?> mappingInfo = new MappingInfo<>(dt.getMapping()); QueryCondition condition = new QueryCondition("unitID", NOT_EQUALS, null); QueryCondition condition01 = new QueryCondition("license", EQUALS, "CC0"); QueryCondition condition02 = new QueryCondition("associatedMultiMediaUris.variant", EQUALS, "MEDIUM_QUALITY"); QueryCondition condition03 = new QueryCondition("gatheringEvent.gatheringPersons.fullName", NOT_EQUALS, null); QueryCondition condition04 = new QueryCondition("identifications.scientificName.specificEpithet", EQUALS, "Badger"); condition.and(condition01).and(condition02).and(condition03).and(condition04); LogicalOperator operator = AND; ConditionCollector collector = new ConditionCollector(condition, mappingInfo); LinkedHashMap<String, ArrayList<QueryCondition>> conditionsMap = collector.createConditionsMap(operator); assertTrue("01", conditionsMap.containsKey(null)); assertTrue("02", conditionsMap.containsKey("associatedMultiMediaUris")); assertTrue("03", conditionsMap.containsKey("gatheringEvent.gatheringPersons")); assertTrue("04", conditionsMap.containsKey("identifications")); assertTrue("05", conditionsMap.get(null).size() == 2); assertTrue("05", conditionsMap.get("associatedMultiMediaUris").size() == 1); assertTrue("05", conditionsMap.get("gatheringEvent.gatheringPersons").size() == 1); assertTrue("05", conditionsMap.get("identifications").size() == 1); }
LinkedHashMap<String, ArrayList<QueryCondition>> createConditionsMap(LogicalOperator op) { LinkedHashMap<String, ArrayList<QueryCondition>> conditionsMap = new LinkedHashMap<>(); List<QueryCondition> siblingConditions; if (op == AND) { siblingConditions = condition.getAnd(); } else { siblingConditions = condition.getOr(); } String nestedPath = null; if (condition.getField() != null) { nestedPath = getNestedPath(condition.getField(), mappingInfo); } conditionsMap.putIfAbsent(nestedPath, new ArrayList<QueryCondition>()); conditionsMap.get(nestedPath).add(condition); for (QueryCondition c : siblingConditions) { if (hasElements(c.getAnd()) || hasElements(c.getOr())) { conditionsMap.putIfAbsent(null, new ArrayList<QueryCondition>()); conditionsMap.get(null).add(c); } else { String nestedPathNext = null; if (c.getField() != null && c.getOperator() != null) { nestedPathNext = getNestedPath(c.getField(), mappingInfo); } conditionsMap.putIfAbsent(nestedPathNext, new ArrayList<QueryCondition>()); conditionsMap.get(nestedPathNext).add(c); } } return conditionsMap; }
ConditionCollector { LinkedHashMap<String, ArrayList<QueryCondition>> createConditionsMap(LogicalOperator op) { LinkedHashMap<String, ArrayList<QueryCondition>> conditionsMap = new LinkedHashMap<>(); List<QueryCondition> siblingConditions; if (op == AND) { siblingConditions = condition.getAnd(); } else { siblingConditions = condition.getOr(); } String nestedPath = null; if (condition.getField() != null) { nestedPath = getNestedPath(condition.getField(), mappingInfo); } conditionsMap.putIfAbsent(nestedPath, new ArrayList<QueryCondition>()); conditionsMap.get(nestedPath).add(condition); for (QueryCondition c : siblingConditions) { if (hasElements(c.getAnd()) || hasElements(c.getOr())) { conditionsMap.putIfAbsent(null, new ArrayList<QueryCondition>()); conditionsMap.get(null).add(c); } else { String nestedPathNext = null; if (c.getField() != null && c.getOperator() != null) { nestedPathNext = getNestedPath(c.getField(), mappingInfo); } conditionsMap.putIfAbsent(nestedPathNext, new ArrayList<QueryCondition>()); conditionsMap.get(nestedPathNext).add(c); } } return conditionsMap; } }
ConditionCollector { LinkedHashMap<String, ArrayList<QueryCondition>> createConditionsMap(LogicalOperator op) { LinkedHashMap<String, ArrayList<QueryCondition>> conditionsMap = new LinkedHashMap<>(); List<QueryCondition> siblingConditions; if (op == AND) { siblingConditions = condition.getAnd(); } else { siblingConditions = condition.getOr(); } String nestedPath = null; if (condition.getField() != null) { nestedPath = getNestedPath(condition.getField(), mappingInfo); } conditionsMap.putIfAbsent(nestedPath, new ArrayList<QueryCondition>()); conditionsMap.get(nestedPath).add(condition); for (QueryCondition c : siblingConditions) { if (hasElements(c.getAnd()) || hasElements(c.getOr())) { conditionsMap.putIfAbsent(null, new ArrayList<QueryCondition>()); conditionsMap.get(null).add(c); } else { String nestedPathNext = null; if (c.getField() != null && c.getOperator() != null) { nestedPathNext = getNestedPath(c.getField(), mappingInfo); } conditionsMap.putIfAbsent(nestedPathNext, new ArrayList<QueryCondition>()); conditionsMap.get(nestedPathNext).add(c); } } return conditionsMap; } ConditionCollector(QueryCondition condition, MappingInfo<?> mappingInfo); }
ConditionCollector { LinkedHashMap<String, ArrayList<QueryCondition>> createConditionsMap(LogicalOperator op) { LinkedHashMap<String, ArrayList<QueryCondition>> conditionsMap = new LinkedHashMap<>(); List<QueryCondition> siblingConditions; if (op == AND) { siblingConditions = condition.getAnd(); } else { siblingConditions = condition.getOr(); } String nestedPath = null; if (condition.getField() != null) { nestedPath = getNestedPath(condition.getField(), mappingInfo); } conditionsMap.putIfAbsent(nestedPath, new ArrayList<QueryCondition>()); conditionsMap.get(nestedPath).add(condition); for (QueryCondition c : siblingConditions) { if (hasElements(c.getAnd()) || hasElements(c.getOr())) { conditionsMap.putIfAbsent(null, new ArrayList<QueryCondition>()); conditionsMap.get(null).add(c); } else { String nestedPathNext = null; if (c.getField() != null && c.getOperator() != null) { nestedPathNext = getNestedPath(c.getField(), mappingInfo); } conditionsMap.putIfAbsent(nestedPathNext, new ArrayList<QueryCondition>()); conditionsMap.get(nestedPathNext).add(c); } } return conditionsMap; } ConditionCollector(QueryCondition condition, MappingInfo<?> mappingInfo);  }
ConditionCollector { LinkedHashMap<String, ArrayList<QueryCondition>> createConditionsMap(LogicalOperator op) { LinkedHashMap<String, ArrayList<QueryCondition>> conditionsMap = new LinkedHashMap<>(); List<QueryCondition> siblingConditions; if (op == AND) { siblingConditions = condition.getAnd(); } else { siblingConditions = condition.getOr(); } String nestedPath = null; if (condition.getField() != null) { nestedPath = getNestedPath(condition.getField(), mappingInfo); } conditionsMap.putIfAbsent(nestedPath, new ArrayList<QueryCondition>()); conditionsMap.get(nestedPath).add(condition); for (QueryCondition c : siblingConditions) { if (hasElements(c.getAnd()) || hasElements(c.getOr())) { conditionsMap.putIfAbsent(null, new ArrayList<QueryCondition>()); conditionsMap.get(null).add(c); } else { String nestedPathNext = null; if (c.getField() != null && c.getOperator() != null) { nestedPathNext = getNestedPath(c.getField(), mappingInfo); } conditionsMap.putIfAbsent(nestedPathNext, new ArrayList<QueryCondition>()); conditionsMap.get(nestedPathNext).add(c); } } return conditionsMap; } ConditionCollector(QueryCondition condition, MappingInfo<?> mappingInfo);   }