Changeset 192

Show
Ignore:
Timestamp:
12/08/08 14:35:24 (10 years ago)
Author:
samuraraujo
Message:
 
Location:
Explorator/trunk/app/controllers
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • Explorator/trunk/app/controllers/application.rb

    r181 r192  
    1414      session[:disablerepositories]=Array.new 
    1515      session[:disablerepositories] << 'Explorator' 
    16       session[:disablerepositories] << 'NOKIA_SPARQL'       
     16      session[:disablerepositories] << 'NOKIA_DEFAULT'      
     17      session[:addrepositories] = Array.new 
    1718      session[:application] =  Application.new(session.session_id) 
    1819    end 
  • Explorator/trunk/app/controllers/repository_controller.rb

    r183 r192  
    1414    adapters.each do |repository| 
    1515      #create a model repository passing the repository's id, title and enableness  
    16       if repository.title!= 'Explorator' 
    17         @repositories <<  Repository.new(repository.object_id,repository.title, session[:disablerepositories].include?(repository.title)) 
     16      if repository.title!= 'Explorator' && (repository.title.index('_DEFAULT') || session[:addrepositories].include?(repository)) 
     17        @repositories <<  Repository.new(repository.object_id,repository.title, session[:disablerepositories].include?(repository.title),repository.limit) 
    1818      end 
    1919    end        
    2020    render :layout => false 
    2121  end 
    22    
     22  def limit 
     23    adapters = ConnectionPool.adapters() 
     24    adapters.each do |repository| 
     25      #create a model repository passing the repository's id, title and enableness  
     26      if repository.title == params[:title] 
     27          repository.limit=params[:limit] 
     28      end 
     29    end        
     30    render :text => '',:layout => false 
     31  end 
    2332  #The disable method disable a adapter. 
    2433  #disable a specific adapter in the ConnectionPool. 
     
    2837   # Repository.disable_by_title(params[:title]) 
    2938    #render nothing. 
    30     render :text => '',:layout => false 
    31      
     39    render :text => '',:layout => false     
    3240  end 
    3341  #The enable method enable a adapter. 
     
    4048  end 
    4149  def add 
    42     adapter =ConnectionPool.add_data_source :type => :sparql,:engine => :sesame2, :url => params[:uri], :results => :sparql_xml, :caching =>true 
     50    if params[:title]==nil || params[:title]  == '' 
     51      render :text => 'O título do sparql endpoint é obrigatório.',:layout => false       
     52      return 
     53    end 
     54    adapter = ConnectionPool.add_data_source :type => :sparql,:engine => :sesame2, :url => params[:uri], :results => :sparql_xml, :caching =>true 
    4355    adapter.title=params[:title]     
     56    adapter.limit=params[:limit]  if params[:limit] != nil    
     57    session[:addrepositories]<<adapter 
     58    session[:disablerepositories] << (params[:title])  
     59    session[:disablerepositories].uniq! 
    4460    RDFS::Resource.find_all_predicates     
    4561    # construct the necessary Ruby Modules and Classes to use the Namespace 
    4662    ObjectManager.construct_classes 
    47    # enable(params[:title]) 
    48      
     63   # enable(params[:title])     
    4964    render :text => 'SparqlEndpoint Added!',:layout => false 
    5065  end