donderdag 14 november 2019

'Knowledge' Management Part 5 (connecting label-list-items and court decisions)



This is the result.

Court decisions are connected to labels-list-items or vice versa. I don't know anymore what I have been doing here. It works however.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
var naamSkelet = "Skelet";
var aantalKolommen = 5;
var dropDownEersteKolom = 7;
var indexDropDownEersteKolom = dropDownEersteKolom - 1;
var indexDropDownLaatsteKolom = dropDownEersteKolom + aantalKolommen;

function ImportsCaseLawInDocument(){
  var ss = SpreadsheetApp.openById(idSS); 
  var sheet = ss.getSheetByName("Data");
  var range = sheet.getRange(1,1,sheet.getMaxRows(),sheet.getMaxColumns());
  var data = range.getValues(); 
  
  for(var d=1;d<data.length;d++){
    var row = data[d];
        
    if(row[1]){
      var datum = ddKort(row[1]);
      var kenmerk = row[2];
      if(row[3]){var ecli = row[3];}else{var ecli = kenmerk;}
      var link = row[4];
      var instantie = row[5]; 
      var inhoudsindicatie = row[6];
      var tekst = inhoudsindicatie + " [" + instantie +  " " + datum +  " " + ecli +  " " + kenmerk +  "]";  
      var searchArray = [];
      
      var s= indexDropDownEersteKolom; 
      while(s<indexDropDownLaatsteKolom && row[s] !== ""){
        searchArray.push(row[s]);
        s++
      }
      
      if(searchArray){
        hlpImportsCaseLawInDocument(searchArray,tekst,ecli,link);
      }
    }
  }  
}

function hlpImportsCaseLawInDocument(searchArray,tekst,ecli,link){
  var doc = DocumentApp.getActiveDocument();
  var body = doc.getBody();
  var children = body.getListItems().filter(function(child){
    return child.getText() == searchArray[searchArray.length-1];
  });    
  
  for(var i=0;i<children.length;i++){
    var child = children[i]; 
    var resultArray = zoektVoorouders(child);
    
    if(comparesArrays(searchArray,resultArray) == true){
      var childIndex = body.getChildIndex(child);
      var childNestingLevel = body.getChild(childIndex).asListItem().getNestingLevel(); 
      var usp = body.insertListItem(childIndex+1,tekst).setNestingLevel(childNestingLevel + 1);
      addHyperlink(usp,ecli,link);
    }
  }
}

function comparesArrays(arrayeen,arraytwee){
  if(arrayeen.length !== arraytwee.length){
   return false; 
  }
  var i=0;
  while(i<arrayeen.length){
   if (arrayeen[i] !== arraytwee[i]){
   return false;  
   }
  i++  
  }
  return true;
}

Geen opmerkingen:

Een reactie posten