Module: Ddr::Models::Indexing

Includes:
Index::Fields
Included in:
Base
Defined in:
lib/ddr/models/indexing.rb

Constant Summary

Constants included from Index::Fields

Index::Fields::ACCESS_ROLE, Index::Fields::ACTIVE_FEDORA_MODEL, Index::Fields::ADMIN_SET, Index::Fields::ADMIN_SET_FACET, Index::Fields::ADMIN_SET_TITLE, Index::Fields::AFFILIATION, Index::Fields::AFFILIATION_FACET, Index::Fields::ALEPH_ID, Index::Fields::ALL_TEXT, Index::Fields::ARRANGER_FACET, Index::Fields::ASPACE_ID, Index::Fields::ATTACHED_FILES_HAVING_CONTENT, Index::Fields::BOX_NUMBER_FACET, Index::Fields::CATEGORY_FACET, Index::Fields::COLLECTION_FACET, Index::Fields::COLLECTION_TITLE, Index::Fields::COLLECTION_URI, Index::Fields::COMPANY_FACET, Index::Fields::COMPOSER_FACET, Index::Fields::CONTENT_CONTROL_GROUP, Index::Fields::CONTENT_CREATE_DATE, Index::Fields::CONTENT_SIZE, Index::Fields::CONTENT_SIZE_HUMAN, Index::Fields::CONTRIBUTOR_FACET, Index::Fields::CREATOR_FACET, Index::Fields::DATE_FACET, Index::Fields::DATE_SORT, Index::Fields::DC_IS_PART_OF, Index::Fields::DEPOSITOR, Index::Fields::DISPLAY_FORMAT, Index::Fields::DOI, Index::Fields::EAD_ID, Index::Fields::ENGRAVER_FACET, Index::Fields::EXTRACTED_TEXT, Index::Fields::FOLDER_FACET, Index::Fields::FORMAT_FACET, Index::Fields::GENRE_FACET, Index::Fields::HAS_MODEL, Index::Fields::ID, Index::Fields::IDENTIFIER_ALL, Index::Fields::ILLUSTRATED_FACET, Index::Fields::ILLUSTRATOR_FACET, Index::Fields::INGESTED_BY, Index::Fields::INGESTION_DATE, Index::Fields::INSTRUMENTATION_FACET, Index::Fields::INTERNAL_URI, Index::Fields::INTERVIEWER_NAME_FACET, Index::Fields::IS_ATTACHED_TO, Index::Fields::IS_EXTERNAL_TARGET_FOR, Index::Fields::IS_FORMAT_OF, Index::Fields::IS_GOVERNED_BY, Index::Fields::IS_LOCKED, Index::Fields::IS_MEMBER_OF, Index::Fields::IS_MEMBER_OF_COLLECTION, Index::Fields::IS_PART_OF, Index::Fields::LANGUAGE_FACET, Index::Fields::LANGUAGE_NAME, Index::Fields::LAST_FIXITY_CHECK_ON, Index::Fields::LAST_FIXITY_CHECK_OUTCOME, Index::Fields::LAST_VIRUS_CHECK_ON, Index::Fields::LAST_VIRUS_CHECK_OUTCOME, Index::Fields::LICENSE, Index::Fields::LITHOGRAPHER_FACET, Index::Fields::LOCAL_ID, Index::Fields::LYRICIST_FACET, Index::Fields::MEDIA_MAJOR_TYPE, Index::Fields::MEDIA_SUB_TYPE, Index::Fields::MEDIA_TYPE, Index::Fields::MEDIUM_FACET, Index::Fields::MULTIRES_IMAGE_FILE_PATH, Index::Fields::NESTED_PATH, Index::Fields::NESTED_PATH_TEXT, Index::Fields::OBJECT_CREATE_DATE, Index::Fields::OBJECT_MODIFIED_DATE, Index::Fields::OBJECT_PROFILE, Index::Fields::OBJECT_STATE, Index::Fields::PERFORMER_FACET, Index::Fields::PERMANENT_ID, Index::Fields::PERMANENT_URL, Index::Fields::PLACEMENT_COMPANY_FACET, Index::Fields::POLICY_ROLE, Index::Fields::PRODUCER_FACET, Index::Fields::PRODUCT_FACET, Index::Fields::PUBLICATION_FACET, Index::Fields::PUBLISHER_FACET, Index::Fields::RESEARCH_HELP_CONTACT, Index::Fields::RESOURCE_ROLE, Index::Fields::RIGHTS_NOTE, Index::Fields::ROLL_NUMBER_FACET, Index::Fields::SERIES_FACET, Index::Fields::SETTING_FACET, Index::Fields::SPATIAL_FACET, Index::Fields::STREAMABLE_MEDIA_TYPE, Index::Fields::STRUCTURE, Index::Fields::STRUCTURE_SOURCE, Index::Fields::SUBJECT_FACET, Index::Fields::SUBSERIES_FACET, Index::Fields::TECHMD_COLOR_SPACE, Index::Fields::TECHMD_CREATING_APPLICATION, Index::Fields::TECHMD_CREATION_TIME, Index::Fields::TECHMD_FILE_SIZE, Index::Fields::TECHMD_FITS_DATETIME, Index::Fields::TECHMD_FITS_VERSION, Index::Fields::TECHMD_FORMAT_LABEL, Index::Fields::TECHMD_FORMAT_VERSION, Index::Fields::TECHMD_ICC_PROFILE_NAME, Index::Fields::TECHMD_ICC_PROFILE_VERSION, Index::Fields::TECHMD_IMAGE_HEIGHT, Index::Fields::TECHMD_IMAGE_WIDTH, Index::Fields::TECHMD_MD5, Index::Fields::TECHMD_MEDIA_TYPE, Index::Fields::TECHMD_MODIFICATION_TIME, Index::Fields::TECHMD_PRONOM_IDENTIFIER, Index::Fields::TECHMD_VALID, Index::Fields::TECHMD_WELL_FORMED, Index::Fields::TEMPORAL_FACET, Index::Fields::TITLE, Index::Fields::TONE_FACET, Index::Fields::TYPE_FACET, Index::Fields::VOLUME_FACET, Index::Fields::WORKFLOW_STATE, Index::Fields::YEAR_FACET

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Index::Fields

descmd, get, techmd

Class Method Details

.const_missing(name) ⇒ Object



8
9
10
# File 'lib/ddr/models/indexing.rb', line 8

def self.const_missing(name)
  Ddr::Index::Fields.const_missing(name)
end

Instance Method Details

#admin_set_facetObject



155
156
157
158
159
160
161
# File 'lib/ddr/models/indexing.rb', line 155

def admin_set_facet
  if admin_set.present?
    admin_set
  elsif associated_collection.present?
    associated_collection.admin_set
  end
end

#admin_set_titleObject



163
164
165
166
167
168
169
170
171
172
173
174
# File 'lib/ddr/models/indexing.rb', line 163

def admin_set_title
  code = if admin_set.present?
           admin_set
         elsif associated_collection.present?
           associated_collection.admin_set
         else
           nil
         end
  if code && ( as = AdminSet.find_by_code(code) )
    as.title
  end
end

#all_identifiersObject



145
146
147
# File 'lib/ddr/models/indexing.rb', line 145

def all_identifiers
  identifier + [local_id, permanent_id, pid].compact
end

#associated_collectionObject



149
150
151
152
153
# File 'lib/ddr/models/indexing.rb', line 149

def associated_collection
  # XXX Can/should we use SolrDocument here?
  # I.e., ::SolrDocument.find(admin_policy_id)
  admin_policy
end

#collection_facetObject



176
177
178
# File 'lib/ddr/models/indexing.rb', line 176

def collection_facet
  associated_collection.internal_uri if associated_collection.present?
end

#collection_titleObject



180
181
182
183
184
185
186
# File 'lib/ddr/models/indexing.rb', line 180

def collection_title
  if instance_of?(Collection)
    title_display
  elsif associated_collection.present?
    associated_collection.title_display
  end
end

#date_sortObject



188
189
190
# File 'lib/ddr/models/indexing.rb', line 188

def date_sort
  date.first
end

#index_fieldsObject



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
# File 'lib/ddr/models/indexing.rb', line 17

def index_fields
  fields = {
    ACCESS_ROLE             => roles.to_json,
    ADMIN_SET               => admin_set,
    ADMIN_SET_TITLE         => admin_set_title,
    AFFILIATION             => affiliation,
    AFFILIATION_FACET       => affiliation,
    ALEPH_ID                => aleph_id,
    ARRANGER_FACET          => ('arranger'),
    ASPACE_ID               => aspace_id,
    ATTACHED_FILES_HAVING_CONTENT => attached_files_having_content.keys,
    BOX_NUMBER_FACET        => ('box_number'),
    CATEGORY_FACET          => ('category'),
    COLLECTION_TITLE        => collection_title,
    COMPANY_FACET           => ('company'),
    COMPOSER_FACET          => ('composer'),
    CONTRIBUTOR_FACET       => contributor,
    CREATOR_FACET           => creator,
    DATE_FACET              => date,
    DATE_SORT               => date_sort,
    DC_IS_PART_OF           => ('isPartOf'),
    DEPOSITOR               => depositor,
    DISPLAY_FORMAT          => display_format,
    DOI                     => .doi,
    EAD_ID                  => ead_id,
    ENGRAVER_FACET          => ('engraver'),
    FOLDER_FACET            => ('folder'),
    FORMAT_FACET            => format,
    GENRE_FACET             => ('genre'),
    IDENTIFIER_ALL          => all_identifiers,
    ILLUSTRATED_FACET       => ('illustrated'),
    ILLUSTRATOR_FACET       => ('illustrator'),
    INGESTED_BY             => ingested_by,
    INGESTION_DATE          => ingestion_date,
    INSTRUMENTATION_FACET   => ('instrumentation'),
    INTERNAL_URI            => internal_uri,
    INTERVIEWER_NAME_FACET  => ('interviewer_name'),
    IS_FORMAT_OF            => ('isFormatOf'),
    IS_LOCKED               => is_locked,
    LANGUAGE_FACET          => language_name,
    LANGUAGE_NAME           => language_name,
    LICENSE                 => license,
    LITHOGRAPHER_FACET      => ('lithographer'),
    LOCAL_ID                => local_id,
    LYRICIST_FACET          => ('lyricist'),
    MEDIUM_FACET            => ('medium'),
    PERFORMER_FACET         => ('performer'),
    PERMANENT_ID            => permanent_id,
    PERMANENT_URL           => permanent_url,
    PLACEMENT_COMPANY_FACET => ('placement_company'),
    POLICY_ROLE             => roles.in_policy_scope.agents,
    PRODUCER_FACET          => ('producer'),
    PRODUCT_FACET           => ('product'),
    PUBLICATION_FACET       => ('publication'),
    PUBLISHER_FACET         => publisher,
    RESEARCH_HELP_CONTACT   => research_help_contact,
    RESOURCE_ROLE           => roles.in_resource_scope.agents,
    RIGHTS_NOTE             => rights_note,
    ROLL_NUMBER_FACET       => ('roll_number'),
    SERIES_FACET            => ('series'),
    SETTING_FACET           => ('setting'),
    SPATIAL_FACET           => ('spatial'),
    SUBJECT_FACET           => subject,
    SUBSERIES_FACET         => ('subseries'),
    TEMPORAL_FACET          => ('temporal'),
    TITLE                   => title_display,
    TONE_FACET              => ('tone'),
    TYPE_FACET              => type,
    VOLUME_FACET            => ('volume'),
    WORKFLOW_STATE          => workflow_state,
    YEAR_FACET              => year_facet,
  }
  if respond_to? :fixity_checks
    last_fixity_check = fixity_checks.last
    fields.merge!(last_fixity_check.to_solr) if last_fixity_check
  end
  if respond_to? :virus_checks
    last_virus_check = virus_checks.last
    fields.merge!(last_virus_check.to_solr) if last_virus_check
  end
  if has_content?
    fields[CONTENT_CREATE_DATE] = Ddr::Utils.solr_date(content.createDate)
    fields[CONTENT_CONTROL_GROUP] = content.controlGroup
    fields[CONTENT_SIZE] = content_size
    fields[CONTENT_SIZE_HUMAN] = content_human_size
    fields[MEDIA_TYPE] = content_type
    fields[MEDIA_MAJOR_TYPE] = content_major_type
    fields[MEDIA_SUB_TYPE] = content_sub_type
    fields.merge! techmd.index_fields
  end
  if has_multires_image?
    fields[MULTIRES_IMAGE_FILE_PATH] = multires_image_file_path
  end
  if has_struct_metadata?
    fields[STRUCTURE] = structure.dereferenced_structure.to_json
    fields[STRUCTURE_SOURCE] = structure.repository_maintained? ? Ddr::Models::Structure::REPOSITORY_MAINTAINED
                                                                : Ddr::Models::Structure::EXTERNALLY_PROVIDED
  end
  if has_extracted_text?
    fields[EXTRACTED_TEXT] = extractedText.content
  end
  if streamable?
    fields[STREAMABLE_MEDIA_TYPE] = streamable_media_type
  end
  if is_a? Component
    fields[COLLECTION_URI] = collection_uri
  end
  if is_a? Collection
    fields[ADMIN_SET_FACET] = admin_set_facet
    fields[COLLECTION_FACET] = collection_facet
  end
  if is_a? Item
    fields[ADMIN_SET_FACET] = admin_set_facet
    fields[COLLECTION_FACET] = collection_facet
    fields[NESTED_PATH] = nested_path
    fields[NESTED_PATH_TEXT] = nested_path
    fields[ALL_TEXT] = all_text
  end
  fields
end

#language_nameObject



192
193
194
195
196
# File 'lib/ddr/models/indexing.rb', line 192

def language_name
  language.map do |lang|
    Language.find_by_code(lang).to_s rescue lang
  end
end

#title_displayObject



138
139
140
141
142
143
# File 'lib/ddr/models/indexing.rb', line 138

def title_display
  return title.first if title.present?
  return identifier.first if identifier.present?
  return original_filename if respond_to?(:original_filename) && original_filename.present?
  "[#{pid}]"
end

#to_solr(solr_doc = Hash.new, opts = {}) ⇒ Object



12
13
14
15
# File 'lib/ddr/models/indexing.rb', line 12

def to_solr(solr_doc=Hash.new, opts={})
  solr_doc = super(solr_doc, opts)
  solr_doc.merge index_fields
end

#year_facetObject



198
199
200
# File 'lib/ddr/models/indexing.rb', line 198

def year_facet
  YearFacet.call(self)
end