41 function __construct(
DbManager $dbManager)
44 $this->logger =
new Logger(self::class);
46 $this->typeMap = array(
47 'M' => Highlight::MATCH,
48 'M ' => Highlight::MATCH,
49 'M0' => Highlight::MATCH,
50 'M+' => Highlight::ADDED,
51 'M-' => Highlight::DELETED,
52 'MR' => Highlight::CHANGED,
53 'L' => Highlight::SIGNATURE,
54 'L ' => Highlight::SIGNATURE,
55 'K' => Highlight::KEYWORD,
56 'K ' => Highlight::KEYWORD,
69 $params =array($itemTreeBounds->
getItemId());
72 $sql =
"SELECT start,len,type,rf_fk,rf_start,rf_len 74 INNER JOIN highlight ON license_file.fl_pk = highlight.fl_fk 75 INNER JOIN $uploadTreeTableName ut ON ut.pfile_fk = license_file.pfile_fk 76 WHERE uploadtree_pk = $1 AND (type LIKE 'M_' OR type = 'L')";
78 $stmt = __METHOD__.$uploadTreeTableName;
79 if (!empty($licenseId) && empty($highlightId)) {
80 $params[] = $licenseId;
82 $sql .=
" AND license_file.rf_fk=$" . count($params);
84 if (!empty($agentId) && is_array($agentId)) {
85 $params[] =
'{' . implode(
',', $agentId) .
'}';
87 $sql .=
" AND license_file.agent_fk=ANY($" . count($params).
")";
88 }
else if (!empty($agentId)) {
91 $sql .=
" AND license_file.agent_fk=$" . count($params);
94 if (!empty($highlightId)) {
95 $params[] = $highlightId;
96 $stmt .=
'.Highlight';
97 $sql .=
" AND fl_pk=$" . count($params);
100 $result = $this->
dbManager->execute($stmt, $params);
101 $highlightEntries = array();
102 while ($row = $this->
dbManager->fetchArray($result)) {
104 intval($row[
'start']), intval($row[
'start'] + $row[
'len']),
105 $this->typeMap[$row[
'type']],
106 intval($row[
'rf_start']), intval($row[
'rf_start'] + $row[
'rf_len']));
108 $licenseId = $row[
'rf_fk'];
110 $newHiglight->setLicenseId($licenseId);
112 $highlightEntries[] = $newHiglight;
115 return $highlightEntries;
118 public function getHighlightRegion($licenseMatchId)
121 "SELECT MIN(start) AS start, MAX(start+len) AS end FROM highlight WHERE fl_fk = $1",
122 array($licenseMatchId)
124 return false !== $row ? array($row[
'start'], $row[
'end']) : array(-1, -1);
134 $stmt = __METHOD__.$uploadTreeTableName;
135 $sql =
"SELECT start,len 136 FROM highlight_keyword AS hk 137 INNER JOIN $uploadTreeTableName AS ut 138 ON hk.pfile_fk = ut.pfile_fk 139 WHERE ut.uploadtree_pk = $1";
142 $highlightEntries = array();
143 while ($row = $this->
dbManager->fetchArray($result)) {
145 intval($row[
'start']), intval($row[
'start'] + $row[
'len']),
146 Highlight::KEYWORD, 0, 0);
149 return $highlightEntries;
160 $sql =
"SELECT h.clearing_event_fk, h.start, h.len, ce.rf_fk, rf_text 161 FROM clearing_event ce 162 INNER JOIN highlight_bulk h ON ce.clearing_event_pk = h.clearing_event_fk 163 INNER JOIN license_ref_bulk lrb ON lrb.lrb_pk = h.lrb_fk 164 WHERE ce.uploadtree_fk = $1";
165 $params = array($uploadTreeId);
166 if (!empty($clearingId)) {
167 $stmt .=
".clearingId";
168 $params[] = $clearingId;
169 $sql .=
" AND h.clearing_event_fk = $" . count($params);
172 $result = $this->
dbManager->execute($stmt, $params);
173 $highlightEntries = array();
174 while ($row = $this->
dbManager->fetchArray($result)) {
176 intval($row[
'start']), intval($row[
'start'] + $row[
'len']),
177 Highlight::BULK, 0, 0);
178 $newHighlight->setLicenseId($row[
'rf_fk']);
179 $highlightEntries[] = $newHighlight;
182 return $highlightEntries;
195 $highlightDiffs = $this->
getHighlightDiffs($itemTreeBounds, $licenseId, $agentId, $highlightId);
198 $highlightEntries = array_merge(array_merge($highlightDiffs,$highlightKeywords),$highlightBulk);
199 return $highlightEntries;
211 SELECT start FROM highlight WHERE fl_fk=$1 ORDER BY start ASC LIMIT 1 213 SELECT conf_value FROM sysconfig WHERE variablename LIKE 'BlockSizeText' 217 array($licenseMatchId)
getHighlightEntries(ItemTreeBounds $itemTreeBounds, $licenseId=null, $agentId=null, $highlightId=null, $clearingId=null)
getHighlightKeywords(ItemTreeBounds $itemTreeBounds)
fo_dbManager * dbManager
fo_dbManager object
getHighlightBulk($uploadTreeId, $clearingId=null)
getPageNumberOfHighlightEntry($licenseMatchId)
getHighlightDiffs(ItemTreeBounds $itemTreeBounds, $licenseId=null, $agentId=null, $highlightId=null)