rdf-environment.js
/**
   Compute a set of identified deltas from the graph content.
   Each entry is an array of which the first element is the lexical identifier of a subject
   and the second is an array of roll-forward deltas.
   That is, the first value is set to a JavaScript value and the second is left undefined.
   Functional predicate yield a single value, while multi-valued predicate yield an array.
   */
Compute a set of identified deltas from the graph content.
Each entry is an array of which the first element is the lexical identifier of a subject
and the second is an array of roll-forward deltas.
That is, the first value is set to a JavaScript value and the second is left undefined.
Functional predicate yield a single value, while multi-valued predicate yield an array.
Compute a set of identified deltas from the graph content . Each entry is an array of which the first element is the lexical identifier of a subject and the second is an array of roll - forward deltas . That is the first value is set to a JavaScript value and the second is left undefined . Functional predicate yield a single value while multi - valued predicate yield an array .
computeDeltas(environment, prototypeObject) {
    var ids = [];
    var allDeltas = new Map();
    var addStatementDelta = function(stmt, makeEntry) {
      var name = null;
      var predicate = stmt.predicate.lexicalForm;
      try { name = prototypeObject.getPropertyName(predicate) || environment.findIdentifierName(stmt.predicate); }
        catch (e) {console.warn("computeDeltas: name failure", e);}
      var value = null;
      try { value = environment.toValue(stmt.object, stmt.predicate); }
        catch (e) {console.warn("computeDeltas: value failure", e);}
      var id = stmt.subject.lexicalForm;
      var idDeltas = allDeltas.get(id);
      var deltas = null;
      if (! idDeltas ) {
        deltas = {};
        idDeltas = [id, deltas];
        allDeltas.set(id, idDeltas);
      } else {
        deltas = idDeltas[1];
      }
      var delta = deltas[name];
      if (delta) {
        var deltaValue = delta[0];
        if (deltaValue instanceof Array) { deltaValue.push(value); }
        else { delta[0] = [deltaValue, value]; }
      } else {
        delta = makeEntry(value);
      }
      console.debug('entry', delta);
    };
    this.statements.forEach(function(stmt) {
      addStatementDelta(stmt, function(value) { return ([value, undefined]); });
    });
    console.debug('Graph.computeDeltas', allDeltas);
    return (Array.from(allDeltas.values()));
  }
computeDeltas ( environment , prototypeObject ) { var ids = [ ] ; var allDeltas = new Map ( ) ; var addStatementDelta = function ( stmt , makeEntry ) { var name = null ; var predicate = stmt . predicate . lexicalForm ; try { name = prototypeObject . getPropertyName ( predicate ) || environment . findIdentifierName ( stmt . predicate ) ; } catch ( e ) { console . warn ( "computeDeltas: name failure" , e ) ; } var value = null ; try { value = environment . toValue ( stmt . object , stmt . predicate ) ; } catch ( e ) { console . warn ( "computeDeltas: value failure" , e ) ; } var id = stmt . subject . lexicalForm ; var idDeltas = allDeltas . get ( id ) ; var deltas = null ; if ( ! idDeltas ) { deltas = { } ; idDeltas = [ id , deltas ] ; allDeltas . set ( id , idDeltas ) ; } else { deltas = idDeltas [ 1 ] ; } var delta = deltas [ name ] ; if ( delta ) { var deltaValue = delta [ 0 ] ; if ( deltaValue instanceof Array ) { deltaValue . push ( value ) ; } else { delta [ 0 ] = [ deltaValue , value ] ; } } else { delta = makeEntry ( value ) ; } console . debug ( 'entry' , delta ) ; } ; this . statements . forEach ( function ( stmt ) { addStatementDelta ( stmt , function ( value ) { return ( [ value , undefined ] ) ; } ) ; } ) ; console . debug ( 'Graph.computeDeltas' , allDeltas ) ; return ( Array . from ( allDeltas . values ( ) ) ) ; }
Compute a set of identified deltas from the graph content.
Compute a set of identified deltas from the graph content .
// console.log('computeDeltas', this, environment); // console.log('computeDeltas.fin', environment.findIdentifierName) // extract all subjects , for each assemble add/remove sets // console.log('allDeltas', allDeltas); // console.log("computeDeltas.asd:", stmt) // console.log("computeDeltas", "name", name, "value", value); // console.log('id', id); // console.log('allDeltas', allDeltas); // console.log( 'iddeltas', idDeltas); /*
      var object = null;
      if (name == '@type') {
        // create an instance to accompany the deltas
        // console.log('type');
        var stmtClass = stmt.object.lexicalForm;
        // console.log('class', stmtClass);
        object = environment.createObject(stmtClass, id);
        // console.log('Graph.computeDeltas.asd: created: ', object._state);
        // console.log('object by type', object);
        idDeltas['object'] = object;
        // console.log('object by type', object);
      }*/ // console.log("computeDeltas.asd: added:", stmt);