Class: CaTissue::Database

Inherits:
CaRuby::Database
  • Object
show all
Defined in:
lib/catissue/database.rb

Overview

CaTissue::Database mediates access to the caTissue application service and database. The CaRuby::Database functionality is preserved, but CaTissue::Database overrides several base class private methods to enable alternate CaTissue-specific search strategies and work around caTissue and caCORE bugs.

There is a single caTissue client database instance per thread.

This class contains a grab-bag of long and convoluted method implementations for the many caTissue API quirks that necessitate special attention.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeDatabase

Creates a new Database with the catissuecore service and #access_properties.



24
25
26
# File 'lib/catissue/database.rb', line 24

def initialize
  super(SVC_NAME) { access_properties }
end

Class Method Details

.currentObject



19
20
21
# File 'lib/catissue/database.rb', line 19

def self.current
  Thread.current[:crtdb] ||= new 
end

Instance Method Details

#access_propertiesObject



29
30
31
# File 'lib/catissue/database.rb', line 29

def access_properties
  CaTissue.properties
end

#annotatorAnnotator

Returns the annotator utility.

Returns:



39
40
41
# File 'lib/catissue/database.rb', line 39

def annotator
  @annotator ||= Annotator.new(self)
end

#create(obj) ⇒ Object

Parameters:

  • obj (Resource)

    the dependent domain object to save

Raises:

  • (CaRuby::DatabaseError)

    if the object is a Address



61
62
63
64
65
66
# File 'lib/catissue/database.rb', line 61

def create(obj)
  if CaTissue::Address === obj then
    raise CaRuby::DatabaseError.new("Address creation is not supported.new(since a caTissue bug does not set the create result identifier property.")
  end
  super
end

#ensure_exists(obj) ⇒ Object

Augments CaRuby::Database.ensure_exists} to ensure that an {Annotation::Proxy reference identifier reflects the hook identifier.



72
73
74
75
76
77
# File 'lib/catissue/database.rb', line 72

def ensure_exists(obj)
  if Annotation::Proxy === obj then
    obj.ensure_hook_exists
  end
  super
end

#executorObject

return [CaRuby::SQLExecutor] a utility SQL executor



34
35
36
# File 'lib/catissue/database.rb', line 34

def executor
  @executor ||= create_executor
end

#persistence_service(klass) ⇒ Object

If the given domain object is an Annotation, then this method returns the CaRuby::AnnotationService for the object AnnotationModule, otherwise this method returns the standard CaTissue::Database service.



49
50
51
# File 'lib/catissue/database.rb', line 49

def persistence_service(klass)
  klass < Annotation ? klass.annotation_module.persistence_service : super
end