Top Level Namespace
Defined Under Namespace
Modules: AnalysisSrStageMixin, BibliographicalImporter, Buhos, DOIHelpers, FileHandler, HTMLHelpers, PMC, PubmedRemote, ReferenceMethods, ReportBuilder, SearchGrammar, SemanticScholar, Sinatra, SystematicReviewViewsMixin, TagBuilder, TagMixin Classes: AbstractPresentation, AllocationCd, AnalysisSystematicReview, AnalysisUserDecision, Analysis_SR_Stage, Authorization, AuthorizationsRole, BadCrossrefResponseError, BibliographicDatabase, BibliographicFileProcessor, CanonicalDocument, CategorizerSr, CdCriterion, CdQualityCriterion, Criterion, CrossrefDoi, CrossrefQuery, Decision, FileCd, FileProcessor, FileSr, FormBuilder, Group, GroupsUser, IFile, Institution, Message, MessageSr, MessageSrSeen, OutgoingEmail, PdfFileProcessor, PdfProcessor, Pmc_Summary, QualityCriterion, Record, RecordCrossrefProcessor, RecordsReferences, RecordsSearch, Reference, ReferenceProcessor, Resolution, Result, RisReader, Role, Scale, ScalesItem, ScopusRemote, Scopus_Abstract, Search, SearchValidator, SearchValidatorReview, SearchValidatorUser, SecurityEvent, Semantic_Scholar_Paper, SrCriterion, SrField, SrQualityCriterion, SrTaxonomy, SrTaxonomyCategory, SystematicReview, Systematic_Review_SRTC, T_Class, Tag, TagBwCd, TagInCd, TagInClass, User, UserDashboardInfo
Tags collapse
-
#GET____tags__basic____ref___10_json_ ⇒ Object
Retrieve a basic json for autopredict.
-
#GET___tag__tag_id_rs__rs_id_cds_ ⇒ Object
Retrieve canonical document what uses a tag, for a given user.
-
#GET___tag__tag_id_rs__rs_id_stage__stage_cds_ ⇒ Object
Retrieve canonical document what uses a tag on a specific stage.
-
#GET___tags_query_json__query_ ⇒ Object
Query for tags (canonical documents).
-
#GET___tags_refs_query_json__query_ ⇒ Object
Query for tags (relation between canonical documents).
-
#GET___tags_systematic_review__rs_id_query_json__query_ ⇒ Object
Query for tags (canonical documents on a specific systematic review).
-
#GET___tags_systematic_review__rs_id_ref_query_json__query_ ⇒ Object
Query for tags (relation between canonical documents on a specific systematic review).
-
#POST___tag_delete_rs_ ⇒ Object
Remove tag allocated to a canonical document.
-
#POST___tags_cd__cd_id_rs__rs_id__accion_ ⇒ Object
Actions for tags and canonical documents * add_tag * approve_tag * reject_tag.
-
#POST___tags_cd_start__cd_start_id_cd_end__cd_end_id_rs__rs_id__accion_ ⇒ Object
Actions for tags and relations between canonical documents * add_tag * approve_tag * reject_tag.
-
#POST___tags_class__t_clase_id_add_tag_ ⇒ Object
Add a tag to a class tag.
-
#POST___tags_class__t_clase_id_remove_tag_ ⇒ Object
Remove tag from a class tag.
-
#POST___tags_classes_new_ ⇒ Object
Create a new class tag.
- #PUT___tag_rename_review__sr_id_user__user_id_ ⇒ Object
- #PUT___tags_classes_edit_field__field_ ⇒ Object
-
#PUT__tag_edit ⇒ Object
Edit a tag.
User collapse
-
#GET___my_messages_ ⇒ Object
See all messages for a user Alias for ‘/user/:user_id/messages’.
-
#GET___user__user_id_ ⇒ Object
View and edit user attributes.
-
#GET___user__user_id_change_password_ ⇒ Object
Form to change password.
-
#GET___user__user_id_edit_ ⇒ Object
An alias to /user/:user_id.
-
#POST___user__user_id_change_password_ ⇒ Object
Change the password of a user.
-
#PUT___user_edit__field_ ⇒ Object
Edit an attribute of a user.
Personal messages collapse
-
#GET___user__user_id_compose_message_ ⇒ Object
Compose a personal message.
-
#GET___user__user_id_messages_ ⇒ Object
Get all user messages.
-
#POST___message_per__m_id_reply_ ⇒ Object
Send a reply to a message.
-
#POST___user__user_id_compose_message_send_ ⇒ Object
Send a personal message.
Files collapse
-
#GET___file__id_download_ ⇒ Object
Download a file.
-
#GET___file__id_download_external_ ⇒ Object
Download a file.
-
#GET___file__id_page__pagina__format_ ⇒ Object
Get a specific page on a document.
-
#GET___file__id_to_text_download_external_ ⇒ Object
Requires poppler-utils on Ubuntu Todo: use pdf-reader.
-
#GET___file__id_view_ ⇒ Object
Retrieves a file, on mode ‘inline’.
-
#GET___files_rs__systematic_review_id_assign_to_canonical_documents_ ⇒ Object
Allocate automatically files to canonical documents.
-
#GET___ViewerJS__ ⇒ Object
Get ViewerJS.
-
#GET___ViewerJS___file__id_download_ ⇒ Object
Get a file.
-
#POST___file_assign_to_canonical_ ⇒ Object
Allocate a specific file to a canonical document.
-
#POST___file_delete_ ⇒ Object
Delete a file.
-
#POST___file_hide_cd_ ⇒ Object
Hide a file allocated to a canonical document.
-
#POST___file_show_cd_ ⇒ Object
Show a file allocated to a canonical document.
-
#POST___file_unassign_cd_ ⇒ Object
Remove the allocation of a file to a canonical document.
-
#POST___file_unassign_sr_ ⇒ Object
Remove the allocation of a file to a systematic review.
-
#PUT___file_edit_field__campo_ ⇒ Object
Edit an attribute of a file.
Searches collapse
-
#GET___review__id_search_bibliographic_file_new_ ⇒ Object
Form to create a new search based on bibliographic files.
- #GET___review__id_search_uploaded_files_new_ ⇒ Object
-
#GET___review__id_searches_ ⇒ Object
List of searches.
- #GET___review__review_id_search__search_id_record__record_id_complete_information_ ⇒ Object
-
#GET___review__rs_id_searches_compare_records_ ⇒ Object
Compare records betweeen searches.
-
#GET___review__rs_id_searches_user__user_id_ ⇒ Object
List of searches for a user.
-
#GET___search__id_ ⇒ Object
View search.
-
#GET___search__id_edit_ ⇒ Object
Form to edit a search.
-
#GET___search__id_file_download_ ⇒ Object
Download the file allocated to a search.
-
#GET___search__id_invalidate_ ⇒ Object
Invalidate a specific search.
-
#GET___search__id_records_ ⇒ Object
List of records for a search.
-
#GET___search__id_records_complete_doi_ ⇒ Object
Complete the information for each Record, using Crossref.
-
#GET___search__id_references_ ⇒ Object
List of references for a search.
-
#GET___search__id_references_generate_canonical_doi__n_ ⇒ Object
Join canonicals to references.
-
#GET___search__id_references_search_doi_ ⇒ Object
Search on each reference a posible DOI string @todo: Should be integrated on a better way.
-
#GET___search__id_validate_ ⇒ Object
Validate a specific search.
-
#GET___search__s_id_record__r_id_ ⇒ Object
Retrieve a single record from a search.
- #GET__r__review___d______searches___records____user___d_____ ⇒ Object
- #GET__r__review___d___searches_analyze___________ ⇒ Object
- #POST___review_search_uploaded_files_new_ ⇒ Object
-
#POST___search_update_ ⇒ Object
Update or create a search.
-
#POST___searches_update_batch_ ⇒ Object
Update actions for searchs: valid, invalid, delete.
Records collapse
-
#GET___record__id_ ⇒ Object
View a record.
-
#GET___record__id_assign_doi__doi_ ⇒ Object
Assign a DOI to a record.
-
#GET___record__id_search_crossref_ ⇒ Object
Query crossref for a given record.
-
#POST___record__id_manual_references_ ⇒ Object
Add manual references to a record.
-
#POST___record__id_references_action_ ⇒ Object
Reference action.
Systematic reviews collapse
-
#GET___review__id_advance_stage_ ⇒ Object
Go to next stage, if complete.
- #GET___review__id_dashboard_ ⇒ Object
- #GET___review__id_delete_ ⇒ Object
-
#GET___review__id_files_ ⇒ Object
List of review files.
- #GET___review__rev_id_reference__ref_id_assign_canonical_document_ ⇒ Object
-
#GET___review_new_ ⇒ Object
Form to create a new systematic review.
-
#GET___reviews_ ⇒ Object
Get a list of systematic Reviews.
-
#GET__review__id ⇒ Object
View a specific review.
-
#GET__review__id_edit ⇒ Object
Form to edit a specific review.
- #POST___review__id_delete2_ ⇒ Object
-
#POST___review_files_add_ ⇒ Object
Add one or more files to a review.
-
#POST___review_update_ ⇒ Object
Create (id=0) or edit(id>0)a Systematic review.
Screening and analysis of documents collapse
-
#GET___decision_review__review_id_user__user_id_canonical_document__cd_id_stage__stage_ ⇒ Object
Retrieve the interface to make decision on a document.
-
#GET___review__id_review_full_text_ ⇒ Object
Inteface for stage review full text.
-
#GET___review__id_screening_references_ ⇒ Object
Inteface for stage screening references.
-
#GET___review__id_screening_title_abstract_ ⇒ Object
Interface for stage screening titles and abstract.
-
#POST___decision_review__review_id_user__user_id_canonical_document__cd_id_stage__stage_decision_ ⇒ Object
Make a decision on a given document.
-
#PUT___decision_review__review_id_user__user_id_canonical_document__cd_id_stage__stage_commentary_ ⇒ Object
Put a commentary for a specific document on analysis.
Systematic review message collapse
-
#GET___review__id_messages_ ⇒ Object
Messages for a systematic review.
- #POST___message__m_id_seen_by__user_id_ ⇒ Object
-
#POST___message_sr__ms_id_reply_ ⇒ Object
Show form to reply a message.
-
#POST___message_sr__ms_id_seen_by__user_id_ ⇒ Object
Mark a message as seen by a user.
-
#POST___review__id_message_new_ ⇒ Object
Post a message.
Allocation of canonical documents to users collapse
-
#GET___review__rev_id_administration__stage_cd_assignations_ ⇒ Object
List of allocations of canonical documents to users.
- #GET___review__rev_id_administration__stage_cd_assignations_excel__mode_ ⇒ Object
- #GET___review__rev_id_administration__stage_cd_without_allocations_ ⇒ Object
-
#GET___review__rev_id_stage__stage_add_assign_user__user_id__type_ ⇒ Object
Allocate canonical documents to a user if type=‘all’, all documents are allocated if type=‘without_allocation’, only documents without allocation are allocated.
- #GET___review__rev_id_stage__stage_reassign_user__user_id_ ⇒ Object
-
#GET___review__rev_id_stage__stage_rem_assign_user__user_id__type_ ⇒ Object
Remove all documents allocations from a user.
- #GET___review__sr_id_stage__stage_import_export_decisions_ ⇒ Object
- #POST___review__rev_id_administration__stage_cd_assignations_excel__mode_ ⇒ Object
- #POST___review_reassign_cd_to_user_ ⇒ Object
-
#PUT___allocation_user__user_id_review__rs_id_cd__cd_id_stage__stage_id_edit_instruction_ ⇒ Object
Provide instruction for a user on a given allocation.
References collapse
-
#GET___reference__id_ ⇒ Object
View a reference.
- #GET___reference__id_assign_doi__doi_ ⇒ Object
-
#GET___reference__id_search_crossref_ ⇒ Object
Query crossref for a specific references.
-
#GET___reference__id_search_similar_ ⇒ Object
Search references similar to a specific one.
-
#POST___reference__id_merge_similar_references_ ⇒ Object
Merge similar references.
- #POST___reference_assign_canonical_document_ ⇒ Object
-
#POST___references_search_crossref_by_doi_ ⇒ Object
Query one or more references on Crossref using their DOIs.
roles collapse
-
#GET___admin_roles_ ⇒ Object
List of roles.
-
#GET___role__id_ ⇒ Object
Information about a role.
-
#GET___role__role_id_edit_ ⇒ Object
Form to update a role.
-
#GET___role_new_ ⇒ Object
Form to create a new role.
-
#POST___role__role_id_delete_ ⇒ Object
Deletes a role.
- #POST___role_update_ ⇒ Object
users collapse
-
#GET___admin_users___ ⇒ Object
Get list of users.
- #GET___admin_users_batch_edition_ ⇒ Object
- #GET___admin_users_batch_edition_excel_export_ ⇒ Object
- #POST___admin_users_batch_edition_excel_import_ ⇒ Object
- #POST___admin_users_delete_ ⇒ Object
-
#POST___admin_users_update_ ⇒ Object
Update information for users.
- #POST___admin_users_update_edit_ ⇒ Object
stages administration collapse
-
#GET___review__id_administration__stage_ ⇒ Object
Interface to administrate a stage.
- #GET___review__id_administration_stages_ ⇒ Object
-
#GET___review__id_stage__stage_pattern__patron_resolution__resolution_ ⇒ Object
Set a resolution for a given pattern.
- #GET___review__id_stage__stage_pattern__patron_view_ ⇒ Object
-
#GET___review__rev_id_stage__stage_generate_crossref_references_ ⇒ Object
Retrieve information from Crossref for all canonical documents approved for a given stage TODO: Move this to independent class.
- #GET___review__rev_id_stage__stage_generate_crossref_references_stream_ ⇒ Object
-
#POST___resolution_review__id_canonical_document__cd_id_stage__stage_resolution_ ⇒ Object
Set resolution of a specific canonical document on a stage.
- #PUT___resolution_review__id_canonical_document__cd_id_stage__stage_user__user_id_resolution_commentary_ ⇒ Object
groups routes collapse
-
#GET___admin_groups_ ⇒ Object
Display list of groups.
-
#GET___group__group_id_delete_ ⇒ Object
Deletes a group.
-
#GET___group__id_datos_json_ ⇒ Object
Returns a json with information for a group.
-
#GET___group_new_ ⇒ Object
Display form to create a new group.
-
#GET__group__id ⇒ Object
Display information for a group.
-
#GET__group__id_edit ⇒ Object
Display form to edit a group.
-
#POST___group_update_ ⇒ Object
Updates information for a group.
Tags related to systematic reviews collapse
-
#GET___review__id_tags_ ⇒ Object
Get tags and classes of tags for a systematic review.
-
#GET___review__id_tags_user__user_id_ ⇒ Object
Interface for stage screening titles and abstract.
Export collapse
-
#GET___review__id_generate_graphml_ ⇒ Object
Generate a GraphML file of all documents on a systematic review.
- #GET___review__rev_id_generate_bibtex_ ⇒ Object
- #GET___review__rev_id_generate_excel_ ⇒ Object
-
#GET___review__rev_id_stage__stage_generate_bibtex_ ⇒ Object
Generate a BibTeX file of documents on a specific stage.
-
#GET___review__rev_id_stage__stage_generate_doi_list_ ⇒ Object
Generate a list of DOI of documents on a specific stage.
- #GET___review__rev_id_stage__stage_generate_excel_ ⇒ Object
-
#GET___review__rev_id_stage__stage_generate_graphml_ ⇒ Object
Generate a GraphML file of documents on a specific stage.
Analysis form collapse
-
#GET___review__rs_id_field__fid_delete_ ⇒ Object
Delete a field.
-
#GET___review__rs_id_fields_ ⇒ Object
List of personalized fields.
-
#GET___review__rs_id_quality_assesment_criteria_ ⇒ Object
List of personalized fields.
-
#GET___review__rs_id_update_field_table_ ⇒ Object
Update analysis table, using information provide on fields.
-
#POST___review__rs_id_new_field_ ⇒ Object
Add a new field.
-
#POST___review__rs_id_new_quality_criterion_ ⇒ Object
Add a new field.
-
#POST___review__sr_id_quality_criterion__qc_id_delete_ ⇒ Object
Delete a quality criteria.
-
#PUT___review__sr_id_edit_quality_criterion__attr_ ⇒ Object
Edit specific attribute of a field.
-
#PUT___review_edit_field__attr_id__attr_ ⇒ Object
Edit specific attribute of a field.
report collapse
-
#GET___review__sr_id_report__type__format_ ⇒ Object
Provide a report.
reflection collapse
-
#GET___admin_authorizations_ ⇒ Object
Get all authorizations used on system.
-
#GET___admin_routes_ ⇒ Object
Get all routes on system.
Inclusion and exclusion criteria collapse
Canonical documents collapse
-
#GET___canonical_document__id_ ⇒ Object
View a Canonical document.
- #GET___canonical_document__id_get_external_data__type_ ⇒ Object
-
#GET___canonical_document__id_search_abstract_scopus_ ⇒ Object
Query Scopus for abstract.
-
#GET___canonical_document__id_search_abstract_semantic_scholar_ ⇒ Object
Query Semantic Scholar for abstract.
-
#GET___canonical_document__id_search_crossref_references_ ⇒ Object
Query crossref for all references of a canonical document.
-
#GET___canonical_document__id_search_similar_ ⇒ Object
Search references similar to a specific canonical documents, using lexical distance.
-
#GET___canonical_document__id_update_using_crossref_info_ ⇒ Object
Update information about a canonical document using crossref information.
-
#GET___canonical_document__id_view_crossref_info_ ⇒ Object
View raw crossref information using the doi of the canonical document.
-
#GET___canonical_document__id_view_pubmed_info_ ⇒ Object
View raw pubmed information using the pmid of the canonical document.
-
#GET___canonical_document__ref_id_clean_references_ ⇒ Object
Reset all references asssigned to a canonical document.
-
#GET___canonical_documents_review__rev_id_automatic_categories_ ⇒ Object
See automatic categories for canonical documents.
- #GET___canonical_documents_review__rev_id_complete_pubmed_pmid_ ⇒ Object
-
#GET___canonical_documents_review__review_id_complete_abstract_scopus_ ⇒ Object
Complete all canonical document abstracts on a systematic review, using Scopus.
-
#POST___canonical_document__id_merge_similar_references_ ⇒ Object
Merge similar references to a specific canonical document.
- #POST___canonical_document_actions_ ⇒ Object
-
#POST___canonical_document_merge_ ⇒ Object
Merge two or more canonical documents.
-
#POST___canonical_document_user_allocation__action_ ⇒ Object
Allocate a canonical document to user, for screening or analyze.
-
#PUT___canonical_document_edit_field__field_ ⇒ Object
Edit a field on a canonical document.
references in searches to reviews collapse
-
#GET___review__id_references_ ⇒ Object
List of canonical documents of a review.
- #GET___review__sr_id_assign_canonical_to_references_ ⇒ Object
- #GET__review__sr_id_reference__ref_id ⇒ Object
- #POST___review__sr_id_create_canonical_for_references_ ⇒ Object
- #POST___review__sr_id_references_actions_ ⇒ Object
Administration of documents without abstract collapse
-
#GET___review__rev_id_stage__stage_complete_empty_abstract_manual_ ⇒ Object
List of documents without abstract.
-
#GET___review__rev_id_stage__stage_complete_empty_abstract_pubmed_ ⇒ Object
Automatic retrieval of abstract from Pubmed for documents without abstract.
-
#GET___review__rev_id_stage__stage_complete_empty_abstract_scopus_ ⇒ Object
Automatic retrieval of abstract from Scopus for documents without abstract.
Quality assesment collapse
-
#GET___review__sr_id_quality_assessment_cd__cd_id_ ⇒ Object
Form to assess quality of a document in stage review full text.
-
#PUT___review__sr_id_quality_assessment_cd__cd_id_user__user_id__action_ ⇒ Object
Update information of a specific quality criterion.
canonical documents assigned to reviews collapse
- #GET___canonical_documents_review__id_check_inconsistencies_ ⇒ Object
- #GET___canonical_documents_review__rs_id_resolve_inconsistencies_decisions__stage_ ⇒ Object
- #GET___canonical_documents_review__rs_id_resolve_inconsistencies_resolutions__stage_ ⇒ Object
-
#GET___review__id_canonical_documents_ ⇒ Object
List of canonical documents of a review.
-
#GET___review__id_repeated_canonical_documents_ ⇒ Object
Get a list of repeated canonical documents, using DOI and metadata.
- #GET__r__review___d___canonical_document___d____cites_cited_by_cited_by_rtr__ ⇒ Object
- #GET__review__sr_id_canonical_document__cd_id ⇒ Object
- #GET__review__sr_id_canonical_document__cd_id_similar ⇒ Object
- #GET__review__sr_id_canonical_documents_import_export ⇒ Object
- #GET__review__sr_id_canonical_documents_tags ⇒ Object
- #POST___review__id_canonical_document_automatic_deduplication__type_ ⇒ Object
- #POST__review__sr_id_canonical_documents_tags_actions ⇒ Object
Data extraction collapse
- #GET___review__sr_id__action_cd__cd_id_by_similarity_ ⇒ Object
-
#GET___review__sr_id_extract_information_cd__cd_id_ ⇒ Object
Form to retrieve information from a document in stage review full text.
-
#PUT___review__sr_id_extract_information_cd__cd_id_user__user_id_update_field_ ⇒ Object
Update information of a specific personalized field.
Import and export decisions collapse
-
#POST___review__sr_id_canonical_documents_import_excel_ ⇒ Object
TODO: The system doesn’t check proper authorization.
- #POST___review__sr_id_canonical_documents_import_excel_reviewed_ ⇒ Object
-
#POST___review_import_decisions_excel_ ⇒ Object
TODO: The system doesn’t check proper authorization.
Instance Method Summary collapse
-
#GET___admin_institutions_ ⇒ Object
Display list of scales.
-
#GET___admin_scales_ ⇒ Object
Display list of scales.
Instance Method Details
#GET____tags__basic____ref___10_json_ ⇒ Object
Retrieve a basic json for autopredict
232 233 234 235 236 |
# File 'controllers/tag.rb', line 232 get /\/tags\/basic_(?:ref_)?10.json/ do halt_unless_auth('review_view') res=Tag.order(:text).limit(10) ds_to_json(res) end |
#GET___admin_authorizations_ ⇒ Object
Get all authorizations used on system
22 23 24 25 26 27 28 29 |
# File 'controllers/admin/reflection.rb', line 22 get '/admin/authorizations' do halt_unless_auth('reflection') auth=Buhos::Reflection.(self) @files=auth.files @permits=auth.permits haml "admin/permits".to_sym, escape_html: false end |
#GET___admin_groups_ ⇒ Object
Display list of groups
11 12 13 14 15 |
# File 'controllers/admin/groups.rb', line 11 get '/admin/groups' do halt_unless_auth('group_admin') @groups=Group.all haml :groups, escape_html: false end |
#GET___admin_institutions_ ⇒ Object
Display list of scales
11 12 13 14 15 |
# File 'controllers/admin/institutions.rb', line 11 get '/admin/institutions' do halt_unless_auth('institution_admin') @scales=Institution.all haml :institutions, escape_html: false end |
#GET___admin_roles_ ⇒ Object
List of roles
11 12 13 14 15 16 |
# File 'controllers/admin/roles.rb', line 11 get '/admin/roles' do halt_unless_auth('role_admin') @roles=Role @authorizations=Authorization.order(:id) haml "admin/roles".to_sym, escape_html: false end |
#GET___admin_routes_ ⇒ Object
Get all routes on system
12 13 14 15 16 17 |
# File 'controllers/admin/reflection.rb', line 12 get '/admin/routes' do halt_unless_auth('reflection') lines = Buhos::Reflection.get_routes(self) "<html><body>#{lines.sort.join('<br/>')}</body></html>" end |
#GET___admin_scales_ ⇒ Object
Display list of scales
11 12 13 14 15 |
# File 'controllers/admin/scales.rb', line 11 get '/admin/scales' do halt_unless_auth('scale_admin') @scales=Scale.all haml :scales, escape_html: false end |
#GET___admin_users___ ⇒ Object
Get list of users
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
# File 'controllers/admin/users.rb', line 151 get '/admin/users/?' do halt_unless_auth('user_admin') @usr_bus=params[:users_search] if(@usr_bus.nil? or @usr_bus=="") @users=User.all else @users=User.filter(Sequel.ilike(:name, "%#{@usr_bus}%")).order(:name) end @have_permit_password = auth_to("user_admin") #log.info(@personas.all) @roles=Role.order() haml :users, escape_html: false end |
#GET___admin_users_batch_edition_ ⇒ Object
11 12 13 14 |
# File 'controllers/admin/users.rb', line 11 get '/admin/users_batch_edition' do halt_unless_auth('user_admin') haml "users/batch_edition".to_sym, escape_html: false end |
#GET___admin_users_batch_edition_excel_export_ ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'controllers/admin/users.rb', line 17 get '/admin/users_batch_edition/excel_export' do require 'caxlsx' halt_unless_auth('user_admin') package = Axlsx::Package.new wb = package.workbook blue_cell = wb.styles.add_style :fg_color => "0000FF", :sz => 14, :alignment => { :horizontal=> :center } wrap_text = wb.styles.add_style alignment: { wrap_text: true } little_text = wb.styles.add_style users=User.where(Sequel.lit("role_id!='administrator'")) institutions=Institution.to_hash(:id,:name) wb.add_worksheet(:name => t(:Users)) do |sheet| header=["id","active","email","institution","language","login","name","password","role_id"] sheet.add_row header, :style=> [blue_cell]*9 users.each do |user| row=[user[:id], user[:active] ? 1:0, user[:email], institutions.fetch(user[:institution_id], nil), user[:language], user[:login], user[:name], nil, user[:role_id]] sheet.add_row row end end headers 'Content-Type' => "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" headers 'Content-Disposition' => "attachment; filename=users.xlsx" package.to_stream end |
#GET___canonical_document__id_ ⇒ Object
View a Canonical document
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'controllers/canonical_document.rb', line 15 get '/canonical_document/:id' do |id| halt_unless_auth('canonical_document_view') @cd=CanonicalDocument[id] raise Buhos::NoCdIdError, id if !@cd @records=@cd.records @references=@cd.references if CrossrefDoi[doi_without_http(@cd.doi)] @cr_doi=@cd.crossref_integrator end if Pmc_Summary[@cd.pubmed_id] @pmc_sum=@cd.pubmed_integrator end @references_realizadas=@cd.references_performed title(t(:canonical_document_title, cd_title:@cd.ref_apa_6)) haml :canonical_document , escape_html: false end |
#GET___canonical_document__id_get_external_data__type_ ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'controllers/canonical_document.rb', line 54 get '/canonical_document/:id/get_external_data/:type' do |id, type| halt_unless_auth('canonical_document_admin') @cd=CanonicalDocument[id] method="#{type}_integrator".to_sym if @cd.respond_to? method begin if @cd.send(method) (t("external_data.get_successful", type:type, cd_id:id)) else (t("external_data.get_error", type:type, cd_id:id)) end rescue Buhos::NoCrossrefConnection => e (t("external_data.get_error", type:e., cd_id:id), :error) end else (t("external_data.dont_know_type"), type: type) end redirect back end |
#GET___canonical_document__id_search_abstract_scopus_ ⇒ Object
Query Scopus for abstract
167 168 169 170 171 |
# File 'controllers/canonical_document.rb', line 167 get '/canonical_document/:id/search_abstract_scopus' do |id| halt_unless_auth('canonical_document_admin') add_result(Scopus_Abstract.get_abstract_cd(id)) redirect back end |
#GET___canonical_document__id_search_abstract_semantic_scholar_ ⇒ Object
Query Semantic Scholar for abstract
175 176 177 178 179 180 |
# File 'controllers/canonical_document.rb', line 175 get '/canonical_document/:id/search_abstract_semantic_scholar' do |id| halt_unless_auth('canonical_document_admin') add_result(Semantic_Scholar_Paper.get_abstract_cd(id)) redirect back end |
#GET___canonical_document__id_search_crossref_references_ ⇒ Object
Query crossref for all references of a canonical document
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'controllers/canonical_document.rb', line 35 get '/canonical_document/:id/search_crossref_references' do |id| halt_unless_auth('canonical_document_admin') @cd=CanonicalDocument[id] result=Result.new references=@cd.references_performed.exclude(:doi=>nil).where(:canonical_document_id=>nil) if references.empty? result.info(I18n::t(:no_references_to_search_on_crossref)) else references.each do |ref| result.add_result(ref.add_doi(ref[:doi])) end end add_result(result) redirect back end |
#GET___canonical_document__id_search_similar_ ⇒ Object
Search references similar to a specific canonical documents, using lexical distance
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'controllers/canonical_document.rb', line 76 get '/canonical_document/:id/search_similar' do |id| halt_unless_auth('canonical_document_admin') @cd=CanonicalDocument[id] raise Buhos::NoCdIdError, id if !@cd @ajax=!params['ajax'].nil? @distancia=params['distancia'].to_i @distancia=30 if @distancia==0 @ref_similares=@cd.search_similar_references(@distancia) ##$log.info(@ref_similares) if @ajax haml "canonical_documents/reference_search_similar".to_sym, :layout=>nil, escape_html: false else haml "canonical_documents/reference_search_similar".to_sym, escape_html: false end end |
#GET___canonical_document__id_update_using_crossref_info_ ⇒ Object
Update information about a canonical document using crossref information
288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 |
# File 'controllers/canonical_document.rb', line 288 get '/canonical_document/:id/update_using_crossref_info' do |id| halt_unless_auth('canonical_document_admin') @cd=CanonicalDocument[id] #$log.info(@cd) raise Buhos::NoCdIdError, id unless @cd @cr_doi=@cd.crossref_integrator if @cr_doi results=@cd.update_info_using_record(@cr_doi) else results=Result.new results.error(I18n::t(:No_DOI_to_obtain_information_from_Crossref)) end $log.info(results) add_result results redirect back end |
#GET___canonical_document__id_view_crossref_info_ ⇒ Object
View raw crossref information using the doi of the canonical document
277 278 279 280 281 282 283 284 |
# File 'controllers/canonical_document.rb', line 277 get '/canonical_document/:id/view_crossref_info' do |id| halt_unless_auth('canonical_document_view') @cd=CanonicalDocument[id] raise Buhos::NoCdIdError, id if !@cd @cr_doi=@cd.crossref_integrator @doi_json=CrossrefDoi[doi_without_http(@cd.doi)][:json] if @cd.doi haml "canonical_documents/view_crossref_info".to_sym, escape_html: false end |
#GET___canonical_document__id_view_pubmed_info_ ⇒ Object
View raw pubmed information using the pmid of the canonical document
310 311 312 313 314 315 316 317 318 319 320 321 |
# File 'controllers/canonical_document.rb', line 310 get '/canonical_document/:id/view_pubmed_info' do |id| halt_unless_auth('canonical_document_view') @cd=CanonicalDocument[id] raise Buhos::NoCdIdError, id if !@cd @pmc_sum=@cd.pubmed_integrator if @cd.pubmed_id @xml=Pmc_Summary[@cd.pubmed_id][:xml] else @xml=nil end haml "canonical_documents/view_pubmed_info".to_sym, escape_html: false end |
#GET___canonical_document__ref_id_clean_references_ ⇒ Object
Reset all references asssigned to a canonical document
183 184 185 186 187 188 189 190 191 |
# File 'controllers/canonical_document.rb', line 183 get '/canonical_document/:ref_id/clean_references' do |cd_id| halt_unless_auth('canonical_document_admin') @cd=CanonicalDocument[cd_id] raise Buhos::NoCdIdError, cd_id if !@cd Reference.where(:canonical_document_id => cd_id).update(:canonical_document_id => nil, :doi => nil) ("Las references para canonico #{cd_id} estan limpias") redirect back end |
#GET___canonical_documents_review__id_check_inconsistencies_ ⇒ Object
221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 |
# File 'controllers/reviews/canonical_documents.rb', line 221 get '/canonical_documents/review/:id/check_inconsistencies' do |id| halt_unless_auth('review_view') @review=SystematicReview[id] raise Buhos::NoReviewIdError, id if !@review @inc_analysis=Buhos::InconsistenciesAnalysis.new(@review) haml "systematic_reviews/canonical_documents_inconsistencies".to_sym, escape_html: false end |
#GET___canonical_documents_review__rev_id_automatic_categories_ ⇒ Object
See automatic categories for canonical documents. Is very experimental. Works so-so
195 196 197 198 199 200 201 202 203 204 |
# File 'controllers/canonical_document.rb', line 195 get '/canonical_documents/review/:rev_id/automatic_categories' do |rev_id| halt_unless_auth('canonical_document_view') @review=SystematicReview[rev_id] @cd_hash=@review.cd_hash #require 'categorize' #modelo=Categorize::Models::Cluster.new #modelo.num_clusters = 20 @categorizador=CategorizerSr.new(@review, nil) haml "systematic_reviews/canonical_documents_automatic_categories".to_sym, escape_html: false end |
#GET___canonical_documents_review__rev_id_complete_pubmed_pmid_ ⇒ Object
206 207 208 209 210 211 212 213 214 |
# File 'controllers/canonical_document.rb', line 206 get '/canonical_documents/review/:rev_id/complete_pubmed_pmid' do |rev_id| @review=SystematicReview[rev_id] halt 500 unless auth_to("pubmed_query") and ( auth_to('review_admin') or review_belongs_to(@review.id, session['user_id'])) # Retrieve all doi we can! @cd_ds=@review.canonical_documents.exclude(:doi=>nil).where(:pubmed_id=>nil) result=PubmedRemote.retrieve_pmid(@cd_ds) add_result(result) redirect back end |
#GET___canonical_documents_review__review_id_complete_abstract_scopus_ ⇒ Object
Complete all canonical document abstracts on a systematic review, using Scopus
153 154 155 156 157 158 159 160 161 162 163 164 |
# File 'controllers/canonical_document.rb', line 153 get '/canonical_documents/review/:review_id/complete_abstract_scopus' do |rev_id| halt_unless_auth('canonical_document_admin') @rev=SystematicReview[rev_id] @cd_wo_abstract=@rev.canonical_documents.where(Sequel.lit("abstract IS NULL OR abstract=''")).select_map(:id) ("Se procesan #{@cd_wo_abstract.count} documentos canonicos") @cd_wo_abstract.each do |cd| add_result(Scopus_Abstract.get_abstract_cd(cd)) end redirect back end |
#GET___canonical_documents_review__rs_id_resolve_inconsistencies_decisions__stage_ ⇒ Object
249 250 251 252 253 254 255 256 257 258 |
# File 'controllers/reviews/canonical_documents.rb', line 249 get '/canonical_documents/review/:rs_id/resolve_inconsistencies_decisions/:stage' do |id,stage| halt_unless_auth('review_view') @review=SystematicReview[id] raise Buhos::NoReviewIdError, id if !@review @inc_analysis=Buhos::InconsistenciesAnalysis.new(@review) result=@inc_analysis.resolve_inconsistencies_decisions(stage) add_result(result) redirect back end |
#GET___canonical_documents_review__rs_id_resolve_inconsistencies_resolutions__stage_ ⇒ Object
238 239 240 241 242 243 244 245 246 247 |
# File 'controllers/reviews/canonical_documents.rb', line 238 get '/canonical_documents/review/:rs_id/resolve_inconsistencies_resolutions/:stage' do |id,stage| halt_unless_auth('review_view') @review=SystematicReview[id] raise Buhos::NoReviewIdError, id if !@review @inc_analysis=Buhos::InconsistenciesAnalysis.new(@review) result=@inc_analysis.resolve_inconsistencies_resolutions(stage) add_result(result) redirect back end |
#GET___decision_review__review_id_user__user_id_canonical_document__cd_id_stage__stage_ ⇒ Object
Retrieve the interface to make decision on a document
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'controllers/decision.rb', line 13 get '/decision/review/:review_id/user/:user_id/canonical_document/:cd_id/stage/:stage' do |review_id, user_id, cd_id, stage| halt_unless_auth('review_view') review=SystematicReview[review_id] cd=CanonicalDocument[cd_id] ars=AnalysisSystematicReview.new(review) usuario=User[user_id] decisions=Decision.where(:user_id => user_id, :systematic_review_id => review_id, :stage => stage).as_hash(:canonical_document_id) if !review or !cd or !usuario return [500, "No existe alguno de los componentes"] end return partial(:decision, :locals => {review: review, cd: cd, decisions: decisions, ars: ars, user_id: user_id, stage: stage}) end |
#GET___file__id_download_ ⇒ Object
Download a file
74 75 76 77 78 79 80 81 82 83 84 |
# File 'controllers/files.rb', line 74 get '/file/:id/download' do |id| halt_unless_auth('file_view') file=IFile[id] return 404 if file.nil? #headers["Content-Disposition"] = "attachment;filename=#{file[:filename]}" content_type file[:filetype] send_file(file.absolute_path(dir_files)) end |
#GET___file__id_download_external_ ⇒ Object
Download a file
107 108 109 110 111 112 113 114 115 116 |
# File 'controllers/files.rb', line 107 get '/file/:id/download_external' do |id| file=IFile[id] return 404 if file.nil? #headers["Content-Disposition"] = "attachment;filename=#{file[:filename]}" content_type file[:filetype] send_file(file.absolute_path(dir_files)) end |
#GET___file__id_page__pagina__format_ ⇒ Object
Get a specific page on a document. Only works on Linux
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 |
# File 'controllers/files.rb', line 121 get '/file/:id/page/:pagina/:format' do |id,pagina,format| halt_unless_auth('file_view') file=IFile[id] pagina=pagina.to_i return 404 if file.nil? filepath=file.absolute_path(dir_files) if file[:filetype]=="application/pdf" begin if format=='text' require 'pdf-reader' reader=PDF::Reader.new(filepath) file.update(:pages=>reader.pages.length) if file[:pages].nil? return I18n::t(:page_doesnt_exists) if reader.pages.length<pagina reader.pages[pagina-1].text elsif format=='image' require 'grim' pdf = Grim.reap(filepath) return I18n::t(:page_doesnt_exists) if pdf.count<pagina or pagina<1 file.update(:pages=>pdf.count) if file[:pages].nil? filepath_image="#{dir_files}/pdf_images/#{file[:sha256][0]}/#{file[:sha256]}_#{pagina}.png" #$log.info(File.dirname(filepath_image)) FileUtils.mkdir_p File.dirname(filepath_image) unless File.exist? File.dirname(filepath_image) #FileUtils.touch filepath_image unless File.exist? filepath_image pdf[pagina-1].save(filepath_image,{ :density=>300, :alpha=>"Set" }) end headers["Content-Disposition"] = "inline;filename=#{File.basename(filepath_image)}" content_type "image/png" send_file(filepath_image) else raise I18n::t(:cant_process) end rescue Grim::UnprocessablePage => e if e.=~/convert: not authorized/ return [500,I18n::t("error.policy_imagemagick", message:e.)] else raise end rescue StandardError =>e halt 500, I18n::t(:generic_error, :message=>e.) end else return 500 end # headers["Content-Disposition"] = "inline;filename=#{file[:filename]}" # content_type file[:filetype] # send_file(file.absolute_path(dir_files)) end |
#GET___file__id_to_text_download_external_ ⇒ Object
Requires poppler-utils on Ubuntu Todo: use pdf-reader
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'controllers/files.rb', line 88 get '/file/:id/to_text/download_external' do |id| file=IFile[id] return 404 if file.nil? if file[:filetype]=~/pdf/ # Ok, this is a hack! temp_pdf=Tempfile.new("file_pdf#{id}") temp_html=Tempfile.new("file_html#{id}") temp_pdf.write(File.read(file.absolute_path(dir_files))) temp_pdf.close `pdftotext -layout #{temp_pdf.path} #{temp_html.path}` temp_pdf.unlink temp_html.close content_type "text/plain" send_file(temp_html.path) end end |
#GET___file__id_view_ ⇒ Object
Retrieves a file, on mode ‘inline’
179 180 181 182 183 184 185 186 187 188 189 |
# File 'controllers/files.rb', line 179 get '/file/:id/view' do |id| halt_unless_auth('file_view') file=IFile[id] return 404 if file.nil? headers["Content-Disposition"] = "inline;filename=#{file[:filename]}" content_type file[:filetype] send_file(file.absolute_path(dir_files)) end |
#GET___files_rs__systematic_review_id_assign_to_canonical_documents_ ⇒ Object
Allocate automatically files to canonical documents
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'controllers/files.rb', line 12 get '/files/rs/:systematic_review_id/assign_to_canonical_documents' do |rs_id| halt_unless_auth('file_admin') rs = SystematicReview[rs_id] raise Buhos::NoReviewIdError, rs_id if !rs require 'pdf-reader' # Solo buscar en los files que no tienen canonico asignado pdf_por_revisar = FileSr.files_wo_cd(rs_id).where(:filetype => 'application/pdf') pdf_por_revisar.each do |pdf| begin pdfp=PdfProcessor.new(pdf.absolute_path(dir_files)) doi=pdfp.get_doi if doi cd = CanonicalDocument.where(:doi => doi) if cd.count > 0 $db.transaction do FileCd.insert(:file_id => pdf[:id], :canonical_document_id => cd.first[:id]) end ("Agregado file #{pdf[:filename]} a canónico #{cd[:title]}") else ("No puedo encontrar doi: #{doi} en los canonicos", :warning) end else ("No puedo encontrar doi en el documento #{pdf[:filename]}", :warning) end rescue StandardError => e $log.error("Error on file: #{pdf[:filename]}") ("Error on file: #{pdf[:filename]}", :error) #raise end end redirect back end |
#GET___group__group_id_delete_ ⇒ Object
modify to use POST or DELETE method
Deletes a group
131 132 133 134 135 136 137 138 139 |
# File 'controllers/admin/groups.rb', line 131 get '/group/:group_id/delete' do |group_id| halt_unless_auth('group_admin') @group=Group[group_id] error(404) unless @group group_name=@group[:name] Group[group_id].delete (t(:Group_deleted, group_name:group_name)) redirect back end |
#GET___group__id_datos_json_ ⇒ Object
Returns a json with information for a group
54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'controllers/admin/groups.rb', line 54 get '/group/:id/datos.json' do |id| halt_unless_auth('group_view') require 'json' @group=Group[id] content_type :json {:id=>id, :name=>@group.name, :group_administrator=>@group.group_administrator, :description=>@group.description, :users=>@group.users_dataset.order(:name).map {|u| {id:u[:id], name:u[:name]}} }.to_json end |
#GET___group_new_ ⇒ Object
Display form to create a new group
28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'controllers/admin/groups.rb', line 28 get '/group/new' do halt_unless_auth('group_admin') Group_I = Struct.new(:id, :name, :description, :group_administrator) @group = Group_I.new('NA', params['name'], params['description'], params['admin_id'] ) @users_id=[] if params['users'] @users_id=params['users'].map {|v| v.to_i} end haml "groups/edit".to_sym, escape_html: false end |
#GET___my_messages_ ⇒ Object
See all messages for a user Alias for ‘/user/:user_id/messages’
97 98 99 |
# File 'controllers/user.rb', line 97 get '/my_messages' do redirect "/user/#{session['user_id']}/messages" end |
#GET___record__id_ ⇒ Object
View a record
12 13 14 15 16 17 18 19 20 21 |
# File 'controllers/records.rb', line 12 get '/record/:id' do |id| halt_unless_auth('record_view') @reg=Record[id] raise Buhos::NoRecordIdError, id if !@reg @references=@reg.references haml "record".to_sym, escape_html: false end |
#GET___record__id_assign_doi__doi_ ⇒ Object
Assign a DOI to a record
38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'controllers/records.rb', line 38 get '/record/:id/assign_doi/:doi' do |id,doi| halt_unless_auth('record_edit') @reg=Record[id] raise Buhos::NoRecordIdError, id if !@reg $db.transaction(:rollback=>:reraise) do doi=doi.gsub("***","/") result=@reg.add_doi(doi) add_result(result) end redirect back end |
#GET___record__id_search_crossref_ ⇒ Object
Query crossref for a given record
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'controllers/records.rb', line 24 get '/record/:id/search_crossref' do |id| halt_unless_auth('record_edit') @reg=Record[id] raise Buhos::NoRecordIdError, id if !@reg @response_crossref=@reg.crossref_query #$log.info(@respuesta) haml "systematic_reviews/record_search_crossref".to_sym, escape_html: false end |
#GET___reference__id_ ⇒ Object
View a reference
14 15 16 17 18 19 20 |
# File 'controllers/references.rb', line 14 get '/reference/:id' do |id| halt_unless_auth('reference_view') @ref=Reference[id] raise Buhos::NoReferenceIdError, id unless @ref @records=@ref.records haml :reference, escape_html: false end |
#GET___reference__id_assign_doi__doi_ ⇒ Object
128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
# File 'controllers/references.rb', line 128 get '/reference/:id/assign_doi/:doi' do |id,doi| halt_unless_auth('reference_edit') url=params['volver_url'] @ref=Reference[id] doi=doi.gsub("***","/") result=@ref.add_doi(doi) add_result(result) if url redirect to(url) else redirect back end end |
#GET___reference__id_search_crossref_ ⇒ Object
check differences with ‘/references/search_crossref_by_doi/:doi
Query crossref for a specific references
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'controllers/references.rb', line 100 get '/reference/:id/search_crossref' do |id| halt_unless_auth('reference_edit') @ref=Reference[id] raise Buhos::NoReferenceIdError, id if !@ref if @ref.doi result=Result.new result.add_result(@ref.add_doi(@ref.doi)) if result.success? add_result(result) redirect back else add_result(result) end end @response_crossref=@ref.crossref_query $log.info(@bib_int) # $log.info(@response_crossref) haml "systematic_reviews/reference_search_crossref".to_sym, escape_html: false end |
#GET___reference__id_search_similar_ ⇒ Object
Search references similar to a specific one
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'controllers/references.rb', line 23 get '/reference/:id/search_similar' do |id| halt_unless_auth('reference_edit') @ref=Reference[id] raise Buhos::NoReferenceIdError, id unless @ref @ajax=!params['ajax'].nil? @distancia=params['distancia'].to_i @distancia=30 if @distancia==0 @ref_similares=@ref.search_similars(@distancia) ##$log.info(@ref_similares) if @ajax haml "systematic_reviews/reference_search_similar".to_sym, :layout=>nil, escape_html: false else haml "systematic_reviews/reference_search_similar".to_sym, escape_html: false end end |
#GET___review__id_administration__stage_ ⇒ Object
Interface to administrate a stage
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'controllers/reviews/administration.rb', line 25 get '/review/:id/administration/:stage' do |id,stage| halt_unless_auth_any('review_admin', 'review_admin_view') @review=SystematicReview[id] raise Buhos::NoReviewIdError, id if !@review @stage=stage @ars=AnalysisSystematicReview.new(@review) @cd_without_allocation=@ars.cd_without_allocations(stage) @text_decision_cd= Buhos::AnalysisCdDecisions.new(@review, stage) @cds_id=@review.cd_id_by_stage(stage) @cds=CanonicalDocument.where(:id=>@cds_id) @files_by_cd=@ars.files_by_cd ## Aquí calcularé cuantos si y no hay por categoría res_stage=@ars.resolution_by_cd(stage) begin @categorizador=CategorizerSr.new(@review) unless stage==:search @aprobacion_categorias=@categorizador.categorias_cd_id.inject({}) {|ac,v| cd_validos=res_stage.keys & (v[1]) n=cd_validos.length if n==0 ac[v[0]] = {n:0, p:nil} else ac[v[0]] = {n:n, p: cd_validos.find_all {|vv| res_stage[vv]=='yes' }.length / n.to_f} end ac } rescue LoadError @categorizador=nil end # $log.info(p_aprobaciones_categoria) @name_stage=get_stage_name(@stage) @user_id=session['user_id'] @modal_files=get_modal_files if %w{screening_title_abstract screening_references review_full_text}.include? stage haml "systematic_reviews/administration_reviews".to_sym, escape_html: false else haml "systematic_reviews/administration_#{stage}".to_sym, escape_html: false end end |
#GET___review__id_administration_stages_ ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'controllers/reviews/administration.rb', line 15 get '/review/:id/administration_stages' do |id| halt_unless_auth_any('review_admin', 'review_admin_view') @review=SystematicReview[id] raise Buhos::NoReviewIdError, id if !@review @ars=AnalysisSystematicReview.new(@review) haml "systematic_reviews/administration_stages".to_sym, escape_html: false end |
#GET___review__id_advance_stage_ ⇒ Object
Go to next stage, if complete
203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 |
# File 'controllers/reviews.rb', line 203 get '/review/:id/advance_stage' do |id| halt_unless_auth('review_admin') @review=SystematicReview[id] raise Buhos::NoReviewIdError, id if !@review @ars=AnalysisSystematicReview.new(@review) if (@ars.stage_complete?(@review.stage)) stage_i=get_stages_ids.index(@review[:stage].to_sym) #$log.info(stage_i) return 405 if stage_i.nil? @review.update(:stage=>get_stages_ids[stage_i+1]) (I18n::t(:stage_complete)) redirect("/review/#{@review[:id]}/administration/#{@review[:stage]}") else (I18n::t(:stage_not_yet_complete), :error) redirect back end end |
#GET___review__id_canonical_documents_ ⇒ Object
List of canonical documents of a review
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'controllers/reviews/canonical_documents.rb', line 12 get '/review/:id/canonical_documents' do |id| halt_unless_auth('review_view') @review=SystematicReview[id] raise Buhos::NoReviewIdError, id if !@review @pager=get_pager @pager.cpp=20 @pager.order||="n_total_references_in__desc" @wo_abstract=params['wo_abstract']=='true' @only_records=params['only_records']=='true' @ars=AnalysisSystematicReview.new(@review) @cd_total_ds=@review.canonical_documents # Repetidos doi @dup_analysis=Buhos::DuplicateAnalysis.new(@cd_total_ds) @cd_rep_doi=@dup_analysis.by_doi ##$log.info(@cd_rep_doi) @url="/review/#{id}/canonical_documents" @cds_pre=@review.canonical_documents.left_join(@review.count_references_bw_canonical, cd_id: Sequel[:canonical_documents][:id]).left_join(@review.count_references_rtr, cd_end: :cd_id) if @pager.query # Code por pager begin sp=Buhos::SearchParser.new if @pager.query=~/\(.+\)/ sp.parse(@pager.query) else sp.parse("title(\"#{@pager.query}\")") end @cds_pre=@cds_pre.where(Sequel.lit(sp.to_sql)) rescue Buhos::SearchParser::ParsingError=> e (e., :error) end # end if @wo_abstract @cds_pre=@cds_pre.where(:abstract=>nil) end if @only_records @cds_pre=@cds_pre.where(:id=>@ars.cd_reg_id) end @cds_total=@cds_pre.count @pager.max_page=(@cds_total/@pager.cpp.to_f).ceil # $log.info(@pager) @order_criteria={:n_references_rtr=>I18n::t(:RTA_references), :n_total_references_in=>t(:Citations), :n_total_references_made=>t(:Outgoing_citations), :title=>t(:Title), :year=> t(:Year), :author=>t(:Author)} @cds=@pager.adjust_page_order(@cds_pre) @ars=AnalysisSystematicReview.new(@review) @user=User[session['user_id']] @tags_a=Buhos::AnalysisTags.new @tags_a.systematic_review_id(@review.id) #$log.info($db[:canonical_documents].all) #$log.info(@cds.all) haml "systematic_reviews/canonical_documents".to_sym, escape_html: false end |
#GET___review__id_dashboard_ ⇒ Object
72 73 74 75 76 77 78 79 80 81 |
# File 'controllers/reviews.rb', line 72 get '/review/:id/dashboard' do |id| halt_unless_auth('review_edit') @review=SystematicReview[id] raise Buhos::NoReviewIdError, id if !@review @user=User[session['user_id']] haml "systematic_reviews/dashboard".to_sym, escape_html: false end |
#GET___review__id_delete_ ⇒ Object
247 248 249 250 251 252 253 254 |
# File 'controllers/reviews.rb', line 247 get '/review/:id/delete' do |id| halt_unless_auth('review_admin') @review=SystematicReview[id] raise Buhos::NoReviewIdError, id if !@review haml "systematic_reviews/delete_warning".to_sym, escape_html: false end |
#GET___review__id_files_ ⇒ Object
List of review files
157 158 159 160 161 162 163 164 165 166 167 168 |
# File 'controllers/reviews.rb', line 157 get '/review/:id/files' do |id| halt_unless_auth('review_view', 'file_view') @review=SystematicReview[id] raise Buhos::NoReviewIdError, id if !@review @file_rs=IFile.join(:file_srs, :file_id => :id).left_join(:file_cds, :file_id => :file_id).where(:systematic_review_id => id).order_by(:filename) @modal_files=get_modal_files @canonical_documents_h=@review.canonical_documents.order(:title).as_hash @cd_validos_id=@review.cd_id_by_stage(@review.stage) @cd_validos=@canonical_documents_h.find_all {|v| @cd_validos_id.include? v[0]}.map{|v| v[1]} @usuario=User[session['user_id']] haml "systematic_reviews/files".to_sym, escape_html: false end |
#GET___review__id_generate_graphml_ ⇒ Object
Generate a GraphML file of all documents on a systematic review. Warning: Could be very big!
17 18 19 20 21 22 23 24 25 26 |
# File 'controllers/reviews/export.rb', line 17 get '/review/:id/generate_graphml' do |id| halt_unless_auth('review_view') @review=SystematicReview[id] raise Buhos::NoReviewIdError, id if !@review headers["Content-Disposition"] = "attachment;filename=graphml_revision_#{id}.graphml" content_type 'application/graphml+xml' graphml=Buhos::GraphML_Builder.new(@review, nil) graphml.generate_graphml end |
#GET___review__id_messages_ ⇒ Object
Messages for a systematic review
12 13 14 15 16 17 18 19 |
# File 'controllers/messages.rb', line 12 get '/review/:id/messages' do |id| halt_unless_auth('review_view') @review=SystematicReview[id] raise Buhos::NoReviewIdError, id if !@review @mensajes_rs=@review..order(Sequel.desc(:time)) @usuario=User[session['user_id']] haml "systematic_reviews/messages".to_sym , escape_html: false end |
#GET___review__id_references_ ⇒ Object
List of canonical documents of a review
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'controllers/reviews/references.rb', line 12 get '/review/:id/references' do |id| halt_unless_auth('review_view') @review=SystematicReview[id] raise Buhos::NoReviewIdError, id if !@review @pager=get_pager @pager.cpp=50 @pager.order||="cited_by_cd_n__desc" @wo_canonical=params['wo_canonical']=='true' #$log.info(@wo_canonical) #@only_records=params['only_records']=='true' @references=@review.bib_references # Repetidos doi @url="/review/#{id}/references" @ref_pre=@references if @pager.query # Code por pager begin sp=Buhos::SearchParser.new if @pager.query=~/\(.+\)/ sp.parse(@pager.query) else sp.parse("text(\"#{@pager.query}\")") end @ref_pre=@ref_pre.where(Sequel.lit(sp.to_sql)) rescue Buhos::SearchParser::ParsingError=> e (e., :error) end # end if @wo_canonical @ref_pre=@ref_pre.where(:canonical_document_id=>nil) end @ref_total=@ref_pre.count @pager.max_page=(@ref_total/@pager.cpp.to_f).ceil # $log.info(@pager) @order_criteria={:cited_by_cd_n=>t(:Citations), :searches_count=>t(:Searches), :text=>t(:Text)} @refs=@pager.adjust_page_order(@ref_pre) @user=User[session['user_id']] cd_ids=@refs.map {|ref|ref[:canonical_document_id]}.find_all{ |cd_id| !cd_id.nil?} @cd_hash=CanonicalDocument.where(id:cd_ids).as_hash(:id) @asr=AnalysisSystematicReview.new(@review) #$log.info(@cd_hash) haml "systematic_reviews/references".to_sym, escape_html: false end |
#GET___review__id_repeated_canonical_documents_ ⇒ Object
Check another ways to deduplicate
Get a list of repeated canonical documents, using DOI and metadata
263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 |
# File 'controllers/reviews/canonical_documents.rb', line 263 get '/review/:id/repeated_canonical_documents' do |id| halt_unless_auth('review_view') @review=SystematicReview[id] raise Buhos::NoReviewIdError, id if !@review @cds=@review.canonical_documents @dup_analysis=Buhos::DuplicateAnalysis.new(@cds) @cd_rep_doi = @dup_analysis.by_doi @cd_rep_scielo = @dup_analysis.by_scielo_id @cd_rep_wos = @dup_analysis.by_wos_id @cd_rep_scopus = @dup_analysis.by_scopus_id @cd_rep_pubmed = @dup_analysis.by_pubmed_id @cd_rep_metadata=@dup_analysis. @cd_hash=@cds.to_hash(:id) @cd_por_doi=CanonicalDocument.where(:doi => @cd_rep_doi, :id=>@cd_hash.keys()).to_hash_groups(:doi, :id) @cd_por_scielo=CanonicalDocument.where(:scielo_id => @cd_rep_scielo, :id=>@cd_hash.keys()).to_hash_groups(:scielo_id, :id) @cd_por_wos=CanonicalDocument.where(:wos_id => @cd_rep_wos, :id=>@cd_hash.keys()).to_hash_groups(:wos_id, :id) @cd_por_scopus=CanonicalDocument.where(:scopus_id => @cd_rep_scopus, :id=>@cd_hash.keys()).to_hash_groups(:scopus_id, :id) @cd_por_pubmed=CanonicalDocument.where(:pubmed_id => @cd_rep_pubmed, :id=>@cd_hash.keys()).to_hash_groups(:pubmed_id, :id) ##$log.info(@cd_por_doi) haml "systematic_reviews/repeated_canonical_documents".to_sym, escape_html: false end |
#GET___review__id_review_full_text_ ⇒ Object
Inteface for stage review full text
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 |
# File 'controllers/reviews/stages.rb', line 108 get '/review/:id/review_full_text' do |id| halt_unless_auth('review_analyze') @review=SystematicReview[id] raise Buhos::NoReviewIdError, id if !@review @user=User[session['user_id']] @user_id=@user[:id] @pager=get_pager([:decision, :tag_select, :search_title]) @pager.order||="year__asc" @order_criteria={:n_references_rtr=>I18n.t(:RTA_references), :title=>I18n.t(:Title), :year=> I18n.t(:Year), :author=>I18n.t(:Author)} @ars=AnalysisSystematicReview.new(@review) @cd_total_ds=@review.canonical_documents @url="/review/#{id}/review_full_text" @ads=AnalysisUserDecision.new(id, @user_id, 'review_full_text') @cds_pre=@ads.canonical_documents.join_table(:left, @review.count_references_rtr_tn.to_sym, cd_end: :id) @assignations=@ads.assignations.to_hash(:canonical_document_id) @decisions=@ads.decisions @cds_total=@cds_pre.count begin @cds=@pager.adapt_ads_cds(@ads, @cds_pre) rescue Buhos::SearchParser::ParsingError => e (e.,:error ) params['query']=nil @cds=@pager.adapt_ads_cds(@ads, @cds_pre, no_query:true) end @a_tags=Buhos::AnalysisTags.new @a_tags.systematic_review_id(@review.id) @a_tags.user_id(@user_id) haml %s{systematic_reviews/review_full_text}, escape_html: false end |
#GET___review__id_screening_references_ ⇒ Object
Inteface for stage screening references
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'controllers/reviews/stages.rb', line 57 get '/review/:id/screening_references' do |id| halt_unless_auth('review_analyze') @review=SystematicReview[id] raise Buhos::NoReviewIdError, id if !@review @usuario=User[session['user_id']] @user_id=@usuario[:id] @pager=get_pager([:decision]) @pager.order||="n_references_rtr__desc" @order_criteria={:n_references_rtr=>I18n.t(:RTA_references), :title=>I18n.t(:Title), :year=> I18n.t(:Year), :author=>I18n.t(:Author)} # $log.info(params) @stage='screening_references' @ars=AnalysisSystematicReview.new(@review) @cd_total_ds=@review.canonical_documents @url="/review/#{id}/screening_references" @ads=AnalysisUserDecision.new(id, @user_id, 'screening_references') @cds_pre=@ads.canonical_documents.join_table(:inner, @review.count_references_rtr_tn.to_sym, cd_end: :id) @decisions=@ads.decisions @cds_total=@cds_pre.count begin @cds=@pager.adapt_ads_cds(@ads, @cds_pre) rescue Buhos::SearchParser::ParsingError => e (e.,:error ) params['query']=nil @cds=@pager.adapt_ads_cds(@ads, @cds_pre, no_query:true) end $log.info(@pager) haml "systematic_reviews/screening_general".to_sym, escape_html: false end |
#GET___review__id_screening_title_abstract_ ⇒ Object
Interface for stage screening titles and abstract
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'controllers/reviews/stages.rb', line 13 get '/review/:id/screening_title_abstract' do |id| halt_unless_auth('review_analyze') @review=SystematicReview[id] raise Buhos::NoReviewIdError, id if !@review @usuario=User[session['user_id']] @user_id=@usuario[:id] @pager=get_pager([:decision]) @pager.order||="year__asc" @order_criteria={:title=>I18n.t(:Title), :year=> I18n.t(:Year), :author=>I18n.t(:Author)} # $log.info(params) @stage='screening_title_abstract' @ars=AnalysisSystematicReview.new(@review) @cd_total_ds=@review.canonical_documents @url="/review/#{id}/#{@stage}" @ads=AnalysisUserDecision.new(id, @user_id,@stage) @cds_pre=@ads.canonical_documents @cds_total=@cds_pre.count @decisions=@ads.decisions begin @cds=@pager.adapt_ads_cds(@ads, @cds_pre) rescue Buhos::SearchParser::ParsingError => e (e.,:error ) params['query']=nil @cds=@pager.adapt_ads_cds(@ads, @cds_pre, no_query:true) end haml "systematic_reviews/screening_general".to_sym, escape_html: false end |
#GET___review__id_search_bibliographic_file_new_ ⇒ Object
Form to create a new search based on bibliographic files
148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
# File 'controllers/reviews/searches.rb', line 148 get '/review/:id/search/bibliographic_file/new' do |id| halt_unless_auth('search_edit') require 'date' @review=SystematicReview[id] raise Buhos::NoReviewIdError, id if !@review @header=t_systematic_review_title(@review[:name], :New_search) @bb_general_id=BibliographicDatabase[:name=>'generic'][:id] @search=Search.new(:user_id=>session['user_id'], :source=>"database_search",:valid=>false, :date_creation=>Date.today, :bibliographic_database_id=>@bb_general_id, :search_type=>"bibliographic_file") @usuario=User[session['user_id']] haml "searches/search_edit".to_sym, escape_html: false end |
#GET___review__id_search_uploaded_files_new_ ⇒ Object
96 97 98 99 100 101 102 |
# File 'controllers/reviews/searches.rb', line 96 get '/review/:id/search/uploaded_files/new' do |id| halt_unless_auth('search_edit') @review=SystematicReview[id] raise Buhos::NoReviewIdError, id if !@review haml "searches/search_uploaded_files".to_sym, escape_html: false end |
#GET___review__id_searches_ ⇒ Object
List of searches
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'controllers/reviews/searches.rb', line 14 get '/review/:id/searches' do |id| halt_unless_auth('review_view') @review=SystematicReview[id] raise Buhos::NoReviewIdError, id if !@review @searches=@review.searches @header=t_systematic_review_title(@review[:name], :systematic_review_searches) @user=User[session['user_id']] #$log.info(@user) @url_back="/review/#{id}/searches" haml "systematic_reviews/searches".to_sym, escape_html: false end |
#GET___review__id_stage__stage_pattern__patron_resolution__resolution_ ⇒ Object
Set a resolution for a given pattern
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'controllers/reviews/administration.rb', line 87 get '/review/:id/stage/:stage/pattern/:patron/resolution/:resolution' do |id,stage,patron_s,resolution| halt_unless_auth_any('review_admin', 'review_admin_view') @review=SystematicReview[id] raise Buhos::NoReviewIdError, id if !@review @ars=AnalysisSystematicReview.new(@review) patron=@ars.pattern_from_s(patron_s) cds=@ars.cd_from_pattern(stage, patron) #$log.info(cds) $db.transaction(:rollback=>:reraise) do cds.each do |cd_id| res=Resolution.where(:systematic_review_id=>id, :canonical_document_id=>cd_id, :stage=>stage) if res.empty? Resolution.insert(:systematic_review_id=>id, :canonical_document_id=>cd_id, :stage=>stage, :resolution=>resolution, :user_id=>session['user_id'], :timestamp=>DateTime.now, :commentary=>"Resuelto en forma masiva en #{DateTime.now.to_s}") else res.update(:resolution=>resolution, :user_id=>session['user_id'], :timestamp=>DateTime.now, :commentary=>"Actualizado en forma masiva en #{DateTime.now.to_s}") end end end (I18n::t("resolution_for_n_documents", resolution:resolution, n:cds.length)) redirect back end |
#GET___review__id_stage__stage_pattern__patron_view_ ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'controllers/reviews/administration.rb', line 71 get '/review/:id/stage/:stage/pattern/:patron/view' do |id,stage,patron_s| halt_unless_auth_any('review_admin', 'review_admin_view') @review=SystematicReview[id] @stage=stage raise Buhos::NoReviewIdError, id if !@review @ars=AnalysisSystematicReview.new(@review) @pattern=@ars.pattern_from_s(patron_s) @pattern_name=@ars.pattern_name(@pattern) @text_decision_cd= Buhos::AnalysisCdDecisions.new(@review, stage) @cds=@ars.cd_from_pattern(stage, @pattern) @user_id=session['user_id'] haml "systematic_reviews/administration_reviews_documents_by_decision".to_sym, escape_html: false end |
#GET___review__id_tags_ ⇒ Object
Get tags and classes of tags for a systematic review
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'controllers/reviews/tags.rb', line 12 get '/review/:id/tags' do |id| halt_unless_auth('review_view') @review=SystematicReview[id] raise Buhos::NoReviewIdError, id if !@review @stages_list={:NIL=>"--Todas--"}.merge(get_stages_names_t) @select_stage=get_xeditable_select(@stages_list, "/tags/classes/edit_field/stage","select_stage") @select_stage.nil_value=:NIL @types_list={general:"General", document:"Documento", relation:"Relación"} @select_type=get_xeditable_select(@types_list, "/tags/classes/edit_field/type","select_type") @tag_estadisticas=@review. haml "systematic_reviews/tags".to_sym, escape_html: false end |
#GET___review__id_tags_user__user_id_ ⇒ Object
Interface for stage screening titles and abstract
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'controllers/reviews/tags.rb', line 32 get '/review/:id/tags/user/:user_id' do |sr_id, user_id| halt_unless_auth('review_analyze') @review=SystematicReview[sr_id] raise Buhos::NoReviewIdError, sr_id if !@review @user=User[user_id] raise Buhos::NoUserIdError, user_id if !@user @a_tags=Buhos::AnalysisTags.new @a_tags.systematic_review_id sr_id @a_tags.user_id user_id @sim_an=Buhos::SimilarAnalysisSr.new(@review) @sim_an.process haml "systematic_reviews/tags_analysis".to_sym, escape_html: false end |
#GET___review__rev_id_administration__stage_cd_assignations_ ⇒ Object
List of allocations of canonical documents to users
332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 |
# File 'controllers/reviews/administration.rb', line 332 get '/review/:rev_id/administration/:stage/cd_assignations' do |rev_id, stage| halt_unless_auth_any('review_admin', 'review_admin_view') @review=SystematicReview[rev_id] raise Buhos::NoReviewIdError, rev_id if !@review @cds_id=@review.cd_id_by_stage(stage) @ars=AnalysisSystematicReview.new(@review) @stage=stage @url="/review/#{rev_id}/administration/#{stage}/cd_assignations" @cds_pre=CanonicalDocument.where(:id=>@cds_id) #.order(:author) @pager=get_pager @pager.order||="title__asc" @order_criteria={:title=>I18n.t(:Title), :year=> I18n.t(:Year), :author=>I18n.t(:Author)} @cds=@pager.adapt_cds(@cds_pre) @type="all" haml "systematic_reviews/cd_assignations_to_user".to_sym, escape_html: false end |
#GET___review__rev_id_administration__stage_cd_assignations_excel__mode_ ⇒ Object
284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 |
# File 'controllers/reviews/administration.rb', line 284 get '/review/:rev_id/administration/:stage/cd_assignations_excel/:mode' do |rev_id, stage, mode| halt_unless_auth_any('review_admin', 'review_admin_view') review=SystematicReview[rev_id] raise Buhos::NoReviewIdError, rev_id if !review cds_id=review.cd_id_by_stage(stage) stage=stage cds=CanonicalDocument.where(:id=>cds_id).order(:author) users_grupos=review.group_users if mode=="save" or mode=="save_only_not_allocated" or mode=="save_only_not_resolved" require 'caxlsx' package = Axlsx::Package.new wb = package.workbook blue_cell = wb.styles.add_style :fg_color => "0000FF", :sz => 14, :alignment => { :horizontal=> :center } wrap_text = wb.styles.add_style alignment: { wrap_text: true } little_text = wb.styles.add_style wb.add_worksheet(:name => t(:Assign)) do |sheet| header=["id","reference"]+users_grupos.map {|v| "[#{v[:id]}] #{v[:name]}"} sheet.add_row header, :style=> [blue_cell]*(2+users_grupos.count) cds.each do |cd| row=[cd[:id], cd.ref_apa_6] user_allocations=AllocationCd.where(:systematic_review_id=>review[:id], :canonical_document_id=>cd[:id], :stage=>stage ).to_hash(:user_id) resolution=Resolution[:systematic_review_id=>review[:id], :canonical_document_id=>cd[:id], :stage=>stage] $log.info(resolution) asignaciones= users_grupos.map {|user| user_allocations[user[:id]].nil? ? 0 : 1 } total=asignaciones.inject(0) {|sum,v|sum+v} if mode=="save" or (mode=="save_only_not_allocated" and total==0) or (mode=="save_only_not_resolved" and not resolution) sheet.add_row row+asignaciones, style: ([wrap_text]*2)+[nil]*users_grupos.count end end sheet.column_widths *([nil, 30]+ [5]*users_grupos.count) sheet.column_widths *([nil, 30]+ [5]*users_grupos.count) end headers 'Content-Type' => "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" headers 'Content-Disposition' => "attachment; filename=cd_assignation_#{rev_id}_#{stage}.xlsx" package.to_stream else raise "Not implemented" end end |
#GET___review__rev_id_administration__stage_cd_without_allocations_ ⇒ Object
357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 |
# File 'controllers/reviews/administration.rb', line 357 get '/review/:rev_id/administration/:stage/cd_without_allocations' do |rev_id, stage| halt_unless_auth_any('review_admin', 'review_admin_view') @review=SystematicReview[rev_id] raise Buhos::NoReviewIdError, rev_id if !@review @ars=AnalysisSystematicReview.new(@review) @cds_id=@ars.cd_without_allocations(stage).map {|cd|cd[:id]} @stage=stage @cds_pre=CanonicalDocument.where(:id=>@cds_id) #.order(:author) @pager=get_pager @pager.order||="title__asc" @order_criteria={:title=>I18n.t(:Title), :year=> I18n.t(:Year), :author=>I18n.t(:Author)} @cds=@pager.adapt_cds(@cds_pre) @type="without_allocation" haml "systematic_reviews/cd_assignations_to_user".to_sym , escape_html: false end |
#GET___review__rev_id_generate_bibtex_ ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'controllers/reviews/export.rb', line 66 get '/review/:rev_id/generate_bibtex' do |rev_id| halt_unless_auth('review_view') @review=SystematicReview[rev_id] raise Buhos::NoReviewIdError, rev_id if !@review canonicos_id=@review.cd_all_id @canonicos_resueltos=CanonicalDocument.where(:id=>canonicos_id).order(:author,:year) bib=BibliographicalImporter::BibTex::Writer.generate(@canonicos_resueltos) headers["Content-Disposition"] = "attachment;filename=systematic_review_#{rev_id}_all.bib" content_type 'text/x-bibtex' bib.to_s end |
#GET___review__rev_id_generate_excel_ ⇒ Object
43 44 45 46 47 48 49 50 51 |
# File 'controllers/reviews/export.rb', line 43 get '/review/:rev_id/generate_excel' do |rev_id| halt_unless_auth('review_view') @review=SystematicReview[rev_id] raise Buhos::NoReviewIdError, rev_id if !@review eb=Buhos::ExcelBuilder.new(@review,nil) eb.generate_excel(true) eb.prepare_stream(self) eb.stream end |
#GET___review__rev_id_reference__ref_id_assign_canonical_document_ ⇒ Object
223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 |
# File 'controllers/reviews.rb', line 223 get '/review/:rev_id/reference/:ref_id/assign_canonical_document' do |rev_id, r_id| halt_unless_auth('reference_edit') @reference=Reference[r_id] raise Buhos::NoReferenceIdError, r_id if @reference.nil? @review=SystematicReview[rev_id] raise Buhos::NoReviewIdError, rev_id if @review.nil? @cds=nil @query=params['query'] if @query @cds=@review.canonical_documents @cds=@cds.where(Sequel.like(:author, "%#{@query['author'].chomp}%")) if @query['author'].to_s!="" @cds=@cds.where(:year=>@query['year']) if @query['year'].to_s!="" @cds=@cds.where(Sequel.like(:title, "%#{@query['title'].chomp}%")) if @query['title'].to_s!="" @cds=@cds.order(:author).limit(20) else @query={} end haml "systematic_reviews/reference_assign_canonical_document".to_sym, escape_html: false end |
#GET___review__rev_id_stage__stage_add_assign_user__user_id__type_ ⇒ Object
Allocate canonical documents to a user if type=‘all’, all documents are allocated if type=‘without_allocation’, only documents without allocation are allocated
385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 |
# File 'controllers/reviews/administration.rb', line 385 get '/review/:rev_id/stage/:stage/add_assign_user/:user_id/:type' do |rev_id, stage, user_id,type| halt_unless_auth('review_admin') @review=SystematicReview[rev_id] raise Buhos::NoReviewIdError, rev_id if !@review if type=='all' @cds_id=@review.cd_id_by_stage(stage) elsif type=='without_allocation' ars=AnalysisSystematicReview.new(@review) @cds_id_previous=ars.cd_id_assigned_by_user(stage,user_id) @cds_id_add=ars.cd_without_allocations(stage).map(:id) @cds_id=(@cds_id_previous+@cds_id_add).uniq end add_result(AllocationCd.update_assignation(rev_id, @cds_id, user_id,stage, 'massive_assigment')) redirect back end |
#GET___review__rev_id_stage__stage_complete_empty_abstract_manual_ ⇒ Object
List of documents without abstract
483 484 485 486 487 488 489 490 491 |
# File 'controllers/reviews/administration.rb', line 483 get '/review/:rev_id/stage/:stage/complete_empty_abstract_manual' do |rev_id, stage| halt_unless_auth_any('review_admin', 'review_admin_view') @review=SystematicReview[rev_id] raise Buhos::NoReviewIdError, rev_id if !@review @ars=AnalysisSystematicReview.new(@review) @stage=stage @cd_wo_abstract=@ars.cd_without_abstract(stage) haml "systematic_reviews/complete_abstract_manual".to_sym, escape_html: false end |
#GET___review__rev_id_stage__stage_complete_empty_abstract_pubmed_ ⇒ Object
Automatic retrieval of abstract from Pubmed for documents without abstract
514 515 516 517 518 519 520 521 522 523 524 525 526 527 |
# File 'controllers/reviews/administration.rb', line 514 get '/review/:rev_id/stage/:stage/complete_empty_abstract_pubmed' do |rev_id, stage| halt_unless_auth('review_admin') @review=SystematicReview[rev_id] raise Buhos::NoReviewIdError, rev_id if !@review @ars=AnalysisSystematicReview.new(@review) result=Result.new @cd_wo_abstract=@ars.cd_without_abstract(stage) (I18n::t(:Processing_n_canonical_documents, count:@cd_wo_abstract.count)) @cd_wo_abstract.each do |cd| result.add_result(PubmedRemote.get_abstract_cd(cd)) end add_result(result) redirect back end |
#GET___review__rev_id_stage__stage_complete_empty_abstract_scopus_ ⇒ Object
Automatic retrieval of abstract from Scopus for documents without abstract
496 497 498 499 500 501 502 503 504 505 506 507 508 509 |
# File 'controllers/reviews/administration.rb', line 496 get '/review/:rev_id/stage/:stage/complete_empty_abstract_scopus' do |rev_id, stage| halt_unless_auth('review_admin') @review=SystematicReview[rev_id] raise Buhos::NoReviewIdError, rev_id if !@review @ars=AnalysisSystematicReview.new(@review) result=Result.new @cd_wo_abstract=@ars.cd_without_abstract(stage) (I18n::t(:Processing_n_canonical_documents, count:@cd_wo_abstract.count)) @cd_wo_abstract.each do |cd| result.add_result(Scopus_Abstract.get_abstract_cd(cd[:id])) end add_result(result) redirect back end |
#GET___review__rev_id_stage__stage_generate_bibtex_ ⇒ Object
Generate a BibTeX file of documents on a specific stage
82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'controllers/reviews/export.rb', line 82 get '/review/:rev_id/stage/:stage/generate_bibtex' do |rev_id, stage| halt_unless_auth('review_view') @review=SystematicReview[rev_id] raise Buhos::NoReviewIdError, rev_id if !@review canonicos_id=@review.cd_id_by_stage(stage) @canonicos_resueltos=CanonicalDocument.where(:id=>canonicos_id).order(:author,:year) bib=BibliographicalImporter::BibTex::Writer.generate(@canonicos_resueltos) headers["Content-Disposition"] = "attachment;filename=systematic_review_#{rev_id}_#{stage}.bib" content_type 'text/x-bibtex' bib.to_s end |
#GET___review__rev_id_stage__stage_generate_crossref_references_ ⇒ Object
Retrieve information from Crossref for all canonical documents approved for a given stage TODO: Move this to independent class
126 127 128 129 130 131 132 |
# File 'controllers/reviews/administration.rb', line 126 get '/review/:rev_id/stage/:stage/generate_crossref_references' do |rev_id,stage| halt_unless_auth_any('review_admin') @review=SystematicReview[rev_id] @stage=stage raise Buhos::NoReviewIdError, id if !@review haml "/systematic_reviews/generate_crossref_references".to_sym, escape_html: false end |
#GET___review__rev_id_stage__stage_generate_crossref_references_stream_ ⇒ Object
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 |
# File 'controllers/reviews/administration.rb', line 134 get '/review/:rev_id/stage/:stage/generate_crossref_references_stream' do |rev_id,stage| halt_unless_auth_any('review_admin') @review=SystematicReview[rev_id] raise Buhos::NoReviewIdError, id if !@review result=Result.new start = request.env['HTTP_LAST_EVENT_ID'] ? request.env['HTTP_LAST_EVENT_ID'].to_i+1 : 0 content_type "text/event-stream" #$log.info("Start:#{start}") stream do |out| begin dois_agregados=0 cd_i=Resolution.where(:systematic_review_id=>rev_id, :resolution=>"yes", :stage=>stage.to_s).map {|v|v [:canonical_document_id]}.uniq if start>=cd_i.length out << "data:CLOSE\n\n" return 200 end start.upto(cd_i.length-1).each do |i| $log.info(i) cd_id=cd_i[i] out << "id: #{i}\n" @cd=CanonicalDocument[cd_id] out << "data: Processing '#{t(:Canonical_document)}:#{@cd[:title]}'\n\n" # first, we process all records pertinent with this canonical document. records=Record.where(:canonical_document_id=>cd_id) out << "data: #{I18n::t(:No_records_search)}\n\n" if records.empty? rcp=RecordCrossrefProcessor.new(records,$db) out << "data: #{rcp.result.}\n\n" result.add_result(rcp.result) if @cd.crossref_integrator begin # Agregar dois a references @cd.references_performed.where(:canonical_document_id=>nil).each do |ref| # primero agregamos doi si podemos # Si tiene doi, tratamos de rp=ReferenceProcessor.new(ref) if ref.doi.nil? dois_agregados+=1 if rp.process_doi end if !ref.doi.nil? res_doi=ref.add_doi(ref[:doi]) out << "data: #{res_doi.}\n\n" result.add_result(res_doi) end end rescue StandardError=>e out << "data: #{e.}\n\n" result.error(e.) end else result.error(I18n::t("error.error_on_add_crossref_for_cd", cd_title:@cd[:title])) end end mes_dois_added=I18n::t(:Search_add_doi_references, :count=>dois_agregados) result.info(mes_dois_added) out << "data: #{mes_dois_added}\n\n" rescue Faraday::ConnectionFailed=>e result.error("#{t(:No_connection_to_crossref)}:#{e.}") end add_result(result) out << "data:CLOSE\n\n" end #redirect back end |
#GET___review__rev_id_stage__stage_generate_doi_list_ ⇒ Object
Generate a list of DOI of documents on a specific stage
101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'controllers/reviews/export.rb', line 101 get '/review/:rev_id/stage/:stage/generate_doi_list' do |rev_id, stage| halt_unless_auth('review_view') @review=SystematicReview[rev_id] raise Buhos::NoReviewIdError, rev_id if !@review canonicos_id=@review.cd_id_by_stage(stage) @canonicos_resueltos=CanonicalDocument.where(:id=>canonicos_id).order(:author,:year).exclude(:doi=>nil) dois=@canonicos_resueltos.map {|v| v.doi}.join("\n") # headers["Content-Disposition"] = "attachment;filename=systematic_review_#{rev_id}_#{stage}.bib" content_type 'text/plain' dois end |
#GET___review__rev_id_stage__stage_generate_excel_ ⇒ Object
55 56 57 58 59 60 61 62 63 |
# File 'controllers/reviews/export.rb', line 55 get '/review/:rev_id/stage/:stage/generate_excel' do |rev_id, stage| halt_unless_auth('review_view') @review=SystematicReview[rev_id] raise Buhos::NoReviewIdError, rev_id if !@review eb=Buhos::ExcelBuilder.new(@review, stage) eb.generate_excel(true) eb.prepare_stream(self) eb.stream end |
#GET___review__rev_id_stage__stage_generate_graphml_ ⇒ Object
Generate a GraphML file of documents on a specific stage.
32 33 34 35 36 37 38 39 40 |
# File 'controllers/reviews/export.rb', line 32 get '/review/:rev_id/stage/:stage/generate_graphml' do |rev_id, stage| halt_unless_auth('review_view') @review=SystematicReview[rev_id] raise Buhos::NoReviewIdError, rev_id if !@review graphml=Buhos::GraphML_Builder.new(@review, stage) graphml.prepare_stream(self) graphml.generate_graphml end |
#GET___review__rev_id_stage__stage_reassign_user__user_id_ ⇒ Object
412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 |
# File 'controllers/reviews/administration.rb', line 412 get '/review/:rev_id/stage/:stage/reassign_user/:user_id' do |rev_id, stage, user_id| halt_unless_auth('review_admin') # Type doesn't have meaning here @review=SystematicReview[rev_id] raise Buhos::NoReviewIdError, rev_id if !@review @user=User[user_id] raise Buhos::NoUserIdError, user_id if !@user @asr=::Analysis_SR_Stage.new(@review, stage) @stage=stage @cdid_abu=@asr.cd_id_assigned_by_user(user_id) @resolved=@asr.cd_resolved_id @assigned_not_resolved_id=@cdid_abu-@resolved @cd_assigned_not_resolved=CanonicalDocument.where(id:@assigned_not_resolved_id).order_by(:year) haml "systematic_reviews/cd_reassignations".to_sym , escape_html: false end |
#GET___review__rev_id_stage__stage_rem_assign_user__user_id__type_ ⇒ Object
Remove all documents allocations from a user
403 404 405 406 407 408 409 410 |
# File 'controllers/reviews/administration.rb', line 403 get '/review/:rev_id/stage/:stage/rem_assign_user/:user_id/:type' do |rev_id, stage, user_id, type| halt_unless_auth('review_admin') # Type doesn't have meaning here @review=SystematicReview[rev_id] raise Buhos::NoReviewIdError, rev_id if !@review add_result(AllocationCd.update_assignation(rev_id, [], user_id,stage)) redirect back end |
#GET___review__review_id_search__search_id_record__record_id_complete_information_ ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'controllers/reviews/searches.rb', line 78 get '/review/:review_id/search/:search_id/record/:record_id/complete_information' do |review_id, search_id, record_id| @review=SystematicReview[review_id] raise Buhos::NoReviewIdError, review_id if !@review @search=Search[search_id] raise Buhos::NoSearchIdError, search_id if !@search @record=Record[record_id] raise Buhos::NoRecordIdError, record_id if !@record @record_search=RecordsSearch[record_id: record_id, search_id:search_id ] raise Buhos::NoRecordSearchIdError, [record_id, search_id] if !@record_search @cd=@record.canonical_document @user=User[params['user_id']] @current_file=get_file_canonical_document(@review,@cd) haml "searches/record_complete_information".to_sym, escape_html: false end |
#GET___review__rs_id_field__fid_delete_ ⇒ Object
Delete a field
73 74 75 76 77 78 79 80 81 |
# File 'controllers/reviews/fields.rb', line 73 get '/review/:rs_id/field/:fid/delete' do |rs_id, fid| halt_unless_auth('review_admin') sr_field=SrField[fid] name=sr_field[:name] return 404 if !sr_field sr_field.delete (t("fields.field_deleted", name:name)) redirect back end |
#GET___review__rs_id_fields_ ⇒ Object
List of personalized fields
13 14 15 16 17 18 19 20 21 22 |
# File 'controllers/reviews/fields.rb', line 13 get '/review/:rs_id/fields' do |rs_id| halt_unless_auth('review_view') @review=SystematicReview[rs_id] raise Buhos::NoReviewIdError, rs_id if !@review @campos=@review.fields @xselect=get_xeditable_select(SrField.types_hash, "/review/edit_field/nil/type", 'select-type') haml %s{systematic_reviews/fields}, escape_html: false end |
#GET___review__rs_id_quality_assesment_criteria_ ⇒ Object
List of personalized fields
13 14 15 16 17 18 19 20 21 |
# File 'controllers/reviews/quality_criteria.rb', line 13 get '/review/:rs_id/quality_assesment_criteria' do |rs_id| halt_unless_auth('review_view') @review=SystematicReview[rs_id] raise Buhos::NoReviewIdError, rs_id if !@review @sr_quality_criteria=SrQualityCriterion.join(:quality_criteria, id: :quality_criterion_id).where(systematic_review_id:rs_id) @xselect=get_xeditable_select(Scale.to_hash, "/review/#{rs_id}/edit_quality_criterion/scale_id", 'select-criteria') haml "systematic_reviews/quality_criteria".to_sym, escape_html: false end |
#GET___review__rs_id_searches_compare_records_ ⇒ Object
Compare records betweeen searches
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 |
# File 'controllers/reviews/searches.rb', line 180 get '/review/:rs_id/searches/compare_records' do |rs_id| halt_unless_auth('search_view') @review=SystematicReview[rs_id] raise Buhos::NoReviewIdError, rs_id if !@review @cds={} @errores=[] @searches_id=@review.searches_dataset.map(:id) n_searches=@searches_id.length @review.searches.each do |search| search.records.each do |registro| rcd_id=registro[:canonical_document_id] if rcd_id @cds[rcd_id]||={:searches=>{}} @cds[rcd_id][:searches][search[:id]]=true else errores.push(registro[:id]) end end end @cds_o=CanonicalDocument.where(:id=>@cds.keys).to_hash(:id) @cds_ordered=@cds.sort_by {|key,a| #$log.info(@searches_id) #$log.info(a) base_n=1+a[:searches].length*(2**(n_searches+1)) #$log.info("Base:#{base_n}") sec_n=(0...n_searches).inject(0) {|total,aa| total+=(a[:searches][@searches_id[aa]].nil? ) ? 0 : 2**aa;total} #$log.info("Sec:#{sec_n}") base_n+sec_n } haml "searches/compare_records".to_sym, escape_html: false end |
#GET___review__rs_id_searches_user__user_id_ ⇒ Object
List of searches for a user
165 166 167 168 169 170 171 172 173 174 175 176 |
# File 'controllers/reviews/searches.rb', line 165 get '/review/:rs_id/searches/user/:user_id' do |rs_id,user_id| halt_unless_auth('review_view') @review=SystematicReview[rs_id] raise Buhos::NoReviewIdError, rs_id if !@review @user=User[user_id] @header=t_systematic_review_title(@review[:name], t(:searches_user, :user_name=>User[user_id][:name]), false) @url_back="/review/#{rs_id}/searches/user/#{user_id}" @searches=@review.searches_dataset.where(:user_id=>user_id) haml "systematic_reviews/searches".to_sym, escape_html: false end |
#GET___review__rs_id_update_field_table_ ⇒ Object
Update analysis table, using information provide on fields
62 63 64 65 66 67 68 69 70 |
# File 'controllers/reviews/fields.rb', line 62 get '/review/:rs_id/update_field_table' do |rs_id| halt_unless_auth('review_admin') @review=SystematicReview[rs_id] raise Buhos::NoReviewIdError, rs_id if !@review @campos=@review.fields SrField.update_table(@review) (t("fields.sr_table_update_success")) redirect back end |
#GET___review__sr_id__action_cd__cd_id_by_similarity_ ⇒ Object
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'controllers/reviews/extract_information.rb', line 88 get '/review/:sr_id/:action/cd/:cd_id/by_similarity' do |sr_id,action, cd_id| halt_unless_auth('review_analyze') return 500, I18n::t(:No_valid_action) unless ['extract_information', 'quality_assessment'].include? action @sr=SystematicReview[sr_id] raise Buhos::NoReviewIdError, sr_id if !@sr @cd=CanonicalDocument[cd_id] raise Buhos::NoCdIdError, cd_id if !@cd @user=User[session['user_id']] @ads=AnalysisUserDecision.new(sr_id, @user[:id], Buhos::Stages::STAGE_REVIEW_FULL_TEXT) undecided=@ads.decision_by_cd.find_all {|v| v[1]==Decision::NO_DECISION}.map {|v|v[0]} if undecided.length==0 (t(:No_undecided_documents_left), :success) redirect url("/review/#{@sr[:id]}/#{Buhos::Stages::STAGE_REVIEW_FULL_TEXT}") else sim_an=Buhos::SimilarAnalysisSr.new(@sr) sim_an.process sato=sim_an.similarity_all_to_one(cd_id).find_all {|v| undecided.include? v[:id]}.sort_by{|a| a[:similarity]}.last redirect url("/review/#{@sr[:id]}/#{action}/cd/#{sato[:id]}") end "" end |
#GET___review__sr_id_assign_canonical_to_references_ ⇒ Object
149 150 151 152 153 154 155 156 157 |
# File 'controllers/reviews/references.rb', line 149 get '/review/:sr_id/assign_canonical_to_references' do |sr_id| halt_unless_auth('review_analyze') @ref_ids=params['references'].split(",") @review=SystematicReview[sr_id] @references=Reference.where(:id=>@ref_ids) raise Buhos::NoReviewIdError, sr_id if !@review haml "systematic_reviews/references_create_canonical_document".to_sym, escape_html: false end |
#GET___review__sr_id_extract_information_cd__cd_id_ ⇒ Object
Form to retrieve information from a document in stage review full text
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'controllers/reviews/extract_information.rb', line 13 get '/review/:sr_id/extract_information/cd/:cd_id' do |sr_id,cd_id| halt_unless_auth('review_view') @sr=SystematicReview[sr_id] raise Buhos::NoReviewIdError, sr_id if !@sr @modal_files=get_modal_files @cd=CanonicalDocument[cd_id] @user=User[session['user_id']] return 404 if @sr.nil? or @cd.nil? @stage='review_full_text' cds_id=@sr.cd_id_by_stage(@stage) if !cds_id.include?(cd_id.to_i) (t(:Canonical_documento_not_assigned_to_this_systematic_review), :error) redirect back end adu=AnalysisUserDecision.new(sr_id, @user[:id], 'review_full_text') if !adu.allocated_to_cd_id(cd_id) (t(:Canonical_documento_not_assigned_to_this_user), :error) redirect back end @files_id=FileCd.where(:canonical_document_id=>cd_id, :not_consider=>false).map(:file_id) @files=IFile.where(:id=>@files_id).as_hash @current_file_id = params['file'] || @files.keys[0] @current_file = @files[@current_file_id] @ars=AnalysisSystematicReview.new(@sr) @ads=AnalysisUserDecision.new(sr_id, @user[:id], @stage) @decisions=@ads.decisions @form_creator=FormBuilder.new(@sr, @cd, @user) @incoming_citations=CanonicalDocument.where(:id=>@ars.incoming_citations(@stage,cd_id)).order(:year,:author) @outgoing_citations=CanonicalDocument.where(:id=>@ars.outgoing_citations(@stage,cd_id)).order(:year,:author) haml "systematic_reviews/cd_extract_information".to_sym, escape_html: false end |
#GET___review__sr_id_quality_assessment_cd__cd_id_ ⇒ Object
Form to assess quality of a document in stage review full text
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'controllers/reviews/quality_assesment.rb', line 13 get '/review/:sr_id/quality_assessment/cd/:cd_id' do |sr_id,cd_id| halt_unless_auth('review_view') @sr=SystematicReview[sr_id] raise Buhos::NoReviewIdError, sr_id if !@sr @modal_files=get_modal_files @cd=CanonicalDocument[cd_id] @user=User[session['user_id']] return 404 if @sr.nil? or @cd.nil? @stage='review_full_text' cds_id=@sr.cd_id_by_stage(@stage) if !cds_id.include?(cd_id.to_i) (t(:Canonical_documento_not_assigned_to_this_systematic_review), :error) redirect back end adu=AnalysisUserDecision.new(sr_id, @user[:id], 'review_full_text') if !adu.allocated_to_cd_id(cd_id) (t(:Canonical_documento_not_assigned_to_this_user), :error) redirect back end @files_id=FileCd.where(:canonical_document_id=>cd_id, :not_consider=>false).map(:file_id) @files=IFile.where(:id=>@files_id).as_hash @current_file_id = params['file'] || @files.keys[0] @current_file = @files[@current_file_id] @ars=AnalysisSystematicReview.new(@sr) @ads=AnalysisUserDecision.new(sr_id, @user[:id], @stage) @decisions=@ads.decisions @sr_quality_criteria=SrQualityCriterion.join(:quality_criteria, id: :quality_criterion_id).where(systematic_review_id:sr_id) @scales_types=@sr_quality_criteria.map {|v| v[:scale_id]}.uniq @xselect_a=@scales_types.inject({}) {|ac,v| ac[v]=get_xeditable_select(Scale[v].items_hash, "/review/#{sr_id}/quality_assessment/cd/#{@cd[:id]}/user/#{@user[:id]}/evaluation", "scale-#{v}") ac } @url_commentary= "/review/#{sr_id}/quality_assessment/cd/#{@cd[:id]}/user/#{@user[:id]}/commentary" @cd_qc=CdQualityCriterion.where(systematic_review_id:sr_id, user_id:@user[:id], canonical_document_id:@cd[:id]).to_hash(:quality_criterion_id) $log.info(@cd_qc) haml "systematic_reviews/quality_assessment".to_sym, escape_html: false end |
#GET___review__sr_id_report__type__format_ ⇒ Object
Provide a report
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'controllers/reviews/reports.rb', line 13 get '/review/:sr_id/report/:type/:format' do |sr_id,type,format| halt_unless_auth('review_view') @sr=SystematicReview[sr_id] raise Buhos::NoReviewIdError, sr_id if !@sr @type=type return 404 if @sr.nil? @report=ReportBuilder.get_report(@sr, @type, self) if format=='html' haml "/reports/#{type.downcase}".to_sym, :escape_html=>false else @report.output(format) end end |
#GET___review__sr_id_stage__stage_import_export_decisions_ ⇒ Object
274 275 276 277 278 279 280 281 282 |
# File 'controllers/reviews/administration.rb', line 274 get '/review/:sr_id/stage/:stage/import_export_decisions' do |sr_id, stage| halt_unless_auth_any('review_admin', 'review_admin_view') @review=SystematicReview[sr_id] raise Buhos::NoReviewIdError, sr_id if !@review @stage=stage.to_sym @name_stage=get_stage_name(@stage) haml "systematic_reviews/administration_import_export_decisions".to_sym, escape_html: false end |
#GET___review_new_ ⇒ Object
Form to create a new systematic review
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'controllers/reviews.rb', line 32 get '/review/new' do halt_unless_auth('review_edit') require 'date' title(t(:Systematic_review_new)) first_group=User[session['user_id']].groups.first if first_group.nil? (I18n::t(:user_should_be_included_in_one_group_at_least), :error) redirect back end @current_year=DateTime.now.year administrator=first_group[:group_administrator] @review=SystematicReview.new( active: true, stage: "search", group: first_group, sr_administrator: administrator, date_creation: Date.today, year_start: @current_year, year_end: @current_year ) @taxonomy_categories_id=[] haml "systematic_reviews/edit".to_sym, escape_html: false end |
#GET___reviews_ ⇒ Object
Get a list of systematic Reviews
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'controllers/reviews.rb', line 11 get '/reviews' do halt_unless_auth('review_view') @user=User[session['user_id']] @show_inactives=params['show_inactives'] @show_inactives||='only_actives' @show_only_user=params['show_only_user'] @show_only_user||='yes' if @show_only_user=='yes' @reviewes=SystematicReview.get_reviews_by_user(@user.id) else @reviewes=SystematicReview end @reviewes=@reviewes.where(:active => 1) if @show_inactives=='only_actives' haml :reviews, escape_html: false end |
#GET___role__id_ ⇒ Object
Information about a role
36 37 38 39 40 41 42 43 44 |
# File 'controllers/admin/roles.rb', line 36 get '/role/:id' do |role_id| halt_unless_auth('role_view') @role=Role[role_id] raise Buhos::NoRoleIdError, role_id if @role.nil? @authorizations=Authorization.order(:id) haml "admin/role_view".to_sym, escape_html: false end |
#GET___role__role_id_edit_ ⇒ Object
Form to update a role
48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'controllers/admin/roles.rb', line 48 get '/role/:role_id/edit' do |role_id| halt_unless_auth('role_admin') halt 403, t(:"sinatra_auth.nobody_can_edit_these_roles") if ["administrator","analyst"].include? role_id @role=Role[role_id] @authorizations=Authorization.order(:id) return 404 if @role.nil? haml "admin/role_edit".to_sym, escape_html: false end |
#GET___role_new_ ⇒ Object
Form to create a new role
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'controllers/admin/roles.rb', line 21 get '/role/new' do halt_unless_auth('role_admin') role_id="Role #{Digest::SHA1.hexdigest(DateTime.now.to_s)}" Role.unrestrict_primary_key @role=Role.create({:id=>role_id, :description=>I18n::t('Description')}) @authorizations=Authorization.order(:id) haml "admin/role_edit".to_sym, escape_html: false end |
#GET___search__id_ ⇒ Object
View search
12 13 14 15 16 17 18 19 |
# File 'controllers/search.rb', line 12 get '/search/:id' do |id| halt_unless_auth('search_view') @search=Search[id] raise Buhos::NoSearchIdError, id if @search.nil? @review=@search.systematic_review haml "searches/search_view".to_sym, escape_html: false end |
#GET___search__id_edit_ ⇒ Object
Form to edit a search
22 23 24 25 26 27 28 29 |
# File 'controllers/search.rb', line 22 get '/search/:id/edit' do |id| halt_unless_auth('search_edit') @search=Search[id] raise Buhos::NoSearchIdError, id if @search.nil? @review=@search.systematic_review haml "searches/search_edit".to_sym, escape_html: false end |
#GET___search__id_file_download_ ⇒ Object
Download the file allocated to a search
33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'controllers/search.rb', line 33 get '/search/:id/file/download' do |id| halt_unless_auth('search_view') @search=Search[id] raise Buhos::NoSearchIdError, id if @search.nil? if @search[:filename].nil? return 404 else headers["Content-Disposition"] = "attachment; filename=#{@search[:filename]}" content_type @search[:filetype] @search[:file_body] end end |
#GET___search__id_invalidate_ ⇒ Object
Invalidate a specific search
251 252 253 254 255 256 |
# File 'controllers/search.rb', line 251 get '/search/:id/invalidate' do |id| halt_unless_auth('search_edit') Search[id].update(:valid=>false) (I18n::t(:Search_marked_as_invalid)) redirect back end |
#GET___search__id_records_ ⇒ Object
List of records for a search
49 50 51 52 53 54 55 56 57 58 |
# File 'controllers/search.rb', line 49 get '/search/:id/records' do |id| halt_unless_auth('search_view') @search=Search[id] raise Buhos::NoSearchIdError, id if @search.nil? @review=@search.systematic_review @records=@search.records_dataset.order(:author) haml "searches/search_records".to_sym, escape_html: false end |
#GET___search__id_records_complete_doi_ ⇒ Object
Complete the information for each Record, using Crossref
99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'controllers/search.rb', line 99 get '/search/:id/records/complete_doi' do |id| halt_unless_auth('search_edit') @search=Search[id] raise Buhos::NoSearchIdError, id if @search.nil? @records=@search.records_dataset rcp=RecordCrossrefProcessor.new(@records,$db) #$log.info(rcp.result) add_result(rcp.result) redirect back end |
#GET___search__id_references_ ⇒ Object
List of references for a search
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'controllers/search.rb', line 75 get '/search/:id/references' do |id| halt_unless_auth('search_view') @search=Search[id] raise Buhos::NoSearchIdError, id if @search.nil? @review=@search.systematic_review @references=@search.references @references_con_canonico=@search.references.where(Sequel.lit("canonical_document_id IS NOT NULL")) @references_solo_doi=@search.references.where(Sequel.lit("canonical_document_id IS NULL AND doi IS NOT NULL")) @n_references = params['n_references'].nil? ? 20 : params['n_references'] @rmc_canonico = @search.references_with_canonical_n(@n_references) @rmc_sin_canonico = @search.references_wo_canonical_n(@n_references) @rmc_sin_canonico_con_doi = @search.references_wo_canonical_w_doi_n(@n_references) ##$log.info(@rmc_canonico) haml "searches/search_references".to_sym, escape_html: false end |
#GET___search__id_references_generate_canonical_doi__n_ ⇒ Object
Join canonicals to references
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
# File 'controllers/search.rb', line 135 get '/search/:id/references/generate_canonical_doi/:n' do |id, n| halt_unless_auth('search_edit') @search=Search[id] raise Buhos::NoSearchIdError, id if @search.nil? col_dois=@search.references_wo_canonical_w_doi_n(n) result=Result.new col_dois.each do |col_doi| Reference.where(:doi => col_doi[:doi]).each do |ref| result.add_result(ref.add_doi(col_doi[:doi])) end end add_result(result) redirect back end |
#GET___search__id_references_search_doi_ ⇒ Object
Search on each reference a posible DOI string @todo: Should be integrated on a better way
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'controllers/search.rb', line 117 get '/search/:id/references/search_doi' do |id| halt_unless_auth('search_edit') exitos=0 @search=Search[id] raise Buhos::NoSearchIdError, id if @search.nil? @references=@search.references.where(:doi=>nil) $db.transaction do @references.each do |reference| rp=ReferenceProcessor.new(reference) exitos+=1 if rp.process_doi end end (I18n::t(:Search_add_doi_references, :count=>exitos)) redirect back end |
#GET___search__id_validate_ ⇒ Object
Validate a specific search
243 244 245 246 247 248 |
# File 'controllers/search.rb', line 243 get '/search/:id/validate' do |id| halt_unless_auth('search_edit') Search[id].update(:valid=>true) (I18n::t(:Search_marked_as_valid)) redirect back end |
#GET___search__s_id_record__r_id_ ⇒ Object
Retrieve a single record from a search
62 63 64 65 66 67 68 69 70 71 72 |
# File 'controllers/search.rb', line 62 get '/search/:s_id/record/:r_id' do |s_id, r_id| halt_unless_auth('search_view') @search=Search[s_id] raise Buhos::NoSearchIdError, s_id if @search.nil? @reg=Record[r_id] raise Buhos::NoRecordIdError, r_id if @reg.nil? @review=@search.systematic_review @references=@reg.references haml "record".to_sym, escape_html: false end |
#GET___tag__tag_id_rs__rs_id_cds_ ⇒ Object
Retrieve canonical document what uses a tag, for a given user
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
# File 'controllers/tag.rb', line 110 get '/tag/:tag_id/rs/:rs_id/cds' do |tag_id, rs_id| halt_unless_auth('review_view') @tag=Tag[tag_id] raise Buhos::NoTagIdError, tag_id if !@tag @review=SystematicReview[rs_id] raise Buhos::NoReviewIdError, rs_id if !@review @ars=AnalysisSystematicReview.new(@review) @usuario=User[session['user_id']] @analysis_tag=Buhos::AnalysisTags.new @analysis_tag.systematic_review_id(@review.id) #@analysis_tag.user_id(@usuario.id) @analysis_tag.tag_id(tag_id) @cds_id=@analysis_tag..group_by(:canonical_document_id).map{|v| v[:canonical_document_id]} @cds_pre=CanonicalDocument.where(:id=>@cds_id) @pager=get_pager @pager.order||="year__asc" @order_criteria={:title=>I18n.t(:Title), :year=> I18n.t(:Year), :author=>I18n.t(:Author)} @cds=@pager.adapt_cds(@cds_pre) @url="/tag/#{tag_id}/rs/#{rs_id}/cds" haml '/tags/rs_cds'.to_sym, escape_html: false end |
#GET___tag__tag_id_rs__rs_id_stage__stage_cds_ ⇒ Object
Retrieve canonical document what uses a tag on a specific stage
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'controllers/tag.rb', line 79 get '/tag/:tag_id/rs/:rs_id/stage/:stage/cds' do |tag_id, rs_id, stage| halt_unless_auth('review_view') @tag=Tag[tag_id] raise Buhos::NoTagIdError, tag_id if !@tag @review=SystematicReview[rs_id] raise Buhos::NoReviewIdError, rs_id if !@review @ars=AnalysisSystematicReview.new(@review) @usuario=User[session['user_id']] @stage=stage @cds_tag=TagInCd.cds_rs_tag(@review,@tag,false,stage) @cds_pre=CanonicalDocument.where(:id=>@cds_tag.map(:id)) @pager=get_pager @pager.order||="year__asc" @order_criteria={:title=>I18n.t(:Title), :year=> I18n.t(:Year), :author=>I18n.t(:Author)} @cds=@pager.adapt_cds(@cds_pre) @url="/tag/#{tag_id}/rs/#{rs_id}/stage/#{stage}/cds" haml '/tags/rs_cds'.to_sym, escape_html: false end |
#GET___tags_query_json__query_ ⇒ Object
Query for tags (canonical documents)
240 241 242 243 244 245 246 |
# File 'controllers/tag.rb', line 240 get '/tags/query_json/:query' do |query| halt_unless_auth('review_view') res=$db["SELECT id, text,COUNT(*) as n from tags t INNER JOIN tag_in_cds tec ON t.id=tec.tag_id WHERE INSTR(text,?)>0 and decision='yes' GROUP BY t.text ORDER BY n DESC LIMIT 10", query] ds_to_json(res) end |
#GET___tags_refs_query_json__query_ ⇒ Object
Query for tags (relation between canonical documents)
250 251 252 253 254 255 |
# File 'controllers/tag.rb', line 250 get '/tags/refs/query_json/:query' do |query| halt_unless_auth('review_view') res=$db["SELECT id, text,COUNT(*) as n from tags t INNER JOIN tag_bw_cds tec ON t.id=tec.tag_id WHERE INSTR(text,?)>0 and decision='yes' GROUP BY t.text ORDER BY n DESC LIMIT 10", query] ds_to_json(res) end |
#GET___tags_systematic_review__rs_id_query_json__query_ ⇒ Object
Query for tags (canonical documents on a specific systematic review)
260 261 262 263 264 265 266 |
# File 'controllers/tag.rb', line 260 get '/tags/systematic_review/:rs_id/query_json/:query' do |rs_id,query| halt_unless_auth('review_view') res=$db["SELECT id, text,COUNT(*) as n from tags t INNER JOIN tag_in_cds tec ON t.id=tec.tag_id WHERE INSTR(text,?)>0 and decision='yes' and systematic_review_id=? GROUP BY t.text ORDER BY n DESC LIMIT 10", query, rs_id ] ds_to_json(res) end |
#GET___tags_systematic_review__rs_id_ref_query_json__query_ ⇒ Object
Query for tags (relation between canonical documents on a specific systematic review)
272 273 274 275 276 277 278 |
# File 'controllers/tag.rb', line 272 get '/tags/systematic_review/:rs_id/ref/query_json/:query' do |rs_id,query| halt_unless_auth('review_view') res=$db["SELECT id, text,COUNT(*) as n from tags t INNER JOIN tag_bw_cds tec ON t.id=tec.tag_id WHERE INSTR(text,?)>0 and decision='yes' and systematic_review_id=? GROUP BY t.text ORDER BY n DESC LIMIT 10", query, rs_id ] ds_to_json(res) end |
#GET___user__user_id_ ⇒ Object
View and edit user attributes
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'controllers/user.rb', line 13 get '/user/:user_id' do |user_id| if user_id=='new' halt_unless_auth('user_admin') new_user_id=User.create_new_user(session['language']) @usuario=User[new_user_id] else @usuario=User[user_id] end raise Buhos::NoUserIdError, user_id if !@usuario # Debo reemplazar por las elecciones de acuerdo a equipo @have_permit = auth_to("user_admin") or is_session_user(@usuario.id) @rss=@usuario.systematic_reviews.where(:active=>true) @select_role=get_xeditable_select(Hash[Role.map{ |r| [r[:id], r[:id]] }],'/user/edit/role_id','select_role') @select_role.active=false if(!auth_to("user_admin") or user_id.to_i==session['user_id']) @select_active_user=get_xeditable_select_bool('/user/edit/active','select_active') @select_active_user.active=false if(!auth_to("user_admin") or user_id.to_i==session['user_id']) @select_language=get_xeditable_select(available_locales_hash, '/user/edit/language','select_language') @select_language.active=false if(!auth_to("user_admin") and user_id.to_i!=session['user_id']) haml :user, escape_html: false end |
#GET___user__user_id_change_password_ ⇒ Object
Form to change password
64 65 66 67 68 69 70 71 72 |
# File 'controllers/user.rb', line 64 get '/user/:user_id/change_password' do |user_id| @user=User[user_id] raise Buhos::NoUserIdError, user_id if !@user return 403 unless (is_session_user(user_id) or auth_to("user_admin")) haml "users/change_password".to_sym, escape_html: false end |
#GET___user__user_id_compose_message_ ⇒ Object
Compose a personal message
127 128 129 130 131 132 133 134 135 136 137 |
# File 'controllers/user.rb', line 127 get '/user/:user_id/compose_message' do |user_id| @user=User[user_id] raise Buhos::NoUserIdError, user_id if !@user return 403 unless (auth_to('message_edit') and is_session_user(user_id)) @ms_id="NEW" @ms_text="" haml "users/compose_message".to_sym, escape_html: false end |
#GET___user__user_id_edit_ ⇒ Object
An alias to /user/:user_id
43 44 45 46 |
# File 'controllers/user.rb', line 43 get '/user/:user_id/edit' do |user_id| halt 403 unless (auth_to('user_admin') or is_session_user(user_id)) redirect "/user/#{user_id}" end |
#GET___user__user_id_messages_ ⇒ Object
Get all user messages
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'controllers/user.rb', line 108 get '/user/:user_id/messages' do |user_id| @user=User[user_id] halt 403 unless (is_session_user(user_id) or auth_to("message_view")) raise Buhos::NoUserIdError, user_id if !@user @messages_personal=Message.where(:user_to=>user_id).order(Sequel.desc(:time)) @messages_personal_sent=Message.where(:user_from=>user_id).order(Sequel.desc(:time)) @n_not_readed=@messages_personal.where(:viewed=>false).count @srs=@user.systematic_reviews haml "users/messages".to_sym, escape_html: false end |
#GET___ViewerJS__ ⇒ Object
Get ViewerJS
52 53 54 55 |
# File 'controllers/files.rb', line 52 get '/ViewerJS/' do halt_unless_auth('file_view') send_file("#{dir_base}/public/ViewerJS/index.html") end |
#GET___ViewerJS___file__id_download_ ⇒ Object
Get a file. We need this strange form to do it because ViewerJS ask for it
59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'controllers/files.rb', line 59 get '/ViewerJS/..file/:id/download' do |id| halt_unless_auth('file_view') file=IFile[id] return 404 if file.nil? #headers["Content-Disposition"] = "attachment;filename=#{file[:filename]}" content_type file[:filetype] # $log.info(File.size(file.absolute_path(dir_files))) send_file(file.absolute_path(dir_files)) end |
#GET__group__id ⇒ Object
Display information for a group
44 45 46 47 48 49 |
# File 'controllers/admin/groups.rb', line 44 get "/group/:id" do |id| halt_unless_auth('group_view') @group=Group[id] @users_id=@group.users.map {|v| v.id} haml "groups/view".to_sym, escape_html: false end |
#GET__group__id_edit ⇒ Object
Display form to edit a group
19 20 21 22 23 24 |
# File 'controllers/admin/groups.rb', line 19 get "/group/:id/edit" do |id| halt_unless_auth('group_admin') @group=Group[id] @users_id=@group.users.map {|v| v.id} haml "groups/edit".to_sym, escape_html: false end |
#GET__r__review___d______searches___records____user___d_____ ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'controllers/reviews/searches.rb', line 54 get %r{/review/(\d+)/(?:searches/)?records(?:/user/(\d+))?} do halt_unless_auth('record_view') review_id, user_id=params['captures'] @review=SystematicReview[review_id] raise Buhos::NoReviewIdError, review_id if !@review records_base=Record.select(:record_id, :search_id, :canonical_document_id).join(:records_searches, record_id: :id).join(:searches, id: :search_id).distinct if user_id @users=nil @user=User[user_id] @records=records_base.where(systematic_review_id:review_id, user_id:user_id) @sv=SearchValidatorUser.new(@review, @user) else @user=nil @records=records_base.where(systematic_review_id:review_id) @users=@records.map {|v| v[:user_id]}.uniq @sv=SearchValidatorReview.new(@review) end @sv.validate @cds=CanonicalDocument.where(:id=>@records.map {|v| v[:canonical_document_id]}.uniq).to_hash # $log.info(@cds) haml "searches/records".to_sym, escape_html: false end |
#GET__r__review___d___canonical_document___d____cites_cited_by_cited_by_rtr__ ⇒ Object
206 207 208 209 210 211 212 213 214 215 216 217 218 |
# File 'controllers/reviews/canonical_documents.rb', line 206 get %r{/review/(\d+)/canonical_document/(\d+)/(cites|cited_by|cited_by_rtr)} do halt_unless_auth('review_view') @sr_id=params[:captures][0] @cd_id=params[:captures][1] @type=params[:captures][2] @sr=SystematicReview[@sr_id] raise Buhos::NoReviewIdError, sr_id if !@sr @cd=CanonicalDocument[@cd_id] raise Buhos::NoCdIdError, @cd_id if !@cd @rwc= AnalysisSystematicReview.reference_between_canonicals(@sr) @cd_to_show=@rwc.send(@type.to_sym, @cd_id) haml "systematic_reviews/canonical_document_cites".to_sym, escape_html: false end |
#GET__r__review___d___searches_analyze___________ ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'controllers/reviews/searches.rb', line 33 get %r{/review/(\d+)/searches/analyze(?:/(.*))?} do sr_id, search_ids=params['captures'] @review=SystematicReview[sr_id] raise Buhos::NoReviewIdError, sr_id if !@review if search_ids.to_s!="" @searches=Search.where(:id=>search_ids.split(",")) else @searches=Search.where(:systematic_review_id=>sr_id) end @an_searches=Buhos::AnalysisSearches.new(@searches) @searches_id=@an_searches.searches_id.join(", ") haml "searches/analyze".to_sym, escape_html: false end |
#GET__review__id ⇒ Object
View a specific review
58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'controllers/reviews.rb', line 58 get "/review/:id" do |id| halt_unless_auth('review_view') @review=SystematicReview[id] ##$log.info(@names_trs) raise Buhos::NoReviewIdError, id if !@review # return 404 if !@review @taxonomy_categories = @review.taxonomy_categories_hash @criteria = @review.criteria_hash haml "systematic_reviews/view".to_sym, escape_html: false end |
#GET__review__id_edit ⇒ Object
Form to edit a specific review
84 85 86 87 88 89 90 91 92 |
# File 'controllers/reviews.rb', line 84 get "/review/:id/edit" do |id| halt_unless_auth('review_edit') @review=SystematicReview[id] raise Buhos::NoReviewIdError, id if !@review @taxonomy_categories_id=@review.taxonomy_categories_id title(t(:Systematic_review_edit, sr_name:@review.name)) haml "systematic_reviews/edit".to_sym, escape_html: false end |
#GET__review__sr_id_canonical_document__cd_id ⇒ Object
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 |
# File 'controllers/reviews/canonical_documents.rb', line 148 get "/review/:sr_id/canonical_document/:cd_id" do |sr_id, cd_id| halt_unless_auth('review_view') @sr_id=sr_id @cd_id=cd_id @review=SystematicReview[@sr_id] raise Buhos::NoReviewIdError, sr_id if !@review @cd=CanonicalDocument[@cd_id] raise Buhos::NoCdIdError, cd_id if !@cd title(t(:canonical_document_title, cd_title:@cd.ref_apa_6)) @rs_cds=@review.cd_hash # TODO: Should be refactored on independent method @records= Record.where(id:$db["SELECT rs.record_id from records_searches rs INNER JOIN searches s ON rs.search_id=s.id WHERE s.valid=1 AND s.systematic_review_id=?", @review.id].map(:record_id), canonical_document_id:@cd_id).order(:author, :year) @references=Reference.where(id:$db["SELECT DISTINCT(rr.reference_id) as ref_id FROM records_references rr INNER JOIN records_searches rs ON rr.record_id=rs.record_id INNER JOIN searches s ON rs.search_id=s.id WHERE s.valid=1 and s.systematic_review_id=?", @review.id].map(:ref_id), canonical_document_id:@cd_id).order(:text) if CrossrefDoi[doi_without_http(@cd.doi)] @cr_doi=@cd.crossref_integrator end if Pmc_Summary[@cd.pubmed_id] @pmc_sum=@cd.pubmed_integrator end @asr=AnalysisSystematicReview.new(@review) #@sim_all=Buhos::SimilarAnalysisSr.similar_to_cd_in_sr( cd:@cd, sr:@review) @references_realizadas=@cd.references_performed haml :canonical_document, escape_html: false end |
#GET__review__sr_id_canonical_document__cd_id_similar ⇒ Object
186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 |
# File 'controllers/reviews/canonical_documents.rb', line 186 get "/review/:sr_id/canonical_document/:cd_id/similar" do |sr_id, cd_id| halt_unless_auth('review_view') @sr_id=sr_id @cd_id=cd_id @review=SystematicReview[@sr_id] raise Buhos::NoReviewIdError, sr_id if !@review @cd=CanonicalDocument[@cd_id] raise Buhos::NoCdIdError, cd_id if !@cd @rs_cds=@review.cd_hash title(t(:Similar_canonical_documents)) @sim_all=Buhos::SimilarAnalysisSr.similar_to_cd_in_sr( cd:@cd, sr:@review) @references_realizadas=@cd.references_performed haml "canonical_documents/similar".to_sym, escape_html: false end |
#GET__review__sr_id_canonical_documents_import_export ⇒ Object
92 93 94 95 96 97 98 99 100 101 |
# File 'controllers/reviews/canonical_documents.rb', line 92 get "/review/:sr_id/canonical_documents/import_export" do |sr_id| halt_unless_auth('review_view') @sr_id=sr_id @review=SystematicReview[@sr_id] raise Buhos::NoReviewIdError, sr_id if !@review haml "canonical_documents/import_export".to_sym, escape_html: false end |
#GET__review__sr_id_canonical_documents_tags ⇒ Object
103 104 105 106 107 |
# File 'controllers/reviews/canonical_documents.rb', line 103 get "/review/:sr_id/canonical_documents/tags" do |sr_id| (sr_id) haml "tags/rs_cds_massive".to_sym, escape_html: false end |
#GET__review__sr_id_reference__ref_id ⇒ Object
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'controllers/reviews/references.rb', line 94 get "/review/:sr_id/reference/:ref_id" do |sr_id, ref_id| halt_unless_auth('review_view') @sr_id=sr_id @ref_id=ref_id @review=SystematicReview[@sr_id] raise Buhos::NoReviewIdError, sr_id if !@review @ref=Reference[@ref_id] raise Buhos::NoReferenceIdError, ref_id if !@ref_id # Records title(t(:reference_title, ref_title:@ref.text)) @records=@ref.records_in_sr(@review) haml :reference, escape_html: false end |
#POST___admin_users_batch_edition_excel_import_ ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
# File 'controllers/admin/users.rb', line 44 post '/admin/users_batch_edition/excel_import' do require 'simple_xlsx_reader' SimpleXlsxReader.configuration.auto_slurp = true archivo=params.delete("file") doc = SimpleXlsxReader.open(archivo["tempfile"]) sheet=doc.sheets.first header=sheet.headers id_index = header.find_index("id") id_active = header.find_index("active") id_email = header.find_index("email") id_institution = header.find_index("institution") id_language = header.find_index("language") id_login = header.find_index("login") id_name = header.find_index("name") id_password = header.find_index("password") id_role = header.find_index("role_id") lista_excel={"id"=> id_index,"active"=> id_active, "email"=>id_email, "institution"=>id_institution, "language"=>id_language, "login"=>id_login, "name"=>id_name, "password"=>id_password, "role_id"=>id_role} result=Result.new missing_fields=lista_excel.find_all{|field,value| value.nil?}.map{|x| x[0]} if missing_fields.length >0 result.error("Missing fields:#{missing_fields.join(', ')}") add_result(result) redirect url("/admin/users_batch_edition") end institutions_names=Institution.to_hash(:name, :id) users_assignation={} header.each_index { |i| if header[i]=~/\[(\d+)\].+/ users_assignation[i]=$1 end } number_of_actions=0 $db.transaction(:rollback => :reraise) do sheet.data.each do |row| user_id=row[id_index] active=row[id_active].to_i == 1 email=row[id_email] login=row[id_login] name=row[id_name] next if login.nil? or name.nil? institution=row[id_institution].nil? ? "**NO INSTITUTION**": row[id_institution].strip language=row[id_language] password=row[id_password] role_id=row[id_role] institution_id=institutions_names[institution] || Institution.find_or_create(name:institution)[:id] # Login and name should be the same. If not, ok if user_id.nil? # Create user, if login and e-mail doesn't exists if User.where {Sequel.or(email:email, login:login, name:name)}.count>0 result.error("User already exists:#{login}, #{name}, #{email}") else user_o=User.create(active:active, email:email, institution_id:institution_id, language:language, login:login, name:name, password:Digest::SHA1.hexdigest(password), role_id:role_id) result.success("User add: #{name}") end else user_o=User[id:user_id] if user_o to_update={active:active, email:email, institution_id:institution_id, language:language, login:login, name:name, role_id:role_id } if !password.nil? and password.strip!="" to_update[:password]=Digest::SHA1.hexdigest(password) end to_update_2=to_update.inject({}) {|ac,v| if v[1]!=user_o[v[0]] ac[v[0].to_sym]=v[1] end ac } #$log.info(to_update_2) if to_update_2.length>0 $log.info(to_update_2) user_o.update(values=to_update_2) result.success("User update: #{user_id}") number_of_actions+=1 end else result.error("User doesn't exists:#{user_id}") end end end end if number_of_actions==0 result.info(::I18n::t(:Nothing_to_update)) end add_result(result) redirect url("/admin/users_batch_edition") end |
#POST___admin_users_delete_ ⇒ Object
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 |
# File 'controllers/admin/users.rb', line 201 post '/admin/users/delete' do if params['action']=='delete' users=User.where(:id=>params['users'].split(",")) if !users (::I18n.t("users_admin.no_valid_user_selected"), :error) else $db.transaction do User.where(:id=>params['users'].split(",")).delete end (::I18n.t("users_admin.action_delete", ids: params['users'])) end end redirect url('admin/users') end |
#POST___admin_users_update_ ⇒ Object
Update information for users
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 |
# File 'controllers/admin/users.rb', line 170 post '/admin/users/update' do halt_unless_auth('user_admin') if params['user'].nil? (::I18n.t(:No_users_selected), :error) redirect back end users=params['user'] if params['action']=='inactive' User.where(:id => users).update(:active=>false) (::I18n.t("users_admin.action_inactive", ids: users.join(","))) elsif params['action']=='active' User.where(:id => users).update(:active=>true) (::I18n.t("users_admin.action_active", ids: users.join(","))) elsif params['action']=='delete' @users_id=users @users=User.where(:id=>@users_id) if @users_id.map(&:to_i).include? session['user_id'] (::I18n.t("users_admin.cant_delete_itself")) redirect back else return haml "users/delete_confirm".to_sym, escape_html: false end elsif params['action']=='edit' @users_id=users @users=User.where(:id=>@users_id) return haml "users/multiple_edit".to_sym, escape_html: false end redirect back end |
#POST___admin_users_update_edit_ ⇒ Object
217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 |
# File 'controllers/admin/users.rb', line 217 post '/admin/users/update_edit' do user_info=params['user'] if !user_info (::I18n.t("users_admin.no_valid_user_selected"), :error) redirect url("admin/users") else result=Result.new user_info.each do |user_id, user_info| begin if user_info[:name].strip=="" result.error(::I18n.t("users_admin.user_should_have_a_name", id: user_id)) elsif user_info[:login].strip=="" result.error(::I18n.t("users_admin.user_should_have_a_login", id: user_id)) else $db.transaction do User[user_id].update(name:user_info[:name], login:user_info[:login], active: user_info[:active].to_i==1, role_id: user_info[:role_id], email: user_info[:email], institution_id:user_info[:institution_id], language: user_info[:language]) result.success(::I18n.t("users_admin.update_was_successful", id: user_id)) end end rescue Exception => e result.error(::I18n.t("users_admin.update_failed", id: user_id, message:e.)) end end add_result(result) end if result.success? redirect url("admin/users") else @users_id=user_info.keys @users=User.where(:id=>@users_id) return haml "users/multiple_edit".to_sym, escape_html: false end end |
#POST___canonical_document__id_merge_similar_references_ ⇒ Object
Merge similar references to a specific canonical document
95 96 97 98 99 100 101 102 103 104 105 |
# File 'controllers/canonical_document.rb', line 95 post '/canonical_document/:id/merge_similar_references' do |id| halt_unless_auth('canonical_document_admin') @cd=CanonicalDocument[id] raise Buhos::NoCdIdError, id if !@cd if !params['reference'].nil? references_to_merge=params['reference'].keys Reference.where(:id=>references_to_merge).update(:canonical_document_id=>@cd[:id]) ("Se unieron #{references_to_merge.length} references al canonico comun #{@cd[:id]}") end redirect back end |
#POST___canonical_document_actions_ ⇒ Object
217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 |
# File 'controllers/canonical_document.rb', line 217 post '/canonical_document/actions' do halt_unless_auth('canonical_document_admin') action=params['action'] halt 500, t(:no_action_specified) unless action halt 500, t(:no_canonical_document) if params['canonical_document'].nil? cd_ids=params['canonical_document'].keys if action=='merge' if CanonicalDocument.merge(cd_ids) (t(:Canonical_document_merge_successful)) else (t(:Canonical_document_merge_error), :error) end elsif action=='tags' url_action="/review/#{params[:sr_id]}/canonical_documents/tags?" url_action+="cd_id="+params['canonical_document'].keys.join(',') url_action+="&url_back="+params['url_back'] url_action+="&user_id="+params['user_id'] redirect(url(url_action)) elsif action=='bibtex' @canonicos=CanonicalDocument.where(:id=>cd_ids).order(:author,:year) bib=BibliographicalImporter::BibTex::Writer.generate(@canonicos) headers["Content-Disposition"] = "attachment;filename=canonical_document_list.bib" content_type 'text/x-bibtex' return bib.to_s else return [500, I18n.t(:that_function_doesn_exists)] end redirect back end |
#POST___canonical_document_merge_ ⇒ Object
Merge two or more canonical documents
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
# File 'controllers/canonical_document.rb', line 122 post '/canonical_document/merge' do halt_unless_auth('canonical_document_admin') doi=params['doi'] scielo_id=params['scielo_id'] scopus_id=params['scopus_id'] wos_id=params['wos_id'] pk_ids=params['pk_ids'] if doi cds=CanonicalDocument.where(:doi => doi, :id => pk_ids.split(",")) elsif scielo_id cds=CanonicalDocument.where(:scielo_id => scielo_id, :id => pk_ids.split(",")) elsif wos_id cds=CanonicalDocument.where(:wos_id => wos_id, :id => pk_ids.split(",")) elsif scopus_id cds=CanonicalDocument.where(:scopus_id => scopus_id, :id => pk_ids.split(",")) else cds=CanonicalDocument.where(:id => pk_ids.split(",")) end if cds.count>1 resultado=CanonicalDocument.merge(cds.map(:id)) end $log.info(resultado) return resultado ? 200 : 500 end |
#POST___canonical_document_user_allocation__action_ ⇒ Object
Allocate a canonical document to user, for screening or analyze
251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 |
# File 'controllers/canonical_document.rb', line 251 post '/canonical_document/user_allocation/:action' do |action| halt_unless_auth('review_admin') revision=SystematicReview[params['rs_id']] cd=CanonicalDocument[params['cd_id']] user=User[params['user_id']] stage=params['stage'] return 404 if !revision or !cd or !user or !stage a_cd=AllocationCd[:systematic_review_id=>revision[:id],:canonical_document_id=>cd[:id],:user_id=>user[:id], :stage=>stage] if action=='allocate' if !a_cd AllocationCd.insert(:systematic_review_id=>revision[:id],:canonical_document_id=>cd[:id],:user_id=>user[:id],:stage=>stage,:status=>"assigned") return 200 end elsif action=='unallocate' if a_cd a_cd.delete return 200 end else return [500, I18n.t(:that_function_doesn_exists)] end end |
#POST___decision_review__review_id_user__user_id_canonical_document__cd_id_stage__stage_decision_ ⇒ Object
Make a decision on a given document
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'controllers/decision.rb', line 48 post '/decision/review/:review_id/user/:user_id/canonical_document/:cd_id/stage/:stage/decision' do |review_id, user_id, cd_id, stage| halt_unless_auth('review_analyze') #cd_id=params['pk_id'] decision=params['decision'] #user_id=params['user_id'] = params['only_buttons'] == "1" $db.transaction do des=Decision.where(:systematic_review_id => review_id, :user_id => user_id, :canonical_document_id => cd_id, :stage => stage).first if des des.update(:decision => decision) else Decision.insert(:systematic_review_id => review_id, :decision => decision, :user_id => user_id, :canonical_document_id => cd_id, :stage => stage) end end review=SystematicReview[review_id] cd=CanonicalDocument[cd_id] ars=AnalysisSystematicReview.new(review) decisions=Decision.where(:user_id => user_id, :systematic_review_id => review_id, :stage => stage).as_hash(:canonical_document_id) return partial(:decision, :locals => {review: review, cd: cd, decisions: decisions, ars: ars, user_id: user_id, stage: stage, ajax: true, only_buttons:}) end |
#POST___file_assign_to_canonical_ ⇒ Object
Allocate a specific file to a canonical document
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 |
# File 'controllers/files.rb', line 194 post '/file/assign_to_canonical' do halt_unless_auth('canonical_document_admin') file=IFile[params['file_id']] return 404 if file.nil? acd=FileCd.where(:file_id=>file.id) if params['cd_id']=="" acd.delete return I18n::t("file_handler.no_canonical_document") else cd=CanonicalDocument[params['cd_id']] return 404 if !cd if acd.empty? FileCd.insert(:file_id=>file.id,:canonical_document_id=>cd.id,:not_consider=>false) else FileCd.where(:file_id=>file.id).update(:canonical_document_id=>cd.id) end return "<a href='/canonical_document/#{cd[:id]}'>#{cd[:title][0..50]}</a>" end end |
#POST___file_delete_ ⇒ Object
Delete a file.
277 278 279 280 281 282 283 284 285 286 287 |
# File 'controllers/files.rb', line 277 post '/file/delete' do halt_unless_auth('file_admin') file=IFile[params['file_id']] return 404 if file.nil? FileSr.where(:file_id => file.id).delete FileCd.where(:file_id => file.id).delete file.delete return 200 end |
#POST___file_hide_cd_ ⇒ Object
Hide a file allocated to a canonical document
219 220 221 222 223 224 225 226 227 228 229 |
# File 'controllers/files.rb', line 219 post '/file/hide_cd' do halt_unless_auth('canonical_document_admin') file=IFile[params['file_id']] cd=CanonicalDocument[params['cd_id']] raise Buhos::NoFileIdError , params['file_id'] unless file raise Buhos::NoCdIdError , params['cd_id'] unless cd FileCd.where(:file_id=>file.id, :canonical_document_id=>cd.id).update(:not_consider=>true) return 200 end |
#POST___file_show_cd_ ⇒ Object
Show a file allocated to a canonical document
234 235 236 237 238 239 240 241 242 243 244 |
# File 'controllers/files.rb', line 234 post '/file/show_cd' do halt_unless_auth('canonical_document_admin') file=IFile[params['file_id']] cd=CanonicalDocument[params['cd_id']] raise Buhos::NoFileIdError , params['file_id'] unless file raise Buhos::NoCdIdError , params['cd_id'] unless cd FileCd.where(:file_id=>file.id, :canonical_document_id=>cd.id).update(:not_consider=>false) return 200 end |
#POST___file_unassign_cd_ ⇒ Object
Remove the allocation of a file to a canonical document
248 249 250 251 252 253 254 255 256 257 258 |
# File 'controllers/files.rb', line 248 post '/file/unassign_cd' do halt_unless_auth('canonical_document_admin') file=IFile[params['file_id']] cd=CanonicalDocument[params['cd_id']] raise Buhos::NoFileIdError , params['file_id'] unless file raise Buhos::NoCdIdError , params['cd_id'] unless cd FileCd.where(:file_id=>file.id, :canonical_document_id=>cd.id).delete return 200 end |
#POST___file_unassign_sr_ ⇒ Object
Remove the allocation of a file to a systematic review
261 262 263 264 265 266 267 268 269 270 271 272 273 274 |
# File 'controllers/files.rb', line 261 post '/file/unassign_sr' do halt_unless_auth('review_admin') rs=SystematicReview[params['rs_id']] file=IFile[params['file_id']] raise Buhos::NoFileIdError, params['file_id'] unless file raise Buhos::NoReviewIdError, params['rs_id'] unless rs return 404 if file.nil? or rs.nil? FileSr.where(:file_id=>file.id, :systematic_review_id=>rs.id).delete return 200 end |
#POST___group_update_ ⇒ Object
Updates information for a group
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'controllers/admin/groups.rb', line 70 post '/group/update' do halt_unless_auth('group_admin') id=params['group_id'] name=params['name'] error=false if name.chomp=="" (t(:group_without_name), :error) error=true end description=params['description'] if description.chomp=="" (t(:group_without_description), :error) error=true end admin_id=params['group_administrator'] users=params['users'] ? params['users'].keys : [] if users.length==0 (t(:group_without_users), :error) error=true end if not users.include? admin_id (t(:group_should_include_admin_as_user), :error) error=true end if error if id=="NA" new_params={ name:name, description:description, admin_id:admin_id, "users[]"=>users } uri = URI.parse(url("group/new")) uri.query=URI.encode_www_form(new_params) redirect to(uri) else redirect back end end if id=="NA" group=Group.create(:name=>name,:description=>description, :group_administrator=>admin_id) id=group.id else Group[id].update(:name=>name,:description=>description, :group_administrator=>admin_id) end GroupsUser.where(:group_id=>id).delete() users.each {|u| GroupsUser.insert(:user_id=>u, :group_id=>id) } redirect url('/admin/groups') end |
#POST___message__m_id_seen_by__user_id_ ⇒ Object
53 54 55 56 57 58 59 60 |
# File 'controllers/messages.rb', line 53 post '/message/:m_id/seen_by/:user_id' do |m_id, user_id| halt_unless_auth('message_edit') ms=Message.where(:id=>m_id, :user_to=>user_id) if ms ms.update(:viewed=>true) end return 200 end |
#POST___message_per__m_id_reply_ ⇒ Object
Send a reply to a message
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'controllers/messages.rb', line 87 post '/message_per/:m_id/reply' do |m_id| halt_unless_auth('message_edit') m_per=Message[m_id] @user_id=params['user_id'] @user=User[@user_id] raise Buhos::NoUserIdError, @user_id if !@user raise Buhos::NoMessageIdError, m_id if !m_per halt 403 unless is_session_user(@user_id) @subject=params['subject'].chomp @text=params['text'].chomp $db.transaction(:rollback=>:reraise) do id=Message.insert(:user_from=>@user_id, :user_to=>m_per.user_from , :reply_to=>m_per.id, :time=>DateTime.now(), :subject=>@subject, :text=>@text, :viewed=>false) (t("messages.add_reply_to", subject: m_per.subject)) end redirect back end |
#POST___message_sr__ms_id_reply_ ⇒ Object
Show form to reply a message
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'controllers/messages.rb', line 64 post '/message_sr/:ms_id/reply' do |ms_id| halt_unless_auth('message_edit') ms=MessageSr[ms_id] @user_id=params['user_id'] raise Buhos::NoUserIdError, params['user_id'] unless User[@user_id] halt 403 unless is_session_user(@user_id) return 404 if ms.nil? @subject=params['subject'] @text=params['text'] $db.transaction(:rollback=>:reraise) do MessageSr.insert(:systematic_review_id=>ms.systematic_review_id, :user_from=>@user_id, :reply_to=>ms.id, :time=>DateTime.now(), :subject=>@subject, :text=>@text) (t("messages.add_reply_to", subject: ms.subject)) end redirect back end |
#POST___message_sr__ms_id_seen_by__user_id_ ⇒ Object
Mark a message as seen by a user
39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'controllers/messages.rb', line 39 post '/message_sr/:ms_id/seen_by/:user_id' do |ms_id, user_id| halt_unless_auth('message_edit') ms=MessageSrSeen.where(:m_rs_id=>ms_id, :user_id=>user_id) unless ms.empty? ms.update(:viewed=>true) else MessageSrSeen.insert(:m_rs_id=>ms_id, :user_id=>user_id,:viewed=>true) end return 200 end |
#POST___record__id_manual_references_ ⇒ Object
Add manual references to a record
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'controllers/records.rb', line 76 post '/record/:id/manual_references' do |id| halt_unless_auth('record_edit') ref_man=params['reference_manual'] $db.transaction(:rollback => :reraise) do if ref_man partes=ref_man.split("\n").map {|v| v.strip.gsub("[ Links ]", "").gsub(/\s+/, ' ')}.find_all {|v| v!=""} partes.each do |parte| parte=parte.chomp.lstrip ref=Reference.get_by_text_and_doi(parte, nil, true) ref_reg=RecordsReferences.where(:record_id => id, :reference_id => ref[:id]).first unless ref_reg RecordsReferences.insert(:record_id => id, :reference_id => ref[:id]) end end (::I18n.t(:Added_references_to_record, :record_id=>id, :count_references=>partes.length)) end end redirect back end |
#POST___record__id_references_action_ ⇒ Object
Reference action
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'controllers/records.rb', line 55 post '/record/:id/references_action' do |id| halt_unless_auth('reference_edit') record=Record[id] raise Buhos::NoRecordIdError, id if record.nil? action=params['action'] references=params['references'] if action=='delete' if references $db.transaction do rr=RecordsReferences.where(:record_id=>id, :reference_id=>references) count=rr.count rr.delete (t(:Count_references_delete, count:count)) end else (t(:No_references_selected), :error) end end redirect back end |
#POST___reference__id_merge_similar_references_ ⇒ Object
Merge similar references
44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'controllers/references.rb', line 44 post '/reference/:id/merge_similar_references' do |id| halt_unless_auth('reference_edit') @ref=Reference[id] if (@ref[:canonical_document_id].nil?) raise "No tengo método para unificar sin canonico" end if !params['reference'].nil? references_a_unir=params['reference'].keys Reference.where(:id=>references_a_unir).update(:canonical_document_id=>@ref[:canonical_document_id]) ("Se unieron las references de #{references_a_unir.length} references a un canonico comun") end redirect back end |
#POST___reference_assign_canonical_document_ ⇒ Object
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
# File 'controllers/references.rb', line 143 post '/reference/assign_canonical_document' do halt_unless_auth('reference_edit') @canonical_document=CanonicalDocument[params['cd_id']] @reference=Reference[params['ref_id']] raise Buhos::NoReferenceIdError, params['ref_id'] if !@reference raise Buhos::NoCdIdError, params['cd_id'] if !@canonical_document $db.transaction do @reference.update(:canonical_document_id=>@canonical_document.id) (t("canonical_document.assigned_to_reference", cd_title:@canonical_document.title, reference:@reference.text)) end redirect back end |
#POST___references_search_crossref_by_doi_ ⇒ Object
Query one or more references on Crossref using their DOIs
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'controllers/references.rb', line 76 post '/references/search_crossref_by_doi' do halt_unless_auth('reference_edit') dois=params['doi'] result=Result.new #$log.info("Procesando :#{dois}") if !dois result.error(I18n::t(:one_or_more_DOI_needed)) else dois.each do |doi| #$log.info("Buscando:#{doi}") Reference.where(:doi=>doi).each do |ref| result.add_result(ref.add_doi(doi)) #$log.info(result) end end end add_result(result) redirect back end |
#POST___resolution_review__id_canonical_document__cd_id_stage__stage_resolution_ ⇒ Object
Set resolution of a specific canonical document on a stage
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'controllers/resolutions.rb', line 11 post '/resolution/review/:id/canonical_document/:cd_id/stage/:stage/resolution' do |rev_id, cd_id, stage| halt_unless_auth('review_admin') resolution=params['resolution'] user_id=params['user_id'] res=Resolution.where(:systematic_review_id=>rev_id, :canonical_document_id=>cd_id, :stage=>stage) if resolution=='delete' return 404 if res.empty? res.delete else return 500 unless ['yes','no'].include? resolution $db.transaction(:rollback=>:reraise) do if res.empty? Resolution.insert(:systematic_review_id=>rev_id, :canonical_document_id=>cd_id, :stage=>stage, :resolution=>resolution, :user_id=>user_id, :commentary=>"Resuelto en forma especifica en #{DateTime.now.to_s}") else res.update(:resolution=>resolution, :user_id=>user_id) end end end review=SystematicReview[rev_id] ars=AnalysisSystematicReview.new(review) rpc=ars.resolution_by_cd(stage) rcompc=ars.resolution_commentary_by_cd(stage) partial(:buttons_resolution, :locals=>{:rpc=>rpc, :rcompc=>rcompc, :cd_id=>cd_id.to_i, :stage=>stage, :user_id=>user_id, :review=>review}) end |
#POST___review__id_canonical_document_automatic_deduplication__type_ ⇒ Object
293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 |
# File 'controllers/reviews/canonical_documents.rb', line 293 post '/review/:id/canonical_document/automatic_deduplication/:type' do |id, type| halt_unless_auth('canonical_document_admin') @review=SystematicReview[id] raise Buhos::NoReviewIdError, id if !@review @dup_analysis=Buhos::DuplicateAnalysis.new(@review.canonical_documents) @cds=@review.canonical_documents @cd_ids=@cds.map {|cd| cd.id} result=Result.new if type=="doi" @cd_rep_doi=@dup_analysis.by_doi @cd_por_doi=CanonicalDocument.where(doi: @cd_rep_doi, id: @cd_ids).order(:id).to_hash_groups(:doi, :id) @cd_por_doi.each_pair do |doi, cds_id| if CanonicalDocument.where(id:cds_id).count()==cds_id.length resultado=CanonicalDocument.merge(cds_id) if resultado result.success("DOI:#{doi} - #{I18n::t("Canonical_document_merge_successful")}") else result.error("DOI:#{doi} - #{I18n::t("Canonical_document_merge_error")}") end end end end if type=="scielo" @cd_rep_scielo = @dup_analysis.by_scielo_id @cd_por_scielo=CanonicalDocument.where(:scielo_id => @cd_rep_scielo, :id=>@cd_ids).to_hash_groups(:scielo_id, :id) @cd_por_scielo.each_pair do |scielo_id, cds_id| if CanonicalDocument.where(id:cds_id).count()==cds_id.length resultado=CanonicalDocument.merge(cds_id) if resultado result.success("Scielo:#{scielo_id} - #{I18n::t("Canonical_document_merge_successful")}") else result.error("Scielo:#{scielo_id} - #{I18n::t("Canonical_document_merge_error")}") end end end end if type=="pubmed" @cd_rep_pubmed = @dup_analysis.by_pubmed_id @cd_por_pubmed=CanonicalDocument.where(:pubmed_id => @cd_rep_pubmed, :id=>@cd_ids).to_hash_groups(:pubmed_id, :id) @cd_por_pubmed.each_pair do |pubmed_id, cds_id| if CanonicalDocument.where(id:cds_id).count()==cds_id.length resultado=CanonicalDocument.merge(cds_id) if resultado result.success("Pubmed:#{pubmed_id} - #{I18n::t("Canonical_document_merge_successful")}") else result.error("Pubmed:#{pubmed_id} - #{I18n::t("Canonical_document_merge_error")}") end end end end if type=="scopus" @cd_rep_scopus = @dup_analysis.by_scopus_id @cd_por_scopus=CanonicalDocument.where(:scopus_id => @cd_rep_scopus, :id=>@cd_ids).to_hash_groups(:scopus_id, :id) @cd_por_scopus.each_pair do |scopus_id, cds_id| if CanonicalDocument.where(id:cds_id).count()==cds_id.length resultado=CanonicalDocument.merge(cds_id) if resultado result.success("Scopus:#{scopus_id} - #{I18n::t("Canonical_document_merge_successful")}") else result.error("Scopus:#{scopus_id} - #{I18n::t("Canonical_document_merge_error")}") end end end end if type=="wos" @cd_rep_wos = @dup_analysis.by_wos_id @cd_por_wos=CanonicalDocument.where(:wos_id => @cd_rep_wos, :id=>@cd_ids).to_hash_groups(:wos_id, :id) @cd_por_wos.each_pair do |wos_id, cds_id| if CanonicalDocument.where(id:cds_id).count()==cds_id.length resultado=CanonicalDocument.merge(cds_id) if resultado result.success("WOS:#{wos_id} - #{I18n::t("Canonical_document_merge_successful")}") else result.error("WOS:#{wos_id} - #{I18n::t("Canonical_document_merge_error")}") end end end end add_result(result) redirect back end |
#POST___review__id_delete2_ ⇒ Object
257 258 259 260 261 262 263 264 265 266 267 268 269 |
# File 'controllers/reviews.rb', line 257 post '/review/:id/delete2' do |id| id2=params['sr_id'] @review=SystematicReview[id] raise Buhos::NoReviewIdError, id if !@review raise "#{id} and #{id2} should coincide" if id.to_s!=id2.to_s if @review.delete (t("systematic_review.delete_successful")) else (t("systematic_review.delete_unsuccessful")) end redirect url('/reviews') end |
#POST___review__id_message_new_ ⇒ Object
Post a message
22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'controllers/messages.rb', line 22 post '/review/:id/message/new' do |id| halt_unless_auth('message_edit') @review=SystematicReview[id] raise Buhos::NoReviewIdError, id if !@review @user_id=params['user_id'] return 404 if @review.nil? or @user_id.nil? @subject=params['subject'] @text=params['text'] $db.transaction(:rollback=>:reraise) do id=MessageSr.insert(:systematic_review_id=>id, :user_from=>@user_id, :reply_to=>nil, :time=>DateTime.now(), :subject=>@subject, :text=>@text) (t("messages.new_message_for_sr", sr_name:@review[:name])) end redirect back end |
#POST___review__rev_id_administration__stage_cd_assignations_excel__mode_ ⇒ Object
211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 |
# File 'controllers/reviews/administration.rb', line 211 post '/review/:rev_id/administration/:stage/cd_assignations_excel/:mode' do |rev_id, stage, mode| halt_unless_auth('review_admin') review=SystematicReview[rev_id] raise Buhos::NoReviewIdError, rev_id if !review cds_id=review.cd_id_by_stage(stage) stage=stage cds=CanonicalDocument.where(:id=>cds_id).order(:author) users_grupos=review.group_users archivo=params.delete("file") if mode=="load" require 'simple_xlsx_reader' SimpleXlsxReader.configuration.auto_slurp = true doc = SimpleXlsxReader.open(archivo["tempfile"]) sheet=doc.sheets.first header=sheet.headers id_index=header.find_index("id") users_assignation={} header.each_index { |i| if header[i]=~/\[(\d+)\].+/ users_assignation[i]=$1 end } number_of_actions=0 $db.transaction(:rollback => :reraise) do sheet.data.each do |row| cd_id=row[id_index] if cd_id.nil? ("Row without information", :error) else user_allocations=AllocationCd.where(:systematic_review_id=>review[:id], :canonical_document_id=>cd_id, :stage=>stage ).to_hash(:user_id) #$log.debug(user_allocations) users_assignation.each do |i,user_id| if !row[i].nil? #$log.debug("#{row[i]}: #{user_id}") if row[i].to_i==0 and user_allocations[user_id.to_i] number_of_actions+=1 # $log.debug("Deleting") AllocationCd.where(:systematic_review_id=>review[:id], :canonical_document_id=>cd_id, :stage=>stage, :user_id=>user_id).delete elsif row[i].to_i==1 and !user_allocations[user_id.to_i] #$log.debug("assing") number_of_actions+=1 AllocationCd.insert(:systematic_review_id=>review[:id], :canonical_document_id=>cd_id, :stage=>stage, :user_id=>user_id, :status=>"Massive assign") end end end end end end (t("systematic_review_page.cd_assignations_number", n:number_of_actions)) redirect back # Aquí es-> fp.read else raise "Not implemented" end end |
#POST___review__rs_id_new_field_ ⇒ Object
Add a new field
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'controllers/reviews/fields.rb', line 26 post '/review/:rs_id/new_field' do |rs_id| halt_unless_auth('review_admin') @review=SystematicReview[rs_id] raise Buhos::NoReviewIdError, rs_id if !@review name=params['name'].chomp @campo_previo=@review.fields.where(:name=>name) if @campo_previo.empty? type=params['type'].chomp halt 500, "Not valid type #{type}" unless SrField.is_valid_type?(type) SrField.insert(:systematic_review_id=>rs_id, :order=>params['order'],:name=>name, :description=>params['description'], :type=>type,:options=>params['options']) (t('sr_new_sr_edit_field.doesnt_existfield.success', name:params['name'])) else (t('sr_new_field.duplicated', name:params['name']), :error) end redirect back end |
#POST___review__rs_id_new_quality_criterion_ ⇒ Object
Add a new field
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'controllers/reviews/quality_criteria.rb', line 25 post '/review/:rs_id/new_quality_criterion' do |rs_id| halt_unless_auth('review_admin') @review=SystematicReview[rs_id] raise Buhos::NoReviewIdError, rs_id if !@review text=params['text'].chomp if text=="" ("quality_asessment.criterion_cant_be_empty", :error) else quality_criterion=QualityCriterion.get_criterion(text) scale=Scale[params['scale_id']] raise Buhos::NoScaleIdError, params['scale_id'] unless scale add_result(Buhos::QualityCriteriaProcessor.add_criterion_to_rs(@review,quality_criterion, scale)) end redirect back end |
#POST___review__sr_id_canonical_documents_import_excel_ ⇒ Object
TODO: The system doesn’t check proper authorization. Use with care
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'controllers/reviews/import_canonical_documents.rb', line 46 post '/review/:sr_id/canonical_documents/import_excel' do |sr_id| halt_unless_auth_any('review_admin') #$log.info(params) @review=SystematicReview[sr_id] cds=@review.cd_all_id #$log.info(cds) raise Buhos::NoReviewIdError, sr_id if !@review archivo=params.delete("file") require 'simple_xlsx_reader' SimpleXlsxReader.configuration.auto_slurp = true #$log.info(archivo) doc = SimpleXlsxReader.open(archivo["tempfile"]) valid_headers=%w{title year author journal volume pages doi wos_id scielo_id scopus_id abstract} rows=doc.sheets.first.rows cd_ids_a_revisar=[] cd_dato_nuevo=rows.each(headers: true).with_object({}) do |row, acc| if cds.include? row['canonical_document_id'].to_i cd_ids_a_revisar.append(row['canonical_document_id'].to_i) datos=valid_headers.inject({}) {|acc,v| acc[v]=row[v] if row.key?(v) acc } acc[row["canonical_document_id"]] = datos end end canonical_base=CanonicalDocument.where(:id=>cd_ids_a_revisar).as_hash(:id) @updated_data_per_cd=cd_dato_nuevo.each_with_object({}) {|v,acc| cd_id, data_cd=v datos=data_cd.each_with_object({}) {|v2,acc2| key_v, data_v=v2 if ["year", "volume"].include? key_v and data_v.is_a? Numeric data_v=data_v.to_i end acc2[key_v]=data_v if data_v.to_s!=canonical_base[cd_id.to_i][key_v.to_sym].to_s } if datos.length>0 acc[cd_id.to_i]=datos acc[cd_id.to_i]['original_title']=canonical_base[cd_id.to_i][:title] end } haml "canonical_documents/import_review".to_sym, escape_html: false end |
#POST___review__sr_id_canonical_documents_import_excel_reviewed_ ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'controllers/reviews/import_canonical_documents.rb', line 12 post '/review/:sr_id/canonical_documents/import_excel_reviewed' do |sr_id| halt_unless_auth_any('review_admin') #$log.info(params) @review=SystematicReview[sr_id] raise Buhos::NoReviewIdError, sr_id if !@review cds_list=@review.cd_all_id cd_to_update=params["canonical_document"] if cd_to_update.nil? ("No document to update", :warning) redirect url("review/#{sr_id}/canonical_documents/import_export") end i=0 $db.transaction(:rollback=>:reraise) do cd_to_update.each do |key,vals| if cds_list.map {|v| v.to_s}.include? key if vals.key?("updated") and vals['updated']=="on" hash_to_update=vals.each_with_object({}) {|v,acc| acc[v[0].to_sym]=v[1].to_s.strip if v[0]!="updated" } CanonicalDocument[key].update(hash_to_update) i+=1 end end end end (t("Number of canonical documents updated:#{i}")) redirect url("review/#{sr_id}/canonical_documents/import_export") end |
#POST___review__sr_id_create_canonical_for_references_ ⇒ Object
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 |
# File 'controllers/reviews/references.rb', line 159 post '/review/:sr_id/create_canonical_for_references' do |sr_id| halt_unless_auth('review_analyze') $log.info(params) @ref_ids=params['references'].keys() @review=SystematicReview[sr_id] @references=Reference.where(:id=>@ref_ids) raise Buhos::NoReviewIdError, sr_id if !@review (I18n::t(:List_of_references_not_compatible)) if @references.count!= @ref_ids.length $db.transaction do cd_id=CanonicalDocument.insert(:author=>params['author'], :year=>params['year'], :title=>params[:title]) @references.update(:canonical_document_id=>cd_id) ("Created canonical document #{cd_id} for #{@ref_ids.length} references") end redirect "/review/#{sr_id}/references" end |
#POST___review__sr_id_quality_criterion__qc_id_delete_ ⇒ Object
Delete a quality criteria
69 70 71 72 73 74 75 76 77 78 79 |
# File 'controllers/reviews/quality_criteria.rb', line 69 post '/review/:sr_id/quality_criterion/:qc_id/delete' do |sr_id, qc_id| halt_unless_auth('review_admin') review=SystematicReview[sr_id] raise Buhos::NoReviewIdError, rs_id unless review quality_criterion=QualityCriterion[qc_id] raise Buhos::NoQualityCriterionIdError, qc_id unless quality_criterion SrQualityCriterion[systematic_review_id:sr_id, quality_criterion_id:qc_id].delete (I18n::t('quality_assesment.criterion_unassigned_from_rs', criterion:quality_criterion[:text], review:review[:name])) redirect back end |
#POST___review__sr_id_references_actions_ ⇒ Object
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
# File 'controllers/reviews/references.rb', line 115 post '/review/:sr_id/references/actions' do |sr_id| halt_unless_auth('review_analyze') @ref_ids=params['reference'].keys @url_back=params['url_back'] @user_id=params['user_id'] @review=SystematicReview[sr_id] raise Buhos::NoReviewIdError, sr_id if !@review @user=User[@user_id] raise Buhos::NoUserIdError, @user_id if !@user @refs=Reference.where(:id=>@ref_ids).order(:id) (I18n::t(:List_of_references_not_compatible)) unless @refs.count==@ref_ids.length action=params['action'] result=Result.new if action=='assigncdcrossref' result.add_result(ReferenceProcessor.assign_to_canonical_document(@refs)) elsif action=='assigncdmanual' ref_id=@ref_ids.join(",") redirect "/review/#{@review[:id]}/assign_canonical_to_references?references=#{ref_id}" elsif action=='removecd' result.add_result(Reference.remove_canonicals(@refs)) else raise "#{t(:Action_not_defined)}:#{action}" end add_result(result) redirect back end |
#POST___review_criteria_cd_ ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'controllers/reviews/criteria.rb', line 13 post '/review/criteria/cd' do cd = CanonicalDocument[params['cd_id']] sr = SystematicReview[params['sr_id']] user = User[params['user_id']] criterion=Criterion[params['criterion_id']] presence = params['presence'] raise Buhos::NoReviewIdError, params['sr_id'] if !sr raise Buhos::NoCdIdError , params['cd_id'] if !cd raise Buhos::NoUserIdError, params['user_id'] if !user raise Buhos::NoCriterionIdError, params['criterion_id'] if !criterion raise I18n::t("criteria.not_valid_presence_type", type:presence) unless CdCriterion.valid_presence? presence h_crit={criterion_id:criterion[:id], canonical_document_id: cd[:id], user_id:user[:id], systematic_review_id: sr[:id]} cd_criteria=CdCriterion[h_crit] if !cd_criteria CdCriterion.insert(h_crit.merge({presence:presence})) else cd_criteria.update(presence:presence) end cd_criteria_list=CdCriterion.where(systematic_review_id:sr[:id], canonical_document_id:cd[:id], user_id:user[:id]).to_hash(:criterion_id) partial(:criteria_cd, locals:{review:sr, cd:cd, user_id:user[:id], cd_criteria:cd_criteria_list, open:true}) end |
#POST___review_files_add_ ⇒ Object
Add one or more files to a review
172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 |
# File 'controllers/reviews.rb', line 172 post '/review/files/add' do halt_unless_auth('review_edit', 'file_admin') #$log.info(params) @review=SystematicReview[params['systematic_review_id']] raise Buhos::NoReviewIdError, id if !@review files=params['files'] cd=nil cd_id=params['canonical_document_id'] if cd_id cd=CanonicalDocument[cd_id] raise Buhos::NoCdIdError, cd_id if cd.nil? end if files results=Result.new files.each do |file| file_proc=FileProcessor.new(file, dir_files) file_proc.add_to_sr(@review) file_proc.add_to_cd(cd) if cd results.success(I18n::t("search.successful_upload", filename:File.basename(file_proc.filepath), sr_name:@review.name)) end add_result results else (I18n::t(:Files_not_uploaded), :error) end redirect back end |
#POST___review_import_decisions_excel_ ⇒ Object
TODO: The system doesn’t check proper authorization. Use with care
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'controllers/reviews/import_export_decisions.rb', line 13 post '/review/import_decisions_excel' do halt_unless_auth_any('review_admin', 'review_admin_view') $log.info(params) sr_id=params['systematic_review_id'] @review=SystematicReview[sr_id] cds=@review.cd_all_id #$log.info(cds) raise Buhos::NoReviewIdError, sr_id if !@review archivo=params.delete("file") require 'simple_xlsx_reader' SimpleXlsxReader.configuration.auto_slurp = true #$log.info(archivo) doc = SimpleXlsxReader.open(archivo["tempfile"]) sheet=doc.sheets.first header=sheet.headers sr_idx=header.find_index("systematic_review_id") cd_idx=header.find_index("canonical_document_id") user_idx=header.find_index("user_id") stage_idx=header.find_index("stage") decision_idx=header.find_index("decision") commentary_idx=header.find_index("commentary") n_update=0 n_insert=0 n_errors=0 $db.transaction(:rollback => :reraise) do sheet.data.each do |row| sr_id = row[sr_idx].to_i cd_id = row[cd_idx].to_i user_id = row[user_idx].to_i stage = row[stage_idx].to_s decision = (row[decision_idx].nil? or row[decision_idx].strip=="") ? Decision::NO_DECISION : row[decision_idx].strip.downcase commentary = row[commentary_idx] if Decision::N_EST.keys().include? decision and cds.include? cd_id previous_dec=Decision[:systematic_review_id=>sr_id, :user_id=>user_id, :canonical_document_id=>cd_id, :stage=>stage] if previous_dec n_update+=1 previous_dec.update(:decision=>decision, :commentary=>commentary) else n_insert+=1 Decision.insert(:systematic_review_id=>sr_id, :user_id=>user_id, :canonical_document_id=>cd_id, :stage=>stage, :decision=>decision, :commentary=>commentary) end end end end (t("systematic_review_page.import_decisions_excel", n_update:n_update, n_insert: n_insert)) redirect back end |
#POST___review_reassign_cd_to_user_ ⇒ Object
434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 |
# File 'controllers/reviews/administration.rb', line 434 post '/review/reassign_cd_to_user' do rev_id=params['review_id'] @review=SystematicReview[rev_id] raise Buhos::NoReviewIdError, rev_id if !@review user_id_from=params['user_id_from'] @user_from=User[user_id_from] raise Buhos::NoUserIdError, user_id_from if !@user_from user_id_to=params['user_id_to'] @user_to=User[user_id_to] raise Buhos::NoUserIdError, user_id_to if !@user_to @stage=params['stage'] @asr=::Analysis_SR_Stage.new(@review, @stage) @cdid_abu=@asr.cd_id_assigned_by_user(user_id_from) @resolved=@asr.cd_resolved_id @assigned_not_resolved_id=@cdid_abu-@resolved if params['canonical_documents'] canonical_documents=params['canonical_documents'].keys.map {|v| v.to_i} #$log.info(@assigned_not_resolved_id) #$log.info(canonical_documents) cds_id=@assigned_not_resolved_id & canonical_documents result=AllocationCd.reassign_assignations(rev_id, @stage, user_id_from, user_id_to, cds_id, ::I18n::t("systematic_review_page.massive_reassignation_from_to", from:user_id_from, to:user_id_to)) add_result(result) redirect back else (::I18n::t("systematic_review_page.should_assign_at_least_one_canonical_document"), :error) redirect url("/review/#{rev_id}/stage/#{@stage}/reassign_user/#{user_id_from}") end end |
#POST___review_search_uploaded_files_new_ ⇒ Object
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
# File 'controllers/reviews/searches.rb', line 106 post '/review/search/uploaded_files/new' do halt_unless_auth('review_edit', 'file_admin') @bb_general_id=BibliographicDatabase[:name=>'generic'][:id] @review=SystematicReview[params['systematic_review_id']] raise Buhos::NoReviewIdError, id if !@review files=params['files'] cds_id=[] $db.transaction do search_id=Search.insert(:systematic_review_id=>@review.id,:description=>params["description"], :filetype=>'text/plain', :source=>params['source'], :valid=>false, :user_id=>session['user_id'], :date_creation=>Date.today, :bibliographic_database_id=>@bb_general_id, :search_type=>'uploaded_files') search=Search[search_id] if files results=Result.new files.each do |file| next if file[:type]!~/pdf/ and file[:filename]!~/\.pdf/ pdfprocessor=PdfFileProcessor.new(search, file[:tempfile], dir_files) pdfprocessor.process results.add_result(pdfprocessor.results) cds_id.push(pdfprocessor.canonical_document.id) end add_result results else (I18n::t(:Files_not_uploaded), :error) end search.update(:file_body=>cds_id.join("\n")) redirect url("/review/#{@review.id}/dashboard") end (I18n::t("error.problem_uploading_files"), :error) redirect back end |
#POST___review_update_ ⇒ Object
Create (id=0) or edit(id>0)a Systematic review
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 |
# File 'controllers/reviews.rb', line 98 post '/review/update' do halt_unless_auth('review_edit') id=params['review_id'] otros_params=params otros_params.delete("review_id") otros_params.delete("captures") strc=params.delete("srtc") criteria=params.delete("criteria") criteria||={'inclusion'=>[], 'exclusion'=>[]} otros_params=otros_params.inject({}) {|ac,v| ac[v[0].to_sym]=v[1];ac } # aa=SystematicReview.new #$log.info(otros_params) $db.transaction(:rollback=>:reraise) do if(id=="") id=SystematicReview.insert(otros_params) else revision=SystematicReview[id] revision.update(otros_params) end # Process criteria criteria_processor=Buhos::CriteriaProcessor.new(SystematicReview[id]) criteria_processor.update_criteria(criteria['inclusion'], criteria['exclusion']) # Process the srtc Systematic_Review_SRTC.where(:sr_id=>id).delete if !strc.nil? and !strc.keys.nil? strc.keys.each {|key| Systematic_Review_SRTC.insert(:sr_id=>id, :srtc_id=>key.to_i) } end end redirect url("/review/#{id}/dashboard") end |
#POST___role__role_id_delete_ ⇒ Object
Deletes a role
63 64 65 66 67 68 69 70 |
# File 'controllers/admin/roles.rb', line 63 post '/role/:role_id/delete' do |role_id| halt_unless_auth('role_admin') error(403) if role_id=="administrator" or role_id=="analyst" Role[role_id].delete (t(:Role_deleted_name, role:role_id)) redirect back end |
#POST___role_update_ ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'controllers/admin/roles.rb', line 72 post '/role/update' do halt_unless_auth('role_admin') old_id=params['role_id_old'] new_id=params['role_id_new'] if new_id.chomp=="" (t(:role_without_name), :error) redirect back end if params['authorizations'].nil? (t(:role_without_authorizations), :error) redirect back end @role=Role[old_id] return 404 if !@role exists_another=Role[new_id] if old_id==new_id or !exists_another $db.transaction(:rollback=>:reraise) do AuthorizationsRole.where(:role_id=>old_id).delete if (old_id!=new_id) Role.unrestrict_primary_key Role.where(:id=>old_id).update(:id=>new_id, :description=>params['description'].chomp) else @role.update(:description=>params['description'].chomp) end params['authorizations'].each {|| AuthorizationsRole.insert(:role_id=>new_id,:authorization_id=>) } end else (t(:Exists_another_role_with_that_name), :error) end redirect '/admin/roles' end |
#POST___search_update_ ⇒ Object
Update or create a search
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 |
# File 'controllers/search.rb', line 152 post '/search/update' do halt_unless_auth('search_edit') id=params['search_id'] otros_params=params otros_params.delete("search_id") otros_params.delete("captures") archivo=otros_params.delete("file") #No nulos otros_params=otros_params.inject({}) {|ac,v| ac[v[0].to_sym]=v[1];ac } # aa=SystematicReview.new if params['bibliographic_database_id'].nil? (I18n::t(:No_empty_bibliographic_database_on_search), :error) else if id=="" search=Search.create( :systematic_review_id=>otros_params[:systematic_review_id], :source=>otros_params[:source], :bibliographic_database_id=>otros_params[:bibliographic_database_id], :date_creation=>otros_params[:date_creation], :search_criteria=>otros_params[:search_criteria], :description=>otros_params[:description], :search_type=>otros_params[:search_type], :user_id=>session['user_id'] ) else search=Search[id] search.update(otros_params) end if archivo fp=File.open(archivo[:tempfile],"rb") search.update(:file_body=>fp.read, :filetype=>archivo[:type],:filename=>archivo[:filename]) fp.close end if search.is_type?(:bibliographic_file) sp=BibliographicFileProcessor.new(search) add_result(sp.result) unless sp.error.nil? (sp.error, :error) search.delete end end end redirect "/review/#{otros_params[:systematic_review_id]}/dashboard" end |
#POST___searches_update_batch_ ⇒ Object
Update actions for searchs: valid, invalid, delete
209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 |
# File 'controllers/search.rb', line 209 post '/searches/update_batch' do halt_unless_auth('search_edit') @sr=SystematicReview[params['sr_id']] raise Buhos::NoReviewIdError, params['sr_id'] if @sr.nil? #$log.info(params) if params["action"].nil? (I18n::t(:No_valid_action), :error) elsif params['search'].nil? (I18n::t(:No_search_selected), :error) else searches=Search.where(:id=>params['search']) if params['action']=='analyze' redirect url("/review/#{@sr.id}/searches/analyze/#{searches.map {|v|v[:id]}.join(',')}") elsif params['action']=='valid' searches.update(:valid=>true) elsif params['action']=='invalid' searches.update(:valid=>false) elsif params['action']=='delete' searches.each do |search| search.delete() end elsif params['action']=='process' results=Result.new searches.each do |search| sp=BibliographicFileProcessor.new(search) results.add_result(sp.result) end add_result(results) else (I18n::t(:Action_not_defined), :error) end end redirect params['url_back'] end |
#POST___tag_delete_rs_ ⇒ Object
Remove tag allocated to a canonical document
282 283 284 285 286 287 288 289 290 291 292 |
# File 'controllers/tag.rb', line 282 post '/tag/delete_rs' do halt_unless_auth('tag_edit') rs=SystematicReview[params['rs_id']] tag=Tag[params['tag_id']] return 404 if rs.nil? or tag.nil? $db.transaction(:rollback=>:reraise) { TagInCd.where(:tag_id=>tag.id, :systematic_review_id=>rs.id).delete tag.delete_if_unused } return 200 end |
#POST___tags_cd__cd_id_rs__rs_id__accion_ ⇒ Object
Actions for tags and canonical documents
-
add_tag
-
approve_tag
-
reject_tag
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 |
# File 'controllers/tag.rb', line 149 post '/tags/cd/:cd_id/rs/:rs_id/:accion' do |cd_id,rs_id,accion| halt_unless_auth('review_analyze') cd=CanonicalDocument[cd_id] raise Buhos::NoCdIdError, cd_id if !cd rs=SystematicReview[rs_id] raise Buhos::NoReviewIdError, rs_id if !rs tag_id=params['tag_id'] tag=Tag[tag_id] user_id=session['user_id'] if accion=='add_tag' tag_name=params['value'].chomp return 405 if tag_name=="" tag=Tag.get_tag(tag_name) $db.transaction(:rollback=>:reraise) do TagInCd.approve_tag(cd,rs,tag,user_id) end elsif accion=='approve_tag' raise Buhos::NoTagIdError, tag_id if !tag $db.transaction(:rollback=>:reraise) do TagInCd.approve_tag(cd,rs,tag,user_id) end elsif accion=='reject_tag' raise Buhos::NoTagIdError, tag_id if !tag $db.transaction(:rollback=>:reraise) do TagInCd.reject_tag(cd,rs,tag,user_id) end else return [405,"I don't know the action to perform"] end partial("tags/tags_cd_rs", :locals=>{cd:cd, review:rs, :nuevo=>true, user_id: user_id}) end |
#POST___tags_cd_start__cd_start_id_cd_end__cd_end_id_rs__rs_id__accion_ ⇒ Object
Actions for tags and relations between canonical documents
-
add_tag
-
approve_tag
-
reject_tag
192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 |
# File 'controllers/tag.rb', line 192 post '/tags/cd_start/:cd_start_id/cd_end/:cd_end_id/rs/:rs_id/:accion' do |cd_start_id,cd_end_id,rs_id,accion| halt_unless_auth('review_analyze') cd_start=CanonicalDocument[cd_start_id] cd_end=CanonicalDocument[cd_end_id] rs=SystematicReview[rs_id] return 405 if cd_start.nil? or cd_end.nil? or rs.nil? user_id = session['user_id'] tag_id=params['tag_id'] tag=Tag[tag_id] if accion=='add_tag' tag_name=params['value'].chomp return 405 if tag_name=="" tag=Tag.get_tag(tag_name) $db.transaction(:rollback=>:reraise) do TagBwCd.approve_tag(cd_start,cd_end,rs,tag,user_id) end elsif accion=='approve_tag' return 404 if tag.nil? $db.transaction(:rollback=>:reraise) do TagBwCd.approve_tag(cd_start,cd_end,rs,tag,user_id) end elsif accion=='reject_tag' return 404 if tag.nil? $db.transaction(:rollback=>:reraise) do TagBwCd.reject_tag(cd_start,cd_end,rs,tag,user_id) end else return [405,"I don't know the action to perform"] end partial("tags/tags_cd_rs_ref", :locals=>{cd_start: cd_start, cd_end:cd_end, review:rs, :nuevo=>true, user_id: user_id}) end |
#POST___tags_class__t_clase_id_add_tag_ ⇒ Object
Add a tag to a class tag
52 53 54 55 56 57 58 59 60 61 62 |
# File 'controllers/tag.rb', line 52 post '/tags/class/:t_clase_id/add_tag' do |t_clase_id| halt_unless_auth('tag_edit') t_class=T_Class[t_clase_id] raise NoTagClassIdError, t_clase_id if !t_class tag_name=params['value'].chomp return 405 if tag_name=="" tag=Tag.get_tag(tag_name) t_class.allocate_tag(tag) partial("tags/tags_class", :locals=>{t_class: t_class}) end |
#POST___tags_class__t_clase_id_remove_tag_ ⇒ Object
Remove tag from a class tag
65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'controllers/tag.rb', line 65 post '/tags/class/:t_clase_id/remove_tag' do |t_clase_id| halt_unless_auth('tag_edit') t_class=T_Class[t_clase_id] raise NoTagClassIdError, t_clase_id if !t_class tag=Tag[params['value']] raise NoTagIdError, value if !tag t_class.deallocate_tag(tag) partial("tags/tags_class", :locals=>{t_class: t_class}) end |
#POST___tags_classes_new_ ⇒ Object
Create a new class tag
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'controllers/tag.rb', line 11 post '/tags/classes/new' do halt_unless_auth('tag_edit') @review=SystematicReview[params['review_id']] stage= params['stage'] stage=nil if stage=="NIL" type = params['type'] raise Buhos::NoReviewIdError, params['review_id'] if !@review $db.transaction(:rollback=>:reraise) do T_Class.insert(:name=>params["name"], :systematic_review_id=>@review.id, :stage=>stage, :type=>type) end redirect back end |
#POST___user__user_id_change_password_ ⇒ Object
Change the password of a user
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'controllers/user.rb', line 76 post '/user/:user_id/change_password' do |user_id| @user=User[user_id] raise Buhos::NoUserIdError, user_id if !@user return 403 unless (is_session_user(user_id) or auth_to("user_admin")) password_1=params['password'] password_2=params['repeat_password'] if password_1!=password_2 (I18n::t("password.not_equal_password"), :error) redirect back else @user.change_password(password_1) (I18n::t("password.password_updated")) redirect "/user/#{@user[:id]}".to_sym end end |
#POST___user__user_id_compose_message_send_ ⇒ Object
Send a personal message
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
# File 'controllers/user.rb', line 140 post '/user/:user_id/compose_message/send' do |user_id| return 403 unless (auth_to('message_edit') and is_session_user(user_id)) @user=User[user_id] raise Buhos::NoUserIdError, user_id if !@user subject=params['subject'].chomp text=params['text'].chomp destination=params['to'] @user_to=User[destination] if @user_to Message.insert(:user_from=>user_id, :user_to=>destination, :reply_to=>nil, :time=>DateTime.now(), :subject=>subject, :text=>text, :viewed=>false) (t("messages.new_message_for_user", user_name:@user_to[:name])) else (t(:User_not_exists, user_id:destination), :error) end redirect "/user/#{user_id}/messages" end |
#POST__review__sr_id_canonical_documents_tags_actions ⇒ Object
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
# File 'controllers/reviews/canonical_documents.rb', line 110 post "/review/:sr_id/canonical_documents/tags/actions" do |sr_id| (sr_id) action=params['action'] result=Result.new if action=='add_for_all' or action=='remove_for_all' unless params['tags_all'] (t(:No_tag_defined), :error) redirect back end params['tags_all'].map(&:to_i).each do |tag_id| tag=Tag[tag_id] raise Buhos::NoTagIdError tag_id unless tag if action=='add_for_all' result.add_result(TagInCd.approve_tag_batch(@cds,@review,tag,@user_id)) else result.add_result(TagInCd.reject_tag_batch(@cds,@review,tag,@user_id)) end end elsif action=='add_new' unless params['new_tags'].chomp!="" (t(:No_tag_defined), :error) redirect back end tag=Tag.get_tag(params['new_tags'].chomp) raise Buhos::NoTagIdError tag_id unless tag result.add_result(TagInCd.approve_tag_batch(@cds,@review,tag,@user_id)) else raise "#{t(:Action_not_defined)}:#{action}" end add_result(result) redirect back end |
#PUT___allocation_user__user_id_review__rs_id_cd__cd_id_stage__stage_id_edit_instruction_ ⇒ Object
Provide instruction for a user on a given allocation
12 13 14 15 16 17 18 19 |
# File 'controllers/allocation.rb', line 12 put '/allocation/user/:user_id/review/:rs_id/cd/:cd_id/stage/:stage_id/edit_instruction' do |user_id, rs_id, cd_id,stage| halt_unless_auth('review_admin') pk = params['pk'] value = params['value'] AllocationCd.where(:systematic_review_id=>rs_id, :canonical_document_id=>cd_id, :user_id=>user_id, :stage=>stage).update(:instruction=>value.chomp) return true end |
#PUT___canonical_document_edit_field__field_ ⇒ Object
Edit a field on a canonical document
109 110 111 112 113 114 115 116 117 118 119 |
# File 'controllers/canonical_document.rb', line 109 put '/canonical_document/edit_field/:field' do |field| halt_unless_auth('canonical_document_admin') pk = params['pk'] value = params['value'] value=process_abstract_text(value) if field=='abstract' @cd=CanonicalDocument[pk] @cd.update(field.to_sym=>value.chomp) return true end |
#PUT___decision_review__review_id_user__user_id_canonical_document__cd_id_stage__stage_commentary_ ⇒ Object
Put a commentary for a specific document on analysis
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'controllers/decision.rb', line 29 put '/decision/review/:review_id/user/:user_id/canonical_document/:cd_id/stage/:stage/commentary' do |review_id, user_id, cd_id, stage| halt_unless_auth('review_analyze') pk = params['pk'] value = params['value'] $db.transaction(:rollback => :reraise) do des=Decision.where(:systematic_review_id => review_id, :user_id => user_id, :canonical_document_id => pk, :stage => stage).first if des des.update(:commentary => value) else Decision.insert(:systematic_review_id => review_id, :decision => nil, :user_id => user_id, :canonical_document_id => pk, :stage => stage, :commentary => value.strip) end end return 200 end |
#PUT___file_edit_field__campo_ ⇒ Object
Edit an attribute of a file
290 291 292 293 294 295 296 297 298 299 |
# File 'controllers/files.rb', line 290 put '/file/edit_field/:campo' do |field| halt_unless_auth('file_admin') return 505 unless %w{filename filetype}.include? field pk = params['pk'] value = params['value'] @arc=IFile[pk] @arc.update(field.to_sym => value.chomp) return true end |
#PUT___resolution_review__id_canonical_document__cd_id_stage__stage_user__user_id_resolution_commentary_ ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'controllers/resolutions.rb', line 42 put '/resolution/review/:id/canonical_document/:cd_id/stage/:stage/user/:user_id/resolution_commentary' do |rev_id, cd_id, stage, user_id| halt_unless_auth('review_admin') $db.transaction(:rollback => :reraise) do res=Resolution.where(:systematic_review_id=>rev_id, :canonical_document_id=>cd_id, :stage=>stage) if res.empty? Resolution.insert(:systematic_review_id=>rev_id, :canonical_document_id=>cd_id, :stage=>stage, :resolution=>Resolution::NO_RESOLUTION, :user_id=>user_id, :commentary=>params['value'].chomp) else res.update(:commentary=>params['value'].chomp) end end return 200 end |
#PUT___review__sr_id_edit_quality_criterion__attr_ ⇒ Object
Edit specific attribute of a field
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'controllers/reviews/quality_criteria.rb', line 43 put '/review/:sr_id/edit_quality_criterion/:attr' do |sr_id, attr| halt_unless_auth('review_admin') review=SystematicReview[sr_id] raise Buhos::NoReviewIdError, rs_id unless review return [500, t('quality_assesment.invalid_attribute', field:attr)] unless %w{order text scale_id}.include? attr qc_id = params['pk'] value = params['value'] qc=QualityCriterion[qc_id] raise Buhos::NoQualityCriterionIdError, qc_id unless qc srqc=SrQualityCriterion[systematic_review_id:sr_id, quality_criterion_id:qc_id] if %w{order scale_id}.include? attr srqc.update(attr.to_sym => value) elsif attr=='text' res=Buhos::QualityCriteriaProcessor.change_criterion_name(review,qc,value) return[500, res.] unless res.success? end return 200 end |
#PUT___review__sr_id_extract_information_cd__cd_id_user__user_id_update_field_ ⇒ Object
Update information of a specific personalized field
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'controllers/reviews/extract_information.rb', line 60 put '/review/:sr_id/extract_information/cd/:cd_id/user/:user_id/update_field' do |sr_id,cd_id,user_id| halt_unless_auth('review_analyze') @sr=SystematicReview[sr_id] raise Buhos::NoReviewIdError, sr_id if !@sr @cd=CanonicalDocument[cd_id] raise Buhos::NoCdIdError, cd_id if !@cd @user=User[user_id] raise Buhos::NoUserIdError, user_id if !@user field = params['pk'] value = params['value'] fila=@sr.analysis_cd_user_row(@cd,@user) if value.nil? value_store=nil elsif value.is_a? Array value_store=value.join(",") else value_store=value.chomp end @sr.analysis_cd.where(:id=>fila[:id]).update(field.to_sym=>value_store) return true end |
#PUT___review__sr_id_quality_assessment_cd__cd_id_user__user_id__action_ ⇒ Object
Update information of a specific quality criterion
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'controllers/reviews/quality_assesment.rb', line 73 put '/review/:sr_id/quality_assessment/cd/:cd_id/user/:user_id/:action' do |sr_id,cd_id,user_id, action| halt_unless_auth('review_analyze') @sr=SystematicReview[sr_id] raise Buhos::NoReviewIdError, sr_id if !@sr @cd=CanonicalDocument[cd_id] raise Buhos::NoCdIdError, cd_id if !@cd @user=User[user_id] raise Buhos::NoUserIdError, user_id if !@user qc_id= params['pk'] value = params['value'] criteria={systematic_review_id:sr_id, user_id:user_id, canonical_document_id:cd_id, quality_criterion_id:qc_id} cd_qc=CdQualityCriterion[criteria] scale_id=SrQualityCriterion[systematic_review_id:sr_id, quality_criterion_id:qc_id][:scale_id] field=case action when 'evaluation' then :value when 'commentary' then :commentary else raise t(:Action_not_defined) end if cd_qc cd_qc.update(field=>value) else return [500, I18n::t("quality_assesment.cant_comment_before_assessment")] if field==:commentary CdQualityCriterion.insert(criteria.merge({scale_id:scale_id, field=>value})) end return true end |
#PUT___review_edit_field__attr_id__attr_ ⇒ Object
Edit specific attribute of a field
50 51 52 53 54 55 56 57 58 59 |
# File 'controllers/reviews/fields.rb', line 50 put '/review/edit_field/:attr_id/:attr' do |attr_id,attr| halt_unless_auth('review_admin') return [500, t('sr_edit_field.invalid', field:attr)] unless %w{order name description type options}.include? attr pk = params['pk'] value = params['value'] campo_o=SrField[pk] return [t('sr_edit_field.doesnt_exist_db', field_id:attr_id)] unless attr campo_o.update({attr.to_sym=>value}) return 200 end |
#PUT___tag_rename_review__sr_id_user__user_id_ ⇒ Object
295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 |
# File 'controllers/tag.rb', line 295 put '/tag/rename/review/:sr_id/user/:user_id' do |sr_id, user_id| halt_unless_auth('tag_edit') pk = params['pk'] value = params['value'].chomp @review=SystematicReview[sr_id] raise Buhos::NoReviewIdError, sr_id if !@review @user = User[user_id] raise Buhos::NoUserIdError, user_id if !@user @tag = Tag[pk] raise Buhos::NoTagIdError, pk if !@tag $db.transaction do new_tag=Tag.get_tag(value) TagInCd.where(:tag_id=>pk, :systematic_review_id=>sr_id, :user_id=>user_id).update(:tag_id=>new_tag.id) @tag.delete_if_unused end return 200 end |
#PUT___tags_classes_edit_field__field_ ⇒ Object
29 30 31 32 33 34 35 36 37 38 |
# File 'controllers/tag.rb', line 29 put '/tags/classes/edit_field/:field' do |field| halt_unless_auth('tag_edit') pk = params['pk'] value = params['value'] value = nil if value=="NIL" return 405 unless %w{name stage type}.include? field T_Class[pk].update(field.to_sym=>value) return 200 end |
#PUT___user_edit__field_ ⇒ Object
Edit an attribute of a user
49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'controllers/user.rb', line 49 put '/user/edit/:field' do |field| put_editable(request) {|id,value| user=User[id] halt 403 unless (auth_to('user_admin') or (is_session_user(id) and %w{name language}.include? field)) raise Buhos::NoUserIdError, id if !user if field=='login' halt 405, t(:Login_already_used) if User.where(:login=>value).exclude(:id=>id).count>0 halt 405, t(:Login_cant_be_nil) if value.chomp=="" end user.update(field.to_sym=>value) } end |
#PUT__tag_edit ⇒ Object
Edit a tag
41 42 43 44 45 46 47 48 49 |
# File 'controllers/tag.rb', line 41 put "/tag/edit" do halt_unless_auth('tag_edit') pk = params['pk'] value = params['value'].chomp return [405,"Debe ingresar algun text"] if value=="" Tag[pk].update(:text=>value) return 200 end |