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