-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from UKGovLD/coherence-matching
Coherence matching
- Loading branch information
Showing
7 changed files
with
255 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
#* | ||
$response | The Response instance to be rendered. The response entity is a Jena model. | ||
$newItems | The RDF Nodes corresponding to the register items that were inferred from the request. | ||
*# | ||
|
||
#set($root=$registry.rootPath) | ||
#set($uiroot="$root/ui") | ||
#set($assets="$uiroot/assets") | ||
|
||
#macro( resultRowValues $item ) | ||
#set( $itemEntity = $item.getPropertyValue("reg:definition").getPropertyValue("reg:entity") ) | ||
<td> | ||
<a href="#linkhref($item)" title="$lib.reg.xssCleanURI($item.uRI)" target="_blank">$item.name</a> | ||
</td> | ||
<td> | ||
#set( $registerPath = $item.getPropertyValue("reg:register").uRI.substring($registry.baseURI.length()) ) | ||
#set( $registerUri = "$root$registerPath" ) | ||
<a href="$lib.reg.xssCleanURI($registerUri)" title="$lib.reg.xssCleanURI($registerUri)" target="_blank">$registerPath</a> | ||
</td> | ||
<td> | ||
#foreach($ty in $itemEntity.listPropertyValues("rdf:type")) | ||
#linkfor($ty)#if( $foreach.hasNext ), #end | ||
#end | ||
</td> | ||
<td>#showstatus($item.getPropertyValue("reg:status"))</td> | ||
#end | ||
|
||
#macro( resultRow $newItemW $property $isMulti ) | ||
#set( $items = $newItemW.listPropertyValues($property) ) | ||
#set( $firstItem = true ) | ||
|
||
#foreach( $item in $items ) | ||
<tr> | ||
#set( $newEntity = $newItemW.getPropertyValue("reg:definition").getPropertyValue("reg:entity") ) | ||
#if( $firstItem && $isMulti )<td rowspan="$items.size()">$lib.reg.xssCleanURI($newEntity.uRI)</td>#end | ||
#resultRowValues($item) | ||
</tr> | ||
|
||
#set( $firstItem = false ) | ||
#end | ||
#end | ||
|
||
#macro( resultTable $modelW $newItems $property ) | ||
#set( $isMulti = $newItems.size() > 1 ) | ||
|
||
<table class="table table-striped table-bordered" style="color: black; background-color: white;"> | ||
<thead> | ||
<tr> | ||
#if( $isMulti )<th>New</th>#end | ||
<th>Suggested</th> | ||
<th>Register</th> | ||
<th>Types</th> | ||
<th>Status</th> | ||
</tr> | ||
</thead> | ||
|
||
<tbody> | ||
#foreach( $newItem in $newItems ) | ||
#set( $newItemW = $modelW.getNode($newItem.uRI) ) | ||
#resultRow( $newItemW, $property, $isMulti ) | ||
#end | ||
</tbody> | ||
</table> | ||
#end | ||
|
||
<div> | ||
#set( $model = $response.entity ) | ||
#set( $modelW = $lib.reg.wrapModel($response.entity) ) | ||
#set( $isExactMatch = $modelW.queryAsk("ASK { ?result a reg:CompareResult; rdfs:member/skos:exactMatch ?item }") ) | ||
#set( $isCloseMatch = $modelW.queryAsk("ASK { ?result a reg:CompareResult; rdfs:member/skos:closeMatch ?item }") ) | ||
|
||
#if( $isExactMatch || $isCloseMatch ) | ||
#if( $isExactMatch ) | ||
<div class='alert alert-warning'> | ||
<button type='button' class='close' data-dismiss='alert'>×</button> | ||
<span>One or more entries exist with the same label or identifier:</span> | ||
|
||
#resultTable( $modelW, $newItems, "skos:exactMatch" ) | ||
</div> | ||
#end | ||
|
||
#if( $isCloseMatch ) | ||
<div class='alert alert-warning'> | ||
<button type='button' class='close' data-dismiss='alert'>×</button> | ||
<span>One or more entries exist with a similar label:</span> | ||
|
||
#resultTable( $modelW, $newItems, "skos:closeMatch" ) | ||
</div> | ||
#end | ||
#else | ||
<div class='alert'> | ||
<button type='button' class='close' data-dismiss='alert'>×</button> | ||
<span>No similar entries were found.</span> | ||
</div> | ||
#end | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/** | ||
* This function provides a simplified interface for invoking the registry comparison feature for a single entity, | ||
* and rendering the results as HTML within a containing document. | ||
* @param {Object} opts The block of parameters. | ||
* @param {Object} opts.selector The block of CSS selectors which determine the input data and output display. All selectors are required. | ||
* @param {String} opts.selector.target The selector for the element to output the results of the comparison. | ||
* @param {String} opts.selector.error The selector for the element to output error messages if the comparison fails. | ||
* @param {String} opts.selector.button The selector for the button element which triggers the comparison. | ||
* @param {String} opts.selector.form The selector for the form element which contains the data to be compared. | ||
* @param {Object} opts.data The block of modifiers which alter the data submitted to the API. Optional. | ||
* @param {Function} opts.data.apply A function which modifies the supplied set of key-value pairs which will be added to the form data. | ||
* @param {Function} opts.data.isEdit A function which determines whether the submitted data contains edits to existing registry items. | ||
*/ | ||
var registryCompare = function(opts) { | ||
var renderError = function(msg) { | ||
$(opts.selector.error).html("<div class='alert alert-warning'> <button type='button' class='close' data-dismiss='alert'>×</button>" + msg + "</div>"); | ||
}; | ||
|
||
var onError = function(xhr, status, error) { | ||
renderError("Action failed: " + error + " - " + xhr.responseText); | ||
}; | ||
|
||
$(opts.selector.button).click(function(event) { | ||
var form = $(opts.selector.form); | ||
var target = form.attr('action') + "?compare"; | ||
var data = { | ||
action: "compare" | ||
}; | ||
|
||
if (opts.data) { | ||
if (opts.data.apply) { | ||
opts.data.apply(data); | ||
} | ||
|
||
if (opts.data.isEdit && opts.data.isEdit()) { | ||
target += "&compare-edit" | ||
} | ||
} | ||
|
||
form.ajaxSubmit({ | ||
type: "post", | ||
url: target, | ||
headers: { | ||
"Accept": "text/html" | ||
}, | ||
target: opts.selector.target, | ||
data: data, | ||
error: onError | ||
}); | ||
}); | ||
}; |