Top Level Namespace
Defined Under Namespace
Modules: ActionDispatch, Hyrax, HyraxHelper, Sipity, Vocab
Classes: AdminSet, AttachFilesToWorkJob, AttachFilesToWorkWithOrderedMembersJob, BatchCreateJob, BatchUploadItem, CatalogController, CharacterizeJob, ChecksumAuditLog, Collection, CollectionBrandingInfo, ContentBlock, ContentDeleteEventJob, ContentDepositEventJob, ContentDepositorChangeEventJob, ContentEventJob, ContentNewVersionEventJob, ContentRestoredVersionEventJob, ContentUpdateEventJob, ControlledVocabularyInput, CreateDerivativesJob, CreateWorkJob, EmbargoExpiryJob, EventJob, FeaturedWork, FeaturedWorkList, FileDownloadStat, FileSet, FileSetAttachedEventJob, FileViewStat, FixityCheckJob, IiifManifestCachePrewarmJob, ImportExportJob, ImportUrlJob, IngestJob, IngestLocalFileJob, InheritPermissionsJob, JobIoWrapper, LeaseExpiryJob, MoveAllWorksToAdminSet, MultiValueSelectInput, MultifileInput, ProxyDepositRequest, ProxyDepositRights, ResolrizeJob, SingleUseLink, StreamNotificationsJob, Trophy, UserEditProfileEventJob, UserMailbox, UserStat, VisibilityCopyJob, WorkViewStat
Instance Method Summary
collapse
-
#collection_attributes_for(collection_ids) ⇒ Object
-
#create_authenticated_work(user, id, options) ⇒ Object
-
#create_collection(user, type_gid, id, options) ⇒ Object
-
#create_collection_type(machine_id, options) ⇒ Object
-
#create_private_collection(user, type_gid, id, options) ⇒ Object
-
#create_private_work(user, id, options) ⇒ Object
-
#create_public_collection(user, type_gid, id, options) ⇒ Object
-
#create_public_work(user, id, options) ⇒ Object
-
#create_user(email, pw) ⇒ Object
——————————— methods to create various objects ———————————.
-
#create_work(user, id, options) ⇒ Object
Instance Method Details
#collection_attributes_for(collection_ids) ⇒ Object
96
97
98
99
100
|
# File 'lib/generators/hyrax/templates/db/seeds.rb', line 96
def collection_attributes_for(collection_ids)
attrs = {}
0.upto(collection_ids.size) { |i| attrs[i.to_s] = { 'id' => collection_ids[i] } }
attrs
end
|
#create_authenticated_work(user, id, options) ⇒ Object
75
76
77
78
|
# File 'lib/generators/hyrax/templates/db/seeds.rb', line 75
def create_authenticated_work(user, id, options)
options[:visibility] = Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_AUTHENTICATED
create_work(user, id, options)
end
|
#create_collection(user, type_gid, id, options) ⇒ Object
57
58
59
60
61
62
63
64
65
66
67
68
|
# File 'lib/generators/hyrax/templates/db/seeds.rb', line 57
def create_collection(user, type_gid, id, options)
col = Collection.where(id: id)
return col.first if col.present?
col = Collection.new(id: id)
col.attributes = options.except(:visibility)
col.apply_depositor_metadata(user.user_key)
col.collection_type_gid = type_gid
col.visibility = options[:visibility]
col.save
Hyrax::Collections::PermissionsCreateService.create_default(collection: col, creating_user: user)
col
end
|
#create_collection_type(machine_id, options) ⇒ Object
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/generators/hyrax/templates/db/seeds.rb', line 34
def create_collection_type(machine_id, options)
coltype = Hyrax::CollectionType.find_by_machine_id(machine_id)
return coltype if coltype.present?
default_options = {
nestable: false, discoverable: false, sharable: false, allow_multiple_membership: false,
require_membership: false, assigns_workflow: false, assigns_visibility: false,
participants: [{ agent_type: Hyrax::CollectionTypeParticipant::GROUP_TYPE, agent_id: ::Ability.admin_group_name, access: Hyrax::CollectionTypeParticipant::MANAGE_ACCESS },
{ agent_type: Hyrax::CollectionTypeParticipant::GROUP_TYPE, agent_id: ::Ability.registered_group_name, access: Hyrax::CollectionTypeParticipant::CREATE_ACCESS }]
}
final_options = default_options.merge(options.except(:title))
Hyrax::CollectionTypes::CreateService.create_collection_type(machine_id: machine_id, title: options[:title], options: final_options)
end
|
#create_private_collection(user, type_gid, id, options) ⇒ Object
52
53
54
55
|
# File 'lib/generators/hyrax/templates/db/seeds.rb', line 52
def create_private_collection(user, type_gid, id, options)
options[:visibility] = Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PRIVATE
create_collection(user, type_gid, id, options)
end
|
#create_private_work(user, id, options) ⇒ Object
80
81
82
83
|
# File 'lib/generators/hyrax/templates/db/seeds.rb', line 80
def create_private_work(user, id, options)
options[:visibility] = Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PRIVATE
create_work(user, id, options)
end
|
#create_public_collection(user, type_gid, id, options) ⇒ Object
47
48
49
50
|
# File 'lib/generators/hyrax/templates/db/seeds.rb', line 47
def create_public_collection(user, type_gid, id, options)
options[:visibility] = Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC
create_collection(user, type_gid, id, options)
end
|
#create_public_work(user, id, options) ⇒ Object
70
71
72
73
|
# File 'lib/generators/hyrax/templates/db/seeds.rb', line 70
def create_public_work(user, id, options)
options[:visibility] = Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC
create_work(user, id, options)
end
|
#create_user(email, pw) ⇒ Object
methods to create various objects
24
25
26
27
28
29
30
31
32
|
# File 'lib/generators/hyrax/templates/db/seeds.rb', line 24
def create_user(email, pw)
user = User.find_or_create_by(Hydra.config.user_key_field => email) do |u|
u.email = email
u.password = pw
u.password_confirmation = pw
end
user
end
|
#create_work(user, id, options) ⇒ Object
85
86
87
88
89
90
91
92
93
94
|
# File 'lib/generators/hyrax/templates/db/seeds.rb', line 85
def create_work(user, id, options)
work = GenericWork.where(id: id)
return work.first if work.present?
actor = Hyrax::CurationConcern.actor
attributes_for_actor = options
work = GenericWork.new(id: id)
actor_environment = Hyrax::Actors::Environment.new(work, Ability.new(user), attributes_for_actor)
actor.create(actor_environment)
work
end
|