Class: TriplestoreSyncController

Inherits:
ApplicationController show all
Includes:
Iqvoc::RDFSync::Helper
Defined in:
app/controllers/triplestore_sync_controller.rb

Instance Method Summary collapse

Methods included from Iqvoc::RDFSync::Helper

#triplestore_syncer

Instance Method Details

#indexObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'app/controllers/triplestore_sync_controller.rb', line 22

def index
  authorize! :use, :dashboard

  if Iqvoc.config["triplestore.url"] == Iqvoc.config.defaults["triplestore.url"]
    flash.now[:warning] = I18n.t("txt.controllers.triplestore_sync.config_warning")
  else
    host = Iqvoc.config["triplestore.url"]
    username = Iqvoc.config["triplestore.username"].presence
    password = Iqvoc.config["triplestore.password"].presence
    target_info = host
    if username && password
      target_info = "#{target_info} (as #{username} with password)" # XXX: i18n
    elsif username
      target_info = "#{target_info} (as #{username})" # XXX: i18n
    end
    flash.now[:info] = I18n.t("txt.controllers.triplestore_sync.config_info",
        :target_info => target_info)
  end

  # per-class pagination
  @candidates = Iqvoc::RDFSync.candidates.map do |records|
    records.page(params[:page])
  end
end

#syncObject



47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'app/controllers/triplestore_sync_controller.rb', line 47

def sync
  authorize! :use, :dashboard

  success = triplestore_syncer.all # XXX: long-running

  if success
    flash[:success] = I18n.t("txt.controllers.triplestore_sync.success")
  else
    flash[:error] = I18n.t("txt.controllers.triplestore_sync.error")
  end

  redirect_to :action => "index"
end