hylar/core/Logics/Solver.js
function(fact, ruleFact, mapping, constants, rule) {
        var localMapping = {};
    
        // Checks and update localMapping if matches     
        if (!this.factElemMatches(fact.predicate, ruleFact.predicate, mapping, localMapping)) {
            return false;
        }        
        if (!this.factElemMatches(fact.object, ruleFact.object, mapping, localMapping)) {
            return false;
        }
        if (!this.factElemMatches(fact.subject, ruleFact.subject, mapping, localMapping)) {
            return false;
        }
        
        emitter.emit('rule-fired', rule.name);        

        // If an already existing uri has been mapped...
        for (var key in localMapping) {
            if(constants.indexOf(localMapping[key]) !== -1) {
                return false;
            }
        }

        // Merges local and global mapping
        for (var mapKey in mapping) {
            if (mapKey == '__facts__') {
                localMapping[mapKey] = Utils.uniques(mapping[mapKey], [fact]);
            } else {
                for (key in localMapping) {
                    if (mapping[mapKey] == localMapping[key]) {
                        if (mapKey != key) {
                            return false;
                        }
                    }
                }
                localMapping[mapKey] = mapping[mapKey];
            }
        }

        // The new mapping is updated
        return localMapping;    
    }
function(fact, ruleFact, mapping, constants, rule) {
        var localMapping = {};
    
        // Checks and update localMapping if matches     
        if (!this.factElemMatches(fact.predicate, ruleFact.predicate, mapping, localMapping)) {
            return false;
        }        
        if (!this.factElemMatches(fact.object, ruleFact.object, mapping, localMapping)) {
            return false;
        }
        if (!this.factElemMatches(fact.subject, ruleFact.subject, mapping, localMapping)) {
            return false;
        }
        
        emitter.emit('rule-fired', rule.name);        

        // If an already existing uri has been mapped...
        for (var key in localMapping) {
            if(constants.indexOf(localMapping[key]) !== -1) {
                return false;
            }
        }

        // Merges local and global mapping
        for (var mapKey in mapping) {
            if (mapKey == '__facts__') {
                localMapping[mapKey] = Utils.uniques(mapping[mapKey], [fact]);
            } else {
                for (key in localMapping) {
                    if (mapping[mapKey] == localMapping[key]) {
                        if (mapKey != key) {
                            return false;
                        }
                    }
                }
                localMapping[mapKey] = mapping[mapKey];
            }
        }

        // The new mapping is updated
        return localMapping;    
    }
function ( fact , ruleFact , mapping , constants , rule ) { var localMapping = { } ; // Checks and update localMapping if matches      if ( ! this . factElemMatches ( fact . predicate , ruleFact . predicate , mapping , localMapping ) ) { return false ; } if ( ! this . factElemMatches ( fact . object , ruleFact . object , mapping , localMapping ) ) { return false ; } if ( ! this . factElemMatches ( fact . subject , ruleFact . subject , mapping , localMapping ) ) { return false ; } emitter . emit ( 'rule-fired' , rule . name ) ; // If an already existing uri has been mapped... for ( var key in localMapping ) { if ( constants . indexOf ( localMapping [ key ] ) !== - 1 ) { return false ; } } // Merges local and global mapping for ( var mapKey in mapping ) { if ( mapKey == '__facts__' ) { localMapping [ mapKey ] = Utils . uniques ( mapping [ mapKey ] , [ fact ] ) ; } else { for ( key in localMapping ) { if ( mapping [ mapKey ] == localMapping [ key ] ) { if ( mapKey != key ) { return false ; } } } localMapping [ mapKey ] = mapping [ mapKey ] ; } } // The new mapping is updated return localMapping ; }
Returns a new or updated mapping if a fact matches a rule cause or consequence,
return false otherwise.
@param fact
@param ruleFact
@param mapping
@returns {*}
Returns a new or updated mapping if a fact matches a rule cause or consequence return false otherwise .