Author: thomas.heute(a)jboss.com
Date: 2006-12-14 09:49:08 -0500 (Thu, 14 Dec 2006)
New Revision: 5854
Added:
trunk/search/src/main/org/jboss/portal/search/result/
trunk/search/src/main/org/jboss/portal/search/result/Result.java
trunk/search/src/main/org/jboss/portal/search/result/Results.java
trunk/search/src/main/org/jboss/portal/search/result/impl/
trunk/search/src/main/org/jboss/portal/search/result/impl/AbstractResult.java
trunk/search/src/main/org/jboss/portal/search/result/impl/SimpleResult.java
Removed:
trunk/search/src/main/org/jboss/portal/search/Result.java
trunk/search/src/main/org/jboss/portal/search/Results.java
Modified:
trunk/search/src/main/org/jboss/portal/search/federation/SearchFederated.java
trunk/search/src/main/org/jboss/portal/search/federation/SearchFederation.java
trunk/search/src/main/org/jboss/portal/search/federation/impl/SearchFederationService.java
trunk/search/src/main/org/jboss/portal/search/test/LuceneQueryTest.java
trunk/search/src/main/org/jboss/portal/search/test/SearchFederatedLucene.java
Log:
Federated search
Deleted: trunk/search/src/main/org/jboss/portal/search/Result.java
===================================================================
--- trunk/search/src/main/org/jboss/portal/search/Result.java 2006-12-14 00:37:26 UTC (rev
5853)
+++ trunk/search/src/main/org/jboss/portal/search/Result.java 2006-12-14 14:49:08 UTC (rev
5854)
@@ -1,56 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.search;
-
-/**
- * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
- * @version $Revision$
- */
-public class Result
-{
- private String federatedId;
-
- private Object value;
-
- public Result(String federatedId, Object value)
- {
- this.federatedId = federatedId;
- this.value = value;
- }
-
- public Object getValue()
- {
- return value;
- }
-
- public void setValue(Object value)
- {
- this.value = value;
- }
-
- public String getFederatedId()
- {
- return federatedId;
- }
-
-}
Deleted: trunk/search/src/main/org/jboss/portal/search/Results.java
===================================================================
--- trunk/search/src/main/org/jboss/portal/search/Results.java 2006-12-14 00:37:26 UTC
(rev 5853)
+++ trunk/search/src/main/org/jboss/portal/search/Results.java 2006-12-14 14:49:08 UTC
(rev 5854)
@@ -1,36 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.search;
-
-import java.util.ArrayList;
-
-/**
- * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
- * @version $Revision$
- */
-public class Results extends ArrayList
-{
-
- private static final long serialVersionUID = -334471675564695554L;
-
-}
Modified: trunk/search/src/main/org/jboss/portal/search/federation/SearchFederated.java
===================================================================
---
trunk/search/src/main/org/jboss/portal/search/federation/SearchFederated.java 2006-12-14
00:37:26 UTC (rev 5853)
+++
trunk/search/src/main/org/jboss/portal/search/federation/SearchFederated.java 2006-12-14
14:49:08 UTC (rev 5854)
@@ -23,8 +23,8 @@
package org.jboss.portal.search.federation;
import org.jboss.portal.search.IndexingException;
-import org.jboss.portal.search.Results;
import org.jboss.portal.search.query.Query;
+import org.jboss.portal.search.result.Results;
/**
* @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
Modified: trunk/search/src/main/org/jboss/portal/search/federation/SearchFederation.java
===================================================================
---
trunk/search/src/main/org/jboss/portal/search/federation/SearchFederation.java 2006-12-14
00:37:26 UTC (rev 5853)
+++
trunk/search/src/main/org/jboss/portal/search/federation/SearchFederation.java 2006-12-14
14:49:08 UTC (rev 5854)
@@ -24,6 +24,9 @@
import java.util.List;
+import org.jboss.portal.search.query.Query;
+import org.jboss.portal.search.result.Results;
+
/**
* @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
* @version $Revision$
@@ -39,5 +42,7 @@
public List getSearchFederated();
public SearchFederated getSearchFederated(String id);
+
+ public Results search(Query query);
}
Modified:
trunk/search/src/main/org/jboss/portal/search/federation/impl/SearchFederationService.java
===================================================================
---
trunk/search/src/main/org/jboss/portal/search/federation/impl/SearchFederationService.java 2006-12-14
00:37:26 UTC (rev 5853)
+++
trunk/search/src/main/org/jboss/portal/search/federation/impl/SearchFederationService.java 2006-12-14
14:49:08 UTC (rev 5854)
@@ -34,6 +34,8 @@
import org.jboss.portal.search.federation.Info;
import org.jboss.portal.search.federation.SearchFederated;
import org.jboss.portal.search.federation.SearchFederation;
+import org.jboss.portal.search.query.Query;
+import org.jboss.portal.search.result.Results;
/**
* @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
@@ -44,6 +46,11 @@
private Map registry;
+ public SearchFederationService()
+ {
+ registry = new HashMap();
+ }
+
public synchronized void register(SearchFederated searchFederated)
{
if (searchFederated == null)
@@ -127,5 +134,17 @@
{
return (SearchFederated)registry.get(id);
}
+
+ public Results search(Query query)
+ {
+ Results results = new Results();
+ Iterator it = registry.values().iterator();
+ while (it.hasNext())
+ {
+ SearchFederated federated = (SearchFederated)it.next();
+ results.addAll(federated.search(query));
+ }
+ return results;
+ }
}
Added: trunk/search/src/main/org/jboss/portal/search/result/Result.java
===================================================================
--- trunk/search/src/main/org/jboss/portal/search/result/Result.java 2006-12-14 00:37:26
UTC (rev 5853)
+++ trunk/search/src/main/org/jboss/portal/search/result/Result.java 2006-12-14 14:49:08
UTC (rev 5854)
@@ -0,0 +1,34 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.search.result;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public interface Result
+{
+ public float getScore();
+
+ public String getFederatedId();
+}
Copied: trunk/search/src/main/org/jboss/portal/search/result/Results.java (from rev 5853,
trunk/search/src/main/org/jboss/portal/search/Results.java)
===================================================================
--- trunk/search/src/main/org/jboss/portal/search/Results.java 2006-12-14 00:37:26 UTC
(rev 5853)
+++ trunk/search/src/main/org/jboss/portal/search/result/Results.java 2006-12-14 14:49:08
UTC (rev 5854)
@@ -0,0 +1,41 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.search.result;
+
+import java.util.ArrayList;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class Results extends ArrayList
+{
+
+ private static final long serialVersionUID = -334471675564695554L;
+
+ public Result getResult(int i)
+ {
+ return (Result)get(i);
+ }
+
+}
Added: trunk/search/src/main/org/jboss/portal/search/result/impl/AbstractResult.java
===================================================================
---
trunk/search/src/main/org/jboss/portal/search/result/impl/AbstractResult.java 2006-12-14
00:37:26 UTC (rev 5853)
+++
trunk/search/src/main/org/jboss/portal/search/result/impl/AbstractResult.java 2006-12-14
14:49:08 UTC (rev 5854)
@@ -0,0 +1,57 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.search.result.impl;
+
+import org.jboss.portal.search.result.Result;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public abstract class AbstractResult implements Result
+{
+ private String federatedId;
+
+ private float score;
+
+ public AbstractResult(String federatedId)
+ {
+ this.federatedId = federatedId;
+ }
+
+ public String getFederatedId()
+ {
+ return federatedId;
+ }
+
+ public float getScore()
+ {
+ return score;
+ }
+
+ public void setScore(float score)
+ {
+ this.score = score;
+ }
+
+}
Added: trunk/search/src/main/org/jboss/portal/search/result/impl/SimpleResult.java
===================================================================
--- trunk/search/src/main/org/jboss/portal/search/result/impl/SimpleResult.java 2006-12-14
00:37:26 UTC (rev 5853)
+++ trunk/search/src/main/org/jboss/portal/search/result/impl/SimpleResult.java 2006-12-14
14:49:08 UTC (rev 5854)
@@ -0,0 +1,51 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.search.result.impl;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class SimpleResult extends AbstractResult
+{
+
+ private Object value;
+
+ public SimpleResult(String federatedId, Object value)
+ {
+ super(federatedId);
+ setValue(value);
+ }
+
+ public Object getValue()
+ {
+ return value;
+ }
+
+ public void setValue(Object value)
+ {
+ this.value = value;
+ }
+
+
+}
Modified: trunk/search/src/main/org/jboss/portal/search/test/LuceneQueryTest.java
===================================================================
--- trunk/search/src/main/org/jboss/portal/search/test/LuceneQueryTest.java 2006-12-14
00:37:26 UTC (rev 5853)
+++ trunk/search/src/main/org/jboss/portal/search/test/LuceneQueryTest.java 2006-12-14
14:49:08 UTC (rev 5854)
@@ -23,9 +23,9 @@
package org.jboss.portal.search.test;
import org.jboss.portal.search.IndexingException;
-import org.jboss.portal.search.Results;
import org.jboss.portal.search.query.Query;
import org.jboss.portal.search.query.impl.FieldQueryTerm;
+import org.jboss.portal.search.result.Results;
import junit.framework.TestCase;
Modified: trunk/search/src/main/org/jboss/portal/search/test/SearchFederatedLucene.java
===================================================================
---
trunk/search/src/main/org/jboss/portal/search/test/SearchFederatedLucene.java 2006-12-14
00:37:26 UTC (rev 5853)
+++
trunk/search/src/main/org/jboss/portal/search/test/SearchFederatedLucene.java 2006-12-14
14:49:08 UTC (rev 5854)
@@ -34,11 +34,12 @@
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.Searcher;
import org.jboss.portal.search.IndexingException;
-import org.jboss.portal.search.Result;
-import org.jboss.portal.search.Results;
import org.jboss.portal.search.federation.Info;
import org.jboss.portal.search.federation.SearchFederated;
import org.jboss.portal.search.query.Query;
+import org.jboss.portal.search.result.Results;
+import org.jboss.portal.search.result.impl.AbstractResult;
+import org.jboss.portal.search.result.impl.SimpleResult;
/**
* @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
@@ -115,7 +116,7 @@
Hits hits = searcher.search(luceneQuery);
for (int i=0; i<hits.length(); i++)
{
- result.add(new Result(id, hits.doc(i)));
+ result.add(new SimpleResult(id, hits.doc(i)));
}
}
catch (Exception e)
@@ -133,8 +134,8 @@
Iterator it = results.iterator();
while (it.hasNext())
{
- Result result = (Result) it.next();
- Document document = (Document)result.getValue();
+ AbstractResult result = (AbstractResult) it.next();
+ Document document = (Document)((SimpleResult)result).getValue();
buffer.append("Id:" +
document.getField("id").stringValue());
buffer.append(" ");
}