Class: ImportAttribute

Inherits:
DataAttribute show all
Defined in:
app/models/import_attribute.rb

Overview

The DataAttribute that has an externally referenced (and likely undefined) predicate.

An ImportAttribute should (can) only be created during a batch import process, they are write once, read many.

The values and predicates of _can not be edited_ after creation.

ImportAttributes are used to attach data to other TW data in cases where the user is unclear as to the meaning of the related data. For example, if a spreadsheet is batch imported it might be that 4 of the 10 columns could be mapped to a concept, say CollectionObject, in TW. The remaining 6 columns do not nicely map. If the user wants to associate the data from those 6 columns she can include them as import attributes. In this case the column header is the @import_predicate.

Use with caution, typically as a means to maintain legacy values on import.

For example:

attribute_subject  import_predicate       value
@some_otu          "times_seen_in_lake"   14

or

attribute_subject  import_predicate       value
@some_specimen     'has_part'            'some_uri'

or

attribute_subject       import_predicate  value
@some_collecting_event  "micro_habitat"   "north side of wet rock"

Constant Summary

Constants included from Shared::DualAnnotator

Shared::DualAnnotator::ALWAYS_COMMUNITY

Instance Attribute Summary collapse

Attributes inherited from DataAttribute

#attribute_subject_id, #attribute_subject_type, #controlled_vocabulary_term_id, #project_id, #type, #value

Instance Method Summary collapse

Methods inherited from DataAttribute

#editable?, find_for_autocomplete

Methods included from Shared::PolymorphicAnnotator

#annotated_object_is_persisted?

Methods included from Shared::IsData

#errors_excepting, #full_error_messages_excepting, #identical, #is_community?, #is_destroyable?, #is_editable?, #is_in_use?, #is_in_users_projects?, #metamorphosize, #similar

Methods included from Shared::Citations

#cited?, #mark_citations_for_destruction, #nomenclature_date, #origin_citation_source_id, #reject_citations, #requires_citation?, #sources_by_topic_id

Methods included from Housekeeping

#has_polymorphic_relationship?

Methods inherited from ApplicationRecord

transaction_with_retry

Instance Attribute Details

#import_predicatestring

The predicate literal. For example a column header.

Returns:

  • (string)


35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'app/models/import_attribute.rb', line 35

class ImportAttribute < DataAttribute
  validates_absence_of :predicate
  
  validates_presence_of :import_predicate
  validates_uniqueness_of :value, scope: [
    :attribute_subject_id,
    :attribute_subject_type,
    :type,
    :import_predicate,
    :project_id]

  def predicate_name
    import_predicate
  end
end

Instance Method Details

#predicate_nameObject



46
47
48
# File 'app/models/import_attribute.rb', line 46

def predicate_name
  import_predicate
end