Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
clinicaltrials
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
david Chavalarias
clinicaltrials
Commits
0fe18527
Commit
0fe18527
authored
Jul 05, 2017
by
Romain Loth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
minimal implementation of php reading db.json
parent
26ba9a7f
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
116 additions
and
28 deletions
+116
-28
servermenu_config.md
00.DOCUMENTATION/A-Introduction/servermenu_config.md
+27
-0
db.json
db.json
+1
-4
default_div.php
twbackends/phpAPI/default_div.php
+8
-8
parameters_details.php
twbackends/phpAPI/parameters_details.php
+80
-16
No files found.
00.DOCUMENTATION/A-Introduction/servermenu_config.md
0 → 100644
View file @
0fe18527
## Servermenu Configuration
#### minimal config
```
json
"$$data/yourprojectdir"
:
{
"graphs"
:
{
"$$something.gexf"
:{
"node0"
:
{
"name"
:
"$$blabla"
}
}
}
}
```
#### to activate relatedDocs LocalDB queries
For a relatedDocs query, you need to add to your node entry the
`reldbfile`
key:
```json
"node0": {
"name": "$$blabla",
"reldbfile": "$$relpath/to/csv/or/sqlite"
}
```
db.json
View file @
0fe18527
...
...
@@ -54,10 +54,8 @@
}
},
"data/politoscope"
:
{
"dbname"
:
null
,
"title"
:
"Politoscope"
,
"date"
:
"2017"
,
"abstract"
:
""
,
"first"
:
"ProgrammeDesCandidats.enrichi.gexf"
,
"graphs"
:
{
"ProgrammeDesCandidats.enrichi.gexf"
:
{
...
...
@@ -69,13 +67,12 @@
}
},
"data/ClimateChange"
:
{
"abstract"
:
"ISIABSTRACT"
,
"graphs"
:
{
"Maps_S_800.gexf"
:
{
"node0"
:
{
"name"
:
"ISItermsWhitelistV2Oct_5 & ISItermsWhitelistV2Oct_5"
,
"reldbtable"
:
"ISItermsWhitelistV2Oct_5"
,
"reldb
nam
e"
:
"wos_climate-change_title_2014-2015.db"
,
"reldb
fil
e"
:
"wos_climate-change_title_2014-2015.db"
,
"reldbtype"
:
"CortextDB"
}
}
...
...
twbackends/phpAPI/default_div.php
View file @
0fe18527
<?php
// default informations
$thedb
=
$graphdb
;
$gexf
=
$_GET
[
"gexf"
];
$type
=
$_GET
[
"type"
];
$TITLE
=
"ISITITLE"
;
$TITLE
=
"ISITITLE"
;
// <=== hardcoded Cortext table /!\
$query
=
str_replace
(
'__and__'
,
'&'
,
$_GET
[
"query"
]
);
$elems
=
json_decode
(
$query
);
// hardcoded CortextDB table /!\
$table
=
""
;
$column
=
""
;
$id
=
""
;
...
...
@@ -19,15 +18,15 @@ $twjs="LOCALDB/"; // LOCALDB folder.
// echo("elems[0]: ".$elems[0]."<br/>");
// echo("is_array($elems): ".is_array($elems)."<br/>");
if
(
$type
==
"social"
){
$table
=
"ISIAUTHOR"
;
if
(
$
nd
type
==
"social"
){
$table
=
"ISIAUTHOR"
;
// <== hardcoded CortextDB table /!\
$column
=
"data"
;
$id
=
"id"
;
$restriction
=
''
;
$factor
=
10
;
// factor for normalisation of stars
}
if
(
$type
==
"semantic"
){
if
(
$
nd
type
==
"semantic"
){
$table
=
$_GET
[
"index"
];
//"ISItermsfirstindexing";
$column
=
"data"
;
$id
=
"id"
;
...
...
@@ -110,6 +109,7 @@ foreach ($wos_ids as $id => $score) {
if
(
$count
<=
$max_item_displayed
){
$count
+=
1
;
// hardcoded CortextDB table /!\
$sql
=
'SELECT data FROM ISITITLE WHERE id='
.
$id
.
' group by data'
;
foreach
(
$base
->
query
(
$sql
)
as
$row
)
{
...
...
@@ -120,7 +120,7 @@ foreach ($wos_ids as $id => $score) {
// echo '<a href="JavaScript:newPopup(\''.$twjs.'default_doc_details.php?gexf='.urlencode($gexf).'&index='.$table.'&query='.urlencode($query).'&type='.urlencode($_GET["type"]).'&id='.$id.' \')">'.$row['data']." </a> ";
}
// get the authors
// get the authors
/!\ hardcoded CortextDB table /!\
$sql
=
'SELECT data FROM ISIAUTHOR WHERE id='
.
$id
;
foreach
(
$base
->
query
(
$sql
)
as
$row
)
{
$output
.=
(
$row
[
'data'
])
.
', '
;
...
...
twbackends/phpAPI/parameters_details.php
View file @
0fe18527
<?php
// default path to ProjectExplorer root
// (where data directory and db.json file reside)
$mainpath
=
dirname
(
getcwd
())
.
"/../"
;
$ntypes
=
2
;
$project_menu_path
=
"db.json"
;
// reading db.json associations
// source graph file <=> (db, dbtype, cols) as relatedDocs php API
$project_menu_fh
=
fopen
(
$mainpath
.
$project_menu_path
,
"r"
);
$json_st
=
''
;
while
(
!
feof
(
$project_menu_fh
))
{
$json_st
.=
fgets
(
$project_menu_fh
);
}
fclose
(
$project_menu_fh
);
$project_menu
=
json_decode
(
$json_st
);
// echodump("== db.json menu ==", $project_menu);
// parse db.json project menu and create a conf by file
$conf
=
array
();
foreach
(
$project_menu
as
$project_dir
=>
$dir_items
){
// NB access by obj property (and not array key)
if
(
!
property_exists
(
$dir_items
,
'graphs'
))
{
error_log
(
"tw/phpAPI skip error: conf file (
$project_menu_path
)
has no 'graphs' entry for project '
$project_dir
' !"
);
continue
;
}
foreach
(
$dir_items
->
graphs
as
$graph_file
=>
$graph_conf
){
// echodump("== $graph_file ==", $graph_conf);
# loading an associated db for a given gexf as relatedDocs php API
$gexf_db
=
array
();
$gpath
=
$project_dir
.
'/'
.
$graph_file
;
# £££TODO read the db.json
$gexf_db
[
"data/ClimateChange/Maps_S_800.gexf"
]
=
"data/ClimateChange/wos_climate-change_title_2014-2015.db"
;
$gexf_db
[
"data/AXA/RiskV2PageRank1000.gexf"
]
=
"data/AXA/data.db"
;
$gexf_db
[
"data/AXA/RiskV2PageRank2500.gexf"
]
=
"data/AXA/data.db"
;
$gexf_db
[
"data/AXA/RiskV2PageRank5000.gexf"
]
=
"data/AXA/data.db"
;
$gexf_db
[
"data/test/mini_for_csv.gexf"
]
=
"data/test/mini_for_csv.csv"
;
$gexf_db
[
"data/gargistex/shale_and_ice.gexf"
]
=
"data/gargistex/shale_and_ice.csv"
;
$gexf_db
[
"data/gargistex/model_calibration.gexf"
]
=
"data/gargistex/model_calibration.csv"
;
// NB a graph conf can now have different settings for each nodetype
// node0 <=> classic type 'semantic'
// node1 <=> classic type 'social'
// $gexf_db["data/ProgrammeDesCandidats.gexf"] = "foobar";
$conf
[
$gpath
]
=
array
(
$ntypes
);
for
(
$i
=
0
;
$i
<
$ntypes
;
$i
++
)
{
// check node0, node1, etc to see if they at least have a reldbfile
if
(
!
property_exists
(
$graph_conf
,
'node'
.
$i
)
||
!
property_exists
(
$graph_conf
->
{
'node'
.
$i
},
'reldbfile'
)
)
{
$conf
[
$gpath
][
$i
]
=
array
(
'active'
=>
false
);
continue
;
}
else
{
// we have a file for this type: copy entire conf
$conf
[
$gpath
][
$i
]
=
(
array
)
$graph_conf
->
{
'node'
.
$i
};
$conf
[
$gpath
][
$i
][
'active'
]
=
true
;
$conf
[
$gpath
][
$i
][
'dir'
]
=
$project_dir
;
}
// POSS here info on higher level may be propagated for lower ones
// (ex: if dbtype is on the project level, its value should count
// for each source file in the project unless overridden)
}
}
}
// =======================================
// echodump("== READ CONF ==<br>", $conf);
// =======================================
$gexf
=
str_replace
(
'"'
,
''
,
$_GET
[
"gexf"
]);
$ndtype
=
$_GET
[
"type"
];
$ntid
=
null
;
//
default path to ProjectExplorer root
// (where data directory and db.json file reside)
$mainpath
=
dirname
(
getcwd
())
.
"/../"
;
//
legacy types => generic types
if
(
$ndtype
==
'semantic'
)
{
$ntid
=
0
;
}
else
{
$ntid
=
1
;
}
$graphdb
=
$gexf_db
[
$gexf
];
if
(
!
$conf
[
$gexf
][
$ntid
][
'active'
])
{
echo
(
"The relatedDocs configuration for your graph (
$gexf
) isn't active
(please read 00.DOCUMENTATION/A-Introduction/servermenu_config.md).<br>"
);
exit
(
1
);
}
else
{
$my_conf
=
$conf
[
$gexf
][
$ntid
];
$graphdb
=
$my_conf
[
'dir'
]
.
'/'
.
$my_conf
[
'reldbfile'
];
}
echodump
(
"reldb"
,
$graphdb
);
// for csv parsing
$csvsep
=
"
\t
"
;
...
...
@@ -39,7 +101,9 @@ $max_item_displayed = 7;
function
echodump
(
$title
,
$anyObj
)
{
echo
"<br>"
.
$title
.
": "
;
echo
(
json_encode
(
$anyObj
,
JSON_PRETTY_PRINT
));
echo
(
preg_replace_callback
(
"/
\n
(\s*)/"
,
function
(
$capt
){
return
(
'<br>'
.
str_repeat
(
' '
,
strlen
(
$capt
[
0
])));
},
json_encode
(
$anyObj
,
JSON_PRETTY_PRINT
)));
echo
"<br>"
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment