Class: Namespace
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Namespace
- Includes:
- Housekeeping::Timestamps, Housekeeping::Users, Shared::HasPapertrail, Shared::IsData, Shared::SharedAcrossProjects
- Defined in:
- app/models/namespace.rb
Overview
A Namespace is used to define a set of local Identifiers. All identifiers within a Namespace must be unique. Namespaces are shared across projects. In TaxonWorks Identifiers + Namespaces are used for differentiating/disambiguating one datum from another. This applies to all local identifiers, not just what most might be familiar with in the DwC catalogNumber field.
Namespaces are used to to meet practical needs that also have FAIR consequences:
-
They attempt to provide a degree of provenance as to how the Identifier came to be
-
To differentiate, in practical terms, one identifier from another within the system that merges data
-
To act as a labels (short mneomincs) that allows the data curator to disambiguate what might be otherwise two identical strings
Namespaces are minted in TW on a first come first serve basis. Their short and long names must be unique. When conflicts arise new values must be minted for record keeping purposes. In this case a verbatim_short_name can be provided, and this value will be presented for reporting/searching purposes. This is a strong restriction that is intended to encourage users to think before they mint a Namespace.
In TaxonWorks Namespaces _do not_ imply ownership of the things they are linked to. If an identifier has a Namespace that includes a reference, in some way, to some Repository, it does not mean that that Repository ‘owns’ the identified thing.
In natural history collection management many catalog numbers contain an institutional coden as part of their catalog number (as physically written). In TaxonWorks we treat that coden as the basis for a Namespace. Note that we also may use the CODEN in a second way, to identify the Repository. While the string is duplicate the meaning is not. One use let’s us quickly reference a Repository, the second use let’s us quickly narrow searches to a specific Identifier linked to our object.
from DwC in some contexts.
Instance Attribute Summary collapse
-
#delimiter ⇒ String, ...
A Namespace is used to define a set of local Identifiers.
-
#institution ⇒ String, ...
A Namespace is used to define a set of local Identifiers.
-
#is_virtual ⇒ String, ...
A Namespace is used to define a set of local Identifiers.
-
#name ⇒ String, ...
A Namespace is used to define a set of local Identifiers.
-
#short_name ⇒ String, ...
A Namespace is used to define a set of local Identifiers.
-
#verbatim_short_name ⇒ String, ...
A Namespace is used to define a set of local Identifiers.
Attributes included from Housekeeping::Users
Class Method Summary collapse
Instance Method Summary collapse
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::HasPapertrail
#attribute_updated, #attribute_updater
Methods included from Housekeeping::Users
#set_created_by_id, #set_updated_by_id
Methods inherited from ApplicationRecord
Instance Attribute Details
#delimiter ⇒ String, ...
A Namespace is used to define a set of local Identifiers. All identifiers within a Namespace must be unique. Namespaces are shared across projects. In TaxonWorks Identifiers + Namespaces are used for differentiating/disambiguating one datum from another. This applies to all local identifiers, not just what most might be familiar with in the DwC catalogNumber field.
Namespaces are used to to meet practical needs that also have FAIR consequences:
-
They attempt to provide a degree of provenance as to how the Identifier came to be
-
To differentiate, in practical terms, one identifier from another within the system that merges data
-
To act as a labels (short mneomincs) that allows the data curator to disambiguate what might be otherwise two identical strings
Namespaces are minted in TW on a first come first serve basis. Their short and long names must be unique. When conflicts arise new values must be minted for record keeping purposes. In this case a verbatim_short_name can be provided, and this value will be presented for reporting/searching purposes. This is a strong restriction that is intended to encourage users to think before they mint a Namespace.
In TaxonWorks Namespaces _do not_ imply ownership of the things they are linked to. If an identifier has a Namespace that includes a reference, in some way, to some Repository, it does not mean that that Repository ‘owns’ the identified thing.
In natural history collection management many catalog numbers contain an institutional coden as part of their catalog number (as physically written). In TaxonWorks we treat that coden as the basis for a Namespace. Note that we also may use the CODEN in a second way, to identify the Repository. While the string is duplicate the meaning is not. One use let’s us quickly reference a Repository, the second use let’s us quickly narrow searches to a specific Identifier linked to our object.
from DwC in some contexts.
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 |
# File 'app/models/namespace.rb', line 60 class Namespace < ApplicationRecord include Housekeeping::Users include Housekeeping::Timestamps include Shared::SharedAcrossProjects include Shared::HasPapertrail include Shared::IsData after_update :update_local_idenfifiers validates_presence_of :name, :short_name validates_uniqueness_of :name, :short_name, case_sensitive: false # Autosave should resave all, but it clearly doesn't # we also don't want to validte the identifiers on this resave, but rather # just trigger the rebuild of identifiers#cache. Will have to add an after_save here. has_many :identifiers, autosave: true, dependent: :restrict_with_error, inverse_of: :namespace scope :used_on_klass, -> (klass) { joins(:identifiers).where(identifiers: {identifier_object_type: klass} ) } scope :used_recently, -> { joins(:identifiers).includes(:identifiers).where(identifiers: { updated_at: 10.weeks.ago..Time.now } ).order('"identifiers"."created_at" DESC') } scope :used_in_project, -> (project_id) { joins(:identifiers).where( identifiers: { project_id: project_id } ) } def is_virtual? is_virtual end def self.select_optimized(user_id, project_id, klass) h = { recent: ( Namespace.used_on_klass(klass) .where(identifiers: {updated_by_id: user_id}) .used_in_project(project_id) .used_recently .distinct.limit(6).to_a + Namespace.where(created_by_id: user_id, created_at: (3.hours.ago..Time.now)).limit(5)).uniq, pinboard: Namespace.pinned_by(user_id).pinned_in_project(project_id).to_a } h[:quick] = (Namespace.pinned_by(user_id).pinboard_inserted.pinned_in_project(project_id).to_a + h[:recent][0..3]).uniq h end def update_local_idenfifiers Identifier::Local.update_cached(self) end end |
#institution ⇒ String, ...
A Namespace is used to define a set of local Identifiers. All identifiers within a Namespace must be unique. Namespaces are shared across projects. In TaxonWorks Identifiers + Namespaces are used for differentiating/disambiguating one datum from another. This applies to all local identifiers, not just what most might be familiar with in the DwC catalogNumber field.
Namespaces are used to to meet practical needs that also have FAIR consequences:
-
They attempt to provide a degree of provenance as to how the Identifier came to be
-
To differentiate, in practical terms, one identifier from another within the system that merges data
-
To act as a labels (short mneomincs) that allows the data curator to disambiguate what might be otherwise two identical strings
Namespaces are minted in TW on a first come first serve basis. Their short and long names must be unique. When conflicts arise new values must be minted for record keeping purposes. In this case a verbatim_short_name can be provided, and this value will be presented for reporting/searching purposes. This is a strong restriction that is intended to encourage users to think before they mint a Namespace.
In TaxonWorks Namespaces _do not_ imply ownership of the things they are linked to. If an identifier has a Namespace that includes a reference, in some way, to some Repository, it does not mean that that Repository ‘owns’ the identified thing.
In natural history collection management many catalog numbers contain an institutional coden as part of their catalog number (as physically written). In TaxonWorks we treat that coden as the basis for a Namespace. Note that we also may use the CODEN in a second way, to identify the Repository. While the string is duplicate the meaning is not. One use let’s us quickly reference a Repository, the second use let’s us quickly narrow searches to a specific Identifier linked to our object.
from DwC in some contexts.
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 |
# File 'app/models/namespace.rb', line 60 class Namespace < ApplicationRecord include Housekeeping::Users include Housekeeping::Timestamps include Shared::SharedAcrossProjects include Shared::HasPapertrail include Shared::IsData after_update :update_local_idenfifiers validates_presence_of :name, :short_name validates_uniqueness_of :name, :short_name, case_sensitive: false # Autosave should resave all, but it clearly doesn't # we also don't want to validte the identifiers on this resave, but rather # just trigger the rebuild of identifiers#cache. Will have to add an after_save here. has_many :identifiers, autosave: true, dependent: :restrict_with_error, inverse_of: :namespace scope :used_on_klass, -> (klass) { joins(:identifiers).where(identifiers: {identifier_object_type: klass} ) } scope :used_recently, -> { joins(:identifiers).includes(:identifiers).where(identifiers: { updated_at: 10.weeks.ago..Time.now } ).order('"identifiers"."created_at" DESC') } scope :used_in_project, -> (project_id) { joins(:identifiers).where( identifiers: { project_id: project_id } ) } def is_virtual? is_virtual end def self.select_optimized(user_id, project_id, klass) h = { recent: ( Namespace.used_on_klass(klass) .where(identifiers: {updated_by_id: user_id}) .used_in_project(project_id) .used_recently .distinct.limit(6).to_a + Namespace.where(created_by_id: user_id, created_at: (3.hours.ago..Time.now)).limit(5)).uniq, pinboard: Namespace.pinned_by(user_id).pinned_in_project(project_id).to_a } h[:quick] = (Namespace.pinned_by(user_id).pinboard_inserted.pinned_in_project(project_id).to_a + h[:recent][0..3]).uniq h end def update_local_idenfifiers Identifier::Local.update_cached(self) end end |
#is_virtual ⇒ String, ...
A Namespace is used to define a set of local Identifiers. All identifiers within a Namespace must be unique. Namespaces are shared across projects. In TaxonWorks Identifiers + Namespaces are used for differentiating/disambiguating one datum from another. This applies to all local identifiers, not just what most might be familiar with in the DwC catalogNumber field.
Namespaces are used to to meet practical needs that also have FAIR consequences:
-
They attempt to provide a degree of provenance as to how the Identifier came to be
-
To differentiate, in practical terms, one identifier from another within the system that merges data
-
To act as a labels (short mneomincs) that allows the data curator to disambiguate what might be otherwise two identical strings
Namespaces are minted in TW on a first come first serve basis. Their short and long names must be unique. When conflicts arise new values must be minted for record keeping purposes. In this case a verbatim_short_name can be provided, and this value will be presented for reporting/searching purposes. This is a strong restriction that is intended to encourage users to think before they mint a Namespace.
In TaxonWorks Namespaces _do not_ imply ownership of the things they are linked to. If an identifier has a Namespace that includes a reference, in some way, to some Repository, it does not mean that that Repository ‘owns’ the identified thing.
In natural history collection management many catalog numbers contain an institutional coden as part of their catalog number (as physically written). In TaxonWorks we treat that coden as the basis for a Namespace. Note that we also may use the CODEN in a second way, to identify the Repository. While the string is duplicate the meaning is not. One use let’s us quickly reference a Repository, the second use let’s us quickly narrow searches to a specific Identifier linked to our object.
from DwC in some contexts.
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 |
# File 'app/models/namespace.rb', line 60 class Namespace < ApplicationRecord include Housekeeping::Users include Housekeeping::Timestamps include Shared::SharedAcrossProjects include Shared::HasPapertrail include Shared::IsData after_update :update_local_idenfifiers validates_presence_of :name, :short_name validates_uniqueness_of :name, :short_name, case_sensitive: false # Autosave should resave all, but it clearly doesn't # we also don't want to validte the identifiers on this resave, but rather # just trigger the rebuild of identifiers#cache. Will have to add an after_save here. has_many :identifiers, autosave: true, dependent: :restrict_with_error, inverse_of: :namespace scope :used_on_klass, -> (klass) { joins(:identifiers).where(identifiers: {identifier_object_type: klass} ) } scope :used_recently, -> { joins(:identifiers).includes(:identifiers).where(identifiers: { updated_at: 10.weeks.ago..Time.now } ).order('"identifiers"."created_at" DESC') } scope :used_in_project, -> (project_id) { joins(:identifiers).where( identifiers: { project_id: project_id } ) } def is_virtual? is_virtual end def self.select_optimized(user_id, project_id, klass) h = { recent: ( Namespace.used_on_klass(klass) .where(identifiers: {updated_by_id: user_id}) .used_in_project(project_id) .used_recently .distinct.limit(6).to_a + Namespace.where(created_by_id: user_id, created_at: (3.hours.ago..Time.now)).limit(5)).uniq, pinboard: Namespace.pinned_by(user_id).pinned_in_project(project_id).to_a } h[:quick] = (Namespace.pinned_by(user_id).pinboard_inserted.pinned_in_project(project_id).to_a + h[:recent][0..3]).uniq h end def update_local_idenfifiers Identifier::Local.update_cached(self) end end |
#name ⇒ String, ...
A Namespace is used to define a set of local Identifiers. All identifiers within a Namespace must be unique. Namespaces are shared across projects. In TaxonWorks Identifiers + Namespaces are used for differentiating/disambiguating one datum from another. This applies to all local identifiers, not just what most might be familiar with in the DwC catalogNumber field.
Namespaces are used to to meet practical needs that also have FAIR consequences:
-
They attempt to provide a degree of provenance as to how the Identifier came to be
-
To differentiate, in practical terms, one identifier from another within the system that merges data
-
To act as a labels (short mneomincs) that allows the data curator to disambiguate what might be otherwise two identical strings
Namespaces are minted in TW on a first come first serve basis. Their short and long names must be unique. When conflicts arise new values must be minted for record keeping purposes. In this case a verbatim_short_name can be provided, and this value will be presented for reporting/searching purposes. This is a strong restriction that is intended to encourage users to think before they mint a Namespace.
In TaxonWorks Namespaces _do not_ imply ownership of the things they are linked to. If an identifier has a Namespace that includes a reference, in some way, to some Repository, it does not mean that that Repository ‘owns’ the identified thing.
In natural history collection management many catalog numbers contain an institutional coden as part of their catalog number (as physically written). In TaxonWorks we treat that coden as the basis for a Namespace. Note that we also may use the CODEN in a second way, to identify the Repository. While the string is duplicate the meaning is not. One use let’s us quickly reference a Repository, the second use let’s us quickly narrow searches to a specific Identifier linked to our object.
from DwC in some contexts.
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 |
# File 'app/models/namespace.rb', line 60 class Namespace < ApplicationRecord include Housekeeping::Users include Housekeeping::Timestamps include Shared::SharedAcrossProjects include Shared::HasPapertrail include Shared::IsData after_update :update_local_idenfifiers validates_presence_of :name, :short_name validates_uniqueness_of :name, :short_name, case_sensitive: false # Autosave should resave all, but it clearly doesn't # we also don't want to validte the identifiers on this resave, but rather # just trigger the rebuild of identifiers#cache. Will have to add an after_save here. has_many :identifiers, autosave: true, dependent: :restrict_with_error, inverse_of: :namespace scope :used_on_klass, -> (klass) { joins(:identifiers).where(identifiers: {identifier_object_type: klass} ) } scope :used_recently, -> { joins(:identifiers).includes(:identifiers).where(identifiers: { updated_at: 10.weeks.ago..Time.now } ).order('"identifiers"."created_at" DESC') } scope :used_in_project, -> (project_id) { joins(:identifiers).where( identifiers: { project_id: project_id } ) } def is_virtual? is_virtual end def self.select_optimized(user_id, project_id, klass) h = { recent: ( Namespace.used_on_klass(klass) .where(identifiers: {updated_by_id: user_id}) .used_in_project(project_id) .used_recently .distinct.limit(6).to_a + Namespace.where(created_by_id: user_id, created_at: (3.hours.ago..Time.now)).limit(5)).uniq, pinboard: Namespace.pinned_by(user_id).pinned_in_project(project_id).to_a } h[:quick] = (Namespace.pinned_by(user_id).pinboard_inserted.pinned_in_project(project_id).to_a + h[:recent][0..3]).uniq h end def update_local_idenfifiers Identifier::Local.update_cached(self) end end |
#short_name ⇒ String, ...
A Namespace is used to define a set of local Identifiers. All identifiers within a Namespace must be unique. Namespaces are shared across projects. In TaxonWorks Identifiers + Namespaces are used for differentiating/disambiguating one datum from another. This applies to all local identifiers, not just what most might be familiar with in the DwC catalogNumber field.
Namespaces are used to to meet practical needs that also have FAIR consequences:
-
They attempt to provide a degree of provenance as to how the Identifier came to be
-
To differentiate, in practical terms, one identifier from another within the system that merges data
-
To act as a labels (short mneomincs) that allows the data curator to disambiguate what might be otherwise two identical strings
Namespaces are minted in TW on a first come first serve basis. Their short and long names must be unique. When conflicts arise new values must be minted for record keeping purposes. In this case a verbatim_short_name can be provided, and this value will be presented for reporting/searching purposes. This is a strong restriction that is intended to encourage users to think before they mint a Namespace.
In TaxonWorks Namespaces _do not_ imply ownership of the things they are linked to. If an identifier has a Namespace that includes a reference, in some way, to some Repository, it does not mean that that Repository ‘owns’ the identified thing.
In natural history collection management many catalog numbers contain an institutional coden as part of their catalog number (as physically written). In TaxonWorks we treat that coden as the basis for a Namespace. Note that we also may use the CODEN in a second way, to identify the Repository. While the string is duplicate the meaning is not. One use let’s us quickly reference a Repository, the second use let’s us quickly narrow searches to a specific Identifier linked to our object.
from DwC in some contexts.
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 |
# File 'app/models/namespace.rb', line 60 class Namespace < ApplicationRecord include Housekeeping::Users include Housekeeping::Timestamps include Shared::SharedAcrossProjects include Shared::HasPapertrail include Shared::IsData after_update :update_local_idenfifiers validates_presence_of :name, :short_name validates_uniqueness_of :name, :short_name, case_sensitive: false # Autosave should resave all, but it clearly doesn't # we also don't want to validte the identifiers on this resave, but rather # just trigger the rebuild of identifiers#cache. Will have to add an after_save here. has_many :identifiers, autosave: true, dependent: :restrict_with_error, inverse_of: :namespace scope :used_on_klass, -> (klass) { joins(:identifiers).where(identifiers: {identifier_object_type: klass} ) } scope :used_recently, -> { joins(:identifiers).includes(:identifiers).where(identifiers: { updated_at: 10.weeks.ago..Time.now } ).order('"identifiers"."created_at" DESC') } scope :used_in_project, -> (project_id) { joins(:identifiers).where( identifiers: { project_id: project_id } ) } def is_virtual? is_virtual end def self.select_optimized(user_id, project_id, klass) h = { recent: ( Namespace.used_on_klass(klass) .where(identifiers: {updated_by_id: user_id}) .used_in_project(project_id) .used_recently .distinct.limit(6).to_a + Namespace.where(created_by_id: user_id, created_at: (3.hours.ago..Time.now)).limit(5)).uniq, pinboard: Namespace.pinned_by(user_id).pinned_in_project(project_id).to_a } h[:quick] = (Namespace.pinned_by(user_id).pinboard_inserted.pinned_in_project(project_id).to_a + h[:recent][0..3]).uniq h end def update_local_idenfifiers Identifier::Local.update_cached(self) end end |
#verbatim_short_name ⇒ String, ...
A Namespace is used to define a set of local Identifiers. All identifiers within a Namespace must be unique. Namespaces are shared across projects. In TaxonWorks Identifiers + Namespaces are used for differentiating/disambiguating one datum from another. This applies to all local identifiers, not just what most might be familiar with in the DwC catalogNumber field.
Namespaces are used to to meet practical needs that also have FAIR consequences:
-
They attempt to provide a degree of provenance as to how the Identifier came to be
-
To differentiate, in practical terms, one identifier from another within the system that merges data
-
To act as a labels (short mneomincs) that allows the data curator to disambiguate what might be otherwise two identical strings
Namespaces are minted in TW on a first come first serve basis. Their short and long names must be unique. When conflicts arise new values must be minted for record keeping purposes. In this case a verbatim_short_name can be provided, and this value will be presented for reporting/searching purposes. This is a strong restriction that is intended to encourage users to think before they mint a Namespace.
In TaxonWorks Namespaces _do not_ imply ownership of the things they are linked to. If an identifier has a Namespace that includes a reference, in some way, to some Repository, it does not mean that that Repository ‘owns’ the identified thing.
In natural history collection management many catalog numbers contain an institutional coden as part of their catalog number (as physically written). In TaxonWorks we treat that coden as the basis for a Namespace. Note that we also may use the CODEN in a second way, to identify the Repository. While the string is duplicate the meaning is not. One use let’s us quickly reference a Repository, the second use let’s us quickly narrow searches to a specific Identifier linked to our object.
from DwC in some contexts.
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 |
# File 'app/models/namespace.rb', line 60 class Namespace < ApplicationRecord include Housekeeping::Users include Housekeeping::Timestamps include Shared::SharedAcrossProjects include Shared::HasPapertrail include Shared::IsData after_update :update_local_idenfifiers validates_presence_of :name, :short_name validates_uniqueness_of :name, :short_name, case_sensitive: false # Autosave should resave all, but it clearly doesn't # we also don't want to validte the identifiers on this resave, but rather # just trigger the rebuild of identifiers#cache. Will have to add an after_save here. has_many :identifiers, autosave: true, dependent: :restrict_with_error, inverse_of: :namespace scope :used_on_klass, -> (klass) { joins(:identifiers).where(identifiers: {identifier_object_type: klass} ) } scope :used_recently, -> { joins(:identifiers).includes(:identifiers).where(identifiers: { updated_at: 10.weeks.ago..Time.now } ).order('"identifiers"."created_at" DESC') } scope :used_in_project, -> (project_id) { joins(:identifiers).where( identifiers: { project_id: project_id } ) } def is_virtual? is_virtual end def self.select_optimized(user_id, project_id, klass) h = { recent: ( Namespace.used_on_klass(klass) .where(identifiers: {updated_by_id: user_id}) .used_in_project(project_id) .used_recently .distinct.limit(6).to_a + Namespace.where(created_by_id: user_id, created_at: (3.hours.ago..Time.now)).limit(5)).uniq, pinboard: Namespace.pinned_by(user_id).pinned_in_project(project_id).to_a } h[:quick] = (Namespace.pinned_by(user_id).pinboard_inserted.pinned_in_project(project_id).to_a + h[:recent][0..3]).uniq h end def update_local_idenfifiers Identifier::Local.update_cached(self) end end |
Class Method Details
.select_optimized(user_id, project_id, klass) ⇒ Object
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'app/models/namespace.rb', line 85 def self.select_optimized(user_id, project_id, klass) h = { recent: ( Namespace.used_on_klass(klass) .where(identifiers: {updated_by_id: user_id}) .used_in_project(project_id) .used_recently .distinct.limit(6).to_a + Namespace.where(created_by_id: user_id, created_at: (3.hours.ago..Time.now)).limit(5)).uniq, pinboard: Namespace.pinned_by(user_id).pinned_in_project(project_id).to_a } h[:quick] = (Namespace.pinned_by(user_id).pinboard_inserted.pinned_in_project(project_id).to_a + h[:recent][0..3]).uniq h end |
Instance Method Details
#is_virtual? ⇒ Boolean
81 82 83 |
# File 'app/models/namespace.rb', line 81 def is_virtual? is_virtual end |
#update_local_idenfifiers ⇒ Object
101 102 103 |
# File 'app/models/namespace.rb', line 101 def update_local_idenfifiers Identifier::Local.update_cached(self) end |