1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace FlexiPeeHP; |
4
|
|
|
|
5
|
|
|
require_once '../testing/bootstrap.php'; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Obtain structure for given evidence |
9
|
|
|
* |
10
|
|
|
* @param string $evidence |
11
|
|
|
* @param FlexiBeeRO $syncer Class to read from FlexiBee |
12
|
|
|
* @return array Evidence structure |
13
|
|
|
*/ |
14
|
|
|
function getColumnsInfo($evidence, FlexiBeeRO $syncer) { |
15
|
|
|
$useKeywords = []; |
16
|
|
|
$flexinfo = $syncer->performRequest($evidence . '/properties.json'); |
17
|
|
|
if (count($flexinfo) && array_key_exists('properties', $flexinfo)) { |
18
|
|
|
foreach ($flexinfo['properties']['property'] as $evidenceProperty) { |
19
|
|
|
$key = $evidenceProperty['propertyName']; |
20
|
|
|
$useKeywords[$key] = $evidenceProperty; |
21
|
|
|
$useKeywords[$key]['name'] = $evidenceProperty['name']; |
22
|
|
|
$useKeywords[$key]['type'] = $evidenceProperty['type']; |
23
|
|
|
} |
24
|
|
|
} |
25
|
|
|
return $useKeywords; |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
function controlData($data, $fbColumns, $fbRelations) { |
29
|
|
|
$controlResult = []; |
30
|
|
|
if (count($fbColumns)) { |
31
|
|
|
foreach ($data as $key => $value) { |
32
|
|
|
if ($key == 'external-ids') { |
33
|
|
|
continue; |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
if (strstr($key, '@')) { |
37
|
|
|
$baseKey = substr($key, 0, strrpos($key, '@')); |
38
|
|
|
if (!array_key_exists($baseKey, $fbColumns)) { |
39
|
|
|
$controlResult[$key][] = sprintf('unknown column property %s', |
40
|
|
|
$key); |
41
|
|
|
} |
42
|
|
|
continue; |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
if (!array_key_exists($key, $fbColumns)) { |
46
|
|
|
if (is_array($fbRelations) && !array_key_exists($key, |
47
|
|
|
$fbRelations)) { |
48
|
|
|
$controlResult[$key][] = sprintf('unknown column %s', $key); |
49
|
|
|
} |
50
|
|
|
} |
51
|
|
|
} |
52
|
|
|
} |
53
|
|
|
return $controlResult; |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
$syncer = new EvidenceList(); |
57
|
|
|
|
58
|
|
|
$evidencies = $syncer->getColumnsFromFlexibee(['evidencePath', 'evidenceName']); |
|
|
|
|
59
|
|
|
|
60
|
|
|
|
61
|
|
|
$controlResult = []; |
62
|
|
|
foreach ($evidencies['evidences']['evidence'] as $evidenceID => $evidence) { |
63
|
|
|
$evlist[$evidence['evidencePath']] = $evidence['evidenceName']; |
64
|
|
|
|
65
|
|
|
$syncer->setEvidence($evidence['evidencePath']); |
66
|
|
|
$firstRecord = $syncer->getFlexiData(null, ['limit' => 1]); |
67
|
|
|
if (count($firstRecord) && isset($firstRecord[0]) && count($firstRecord[0])) { |
68
|
|
|
$controlled = controlData($firstRecord[0], $syncer->getColumnsInfo(), |
69
|
|
|
$syncer->getRelationsInfo()); |
70
|
|
|
if (count($controlled)) { |
71
|
|
|
$controlResult[$evidence['evidencePath']] = $controlled; |
72
|
|
|
} |
73
|
|
|
} |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
echo json_encode($controlResult, JSON_PRETTY_PRINT); |
77
|
|
|
|
78
|
|
|
|
79
|
|
|
|
This function has been deprecated. The supplier of the function has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.