talia_core 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (119) hide show
  1. data/README.rdoc +41 -0
  2. data/bin/talia +33 -0
  3. data/lib/JXslt/jxslt.rb +60 -0
  4. data/lib/acts_as_roled.rb +11 -0
  5. data/lib/core_ext/platform.rb +9 -0
  6. data/lib/core_ext/string.rb +6 -0
  7. data/lib/core_ext.rb +1 -0
  8. data/lib/custom_template.rb +4 -0
  9. data/lib/loader_helper.rb +62 -0
  10. data/lib/mysql.rb +1214 -0
  11. data/lib/progressbar.rb +236 -0
  12. data/lib/role.rb +12 -0
  13. data/lib/talia_cl/command_line.rb +39 -0
  14. data/lib/talia_cl/commands/standalone/cl_options.rb +9 -0
  15. data/lib/talia_cl/commands/standalone/standalone_generate.rb +75 -0
  16. data/lib/talia_cl/commands/standalone.rb +25 -0
  17. data/lib/talia_cl/commands/talia_console/cl_options.rb +55 -0
  18. data/lib/talia_cl/commands/talia_console/console_commands.rb +37 -0
  19. data/lib/talia_cl/commands/talia_console/talia_commands.rb +131 -0
  20. data/lib/talia_cl/commands/talia_console.rb +47 -0
  21. data/lib/talia_cl/core_commands.rb +11 -0
  22. data/lib/talia_cl.rb +47 -0
  23. data/lib/talia_core/active_source.rb +372 -0
  24. data/lib/talia_core/active_source_parts/class_methods.rb +378 -0
  25. data/lib/talia_core/active_source_parts/predicate_handler.rb +89 -0
  26. data/lib/talia_core/active_source_parts/rdf.rb +131 -0
  27. data/lib/talia_core/active_source_parts/sql_helper.rb +36 -0
  28. data/lib/talia_core/active_source_parts/xml/base_builder.rb +47 -0
  29. data/lib/talia_core/active_source_parts/xml/generic_reader.rb +363 -0
  30. data/lib/talia_core/active_source_parts/xml/rdf_builder.rb +88 -0
  31. data/lib/talia_core/active_source_parts/xml/source_builder.rb +73 -0
  32. data/lib/talia_core/active_source_parts/xml/source_reader.rb +20 -0
  33. data/lib/talia_core/agent.rb +14 -0
  34. data/lib/talia_core/background_jobs/job.rb +82 -0
  35. data/lib/talia_core/background_jobs/progress_job.rb +68 -0
  36. data/lib/talia_core/collection.rb +13 -0
  37. data/lib/talia_core/data_types/data_loader.rb +92 -0
  38. data/lib/talia_core/data_types/data_record.rb +105 -0
  39. data/lib/talia_core/data_types/delayed_copier.rb +76 -0
  40. data/lib/talia_core/data_types/file_record.rb +59 -0
  41. data/lib/talia_core/data_types/file_store.rb +306 -0
  42. data/lib/talia_core/data_types/iip_data.rb +153 -0
  43. data/lib/talia_core/data_types/iip_loader.rb +127 -0
  44. data/lib/talia_core/data_types/image_data.rb +32 -0
  45. data/lib/talia_core/data_types/media_link.rb +19 -0
  46. data/lib/talia_core/data_types/mime_mapping.rb +45 -0
  47. data/lib/talia_core/data_types/path_helpers.rb +77 -0
  48. data/lib/talia_core/data_types/pdf_data.rb +42 -0
  49. data/lib/talia_core/data_types/simple_text.rb +36 -0
  50. data/lib/talia_core/data_types/temp_file_handling.rb +85 -0
  51. data/lib/talia_core/data_types/xml_data.rb +169 -0
  52. data/lib/talia_core/dc_resource.rb +20 -0
  53. data/lib/talia_core/dummy_handler.rb +34 -0
  54. data/lib/talia_core/dummy_source.rb +20 -0
  55. data/lib/talia_core/errors.rb +25 -0
  56. data/lib/talia_core/initializer.rb +427 -0
  57. data/lib/talia_core/ordered_source.rb +228 -0
  58. data/lib/talia_core/rails_ext/actionpack/action_controller/record_identifier.rb +13 -0
  59. data/lib/talia_core/rails_ext/actionpack/action_controller.rb +1 -0
  60. data/lib/talia_core/rails_ext/actionpack.rb +1 -0
  61. data/lib/talia_core/rails_ext.rb +1 -0
  62. data/lib/talia_core/rdf_import.rb +90 -0
  63. data/lib/talia_core/rdf_resource.rb +159 -0
  64. data/lib/talia_core/semantic_collection_item.rb +93 -0
  65. data/lib/talia_core/semantic_collection_wrapper.rb +324 -0
  66. data/lib/talia_core/semantic_property.rb +7 -0
  67. data/lib/talia_core/semantic_relation.rb +67 -0
  68. data/lib/talia_core/source.rb +323 -0
  69. data/lib/talia_core/source_transfer_object.rb +38 -0
  70. data/lib/talia_core/workflow/base.rb +15 -0
  71. data/lib/talia_core/workflow/publication_workflow.rb +62 -0
  72. data/lib/talia_core/workflow.rb +300 -0
  73. data/lib/talia_core.rb +9 -0
  74. data/lib/talia_dependencies.rb +12 -0
  75. data/lib/talia_util/bar_progressor.rb +15 -0
  76. data/lib/talia_util/configuration/config_file.rb +48 -0
  77. data/lib/talia_util/configuration/database_config.rb +40 -0
  78. data/lib/talia_util/configuration/mysql_database_setup.rb +104 -0
  79. data/lib/talia_util/data_import.rb +91 -0
  80. data/lib/talia_util/image_conversions.rb +82 -0
  81. data/lib/talia_util/import_job_helper.rb +132 -0
  82. data/lib/talia_util/io_helper.rb +54 -0
  83. data/lib/talia_util/progressable.rb +38 -0
  84. data/lib/talia_util/progressbar.rb +236 -0
  85. data/lib/talia_util/rdf_update.rb +80 -0
  86. data/lib/talia_util/some_sigla.xml +1960 -0
  87. data/lib/talia_util/test_helpers.rb +151 -0
  88. data/lib/talia_util/util.rb +226 -0
  89. data/lib/talia_util/yaml_import.rb +80 -0
  90. data/lib/talia_util.rb +13 -0
  91. data/lib/user.rb +116 -0
  92. data/lib/version.rb +15 -0
  93. data/test/core_ext/string_test.rb +11 -0
  94. data/test/custom_template_test.rb +8 -0
  95. data/test/talia_core/active_source_predicate_test.rb +54 -0
  96. data/test/talia_core/active_source_rdf_test.rb +89 -0
  97. data/test/talia_core/active_source_test.rb +631 -0
  98. data/test/talia_core/data_types/data_loader_test.rb +123 -0
  99. data/test/talia_core/data_types/data_record_test.rb +40 -0
  100. data/test/talia_core/data_types/file_record_test.rb +171 -0
  101. data/test/talia_core/data_types/iip_data_test.rb +130 -0
  102. data/test/talia_core/data_types/image_data_test.rb +88 -0
  103. data/test/talia_core/data_types/pdf_data_test.rb +68 -0
  104. data/test/talia_core/data_types/xml_data_test.rb +134 -0
  105. data/test/talia_core/generic_xml_test.rb +83 -0
  106. data/test/talia_core/initializer_test.rb +36 -0
  107. data/test/talia_core/ordered_source_test.rb +398 -0
  108. data/test/talia_core/rdf_resource_test.rb +115 -0
  109. data/test/talia_core/semantic_collection_item_test.rb +129 -0
  110. data/test/talia_core/source_reader_test.rb +33 -0
  111. data/test/talia_core/source_test.rb +484 -0
  112. data/test/talia_core/source_transfer_object_test.rb +24 -0
  113. data/test/talia_core/workflow/publication_workflow_test.rb +242 -0
  114. data/test/talia_core/workflow/user_class_for_workflow.rb +35 -0
  115. data/test/talia_core/workflow/workflow_base_test.rb +21 -0
  116. data/test/talia_core/workflow_test.rb +19 -0
  117. data/test/talia_util/import_job_helper_test.rb +46 -0
  118. data/test/test_helper.rb +68 -0
  119. metadata +262 -0
@@ -0,0 +1,89 @@
1
+ # Load the helper class
2
+ require File.join(File.dirname(__FILE__), '..', 'test_helper')
3
+
4
+ module TaliaCore
5
+
6
+ # Test the ActiveSource
7
+ class ActiveSourceRdfTest < Test::Unit::TestCase
8
+ fixtures :active_sources, :semantic_properties, :semantic_relations
9
+
10
+ def setup
11
+ setup_once(:rdf_res) do
12
+ TaliaUtil::Util.flush_rdf
13
+ active_sources(:multirel).send(:create_rdf, :force) # Update the rdf
14
+ active_sources(:multirel).my_rdf
15
+ end
16
+ end
17
+
18
+ def test_direct_predicates
19
+ assert_equal(3, @rdf_res.direct_predicates.size, "Elements #{@rdf_res.direct_predicates}")
20
+ end
21
+
22
+ def test_accessor
23
+ props = @rdf_res['http://testvalue.org/multirel']
24
+ assert_equal(3, props.size)
25
+ assert(props.include?(active_sources(:testy)))
26
+ assert(props.include?(semantic_properties(:other_value).value), "Actually contains #{props}")
27
+ end
28
+
29
+ def test_rel_remove
30
+ src = ActiveSource.new('http://as_test/rel_remover')
31
+ src[N::RDF.rew] << 'value'
32
+ src.save!
33
+ # Test that there is 1 element now
34
+ assert_equal(1, (vals = SemanticRelation.find(:all, :conditions => {'subject_id' => src.id })).size, "Expected 1 value, got [#{print_rels(vals)}]")
35
+ assert_equal(1, src.semantic_relations.size)
36
+ # Test if the element can be removed
37
+ src[N::RDF.rew].remove
38
+ assert_equal(0, (vals = SemanticRelation.find(:all, :conditions => {'subject_id' => src.id })).size, "Expected 0 values, got [#{print_rels(vals)}]")
39
+ assert_equal(0, src[N::RDF.rew].size)
40
+ end
41
+
42
+ def test_rdf_remove
43
+ src = ActiveSource.new('http://as_test/rdf_remove')
44
+ src[N::RDF.rew] << 'value'
45
+ src.save!
46
+ assert_equal(1, src.my_rdf[N::RDF.rew].size)
47
+ src[N::RDF.rew].remove
48
+ src.save!
49
+ assert_equal(0, src.my_rdf[N::RDF.rew].size)
50
+ end
51
+
52
+ def test_rdf_rewrite
53
+ src = ActiveSource.new('http://as_test/rdf_rewrite')
54
+ src[N::RDF.rew] << 'value'
55
+ src.save!
56
+ assert_equal(1, src.my_rdf[N::RDF.rew].size)
57
+ src[N::RDF.rew].remove
58
+ src[N::RDF.rew] << 'new value'
59
+ assert(1, src[N::RDF.rew].size)
60
+ src.save!
61
+ assert_equal(1, src.my_rdf[N::RDF.rew].size)
62
+ end
63
+
64
+ def test_rdf_staggered_save
65
+ src = ActiveSource.new('http://as_test/rdf_saving_test_advanced')
66
+ src[N::RDF.rew] << 'foo'
67
+ src.save!
68
+ src[N::RDF.rew] << 'bar'
69
+ src.save!
70
+ res = ActiveSource.find(src.uri)
71
+ assert_property(res[N::RDF.rew], 'foo', 'bar')
72
+ assert_equal(['foo', 'bar'], res.my_rdf[N::RDF.rew])
73
+ end
74
+
75
+ def test_rdf_on_rewrite
76
+ src = ActiveSource.new('http://asrdf_test/test_update_rdf_rewrite')
77
+ src[N::RDF.something] << 'value1'
78
+ src.rewrite_attributes!('rdf:something' => ['value2', 'value3'])
79
+ assert_equal(src.my_rdf[N::RDF.something], [ 'value2', 'value3' ])
80
+ end
81
+
82
+ protected
83
+
84
+ def print_rels(relations)
85
+ relations.collect { |relation| "<#{relation.subject.uri} - #{relation.predicate_uri} - #{relation.object.is_a?(ActiveSource) ? relation.object.uri : relation.object.value}> | " }
86
+ end
87
+
88
+ end
89
+ end