Skip to content

Commit

Permalink
Docs for DataAttributes.
Browse files Browse the repository at this point in the history
  • Loading branch information
mjy committed Dec 4, 2014
1 parent b29a29b commit 4ac9d2a
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 0 deletions.
20 changes: 20 additions & 0 deletions app/models/data_attribute.rb
@@ -1,3 +1,23 @@
# A data attribute is used to attach an arbitrary predicate/literal pair to a data instance, essentially creating a user-defined triple.
#
# DataAttribute is only instantiated through its subclasses ImportAttribute or InternalAttribute
#
# @!attribute value
# @return [String]
# The user provided data, e.g. RFD literal or objectobject, i.e. RDF literal, i.e. data in a cell of a spreadsheet. Always required.
#
# @!attribute attribute_subject_id
# @return [Integer]
# The id of the subject (Rails polymorphic relationship).
#
# @!attribute attribute_subject_type
# @return [String]
# THe class of the subject (Rails polymorphic relationship).
#
# @!attribute type
# @return [String]
# The type of DataAttribute (Rails STI).
#
class DataAttribute < ActiveRecord::Base
include Housekeeping::Users
include Shared::IsData
Expand Down
33 changes: 33 additions & 0 deletions app/models/import_attribute.rb
@@ -1,3 +1,36 @@

# The DataAttribute that has an externally referenced (and likely undefined) predicate.
#
# 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"
#
#
#
# @!attribute import_predicate
# @return [string]
# The predicate literal. For example a column header.
#
#
class ImportAttribute < DataAttribute
include Housekeeping::Users
validates_presence_of :import_predicate
Expand Down
9 changes: 9 additions & 0 deletions app/models/internal_attribute.rb
@@ -1,3 +1,12 @@
# The DataAttribute that has a Predicate that is internally defined in TaxonwWorks.
#
# Internal attributes have stronger semantics that ImportAttributes in that the user has had to first
# create a Predicate (which is a controlled vocabulary subclass), which in turn requires a definition.

# @!attribute controlled_vocabulary_term_id
# @return [id]
# The the id of the ControlledVocabularyTerm::Predicate. Term is referenced as .predicate.
#
class InternalAttribute < DataAttribute
include Housekeeping
belongs_to :predicate, foreign_key: :controlled_vocabulary_term_id, inverse_of: :internal_attributes
Expand Down

0 comments on commit 4ac9d2a

Please sign in to comment.