9 namespace Fossology\Lib\Dao;
30 function __construct(
DbManager $dbManager)
33 $this->logger =
new Logger(self::class);
35 $this->typeMap = array(
36 'M' => Highlight::MATCH,
37 'M ' => Highlight::MATCH,
38 'M0' => Highlight::MATCH,
39 'M+' => Highlight::ADDED,
40 'M-' => Highlight::DELETED,
41 'MR' => Highlight::CHANGED,
42 'L' => Highlight::SIGNATURE,
43 'L ' => Highlight::SIGNATURE,
44 'K' => Highlight::KEYWORD,
45 'K ' => Highlight::KEYWORD,
58 $params =array($itemTreeBounds->
getItemId());
61 $sql =
"SELECT start,len,type,rf_fk,rf_start,rf_len
63 INNER JOIN highlight ON license_file.fl_pk = highlight.fl_fk
64 INNER JOIN $uploadTreeTableName ut ON ut.pfile_fk = license_file.pfile_fk
65 WHERE uploadtree_pk = $1 AND (type LIKE 'M_' OR type = 'L')";
67 $stmt = __METHOD__.$uploadTreeTableName;
68 if (!empty($licenseId) && empty($highlightId)) {
69 $params[] = $licenseId;
71 $sql .=
" AND license_file.rf_fk=$" . count($params);
73 if (!empty($agentId) && is_array($agentId)) {
74 $params[] =
'{' . implode(
',', $agentId) .
'}';
76 $sql .=
" AND license_file.agent_fk=ANY($" . count($params).
")";
77 }
else if (!empty($agentId)) {
80 $sql .=
" AND license_file.agent_fk=$" . count($params);
83 if (!empty($highlightId)) {
84 $params[] = $highlightId;
85 $stmt .=
'.Highlight';
86 $sql .=
" AND fl_pk=$" . count($params);
89 $result = $this->
dbManager->execute($stmt, $params);
90 $highlightEntries = array();
91 while ($row = $this->
dbManager->fetchArray($result)) {
93 intval($row[
'start']), intval($row[
'start'] + $row[
'len']),
94 $this->typeMap[$row[
'type']],
95 intval($row[
'rf_start']), intval($row[
'rf_start'] + $row[
'rf_len']));
97 $licenseId = $row[
'rf_fk'];
99 $newHiglight->setLicenseId($licenseId);
101 $highlightEntries[] = $newHiglight;
104 return $highlightEntries;
107 public function getHighlightRegion($licenseMatchId)
110 "SELECT MIN(start) AS start, MAX(start+len) AS end FROM highlight WHERE fl_fk = $1",
111 array($licenseMatchId)
113 return false !== $row ? array($row[
'start'], $row[
'end']) : array(-1, -1);
123 $stmt = __METHOD__.$uploadTreeTableName;
124 $sql =
"SELECT start,len
125 FROM highlight_keyword AS hk
126 INNER JOIN $uploadTreeTableName AS ut
127 ON hk.pfile_fk = ut.pfile_fk
128 WHERE ut.uploadtree_pk = $1";
131 $highlightEntries = array();
132 while ($row = $this->
dbManager->fetchArray($result)) {
134 intval($row[
'start']), intval($row[
'start'] + $row[
'len']),
135 Highlight::KEYWORD, 0, 0);
138 return $highlightEntries;
149 $sql =
"SELECT h.clearing_event_fk, h.start, h.len, ce.rf_fk, rf_text
150 FROM clearing_event ce
151 INNER JOIN highlight_bulk h ON ce.clearing_event_pk = h.clearing_event_fk
152 INNER JOIN license_ref_bulk lrb ON lrb.lrb_pk = h.lrb_fk
153 WHERE ce.uploadtree_fk = $1";
154 $params = array($uploadTreeId);
155 if (!empty($clearingId)) {
156 $stmt .=
".clearingId";
157 $params[] = $clearingId;
158 $sql .=
" AND h.clearing_event_fk = $" . count($params);
161 $result = $this->
dbManager->execute($stmt, $params);
162 $highlightEntries = array();
163 while ($row = $this->
dbManager->fetchArray($result)) {
165 intval($row[
'start']), intval($row[
'start'] + $row[
'len']),
166 Highlight::BULK, 0, 0);
167 $newHighlight->setLicenseId($row[
'rf_fk']);
168 $highlightEntries[] = $newHighlight;
171 return $highlightEntries;
184 $highlightDiffs = $this->
getHighlightDiffs($itemTreeBounds, $licenseId, $agentId, $highlightId);
187 return array_merge(array_merge($highlightDiffs,$highlightKeywords),$highlightBulk);
199 SELECT start FROM highlight WHERE fl_fk=$1 ORDER BY start ASC LIMIT 1
201 SELECT conf_value FROM sysconfig WHERE variablename LIKE 'BlockSizeText'
205 array($licenseMatchId)
getPageNumberOfHighlightEntry($licenseMatchId)
getHighlightKeywords(ItemTreeBounds $itemTreeBounds)
getHighlightEntries(ItemTreeBounds $itemTreeBounds, $licenseId=null, $agentId=null, $highlightId=null, $clearingId=null)
getHighlightBulk($uploadTreeId, $clearingId=null)
getHighlightDiffs(ItemTreeBounds $itemTreeBounds, $licenseId=null, $agentId=null, $highlightId=null)
fo_dbManager * dbManager
fo_dbManager object