private void filterMappingsOfSiblingsByRelation ( List < INode > source , List < INode > target , char semanticRelation ) { int sourceDepth = ( source . get ( 0 ) . getLevel ( ) - 1 ) ; int targetDepth = ( target . get ( 0 ) . getLevel ( ) - 1 ) ; int sourceSize = source . size ( ) ; int targetSize = target . size ( ) ; while ( sourceIndex . get ( sourceDepth ) < sourceSize && targetIndex . get ( targetDepth ) < targetSize ) { if ( isRelated ( source . get ( sourceIndex . get ( sourceDepth ) ) , target . get ( targetIndex . get ( targetDepth ) ) , semanticRelation ) ) { //sort the children of the matched node setStrongestMapping ( source . get ( sourceIndex . get ( sourceDepth ) ) , target . get ( targetIndex . get ( targetDepth ) ) ) ; filterMappingsOfChildren ( source . get ( sourceIndex . get ( sourceDepth ) ) , target . get ( targetIndex . get ( targetDepth ) ) , semanticRelation ) ; //increment the index inc ( sourceIndex , sourceDepth ) ; inc ( targetIndex , targetDepth ) ; } else { //look for the next related node in the target int relatedIndex = getRelatedIndex ( source , target , semanticRelation ) ; if ( relatedIndex > sourceIndex . get ( sourceDepth ) ) { //there is a related node, but further between the siblings //they should be swapped swapINodes ( target , targetIndex . get ( targetDepth ) , relatedIndex ) ; //filter the mappings of the children of the matched node filterMappingsOfChildren ( source . get ( sourceIndex . get ( sourceDepth ) ) , target . get ( targetIndex . get ( targetDepth ) ) , semanticRelation ) ; //increment the index inc ( sourceIndex , sourceDepth ) ; inc ( targetIndex , targetDepth ) ; } else { //there is not related item among the remaining siblings //swap this element of source with the last, and decrement the sourceSize swapINodes ( source , sourceIndex . get ( sourceDepth ) , ( sourceSize - 1 ) ) ; sourceSize -- ; } } } }
Filters the mappings of two siblings node list for which the parents are also supposed to be related . Checks whether in the two given node list there is a pair of nodes related by the given relation and if so if deletes all the other relations for the given 2 nodes setting the current one as strongest .