-
Notifications
You must be signed in to change notification settings - Fork 109
/
Copy pathseeds.rb
executable file
·830 lines (788 loc) · 36.2 KB
/
seeds.rb
1
2
3
4
5
6
7
8
9
10
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
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
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
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
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
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
271
272
273
274
275
276
277
278
279
280
281
282
283
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
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
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
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
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
#!/usr/bin/env ruby
# encoding: utf-8
# frozen_string_literal: true
# warn_indent: true
# 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).
default_locale = LocaleService.to_i18n(locale: LocaleService.default_locale).to_s
# When this is executed by `db:setup`, the translation initializer did not run
# so we need to establish the I18n locales manually
I18n.available_locales = LocaleService.available_locales.map do |locale|
LocaleService.to_i18n(locale: locale)
end
I18n.available_locales << :en unless I18n.available_locales.include?(:en)
I18n.default_locale = default_locale
# Identifier Schemes
# -------------------------------------------------------
identifier_schemes = [
{
name: 'orcid',
description: 'ORCID',
active: true,
logo_url:'http://orcid.org/sites/default/files/images/orcid_16x16.png',
identifier_prefix:'https://orcid.org'
},
{
name: 'shibboleth',
description: 'Your institutional credentials',
active: true,
logo_url: 'http://newsite.shibboleth.net/wp-content/uploads/2017/01/Shibboleth-logo_2000x1200-1.png',
identifier_prefix: "https://example.com"
},
]
identifier_schemes.each { |is| IdentifierScheme.create!(is) }
# Question Formats
# -------------------------------------------------------
question_formats = [
{
title: "Text area",
description: "A Tinymce text area",
option_based: false,
formattype: 0
},
{
title: "Text field",
description: "A standard HTML text field",
option_based: false,
formattype: 1
},
{
title: "Radio buttons",
description: "A standard set of HTML radio button fields",
option_based: true,
formattype: 2
},
{
title: "Check box",
description: "A standard set of HTML checkbox fields",
option_based: true,
formattype: 3
},
{
title: "Dropdown",
description: "A standard HTML select field",
option_based: true,
formattype: 4
},
{
title: "Multi select box",
description: "A standard HTML multi-select field",
option_based: true,
formattype: 5
},
{
title: "Date",
description: "A standard HTML5 date field",
option_based: false,
formattype: 6
}
]
question_formats.each{ |qf| QuestionFormat.create!(qf) }
# Languages (check config/locales for any ones not defined here)
# -------------------------------------------------------
languages = [
{abbreviation: 'en-GB',
description: '',
name: 'English (GB)',
default_language: true},
{abbreviation: 'en-US',
description: '',
name: 'English (US)',
default_language: false},
{abbreviation: 'fr',
description: '',
name: 'Français',
default_language: false},
{abbreviation: 'de',
description: '',
name: 'Deutsch',
default_language: false},
{abbreviation: 'es',
description: '',
name: 'Español',
default_language: false},
{abbreviation: 'pt-BR',
description: '',
name: 'Português (Brasil)',
default_language: false},
{abbreviation: 'tr-TR',
description: '',
name: 'Türk',
default_language: false}
]
languages.each { |l| Language.create!(l) }
default_language = Language.find_by(abbreviation: default_locale)
# # 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
# })
# end
# end
# end
# 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'}
]
# 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?
if Region.find_by(abbreviation: r[:abbreviation]).nil?
region = Region.create!(r)
unless srs.nil?
srs.each do |sr|
if Region.find_by(abbreviation: sr[:abbreviation]).nil?
sr[:super_region] = region
Region.create!((sr))
end
end
end
end
end
# Perms
# -------------------------------------------------------
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'},
{name: 'review_org_plans'}
]
perms.each{ |p| Perm.create!(p) }
# 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.each { |t| Theme.create!(t.merge(locale: default_locale)) }
# 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_type: 'templates', text_description: 'allows a user access to the templates api endpoint'},
{token_type: 'statistics', text_description: 'allows a user access to the statistics api endpoint'}
]
token_permission_types.each{ |tpt| TokenPermissionType.create!(tpt) }
# Create our generic organisation, a funder and a University
# -------------------------------------------------------
region = Region.first
orgs = [
{name: Rails.configuration.x.organisation.name,
abbreviation: Rails.configuration.x.organisation.abbreviation,
org_type: 4, links: {"org":[]},
language: default_language, region: region,
token_permission_types: TokenPermissionType.all,
is_other: true, managed: true},
{name: 'Government Agency',
abbreviation: 'GA',
org_type: 2, links: {"org":[]},
language: default_language, region: region,
is_other: false, managed: true},
{name: 'University of Exampleland',
abbreviation: 'UOS',
org_type: 1, links: {"org":[]},
language: default_language, region: region,
is_other: false, managed: true}
]
orgs.each { |o| Org.create!(o) }
# 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: "[email protected]",
firstname: "Super",
surname: "Admin",
password: "password123",
password_confirmation: "password123",
org: Org.find_by(abbreviation: Rails.configuration.x.organisation.abbreviation),
language: default_language,
perms: Perm.all,
accept_terms: true,
api_token: 'abcd1234',
confirmed_at: Time.zone.now},
{email: "[email protected]",
firstname: "Funder",
surname: "Admin",
password: "password123",
password_confirmation: "password123",
org: Org.find_by(abbreviation: 'GA'),
language: default_language,
perms: Perm.where.not(name: ['admin', 'add_organisations', 'change_org_affiliation', 'grant_api_to_orgs']),
accept_terms: true,
api_token: 'efgh5678',
confirmed_at: Time.zone.now},
{email: "[email protected]",
firstname: "Organisational",
surname: "Admin",
password: "password123",
password_confirmation: "password123",
org: Org.find_by(abbreviation: 'UOS'),
language: default_language,
perms: Perm.where.not(name: ['admin', 'add_organisations', 'change_org_affiliation', 'grant_api_to_orgs']),
accept_terms: true,
api_token: 'ijkl9012',
confirmed_at: Time.zone.now},
{email: "[email protected]",
firstname: "Organisational",
surname: "User",
password: "password123",
password_confirmation: "password123",
org: Org.find_by(abbreviation: 'UOS'),
language: default_language,
accept_terms: true,
confirmed_at: Time.zone.now}
]
users.each{ |u| User.create(u) }
# 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: Rails.configuration.x.organisation.abbreviation),
optional_subset: true,
published: true},
{name: "Government Agency Advice (Funder specific guidance)",
org: Org.find_by(abbreviation: 'GA'),
optional_subset: false,
published: true}
]
guidance_groups.each do |gg|
guidance_group = GuidanceGroup.find_or_create_by(org: gg[:org])
guidance_group.update!(gg)
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_group: 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 <a href='https://www.ukdataservice.ac.uk/manage-data/format/recommended-formats' title='UK Data Service guidance on recommended formats'>UK Data Service guidance on recommended formats</a> or <a href='https://www.dataone.org/best-practices/document-and-store-data-using-stable-file-formats' title='DataONE Best Practices for file formats'>DataONE Best Practices for file formats</a>",
guidance_group: 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_group: 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 <a href='https://www.dataone.org/best-practices/quality' title='DataOne Best Practices for data quality'>DataOne Best Practices for data quality</a>",
guidance_group: 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 <a href='http://rd-alliance.github.io/metadata-directory' title='Directory of Metadata Standards'>Directory of Metadata Standards</a>.
● 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_group: 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 <a href='https://www.ukdataservice.ac.uk/manage-data/legal-ethical/consent-data-sharing' title='UK Data Service guidance on consent for data sharing'>UK Data Service guidance on consent for data sharing</a>
● See <a href='http://www.icpsr.umich.edu/icpsrweb/content/datamanagement/confidentiality/index.html' title='ICPSR approach to confidentiality'>ICPSR approach to confidentiality</a> and Health Insurance Portability and Accountability Act <a href='https://privacyruleandresearch.nih.gov/' title='(HIPAA) regulations for health research'>(HIPAA) regulations for health research</a>",
guidance_group: 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 <a href='http://www.dcc.ac.uk/resources/how-guides/license-research-data' title='DCC guide on How to license research data'>DCC guide on How to license research data</a> and <a href='https://ufal.github.io/public-license-selector' title='EUDAT’s data and software licensing wizard'>EUDAT’s data and software licensing wizard</a>.",
guidance_group: 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 <a href='https://www.ukdataservice.ac.uk/manage-data/store' title='UK Data Service Guidance on data storage'>UK Data Service Guidance on data storage</a> or <a href='https://www.dataone.org/best-practices/storage' title='DataONE Best Practices for storage'>DataONE Best Practices for storage</a>
● 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 <a href='http://www.dcc.ac.uk/resources/briefing-papers/standards-watch-papers/information-security-management-iso-27000-iso-27k-s' title='DCC Briefing Paper on Information Security Management -ISO 27000'>DCC Briefing Paper on Information Security Management -ISO 27000</a> and <a href='https://www.ukdataservice.ac.uk/manage-data/store/security' title='UK Data Service guidance on data security'>UK Data Service guidance on data security</a>",
guidance_group: 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_group: 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 <a href='http://www.re3data.org/' title='Re3data'>Re3data</a> and some universities or publishers provide lists of recommendations e.g. <a href='http://journals.plos.org/plosone/s/data-availability#loc-recommended-repositories' title='PLOS ONE recommended repositories'>PLOS ONE recommended repositories</a>",
guidance_group: 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: <a href='http://www.dcc.ac.uk/resources/how-guides/appraise-select-data' title='How to appraise and select research data for curation'>How to appraise and select research data for curation</a> or DataONE Best Practices: <a href='https://www.dataone.org/best-practices/identify-data-long-term-value' title='Identifying data with long-term value'>Identifying data with long-term value</a>",
guidance_group: 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 <a href='https://www.ukdataservice.ac.uk/manage-data/plan/roles-and-responsibilities' title='data management roles and responsibilities'>data management roles and responsibilities</a> or DataONE Best Practices: <a href='https://www.dataone.org/best-practices/define-roles-and-assign-responsibilities-data-management' title='Define roles and assign responsibilities for data management'>Define roles and assign responsibilities for data management</a>",
guidance_group: 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 <a href='https://www.ukdataservice.ac.uk/manage-data/plan/costing' title='costing data management'>costing data management</a>",
guidance_group: 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_group: 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_group: GuidanceGroup.last,
published: true,
themes: [Theme.find_by(title: 'Data Description')]}
]
guidances.each{ |g| Guidance.create!(g) }
# 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: Rails.configuration.x.organisation.abbreviation),
is_default: true, locale: default_locale,
version: 0,
visibility: Template.visibilities[:publicly_visible],
links: {"funder":[],"sample_plan":[]}},
{title: "OLD - Department of Testing Award",
published: false,
org: Org.find_by(abbreviation: 'GA'),
is_default: false, locale: default_locale,
version: 0,
visibility: Template.visibilities[:organisationally_visible],
links: {"funder":[],"sample_plan":[]}},
{title: "Department of Testing Award",
published: true,
org: Org.find_by(abbreviation: 'GA'),
is_default: false, locale: default_locale,
version: 0,
visibility: Template.visibilities[:organisationally_visible],
links: {"funder":[],"sample_plan":[]}}
]
# Template creation calls defaults handler which sets is_default and
# published to false automatically, so update them after creation
templates.each { |atts| Template.create!(atts) }
# Create 2 phases for the funder's template and one for our generic template
# -------------------------------------------------------
phases = [
{title: "Generic Data Management Planning Template",
number: 1,
modifiable: false,
template: Template.find_by(title: "My Curation Center's Default Template")},
{title: "Detailed Overview",
number: 1,
modifiable: false,
template: Template.find_by(title: "OLD - Department of Testing Award")},
{title: "Preliminary Statement of Work",
number: 1,
modifiable: true,
template: Template.find_by(title: "Department of Testing Award")},
{title: "Detailed Overview",
number: 2,
modifiable: false,
template: Template.find_by(title: "Department of Testing Award")}
]
phases.each{ |p| Phase.create!(p) }
generic_template_phase_1 = Phase.find_by(title: "Generic Data Management Planning Template")
funder_template_phase_1 = Phase.find_by(title: "Preliminary Statement of Work")
funder_template_phase_2 = Phase.find_by(title: "Detailed Overview")
# Create sections for the 2 templates and their phases
# -------------------------------------------------------
sections = [
# Sections for the Generic Template
{title: "Data Collection",
number: 1,
modifiable: false,
phase: generic_template_phase_1},
{title: "Documentation and Metadata",
number: 2,
modifiable: false,
phase: generic_template_phase_1},
{title: "Ethics and Legal Compliance",
number: 3,
modifiable: false,
phase: generic_template_phase_1},
{title: "Storage and Backup",
number: 4,
modifiable: false,
phase: generic_template_phase_1},
{title: "Selection and Preservation",
number: 5,
modifiable: false,
phase: generic_template_phase_1},
{title: "Data Sharing",
number: 6,
modifiable: false,
phase: generic_template_phase_1},
{title: "Responsibilities and Resources",
number: 7,
modifiable: false,
phase: generic_template_phase_1},
# Section of old version of Funder Template
{title: "Data Collection and Preservation",
number: 11,
modifiable: true,
phase: Phase.find_by(title: "Detailed Overview")},
# Sections for the Funder Template's Preliminary Phase
{title: "Data Overview",
number: 1,
modifiable: true,
phase: funder_template_phase_1},
{title: "Data Description",
number: 2,
modifiable: true,
phase: funder_template_phase_1},
# Sections for the Funder Template's Detailed Phase
{title: "Preservation Policy",
number: 1,
modifiable: false,
phase: funder_template_phase_2},
{title: "Data Format and Storage",
number: 2,
modifiable: false,
phase: funder_template_phase_2},
{title: "Collection Process",
number: 3,
modifiable: false,
phase: funder_template_phase_2},
{
title: "Ethical Standards",
number: 4,
modifiable: false,
phase: funder_template_phase_2
},
{
title: "Preservation and Reuse Policies",
number: 5,
modifiable: false,
phase: funder_template_phase_2
}
]
sections.each{ |s| Section.create!(s) }
text_area = QuestionFormat.find_by(title: "Text area")
# Create questions for the 2 templates and their phases
# -------------------------------------------------------
questions = [
# Questions for the Generic Template
{text: "What data will you collect or create?",
number: 1,
section: Section.find_by(title: "Data Collection"),
question_format: text_area,
modifiable: false,
themes: [Theme.find_by(title: "Data Description")]},
{text: "How will the data be collected or created?",
number: 2,
section: Section.find_by(title: "Data Collection"),
question_format: text_area,
modifiable: false,
themes: [Theme.find_by(title: "Data Collection")]},
{text: "What documentation and metadata will accompany the data?",
number: 1,
section: Section.find_by(title: "Documentation and Metadata"),
question_format: text_area,
modifiable: false,
themes: [Theme.find_by(title: "Metadata & Documentation")]},
{text: "How will you manage any ethical issues?",
number: 1,
section: Section.find_by(title: "Ethics and Legal Compliance"),
question_format: text_area,
modifiable: false,
themes: [Theme.find_by(title: "Ethics & Privacy")]},
{text: "How will you manage copyright and Intellectual Property Rights (IPR) issues?",
number: 2,
section: Section.find_by(title: "Ethics and Legal Compliance"),
question_format: text_area,
modifiable: false,
themes: [Theme.find_by(title: "Intellectual Property Rights")]},
{text: "How will the data be stored and backed up during the research?",
number: 1,
section: Section.find_by(title: "Storage and Backup"),
question_format: text_area,
modifiable: false,
themes: [Theme.find_by(title: "Storage & Security")]},
{text: "How will you manage access and security?",
number: 2,
section: Section.find_by(title: "Storage and Backup"),
question_format: text_area,
modifiable: false,
themes: [Theme.find_by(title: "Storage & Security")]},
{text: "Which data are of long-term value and should be retained, shared, and/or preserved?",
number: 1,
section: Section.find_by(title: "Selection and Preservation"),
question_format: text_area,
modifiable: false,
themes: [Theme.find_by(title: "Preservation")]},
{text: "What is the long-term preservation plan for the dataset?",
number: 2,
section: Section.find_by(title: "Selection and Preservation"),
question_format: text_area,
modifiable: false},
{text: "How will you share the data?",
number: 1,
section: Section.find_by(title: "Data Sharing"),
question_format: text_area,
modifiable: false,
themes: [Theme.find_by(title: "Data Sharing")]},
{text: "Are any restrictions on data sharing required?",
number: 2,
section: Section.find_by(title: "Data Sharing"),
question_format: text_area,
modifiable: false},
{text: "Who will be responsible for data management?",
number: 1,
section: Section.find_by(title: "Responsibilities and Resources"),
question_format: text_area,
modifiable: false,
themes: [Theme.find_by(title: "Roles & Responsibilities")]},
{text: "What resources will you require to deliver your plan?",
number: 2,
modifiable: false,
section: Section.find_by(title: "Responsibilities and Resources"),
question_format: text_area},
# Questions for old version of Funder Template
{text: "What data will you collect and how will it be obtained?",
number: 1,
modifiable: false,
section: Section.find_by(title: "Data Collection and Preservation"),
question_format: text_area},
{text: "How will you preserve your data during the project and long-term?",
number: 2,
modifiable: false,
section: Section.find_by(title: "Data Collection and Preservation"),
question_format: text_area},
# Questions for the Funder Template's Preliminary Phase
{text: "Provide an overview of the dataset.",
number: 1,
section: Section.find_by(title: "Data Overview"),
question_format: text_area,
modifiable: true,
themes: [Theme.find_by(title: "Data Description")]},
{text: "What types/formats of data will you collect?",
number: 1,
modifiable: true,
section: Section.find_by(title: "Data Description"),
question_format: text_area,
themes: [Theme.find_by(title: "Data Format")]},
{text: "How will you store the data and how will it be preserved?",
number: 2,
modifiable: true,
section: Section.find_by(title: "Data Description"),
question_format: text_area,
themes: [Theme.find_by(title: "Data Collection")]},
# Questions for the Funder Template's Detailed Phase
{text: "What is your policy for long term access to your dataset?",
number: 1,
section: Section.find_by(title: "Preservation Policy"),
question_format: text_area,
modifiable: false,
default_value: "Please enter your answer here ..." ,
themes: [Theme.find_by(title: "Preservation")]},
{text: "Where will your data be preserved?",
number: 2,
section: Section.find_by(title: "Preservation Policy"),
question_format: QuestionFormat.find_by(title: "Text field"),
modifiable: false,
default_value: "on a server at my institution",
themes: [Theme.find_by(title: "Preservation")]},
{text: "What types of data will you collect and how will it be stored?",
number: 1,
section: Section.find_by(title: "Data Format and Storage"),
question_format: text_area,
modifiable: false,
themes: [Theme.find_by(title: "Storage & Security"), Theme.find_by(title: 'Data Format')]},
{text: "What are your institution's ethical policies?",
number: 1,
section: Section.find_by(title: "Ethical Standards"),
question_format: text_area,
modifiable: false,
themes: [Theme.find_by(title: "Ethics & Privacy")]},
{text: "When will your data be available for public consumption?",
number: 2,
section: Section.find_by(title: "Ethical Standards"),
question_format: QuestionFormat.find_by(title: "Date"),
modifiable: false,
themes: [Theme.find_by(title: "Ethics & Privacy")]},
{text: "Tell us about your departmental and institutional policies on reuse and preservation.",
number: 1,
section: Section.find_by(title: "Preservation and Reuse Policies"),
question_format: text_area,
modifiable: false,
themes: [Theme.find_by(title: "Preservation"), Theme.find_by(title: "Data Sharing")]}
]
questions.each{ |q| Question.create!(q) }
radio_button = Question.new(
text: "Please select the appropriate formats.",
number: 2,
section: Section.find_by(title: "Data Format and Storage"),
question_format: QuestionFormat.find_by(title: "Radio buttons"),
modifiable: false,
themes: [Theme.find_by(title: "Storage & Security"), Theme.find_by(title: 'Data Format')])
radio_button.question_options.build([
{
text: "csv files",
number: 1,
is_default: false
},
{
text: "database (e.g. mysql, redis)",
number: 2,
is_default: false
},
{
text: "archive files (e.g. tar, zip)",
number: 3,
is_default: false
}])
radio_button.save!
checkbox = Question.new(
text: "Will software accompany your dataset?",
number: 1,
section: Section.find_by(title: "Collection Process"),
question_format: QuestionFormat.find_by(title: "Check box"),
modifiable: false,
themes: [Theme.find_by(title: "Data Collection")])
checkbox.question_options.build([
{
text: "local hard drive",
number: 1,
is_default: true
},
{
text: "personal cloud storage",
number: 2,
is_default: false
},
{
text: "institutional servers",
number: 3,
is_default: false
}])
checkbox.save!
dropdown = Question.new(
text: "Where will you store your data during the research period?",
number: 2,
section: Section.find_by(title: "Collection Process"),
question_format: QuestionFormat.find_by(title: "Dropdown"),
modifiable: false,
themes: [Theme.find_by(title: "Data Collection")])
dropdown.question_options.build([
{
text: "In a database",
number: 1,
is_default: false
},
{
text: "In a pendrive",
number: 2,
is_default: false
}])
dropdown.save!
multi_select_box = Question.new(
text: "What type(s) of data will you collect?",
number: 3,
section: Section.find_by(title: "Collection Process"),
question_format: QuestionFormat.find_by(title: "Multi select box"),
option_comment_display: true,
modifiable: false,
themes: [Theme.find_by(title: "Data Collection")])
multi_select_box.question_options.build([
{
text: "statistical",
number: 1,
is_default: false
},
{
text: "image/video",
number: 2,
is_default: false
},
{
text: "geographical",
number: 3,
is_default: false
},
{
text: "other",
number: 4,
is_default: false
}])
multi_select_box.save!
# Create suggested answers for a few questions
# -------------------------------------------------------
annotations = [
{text: "We will preserve it in Dryad or a similar data repository service.",
type: Annotation.types[:example_answer],
org: Org.find_by(abbreviation: 'GA'),
question: Question.find_by(text: "What is your policy for long term access to your dataset?")},
{text: "We recommend that you identify the type(s) of content as well as the type of file(s) involved",
type: Annotation.types[:example_answer],
org: Org.find_by(abbreviation: 'GA'),
question: Question.find_by(text: "What types of data will you collect and how will it be stored?")},
]
annotations.each{ |s| Annotation.create!(s) if Annotation.find_by(text: s[:text]).nil? }