Version 2.1 by Artur K. on 2026/05/25 16:43

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