Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
RDMS
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
researchdata
RDMS
Commits
8bc63c39
Commit
8bc63c39
authored
2 years ago
by
Kapil Patel
Browse files
Options
Downloads
Patches
Plain Diff
Extende support to look by source in activefedora dynamic lookup
parent
e1211664
No related branches found
Branches containing commit
No related tags found
Tags containing commit
3 merge requests
!115
Tombstone not available for dataset
,
!93
0.3 release
,
!78
Fix importer issues
Pipeline
#5815
failed
2 years ago
Stage: build
Stage: test
Stage: deploy
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
hyrax/app/models/concerns/bulkrax/dynamic_record_lookup.rb
+48
-0
48 additions, 0 deletions
hyrax/app/models/concerns/bulkrax/dynamic_record_lookup.rb
with
48 additions
and
0 deletions
hyrax/app/models/concerns/bulkrax/dynamic_record_lookup.rb
0 → 100644
+
48
−
0
View file @
8bc63c39
# frozen_string_literal: true
module
Bulkrax
module
DynamicRecordLookup
# Search entries, collections, and every available work type for a record that
# has the provided identifier.
#
# @param identifier [String] Work/Collection ID or Bulkrax::Entry source_identifier
# @param importer_run_id [Number] ID of the current_run of this Importer Job
# @return [Entry, nil], [Work, Collection, nil] Entry if found, otherwise nil and a Work or Collection if found, otherwise nil
def
find_record
(
identifier
,
importer_run_id
=
nil
)
# check for our entry in our current importer first
importer_id
=
ImporterRun
.
find
(
importer_run_id
).
importer_id
default_scope
=
{
identifier:
identifier
,
importerexporter_type:
'Bulkrax::Importer'
}
begin
# the identifier parameter can be a :source_identifier or the id of an object
record
=
Entry
.
find_by
(
default_scope
.
merge
({
importerexporter_id:
importer_id
}))
||
Entry
.
find_by
(
default_scope
)
record
||=
ActiveFedora
::
Base
.
find
(
identifier
)
# NameError for if ActiveFedora isn't installed
rescue
NameError
,
ActiveFedora
::
ObjectNotFoundError
record
=
ActiveFedora
::
Base
.
where
(
source_tesim:
identifier
).
first
end
# return the found entry here instead of searching for it again in the CreateRelationshipsJob
# also accounts for when the found entry isn't a part of this importer
record
.
is_a?
(
Entry
)
?
[
record
,
record
.
factory
.
find
]
:
[
nil
,
record
]
end
# Check if the record is a Work
def
curation_concern?
(
record
)
available_work_types
.
include?
(
record
.
class
)
end
private
# @return [Array<Class>] list of work type classes
def
available_work_types
# If running in a Hyku app, do not include disabled work types
@available_work_types
||=
if
defined?
(
::
Hyku
)
::
Site
.
instance
.
available_works
.
map
(
&
:constantize
)
else
::
Hyrax
.
config
.
curation_concerns
end
end
end
end
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment