lib/app/controllers/triplify_controller.rb in rtriplify-0.0.1 vs lib/app/controllers/triplify_controller.rb in rtriplify-0.0.2

- old
+ new

@@ -3,34 +3,36 @@ class TriplifyController < ActionController::Base def tripleize t = Tripleizer.new t.base_uri = t.uri request.env['REQUEST_URI'].to_s + depth = configatron.linked_data_depth.to_i filename = 'data.n3' headers.merge!( 'Content-Type' => 'text/rdf+n3', 'Content-Disposition' => "attachment; filename=\"#{filename}\"", 'Content-Transfer-Encoding' => 'binary' ) t.output_json = request.content_type.try(:to_sym)==:json content_type = t.output_json ? 'application/json' : 'text/plain' + render :content_type => content_type , :text => proc { |response, output| t.output = output case params[:specs].length when 0 t.write_rdf_head - all t + all t if depth > -1 when 1 t.base_uri = t.base_uri.to_s[0..t.base_uri.to_s.index(params[:specs][0].to_s)-1] t.write_rdf_head - model t, params[:specs][0] + model t, params[:specs][0] if depth >0 when 2 t.base_uri = t.base_uri.to_s[0..t.base_uri.to_s.index(params[:specs][0].to_s)-1] t.write_rdf_head - index t, params[:specs] + index t, params[:specs] if depth > 1 end t_metadata = TriplifyMetadata.new t_metadata.write_metadata(t) output.write t.json if t.output_json @@ -56,11 +58,11 @@ "" end #get all models def model t, model_group - models = t.search_models model_group + models = t.find_models model_group models.values[0].each do |model_name, model_attributes| if model_name.to_s =="sql_query" t.write_sql(model_group_name,model_attributes,output) else t.write_model(model_name, models.keys[0]) @@ -69,10 +71,10 @@ end # get a defined model with given id def index t,param subclass,id = param - models = t.search_models subclass + models = t.find_models subclass models.values[0].each do |model_name, model_attributes| if model_name.to_s =="sql_query" #some magic is needed here ..parse the sql query? else m = Model.new model_name, models.keys[0].to_s