Changeset 315

Show
Ignore:
Timestamp:
03/02/09 12:15:29 (10 years ago)
Author:
samuraraujo
Message:
 
Location:
Explorator/trunk/app/controllers
Files:
1 added
2 modified

Legend:

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

    r273 r315  
    1616  #default rails method. returns the view index.rhtml. 
    1717  def index      
    18   
    19 end 
    20   
    21 def resourcefilter 
    22    @resourceset =  Application.get(params[:uri])   
    23    render  :partial => 'subject_view',:layout=>false; 
    24 end  
    25 #change the set name 
    26 def editSetName 
     18     
     19  end 
     20   
     21  def resourcefilter 
     22    @resourceset =  Application.get(params[:uri])   
     23    render  :partial => 'subject_view',:layout=>false; 
     24  end  
     25  #change the set name 
     26  def editSetName 
    2727    set = session[:application].get(params[:uri]) 
    2828    set.explorator::name=params[:value] 
    2929    render :text => params[:value], :layout=>false 
    30 end 
     30  end 
    3131  #  prints the filter screen 
    3232  def filter     
     
    4040  #/explorator/create?exp=SemanticExpression.new.union(:s,Namespace.lookup(:rdf,:type),Namespace.lookup(:rdfs,:Class)) 
    4141  def create     
    42       
    43     puts params[:exp] 
    44     #creates a new set.  
    45     #the expression must be passed by the uri 
    46     set = EXPLORATOR::Set.new('http://www.tecweb.inf.puc-rio.br/resourceset/id/' + UUID.random_create.to_s)        
    47     set.init(params[:exp]) 
    48  
    49     #the object @resourceset is a global object that will be used by render 
    50     @resourceset = set      
    51     
    52     view = params['view'] 
    53     view = 'subject_view' if  params['view'] == nil || params['view'] == 'null' 
    54     #render the _window.rhtml view 
    55     render :partial => view,:layout=>false; 
     42    begin       
     43      puts params[:exp] 
     44      #creates a new set.  
     45      #the expression must be passed by the uri 
     46      set = EXPLORATOR::Set.new('http://www.tecweb.inf.puc-rio.br/resourceset/id/' + UUID.random_create.to_s)        
     47       
     48      set.init(params[:exp]) 
     49       
     50      #the object @resourceset is a global object that will be used by render 
     51      @resourceset = set      
     52       
     53      view = params['view'] 
     54      view = 'subject_view' if  params['view'] == nil || params['view'] == 'null' 
     55      #render the _window.rhtml view 
     56      render :partial => view,:layout=>false; 
     57       
     58    rescue Exception => e 
     59 puts e.backtrace 
     60        redirect_to :controller => 'message',:action => 'error',:message => e.message ,:layout => false 
     61    end 
    5662  end 
    5763  # The  update method updates a specfic ResourceSet instance identified by the parameter id. 
     
    6066  # must has been defined before. 
    6167  def update      
    62        puts params[:exp] 
     68    puts params[:exp] 
    6369    #reevaluate the expression and return the set 
    6470    resource = session[:application].get(params[:uri]) 
    65    
     71     
    6672    resource.expression = params[:exp]  
    6773     
     
    103109  def refresh(uri,view=:subject_view, filter='')    
    104110    @resourceset= session[:application].get(uri).setWithOffset(0)     
    105      @filter=filter 
     111    @filter=filter 
    106112    #render the _window.rhtml view 
    107113    render :partial => view.to_s , :layout=>false 
    108114  end 
    109115   
    110 #  def addfilter      
    111 #    @resourceset= session[:application].get(params[:uri]) 
    112 #    @resourceset.addFilter("filter('select{|i| i.to_i" + params[:op] +  params[:value]+ "}')") 
    113 #    render :partial => "subject_view" , :layout=>false 
    114 #  end 
    115     
     116  #  def addfilter      
     117  #    @resourceset= session[:application].get(params[:uri]) 
     118  #    @resourceset.addFilter("filter('select{|i| i.to_i" + params[:op] +  params[:value]+ "}')") 
     119  #    render :partial => "subject_view" , :layout=>false 
     120  #  end 
     121   
    116122   
    117123end 
  • Explorator/trunk/app/controllers/repository_controller.rb

    r296 r315  
    5151  def add 
    5252    if params[:title]==nil || params[:title]  == '' 
    53       render :text => 'O título do sparql endpoint é obrigatório.',:layout => false       
     53      redirect_to :controller => 'message',:action => 'error', :message => "Type the SPARQL Enpoint title",:layout => false 
    5454      return 
    5555    end 
     
    5858      adapter.title=params[:title]     
    5959      adapter.limit=params[:limit]  if params[:limit] != nil    
    60        session[:addrepositories]<<adapter 
     60      session[:addrepositories]<<adapter 
    6161    session[:disablerepositories] << (params[:title])  
    6262    session[:disablerepositories].uniq! 
     63     
     64rescue Exception => e 
     65  puts e.message 
     66  puts e.backtrace 
     67   
     68   session[:addrepositories].delete(adapter) 
     69    session[:disablerepositories].delete(params[:title])  
     70   ConnectionPool.remove_data_source(adapter) 
     71      redirect_to :controller => 'message',:action => 'error', :message => "SPARQL Enpoint invalid: "+e.message ,:layout => false 
     72    return 
     73end 
     74       begin  
    6375      RDFS::Resource.find_all_predicates     
    6476      # construct the necessary Ruby Modules and Classes to use the Namespace 
     
    6779      #Test the sparql endpoint. 
    6880      Query.new.distinct(:s).where(:s,Namespace.lookup(:rdf,:type),Namespace.lookup(:rdfs,:Class)).limit(5).execute       
    69  
    70       
    71  
    7281rescue Exception => e 
    7382  puts e.message 
     83  puts e.backtrace 
    7484   session[:addrepositories].delete(adapter) 
    7585    session[:disablerepositories].delete(params[:title])  
     86    ConnectionPool.remove_data_source(adapter) 
     87     
     88        redirect_to :controller => 'message',:action => 'error',:message => e.message ,:layout => false 
    7689  
    77        ConnectionPool.remove_data_source(adapter) 
    78 render :text => e.message,:layout => false 
    79  
    8090   return 
    8191end 
    82  
    83    # enable(params[:title])     
    84 render :text => 'SparqlEndpoint Added!',:layout => false 
     92 redirect_to :controller => 'message',:action => 'confirmation', :message => "SPARQL Enpoint added successfuly ",:layout => false 
     93  
    8594  end 
    8695end