@ Override protected Set < IPersonAttributes > getAttributesFromDao ( final Map < String , List < Object > > seed , final boolean isFirstQuery , final IPersonAttributeDao currentlyConsidering , final Set < IPersonAttributes > resultPeople , final IPersonAttributeDaoFilter filter ) { if ( isFirstQuery || ( ! stopIfFirstDaoReturnsNull && ( resultPeople == null || resultPeople . size ( ) == 0 ) ) ) { return currentlyConsidering . getPeopleWithMultivaluedAttributes ( seed , filter ) ; } else if ( stopIfFirstDaoReturnsNull && ! isFirstQuery && ( resultPeople == null || resultPeople . size ( ) == 0 ) ) { return null ; } Set < IPersonAttributes > mergedPeopleResults = null ; for ( final IPersonAttributes person : resultPeople ) { final Map < String , List < Object > > queryAttributes = new LinkedHashMap <> ( ) ; //Add the userName into the query map final String userName = person . getName ( ) ; if ( userName != null ) { final Map < String , List < Object > > userNameMap = this . toSeedMap ( userName ) ; queryAttributes . putAll ( userNameMap ) ; } //Add the rest of the attributes into the query map final Map < String , List < Object > > personAttributes = person . getAttributes ( ) ; queryAttributes . putAll ( personAttributes ) ; final Set < IPersonAttributes > newResults = currentlyConsidering . getPeopleWithMultivaluedAttributes ( queryAttributes , filter ) ; if ( newResults != null ) { if ( mergedPeopleResults == null ) { //If this is the first valid result set just use it. mergedPeopleResults = new LinkedHashSet <> ( newResults ) ; } else { //Merge the Sets of IPersons mergedPeopleResults = this . attrMerger . mergeResults ( mergedPeopleResults , newResults ) ; } } } return mergedPeopleResults ; }
If this is the first call or there are no results in the resultPeople Set and stopIfFirstDaoReturnsNull = false the seed map is used . If not the attributes of the first user in the resultPeople Set are used for each child dao . If stopIfFirstDaoReturnsNull = true and the first query returned no results in the resultPeopleSet return null .