Changeset 387

Show
Ignore:
Timestamp:
03/31/09 15:44:01 (9 years ago)
Author:
samuraraujo
Message:
 
Files:
1 modified

Legend:

Unmodified
Added
Removed
  • Explorator/trunk/vendor/plugins/active_rdf/lib/active_rdf/federation/connection_pool.rb

    r321 r387  
    1616  # pool of all adapters 
    1717  @@adapter_pool = Array.new 
     18   
     19  @@void = Hash.new 
    1820   
    1921  # pool of connection parameters to all adapter 
     
    3638    @@adapter_pool = [] 
    3739    @@adapter_parameters = [] 
     40    @@void=Hash.new 
    3841    self.write_adapter = nil 
    3942  end 
    40    
     43   def ConnectionPool.void 
     44   @@void 
     45  end 
    4146  def ConnectionPool.adapters 
    4247    @@adapter_pool.dup 
     
    8994    self.write_adapter = adapter if adapter.writes? 
    9095     
     96    void_source =  adapter.query(Query.new.select(:o).where(:s,RDFS::Resource.new('<http://xmlns.com/foaf/0.1/homepage>') ,:o).where(:s,RDF::type,RDFS::Resource.new('<http://rdfs.org/ns/void#Dataset>'))).uniq 
     97    @@void[void_source.to_s.gsub(/>/,'').gsub(/</,'')]=adapter if void_source != nil 
    9198    return adapter 
    9299  end 
     
    132139    alias add add_data_source 
    133140  end 
    134    
     141  #find an sparql adapter by its uri 
     142  def ConnectionPool.find_by_uri(uri) 
     143  
     144    @@adapter_pool.each {|x| 
     145     if x.instance_of? SparqlAdapter 
     146  
     147       if x.url == uri 
     148         return x 
     149       end 
     150     end 
     151    } 
     152    return nil 
     153    
     154  end 
    135155  # adapter-types can register themselves with connection pool by 
    136156  # indicating which adapter-type they are