public IContextMapping < INode > filter ( IContextMapping < INode > mapping ) throws MappingFilterException { //add the first mapping element for the root to the mappings result if ( 0 < mapping . size ( ) ) { IContext sourceContext = mapping . getSourceContext ( ) ; IContext targetContext = mapping . getTargetContext ( ) ; sourceIndex = new ArrayList < Integer > ( ) ; targetIndex = new ArrayList < Integer > ( ) ; defautlMappings = mapping ; spsmMapping = mappingFactory . getContextMappingInstance ( sourceContext , targetContext ) ; spsmMapping . setSimilarity ( computeSimilarity ( mapping ) ) ; log . info ( "Similarity: " + spsmMapping . getSimilarity ( ) ) ; if ( isRelated ( sourceContext . getRoot ( ) , targetContext . getRoot ( ) , IMappingElement . EQUIVALENCE ) || isRelated ( sourceContext . getRoot ( ) , targetContext . getRoot ( ) , IMappingElement . LESS_GENERAL ) || isRelated ( sourceContext . getRoot ( ) , targetContext . getRoot ( ) , IMappingElement . MORE_GENERAL ) ) { setStrongestMapping ( sourceContext . getRoot ( ) , targetContext . getRoot ( ) ) ; filterMappingsOfChildren ( sourceContext . getRoot ( ) , targetContext . getRoot ( ) , IMappingElement . EQUIVALENCE ) ; filterMappingsOfChildren ( sourceContext . getRoot ( ) , targetContext . getRoot ( ) , IMappingElement . MORE_GENERAL ) ; filterMappingsOfChildren ( sourceContext . getRoot ( ) , targetContext . getRoot ( ) , IMappingElement . LESS_GENERAL ) ; } return spsmMapping ; } return mapping ; }
Sorts the siblings in the source and target tree defined in the constructor using the given mapping .