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::BOX_NUMBER_FACET, Index::Fields::COLLECTION_FACET, Index::Fields::COLLECTION_URI, Index::Fields::CONTENT_CONTROL_GROUP, Index::Fields::CONTENT_SIZE, Index::Fields::CONTENT_SIZE_HUMAN, Index::Fields::CREATOR_FACET, Index::Fields::DATE_FACET, Index::Fields::DATE_SORT, Index::Fields::DEPOSITOR, Index::Fields::DISPLAY_FORMAT, Index::Fields::DOI, Index::Fields::EAD_ID, Index::Fields::EXTRACTED_TEXT, Index::Fields::HAS_MODEL, Index::Fields::ID, Index::Fields::IDENTIFIER_ALL, Index::Fields::INTERNAL_URI, Index::Fields::IS_ATTACHED_TO, Index::Fields::IS_EXTERNAL_TARGET_FOR, Index::Fields::IS_GOVERNED_BY, Index::Fields::IS_MEMBER_OF, Index::Fields::IS_MEMBER_OF_COLLECTION, Index::Fields::IS_PART_OF, 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::LOCAL_ID, Index::Fields::MEDIA_MAJOR_TYPE, Index::Fields::MEDIA_SUB_TYPE, Index::Fields::MEDIA_TYPE, Index::Fields::MULTIRES_IMAGE_FILE_PATH, Index::Fields::OBJECT_CREATE_DATE, Index::Fields::OBJECT_MODIFIED_DATE, Index::Fields::OBJECT_PROFILE, Index::Fields::OBJECT_STATE, Index::Fields::PERMANENT_ID, Index::Fields::PERMANENT_URL, Index::Fields::PID, Index::Fields::POLICY_ROLE, Index::Fields::PUBLISHER_FACET, Index::Fields::RESEARCH_HELP_CONTACT, Index::Fields::RESOURCE_ROLE, Index::Fields::SERIES_FACET, Index::Fields::SPATIAL_FACET, Index::Fields::STRUCT_MAPS, 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_IMAGE_HEIGHT, Index::Fields::TECHMD_IMAGE_WIDTH, 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::TITLE, Index::Fields::TYPE_FACET, Index::Fields::WORKFLOW_STATE, Index::Fields::YEAR_FACET

Constants included from Index::LegacyLicenseFields

Index::LegacyLicenseFields::DEFAULT_LICENSE_DESCRIPTION, Index::LegacyLicenseFields::DEFAULT_LICENSE_TITLE, Index::LegacyLicenseFields::DEFAULT_LICENSE_URL, Index::LegacyLicenseFields::LICENSE_DESCRIPTION, Index::LegacyLicenseFields::LICENSE_TITLE, Index::LegacyLicenseFields::LICENSE_URL

Instance Method Summary collapse

Methods included from Index::Fields

get, techmd

Instance Method Details

#admin_set_facetObject



102
103
104
105
106
107
108
# File 'lib/ddr/models/indexing.rb', line 102

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

#all_identifiersObject



94
95
96
# File 'lib/ddr/models/indexing.rb', line 94

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

#associated_collectionObject



98
99
100
# File 'lib/ddr/models/indexing.rb', line 98

def associated_collection
  admin_policy
end

#collection_facetObject



110
111
112
# File 'lib/ddr/models/indexing.rb', line 110

def collection_facet
  associated_collection.internal_uri if associated_collection.present?
end

#date_sortObject



114
115
116
# File 'lib/ddr/models/indexing.rb', line 114

def date_sort
  date.first
end

#index_fieldsObject



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

def index_fields
  fields = {
    ACCESS_ROLE           => roles.to_json,
    ADMIN_SET             => admin_set,
    BOX_NUMBER_FACET      => ('box_number'),
    CREATOR_FACET         => creator,
    DATE_FACET            => date,
    DATE_SORT             => date_sort,
    DEPOSITOR             => depositor,
    DISPLAY_FORMAT        => display_format,
    DOI                   => .doi,
    EAD_ID                => ead_id,
    IDENTIFIER_ALL        => all_identifiers,
    INTERNAL_URI          => internal_uri,
    LICENSE               => license,
    LICENSE_DESCRIPTION   => .license.description.first,
    LICENSE_TITLE         => .license.title.first,
    LICENSE_URL           => .license.url.first,
    LOCAL_ID              => local_id,
    PERMANENT_ID          => permanent_id,
    PERMANENT_URL         => permanent_url,
    POLICY_ROLE           => roles.in_policy_scope.agents,
    PUBLISHER_FACET       => publisher,
    RESEARCH_HELP_CONTACT => research_help_contact,
    RESOURCE_ROLE         => roles.in_resource_scope.agents,
    SERIES_FACET          => ('series'),
    SPATIAL_FACET         => ('spatial'),
    TITLE                 => title_display,
    TYPE_FACET            => type,
    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_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[STRUCT_MAPS] = structure.struct_maps.to_json
  end
  if has_extracted_text?
    fields[EXTRACTED_TEXT] = extractedText.content
  end
  if is_a? Component
    fields[COLLECTION_URI] = collection_uri
  end
  if is_a? Collection
    fields[DEFAULT_LICENSE_DESCRIPTION] = defaultRights.license.description.first
    fields[DEFAULT_LICENSE_TITLE] = defaultRights.license.title.first
    fields[DEFAULT_LICENSE_URL] = defaultRights.license.url.first
    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
  end
  fields
end

#title_displayObject



87
88
89
90
91
92
# File 'lib/ddr/models/indexing.rb', line 87

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



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

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

#year_facetObject



118
119
120
# File 'lib/ddr/models/indexing.rb', line 118

def year_facet
  YearFacet.call(self)
end