Author: navssurtani
Date: 2008-06-10 05:13:33 -0400 (Tue, 10 Jun 2008)
New Revision: 5965
Modified:
searchable/trunk/src/main/java/org/jboss/cache/search/QueryResultImpl.java
searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheFactory.java
searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheImpl.java
searchable/trunk/src/main/java/org/jboss/cache/search/SearchableListener.java
Log:
Started working on adding Work objects to queue
Modified: searchable/trunk/src/main/java/org/jboss/cache/search/QueryResultImpl.java
===================================================================
--- searchable/trunk/src/main/java/org/jboss/cache/search/QueryResultImpl.java 2008-06-09
14:32:08 UTC (rev 5964)
+++ searchable/trunk/src/main/java/org/jboss/cache/search/QueryResultImpl.java 2008-06-10
09:13:33 UTC (rev 5965)
@@ -18,6 +18,7 @@
{
private Query query;
private Cache cache;
+ private Class[] classes;
public QueryResultImpl(Query luceneQuery, Cache cache)
{
@@ -25,6 +26,14 @@
this.cache = cache;
}
+ public QueryResultImpl(Query luceneQuery, Cache cache, Class[] classes)
+ {
+ this.query = luceneQuery;
+ this.cache=cache;
+ this.classes = classes;
+
+ }
+
public FullTextQuery setSort(Sort sort)
{
return null; //To change body of implemented methods use File | Settings | File
Templates.
Modified:
searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheFactory.java
===================================================================
---
searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheFactory.java 2008-06-09
14:32:08 UTC (rev 5964)
+++
searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheFactory.java 2008-06-10
09:13:33 UTC (rev 5965)
@@ -1,5 +1,6 @@
package org.jboss.cache.search;
+import org.hibernate.search.impl.SearchFactoryImpl;
import org.jboss.cache.Cache;
/**
@@ -11,6 +12,9 @@
*/
public class SearchableCacheFactory
{
+
+ private SearchFactoryImpl searchFactory;
+
public SearchableCache createSearchableCache (Cache c, Class... classes)
{
Modified: searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheImpl.java
===================================================================
---
searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheImpl.java 2008-06-09
14:32:08 UTC (rev 5964)
+++
searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheImpl.java 2008-06-10
09:13:33 UTC (rev 5965)
@@ -12,7 +12,6 @@
import org.jboss.cache.config.Configuration;
import org.jgroups.Address;
-import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -28,6 +27,7 @@
{
// this is the ACTUAL cache. that does all the work.
private Cache cache;
+ private Class[] classes;
public SearchableCacheImpl(Cache cache)
{
@@ -39,6 +39,12 @@
return new QueryResultImpl(luceneQuery, cache);
}
+ public QueryResult find(Query luceneQuery, Class... classes)
+ {
+ return new QueryResultImpl(luceneQuery, cache, classes);
+
+ }
+
public Configuration getConfiguration()
{
return cache.getConfiguration();
Modified: searchable/trunk/src/main/java/org/jboss/cache/search/SearchableListener.java
===================================================================
---
searchable/trunk/src/main/java/org/jboss/cache/search/SearchableListener.java 2008-06-09
14:32:08 UTC (rev 5964)
+++
searchable/trunk/src/main/java/org/jboss/cache/search/SearchableListener.java 2008-06-10
09:13:33 UTC (rev 5965)
@@ -2,6 +2,7 @@
import org.hibernate.search.backend.Work;
import org.hibernate.search.backend.WorkType;
+import org.hibernate.search.impl.SearchFactoryImpl;
import org.jboss.cache.notifications.annotation.CacheListener;
import org.jboss.cache.notifications.annotation.NodeModified;
import org.jboss.cache.notifications.event.NodeModifiedEvent;
@@ -19,14 +20,15 @@
@CacheListener
public class SearchableListener
{
-
+
+ private SearchFactoryImpl searchFactory;
+
@NodeModified
public void updateLuceneIndexes(NodeModifiedEvent event)
{
if (!event.isPre())
{
-
// TODO: Update Lucene Indexes. See Hibernate Search's
FullTextEventListener class for details on what to do.
}
else
@@ -39,18 +41,17 @@
{
Map dataMap = event.getData();
- for (Object key: dataMap.keySet())
+ for (Object key : dataMap.keySet())
{
String keyString = (String) key;
- String docId = Transformer.generateId(event.getFqn(), keyString) ;
+ String docId = Transformer.generateId(event.getFqn(), keyString);
- new Work (dataMap.get(key), docId, WorkType.DELETE);
- new Work (dataMap.get(key), docId, WorkType.ADD);
+ new Work(dataMap.get(key), docId, WorkType.ADD);
- //TODO: Add to queue.
+ searchFactory.getWorker().performWork(new Work(dataMap.get(key), docId,
WorkType.DELETE);
+ );
}
-
}
@@ -58,18 +59,17 @@
{
Map dataMap = event.getData();
- for(Object key: dataMap.keySet())
+ for (Object key : dataMap.keySet())
{
String keyString = (String) key;
String docId = Transformer.generateId(event.getFqn(), keyString);
- new Work (dataMap.get(key), docId, WorkType.DELETE);
+ new Work(dataMap.get(key), docId, WorkType.DELETE);
//TODO: Add to queue.
}
-
}
}