Changes for page Intersection table of ML Elements with glossary terms
Last modified by Artur K. on 2026/06/01 15:50
Summary
-
Page properties (1 modified, 0 added, 0 removed)
Details
- Page properties
-
- Content
-
... ... @@ -1,7 +1,8 @@ 1 -{{velocity output="false"}}1 +{{velocity}} 2 2 #set($rootDocFullName = $doc.getParent()) 3 3 #set($rootDoc = $xwiki.getDocument($rootDocFullName)) 4 4 #set($fullNamePrefix = "${rootDoc.space}.%") 5 + 5 5 ## ---------------------------- 6 6 ## 1. Получаем Ontology Elements 7 7 ## ---------------------------- ... ... @@ -15,7 +15,12 @@ 15 15 and doc.fullName <> :rootDocFullName 16 16 and doc.fullName like :fullNamePrefix 17 17 order by doc.fullName") 18 -#set($elementRows = $services.query.hql($hqlElements).bindValue('rootDocFullName', $rootDocFullName).bindValue('fullNamePrefix', $fullNamePrefix).execute()) 19 + 20 +#set($elementQuery = $services.query.hql($hqlElements)) 21 +#set($discard = $elementQuery.bindValue('rootDocFullName', $rootDocFullName)) 22 +#set($discard = $elementQuery.bindValue('fullNamePrefix', $fullNamePrefix)) 23 +#set($elementRows = $elementQuery.execute()) 24 + 19 19 ## --------------------------- 20 20 ## 2. Получаем термины глоссария 21 21 ## ---------------------------- ... ... @@ -29,16 +29,18 @@ 29 29 order by doc.fullName") 30 30 31 31 #set($glossaryRows = $services.query.hql($hqlGlossary).execute()) 38 + 32 32 ## --------------------------- 33 33 ## 3. Строим map глоссария по нормализованному title 34 34 ## ---------------------------- 35 35 #set($glossaryMap = {}) 43 + 36 36 #foreach($row in $glossaryRows) 37 37 #set($glossaryFullName = $row[0]) 38 38 #set($glossaryTitle = "$!row[1]") 39 39 40 40 #if("$!glossaryTitle" != "") 41 - #set($normalizedGlossaryTitle = $stringtool.lowerCase($glossaryTitle).replaceAll("\s+", "")) 49 + #set($normalizedGlossaryTitle = $stringtool.lowerCase($glossaryTitle).replaceAll("\\s+", "")) 42 42 43 43 #if("$!normalizedGlossaryTitle" != "") 44 44 #set($discard = $glossaryMap.put($normalizedGlossaryTitle, { ... ... @@ -48,11 +48,12 @@ 48 48 #end 49 49 #end 50 50 #end 59 + 51 51 ## ---------------------------- 52 -## 4. Ищем совпадения 61 +## 4. Ищем совпадения и записываем rdfs.seeAlso 53 53 ## ---------------------------- 54 54 #set($matches = []) 55 -#set($ totalCount =$elementRows.size())64 +#set($updatedCount = 0) 56 56 57 57 #foreach($row in $elementRows) 58 58 #set($elementFullName = $row[0]) ... ... @@ -59,11 +59,22 @@ 59 59 #set($elementTitle = "$!row[1]") 60 60 61 61 #if("$!elementTitle" != "") 62 - #set($normalizedElementTitle = $stringtool.lowerCase($elementTitle).replaceAll("\s+", "")) 71 + #set($normalizedElementTitle = $stringtool.lowerCase($elementTitle).replaceAll("\\s+", "")) 63 63 64 64 #if($glossaryMap.containsKey($normalizedElementTitle)) 65 65 #set($glossaryData = $glossaryMap.get($normalizedElementTitle)) 66 66 76 + #set($rdoc = $xwiki.getDocument($elementFullName)) 77 + #set($elementObj = $rdoc.getObject('SKMS.Ontology.Code.OntologyElementClass')) 78 + 79 + #set($seeAlsoValue = []) 80 + #set($discard = $seeAlsoValue.add($glossaryData.fullName)) 81 + 82 + #set($discard = $elementObj.set('rdfs.seeAlso', $seeAlsoValue)) 83 + #set($discard = $rdoc.save()) 84 + 85 + #set($updatedCount = $updatedCount + 1) 86 + 67 67 #set($matchRow = { 68 68 "elementFullName" : $elementFullName, 69 69 "elementTitle" : $elementTitle, ... ... @@ -75,25 +75,21 @@ 75 75 #end 76 76 #end 77 77 #end 78 - {{/velocity}}{{velocity output="true"}}98 + 79 79 ## --------------------------- 80 -## 5. Выводим та блицу совпадений100 +## 5. Выводим результат 81 81 ## ---------------------------- 82 82 {{html clean="false" wiki="true"}} 103 +<p><strong>Updated:</strong> $updatedCount</p> 104 + 83 83 <table class="wikitable" border="1"> 84 84 <thead> 85 85 <tr> 86 - <th> MLelements</th>87 - <th> Glossaryterms</th>108 + <th>Ontology elements</th> 109 + <th>Written to rdfs.seeAlso</th> 88 88 </tr> 89 89 </thead> 90 90 <tbody> 91 - <tr> 92 - <th colspan="2" style="text-align: center;"> 93 - Matches ($matches.size() of $totalCount) 94 - </th> 95 - </tr> 96 - 97 97 #if($matches.size() > 0) 98 98 #foreach($match in $matches) 99 99 <tr>