@@ -68,6 +68,7 @@ QueryBuilder = {
6868 query += SPARQL . prefix . rdfs ;
6969 query += "SELECT ?concept ?label WHERE \n{ ?concept rdf:type <" + $ ( "#hdn_qb_class" ) . val ( ) + ">.\n ?concept rdfs:label ?label.\n" ;
7070 query += QueryBuilder . properties . get_subclasses_triples ( ) ;
71+ query += QueryBuilder . properties . get_properties_triples ( ) ;
7172 query += "FILTER(langMatches(lang(?label), \"EN\"))}\n LIMIT 200" ;
7273 $ ( "#txt_sparql_query" ) . val ( query ) ;
7374 }
@@ -222,6 +223,23 @@ QueryBuilder = {
222223
223224 return result ;
224225 } ,
226+ get_properties_triples : function ( ) {
227+ var result = "" ;
228+ $ ( "#qb_properties_properties_selected_filters_list" ) . find ( ".list-item" ) . each ( function ( index ) {
229+ if ( $ ( this ) . attr ( "filter-type" ) == 'object' ) {
230+ var objects = $ ( this ) . attr ( "filter-value" ) . split ( "," ) ;
231+ var property_uri = $ ( this ) . attr ( "property-uri" ) ;
232+ result += "{" ;
233+ for ( var i = 0 ; i < objects . length ; i ++ ) {
234+ if ( i > 0 )
235+ result += " UNION " ;
236+ result += "?concept <" + property_uri + "> <" + objects [ i ] + ">" ;
237+ }
238+ result += "}.\n"
239+ }
240+ } ) ;
241+ return result ;
242+ } ,
225243 select_subclass : function ( uri ) {
226244
227245 $ ( "#property_main_subclasses_group" ) . find ( ".list-group-item" ) . each ( function ( index ) {
@@ -275,13 +293,14 @@ QueryBuilder = {
275293 uris += data [ i ] . uri ;
276294 names += "'" + data [ i ] . name + "'" ;
277295 }
278- var div_html = "<div id='qb_properties_properties_selected_filters_list_item_" + identifier + "' class=\"alert alert-warning list-item\" property-uri=\"" + property_uri + "\" filter-value=\"" + uris + "\" identifier=\"" + identifier + "\">" ;
296+ var div_html = "<div id='qb_properties_properties_selected_filters_list_item_" + identifier + "' class=\"alert alert-warning list-item\" property-uri=\"" + property_uri + "\" filter-value=\"" + uris + "\" identifier=\"" + identifier + "\" filter-type='object' >" ;
279297 div_html += "<div class='row'><div class='col-md-10'>" ;
280298 div_html += "<strong>" + property_name + "</strong> " + names ;
281299 div_html += "</div>" ;
282300 div_html += "<div class='col-md-2'><span class=\"glyphicon glyphicon-remove clickable pull-right\" onclick=\"QueryBuilder.properties.filter.remove('" + identifier + "')\"></span></div>"
283301 div_html += "</div></div>" ;
284302 $ ( "#qb_properties_properties_selected_filters_list" ) . append ( div_html ) ;
303+ QueryBuilder . generate_equivalent_sparql_query ( ) ;
285304 Utils . flash . success ( "Added objects " + names + " to filter for " + property_name ) ;
286305 } ,
287306 //removes the filter
@@ -294,6 +313,7 @@ QueryBuilder = {
294313 $ ( "#qb_properties_properties_selected_filters_header" ) . hide ( "fast" ) ;
295314 $ ( "#qb_properties_properties_selected_filters_list" ) . hide ( "fast" ) ;
296315 }
316+ QueryBuilder . generate_equivalent_sparql_query ( ) ;
297317 } , 500 ) ;
298318 } ,
299319 get_new_list_identifier : function ( ) {
0 commit comments