talia_core 0.5.4 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (122) hide show
  1. data/VERSION.yml +2 -2
  2. data/config/talia_core.yml.example +37 -35
  3. data/generators/talia_admin/templates/app/models/fake_source.rb +93 -0
  4. data/generators/talia_admin/templates/app/models/talia_collection.rb +13 -37
  5. data/generators/talia_base/talia_base_generator.rb +0 -1
  6. data/generators/talia_base/templates/app/controllers/custom_templates_controller.rb +2 -1
  7. data/generators/talia_base/templates/app/controllers/sources_controller.rb +1 -1
  8. data/generators/talia_base/templates/script/configure_talia +56 -73
  9. data/generators/talia_swicky/talia_swicky_generator.rb +18 -0
  10. data/generators/talia_swicky/templates/app/controllers/swicky_notebooks_controller.rb +111 -0
  11. data/generators/talia_swicky/templates/app/helpers/swicky_notebooks_helper.rb +29 -0
  12. data/generators/talia_swicky/templates/app/views/swicky_notebooks/index.builder +6 -0
  13. data/generators/talia_swicky/templates/app/views/swicky_notebooks/index.html.erb +10 -0
  14. data/generators/talia_swicky/templates/app/views/swicky_notebooks/show.html.erb +11 -0
  15. data/generators/talia_swicky/templates/test/fixtures/notebook.rdf +862 -0
  16. data/generators/talia_swicky/templates/test/functional/swicky_notebooks_controller_test.rb +44 -0
  17. data/lib/core_ext/boolean.rb +23 -0
  18. data/lib/core_ext/jdbc_rake_monkeypatch.rb +22 -0
  19. data/lib/core_ext/nil_class.rb +11 -0
  20. data/lib/core_ext/object.rb +34 -0
  21. data/lib/core_ext/string.rb +15 -0
  22. data/lib/custom_template.rb +3 -1
  23. data/lib/loader_helper.rb +16 -3
  24. data/lib/mysql.rb +7 -7
  25. data/lib/progressbar.rb +2 -2
  26. data/lib/swicky/exhibit_json/item.rb +129 -0
  27. data/lib/swicky/exhibit_json/item_collection.rb +129 -0
  28. data/lib/swicky/fragment.rb +0 -0
  29. data/lib/swicky/note.rb +7 -0
  30. data/lib/swicky/notebook.rb +78 -12
  31. data/lib/talia_core/active_source.rb +45 -13
  32. data/lib/talia_core/active_source_parts/class_methods.rb +154 -26
  33. data/lib/talia_core/active_source_parts/finders.rb +49 -26
  34. data/lib/talia_core/active_source_parts/predicate_handler.rb +71 -23
  35. data/lib/talia_core/active_source_parts/rdf/ntriples_reader.rb +13 -0
  36. data/lib/talia_core/active_source_parts/rdf/rdf_reader.rb +99 -0
  37. data/lib/talia_core/active_source_parts/rdf/rdfxml_reader.rb +12 -0
  38. data/lib/talia_core/active_source_parts/{rdf.rb → rdf_handler.rb} +52 -19
  39. data/lib/talia_core/active_source_parts/xml/generic_reader.rb +151 -260
  40. data/lib/talia_core/active_source_parts/xml/generic_reader_add_statements.rb +97 -0
  41. data/lib/talia_core/active_source_parts/xml/generic_reader_helpers.rb +88 -0
  42. data/lib/talia_core/active_source_parts/xml/generic_reader_import_statements.rb +239 -0
  43. data/lib/talia_core/active_source_parts/xml/rdf_builder.rb +14 -7
  44. data/lib/talia_core/active_source_parts/xml/source_builder.rb +7 -3
  45. data/lib/talia_core/active_source_parts/xml/source_reader.rb +17 -2
  46. data/lib/talia_core/collection.rb +192 -1
  47. data/lib/talia_core/data_types/data_loader.rb +88 -18
  48. data/lib/talia_core/data_types/data_record.rb +24 -2
  49. data/lib/talia_core/data_types/delayed_copier.rb +13 -3
  50. data/lib/talia_core/data_types/file_record.rb +24 -13
  51. data/lib/talia_core/data_types/file_store.rb +111 -94
  52. data/lib/talia_core/data_types/iip_data.rb +104 -23
  53. data/lib/talia_core/data_types/iip_loader.rb +102 -56
  54. data/lib/talia_core/data_types/image_data.rb +3 -1
  55. data/lib/talia_core/data_types/media_link.rb +4 -1
  56. data/lib/talia_core/data_types/mime_mapping.rb +65 -38
  57. data/lib/talia_core/data_types/path_helpers.rb +23 -17
  58. data/lib/talia_core/data_types/pdf_data.rb +9 -6
  59. data/lib/talia_core/data_types/simple_text.rb +5 -4
  60. data/lib/talia_core/data_types/xml_data.rb +53 -25
  61. data/lib/talia_core/dummy_handler.rb +3 -2
  62. data/lib/talia_core/errors.rb +13 -27
  63. data/lib/talia_core/initializer.rb +44 -4
  64. data/lib/talia_core/oai/active_source_model.rb +13 -6
  65. data/lib/talia_core/oai/active_source_oai_adapter.rb +13 -12
  66. data/lib/talia_core/rdf_import.rb +1 -1
  67. data/lib/talia_core/rdf_resource.rb +2 -1
  68. data/lib/talia_core/semantic_collection_wrapper.rb +143 -151
  69. data/lib/talia_core/semantic_property.rb +4 -0
  70. data/lib/talia_core/semantic_relation.rb +84 -33
  71. data/lib/talia_core/source.rb +45 -25
  72. data/lib/talia_core/source_fragment.rb +7 -0
  73. data/lib/talia_core/source_transfer_object.rb +3 -1
  74. data/lib/talia_core/source_types/agent.rb +16 -0
  75. data/lib/talia_core/source_types/dc_resource.rb +3 -3
  76. data/lib/talia_core/source_types/marcont_resource.rb +15 -0
  77. data/lib/talia_core/source_types/skos_concept.rb +17 -0
  78. data/lib/talia_dependencies.rb +1 -1
  79. data/lib/talia_util.rb +1 -1
  80. data/lib/talia_util/bar_progressor.rb +1 -1
  81. data/lib/talia_util/image_conversions.rb +8 -2
  82. data/lib/talia_util/import_job_helper.rb +40 -3
  83. data/lib/talia_util/io_helper.rb +15 -4
  84. data/lib/talia_util/progressable.rb +50 -1
  85. data/lib/talia_util/rake_tasks.rb +3 -21
  86. data/lib/talia_util/test_helpers.rb +6 -1
  87. data/lib/talia_util/util.rb +108 -27
  88. data/lib/talia_util/xml/base_builder.rb +28 -1
  89. data/lib/talia_util/xml/rdf_builder.rb +81 -5
  90. data/lib/tasks/talia_core_tasks.rake +2 -0
  91. data/test/core_ext/boolean_test.rb +26 -0
  92. data/test/core_ext/nil_class_test.rb +14 -0
  93. data/test/core_ext/object_test.rb +26 -0
  94. data/test/core_ext/string_test.rb +11 -0
  95. data/test/swicky/json_encoder_test.rb +51 -42
  96. data/test/swicky/notebook_test.rb +13 -6
  97. data/test/talia_core/active_source_finder_interface_test.rb +30 -0
  98. data/test/talia_core/active_source_test.rb +445 -34
  99. data/test/talia_core/collection_test.rb +332 -0
  100. data/test/talia_core/data_types/file_record_test.rb +2 -23
  101. data/test/talia_core/ntriples_reader_test.rb +49 -0
  102. data/test/talia_core/rdfxml_reader_test.rb +51 -0
  103. data/test/talia_core/source_test.rb +12 -0
  104. data/test/talia_util/import_job_helper_test.rb +19 -12
  105. metadata +190 -90
  106. data/config/database.yml +0 -19
  107. data/config/rdfstore.yml +0 -13
  108. data/config/talia_core.yml +0 -24
  109. data/generators/talia_base/templates/migrations/bj_migration.rb +0 -10
  110. data/lib/JXslt/jxslt.rb +0 -60
  111. data/lib/swicky/json_encoder.rb +0 -179
  112. data/lib/talia_core/agent.rb +0 -14
  113. data/lib/talia_core/background_jobs/job.rb +0 -82
  114. data/lib/talia_core/background_jobs/progress_job.rb +0 -68
  115. data/lib/talia_core/data_types/temp_file_handling.rb +0 -85
  116. data/lib/talia_core/ordered_source.rb +0 -228
  117. data/lib/talia_core/semantic_collection_item.rb +0 -94
  118. data/lib/talia_core/source_types/collection.rb +0 -15
  119. data/lib/talia_util/progressbar.rb +0 -236
  120. data/tasks/talia_core_tasks.rake +0 -2
  121. data/test/talia_core/ordered_source_test.rb +0 -394
  122. data/test/talia_core/semantic_collection_item_test.rb +0 -125
@@ -1,16 +1,17 @@
1
1
  module TaliaCore
2
2
  module DataTypes
3
3
 
4
- # Class to manage PDF data type
4
+ # FileRecord that contains a PDF document.
5
5
  class PdfData < FileRecord
6
6
 
7
- # return the mime_type for a file
7
+ # The MIME type is always <tt>application/pdf</tt>
8
8
  def extract_mime_type(location)
9
9
  'application/pdf'
10
10
  end
11
11
 
12
- # Create the PDF data from a PDF writer. This method needs a block
13
- # which will be called with the writer object
12
+ # Create the PDF data using PDF::Writer. The writer will be passed
13
+ # to the block given to this method, and the resulting PDF will be
14
+ # saved as the record's file.
14
15
  def create_from_writer(writer_opts = {})
15
16
  activate_pdf
16
17
  writer = PDF::Writer.new(writer_opts) do |pdf|
@@ -24,14 +25,16 @@ module TaliaCore
24
25
 
25
26
  private
26
27
 
27
- # Little helper method - no need to load the pdf classes unless needed,
28
- # but if called every time round it will slow things down (in Rails it will).
28
+ # Little helper method to load the pdf writer only when needed. This will make sure
29
+ # the thing is loaded only once, otherwise it would be slow in Rails development
30
+ # (which uses #load for #require)
29
31
  def self.activate_pdf
30
32
  return if(@pdf_active)
31
33
  require 'pdf/writer'
32
34
  @pdf_active = true
33
35
  end
34
36
 
37
+ # See PdfData.activate_pdf
35
38
  def activate_pdf
36
39
  self.class.activate_pdf
37
40
  end
@@ -1,18 +1,19 @@
1
1
  require 'talia_core/data_types/file_store'
2
2
 
3
- # Class to manage data stored in a text file
3
+ # File Record that contains a plain text file.
4
4
  module TaliaCore
5
5
  module DataTypes
6
6
 
7
7
  class SimpleText < FileRecord
8
8
 
9
- # return the mime_type for a file
9
+ # The MIME type is always <tt>text/plain</tt>
10
10
  def extract_mime_type(location)
11
11
  'text/plain'
12
12
  end
13
13
 
14
- # Get a line from a text file.
15
- # At the end of file: close the file and return
14
+ # Read onle line from the text file. The file will
15
+ # be closed if the end of the file is hit, or
16
+ # if close_after_single_read is set to true
16
17
  def get_line(close_after_single_read=false)
17
18
  if !is_file_open?
18
19
  open_file
@@ -2,6 +2,8 @@ require 'talia_core/data_types/file_store'
2
2
  require 'rexml/document'
3
3
  # require 'xml/xslt'
4
4
 
5
+ # Little helper to load the "tidy" library, to clean up
6
+ # messy XML/HTML, if possible.
5
7
  begin
6
8
  # if tidy is not present, disable it
7
9
  require 'tidy'
@@ -27,11 +29,14 @@ end
27
29
  module TaliaCore
28
30
  module DataTypes
29
31
 
30
- # Class to manage XML and HTML data type
32
+ # FileRecord class to store XML (or XHTML) files.
31
33
  class XmlData < FileRecord
32
34
 
33
- # return the mime_type for a file
35
+ # MIME type should be one of 'text/html' or 'text/xml'
36
+ # ('text/hnml' is supported for legacy reasons)
34
37
  def extract_mime_type(location)
38
+ # TODO: Could probably use the Mime classes to get the
39
+ # type, or move to the superclass
35
40
  case File.extname(location).downcase
36
41
  when '.htm', '.html','.xhtml'
37
42
  'text/html'
@@ -42,24 +47,29 @@ module TaliaCore
42
47
  end
43
48
  end
44
49
 
45
- # return the mime subtype for this specified class
50
+ # The mime subtype for this specified class
46
51
  def mime_subtype
47
52
  mime_type.split(/\//)[1]
48
53
  end
49
54
 
50
- # return contect of the object as REXML::Elements
51
- # * options: Options for getting context. Default nil.
52
- # * options[:xsl_file]: xsl file path for transformation.
53
- def get_content(options = nil)
55
+ # The content of this document. This returns REXML elements
56
+ # for the document content. For plain XML files, this will
57
+ # return the children of the doucment root. For XHTML documents,
58
+ # this will return the children of the "body" tag.
59
+ #
60
+ # *Options*:
61
+ #
62
+ # * [*xsl_file*] If given, the document will be transformed using this
63
+ # XSL file before the document is extracted
64
+ def get_content(options = {})
65
+ # TODO: Maybe port this to hpricot/nokogiri too
54
66
  text_to_parse = all_text
55
67
 
56
- if (!options.nil?)
57
- # if xsl_file option is specified, execute transformation
58
- if (!options[:xsl_file].nil?)
59
- text_to_parse = xslt_transform(file_path, options[:xsl_file])
60
- end
68
+ # if xsl_file option is specified, execute transformation
69
+ if (options[:xsl_file])
70
+ text_to_parse = xslt_transform(file_path, options[:xsl_file])
61
71
  end
62
-
72
+
63
73
  # create document object
64
74
  document = REXML::Document.new text_to_parse
65
75
 
@@ -78,7 +88,7 @@ module TaliaCore
78
88
  return content
79
89
  end
80
90
 
81
- # Returns an xml string of the elements returned by get_content
91
+ # Same as #get_content, but returns a string instead of the REXML documents
82
92
  def get_content_string(options = nil)
83
93
  xml_str = ''
84
94
  get_content(options).each do |element|
@@ -87,16 +97,26 @@ module TaliaCore
87
97
  xml_str
88
98
  end
89
99
 
90
- # Returns an xml string that is escaped for HTML inclusing
100
+ # Same as #get_content_string, but with the XML escape for inclusion in
101
+ # HTML documents
91
102
  def get_escaped_content_string(options = nil)
92
103
  get_content_string(options).gsub(/</, "&lt;").gsub(/>/, "&gt;")
93
104
  end
94
105
 
95
- # Add data as string into file
96
- # * location: location
97
- # * data: data to write
98
- # * options: options
99
- # * options[:tidy]: enable or disable tidy (convert html into xhtml). Default value is true
106
+ # See the FileStore module for details on how creation of data file objects works.
107
+ # This version differs from the superclass version in that it will (optionally)
108
+ # clean the HTML using the "tidy" tool. Also see http://tidy.rubyforge.org/
109
+ #
110
+ # Tidy will be used under the following circumstances:
111
+ #
112
+ # * The "tidy" option is given and
113
+ # * The library itself is available and
114
+ # * The file appears to be a (X)HTML file
115
+ #
116
+ # *Options:*:
117
+ #
118
+ # [*tidy*] Use the "tidy" tool to clean up (X)HTML. Defaults to true if no options
119
+ # are given.
100
120
  def create_from_data(location, data, options = {:tidy => true})
101
121
  # check tidy option
102
122
  if (((options[:tidy] == true) and (Tidy_enable == true)) and
@@ -118,9 +138,14 @@ module TaliaCore
118
138
  end
119
139
 
120
140
  private
121
- # adjusted/replaced items path
122
- # * item: REXML::Element to parse
141
+
142
+ # Helper that updates the paths in an XML element. Takes a REXML::Element, and updates
143
+ # the paths for "img" and "a" tags to point to the Talia "source_data" controller.
144
+ #
145
+ # This is a quick hack to allow the rendering of HTML that contains those elements and
146
+ # needs to be fixed to show linked files that are stored in Talia.
123
147
  def wrapItem item
148
+ # TODO: Quite hacky. Uses hardcoded paths, maybe should rather be a helper.
124
149
  if item.class == REXML::Element
125
150
  # recursive execution
126
151
  item.each_child { |subItem| wrapItem subItem}
@@ -150,9 +175,12 @@ module TaliaCore
150
175
  end
151
176
  end
152
177
 
153
- # execute xslt transformation
154
- # * document: xml document. Can be file path as string or REXML::Document
155
- # * xsl_file: xsl file for transformation. Can be file path as string or REXML::Document
178
+ # Perform an XSLT transformation
179
+ #
180
+ # *Options*:
181
+ #
182
+ # [*document*] Xml document. Can be file path as string or REXML::Document
183
+ # [*xsl_file*] Xsl file for transformation. Can be file path as string or REXML::Document
156
184
  def xslt_transform(document, xsl_file)
157
185
  xslt = XML::XSLT.new()
158
186
  # get xml document
@@ -9,7 +9,8 @@ module TaliaCore
9
9
  # The problem is that invocations like source.namespace::name are
10
10
  # evaluated to (source.namespace).name
11
11
  # This means that source.namespace must return an object on which
12
- # "name" can be called with the desired effect. This is the "dummy handler"
12
+ # "name" can be called with the desired effect. This object
13
+ # is the "dummy handler"
13
14
  class DummyHandler
14
15
 
15
16
  # Create the new handler
@@ -24,7 +25,7 @@ module TaliaCore
24
25
  # Catch the invocations
25
26
  def method_missing(method, *args)
26
27
  # read value
27
- raise(SemanticNamingError, "Wrong number of arguments") if(args.size != 0)
28
+ raise(ArgumentError, "Wrong number of arguments") if(args.size != 0)
28
29
  @subject[@namespace + method.to_s]
29
30
  end
30
31
 
@@ -1,29 +1,15 @@
1
- # This file contains all the errors that can be raised in the
2
- # Talia core. Since these are not useful classes, they are grouped
3
- # together in one file.
1
+ module TaliaCore
4
2
 
5
- # Indicates that it was tried to create an object with
6
- # an identifier (e.g. an URI) which already exists in the
7
- # system.
8
- class DuplicateIdentifierError < RuntimeError
9
- end
10
-
11
- # Indicates an error during initialization
12
- class SystemInitializationError < RuntimeError
13
- end
14
-
15
- # Indicates an error with the predicate naming
16
- class SemanticNamingError < RuntimeError
17
- end
18
-
19
- # Indicates an attempt to save attributes on an unsaved source
20
- class UnsavedSourceError < RuntimeError
21
- end
22
-
23
- # Indicates an error in a query
24
- class QueryError < RuntimeError
25
- end
26
-
27
- # Indicates an error with import data
28
- class ImportError < RuntimeError
3
+ # Some Excptions/Errors that are specific to the Talia system
4
+ module Errors
5
+
6
+ # Indicates an error during initialization
7
+ class SystemInitializationError < RuntimeError
8
+ end
9
+
10
+ # Indicates an error with import data
11
+ class ImportError < RuntimeError
12
+ end
13
+
14
+ end
29
15
  end
@@ -49,6 +49,46 @@ module TaliaCore
49
49
  # # config file
50
50
  # config['standalone_db'] = "true"
51
51
  # end
52
+ #
53
+ # = Configuration options for <tt>talia_core.yml</tt>
54
+ #
55
+ # [*local_uri*] URL of the current installation. This should be set to
56
+ # the URL where Talia is installed
57
+ # [*rdf_connection_file*] Name of the configuration file that contains the
58
+ # connection parameters for the RDF store.
59
+ # [*rdf_connection*] Used to place the RDF options directly in the configuration
60
+ # file. the *rdf_connection_file* setting will take precedence,
61
+ # though.
62
+ # [*db_file*] File with the database configuration for ActiveRecord. When running
63
+ # from within RAILS, Talia will *always* use the Rails configuration
64
+ # [*db_connection*] Used to place the DB options directly in the file. *db_file*
65
+ # will take precedence, if present
66
+ # [*standalone_db*] If set to true, Talia will be configured to use the ActiveRecord
67
+ # database connection without Rails.
68
+ # [*ardf_log_level*] Used to indicate the log level for the ActiveRDF library (integer value)
69
+ # [*db_log*] Log file for the database/ActiveRecord. Does not take effect if
70
+ # running from inside Rails
71
+ # [*data_directory_location*] Root directory for the FileRecord file storage
72
+ # [*namespaces*] Declares the namespaces that can be used within Talia
73
+ # (a number of "namespace": "url" pairs)
74
+ # [*iip_root_directory_location*] The directory that is used for the pyramidal files
75
+ # that will be served by the IIP server
76
+ # [*iip_server_uri*] The URI to the IIP server. When using the default server, this will
77
+ # be the URL that calls the iipsrv.fcgi
78
+ # [*vips_command*] Path to the "vips" command, which is used to create the pyramidal images
79
+ # [*convert_command*] Path to the "convert" command from ImageMagick, which creates the thumbs
80
+ # [*thumb_options*] Options for thumbnail images. These can contain "height", "width" and the
81
+ # "force" option. If the "force" option is set, the thumbnails will be the
82
+ # exact dimensions given (with a transparent background around the border).
83
+ # Otherwise the aspect ratio of the image will be preserved.
84
+ # [*environment*] The environment for the session, that is "development", "production" or "test".
85
+ # If running from Rails, this will inherit Rails' setting
86
+ # [*standalone_log*] Log file to be used when in standalone mode (not using Rails)
87
+ # [*standalone_log_level*] Log level for the <tt>standalone_log</tt>
88
+ # [*assert*] If true, the <tt>assit</tt> assertions are enabled in the code. Defaults to true.
89
+ # [*auto_ontologies*] If set to a directory, Talia will automatically (re-)load the ontologies
90
+ # from that directory on startup
91
+ # [*site_name*] Site name string. May (or may not) be used in the application.
52
92
  class Initializer
53
93
 
54
94
  # Is used to set the root directory manually. Must be written before
@@ -80,7 +120,7 @@ module TaliaCore
80
120
  # For now, the values are documented in the code below and in the default
81
121
  # configuration file.
82
122
  def run(config_file = nil, &initializer)
83
- raise(SystemInitializationError, "System cannot be initialized twice") if(@@initialized || @@init_started)
123
+ raise(Errors::SystemInitializationError, "System cannot be initialized twice") if(@@initialized || @@init_started)
84
124
 
85
125
  @@init_started = true
86
126
 
@@ -352,10 +392,10 @@ module TaliaCore
352
392
  def load_ontologies
353
393
  return unless(@config['auto_ontologies'] && !['false', 'no'].include?(@config['auto_ontologies'].downcase))
354
394
  onto_dir = File.join(TALIA_ROOT, @config['auto_ontologies'])
355
- raise(SystemInitializationError, "Cannot find configured ontology dir #{onto_dir}") unless(File.directory?(onto_dir))
395
+ raise(Errors::SystemInitializationError, "Cannot find configured ontology dir #{onto_dir}") unless(File.directory?(onto_dir))
356
396
  adapter = ActiveRDF::ConnectionPool.write_adapter
357
- raise(SystemInitializationError, "Ontology autoloading without a context-aware adapter deletes all RDF data. This is only allowed in testing, please load the ontology manually.") unless(adapter.contexts? || (@environment == 'testing'))
358
- raise(SystemInitializationError, "Ontology autoloading requires 'load' capability on the adapter.") unless(adapter.respond_to?(:load))
397
+ raise(Errors::SystemInitializationError, "Ontology autoloading without a context-aware adapter deletes all RDF data. This is only allowed in testing, please load the ontology manually.") unless(adapter.contexts? || (@environment == 'testing'))
398
+ raise(Errors::SystemInitializationError, "Ontology autoloading requires 'load' capability on the adapter.") unless(adapter.respond_to?(:load))
359
399
 
360
400
  # Clear out the RDF
361
401
  if(adapter.contexts?)
@@ -40,13 +40,15 @@ module TaliaCore
40
40
  return select_partial(options[:resumption_token]) if(options[:resumption_token])
41
41
 
42
42
  conditions = sql_conditions(options)
43
-
43
+
44
44
  if(selector == :first)
45
- model_adapter.get_wrapper_for(ActiveSource.find(selector, :prefetch_relations => true, :conditions => conditions))
45
+ #model_adapter.get_wrapper_for(ActiveSource.find(selector, :prefetch_relations => true, :conditions => conditions))
46
+ model_adapter.get_wrapper_for(Source.find(selector, :prefetch_relations => true, :conditions => conditions))
46
47
  elsif(selector == :all)
47
48
  select_partial(OAI::Provider::ResumptionToken.new(last_id(conditions), options.merge(:last => 0)))
48
49
  else
49
- model_adapter.get_wrapper_for(ActiveSource.find(selector, :prefetch_relations => true, :conditions => conditions))
50
+ #model_adapter.get_wrapper_for(ActiveSource.find(selector, :prefetch_relations => true, :conditions => conditions))
51
+ model_adapter.get_wrapper_for(Source.find(selector, :prefetch_relations => true, :conditions => conditions))
50
52
  end
51
53
  rescue ActiveRecord::RecordNotFound
52
54
  nil
@@ -59,11 +61,13 @@ module TaliaCore
59
61
  token = OAI::Provider::ResumptionToken.parse(token) if(token.is_a?(String))
60
62
 
61
63
  conditions = token_conditions(token)
62
- total = ActiveSource.count(:id, :conditions => conditions)
64
+ #total = ActiveSource.count(:id, :conditions => conditions)
65
+ total = Source.count(:id, :conditions => conditions)
63
66
 
64
67
  return [] if(total == 0)
65
68
 
66
- records = ActiveSource.find(:all, :conditions => token_conditions(token),
69
+ #records = ActiveSource.find(:all, :conditions => token_conditions(token),
70
+ records = Source.find(:all, :conditions => token_conditions(token),
67
71
  :limit => @limit,
68
72
  :order => 'id asc',
69
73
  :prefetch_relations => true
@@ -77,7 +81,10 @@ module TaliaCore
77
81
  def select_first_or_last(order, conditions = nil)
78
82
  select_options = { :select => "id, #{timestamp_field}", :order => "#{timestamp_field} #{order}" }
79
83
  select_options[:conditions] = conditions if(conditions)
80
- TaliaCore::ActiveSource.find(:first, select_options)
84
+ #result = TaliaCore::ActiveSource.find(:first, select_options)
85
+ result = TaliaCore::Source.find(:first, select_options)
86
+ raise OAI::NoMatchException if result.nil?
87
+ result
81
88
  end
82
89
 
83
90
  # Sql condition for the given token
@@ -56,17 +56,18 @@ module TaliaCore
56
56
  # Get the author/creator
57
57
  def creator
58
58
  @record[N::DCNS.creator].collect do |creator|
59
- if(creator.is_a?(TaliaCore::ActiveSource))
60
- author = ''
61
- author_name = creator.hyper::author_name.first
62
- author << author_name << ' ' if(author_name)
63
- author_surname = creator.hyper::author_surname.first || ''
64
- author << author_surname if(author_surname)
65
- author = "No lookup. Author should be at #{creator.uri}" if(author == '')
66
- author
67
- else
68
- creator
69
- end
59
+ creator
60
+ # if(creator.is_a?(TaliaCore::ActiveSource))
61
+ # author = ''
62
+ # author_name = creator.hyper::author_name.first
63
+ # author << author_name << ' ' if(author_name)
64
+ # author_surname = creator.hyper::author_surname.first || ''
65
+ # author << author_surname if(author_surname)
66
+ # author = "No lookup. Author should be at #{creator.uri}" if(author == '')
67
+ # author
68
+ # else
69
+ # creator
70
+ # end
70
71
  end
71
72
  end
72
73
 
@@ -89,7 +90,7 @@ module TaliaCore
89
90
  # wrapper class that corresponds to the given record's class
90
91
  def self.get_wrapper_for(records)
91
92
  if(records.is_a?(ActiveSource))
92
- self.new(record)
93
+ self.new(records)
93
94
  elsif(records.respond_to?(:collect))
94
95
  records.collect { |rec| self.new(rec) }
95
96
  elsif(records.nil?)
@@ -27,7 +27,7 @@ module TaliaCore
27
27
  import_file(file, rdf_syntax, context)
28
28
  end
29
29
 
30
- adapter.save if(adapter.respond_to?(:save))
30
+ adapter.try_call.save
31
31
 
32
32
  puts "\n--> Importing rdf/rdfs file: complete!\n\n"
33
33
  end
@@ -29,6 +29,7 @@ module TaliaCore
29
29
 
30
30
  # Initialize a new resource with the given URI
31
31
  def initialize(uri)
32
+ raise ArgumentError, "No blank URI allowed here" if(uri.to_s.blank?)
32
33
  @uri = N::URI.new(uri)
33
34
  end
34
35
 
@@ -73,7 +74,7 @@ module TaliaCore
73
74
  inverseobj.instance_variable_set(:@obj_uri, self)
74
75
  inverseobj.instance_variable_set(:@obj_class, object_class)
75
76
 
76
- class <<inverseobj
77
+ class << inverseobj
77
78
 
78
79
  def [](property)
79
80
  property = N::URI.new(property) unless(property.kind_of?(N::URI))