diff --git a/app/models/guidance.rb b/app/models/guidance.rb index 8c80dec..c2f93fb 100644 --- a/app/models/guidance.rb +++ b/app/models/guidance.rb @@ -15,8 +15,6 @@ belongs_to :guidance_group belongs_to :question has_and_belongs_to_many :themes, join_table: "themes_in_guidance" - # depricated, but required for migration "single_group_for_guidance" - has_and_belongs_to_many :guidance_groups, join_table: "guidance_in_group" diff --git a/app/models/guidance_group.rb b/app/models/guidance_group.rb index 932a921..cc4bd8f 100644 --- a/app/models/guidance_group.rb +++ b/app/models/guidance_group.rb @@ -11,7 +11,7 @@ # Possibly needed for active_admin # -relies on protected_attributes gem as syntax depricated in rails 4.2 attr_accessible :organisation_id, :name, :optional_subset, :published, - :organisation, :as => [:default, :admin] + :org, :as => [:default, :admin] attr_accessible :dmptemplate_ids, :as => [:default, :admin] @@ -25,7 +25,7 @@ - validates :name, :organisation, presence: true + validates :name, :org, presence: true ## # Converts a guidance group to a string containing the display name diff --git a/app/models/org.rb b/app/models/org.rb index 46f5d72..bd32c00 100644 --- a/app/models/org.rb +++ b/app/models/org.rb @@ -19,8 +19,9 @@ # -relies on protected_attributes gem as syntax depricated in rails 4.2 attr_accessible :abbreviation, :banner_text, :logo, :remove_logo, :logo_file_name, :name, :target_url, - :organisation_type_id, :wayfless_entity, :parent_id, :sort_name, - :token_permission_type_ids, :language_id, :contact_email, :language + :organisation_type_id, :wayfless_entity, :parent_id, :sort_name, + :token_permission_type_ids, :language_id, :contact_email, :language, + :org_type, :token_permission_types ## # Validators diff --git a/app/models/user.rb b/app/models/user.rb index 4070aac..1a3df5c 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -43,7 +43,7 @@ :firstname, :last_login,:login_count, :orcid_id, :password, :shibboleth_id, :user_status_id, :surname, :user_type_id, :org_id, :skip_invitation, :other_organisation, :accept_terms, :role_ids, :dmponline3, :api_token, - :organisation, :language, :language_id + :organisation, :language, :language_id, :org, :perms, :confirmed_at validates :email, email: true, allow_nil: true, uniqueness: true diff --git a/db/seeds.rb b/db/seeds.rb index 8a016e0..49b58d2 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -2,651 +2,439 @@ # This file should contain all the record creation needed to seed the database with its default values. # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup). -languages = { - 'English(UK)' => { - abbreviation: 'en-UK', - description: 'UK English language used as default', - name: 'English(UK)', - default_language: true - }, - 'FR' => { - abbreviation: 'fr', - description: '', - name: 'fr', +# Identifier Schemes +# ------------------------------------------------------- +identifier_schemes = [ + {name: 'orcid', description: 'ORCID researcher identifiers', active: true}, + {name: 'shibboleth', description: 'Shibboleth', active: false}, + {name: 'facebook', description: 'Facebook OAuth', active: false} +] +identifier_schemes.map{ |is| IdentifierScheme.create!(is) if IdentifierScheme.find_by(name: is[:name]).nil? } + +# Question Formats +# ------------------------------------------------------- +question_formats = [ + {title: "Text area"}, + {title: "Text field"}, + {title: "Radio buttons"}, + {title: "Check box"}, + {title: "Dropdown"}, + {title: "Multi select box"} +] +question_formats.map{ |qf| QuestionFormat.create!(qf) if QuestionFormat.find_by(title: qf[:title]).nil? } + +# Languages (check config/locales for any ones not defined here) +# ------------------------------------------------------- +languages = [ + {abbreviation: 'en-UK', + description: 'UK English', + name: 'English (UK)', + default_language: true}, + {abbreviation: 'en-US', + description: 'US English', + name: 'English (US)', + default_language: false}, + {abbreviation: 'fr', + description: 'French', + name: 'French', + default_language: false}, + {abbreviation: 'de', + description: 'German', + name: 'German', + default_language: false}, + {abbreviation: 'es', + description: 'Spanish', + name: 'Spanish', + default_language: false} +] +languages.map{ |l| Language.create!(l) if Language.find_by(abbreviation: l[:abbreviation]).nil? } + +# Scan through the locale files and add an entry if a file is present but +# not defined in this seed file +Dir.entries("#{Rails.root.join("config", "locales").to_s}").each do |f| + if f[-4..-1] == '.yml' + lang = f.gsub('.yml', '') + + if Language.where(abbreviation: lang).empty? + Language.create!({ + abbreviation: lang, + description: lang, + name: lang, default_language: false - }, - 'DE' => { - abbreviation: 'de', - description: '', - name: 'de', - default_language: false - }, - 'ES' => { - abbreviation: 'es', - description: '', - name: 'es', - default_language: false - } -} - -languages.each do |l, details| - if Language.where(name: details[:name]).empty? - language = Language.new - language.abbreviation = details[:abbreviation] - language.description = details[:description] - language.name = details[:name] - language.default_language = details[:default_language] - language.save! - end -end - -regions = { - 'UK' => { - abbreviation: 'uk', - description: 'default region', - name: 'UK', - }, - 'DE' => { - abbreviation: 'de', - description: '', - name: 'DE', - }, - 'Horizon2020' => { - abbreviation: 'horizon', - description: 'European super region', - name: 'Horizon2020', - } -} - -regions.each do |l, details| - if Region.where(name: details[:name]).empty? - region = Region.new - region.abbreviation = details[:abbreviation] - region.description = details[:description] - region.name = details[:name] - region.save! - end -end - -region_groups = { - 'UK' => { - super_region_name: 'Horizon2020', - region_name: 'UK', - }, - 'DE' => { - super_region_name: 'Horizon2020', - region_name: 'DE', - } -} - -region_groups.each do |l, details| - if RegionGroup.find_by(region_id: details[:region_name]).blank? - region_group = RegionGroup.new - region_group.super_region_id = Region.find_by_name(details[:super_region_name]).id - region_group.region_id = Region.find_by_name(details[:region_name]).id - region_group.save! - end -end - -identifier_schemes = { - 'orcid' => { - name: 'orcid', - description: 'ORCID provides a persistent digital identifier for researchers', - active: true - } -} - -identifier_schemes.each do |l, details| - if IdentifierScheme.where(name: details[:name]).empty? - scheme = IdentifierScheme.new({ - name: details[:name], - description: details[:description], - active: details[:active] - }) - scheme.save! - end -end - -organisation_types = { - 'Organisation' => { - name: "Organisation" - }, - 'Funder' => { - name: "Funder" - }, - 'Project' => { - name: "Project" - }, - 'Institution' => { - name: "Institution" - }, - 'Research Institute' => { - name: "Research Institute" - } - } - - organisation_types.each do |org_type, details| - if OrganisationType.where(name: details[:name]).empty? - organisation_type = OrganisationType.new - organisation_type.name = details[:name] - organisation_type.save! - end - end - - organisations = { - 'Your Organization' => { - name: "My Regional Curation Centre", - abbreviation: "RCC", - sort_name: "MyRegionalCurationCenter", - organisation_type: "Organisation", - description: "An example: Regional Curation Center concerned with research data management (typically the organization hosting this website)", - banner_text: "Example: Your Regional Curation Center", - region: 'UK', - language: 'English(UK)' - }, - 'Global Funding Organization' => { - name: "Global Research Center", - abbreviation: "EGRC", - sort_name: "GlobalResearchCenter", - organisation_type: "Funder", - description: "An example: Research funding agency", - banner_text: "Example: Global Research Center", - region: 'UK', - language: 'English(UK)' - }, - 'Regional Funding Organization' => { - name: "Regional Science Federation", - abbreviation: "RegSciFed", - sort_name: "RegionalScienceFederation", - organisation_type: "Funder", - description: "An example: Regional funding agency for scientific research", - banner_text: "Example: Regional Science Federation", - region: 'UK', - language: 'English(UK)' - }, - 'Example Institution'=> { - name: "Capital City College", - abbreviation: "CapColl", - sort_name: "CapitalCityCollege", - organisation_type: "Institution", - description: "An example: Academic institution", - banner_text: "Example: Capital City College ... go mascots!!", - region: 'UK', - language: 'English(UK)' - } - } - - organisations.each do |org, details| - if Org.where(abbreviation: details[:abbreviation]).empty? - organisation = Org.new - organisation.name = details[:name] - organisation.abbreviation = details[:abbreviation] - organisation.sort_name = details[:sort_name] - organisation.organisation_type = OrganisationType.find_by_name(details[:organisation_type]) - organisation.region_id = Region.find_by_name(details[:region]).id - organisation.language_id = Language.find_by_name(details[:language]).id - organisation.save! - end - end - -roles = { - 'admin' => { - name: "admin" #depricated - }, - 'org_admin' => { - name: "org_admin" #depricated - }, - 'user' => { - name: "user" #depricated - }, - 'add_organisations' => { - name: 'add_organisations' - }, - 'change_org_affiliation' => { - name: 'change_org_affiliation' - }, - 'grant_permissions' => { - name: 'grant_permissions' - }, - 'modify_templates' => { - name: 'modify_templates' - }, - 'modify_guidance' => { - name: 'modify_guidance' - }, - 'use_api' => { - name: 'use_api' - }, - 'change_org_details' => { - name: 'change_org_details' - }, - 'grant_api_to_orgs' => { - name: 'grant_api_to_orgs' - } -} - -roles.each do |role, details| - if Role.where(name: details[:name]).empty? - role = Role.new - role.name = details[:name] - role.save! - end -end - -users = { - 'Super admin' => { - email: "super_admin@example.com", - password: "password123", - firstname: "RCC Super", - surname: "Admin", - password_confirmation: "password123", - organisation: "RCC", - language: 'English(UK)', - roles: ['admin','org_admin','add_organisations','change_org_affiliation','grant_permissions','modify_templates','modify_guidance','use_api','change_org_details','grant_api_to_orgs'], - accept_terms: true, - confirmed_at: Time.zone.now - }, - 'Funder admin' => { - email: "funder_admin@example.com", - password: "password123", - password_confirmation: "password123", - firstname: "Funder", - surname: "Admin", - organisation: "RegSciFed", - language: 'English(UK)', - roles: ['org_admin','grant_permissions','modify_templates','modify_guidance','change_org_details'], - accept_terms: true, - confirmed_at: Time.zone.now - }, - 'Organizational admin' => { - email: "org_admin@example.com", - password: "password123", - password_confirmation: "password123", - firstname: "Organization", - surname: "Admin", - organisation: "CapColl", - language: 'English(UK)', - roles: ['org_admin','grant_permissions','modify_templates','modify_guidance','change_org_details'], - accept_terms: true, - confirmed_at: Time.zone.now - }, - 'Organizational user' => { - email: "org_user@example.com", - password: "password123", - password_confirmation: "password123", - firstname: "Jane", - surname: "Researcher", - organisation: "CapColl", - language: 'English(UK)', - roles: ['user'], - accept_terms: true, - confirmed_at: Time.zone.now - }, - 'Organizational user' => { - email: "org_user@example.com", - password: "password123", - password_confirmation: "password123", - firstname: "Jane", - surname: "Researcher", - organisation: "CapColl", - language: 'English(UK)', - roles: ['user'], - accept_terms: true, - confirmed_at: Time.zone.now - } - } - -users.each do |user, details| - if User.where(email: details[:email]).empty? - usr = User.new - else - usr = User.where(email: details[:email]) - end - usr.email = details[:email] - usr.password = details[:password] - usr.password_confirmation = details[:password_confirmation] - usr.confirmed_at = details[:confirmed_at] - usr.organisation_id = Org.find_by_abbreviation(details[:organisation]).id - usr.language_id = Language.find_by_name(details[:language]).id - details[:roles].each do |role| - usr.roles << Role.find_by_name(role) + }) end - usr.accept_terms = details[:accept_terms] - usr.save! + end end - themes = { - "Theme 1" => { - title: "Theme 1", - locale: "en" - }, - "Theme 2" => { - title: "Theme 2", - locale: "en" - }, - "Theme 3" => { - title: "Theme 3", - locale: "en", - description: "Theme 3 description." - }, - "Theme 4" => { - title: "Theme 4", - locale: "en", - description: "Theme 4 description." - } - } +# Regions (create the super regions first and then create the rest) +# ------------------------------------------------------- +regions = [ + {abbreviation: 'horizon', + description: 'European super region', + name: 'Horizon2020', + sub_regions: [ + {abbreviation: 'uk', + description: 'United Kingdom', + name: 'UK'}, + {abbreviation: 'de', + description: 'Germany', + name: 'DE'}, + {abbreviation: 'fr', + description: 'France', + name: 'FR'}, + {abbreviation: 'es', + description: 'Spain', + name: 'ES'} + ]}, + {abbreviation: 'us', + description: 'United States of America', + name: 'US'} +] - themes.each do |t, details| - if Theme.where(title: details[:title]).empty? - theme = Theme.new - theme.title = details[:title] - theme.locale = details[:locale] - theme.description = details[:description] - theme.save! - end - end +# Create the region. If it has subregions create them and then connect them +regions.each do |r| + srs = r[:sub_regions] + r.delete(:sub_regions) unless r[:sub_regions].nil? + + region = Region.create!(r) if Region.find_by(abbreviation: r[:abbreviation]).nil? + + unless srs.nil? + srs.each do |sr| + if Region.find_by(abbreviation: sr[:abbreviation]).nil? + subregion = Region.create!(sr) + RegionGroup.create!({region_id: subregion.id, super_region_id: region.id}) + end + end + end +end - question_formats = { - "Text area" => { - title: "Text area" - }, - "Text field" => { - title: "Text field" - }, - "Radio buttons" => { - title: "Radio buttons" - }, - "Check box" => { - title: "Check box" - }, - "Dropdown" => { - title: "Dropdown" - }, - "Multi select box" => { - title: "Multi select box" - }, - } +# Permissions +# ------------------------------------------------------- +perms = [ + {name: 'add_organisations'}, + {name: 'change_org_affiliation'}, + {name: 'grant_permissions'}, + {name: 'modify_templates'}, + {name: 'modify_guidance'}, + {name: 'use_api'}, + {name: 'change_org_details'}, + {name: 'grant_api_to_orgs'} +] - question_formats.each do |qf, details| - if QuestionFormat.where(title: details[:title]).empty? - question_format = QuestionFormat.new - question_format.title = details[:title] - question_format.save! - end - end +perms.map{ |p| Perm.create!(p) if Perm.find_by(name: p[:name]).nil? } - guidance_groups = { - "RCC Guidance" => { - name: "My organization guidance (optional generic guidance you provide for users)", - organisation: "RCC", - optional_subset: true - }, - "Global Research Center Guidance" => { - name: "Global Research Center (Funder specific guidance)", - organisation: "EGRC", - optional_subset: false - }, - "Regional Science Federation Guidance" => { - name: "Regional Science Federation (Funder specific guidance)", - organisation: "RegSciFed", - optional_subset: false - }, - "Institutional Guidance" => { - name: "CapColl - School of Math and Science (optional institutional guidance)", - organisation: "CapColl", - optional_subset: true - } - } +# Guidance Themes +# ------------------------------------------------------- +themes = [ + {title: 'Data Description'}, + {title: 'Data Format'}, + {title: 'Data Volume'}, + {title: 'Data Collection'}, + {title: 'Metadata & Documentation'}, + {title: 'Ethics & Privacy'}, + {title: 'Intellectual Property Rights'}, + {title: 'Storage & Security'}, + {title: 'Data Sharing'}, + {title: 'Data Repository'}, + {title: 'Preservation'}, + {title: 'Roles & Responsibilities'}, + {title: 'Budget'}, + {title: 'Related Policies'} +] +themes.map{ |t| Theme.create!(t) if Theme.find_by(title: t[:title]).nil? } - guidance_groups.each do |gg, details| - if GuidanceGroup.where(name: details[:name]).empty? - guidance_group = GuidanceGroup.new - guidance_group.name = details[:name] - guidance_group.organisation = Org.find_by_abbreviation(details[:organisation]) - guidance_group.optional_subset = details[:optional_subset] - guidance_group.save! - end - end +# Token Permission Types +# ------------------------------------------------------- +token_permission_types = [ + {token_type: 'guidances', text_description: 'allows a user access to the guidances api endpoint'}, + {token_type: 'plans', text_description: 'allows a user access to the plans api endpoint'} +] +token_permission_types.map{ |tpt| TokenPermissionType.create!(tpt) if TokenPermissionType.find_by(token_type: tpt[:token_type]).nil? } - guidances = { - "Guidance 1" => { - text: "Guidance text", - guidance_group: "My organization guidance (optional generic guidance you provide for users)", - themes: ["Theme 4"] - }, - "Guidance 2" => { - text: "Guidance text", - guidance_group: "Global Research Center (Funder specific guidance)", - themes: ["Theme 2"] - }, - "Guidance 3" => { - text: "Guidance text", - guidance_group: "Global Research Center (Funder specific guidance)", - themes: ["Theme 3"] - }, - "Guidance 4" => { - text: "Guidance text", - guidance_group: "Regional Science Federation (Funder specific guidance)", - themes: ["Theme 1"] - }, - "Guidance 4" => { - text: "Guidance text", - guidance_group: "CapColl - School of Math and Science (optional institutional guidance)", - themes: ["Theme 1"] - } - } +# Create our generic organisation, a funder and a University +# ------------------------------------------------------- +orgs = [ + {name: GlobalHelpers.constant("organisation_types.managing_organisation"), + abbreviation: 'CC', + banner_text: 'This is an example organisation', + org_type: 3, + language_id: Language.find_by(abbreviation: I18n.locale).id, + token_permission_types: TokenPermissionType.all}, + {name: 'Government Agency', + abbreviation: 'GA', + org_type: 2, + language_id: Language.find_by(abbreviation: I18n.locale).id}, + {name: 'University of Exampleland', + abbreviation: 'UOS', + org_type: 1, + language_id: Language.find_by(abbreviation: I18n.locale).id} +] +orgs.map{ |o| Org.create!(o) if Org.find_by(abbreviation: o[:abbreviation]).nil? } - guidances.each do |g, details| - if Guidance.where(text: details[:text]).empty? - guidance = Guidance.new - guidance.text = details[:text] - guidance.guidance_groups << GuidanceGroup.find_by_name(details[:guidance_group]) - details[:themes].each do |theme| - guidance.themes << Theme.find_by_title(theme) - end - guidance.save! - end - end +# Create a Super Admin associated with our generic organisation, +# an Org Admin for our funder and an Org Admin and User for our University +# ------------------------------------------------------- +users = [ + {email: "super_admin@example.com", + firstname: "Super", + surname: "Admin", + password: "password123", + password_confirmation: "password123", + org: Org.find_by(abbreviation: 'CC'), + language: Language.find_by(abbreviation: I18n.locale), + perms: Perm.all, + accept_terms: true, + confirmed_at: Time.zone.now}, + {email: "funder_admin@example.com", + firstname: "Funder", + surname: "Admin", + password: "password123", + password_confirmation: "password123", + org: Org.find_by(abbreviation: 'GA'), + language: Language.find_by(abbreviation: I18n.locale), + perms: Perm.where.not(name: ['admin', 'add_organisations', 'change_org_affiliation']), + accept_terms: true, + confirmed_at: Time.zone.now}, + {email: "org_admin@example.com", + firstname: "Organisational", + surname: "Admin", + password: "password123", + password_confirmation: "password123", + org: Org.find_by(abbreviation: 'UOS'), + language: Language.find_by(abbreviation: I18n.locale), + perms: Perm.where.not(name: ['admin', 'add_organisations', 'change_org_affiliation']), + accept_terms: true, + confirmed_at: Time.zone.now}, + {email: "org_user@example.com", + firstname: "Organisational", + surname: "User", + password: "password123", + password_confirmation: "password123", + org: Org.find_by(abbreviation: 'UOS'), + language: Language.find_by(abbreviation: I18n.locale), + accept_terms: true, + confirmed_at: Time.zone.now} +] +users.map{ |u| User.create!(u) if User.find_by(email: u[:email]).nil? } - templates = { - "RCC" => { - title: "Regional Curation Center Template", - description: "The default RCC template", - published: true, - organisation: "RCC", - locale: "en", - is_default: true - }, - "Global Research Center" => { - title: "Global Research Center Award", - description: "Funder template description", - published: true, - organisation: "EGRC", - locale: "en", - is_default: false - }, - "Regional Science Federation" => { - title: "Regional Science Federation Grant - Summary", - description: "Funder template description for phase 1", - published: true, - organisation: "RegSciFed", - locale: "en", - is_default: false - }, - "Regional Science Federation2" => { - title: "Regional Science Federation Grant - Finalized", - description: "Funder template description for phase 2", - published: true, - organisation: "RegSciFed", - locale: "en", - is_default: false - } - } +# Create a Guidance Group for our organisation and the funder +# ------------------------------------------------------- +guidance_groups = [ + {name: "Generic Guidance (provided by the example curation centre)", + org: Org.find_by(abbreviation: 'CC'), + optional_subset: true}, + {name: "Government Agency Advice (Funder specific guidance)", + org: Org.find_by(abbreviation: 'GA'), + optional_subset: false} +] +guidance_groups.map{ |gg| GuidanceGroup.create!(gg) if GuidanceGroup.find_by(name: gg[:name]).nil? } - templates.each do |t, details| - org = Org.where(abbreviation: details[:organisation]).first - - if Dmptemplate.where(organisation: org).where(title: details[:title]).empty? - template = Dmptemplate.new - template.title = details[:title] - template.description = details[:description] - template.published = details[:published] - template.locale = details[:locale] - template.is_default = details[:is_default] - template.organisation = org - template.save! - end - end +# Initialize with the generic Roadmap guidance and a sample funder guidance +# ------------------------------------------------------- +guidances = [ + {text: "● Give a summary of the data you will collect or create, noting the content, coverage and data type, e.g., tabular data, survey data, experimental measurements, models, software, audiovisual data, physical samples, etc. +● Consider how your data could complement and integrate with existing data, or whether there are any existing data or methods that you could reuse. +● If purchasing or reusing existing data, explain how issues such as copyright and IPR have been addressed. You should aim to m +inimise any restrictions on the reuse (and subsequent sharing) of third-party data.", + guidance_groups: [GuidanceGroup.first], + published: true, + themes: [Theme.find_by(title: 'Data Description')]}, + {text: "● Clearly note what format(s) your data will be in, e.g., plain text (.txt), comma-separated values (.csv), geo-referenced TIFF (.tif, .tfw). +● Explain why you have chosen certain formats. Decisions may be based on staff expertise, a preference for open formats, the standards accepted by data centres or widespread usage within a given community. +● Using standardised, interchangeable or open formats ensures the long-term usability of data; these are recommended for sharing and archiving. +● See UK Data Service guidance on recommended formats or DataONE Best Practices for file formats", + guidance_groups: [GuidanceGroup.first], + published: true, + themes: [Theme.find_by(title: 'Data Format')]}, + {text: "● Note what volume of data you will create in MB/GB/TB +● Consider the implications of data volumes in terms of storage, access and preservation. Do you need to include additional costs? +● Consider whether the scale of the data will pose challenges when sharing or transferring data between sites; if so, how will you address these challenges?", + guidance_groups: [GuidanceGroup.first], + published: true, + themes: [Theme.find_by(title: 'Data Volume')]}, + {text: "● Outline how the data will be collected and processed. This should cover relevant standards or methods, quality assurance and data organisation. +● Indicate how the data will be organised during the project, mentioning, e.g., naming conventions, version control and folder structures. Consistent, well-ordered research data will be easier to find, understand and reuse +● Explain how the consistency and quality of data collection will be controlled and documented. This may include processes such as calibration, repeat samples or measurements, standardised data capture, data entry validation, peer review of data or representation with controlled vocabularies. +● See the DataOne Best Practices for data quality", + guidance_groups: [GuidanceGroup.first], + published: true, + themes: [Theme.find_by(title: 'Data Collection')]}, + {text: "● What metadata will be provided to help others identify and discover the data? +● Researchers are strongly encouraged to use community metadata standards where these are in place. The Research Data Alliance offers a Directory of Metadata Standards. +● Consider what other documentation is needed to enable reuse. This may include information on the methodology used to collect the data, analytical and procedural information, definitions of variables, units of measurement, any assumptions made, the format and file type of the data and software used to collect and/or process the data. +● Consider how you will capture this information and where it will be recorded, e.g., in a database with links to each item, in a ‘readme’ text file, in file headers, etc. ", + guidance_groups: [GuidanceGroup.first], + published: true, + themes: [Theme.find_by(title: 'Metadata & Documentation')]}, + {text: "● Investigators carrying out research involving human participants should request consent to preserve and share the data. Do not just ask for permission to use the data in your study or make unnecessary promises to delete it at the end. +● Consider how you will protect the identity of participants, e.g., via anonymisation or using managed access procedures. +● Ethical issues may affect how you store and transfer data, who can see/use it and how long it is kept. You should demonstrate that you are aware of this and have planned accordingly. +● See UK Data Service guidance on consent for data sharing +● See ICPSR approach to confidentiality and Health Insurance Portability and Accountability Act (HIPAA) regulations for health research", + guidance_groups: [GuidanceGroup.first], + published: true, + themes: [Theme.find_by(title: 'Ethics & Privacy')]}, + {text: "● State who will own the copyright and IPR of any new data that you will generate. For multi-partner projects, IPR ownership should be covered in the consortium agreement. +● Outline any restrictions needed on data sharing, e.g., to protect proprietary or patentable data. +● Explain how the data will be licensed for reuse. See the DCC guide on How to license research data and EUDAT’s data and software licensing wizard.", + guidance_groups: [GuidanceGroup.first], + published: true, + themes: [Theme.find_by(title: 'Intellectual Property Rights')]}, + {text: "● Describe where the data will be stored and backed up during the course of research activities. This may vary if you are doing fieldwork or working across multiple sites so explain each procedure. +● Identify who will be responsible for backup and how often this will be performed. The use of robust, managed storage with automatic backup, for example, that provided by university IT teams, is preferable. Storing data on laptops, computer hard drives or external storage devices alone is very risky. +● See UK Data Service Guidance on data storage or DataONE Best Practices for storage +● Also consider data security, particularly if your data is sensitive e.g., detailed personal data, politically sensitive information or trade secrets. Note the main risks and how these will be managed. +● Identify any formal standards that you will comply with, e.g., ISO 27001. See the DCC Briefing Paper on Information Security Management -ISO 27000 and UK Data Service guidance on data security", + guidance_groups: [GuidanceGroup.first], + published: true, + themes: [Theme.find_by(title: 'Storage & Security')]}, + {text: "● How will you share the data e.g. deposit in a data repository, use a secure data service, handle data requests directly or use another mechanism? The methods used will depend on a number of factors such as the type, size, complexity and sensitivity of the data. +● When will you make the data available? Research funders expect timely release. They typically allow embargoes but not prolonged exclusive use. +● Who will be able to use your data? If you need to restricted access to certain communities or apply data sharing agreements, explain why. +● Consider strategies to minimise restrictions on sharing. These may include anonymising or aggregating data, gaining participant consent for data sharing, gaining copyright permissions, and agreeing a limited embargo period. +● How might your data be reused in other contexts? Where there is potential for reuse, you should use standards and formats that facilitate this, and ensure that appropriate metadata is available online so your data can be discovered. Persistent identifiers should be applied so people can reliably and efficiently find your data. They also help you to track citations and reuse.", + guidance_groups: [GuidanceGroup.first], + published: true, + themes: [Theme.find_by(title: 'Data Sharing')]}, + {text: "● Where will the data be deposited? If you do not propose to use an established repository, the data management plan should demonstrate that the data can be curated effectively beyond the lifetime of the grant. +● It helps to show that you have consulted with the repository to understand their policies and procedures, including any metadata standards. +● An international list of data repositories is available via Re3data and some universities or publishers provide lists of recommendations e.g. PLOS ONE recommended repositories", + guidance_groups: [GuidanceGroup.first], + published: true, + themes: [Theme.find_by(title: 'Data Repository')]}, + {text: "● Indicate which data are of long-term value and should be shared and/or preserved. +● Outline the plans for data sharing and preservation - how long will the data be retained and where will it be archived? +● Will additional resources be needed to prepare data for deposit or meet any charges from data repositories? See the DCC guide: How to appraise and select research data for curation or DataONE Best Practices: Identifying data with long-term value", + guidance_groups: [GuidanceGroup.first], + published: true, + themes: [Theme.find_by(title: 'Preservation')]}, + {text: "● Outline the roles and responsibilities for all activities, e.g., data capture, metadata production, data quality, storage and backup, data archiving & data sharing. Individuals should be named where possible. +● For collaborative projects you should explain the coordination of data management responsibilities across partners. +● See UK Data Service guidance on data management roles and responsibilities or DataONE Best Practices: Define roles and assign responsibilities for data management", + guidance_groups: [GuidanceGroup.first], + published: true, + themes: [Theme.find_by(title: 'Roles & Responsibilities')]}, + {text: "● Carefully consider and justify any resources needed to deliver the plan. These may include storage costs, hardware, staff time, costs of preparing data for deposit and repository charges. +● Outline any relevant technical expertise, support and training that is likely to be required and how it will be acquired. +● If you are not depositing in a data repository, ensure you have appropriate resources and systems in place to share and preserve the data. See UK Data Service guidance on costing data management", + guidance_groups: [GuidanceGroup.first], + published: true, + themes: [Theme.find_by(title: 'Budget')]}, + {text: "● Consider whether there are any existing procedures that you can base your approach on. If your group/department has local guidelines that you work to, point to them here. +● List any other relevant funder, institutional, departmental or group policies on data management, data sharing and data security. ", + guidance_groups: [GuidanceGroup.first], + published: true, + themes: [Theme.find_by(title: 'Related Policies')]}, + {text: "Please tell us how much data you plan to collect and what format it will be in once its deposited.", + guidance_groups: [GuidanceGroup.last], + published: true, + themes: [Theme.find_by(title: 'Data Description')]} +] +guidances.map{ |g| Guidance.create!(g) if Guidance.find_by(text: g[:text]).nil? } - phases = { - "RCC" => { - title: "Regional CurationCenter Data Management Plan", - number: 1, - template: "Regional Curation Center Template" - }, - "EGRC Template" => { - title: "Global Research Center Annual Award", - number: 1, - template: "Global Research Center Award" - }, - "RegSciFed Template" => { - title: "Regional Science Federation - Preliminary", - number: 1, - template: "Regional Science Federation Grant - Summary" - }, - "RegSciFed Template2" => { - title: "Regional Science Federation - Final", - number: 1, - template: "Regional Science Federation Grant - Finalized" - } - } +# Create a default template for the curation centre and one for the example funder +# ------------------------------------------------------- +templates = [ + {title: "My Curation Center's Default Template", + description: "The default template", + published: true, + org: Org.find_by(abbreviation: 'CC'), + is_default: true}, + {title: "Department of Testing Award", + published: true, + org: Org.find_by(abbreviation: 'GA'), + is_default: false} +] +templates.map{ |t| Template.create!(t) if Template.find_by(title: t[:title]).nil? } - phases.each do |p, details| - if Phase.where(title: details[:title]).empty? - phase = Phase.new - phase.title = details[:title] - phase.number = details[:number] - phase.dmptemplate = Dmptemplate.find_by_title(details[:template]) - phase.save! - end - end +# Create 2 phases for the funder's template and one for our generic template +# ------------------------------------------------------- +phases = [ + {title: "Generic Data Management Planning Template", + number: 1, + template: Template.find_by(title: "My Curation Center's Default Template"), + modifiable: false}, + {title: "Preliminary Statement of Work", + number: 1, + template: Template.find_by(title: "Department of Testing Award"), + modifiable: false}, + {title: "Detailed Overview", + number: 2, + template: Template.find_by(title: "Department of Testing Award"), + modifiable: false} +] +phases.map{ |p| Phase.create!(p) if Phase.find_by(title: p[:title]).nil? } - versions = { - "RCC" => { - title: "Default Template v1", - number: 1, - phase: "Regional CurationCenter Data Management Plan" - }, - "EGRC" => { - title: "Annual Award v1", - number: 1, - phase: "Global Research Center Annual Award" - }, - "RegSciFed_1" => { - title: "Grant Summary v1", - number: 1, - phase: "Regional Science Federation - Preliminary" - }, - "RegSciFed_2" => { - title: "Grant Finalized Award v1", - number: 1, - phase: "Regional Science Federation - Final" - }, - "RegSciFed_2.1" => { - title: "Grant Finalized v2", - number: 1, - phase: "Regional Science Federation - Final" - }, - } +# Create sections for the 2 templates and their phases +# ------------------------------------------------------- +sections = [ + {title: "Overview", + number: 1, + phase: Phase.find_by(title: "Regional CurationCenter Data Management Plan"), + published: true, + modifiable: false}, + {title: "Collection", + number: 2, + phase: Phase.find_by(title: "Regional CurationCenter Data Management Plan"), + published: true, + modifiable: false}, + {title: "Documentation", + number: 3, + phase: Phase.find_by(title: "Regional CurationCenter Data Management Plan"), + published: true, + modifiable: false}, + {title: "Sharing and Usage", + number: 4, + phase: Phase.find_by(title: "Regional CurationCenter Data Management Plan"), + published: true, + modifiable: false}, + {title: "Long Term Preservation", + number: 5, + phase: Phase.find_by(title: "Regional CurationCenter Data Management Plan"), + published: true, + modifiable: false}, - versions.each do |v, details| - if Version.where(title: details[:title]).empty? - version = Version.new - version.title = details[:title] - version.number = details[:number] - version.phase = Phase.find_by_title(details[:phase]) - version.save! - end - end + {title: "Data Description", + number: 1, + phase: Phase.find_by(title: "Preliminary Statement of Work"), + published: true, + modifiable: false}, + {title: "Data Description", + number: 1, + phase: Phase.find_by(title: "Preliminary Statement of Work"), + published: true, + modifiable: false}, - sections = { - "Section 1" => { - title: "Data Collection", - number: 1, - description: "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.", - version: "Default Template v1", - organisation: "RCC" - }, - "Section 2" => { - title: "Documentation and Metadata", - number: 2, - description: "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.", - version: "Default Template v1", - organisation: "RCC" - }, - "Section A" => { - title: "Data Overview", - number: 1, - version: "Annual Award v1", - organisation: "EGRC" - }, - "Section B" => { - title: "Ethics and Legal Compliance", - number: 2, - version: "Annual Award v1", - organisation: "EGRC" - }, - "Section C" => { - title: "Storage and Backup", - number: 3, - version: "Annual Award v1", - organisation: "EGRC" - }, - "Section D" => { - title: "Preservation, Sustainability and Use", - number: 4, - version: "Annual Award v1", - organisation: "EGRC" - }, - "regSciFed Summary" => { - title: "Data Collection Guidelines", - number: 1, - description: "This is what we plan on collecting and how we're going to store it.", - version: "Grant Summary v1", - organisation: "RegSciFed" - }, - "RegSciFed Final 1" => { - title: "Data Collection and Storage", - number: 1, - version: "Grant Finalized Award v1", - organisation: "RegSciFed" - }, - "RegSciFed Final 1_2" => { - title: "Data Preservation", - number: 2, - version: "Grant Finalized v2", - organisation: "RegSciFed" - }, - "RegSciFed Final 2_2" => { - title: "Ongoing Access", - number: 3, - version: "Grant Finalized v2", - organisation: "RegSciFed" - } - } + {title: "Preservation Policy", + number: 1, + phase: Phase.find_by(title: "Detailed Overview"), + published: true, + modifiable: false}, + {title: "Data Format and Storage", + number: 1, + phase: Phase.find_by(title: "Detailed Overview"), + published: true, + modifiable: false}, + {title: "Collection Process", + number: 1, + phase: Phase.find_by(title: "Detailed Overview"), + published: true, + modifiable: false}, + {title: "Ethical Standards", + number: 1, + phase: Phase.find_by(title: "Detailed Overview"), + published: true, + modifiable: false}, + {title: "Preservation and Reuse Policies", + number: 1, + phase: Phase.find_by(title: "Detailed Overview"), + published: true, + modifiable: false} +] +sections.map{ |s| Section.create!(s) if Section.find_by(title: s[:title]).nil? } - sections.each do |s, details| - if Section.where(title: details[:title]).empty? - section = Section.new - section.title = details[:title] - section.number = details[:number] - section.description = details[:description] - section.version = Version.find_by_title(details[:version]) - section.organisation = Org.find_by_abbreviation(details[:organisation]) - section.save! - end - end +=begin questions = { "What data will you collect or create?" => { text: "What data will you collect or create?", @@ -776,3 +564,4 @@ token_permission_type.save! end end +=end \ No newline at end of file