Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
use rubydora in the jruby indexer script.
  • Loading branch information
cbeer committed Feb 27, 2013
1 parent dcb6295 commit 9234e81
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 4 deletions.
45 changes: 45 additions & 0 deletions pom.xml
Expand Up @@ -14,6 +14,12 @@
<version>4.0-SNAPSHOT</version>
</parent>

<repositories>
<repository>
<id>rubygems-release</id>
<url>http://rubygems-proxy.torquebox.org/releases</url>
</repository>
</repositories>

<properties>

Expand Down Expand Up @@ -174,6 +180,31 @@
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-rs-extension-providers</artifactId>
</dependency>

<dependency>
<groupId>rubygems</groupId>
<artifactId>rubydora</artifactId>
<version>1.4.0</version>
<type>gem</type>

<scope>test</scope>
</dependency>


<dependency>
<groupId>rubygems</groupId>
<artifactId>mediashelf-loggable</artifactId>
<version>0.4.9</version>
<type>gem</type>

<scope>test</scope>
</dependency>
<dependency>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
<version>2.10.0</version>
</dependency>

</dependencies>

<build>
Expand All @@ -187,6 +218,20 @@
<directory>src/main/ruby</directory>
</resource>
</resources>
<plugins>
<plugin>
<groupId>de.saumya.mojo</groupId>
<artifactId>gem-maven-plugin</artifactId>
<version>0.29.1</version>
<executions>
<execution>
<goals>
<goal>initialize</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>
17 changes: 17 additions & 0 deletions src/main/ruby/demo_ruby_solr_indexer.rb
@@ -1,11 +1,28 @@
require 'java'
require 'loggable'
require 'rubydora'

java_package 'org.fcrepo.indexer.solr'

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

def indexObject profile, pid, solr_document

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

repo = Rubydora.connect :url => profile.repository_url

obj = repo.find(pid)

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
Expand Up @@ -75,7 +75,7 @@ public class DemoRubySolrIndexerTest {
@Inject
private ActiveMQConnectionFactory connectionFactory;

private static String TEST_PID = "changeme:1001";
private static String TEST_PID = "changeme_1001";

@Inject
private ScriptingSolrIndexer indexer;
Expand Down Expand Up @@ -147,6 +147,9 @@ 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");

verify(s, timeout(5000)).add(argThat(new MatchesSolrDocument(doc)));
}
Expand Down Expand Up @@ -181,8 +184,10 @@ public boolean matches(final Object o) {
new Predicate<SolrInputField>() {

public boolean apply(SolrInputField f) {
return ((SolrInputDocument) o)
.getField(f.getName()).getValues()
SolrInputDocument test_doc = ((SolrInputDocument) o);

return test_doc.getField(f.getName()) != null &&
test_doc.getField(f.getName()).getValues()
.containsAll(f.getValues());
}
});
Expand Down
2 changes: 1 addition & 1 deletion src/test/resources/spring-test/solr-indexer.xml
Expand Up @@ -21,7 +21,7 @@
</bean>

<bean class="org.fcrepo.indexer.RepositoryProfile">
<property name="repositoryURL" value="http://localhost:8080/rest" />
<property name="repositoryURL" value="http://localhost:${test.port:8080}/rest" />
</bean>

<lang:jruby id="rubyScriptClass" script-interfaces="org.fcrepo.indexer.solr.ScriptIndexer" script-source="classpath:demo_ruby_solr_indexer.rb" />
Expand Down

0 comments on commit 9234e81

Please sign in to comment.