Changeset 29445


Ignore:
Timestamp:
11/17/14 16:44:35 (6 years ago)
Author:
sjs49
Message:

Tidied comparison code and improved comments a little. Changed some function names to be more descriptive.

Location:
main/trunk/model-sites-dev/von-sparql/js
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/model-sites-dev/von-sparql/js/von-sparql-comparison-script.js

    r28914 r29445  
     1// Von-Sparql Collection Comparison Script
     2//
     3// Contains script to build queries to compare contents of
     4// one collection with another.
     5
     6
     7//Builds a single-collection query from inputs
    18function generateQuery(side,dataset){
    29    var predicate = $('#sel_' + side + 'Predicate').val(); 
     
    3138}
    3239
     40//Builds a query comparing data selected from two collections
    3341function generateComparisonQuery(){
    3442
     
    3846
    3947    //Start generating query
    40         var sparqlQuery = "";
     48    var sparqlQuery = "";
    4149    var sparqlQueryHeader = "";
    42     ///////INTERSECTION///////
     50
     51    //If query type is an intersection of the collection data
    4352    if(query.type=="intersection"){
    4453        sparqlQueryHeader   +=  "SELECT DISTINCT ?common ";
     
    5160            sparqlQuery     +=  "   ?s <" + query.pred_L + "> "// ?common;";
    5261           
    53         sparqlQuery += generateFilter("left", comparisonMethod);
     62        sparqlQuery += setComparisonMethod("left", comparisonMethod);
    5463
    5564        if(!$('#cb_showOnlyCommonObjects').is(':checked')){
     
    7988            sparqlQuery     +=  "   ?s1 <" + query.pred_R + "> "// ?common;" ;
    8089
    81         sparqlQuery += generateFilter("right", comparisonMethod);
     90        sparqlQuery += setComparisonMethod("right", comparisonMethod);
    8291
    8392        if(!$('#cb_showOnlyCommonObjects').is(':checked')){
     
    106115   
    107116
    108     //////MINUS/////
     117    //If query is for data that is in one collection, but not the other (MINUS)
    109118    if(query.type=="minus"){
    110119        sparqlQueryHeader   +=  "SELECT DISTINCT ?minus " ;
     
    140149        sparqlQuery         +=  "} ";
    141150        sparqlQuery         +=  "MINUS{"
    142                             +   "GRAPH gsdl:" + leftCollection + "{" ;
     151                        +   "GRAPH gsdl:" + leftCollection + "{" ;
     152   
    143153        if(query.refine_L!="")
    144154            sparqlQuery     +=  "   ?s <" + query.pred_L + "> \"" + query.predval_L + "\";" 
     
    147157            sparqlQuery     +=  "   ?s <" + query.pred_L + "> ";
    148158
    149         sparqlQuery += generateFilter("left", comparisonMethod)
     159        sparqlQuery += setComparisonMethod("left", comparisonMethod)
    150160        sparqlQuery         +=  "}" 
    151161                            +   "GRAPH gsdl:" + rightCollection +"{";
     
    156166            sparqlQuery     +=  "   ?s1 <" + query.pred_R + "> " ;
    157167
    158         sparqlQuery += generateFilter("right", comparisonMethod)
     168        sparqlQuery += setComparisonMethod("right", comparisonMethod)
    159169        sparqlQuery         +=  "}" 
    160170                            +   "}}";
     
    163173    sparqlQuery += "LIMIT " + $('#sel_comparisonLimit').val() + " ";
    164174    sparqlQuery += "OFFSET " + ((query.page-1) * $('#sel_comparisonLimit').val());
    165     console.log(sparqlQuery);
    166175    return sparqlQuery;
    167176}
    168177
    169 function generateFilter(side, comparisonMethod){
     178//Used when substrings of returned values are used for comparison
     179//i.e. when numbers are extracted from DATE triples for plotting in a line graph, etc"
     180function setComparisonMethod(side, comparisonMethod){
    170181    var query = "";
    171182    var tempVar;
     
    209220
    210221
    211 
     222//Updates the "value" selector with possible values
    212223function updateValueSelector(predicate, selector, collectionName){
    213224    var refineDataset = "GRAPH gsdl:" + collectionName + " {\n";
     
    255266}
    256267
     268//Updates the selector which contains available predicates after
     269//previously restricting a predicate to a certain value
    257270function updateVisualizePredicateSelector(predicate,value,selector,collection){
    258271    var sparqlQuery;
     
    295308}
    296309
    297 function drawFilteredDataset(side, collection){
     310function drawCollectionChart(side, collection){
    298311    var Q = new sgvizler.Query();
    299312    Q.query(generateQuery(side, collection))
     
    316329    sgvizler.defaultChartWidth(defaultChartWidth);
    317330    sgvizler.defaultChartHeight(defaultChartHeight);
    318 
    319 /*  var ajaxSparqlQuery = sparqlEndpoint + "?query=" + encodeURIComponent(generateComparisonQuery());
    320 
    321     $('#table_combinedResults').jqGrid({
    322         url: ajaxSparqlQuery,
    323         datatype: "spreadsheet",
    324         colNames: ['Common'],
    325         colModel: [{name: 'common',
    326                     index: 'results.bindings.common',
    327                     width: '300'}],
    328         rowNum: 10,
    329         rowList: [10,20,30],
    330         pager: '#table_combinedResultsPager',
    331 //      sortname: 'common',
    332         viewrecords: true,
    333         sortorder: 'desc',
    334         caption: 'Results table'
    335     });
    336     $('#table_combinedResults').jqGrid('navGrid','#div_combinedResultsPager',{edit:false, add:false, del:false});
    337 
    338 */ 
    339331}
    340332
     
    346338    return name;
    347339}
     340
    348341//Fills the predicate selector with values
    349342function populatePredicateSelector(collection, selector){
     
    398391
    399392function setCursor(style){
    400     console.log("Cursor: " + style);
    401393    document.body.style.cursor = style;
    402394}
  • main/trunk/model-sites-dev/von-sparql/js/von-sparql-comparison-setup.js

    r29444 r29445  
    202202        hardLimit=2000;
    203203        var collectionValue = $("#sel_" + side + "Collection").val();
    204         drawFilteredDataset(side, collectionValue);
     204        drawCollectionChart(side, collectionValue);
    205205    });
    206206
     
    232232        if($('#cb_quickSearch').is(':checked')) {   
    233233            hardLimit=500;
    234             drawFilteredDataset(side, collectionValue);
     234            drawCollectionChart(side, collectionValue);
    235235        }
    236236       
     
    255255
    256256// When a predicate is clicked on one side, makes the same predicate on
    257 // the opposite side bold, to stand out
     257// the opposite side bold to suggest to user.
    258258function showSimilarPredicates(side,clickedText){
    259259    var oppositeSide;
Note: See TracChangeset for help on using the changeset viewer.