vicinityManager/server/services/items/registration.js
/*
Adds all new oids to the node hasItems
If the oid is already in there skip it
*/
Adds all new oids to the node hasItems
If the oid is already in there skip it
Adds all new oids to the node hasItems If the oid is already in there skip it
function updateItemsList(items, allresult){
  return new Promise(function(resolve, reject) {
    try{
      var i, j;
      if(items.length > 0){
        var itemsOid = []; 
        for(i = 0; i < items.length; i++){
            itemsOid.push(items[i].oid);
        }
        for(j = 0; j < allresult.length; j++){
          if(itemsOid.indexOf(allresult[j].data.oid) === -1 && allresult[j].result === "Success"){
            items.push({id: allresult[j].data.id, extid: allresult[j].data.oid});
          }
        }
      } else {
        for(j = 0; j < allresult.length; j++){
          if(allresult[j].result === "Success"){
            items.push({id: allresult[j].data.id, extid: allresult[j].data.oid});
          }
        }
      }
      resolve(items);
    } catch(err){
      reject("(collecting new oids for the node) " + err);
    }
  });
}
function updateItemsList ( items , allresult ) { return new Promise ( function ( resolve , reject ) { try { var i , j ; if ( items . length > 0 ) { var itemsOid = [ ] ; for ( i = 0 ; i < items . length ; i ++ ) { itemsOid . push ( items [ i ] . oid ) ; } for ( j = 0 ; j < allresult . length ; j ++ ) { if ( itemsOid . indexOf ( allresult [ j ] . data . oid ) === - 1 && allresult [ j ] . result === "Success" ) { items . push ( { id : allresult [ j ] . data . id , extid : allresult [ j ] . data . oid } ) ; } } } else { for ( j = 0 ; j < allresult . length ; j ++ ) { if ( allresult [ j ] . result === "Success" ) { items . push ( { id : allresult [ j ] . data . id , extid : allresult [ j ] . data . oid } ) ; } } } resolve ( items ) ; } catch ( err ) { reject ( "(collecting new oids for the node) " + err ) ; } } ) ; }
Adds all new oids to the node hasItems
If the oid is already in there skip it
Adds all new oids to the node hasItems If the oid is already in there skip it
// get oids only if doc saved succesfully // var oidArray = getIds(allresult, 'oid'); //store a simple array of OIDs to compare