-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsearch_singleCI.php
96 lines (83 loc) · 3.2 KB
/
search_singleCI.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
<?php
//file exists for getting search_request in editMode and in deleteMode
//-> I guess its obsolete now
// load up config file
require_once("dataBase_config.php");
$suggestQuery = $_REQUEST['query'];
$suggestType = $_REQUEST['type'];
$suggestProperty = $_REQUEST['prop'];
$answer = array();
switch ($suggestType) {
case "Anwendung":
$queryString = '
MATCH (n) WHERE n.type="'.$suggestType.'" AND n.'.$suggestProperty.' =~ ".*'.$suggestQuery.'.*"
RETURN DISTINCT "node" as element, n.'.$suggestProperty.' AS name, ID(n) AS id
';
$query = new Everyman\Neo4j\Cypher\Query($neo4jClient, $queryString);
$result = $query->getResultSet();
foreach ($result as $row) {
array_push($answer, $row['name']);
array_push($answer, $row['id']);
}
break;
case "Artefakt":
$queryString = '
MATCH (n) WHERE n.type="'.$suggestType.'" AND n.'.$suggestProperty.' =~ ".*'.$suggestQuery.'.*"
RETURN DISTINCT "node" as element, n.'.$suggestProperty.' AS name, n.Lizenz AS lizenz, n.Sonstiges AS sonstiges, ID(n) AS id
';
$query = new Everyman\Neo4j\Cypher\Query($neo4jClient, $queryString);
$result = $query->getResultSet();
foreach ($result as $row) {
array_push($answer, $row['name']);
array_push($answer, $row['lizenz']);
array_push($answer, $row['sonstiges']);
array_push($answer, $row['id']);
}
break;
case "Deployment":
$teile = explode("|", $suggestQuery);
$queryString = '
MATCH (a)-[:deployed_On]->(b)-[:installed_On]->(c)
WHERE a.name =~ ".*'.$teile[0].'.*" AND c.name =~ ".*'.$teile[1].'.*"
RETURN DISTINCT b, b.DeploymentLayer AS dl, b.Port AS port, b.RTE AS rte, b.Zuordnung AS zuord, ID(b) AS id
';
$query = new Everyman\Neo4j\Cypher\Query($neo4jClient, $queryString);
$result = $query->getResultSet();
foreach ($result as $row) {
array_push($answer, $row['dl']);
array_push($answer, $row['port']);
array_push($answer, $row['rte']);
array_push($answer, $row['zuord']);
array_push($answer, $row['id']);
}
break;
case "Server":
$queryString = '
MATCH (n) WHERE n.type="'.$suggestType.'" AND n.'.$suggestProperty.' =~ ".*'.$suggestQuery.'.*"
RETURN DISTINCT "node" as element, n.'.$suggestProperty.' AS name, n.Zone AS zone, n.OS AS os, ID(n) AS id
';
$query = new Everyman\Neo4j\Cypher\Query($neo4jClient, $queryString);
$result = $query->getResultSet();
foreach ($result as $row) {
array_push($answer, $row['name']);
array_push($answer, $row['zone']);
array_push($answer, $row['os']);
array_push($answer, $row['id']);
}
break;
case "Hardware":
$queryString = '
MATCH (n) WHERE n.type="'.$suggestType.'" AND n.'.$suggestProperty.' =~ ".*'.$suggestQuery.'.*"
RETURN DISTINCT "node" as element, n.'.$suggestProperty.' AS name, ID(n) AS id
';
$query = new Everyman\Neo4j\Cypher\Query($neo4jClient, $queryString);
$result = $query->getResultSet();
foreach ($result as $row) {
array_push($answer, $row['name']);
array_push($answer, $row['id']);
}
break;
}
echo json_encode ($answer);
//$arr = array('label' => 'graylog');
?>