|
@@ -44,6 +44,7 @@ nsray.push(mt);
|
|
|
let type_ar = ['datatypes', 'objecttypes', 'referencetypes', 'variabletypes'];
|
|
|
let classes_ar = ['datatypes', 'objecttypes', 'referencetypes', 'variabletypes', 'objects', 'variables', 'methods'];
|
|
|
let child_refs = ['Organizes','HasComponent','HasProperty','HasAddIn','HasSubtype'];
|
|
|
+let hier_refs = ['i=34','i=44','i=45','i=35', 'i=47', 'i=46' ]; //HasChild, Aggregates, HasSubtype, Organizes, HasComponent, HasProperty
|
|
|
|
|
|
/*
|
|
|
async function gen_query(sql, params){
|
|
@@ -127,8 +128,10 @@ async function newNid(nid, i){ //Uni -> whatever is needed, global in i
|
|
|
const ul = parseInt(ret[0][0].nsurl);
|
|
|
command = "SELECT nsindex FROM ns"+i+"depends WHERE nsurl='"+ul+"';";
|
|
|
ret = await pool.query(command);
|
|
|
- obj.ns_local = parseInt(ret[0][0].nsindex);
|
|
|
- obj.combi_local = "ns="+obj.ns_local+";"+obj.ident_all;
|
|
|
+ if(ret[0].length > 0){
|
|
|
+ obj.ns_local = parseInt(ret[0][0].nsindex);
|
|
|
+ obj.combi_local = "ns="+obj.ns_local+";"+obj.ident_all;
|
|
|
+ }
|
|
|
}else{
|
|
|
const n1 = nid.split("=");
|
|
|
obj.ident = n1[1];
|
|
@@ -211,6 +214,7 @@ async function getLocalNid(nid, m){ // Uni -> local
|
|
|
obj.ident = n1[1];
|
|
|
obj.ident_all = nid;
|
|
|
obj.combi_local = nid;
|
|
|
+ obj.combi_uni = nid;
|
|
|
|
|
|
}
|
|
|
return obj;
|
|
@@ -1012,7 +1016,7 @@ listRefType();
|
|
|
*/
|
|
|
|
|
|
let arref = [];
|
|
|
-
|
|
|
+/*
|
|
|
async function getThisNodeAttribute(ix, nid, classname, attr){
|
|
|
try{
|
|
|
var res = "";
|
|
@@ -1032,6 +1036,7 @@ async function getThisNodeAttribute(ix, nid, classname, attr){
|
|
|
console.log(err);
|
|
|
}
|
|
|
}
|
|
|
+*/
|
|
|
|
|
|
async function getThisNode(ix, nid, classname){
|
|
|
try{
|
|
@@ -1052,6 +1057,7 @@ async function getThisNode(ix, nid, classname){
|
|
|
obj0 = {
|
|
|
id: l.combi_uni,
|
|
|
text: resp.name,
|
|
|
+ type: ret[0][0].nodeclass,
|
|
|
data: ret[0][0],
|
|
|
children: flag_ch
|
|
|
};
|
|
@@ -1070,34 +1076,64 @@ async function getThisNode(ix, nid, classname){
|
|
|
async function getChildrenSql(ix, nid){ //Uni nodeid -> 4/ns=4;i=131
|
|
|
try{
|
|
|
let res = [];
|
|
|
+ var obj = {};
|
|
|
for(let i = ix; i < nsray.length; i++){
|
|
|
- var obj = await newNid(nid, i);
|
|
|
+ obj = await newNid(nid, i);
|
|
|
var command = "SELECT nodeidorigin FROM ns"+i+"references WHERE target='"+obj.combi_local+"' AND isforward='false';";
|
|
|
+ console.log(command);
|
|
|
var ret = await pool.query(command);
|
|
|
- const iterator = ret[0].values();
|
|
|
- for (const value of iterator) {
|
|
|
- var bb = await getUniNid(value.nodeidorigin, i)
|
|
|
- var nc = "";
|
|
|
- for(let j = 0; j < classes_ar.length; j++){
|
|
|
- if(bb.ns_uni !== 0){
|
|
|
- command = "SELECT nodeclass FROM ns"+bb.ns_uni+""+classes_ar[j]+" WHERE nodeid='ns=1;"+bb.ident_all+"';";
|
|
|
- ret = await pool.query(command);
|
|
|
- if(ret[0].length !== 0){
|
|
|
- nc = ret[0][0].nodeclass;
|
|
|
- res.push([bb.combi_uni, bb.ns_uni, nc]);
|
|
|
- }
|
|
|
- }else{
|
|
|
- command = "SELECT nodeclass FROM ns0"+classes_ar[j]+" WHERE nodeid='"+bb.ident_all+"';";
|
|
|
- ret = await pool.query(command);
|
|
|
- if(ret[0].length !== 0){
|
|
|
- nc = ret[0][0].nodeclass;
|
|
|
- res.push([bb.combi_uni, bb.ns_uni, nc]);
|
|
|
- }
|
|
|
- }
|
|
|
+ var iterator = ret[0].values();
|
|
|
+ for (const value of iterator) {
|
|
|
+ var bb = await getUniNid(value.nodeidorigin, i)
|
|
|
+ var nc = "";
|
|
|
+ for(let j = 0; j < classes_ar.length; j++){
|
|
|
+ if(bb.ns_uni !== 0){
|
|
|
+ command = "SELECT nodeclass FROM ns"+bb.ns_uni+""+classes_ar[j]+" WHERE nodeid='ns=1;"+bb.ident_all+"';";
|
|
|
+ ret = await pool.query(command);
|
|
|
+ if(ret[0].length !== 0){
|
|
|
+ nc = ret[0][0].nodeclass;
|
|
|
+ res.push([bb.combi_uni, bb.ns_uni, nc]);
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ command = "SELECT nodeclass FROM ns0"+classes_ar[j]+" WHERE nodeid='"+bb.ident_all+"';";
|
|
|
+ ret = await pool.query(command);
|
|
|
+ if(ret[0].length !== 0){
|
|
|
+ nc = ret[0][0].nodeclass;
|
|
|
+ res.push([bb.combi_uni, bb.ns_uni, nc]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ obj = await getLocalNid(nid, ix);
|
|
|
+ command = "SELECT target FROM ns"+ix+"references WHERE nodeidorigin='"+obj.combi_local+"' AND isforward='undefined';"; //Search all hierarchical references!
|
|
|
+ console.log(command);
|
|
|
+ ret = await pool.query(command);
|
|
|
+ var iterator = ret[0].values();
|
|
|
+ for (const value of iterator) {
|
|
|
+ var bb = await getUniNid(value.target, ix)
|
|
|
+ var nc = "";
|
|
|
+ for(let j = 0; j < classes_ar.length; j++){
|
|
|
+ if(bb.ns_uni !== 0){
|
|
|
+ command = "SELECT nodeclass FROM ns"+bb.ns_uni+""+classes_ar[j]+" WHERE nodeid='ns=1;"+bb.ident_all+"';";
|
|
|
+ console.log(command);
|
|
|
+ ret = await pool.query(command);
|
|
|
+ if(ret[0].length !== 0){
|
|
|
+ nc = ret[0][0].nodeclass;
|
|
|
+ res.push([bb.combi_uni, bb.ns_uni, nc]);
|
|
|
}
|
|
|
+ }else{
|
|
|
+ command = "SELECT nodeclass FROM ns0"+classes_ar[j]+" WHERE nodeid='"+bb.ident_all+"';";
|
|
|
+ console.log(command);
|
|
|
+ ret = await pool.query(command);
|
|
|
+ if(ret[0].length !== 0){
|
|
|
+ nc = ret[0][0].nodeclass;
|
|
|
+ res.push([bb.combi_uni, bb.ns_uni, nc]);
|
|
|
+ }
|
|
|
}
|
|
|
- //}
|
|
|
+ }
|
|
|
}
|
|
|
+ console.log(res);
|
|
|
return res;
|
|
|
}catch(err){
|
|
|
console.log(err);
|
|
@@ -2093,7 +2129,7 @@ app.post('/key', async function(req, res){
|
|
|
|
|
|
})
|
|
|
*/
|
|
|
-
|
|
|
+/*
|
|
|
app.get('/look/:ix/:id/:eclass/:attr', async function(req, res){
|
|
|
try{
|
|
|
var ix = req.params["ix"];
|
|
@@ -2119,7 +2155,7 @@ app.get('/look/:ix/:id/:eclass/:attr', async function(req, res){
|
|
|
}
|
|
|
|
|
|
})
|
|
|
-
|
|
|
+*/
|
|
|
app.get('/find/:ix/:id/:eclass', async function(req, res){
|
|
|
try{
|
|
|
var ix = req.params["ix"];
|
|
@@ -2150,7 +2186,7 @@ app.get('/children/sql/:ix/:id', async function(req, res){
|
|
|
var ix = req.params["ix"];
|
|
|
var id = req.params["id"];
|
|
|
var ret = await getChildrenSql(ix, id);
|
|
|
- res.json({result:ret, success: true});
|
|
|
+ res.json({num:ret.length, result:ret, success: true});
|
|
|
}catch(err){
|
|
|
console.log(err);
|
|
|
res.json({result:"NOK"});
|
|
@@ -2553,7 +2589,7 @@ app.get('/lazy', async function(req, res) {
|
|
|
var ret_obj = [];
|
|
|
let node = {};
|
|
|
if(req.query.id == "#"){
|
|
|
- res.json([{id:"i=84",text:"Root",data:{nodeclass:"Object", nsindex:0},children:[{id:"i=85",text:"Objects",data:{nodeclass:"Object", nsindex:0},children:true},{id:"i=86",text:"Types", data:{nodeclass:"Object", nsindex:0},children:true},{id:"i=87",text:"View",data:{nodeclass:"Object", nsindex:0},children:true}]}]);
|
|
|
+ res.json([{id:"i=84",text:"Root", type:"Object", data:{nodeclass:"Object", nsindex:0},children:[{id:"i=85",text:"Objects",type:"Object",data:{nodeclass:"Object", nsindex:0},children:true},{id:"i=86",text:"Types", type:"Object",data:{nodeclass:"Object", nsindex:0},children:true},{id:"i=87",text:"View",type:"Object",data:{nodeclass:"Object", nsindex:0},children:true}]}]);
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
@@ -2576,6 +2612,7 @@ app.get('/lazy', async function(req, res) {
|
|
|
|
|
|
var ch = await getChildrenSql(idx, obj.id);
|
|
|
//console.log(ch);
|
|
|
+ var child_arr = [];
|
|
|
for(let j = 0; j < ch.length; j++){
|
|
|
classn = ch[j][2];
|
|
|
switch(classn){
|
|
@@ -2591,10 +2628,12 @@ app.get('/lazy', async function(req, res) {
|
|
|
console.log(ch[j][1]+","+ch[j][0]+","+class_name);
|
|
|
var ch0 = await getThisNode(ch[j][1],ch[j][0],class_name);
|
|
|
console.log(ch0);
|
|
|
+ child_arr.push(ch0);
|
|
|
}
|
|
|
//console.log(ch);
|
|
|
|
|
|
-
|
|
|
+ res.json([{id:obj.id, text:obj.text, type:obj.data.nodeclass, data:obj.data, children:child_arr}]);
|
|
|
+ return 0;
|
|
|
|
|
|
|
|
|
|