Class: MetadataController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- MetadataController
- Defined in:
- app/controllers/metadata_controller.rb
Constant Summary
Constants included from ProjectsHelper
ProjectsHelper::CLASSIFIER, ProjectsHelper::CLASSIFIER_ANNOTATION
Instance Method Summary collapse
-
#annotators ⇒ Object
/metadata/annotators.json.
-
#attributes ⇒ Object
GET /metadata/attributes?model=CollectingEvent&mode=editable.
- #class_navigation ⇒ Object
- #data_models ⇒ Object
- #get_klass ⇒ Object protected
- #index ⇒ Object
- #object_navigation ⇒ Object
-
#object_radial ⇒ Object
:klass is a base class name, like “Otu”.
- #related_summary ⇒ Object
-
#vocabulary ⇒ Object
!! DO NOT EXPOSE TO API !! until santize tested.
Methods included from RedirectHelper
Methods included from RequestType
Methods included from LogRecent
Methods included from Cookies
#digest_cookie, #digested_cookie_exists?
Methods included from Whitelist
Methods included from ProjectsHelper
#cumulative_gb_per_year, #document_cumulative_gb_per_year, #document_gb_per_year, #gb_per_year, #image_cumulative_gb_per_year, #image_gb_per_year, #invalid_object, #project_classification, #project_link, #project_matches, #project_tag, #projects_list, #projects_search_form, #taxonworks_classification, #week_in_review_graphs
Methods included from Api::Intercept
Methods included from TokenAuthentication
#intercept_project, #intercept_user, #intercept_user_or_project, #project_token_authenticate, #token_authenticate
Instance Method Details
#annotators ⇒ Object
/metadata/annotators.json
34 35 36 |
# File 'app/controllers/metadata_controller.rb', line 34 def annotators render json: helpers.klass_annotations end |
#attributes ⇒ Object
GET /metadata/attributes?model=CollectingEvent&mode=editable
58 59 60 61 62 63 64 65 |
# File 'app/controllers/metadata_controller.rb', line 58 def attributes render json: Vocabulary.attributes( Vocabulary.get_model( params.require(:model) ), mode: params[:mode] ) end |
#class_navigation ⇒ Object
23 24 25 26 |
# File 'app/controllers/metadata_controller.rb', line 23 def k = params.require(:klass) render json: helpers.(k) end |
#data_models ⇒ Object
49 50 51 |
# File 'app/controllers/metadata_controller.rb', line 49 def data_models render json: DATA_MODELS.keys.sort end |
#get_klass ⇒ Object (protected)
69 70 71 72 73 74 75 76 77 78 79 |
# File 'app/controllers/metadata_controller.rb', line 69 def get_klass render json: {status: 400} if (params[:type] && params[:global_id]) || (params[:type].blank? && params[:global_id].blank?) if params[:type] @klass = params[:type] @object = nil else @object = GlobalID::Locator.locate(params.require(:global_id)) @klass = OBJECT_RADIALS[@object.class.name] ? @object.class.name : @object.class.base_class.name end end |
#index ⇒ Object
6 7 8 9 |
# File 'app/controllers/metadata_controller.rb', line 6 def index @klass = params[:klass] render '/shared/data/metadata/index' end |
#object_navigation ⇒ Object
18 19 20 21 |
# File 'app/controllers/metadata_controller.rb', line 18 def @object = GlobalID::Locator.locate(params.require(:global_id)) render json: {status: 200} end |
#object_radial ⇒ Object
:klass is a base class name, like “Otu”
12 13 14 15 16 |
# File 'app/controllers/metadata_controller.rb', line 12 def object_radial get_klass @data = OBJECT_RADIALS[@klass] render '/workbench/navigation/object_radial' end |
#related_summary ⇒ Object
28 29 30 31 |
# File 'app/controllers/metadata_controller.rb', line 28 def @klass = params.require(:klass).safe_constantize render json: @klass.(params.require(:id)) end |
#vocabulary ⇒ Object
!! DO NOT EXPOSE TO API !! until santize tested
39 40 41 42 43 44 45 46 47 |
# File 'app/controllers/metadata_controller.rb', line 39 def vocabulary p = params.permit(:model, :attribute, :begins_with, :limit, :contains, :min, :max).merge(project_id: sessions_current_project_id).to_h.symbolize_keys if @words = Vocabulary.words(**p) render json: @words, status: :ok else render json: {}, status: :unprocessable_entity end end |