Class: Identifier::Local

Inherits:
Identifier show all
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

Instance Method Summary (collapse)

Methods inherited from Identifier

find_for_autocomplete, prototype_identifier, #type_name

Methods included from Housekeeping

#has_polymorphic_relationship?

Methods included from ActiverecordUtilities

#trim_attributes

Instance Method Details

- (Object) set_cached (protected)



41
42
43
# File 'app/models/identifier/local.rb', line 41

def set_cached
  update_column(:cached, namespace.short_name + " " + identifier.to_s)
end

- (Scope) with_namespaced_identifier(namespace_name, identifier)

Exact match on identifier + namespace

Parameters:

  • (String, String)

Returns:

  • (Scope)


31
32
33
34
35
36
37
# File 'app/models/identifier/local.rb', line 31

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