Skip to content

Commit

Permalink
replace rubydora with (non-thread-safe\!) ActiveFedora/solrizer imple…
Browse files Browse the repository at this point in the history
…mentation
  • Loading branch information
cbeer committed Feb 28, 2013
1 parent 9234e81 commit 4c3c923
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 21 deletions.
25 changes: 22 additions & 3 deletions pom.xml
Expand Up @@ -16,8 +16,17 @@

<repositories>
<repository>
<id>rubygems-release</id>
<id>rubygems-proxy</id>
<name>Rubygems Proxy</name>
<url>http://rubygems-proxy.torquebox.org/releases</url>
<layout>default</layout>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>fale</enabled>
<updatePolicy>never</updatePolicy>
</snapshots>
</repository>
</repositories>

Expand Down Expand Up @@ -183,8 +192,8 @@

<dependency>
<groupId>rubygems</groupId>
<artifactId>rubydora</artifactId>
<version>1.4.0</version>
<artifactId>active-fedora</artifactId>
<version>5.6.2</version>
<type>gem</type>

<scope>test</scope>
Expand Down Expand Up @@ -219,6 +228,16 @@
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.11</version>
<configuration>
<argLine>-Xms512m -Xmx512m -XX:MaxPermSize=256m</argLine>
<includes>
<include>**/*.java</include>
</includes>
</configuration>
</plugin>
<plugin>
<groupId>de.saumya.mojo</groupId>
<artifactId>gem-maven-plugin</artifactId>
Expand Down
57 changes: 43 additions & 14 deletions src/main/ruby/demo_ruby_solr_indexer.rb
@@ -1,28 +1,57 @@
require 'java'
require 'loggable'
require 'rubydora'
require 'rubygems'
require 'active_fedora'

java_package 'org.fcrepo.indexer.solr'

class DemoRubySolrIndexer
include org.fcrepo.indexer.solr.ScriptIndexer


class TestConfigurator
attr_reader :fedora_config, :solr_config, :predicate_config

def init(options = {})
@fedora_config = options[:fedora_config]
@solr_config = options[:solr_config]
@predicate_config = options[:predicate_config]
end
end

def indexObject profile, pid, solr_document

solr_document.addField("__org.fcrepo.indexer.solr.class__", self.class.name);

repo = Rubydora.connect :url => profile.repository_url
@config_params = {
:fedora_config => { :url => profile.repository_url },
:solr_config => { :url => profile.repository_url },
:predicate_config => {
:default_namespace => 'info:fedora/fedora-system:def/relations-external#',
:predicate_mapping => {
'info:fedora/fedora-system:def/relations-external#' => { :has_part => 'hasPart' }
}
}
}

ActiveFedora.configurator = DemoRubySolrIndexer::TestConfigurator.new
ActiveFedora.init @config_params

begin
obj = ActiveFedora::Base.find(pid)
rescue ActiveFedora::ObjectNotFoundError
return
end

obj.to_solr.each do |key, values|
next if key == :id
Array(values).each do |v|
solr_document.add_field(key.to_s, v.to_s)
end
end

obj = repo.find(pid)
end

return if obj.new?

obj.profile.each do |key, values|
Array(values).each do |v|
solr_document.add_field(key, v)
end
end


end
end


end
Expand Up @@ -147,10 +147,7 @@ public void testIntegrationScriptingSolrIndexer() throws JMSException,
SolrInputDocument doc = new SolrInputDocument();
doc.addField("id", "IndexingIntegrationTestObject1");
doc.addField("__org.fcrepo.indexer.solr.class__", "DemoRubySolrIndexer");
doc.addField("objOwnerId", "<anonymous>");
doc.addField("objState", "A");
doc.addField("objSize", "393");

doc.addField("active_fedora_model_s", "ActiveFedora::Base");
verify(s, timeout(5000)).add(argThat(new MatchesSolrDocument(doc)));
}

Expand Down

0 comments on commit 4c3c923

Please sign in to comment.