-
Notifications
You must be signed in to change notification settings - Fork 0
/
ajax_server.php
132 lines (82 loc) · 4 KB
/
ajax_server.php
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
include("include.php");
if (isset($_POST)) {
if (isset($_POST['action'])) {
try {
/**
* @var $dbConn GraphDBProtocol
*/
$dbConn = new RDFODBCConn();
$RDFMed = new RDFMediator($dbConn);
if ($_POST['action'] == 'searchObjectsForGraph' && isset($_POST['searchstring'])) {
$RDFMed->searchObjects($_POST['searchstring']);
$RDFMed->printToJsonForGraph();
}
elseif ($_POST['action'] == 'searchObjectsForSearch' && isset($_POST['searchstring'])) {
$RDFMed->searchObjects($_POST['searchstring']);
$RDFMed->printToJsonForSearch();
}
elseif ($_POST['action'] == 'getObjectById') {
if (isset($_POST['recLevel'])) {
$RDFMed->getObject($_POST['oid'], $_POST['recLevel']);
}
else {
$RDFMed->getObject($_POST['oid']);
}
$RDFMed->printToJsonForGraph();
}
elseif ($_POST['action'] == 'newObject' && isset($_POST['type'])) {
if (isset($_POST['properties']) && isset($_POST['values'])) {
$properties = array();
foreach ($_POST['properties'] as $number => $property) {
$properties[$property] = $_POST['values'][$number];
}
$oid = $RDFMed->addObject($_POST['type'], $properties);
}
else {
$oid = $RDFMed->addObject($_POST['type'], array());
}
echo utf8_encode(json_encode(array( 'check' => 'suc', 'oid' => $oid )));
}
elseif ($_POST['action'] == 'deleteObject' && isset($_POST['oid'])) {
$RDFMed->deleteObject($_POST['oid']);
echo utf8_encode(json_encode(array( 'check' => 'suc', 'oid' => $_POST['oid'] )));
}
elseif ($_POST['action'] == 'addProperty' && isset($_POST['oid']) && isset($_POST['property'])
&& isset($_POST['value'])) {
$RDFMed->addProperty($_POST['oid'], $_POST['property'], $_POST['value']);
echo utf8_encode(json_encode(array( 'check' => 'suc' )));
}
elseif ($_POST['action'] == 'removeProperty' && isset($_POST['oid']) && isset($_POST['property'])
&& isset($_POST['value'])) {
$RDFMed->removeProperty($_POST['oid'], $_POST['property'], $_POST['value']);
echo utf8_encode(json_encode(array( 'check' => 'suc' )));
}
elseif ($_POST['action'] == 'addRelation' && isset($_POST['oid']) && isset($_POST['relation'])
&& isset($_POST['other_oid'])) {
$RDFMed->addRelation($_POST['oid'], $_POST['relation'], $_POST['other_oid']);
echo utf8_encode(json_encode(array( 'check' => 'suc' )));
}
elseif ($_POST['action'] == 'removeRelation' && isset($_POST['oid']) && isset($_POST['relation'])
&& isset($_POST['other_oid'])) {
$RDFMed->removeRelation($_POST['oid'], $_POST['relation'], $_POST['other_oid']);
echo utf8_encode(json_encode(array( 'check' => 'suc' )));
}
elseif ($_POST['action'] == 'getClasses' && isset($_POST['searchstring'])) {
$dbConn->getClasses($_POST['searchstring']);
}
elseif ($_POST['action'] == 'getAllPropertyTypes' && isset($_POST['searchstring'])) {
$dbConn->getAllPropertyTypes($_POST['searchstring']);
}
elseif ($_POST['action'] == 'getAllRelationTypes' && isset($_POST['searchstring'])) {
$dbConn->getAllRelationTypes($_POST['searchstring']);
}
}
catch (Exception $e) {
my_print_r($e);
}
}
}
?>