class RawdataController

Public Instance Methods

create() click to toggle source
# File app/controllers/rawdata_controller.rb, line 52
def create
  array = []

  if params[:graph].present?
    array.push("-g" + params[:predicate])
  end

  if request.headers['Content-type'] == "text/plain"
    array.push("-n" + request.body.string)
  else request.headers['Content-type'] == "application/rdf+xml"
    array.push("-x" + request.body.string)
  end

  array.push("-ropendata")

  res =  Java::pmc::Sesamepost.results(array.to_java(:string))

  if res == 1
    render :nothing => true, :status => 409
  else
    render :nothing => true, :status => 204
  end
end
destroy() click to toggle source
# File app/controllers/rawdata_controller.rb, line 120
def destroy
  array = []

  if params[:graph].present?
    array.push("-g" + params[:graph])
  end

  if request.headers['Accept'] == "text/plain"
    array.push("-n" + request.body.string)
  else request.headers['Accept'] == "application/rdf+xml"
    array.push("-x" + request.body.string)
  end

  array.push("-ropendata")

  res =  Java::pmc::Sesamedelete.results(array.to_java(:string))

  if res == 1
    render :nothing => true, :status => 404
  else
    render :nothing => true, :status => 204
  end
end
show() click to toggle source
# File app/controllers/rawdata_controller.rb, line 16
def show

  array = []
  if params[:subject].present?
    array.push("-s" + params[:subject])
  end
  if params[:predicate].present?
    array.push("-p" + params[:predicate])
  end
  if params[:object].present?
    if %r^http:\/\// =~ params[:object] 
      array.push("-o" + params[:object])
    elsf %r^<http:\/\// =~ params[:object] 
      len = params[:object].length
      array.push("-o" + params[:object].slice(1,len-2))
    else
      array.push("-O" + params[:object])
    end
  end
  if params[:graph].present?
    array.push("-g" + params[:predicate])
  end

  if request.headers['Accept'] == "text/plain"
    array.push("-n")
  elsif request.headers['Accept'] == "text/rdf+n3"
    array.push("-3")
  else request.headers['Accept'] == "application/rdf+xml"
    array.push("-x")
  end

  array.push("-ropendata")
  res =  Java::pmc::Sesameget.results(array.to_java(:string))
  render :text => res
end
update() click to toggle source
# File app/controllers/rawdata_controller.rb, line 76
def update
  # RDF/XML ONLY
  idx = request.body.string.rindex("<?")
  len = request.body.string.length
  arg1 = request.body.string.slice(0..(idx-1))
  arg2 = request.body.string.slice(idx..len-1)

  array1 = []
  array2 = []

  if params[:graph].present?
    array1.push("-g" + params[:graph])
    array2.push("-g" + params[:graph])
  end

  if request.headers['Content-type'] == "text/plain"
    array1.push("-n" + arg1)
    array2.push("-n" + arg2)
  else request.headers['Content-type'] == "application/rdf+xml"
    array1.push("-x" + arg1)
    array2.push("-x" + arg2)
  end

  array1.push("-ropendata")
  array2.push("-ropendata")

  res = 0
  res =  Java::pmc::Sesamedelete.results(array1.to_java(:string))

  if res == 1
    render :nothing => true, :status => 404 and return
  end

  res = 0
  res =  Java::pmc::Sesamepost.results(array2.to_java(:string))
    
  if res == 1
      render :nothing => true, :status => 409 and return
  end

  render :nothing => true, :status => 204
end