Class: Identifier::Local
- Inherits:
-
Identifier
- Object
- ActiveRecord::Base
- ApplicationRecord
- Identifier
- Identifier::Local
- Defined in:
- app/models/identifier/local.rb
Overview
The identifier that is generated for local use, i.e. no signficant effort (countering example DOIs) was made to ensure global uniqueness. While most identifiers are intended to be unique globally, few consider mechanisms for ensuring this.
Local identifiers of the same type may be stacked on a single record without defining the relation between each identifier (see conceptual difference in Identfier::Global).
Local identifiers require a namespace. See Namespace.
Multiple local identfiers of the same namespace can be applied to the same object, while this is rarely useful in real life it does have physical-world analogs, see in particular Accession numbers on Collecting Events linked to Specimens that are in the process of being accessioned.
Foo 123 (CatalogNumber)
Foo 345 (CatalogNumber)
You can also do this on the same object:
Foo 123 (CatalogNumber)
Bar 123 (CatalogNumber)
In addition, identifiers of a certain type (subclass) must be unique across namespaces within a project.
Direct Known Subclasses
AccessionCode, CatalogNumber, ContainerCode, Import, LoanCode, OtuUtility, TripCode
Defined Under Namespace
Classes: AccessionCode, CatalogNumber, ContainerCode, Import, LoanCode, OtuUtility, TripCode
Instance Attribute Summary
Attributes inherited from Identifier
#cached, #identifier, #identifier_object_id, #namespace_id, #project_id, #type
Attributes included from Shared::DualAnnotator
Instance Method Summary collapse
- #build_cached ⇒ Object protected
-
#delimiter ⇒ Object
protected
String.
- #set_cached ⇒ Object protected
-
#with_namespaced_identifier(namespace_name, identifier) ⇒ Scope
Exact match on identifier + namespace.
Methods inherited from Identifier
prototype_identifier, #type_name
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::Labels
Methods included from Housekeeping
#has_polymorphic_relationship?
Methods included from Shared::DualAnnotator
Methods inherited from ApplicationRecord
Instance Method Details
#build_cached ⇒ Object (protected)
51 52 53 |
# File 'app/models/identifier/local.rb', line 51 def build_cached [namespace.verbatim_short_name, namespace.short_name].compact.first + delimiter + identifier.to_s end |
#delimiter ⇒ Object (protected)
Returns string.
45 46 47 48 49 |
# File 'app/models/identifier/local.rb', line 45 def delimiter a = namespace&.read_attribute(:delimiter) return '' if a == 'NONE' [a, ' '].compact.first end |
#set_cached ⇒ Object (protected)
55 56 57 |
# File 'app/models/identifier/local.rb', line 55 def set_cached update_column(:cached, build_cached) end |
#with_namespaced_identifier(namespace_name, identifier) ⇒ Scope
Exact match on identifier + namespace
34 35 36 37 38 39 40 |
# File 'app/models/identifier/local.rb', line 34 def with_namespaced_identifier(namespace_name, identifier) ret_val = includes(:identifiers).where(identifiers: {namespace: {name: namespace_name}}, identifier: identifier).references(:identifiers) if ret_val.count == 0 ret_val = includes(:identifiers).where(identifiers: {namespace: {short_name: namespace_name}}, identifier: identifier).references(:identifiers) end ret_val end |