talia_core 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +41 -0
- data/bin/talia +33 -0
- data/lib/JXslt/jxslt.rb +60 -0
- data/lib/acts_as_roled.rb +11 -0
- data/lib/core_ext/platform.rb +9 -0
- data/lib/core_ext/string.rb +6 -0
- data/lib/core_ext.rb +1 -0
- data/lib/custom_template.rb +4 -0
- data/lib/loader_helper.rb +62 -0
- data/lib/mysql.rb +1214 -0
- data/lib/progressbar.rb +236 -0
- data/lib/role.rb +12 -0
- data/lib/talia_cl/command_line.rb +39 -0
- data/lib/talia_cl/commands/standalone/cl_options.rb +9 -0
- data/lib/talia_cl/commands/standalone/standalone_generate.rb +75 -0
- data/lib/talia_cl/commands/standalone.rb +25 -0
- data/lib/talia_cl/commands/talia_console/cl_options.rb +55 -0
- data/lib/talia_cl/commands/talia_console/console_commands.rb +37 -0
- data/lib/talia_cl/commands/talia_console/talia_commands.rb +131 -0
- data/lib/talia_cl/commands/talia_console.rb +47 -0
- data/lib/talia_cl/core_commands.rb +11 -0
- data/lib/talia_cl.rb +47 -0
- data/lib/talia_core/active_source.rb +372 -0
- data/lib/talia_core/active_source_parts/class_methods.rb +378 -0
- data/lib/talia_core/active_source_parts/predicate_handler.rb +89 -0
- data/lib/talia_core/active_source_parts/rdf.rb +131 -0
- data/lib/talia_core/active_source_parts/sql_helper.rb +36 -0
- data/lib/talia_core/active_source_parts/xml/base_builder.rb +47 -0
- data/lib/talia_core/active_source_parts/xml/generic_reader.rb +363 -0
- data/lib/talia_core/active_source_parts/xml/rdf_builder.rb +88 -0
- data/lib/talia_core/active_source_parts/xml/source_builder.rb +73 -0
- data/lib/talia_core/active_source_parts/xml/source_reader.rb +20 -0
- data/lib/talia_core/agent.rb +14 -0
- data/lib/talia_core/background_jobs/job.rb +82 -0
- data/lib/talia_core/background_jobs/progress_job.rb +68 -0
- data/lib/talia_core/collection.rb +13 -0
- data/lib/talia_core/data_types/data_loader.rb +92 -0
- data/lib/talia_core/data_types/data_record.rb +105 -0
- data/lib/talia_core/data_types/delayed_copier.rb +76 -0
- data/lib/talia_core/data_types/file_record.rb +59 -0
- data/lib/talia_core/data_types/file_store.rb +306 -0
- data/lib/talia_core/data_types/iip_data.rb +153 -0
- data/lib/talia_core/data_types/iip_loader.rb +127 -0
- data/lib/talia_core/data_types/image_data.rb +32 -0
- data/lib/talia_core/data_types/media_link.rb +19 -0
- data/lib/talia_core/data_types/mime_mapping.rb +45 -0
- data/lib/talia_core/data_types/path_helpers.rb +77 -0
- data/lib/talia_core/data_types/pdf_data.rb +42 -0
- data/lib/talia_core/data_types/simple_text.rb +36 -0
- data/lib/talia_core/data_types/temp_file_handling.rb +85 -0
- data/lib/talia_core/data_types/xml_data.rb +169 -0
- data/lib/talia_core/dc_resource.rb +20 -0
- data/lib/talia_core/dummy_handler.rb +34 -0
- data/lib/talia_core/dummy_source.rb +20 -0
- data/lib/talia_core/errors.rb +25 -0
- data/lib/talia_core/initializer.rb +427 -0
- data/lib/talia_core/ordered_source.rb +228 -0
- data/lib/talia_core/rails_ext/actionpack/action_controller/record_identifier.rb +13 -0
- data/lib/talia_core/rails_ext/actionpack/action_controller.rb +1 -0
- data/lib/talia_core/rails_ext/actionpack.rb +1 -0
- data/lib/talia_core/rails_ext.rb +1 -0
- data/lib/talia_core/rdf_import.rb +90 -0
- data/lib/talia_core/rdf_resource.rb +159 -0
- data/lib/talia_core/semantic_collection_item.rb +93 -0
- data/lib/talia_core/semantic_collection_wrapper.rb +324 -0
- data/lib/talia_core/semantic_property.rb +7 -0
- data/lib/talia_core/semantic_relation.rb +67 -0
- data/lib/talia_core/source.rb +323 -0
- data/lib/talia_core/source_transfer_object.rb +38 -0
- data/lib/talia_core/workflow/base.rb +15 -0
- data/lib/talia_core/workflow/publication_workflow.rb +62 -0
- data/lib/talia_core/workflow.rb +300 -0
- data/lib/talia_core.rb +9 -0
- data/lib/talia_dependencies.rb +12 -0
- data/lib/talia_util/bar_progressor.rb +15 -0
- data/lib/talia_util/configuration/config_file.rb +48 -0
- data/lib/talia_util/configuration/database_config.rb +40 -0
- data/lib/talia_util/configuration/mysql_database_setup.rb +104 -0
- data/lib/talia_util/data_import.rb +91 -0
- data/lib/talia_util/image_conversions.rb +82 -0
- data/lib/talia_util/import_job_helper.rb +132 -0
- data/lib/talia_util/io_helper.rb +54 -0
- data/lib/talia_util/progressable.rb +38 -0
- data/lib/talia_util/progressbar.rb +236 -0
- data/lib/talia_util/rdf_update.rb +80 -0
- data/lib/talia_util/some_sigla.xml +1960 -0
- data/lib/talia_util/test_helpers.rb +151 -0
- data/lib/talia_util/util.rb +226 -0
- data/lib/talia_util/yaml_import.rb +80 -0
- data/lib/talia_util.rb +13 -0
- data/lib/user.rb +116 -0
- data/lib/version.rb +15 -0
- data/test/core_ext/string_test.rb +11 -0
- data/test/custom_template_test.rb +8 -0
- data/test/talia_core/active_source_predicate_test.rb +54 -0
- data/test/talia_core/active_source_rdf_test.rb +89 -0
- data/test/talia_core/active_source_test.rb +631 -0
- data/test/talia_core/data_types/data_loader_test.rb +123 -0
- data/test/talia_core/data_types/data_record_test.rb +40 -0
- data/test/talia_core/data_types/file_record_test.rb +171 -0
- data/test/talia_core/data_types/iip_data_test.rb +130 -0
- data/test/talia_core/data_types/image_data_test.rb +88 -0
- data/test/talia_core/data_types/pdf_data_test.rb +68 -0
- data/test/talia_core/data_types/xml_data_test.rb +134 -0
- data/test/talia_core/generic_xml_test.rb +83 -0
- data/test/talia_core/initializer_test.rb +36 -0
- data/test/talia_core/ordered_source_test.rb +398 -0
- data/test/talia_core/rdf_resource_test.rb +115 -0
- data/test/talia_core/semantic_collection_item_test.rb +129 -0
- data/test/talia_core/source_reader_test.rb +33 -0
- data/test/talia_core/source_test.rb +484 -0
- data/test/talia_core/source_transfer_object_test.rb +24 -0
- data/test/talia_core/workflow/publication_workflow_test.rb +242 -0
- data/test/talia_core/workflow/user_class_for_workflow.rb +35 -0
- data/test/talia_core/workflow/workflow_base_test.rb +21 -0
- data/test/talia_core/workflow_test.rb +19 -0
- data/test/talia_util/import_job_helper_test.rb +46 -0
- data/test/test_helper.rb +68 -0
- metadata +262 -0
data/README.rdoc
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
= TaliaCore
|
2
|
+
|
3
|
+
This is the "core" of the Talia semantic digital web library system. Talia can
|
4
|
+
be used with Ruby on Rails, or as a standalone package.
|
5
|
+
|
6
|
+
More documentation can be found on the Talia website:
|
7
|
+
http:///trac.talia.discovery-project.eu/
|
8
|
+
|
9
|
+
The RDoc documentation may be created directly from the sources, or you can find
|
10
|
+
it at http://net7.github.com/talia_core/
|
11
|
+
|
12
|
+
= Installation
|
13
|
+
|
14
|
+
If you have the Talia files on your sytem, you're almost there. For now,
|
15
|
+
please consult the web page for installation instructions.
|
16
|
+
|
17
|
+
= Configuration
|
18
|
+
|
19
|
+
When you're in Rails, you can start Talia in the environment.rb, using the
|
20
|
+
TaliaCore::Initializer - if you're building a standalone application, it's
|
21
|
+
almost the same (although you'll have to use standalone_db=yes to configure
|
22
|
+
ActiveRecord manually)
|
23
|
+
|
24
|
+
There are some sample configuration files in the distribution:
|
25
|
+
|
26
|
+
* talia_core.yml - This file contains the main configuration.
|
27
|
+
* database.yml - Standalon Db configuration. Same format as for Rails.
|
28
|
+
* rdfstore.yml - RDF storage configuration.
|
29
|
+
|
30
|
+
The default configuration (talia_core.yml) will use the database.yml and
|
31
|
+
rdfstore.yml to configure the data storage. See the example filme for an
|
32
|
+
explanation of the options. The database configuration will only be used if
|
33
|
+
you are running Talia standalone; otherwise you must use RAILS' existing
|
34
|
+
database connection.
|
35
|
+
|
36
|
+
The options for the RDF store vary depending on the store that you have selected,
|
37
|
+
but some examples are provideed.
|
38
|
+
|
39
|
+
= DB Migrations
|
40
|
+
|
41
|
+
= Importing data
|
data/bin/talia
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# -*- Ruby -*-
|
3
|
+
|
4
|
+
# Talia command line tool
|
5
|
+
# Helper for local requires
|
6
|
+
def local_requires
|
7
|
+
require "talia_cl"
|
8
|
+
end
|
9
|
+
|
10
|
+
# Little helper for running the command line in development mode/without gem
|
11
|
+
# installed. If the
|
12
|
+
begin
|
13
|
+
local_requires
|
14
|
+
rescue LoadError
|
15
|
+
puts "Talia gem does not seem to be installed, trying fallback locations."
|
16
|
+
lib_path_local = File.expand_path(File.join(".", "lib"))
|
17
|
+
lib_path_rails = File.expand_path(File.join(".", "vendor", "plugins", "talia_core", "lib"))
|
18
|
+
if(FileTest.exists?(File.join(lib_path_local, "talia_cl.rb")))
|
19
|
+
puts "...seems to be the local talia directory. Using local config."
|
20
|
+
$: << lib_path_local
|
21
|
+
local_requires
|
22
|
+
elsif(FileTest.exists?(File.join(lib_path_rails, "talia_cl.rb")))
|
23
|
+
puts "... seems to be a rails installation with talia. Using Rails config."
|
24
|
+
$: << lib_path_rails
|
25
|
+
$: << lib_path_local # Also put the path to the "local" rails-specific stuff
|
26
|
+
local_requires
|
27
|
+
else
|
28
|
+
puts "No Talia installation found. Try to run this within the Talia root dir."
|
29
|
+
raise LoadError, "Talia installation not found."
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
run_command_line
|
data/lib/JXslt/jxslt.rb
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
include Java if jruby?
|
2
|
+
module JXslt
|
3
|
+
Dir["#{RAILS_ROOT}/lib/saxon*.jar"].each { |jar| require jar }
|
4
|
+
include_class "javax.xml.transform.TransformerFactory"
|
5
|
+
include_class "javax.xml.transform.Transformer"
|
6
|
+
include_class "javax.xml.transform.stream.StreamSource"
|
7
|
+
include_class "javax.xml.transform.stream.StreamResult"
|
8
|
+
include_class "java.lang.System"
|
9
|
+
|
10
|
+
class XsltProcessor
|
11
|
+
|
12
|
+
puts $CLASSPATH
|
13
|
+
|
14
|
+
|
15
|
+
def transform(xslt, infile, outfile, options)
|
16
|
+
if options[:in] == "stream"
|
17
|
+
in_var = StreamSource.new(infile)
|
18
|
+
else
|
19
|
+
sr = java.io.StringReader.new(infile)
|
20
|
+
in_var = StreamSource.new(sr)
|
21
|
+
end
|
22
|
+
if options[:out] == "stream"
|
23
|
+
out_var = StreamResult.new(outfile)
|
24
|
+
else
|
25
|
+
sw = java.io.StringWriter.new()
|
26
|
+
out_var = StreamResult.new(sw)
|
27
|
+
end
|
28
|
+
if options[:xslt] == "stream"
|
29
|
+
xslt_var = StreamSource.new(xslt)
|
30
|
+
else
|
31
|
+
sxs = java.io.StringReader.new(xslt)
|
32
|
+
xslt_var = StreamSource.new(sxs)
|
33
|
+
end
|
34
|
+
transformer = @tf.newTransformer(xslt_var)
|
35
|
+
unless options[:transformer_parameters].nil?
|
36
|
+
options[:transformer_parameters].each do |key, value|
|
37
|
+
transformer.setParameter(key, java.lang.String.new(value))
|
38
|
+
end
|
39
|
+
end
|
40
|
+
transformer.transform(in_var, out_var)
|
41
|
+
if options[:out] != "stream"
|
42
|
+
outfile = sw.toString()
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end # XsltProcessor
|
46
|
+
class Saxon < XsltProcessor
|
47
|
+
TRANSFORMER_FACTORY_IMPL = "net.sf.saxon.TransformerFactoryImpl"
|
48
|
+
def initialize
|
49
|
+
System.setProperty("javax.xml.transform.TransformerFactory", TRANSFORMER_FACTORY_IMPL)
|
50
|
+
@tf = TransformerFactory.newInstance
|
51
|
+
end
|
52
|
+
end
|
53
|
+
class Xalan < XsltProcessor
|
54
|
+
TRANSFORMER_FACTORY_IMPL = "org.apache.xalan.processor.TransformerFactoryImpl"
|
55
|
+
def initialize
|
56
|
+
System.setProperty("javax.xml.transform.TransformerFactory", TRANSFORMER_FACTORY_IMPL)
|
57
|
+
@tf = TransformerFactory.newInstance
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end if jruby?
|
data/lib/core_ext.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
Dir['lib/core_ext/**/*.rb'].each{|f| require f}
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
|
3
|
+
# Some helpers for the Talia bootstrapping (when the module is loaded)
|
4
|
+
module TLoad
|
5
|
+
|
6
|
+
# This tries to load the the given module.
|
7
|
+
# It first attempts to load from local_path/lib/local_name
|
8
|
+
# The local path is always appended to the directory of the script
|
9
|
+
# currently running.
|
10
|
+
# If that fails, it tries to load the given gem
|
11
|
+
def self.require_module(gem_name, local_name, local_path, gem_version = nil)
|
12
|
+
begin
|
13
|
+
# Try to loaTad from local if it exists
|
14
|
+
search_dir = File.expand_path(File.join(File.dirname(__FILE__), local_path, "lib"))
|
15
|
+
if(File.exists?(search_dir))
|
16
|
+
$:.unshift(search_dir)
|
17
|
+
require local_name
|
18
|
+
else
|
19
|
+
load_from_gem(gem_name, local_name, gem_version)
|
20
|
+
end
|
21
|
+
rescue LoadError
|
22
|
+
load_from_gem(gem_name, local_name, gem_version)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.start_dir
|
27
|
+
@start_dir ||= begin
|
28
|
+
# adding talia_core subdirectory to the ruby loadpath
|
29
|
+
file = File.symlink?(__FILE__) ? File.readlink(__FILE__) : __FILE__
|
30
|
+
this_dir = File.dirname(File.expand_path(file))
|
31
|
+
$: << this_dir
|
32
|
+
$: << this_dir + '/talia_core/'
|
33
|
+
this_dir
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
# Forces the loading of the parts of the rails framework that are used
|
38
|
+
# by Talia
|
39
|
+
def self.force_rails_parts
|
40
|
+
require_module("activerecord", "active_record", "/../../../rails/activerecord", RAILS_GEM_VERSION) unless(defined?(ActiveRecord))
|
41
|
+
require_module("activesupport", "active_support", "/../../../rails/activesupport", RAILS_GEM_VERSION) unless(defined?(ActiveSupport))
|
42
|
+
require_module("actionpack", "action_controller", "/../../../rails/actionpack", RAILS_GEM_VERSION)
|
43
|
+
# This sets the automatic loader path for Talia, allowing the ActiveSupport
|
44
|
+
# classes to automatically load classes from this directory.
|
45
|
+
ActiveSupport::Dependencies.load_paths << TLoad.start_dir unless(ActiveSupport::Dependencies.load_paths.include?(TLoad.start_dir))
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
def self.load_from_gem(gem_name, local_name, gem_version)
|
51
|
+
if gem_version
|
52
|
+
gem gem_name, gem_version
|
53
|
+
else
|
54
|
+
gem gem_name
|
55
|
+
end
|
56
|
+
|
57
|
+
require local_name
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
|
62
|
+
TLoad.start_dir # Load the paths and start directory
|