Version 1.5 by Artur K. on 2026/05/25 16:42

Hide last authors
Artur K. 1.1 1 {{velocity}}
2 #set($rootDocFullName = $doc.getParent())
3 #set($rootDoc = $xwiki.getDocument($rootDocFullName))
4 #set($fullNamePrefix = "${rootDoc.space}.%")
5
6 ## ----------------------------
7 ## 1. Получаем Ontology Elements
8 ## ----------------------------
9 #set($hqlElements = "select distinct
10 doc.fullName,
11 doc.title
12 from XWikiDocument as doc,
13 BaseObject as obj
14 where doc.fullName = obj.name
15 and obj.className = 'SKMS.Ontology.Code.OntologyElementClass'
16 and doc.fullName <> :rootDocFullName
17 and doc.fullName like :fullNamePrefix
18 order by doc.fullName")
19
Artur K. 1.5 20 #set($elementRows = $services.query.hql($hqlElements).bindValue('rootDocFullName', $rootDocFullName).bindValue('fullNamePrefix', $fullNamePrefix).execute())
Artur K. 1.1 21
22 ## ---------------------------
23 ## 2. Получаем термины глоссария
24 ## ----------------------------
25 #set($hqlGlossary = "select distinct
26 doc.fullName,
27 doc.title
28 from XWikiDocument as doc,
29 BaseObject as obj
30 where doc.fullName = obj.name
31 and obj.className = 'SKMS.Glossary.Code.GlossaryConceptClass'
32 order by doc.fullName")
33
34 #set($glossaryRows = $services.query.hql($hqlGlossary).execute())
35
36 ## ---------------------------
37 ## 3. Строим map глоссария по нормализованному title
38 ## ----------------------------
39 #set($glossaryMap = {})
40
41 #foreach($row in $glossaryRows)
42 #set($glossaryFullName = $row[0])
43 #set($glossaryTitle = "$!row[1]")
44
45 #if("$!glossaryTitle" != "")
Artur K. 1.3 46 #set($normalizedGlossaryTitle = $stringtool.lowerCase($glossaryTitle).replaceAll("\s+", ""))
Artur K. 1.1 47
48 #if("$!normalizedGlossaryTitle" != "")
49 #set($discard = $glossaryMap.put($normalizedGlossaryTitle, {
50 "fullName" : $glossaryFullName,
51 "title" : $glossaryTitle
52 }))
53 #end
54 #end
55 #end
56
57 ## ----------------------------
58 ## 4. Ищем совпадения
59 ## ----------------------------
60 #set($matches = [])
61 #set($totalCount = $elementRows.size())
62
63 #foreach($row in $elementRows)
64 #set($elementFullName = $row[0])
65 #set($elementTitle = "$!row[1]")
66
67 #if("$!elementTitle" != "")
Artur K. 1.2 68 #set($normalizedElementTitle = $stringtool.lowerCase($elementTitle).replaceAll("\s+", ""))
Artur K. 1.1 69
70 #if($glossaryMap.containsKey($normalizedElementTitle))
71 #set($glossaryData = $glossaryMap.get($normalizedElementTitle))
72
73 #set($matchRow = {
74 "elementFullName" : $elementFullName,
75 "elementTitle" : $elementTitle,
76 "glossaryFullName" : $glossaryData.fullName,
77 "glossaryTitle" : $glossaryData.title
78 })
79
80 #set($discard = $matches.add($matchRow))
81 #end
82 #end
83 #end
84
85 ## ---------------------------
86 ## 5. Выводим таблицу совпадений
87 ## ----------------------------
88 {{html clean="false" wiki="true"}}
89 <table class="wikitable" border="1">
90 <thead>
91 <tr>
92 <th>Ontology elements</th>
93 <th>Glossary terms</th>
94 </tr>
95 </thead>
96 <tbody>
97 <tr>
98 <th colspan="2" style="text-align: center;">
99 Matches ($matches.size() of $totalCount)
100 </th>
101 </tr>
102
103 #if($matches.size() > 0)
104 #foreach($match in $matches)
105 <tr>
106 <td>[[${match.elementTitle}>>${match.elementFullName}||target="_blank"]]</td>
107 <td>[[${match.glossaryTitle}>>${match.glossaryFullName}||target="_blank"]]</td>
108 </tr>
109 #end
110 #else
111 <tr>
112 <td colspan="2">No matches found.</td>
113 </tr>
114 #end
115 </tbody>
116 </table>
117 {{/html}}
118 {{/velocity}}
© Semantic R&D Group, 2026