myexperiment-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[myexperiment-hackers] [3320] branches/wf4ever: WFE-810 Rip out anything


From: noreply
Subject: [myexperiment-hackers] [3320] branches/wf4ever: WFE-810 Rip out anything with models/ research_objects
Date: Mon, 21 Jan 2013 16:58:35 +0000 (UTC)

Revision
3320
Author
stain
Date
2013-01-21 16:58:35 +0000 (Mon, 21 Jan 2013)

Log Message

WFE-810 Rip out anything with models/research_objects

Modified Paths

Removed Paths

Diff

Deleted: branches/wf4ever/app/controllers/research_objects_controller.rb (3319 => 3320)


--- branches/wf4ever/app/controllers/research_objects_controller.rb	2013-01-21 16:07:53 UTC (rev 3319)
+++ branches/wf4ever/app/controllers/research_objects_controller.rb	2013-01-21 16:58:35 UTC (rev 3320)
@@ -1,238 +0,0 @@
-# myExperiment: app/controllers/research_objects_controller.rb
-#
-# Copyright (c) 2012 University of Manchester and the University of Southampton.
-# See license.txt for details.
-
-require 'curl'
-require 'wf4ever/rosrs_client'
-
-class ResearchObjectsController < ApplicationController
-
-  include ApplicationHelper
-
-  before_filter :find_research_object,  : [:show, :edit, :update, :resource_show, :wfrun]
-  before_filter :find_research_objects, : [:all]
-  
-  # GET /research_objects
-  def index
-    respond_to do |format|
-      format.html {
-
-        @pivot, problem = calculate_pivot(
-
-            :pivot_options  => Conf.pivot_options,
-            :params         => params,
-            :user           => current_user,
-            :search_models  => [ResearchObject],
-            :search_limit   => Conf.max_search_size,
-
-            :locked_filters => { 'CATEGORY' => 'ResearchObject' },
-
-            :active_filters => ["CATEGORY", "TYPE_ID", "TAG_ID", "USER_ID",
-                                "LICENSE_ID", "GROUP_ID", "WSDL_ENDPOINT",
-                                "CURATION_EVENT", "SERVICE_PROVIDER",
-                                "SERVICE_COUNTRY", "SERVICE_STATUS"])
-
-        flash.now[:error] = problem if problem
-
-        @query = params[:query]
-        @query_type = 'research_objects'
-
-        # index.rhtml
-      }
-    end
-  end
-  
-  # GET /research_objects/1
-  def show
-
-    @manifest = @contributable.manifest
-
-      
-    @ro_entry_url = url_for : false,
-                            :host => base_host,
-                            :id => @research_object.object_id
-    
-    respond_to do |format|
-      format.html # show.rhtml
-    end
-  end
-  
-  
-
-  # GET /research_objects/new
-  def new
-    @research_object = ResearchObject.new
-  end
-  
-  # GET /research_objects/1/edit
-  def edit
-    @research_object = @contributable
-  end
-
-  # POST /research_objects
-  def create
-
-    if !params[:research_object].is_a?(Hash)
-      error("Research Object is invalid", "is invalid")
-      return
-    end
-
-    ro_params = params[:research_object]
-
-    # get url (if provided)
-    url = "" if ro_params[:url].is_a?(String) && !ro_params[:url].empty?
-
-    # get request body (if provided)
-    file = request.raw_post if request.raw_post != nil && request.env["CONTENT_TYPE"] == "text/turtle"
-
-    # get uploaded file (if provided)
-    file = ro_params[:data].read if ro_params[:data].respond_to?(:read)
-
-    if !url && !file
-      error("You must either specify a URL or upload a Research Object", "not found")
-      return
-    end
-
-    if url && file
-      error("You specified a URL and uploaded a Research Object", "is invalid")
-      return
-    end
-
-    if url
-      begin
-        curl = Curl::Easy.new(url)
-        
-        curl.follow_location = true
-
-        curl.http_get
-        throw Exception if curl.response_code != 200
-        research_object = curl.body_str
-      rescue
-        error("Problem retrieving content from URL (HTTP status #{curl.response_code})",
-            "is invalid")
-        return
-      end
-    else
-      research_object = file
-    end
-
-    policy = Policy.new(:contributor => current_user, :name => 'auto', :share_mode => 0, :update_mode => 6)
-
-    @research_object = ResearchObject.create(
-        :contributor  => current_user,
-        :contribution => Contribution.new(:policy => policy),
-        :url          ="" url,
-        :title        => ro_params[:title],
-        :description  => ro_params[:description],
-        :content_blob => ContentBlob.new(:data ="" research_object))
-
-    @research_object.load_graph if @research_object.valid?
-
-    respond_to do |format|
-      format.html {
-        if @research_object.new_record?
-          render :action ="" "new"
-        else
-          redirect_to(@research_object)
-        end
-      }
-    end
-  end
-  
-  # PUT /research_objects/1
-  def update
-  end
-
-  # DELETE /research_objects/1
-  def destroy
-  end
-
-  # GET /research_objects/:id/resource/:resource_path
-  def resource_show
-
-#   resource_object = Statement.find(:first, :conditions => {
-#       :research_object_id => @contributable.id,
-#       :predicate_text => 'http://purl.org/wf4ever/ro#name',
-#       :objekt_text => params[:path]})
-
-#   raise ActiveRecord::RecordNotFound if resource_object.nil?
-
-#   statements = Statement.find(:all, :conditions => {
-#       :subject_text => resource_object.subject_text
-#   })
-
-    # Get annotations as merged graph.  This will be pulled from cache
-    # eventually.
-
-    session = ROSRS::Session.new(@contributable.url, Conf.rodl_bearer_token)
-
-    @resuri = @contributable.resolve_resource_uri(params[:resource_path])
-
-    @annotations = session.get_annotation_graph(@contributable.url, @resuri)
-
-    @contributable.manifest.query(address@hidden, nil, nil]).each do |statement|
-
-      case statement.predicate.to_s
-      when "http://purl.org/wf4ever/ro#name":      @manifest_name    = statement.object.to_s
-      when "http://purl.org/dc/terms/created":     @manifest_created = Date.parse(statement.object.to_s)
-      when "http://purl.org/dc/terms/creator":     @manifest_creator = statement.object.to_s
-      when "http://purl.org/wf4ever/ro#checksum" : @manifest_md5     = statement.object.to_s
-      when "http://purl.org/wf4ever/ro#filesize" : @manifest_size    = statement.object.to_s.to_i
-      end
-
-    end
-
-    @annotations.query(address@hidden, nil, nil]).each do |statement|
-
-      case statement.predicate.to_s
-      when "http://purl.org/dc/terms/title":       @title       = statement.object.to_s
-      when "http://purl.org/dc/terms/description": @description = statement.object.to_s
-      when "http://purl.org/dc/terms/creator":     @creator     = statement.object.to_s
-      when "http://purl.org/dc/terms/created":     @created     = Date.parse(statement.object.to_s)
-      end
-
-    end
-
-    render :resource_show
-  end
-
-  protected
-  
-  def find_research_objects
-    @contributables = ResearchObject.find(:all, 
-                       :order => "created_at DESC",
-                       :page => { :size => 20, 
-                       :current => params[:page] })
-  end
-  
-  def find_research_object
-    begin
-      research_object = ResearchObject.find(params[:id])
-      
-      @contributable = research_object
-      
-      @contributable_entry_url = url_for : false,
-                          :host => base_host,
-                          :id => @contributable.id
-
-      @contributable_label                = @contributable.title
-      @contributable_path                 = research_object_path(@contributable)
-
-    rescue ActiveRecord::RecordNotFound
-      error("Research Object not found", "is invalid")
-    end
-  end
-  
-  private
-  
-  def error(notice, message, attr=:id)
-    flash[:error] = notice
-     (err = ResearchObject.new.errors).add(attr, message)
-    
-    respond_to do |format|
-      format.html { redirect_to research_objects_url }
-    end
-  end
-end
-

Modified: branches/wf4ever/app/helpers/application_helper.rb (3319 => 3320)


--- branches/wf4ever/app/helpers/application_helper.rb	2013-01-21 16:07:53 UTC (rev 3319)
+++ branches/wf4ever/app/helpers/application_helper.rb	2013-01-21 16:58:35 UTC (rev 3320)
@@ -1444,10 +1444,6 @@
         end
           
         link = link_to h(title), url_for(:controller => :workflows, :action ="" :show, :id => item.contributable_id, :version => 1)
-      when "ResearchObject"
-        title = item.contributable.title
-          
-        link = link_to h(title), url_for(:controller => :research_objects, :action ="" :show, :id => item.contributable_id, :version => 1)
       else
         link = contributable(item.contributable_id, item.contributable_type)
       end

Deleted: branches/wf4ever/app/models/research_object.rb (3319 => 3320)


--- branches/wf4ever/app/models/research_object.rb	2013-01-21 16:07:53 UTC (rev 3319)
+++ branches/wf4ever/app/models/research_object.rb	2013-01-21 16:58:35 UTC (rev 3320)
@@ -1,292 +0,0 @@
-# myExperiment: app/models/research_object.rb
-#
-# Copyright (c) 2012 University of Manchester and the University of Southampton.
-# See license.txt for details.
-
-require 'lib/acts_as_site_entity'
-require 'lib/acts_as_contributable'
-
-require 'curl'
-require 'xml/libxml'
-require 'zip/zip'
-require 'rdf'
-require 'rdf/raptor'
-require 'wf4ever/rosrs_client'
-
-class ResearchObject < ActiveRecord::Base
-
-  acts_as_site_entity
-  acts_as_contributable
-
-  has_many :statements, :dependent => :destroy
-
-  belongs_to :content_blob, :dependent => :destroy
-
-  validates_presence_of :title
-  validates_presence_of :content_blob
-
-  format_attribute :description
-
-  attr_accessor :manifest
-
-  def load_graph_from_zip
-
-    begin
-
-      filename = "tmp/ro.#{Process.pid}.zip"
-
-      File.open(filename, "w") do |f|
-        f.write(content_blob.data)
-      end
-
-      zip = Zip::ZipFile.open(filename)
-
-      metadata = zip.read(".ro/manifest.rdf")
-
-      # close files
-
-      zip.close
-      FileUtils.rm_rf(filename)
-
-      # create RDF graph
-
-      manifest_name = "tmp/manifest.#{Process.pid}.rdf"
-
-      File.open(manifest_name, "w") do |f|
-        f.write(metadata)
-      end
-
-      graph = RDF::Graph.load(manifest_name)
-
-      FileUtils.rm_rf(manifest_name)
-
-      # create triples
-
-      graph.query([nil, nil, nil]).each do |s, p, o|
-
-        statements.create(
-            :subject_text =>   s.to_s,
-            :predicate_text => p.to_s,
-            :objekt_text =>    o.to_s)
-      end
-
-      graph
-    end
-  end
-
-  def load_graph
-
-    # create RDF graph
-
-    manifest_name = "tmp/graph.#{Process.pid}.rdf"
-
-    File.open(manifest_name, "w") do |f|
-      f.write(content_blob.data)
-    end
-
-    graph = RDF::Graph.load(manifest_name)
-
-    FileUtils.rm_rf(manifest_name)
-
-    # create triples
-
-    graph.query([nil, nil, nil]).each do |s, p, o|
-
-      statements.create(
-          :subject_text   => s.to_s,
-          :predicate_text => p.to_s,
-          :objekt_text    => o.to_s,
-          :context_uri    => url)
-    end
-
-    graph
-  end
-
-  def wf4ever_resources
-
-    resources = statements.find(:all, :conditions =>
-      ['predicate_text = ? AND objekt_text = ?',
-        'http://www.w3.org/1999/02/22-rdf-syntax-ns#type',
-        'http://purl.org/wf4ever/ro#Resource']).map do
-      |a| a.subject_text
-    end
-
-    resources.map do |resource|
-
-      metadata = {}
-
-      statements.find(:all, :conditions =>
-        ['subject_text = ?', resource]).each do |statement|
-
-        case statement.predicate_text
-        when "http://purl.org/wf4ever/ro#name":      metadata[:name]    = statement.objekt_text
-        when "http://purl.org/dc/terms/created":     metadata[:created] = Date.parse(statement.objekt_text)
-        when "http://purl.org/dc/terms/creator":     metadata[:creator] = statement.objekt_text
-        when "http://purl.org/wf4ever/ro#checksum" : metadata[:md5]     = statement.objekt_text
-        when "http://purl.org/wf4ever/ro#filesize" : metadata[:size]    = statement.objekt_text.to_i
-        end
-
-      end
-
-      metadata
-
-    end
-
-  end
-
-  def self.related_research_objects_to_t2(uuid)
-
-    self.related_research_objects("
-
-      PREFIX ro: <http://purl.org/wf4ever/ro#>
-      PREFIX dcterms: <http://purl.org/dc/terms/>
-      PREFIX foaf: <http://xmlns.com/foaf/0.1/>
-
-      SELECT ?resource ?creator ?created
-      WHERE {
-         ?resource a ro:ResearchObject ;
-           dcterms:created ?created ;
-             dcterms:creator ?creator .
-      }
-      ORDER BY DESC(?created)
-
-      LIMIT 10")
-
-  end
-
-  def self.related_research_objects(query)
-
-    Conf.research_object_endpoints.each do |endpoint|
-
-      begin
-
-        url = ""
-
-        curl = Curl::Easy.http_get(url)
-
-        if curl.response_code == 200
-
-          ns  = { :s => 'http://www.w3.org/2005/sparql-results#' }
-
-          doc = LibXML::XML::Parser.string(curl.body_str).parse
-          
-          doc.root.find('/s:sparql/s:results/s:result/s:address@hidden"resource"]/s:uri', ns).each do |uri|
-            puts uri.content
-          end
-
-          return curl.body_str
-        end
-        
-      end
-    end
-  end
-
-  def annotations
-
-    results = []
-
-    annotation_bodies = statements.find(:all,
-        :conditions => ['predicate_text = ?', 'http://purl.org/ao/body'])
-
-    annotation_bodies.each do |body|
-
-      type = statements.find(:first,
-          :conditions => ['predicate_text = ? AND subject_text = ?',
-          'http://www.w3.org/1999/02/22-rdf-syntax-ns#type',
-          body.subject_text])
-
-      next if type.nil?
-
-      results << { :type => type.objekt_text, :body => body.objekt_text }
-    end
-
-    results
-  end
-
-  def create_annotation_body(resource_uri, body, namespaces)
-
-    namespaces["rdf"] = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
-
-    doc = LibXML::XML::Document.new
-    doc.root = LibXML::XML::Node.new("rdf:RDF")
-    doc.root["xml:base"] = url
-
-    namespaces.each do |name, uri|
-      doc.root["xmlns:#{name}"] = uri
-    end
-
-    description = LibXML::XML::Node.new("rdf:Description")
-    description["rdf:about"] = resource_uri
-    description << body
-    doc.root << description
-
-    doc
-  end
-
-  def set_simple_annotation(resource_uri, predicate, namespaces, term, new_value)
-
-    session = ROSRS::Session.new(url, Conf.rodl_bearer_token)
-
-    # Remove existing annotations of the same structure
-
-    annotations = session.get_annotation_graphs(url, resource_uri)
-
-    annotations.each do |annotation|
-
-      next unless annotation[:body].count == 1
-      next unless annotation[:body].query(:predicate => predicate).count == 1
-
-      c, r, h, d = session.do_request("DELETE", annotation[:stub], {} )
-      c, r, h, d = session.do_request("DELETE", annotation[:body_uri], {} )
-    end
-
-    # Create the new annotation
-
-    annotation_body = create_annotation_body(resource_uri,
-        LibXML::XML::Node.new(term, new_value),
-        namespaces)
-
-    agraph = RDFGraph.new(:data ="" annotation_body.to_s, :format => :xml)
-
-    code, reason, stub_uri, body_uri = session.create_internal_annotation(url, resource_uri, agraph)
-  end
-
-  def set_dc_title(resource_uri, value)
-    set_simple_annotation(resource_uri,
-        RDF::DC.title,
-        { "dct" => "http://purl.org/dc/terms/" },
-        "dct:title",
-        value)
-  end
-
-  def set_dc_description(resource_uri, value)
-    set_simple_annotation(resource_uri,
-        RDF::DC.description,
-        { "dct" => "http://purl.org/dc/terms/" },
-        "dct:description",
-        value)
-  end
-
-  
-  def manifest
-
-    return @manifest if @manifest
-
-    session = ROSRS::Session.new(url, Conf.rodl_bearer_token)
-
-    manifest_uri, manifest = session.get_manifest(url)
-
-    @manifest = manifest
-  end
-
-  def resolve_resource_uri(resource_uri)
-    RDF::URI.parse(url).join(RDF::URI.parse(resource_uri))
-  end
-
-  def aggregated_resources
-    manifest.query([nil, RDF.type, RDF::RO.Resource]).map do |statement|
-      statement.subject
-    end
-  end
-end
-

Modified: branches/wf4ever/app/models/statement.rb (3319 => 3320)


--- branches/wf4ever/app/models/statement.rb	2013-01-21 16:07:53 UTC (rev 3319)
+++ branches/wf4ever/app/models/statement.rb	2013-01-21 16:58:35 UTC (rev 3320)
@@ -5,7 +5,7 @@
 
 class Statement < ActiveRecord::Base
 
-  belongs_to :research_object
+  belongs_to :pack
 
   validates_presence_of :subject_text
   validates_presence_of :predicate_text

Deleted: branches/wf4ever/app/views/research_objects/show.rhtml (3319 => 3320)


--- branches/wf4ever/app/views/research_objects/show.rhtml	2013-01-21 16:07:53 UTC (rev 3319)
+++ branches/wf4ever/app/views/research_objects/show.rhtml	2013-01-21 16:58:35 UTC (rev 3320)
@@ -1,90 +0,0 @@
-
-<ul class="sectionIcons">
-	<% if @authorised_to_edit -%>
-		<li><%= icon('new', new_version_workflow_path(@workflow), nil, nil, 'Upload New Version')%></li>
-	<% end -%>	
-	<% if mine?(@workflow) -%>
-		<li><%= icon('manage', edit_workflow_path(@workflow), nil, nil, 'Manage Workflow Entry')%></li>
-	<% end -%>
-	<% if Authorization.check("destroy", @workflow, current_user) -%>
-		<li>
-			<%= icon('destroy', workflow_path(@workflow), nil, { :confirm => 'This deletes all versions of the Workflow and all metadata such as tags, comments and citations. Are you sure?', :method => :delete }, 'Delete Workflow Entry') %>
-		</li>
-	<% end -%>
-</ul>
-
-<h1>Research Object: <%=h @contributable.title -%></h1>
-
-
-
-<%= render :partial => "contributions/datetime_info", :locals => { :contributable => @contributable } -%>
-
-
-<div class="contribution_mini_nav">
-	|
-<%= render :partial => "research_objects/browseportal", :locals => { :ro_uri => @contributable.url  } -%>
-  |
-</div>
-
-
-
-
-
-<div class="contribution_left_box">
-	
-	<div class="contribution_version_box">
-
-    <%= render :partial => "research_objects/versions", :locals => { :contributable => @contributable } -%> 
-  
-	  <div class="contribution_version_inner_box">
-      <%= render :partial => "research_objects/title", :locals => { :contributable => @contributable } -%>      
-      <%= render :partial => "research_objects/uploader", :locals => { :contributable => @contributable } -%>
-      <%= render :partial => "research_objects/description", :locals => { :contributable => @contributable } -%>
-      <%= render :partial => "research_objects/credits", :locals => { :contributable => @contributable } -%>
-      <%= render :partial => "research_objects/tags", :locals => { :contributable => @contributable } -%>
-      <%= render :partial => "research_objects/diagram", :locals => { :contributable => @contributable } -%>  
-      <%= render :partial => "research_objects/attribution", :locals => { :contributable => @contributable } -%>
-
-
-<% if false %>
-      <%= render :partial => "research_objects/resources", :locals => { :contributable => @contributable } -%>
-  <%= render :partial => "research_objects/manifest", :locals => { :contributable => @contributable } -%>
-  <%= render :partial => "research_objects/annotations", :locals => { :contributable => @contributable } -%>
-  <%= render :partial => "research_objects/statements", :locals => { :contributable => @contributable } -%>
-
-<% end %>
-
-
-    </div>
-  </div><!-- End of version -->
-  
-  
-  
-  <%= render :partial => "research_objects/evolution", :locals => { :contributable => @contributable } -%>    
-
-
-  <div id="ratingsBox">
-  	<%= render :partial => "research_objects/reviews", :locals => { :reviewable => @contributable } %>
-  </div>
-
-	<%= render :partial => "research_objects/comments", :locals => { :commentable => @contributable } %>
-  
-
-</div>
-
-<% if false %>
-<% end %>
-
-<div class="contribution_right_box">
-  <%= render :partial => "research_objects/tree", :locals => { :contributable => @contributable, :ro_uri => @contributable.url } -%>    
-  <%= render :partial => "research_objects/wf4evertools", :locals => { :contributable => @contributable, :ro_uri => @contributable.url } -%>    
-
-  <%= render :partial => "research_objects/status", :locals => { :contributable => @contributable } -%>
-  
-	<%= render :partial => "contributions/uploader_box", :locals => { :contributable => @contributable } %>
-																											 
-	<%= render :partial => "contributions/shared_with_groups_box", :locals => { :contributable => @contributable } %>
-	
-	<%= render :partial => "contributions/in_packs_box", :locals => { :contributable => @contributable, :contributable_url => @ro_entry_url } %>
-  
-</div>
\ No newline at end of file

Modified: branches/wf4ever/config/routes.rb (3319 => 3320)


--- branches/wf4ever/config/routes.rb	2013-01-21 16:07:53 UTC (rev 3319)
+++ branches/wf4ever/config/routes.rb	2013-01-21 16:58:35 UTC (rev 3320)
@@ -204,12 +204,6 @@
   # services
   map.resources :services, :collection => { :search => :get }
   
-  # research_objects
-  map.resources :research_objects
-
-  map.research_object_resources '/research_objects/:id/resources', :controller => 'research_objects', :action ="" 'resource_index', :conditions => { :method => :get }
-  map.research_object_resource  '/research_objects/:id/resources/:resource_path', :controller => 'research_objects', :action ="" 'resource_show',  :conditions => { :method => :get }, :requirements => { :resource_path => /.*/ }
-  
     # Finn's folder stuff
   map.folder_contents '/folders/folder_contents', :controller => 'folders', :action ="" 'folder_contents'
   map.resources :folders  

reply via email to

[Prev in Thread] Current Thread [Next in Thread]