Author: thomas.heute(a)jboss.com
Date: 2007-08-10 09:07:59 -0400 (Fri, 10 Aug 2007)
New Revision: 7894
Added:
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/FederatedQuery.java
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/SimpleQuery.java
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/SimpleQueryConverter.java
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/lucene/LuceneFederatedIndexer.java
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/lucene/LuceneFederatedSearcher.java
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/lucene/LuceneQueryConverter.java
Removed:
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/QueryImpl.java
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/hibernate/
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/lucene/LuceneSearchFederated.java
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/test/LuceneQueryTest.java
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/test/TestLuceneSearchFederated.java
Modified:
branches/JBoss_Portal_Branch_2_6/cms/.classpath
branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/CommandFactory.java
branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/impl/jcr/JCRCommandFactory.java
branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/impl/jcr/command/SearchCommand.java
branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/search/CMSFederatedSearch.java
branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/test/cms/commands/TestSearch.java
branches/JBoss_Portal_Branch_2_6/core-cms/.classpath
branches/JBoss_Portal_Branch_2_6/core-cms/src/main/org/jboss/portal/core/cms/ui/admin/CMSAdminPortlet.java
branches/JBoss_Portal_Branch_2_6/core-search/src/main/org/jboss/portal/core/search/ui/SearchBean.java
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/FederatedIndexer.java
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/FederatedSearcher.java
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/QueryConverter.java
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/federation/SearchFederation.java
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/federation/impl/SearchFederationService.java
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/identity/UserSearcher.java
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/AbstractFederatedIndexer.java
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/AbstractFederatedSearcher.java
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/AbstractQueryConverter.java
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/StandardQueryConverter.java
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/jcr/JCRQueryConverter.java
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/lucene/LuceneQuery.java
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/query/BooleanClause.java
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/query/BooleanQuery.java
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/query/TermQuery.java
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/test/ConverterTest.java
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/test/DummyFederatedSearch.java
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/test/FederationTest.java
Log:
- Reverted back to have default support for Lucene (and fallback to simple query objects).
It allows for end-to-end support on Lucene without interfering.
Modified: branches/JBoss_Portal_Branch_2_6/cms/.classpath
===================================================================
--- branches/JBoss_Portal_Branch_2_6/cms/.classpath 2007-08-10 07:32:05 UTC (rev 7893)
+++ branches/JBoss_Portal_Branch_2_6/cms/.classpath 2007-08-10 13:07:59 UTC (rev 7894)
@@ -43,5 +43,6 @@
<classpathentry combineaccessrules="false" kind="src"
path="/security"/>
<classpathentry kind="lib"
path="/thirdparty/jbpm/jaronly/lib/jbpm.jar"/>
<classpathentry combineaccessrules="false" kind="src"
path="/search"/>
+ <classpathentry kind="lib"
path="/thirdparty/apache-lucene/lib/lucene.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
Modified:
branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/CommandFactory.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/CommandFactory.java 2007-08-10
07:32:05 UTC (rev 7893)
+++
branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/CommandFactory.java 2007-08-10
13:07:59 UTC (rev 7894)
@@ -29,7 +29,7 @@
import org.jboss.portal.cms.model.Content;
import org.jboss.portal.cms.model.File;
import org.jboss.portal.cms.model.Folder;
-import org.jboss.portal.search.Query;
+import org.jboss.portal.search.impl.jcr.JCRQuery;
/**
* Factory to create commands for the cms service.
@@ -85,5 +85,5 @@
Command createGetArchiveCommand(String sRootPath, String sLanguage);
- Command createSearchCommand(Query query);
+ Command createSearchCommand(JCRQuery query);
}
Modified:
branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/impl/jcr/JCRCommandFactory.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/impl/jcr/JCRCommandFactory.java 2007-08-10
07:32:05 UTC (rev 7893)
+++
branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/impl/jcr/JCRCommandFactory.java 2007-08-10
13:07:59 UTC (rev 7894)
@@ -54,6 +54,7 @@
import org.jboss.portal.cms.model.File;
import org.jboss.portal.cms.model.Folder;
import org.jboss.portal.search.Query;
+import org.jboss.portal.search.impl.jcr.JCRQuery;
/**
* @author <a href="mailto:roy@jboss.org">Roy Russo</a>
@@ -180,7 +181,7 @@
return new GetArchiveCommand(sRootPath, sLanguage);
}
- public Command createSearchCommand(Query query)
+ public Command createSearchCommand(JCRQuery query)
{
return new SearchCommand(query);
}
Modified:
branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/impl/jcr/command/SearchCommand.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/impl/jcr/command/SearchCommand.java 2007-08-10
07:32:05 UTC (rev 7893)
+++
branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/impl/jcr/command/SearchCommand.java 2007-08-10
13:07:59 UTC (rev 7894)
@@ -51,9 +51,9 @@
private static final long serialVersionUID = 2614067614144410297L;
- private Query query;
+ private JCRQuery query;
- public SearchCommand(Query query)
+ public SearchCommand(JCRQuery query)
{
this.query = query;
}
@@ -70,31 +70,24 @@
{
queryManager = workspace.getQueryManager();
- StandardQueryConverter standardConverter = new StandardQueryConverter();
- query = standardConverter.convert(query);
-
- QueryConverter converter = new JCRQueryConverter();
- if (query != null)
+ queryString = query.getJcrQuery();
+
+ if (!"".equals(queryString) && query != null)
{
- queryString = ((JCRQuery) converter.convert(query)).getJcrQuery();
+ javax.jcr.query.Query jcrQuery = queryManager.createQuery(queryString,
javax.jcr.query.Query.XPATH);
+ QueryResult queryResult = jcrQuery.execute();
+ NodeIterator nodeIterator = queryResult.getNodes();
- if (!"".equals(queryString) && query != null)
+ while (nodeIterator.hasNext())
{
- javax.jcr.query.Query jcrQuery = queryManager.createQuery(queryString,
javax.jcr.query.Query.XPATH);
- QueryResult queryResult = jcrQuery.execute();
- NodeIterator nodeIterator = queryResult.getNodes();
-
- while (nodeIterator.hasNext())
- {
- Node node;
- node = nodeIterator.nextNode().getParent();
- File file = new FileImpl();
- file.setBasePath(node.getPath());
-
file.setCreationDate(node.getProperty("jcr:created").getDate().getTime());
-
file.setLastModified(node.getProperty("jcr:lastModified").getDate().getTime());
- file.setName(node.getName());
- files.add(file);
- }
+ Node node;
+ node = nodeIterator.nextNode().getParent();
+ File file = new FileImpl();
+ file.setBasePath(node.getPath());
+
file.setCreationDate(node.getProperty("jcr:created").getDate().getTime());
+
file.setLastModified(node.getProperty("jcr:lastModified").getDate().getTime());
+ file.setName(node.getName());
+ files.add(file);
}
}
}
Modified:
branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/search/CMSFederatedSearch.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/search/CMSFederatedSearch.java 2007-08-10
07:32:05 UTC (rev 7893)
+++
branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/search/CMSFederatedSearch.java 2007-08-10
13:07:59 UTC (rev 7894)
@@ -30,7 +30,10 @@
import org.jboss.portal.cms.model.File;
import org.jboss.portal.common.i18n.LocalizedString;
import org.jboss.portal.search.Query;
+import org.jboss.portal.search.QueryConverter;
import org.jboss.portal.search.impl.AbstractFederatedSearcher;
+import org.jboss.portal.search.impl.jcr.JCRQuery;
+import org.jboss.portal.search.impl.jcr.JCRQueryConverter;
import org.jboss.portal.search.result.ResultSet;
/**
@@ -41,12 +44,14 @@
{
private CMS cms;
private String urlPrefix;
+ private JCRQueryConverter queryConverter;
public CMSFederatedSearch(String id)
{
setId(id);
setDisplayName(new LocalizedString("Content Management System"));
this.urlPrefix = "portal/content";
+ this.queryConverter = new JCRQueryConverter();
}
public void setCMS(CMS cms)
@@ -56,7 +61,7 @@
public ResultSet search(Query query)
{
- Command searchCommand = cms.getCommandFactory().createSearchCommand(query);
+ Command searchCommand =
cms.getCommandFactory().createSearchCommand((JCRQuery)query);
List files = (List)cms.execute(searchCommand);
ResultSet results = new ResultSet(this);
@@ -69,5 +74,9 @@
return results;
}
-
+ public QueryConverter getQueryConverter()
+ {
+ return queryConverter;
+ }
+
}
Modified:
branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/test/cms/commands/TestSearch.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/test/cms/commands/TestSearch.java 2007-08-10
07:32:05 UTC (rev 7893)
+++
branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/test/cms/commands/TestSearch.java 2007-08-10
13:07:59 UTC (rev 7894)
@@ -29,8 +29,10 @@
import org.jboss.portal.cms.CMSException;
import org.jboss.portal.cms.Command;
import org.jboss.portal.cms.model.File;
+import org.jboss.portal.search.FederatedQuery;
import org.jboss.portal.search.Query;
-import org.jboss.portal.search.impl.QueryImpl;
+import org.jboss.portal.search.impl.jcr.JCRQuery;
+import org.jboss.portal.search.impl.jcr.JCRQueryConverter;
/**
@@ -51,8 +53,11 @@
/** Tests retrieval of the version labeled LIVE. */
public void testFileGet() throws CMSException
{
- Query query = new QueryImpl("risks");
- Command searchCMD = service.getCommandFactory().createSearchCommand(query);
+ FederatedQuery query = new FederatedQuery("risks");
+
+ JCRQueryConverter converter = new JCRQueryConverter();
+
+ Command searchCMD =
service.getCommandFactory().createSearchCommand((JCRQuery)converter.convert(query));
List list = (List)service.execute(searchCMD);
File file = (File)list.get(0);
Modified: branches/JBoss_Portal_Branch_2_6/core-cms/.classpath
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core-cms/.classpath 2007-08-10 07:32:05 UTC (rev
7893)
+++ branches/JBoss_Portal_Branch_2_6/core-cms/.classpath 2007-08-10 13:07:59 UTC (rev
7894)
@@ -24,5 +24,6 @@
<classpathentry combineaccessrules="false" kind="src"
path="/core-admin"/>
<classpathentry kind="lib"
path="/thirdparty/hibernate/lib/hibernate3.jar"/>
<classpathentry combineaccessrules="false" kind="src"
path="/search"/>
+ <classpathentry kind="lib"
path="/thirdparty/apache-lucene/lib/lucene.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
Modified:
branches/JBoss_Portal_Branch_2_6/core-cms/src/main/org/jboss/portal/core/cms/ui/admin/CMSAdminPortlet.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/core-cms/src/main/org/jboss/portal/core/cms/ui/admin/CMSAdminPortlet.java 2007-08-10
07:32:05 UTC (rev 7893)
+++
branches/JBoss_Portal_Branch_2_6/core-cms/src/main/org/jboss/portal/core/cms/ui/admin/CMSAdminPortlet.java 2007-08-10
13:07:59 UTC (rev 7894)
@@ -71,8 +71,10 @@
import org.jboss.portal.identity.RoleModule;
import org.jboss.portal.identity.User;
import org.jboss.portal.identity.UserModule;
+import org.jboss.portal.search.FederatedQuery;
import org.jboss.portal.search.Query;
-import org.jboss.portal.search.impl.QueryImpl;
+import org.jboss.portal.search.impl.jcr.JCRQuery;
+import org.jboss.portal.search.impl.jcr.JCRQueryConverter;
import org.jboss.portal.security.PortalPermission;
import org.jboss.portal.server.request.URLContext;
import org.jboss.portal.server.request.URLFormat;
@@ -309,11 +311,14 @@
rRes.setContentType("text/html");
String textQuery = rReq.getParameter("search");
- Query query = new QueryImpl(textQuery);
+ FederatedQuery query = new FederatedQuery(textQuery);
+
+ JCRQueryConverter converter = new JCRQueryConverter();
+
List files;
try
{
- Command searchCommand =
CMSService.getCommandFactory().createSearchCommand(query);
+ Command searchCommand =
CMSService.getCommandFactory().createSearchCommand((JCRQuery)converter.convert(query));
files = (List)CMSService.execute(searchCommand);
}
catch (CMSException e)
Modified:
branches/JBoss_Portal_Branch_2_6/core-search/src/main/org/jboss/portal/core/search/ui/SearchBean.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/core-search/src/main/org/jboss/portal/core/search/ui/SearchBean.java 2007-08-10
07:32:05 UTC (rev 7893)
+++
branches/JBoss_Portal_Branch_2_6/core-search/src/main/org/jboss/portal/core/search/ui/SearchBean.java 2007-08-10
13:07:59 UTC (rev 7894)
@@ -33,12 +33,12 @@
import javax.portlet.PortletContext;
import org.jboss.portal.core.search.service.SearchResultURLFactory;
+import org.jboss.portal.search.FederatedQuery;
import org.jboss.portal.search.FederatedSearcher;
import org.jboss.portal.search.Query;
import org.jboss.portal.search.SearchingException;
import org.jboss.portal.search.federation.SearchFederation;
import org.jboss.portal.search.identity.UserSearcher;
-import org.jboss.portal.search.impl.QueryImpl;
import org.jboss.portal.search.result.Result;
import org.jboss.portal.search.result.ResultSet;
@@ -138,10 +138,10 @@
public void search()
{
List results = null;
- Query query;
+ FederatedQuery query;
try
{
- query = new QueryImpl(textString);
+ query = new FederatedQuery(textString);
results = searchService.search(query, selectedFederatedSearchers);
}
catch (SearchingException e)
Modified:
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/FederatedIndexer.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/FederatedIndexer.java 2007-08-10
07:32:05 UTC (rev 7893)
+++
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/FederatedIndexer.java 2007-08-10
13:07:59 UTC (rev 7894)
@@ -22,8 +22,6 @@
******************************************************************************/
package org.jboss.portal.search;
-import java.util.Locale;
-
import org.jboss.portal.common.i18n.LocalizedString;
import org.jboss.portal.search.federation.Info;
Added:
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/FederatedQuery.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/FederatedQuery.java
(rev 0)
+++
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/FederatedQuery.java 2007-08-10
13:07:59 UTC (rev 7894)
@@ -0,0 +1,65 @@
+/******************************************************************************
+ * 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 org.apache.lucene.analysis.standard.StandardAnalyzer;
+import org.apache.lucene.queryParser.ParseException;
+import org.apache.lucene.queryParser.QueryParser;
+import org.apache.lucene.search.Query;
+import org.jboss.logging.Logger;
+import org.jboss.portal.search.impl.lucene.LuceneQuery;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class FederatedQuery
+{
+
+ private Logger logger = Logger.getLogger(LuceneQuery.class);
+
+ private Query luceneQuery;
+
+ public FederatedQuery(Query luceneQuery)
+ {
+ this.luceneQuery = luceneQuery;
+ }
+
+ public FederatedQuery(String queryString)
+ {
+ try
+ {
+ luceneQuery = QueryParser.parse(queryString, "all" , new
StandardAnalyzer());
+ }
+ catch (ParseException e)
+ {
+ logger.debug("Cannot parse query: " + queryString);
+ }
+ }
+
+ public Query getLuceneQuery()
+ {
+ return luceneQuery;
+ }
+
+}
Modified:
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/FederatedSearcher.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/FederatedSearcher.java 2007-08-10
07:32:05 UTC (rev 7893)
+++
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/FederatedSearcher.java 2007-08-10
13:07:59 UTC (rev 7894)
@@ -46,6 +46,12 @@
* @return String
*/
public LocalizedString getDisplayName();
+
+ /**
+ * Returns the query converter to apply on the Query
+ * @return
+ */
+ public QueryConverter getQueryConverter();
/**
* From the query object this method is responsible to return the
Modified:
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/QueryConverter.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/QueryConverter.java 2007-08-10
07:32:05 UTC (rev 7893)
+++
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/QueryConverter.java 2007-08-10
13:07:59 UTC (rev 7894)
@@ -30,7 +30,7 @@
public interface QueryConverter
{
- public Query convert(Query query) throws QueryConversionException;
+ public Query convert(FederatedQuery query) throws QueryConversionException;
}
Added:
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/SimpleQuery.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/SimpleQuery.java
(rev 0)
+++
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/SimpleQuery.java 2007-08-10
13:07:59 UTC (rev 7894)
@@ -0,0 +1,33 @@
+/******************************************************************************
+ * 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 abstract class SimpleQuery implements Query
+{
+
+}
+
Modified:
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/federation/SearchFederation.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/federation/SearchFederation.java 2007-08-10
07:32:05 UTC (rev 7893)
+++
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/federation/SearchFederation.java 2007-08-10
13:07:59 UTC (rev 7894)
@@ -24,6 +24,7 @@
import java.util.List;
+import org.jboss.portal.search.FederatedQuery;
import org.jboss.portal.search.Query;
import org.jboss.portal.search.FederatedSearcher;
import org.jboss.portal.search.SearchingException;
@@ -42,8 +43,8 @@
public FederatedSearcher getFederatedSearcher(String id);
- public List search(Query query) throws SearchingException;
+ public List search(FederatedQuery query) throws SearchingException;
- public List search(Query query, List searchers) throws SearchingException;
+ public List search(FederatedQuery query, List searchers) throws SearchingException;
}
Modified:
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/federation/impl/SearchFederationService.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/federation/impl/SearchFederationService.java 2007-08-10
07:32:05 UTC (rev 7893)
+++
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/federation/impl/SearchFederationService.java 2007-08-10
13:07:59 UTC (rev 7894)
@@ -30,10 +30,13 @@
import java.util.Map;
import org.jboss.portal.jems.as.system.AbstractJBossService;
+import org.jboss.portal.search.FederatedQuery;
import org.jboss.portal.search.FederatedSearcher;
import org.jboss.portal.search.Query;
+import org.jboss.portal.search.QueryConversionException;
import org.jboss.portal.search.SearchingException;
import org.jboss.portal.search.federation.SearchFederation;
+import org.jboss.portal.search.result.ResultSet;
/**
* @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
@@ -90,33 +93,54 @@
return (FederatedSearcher)registry.get(id);
}
- public List search(Query query) throws SearchingException
+ public List search(FederatedQuery query) throws SearchingException
{
List results = new ArrayList();
Iterator it = registry.values().iterator();
while (it.hasNext())
{
- FederatedSearcher federated = (FederatedSearcher)it.next();
- results.add(federated.search(query));
+ FederatedSearcher searcher = (FederatedSearcher)it.next();
+ try
+ {
+ results.add(search(query, searcher));
+ }
+ catch (QueryConversionException e)
+ {
+ e.printStackTrace();
+ }
}
return results;
}
- public List search(Query query, List searchers) throws SearchingException
+ public List search(FederatedQuery query, List searchers) throws SearchingException
{
List results = new ArrayList();
Iterator it = searchers.iterator();
while (it.hasNext())
{
String federatedId = (String)it.next();
- FederatedSearcher federated = getFederatedSearcher(federatedId);
- if (federated == null)
+ FederatedSearcher searcher = getFederatedSearcher(federatedId);
+ if (searcher == null)
{
throw new SearchingException("Cannot find searcher: " +
federatedId);
}
- results.add(federated.search(query));
+ try
+ {
+ results.add(search(query, searcher));
+ }
+ catch (QueryConversionException e)
+ {
+ e.printStackTrace();
+ }
}
return results;
}
+ private ResultSet search(FederatedQuery query, FederatedSearcher searcher) throws
QueryConversionException, SearchingException
+ {
+ Query convertedQuery = null;
+ convertedQuery = searcher.getQueryConverter().convert(query);
+ return searcher.search(convertedQuery);
+ }
+
}
Modified:
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/identity/UserSearcher.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/identity/UserSearcher.java 2007-08-10
07:32:05 UTC (rev 7893)
+++
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/identity/UserSearcher.java 2007-08-10
13:07:59 UTC (rev 7894)
@@ -24,7 +24,6 @@
import java.util.HashMap;
import java.util.Iterator;
-import java.util.Locale;
import java.util.Map;
import javax.naming.InitialContext;
@@ -35,12 +34,12 @@
import org.jboss.portal.identity.NoSuchUserException;
import org.jboss.portal.identity.User;
import org.jboss.portal.identity.UserModule;
-import org.jboss.portal.jems.as.system.AbstractJBossService;
-import org.jboss.portal.search.FederatedSearcher;
import org.jboss.portal.search.Query;
import org.jboss.portal.search.QueryConversionException;
+import org.jboss.portal.search.QueryConverter;
import org.jboss.portal.search.SearchingException;
import org.jboss.portal.search.impl.AbstractFederatedSearcher;
+import org.jboss.portal.search.impl.SimpleQueryConverter;
import org.jboss.portal.search.impl.StandardQueryConverter;
import org.jboss.portal.search.query.BooleanClause;
import org.jboss.portal.search.query.BooleanQuery;
@@ -50,7 +49,6 @@
import org.jboss.portal.search.result.ResultURL;
import org.jboss.portal.search.result.impl.PortletResultURL;
import org.jboss.portal.search.result.impl.SimpleResult;
-import org.jboss.portal.search.result.impl.SimpleResultURL;
/**
* @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
@@ -80,6 +78,8 @@
public ResultSet search(Query query) throws SearchingException
{
ResultSet resultSet = new ResultSet(this);
+
+ /*
StandardQueryConverter queryConverter = new StandardQueryConverter();
try
@@ -90,6 +90,9 @@
{
throw new SearchingException("An error occured while searching", e);
}
+ */
+ search(query, resultSet);
+
return resultSet;
}
@@ -145,6 +148,12 @@
}
}
+ public QueryConverter getQueryConverter()
+ {
+ return new SimpleQueryConverter();
+ }
+
+
}
Modified:
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/AbstractFederatedIndexer.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/AbstractFederatedIndexer.java 2007-08-10
07:32:05 UTC (rev 7893)
+++
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/AbstractFederatedIndexer.java 2007-08-10
13:07:59 UTC (rev 7894)
@@ -34,11 +34,11 @@
public abstract class AbstractFederatedIndexer extends AbstractJBossService implements
FederatedIndexer
{
- private String id;
+ protected String id;
- private LocalizedString displayName;
+ protected LocalizedString displayName;
- private Info info;
+ protected Info info;
public LocalizedString getDisplayName()
{
Modified:
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/AbstractFederatedSearcher.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/AbstractFederatedSearcher.java 2007-08-10
07:32:05 UTC (rev 7893)
+++
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/AbstractFederatedSearcher.java 2007-08-10
13:07:59 UTC (rev 7894)
@@ -26,6 +26,7 @@
import org.jboss.portal.jems.as.system.AbstractJBossService;
import org.jboss.portal.search.FederatedSearcher;
import org.jboss.portal.search.Query;
+import org.jboss.portal.search.QueryConverter;
import org.jboss.portal.search.SearchingException;
import org.jboss.portal.search.result.ResultSet;
Modified:
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/AbstractQueryConverter.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/AbstractQueryConverter.java 2007-08-10
07:32:05 UTC (rev 7893)
+++
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/AbstractQueryConverter.java 2007-08-10
13:07:59 UTC (rev 7894)
@@ -22,13 +22,10 @@
******************************************************************************/
package org.jboss.portal.search.impl;
-import org.jboss.logging.Logger;
+import org.jboss.portal.search.FederatedQuery;
import org.jboss.portal.search.Query;
import org.jboss.portal.search.QueryConversionException;
import org.jboss.portal.search.QueryConverter;
-import org.jboss.portal.search.impl.jcr.JCRQueryConverter;
-import org.jboss.portal.search.query.BooleanQuery;
-import org.jboss.portal.search.query.TermQuery;
/**
* @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
@@ -37,29 +34,34 @@
public abstract class AbstractQueryConverter implements QueryConverter
{
- public Query convert(Query query) throws QueryConversionException
+ public Query convert(FederatedQuery query) throws QueryConversionException
{
- if (query instanceof TermQuery)
+ org.apache.lucene.search.Query luceneQuery = query.getLuceneQuery();
+ if (luceneQuery == null)
{
- return convertTermQuery((TermQuery)query);
+ return null;
}
- else if (query instanceof BooleanQuery)
+ return convert(luceneQuery);
+
+ }
+
+ public Query convert(org.apache.lucene.search.Query luceneQuery) throws
QueryConversionException
+ {
+ if (luceneQuery instanceof org.apache.lucene.search.TermQuery)
{
- return convertBooleanQuery((BooleanQuery)query);
+ return convertTermQuery((org.apache.lucene.search.TermQuery)luceneQuery);
}
- else if (query instanceof QueryImpl)
+ else if (luceneQuery instanceof org.apache.lucene.search.BooleanQuery)
{
- StandardQueryConverter converter = new StandardQueryConverter();
- return convert(converter.convert(query));
+ return convertBooleanQuery((org.apache.lucene.search.BooleanQuery)luceneQuery);
}
else
{
- throw new QueryConversionException("Unknown query type: " + query);
+ throw new QueryConversionException("Unknown query type: " +
luceneQuery.getClass());
}
}
-
- public abstract Query convertTermQuery(TermQuery query);
+ public abstract Query convertTermQuery(org.apache.lucene.search.TermQuery query);
- public abstract Query convertBooleanQuery(BooleanQuery query) throws
QueryConversionException;
+ public abstract Query convertBooleanQuery(org.apache.lucene.search.BooleanQuery query)
throws QueryConversionException;
}
Deleted:
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/QueryImpl.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/QueryImpl.java 2007-08-10
07:32:05 UTC (rev 7893)
+++
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/QueryImpl.java 2007-08-10
13:07:59 UTC (rev 7894)
@@ -1,39 +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.impl;
-
-import org.jboss.portal.search.impl.lucene.LuceneQuery;
-
-/**
- * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
- * @version $Revision$
- */
-public class QueryImpl extends LuceneQuery
-{
-
- public QueryImpl(String queryString)
- {
- super(queryString);
- }
-
-}
Added:
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/SimpleQueryConverter.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/SimpleQueryConverter.java
(rev 0)
+++
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/SimpleQueryConverter.java 2007-08-10
13:07:59 UTC (rev 7894)
@@ -0,0 +1,71 @@
+/******************************************************************************
+ * 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.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.portal.search.Query;
+import org.jboss.portal.search.QueryConversionException;
+import org.jboss.portal.search.SimpleQuery;
+import org.jboss.portal.search.query.BooleanClause;
+import org.jboss.portal.search.query.BooleanQuery;
+import org.jboss.portal.search.query.Term;
+import org.jboss.portal.search.query.TermQuery;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class SimpleQueryConverter extends AbstractQueryConverter
+{
+
+ public Query convertTermQuery(org.apache.lucene.search.TermQuery luceneQuery)
+ {
+ org.apache.lucene.index.Term term =
((org.apache.lucene.search.TermQuery)luceneQuery).getTerm();
+ return new TermQuery(new Term(term.field(), term.text()));
+ }
+
+ public Query convertBooleanQuery(org.apache.lucene.search.BooleanQuery luceneQuery)
+ {
+ org.apache.lucene.search.BooleanQuery luceneBooleanQuery =
(org.apache.lucene.search.BooleanQuery)luceneQuery;
+ org.apache.lucene.search.BooleanClause[] luceneClauses =
luceneBooleanQuery.getClauses();
+ List clauses = new ArrayList();
+ for (int i=0; i<luceneClauses.length; i++)
+ {
+ org.apache.lucene.search.BooleanClause luceneClause = luceneClauses[i];
+ try
+ {
+ clauses.add(new BooleanClause((SimpleQuery)convert(luceneClause.query),
luceneClause.required, luceneClause.prohibited));
+ }
+ catch (QueryConversionException e)
+ {
+ e.printStackTrace();
+ }
+ }
+ return new BooleanQuery(clauses);
+ }
+
+
+}
+
Modified:
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/StandardQueryConverter.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/StandardQueryConverter.java 2007-08-10
07:32:05 UTC (rev 7893)
+++
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/StandardQueryConverter.java 2007-08-10
13:07:59 UTC (rev 7894)
@@ -25,6 +25,7 @@
import java.util.ArrayList;
import java.util.List;
+import org.jboss.portal.search.FederatedQuery;
import org.jboss.portal.search.Query;
import org.jboss.portal.search.QueryConversionException;
import org.jboss.portal.search.QueryConverter;
@@ -41,12 +42,15 @@
public class StandardQueryConverter implements QueryConverter
{
- public Query convert(Query query) throws QueryConversionException
+ public Query convert(FederatedQuery query) throws QueryConversionException
{
- org.apache.lucene.search.Query luceneQuery = ((LuceneQuery)
query).getLuceneQuery();
- return convertFromLucene(luceneQuery);
+// org.apache.lucene.search.Query luceneQuery = ((LuceneQuery)
query).getLuceneQuery();
+// return convertFromLucene(luceneQuery);
+ return null;
}
+
+ /*
public Query convertFromLucene(org.apache.lucene.search.Query luceneQuery) throws
QueryConversionException
{
if (luceneQuery == null)
@@ -92,5 +96,6 @@
}
return new BooleanQuery(clauses);
}
+ */
}
Modified:
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/jcr/JCRQueryConverter.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/jcr/JCRQueryConverter.java 2007-08-10
07:32:05 UTC (rev 7893)
+++
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/jcr/JCRQueryConverter.java 2007-08-10
13:07:59 UTC (rev 7894)
@@ -25,13 +25,11 @@
import java.util.Iterator;
import java.util.List;
+import org.apache.lucene.search.BooleanClause;
+import org.jboss.portal.search.FederatedQuery;
import org.jboss.portal.search.Query;
import org.jboss.portal.search.QueryConversionException;
import org.jboss.portal.search.impl.AbstractQueryConverter;
-import org.jboss.portal.search.query.BooleanClause;
-import org.jboss.portal.search.query.BooleanQuery;
-import org.jboss.portal.search.query.Term;
-import org.jboss.portal.search.query.TermQuery;
/**
* @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
@@ -40,7 +38,7 @@
public class JCRQueryConverter extends AbstractQueryConverter
{
- public Query convert(Query query)
+ public Query convert(FederatedQuery query)
{
if (query == null)
{
@@ -60,35 +58,33 @@
return new JCRQuery(result.toString());
}
- public Query convertTermQuery(TermQuery query)
+ public Query convertTermQuery(org.apache.lucene.search.TermQuery query)
{
-
StringBuffer result = new StringBuffer();
- Term term = query.getTerm();
- result.append("jcr:contains(., '" + term.getText() +
"')");
+ org.apache.lucene.index.Term term = query.getTerm();
+ result.append("jcr:contains(., '" + term.text() +
"')");
return new JCRQuery(result.toString());
}
- public Query convertBooleanQuery(BooleanQuery query) throws QueryConversionException
+ public Query convertBooleanQuery(org.apache.lucene.search.BooleanQuery query) throws
QueryConversionException
{
- List clauses = query.getClauses();
+ BooleanClause[] clauses = query.getClauses();
StringBuffer result = new StringBuffer();
- Iterator it = clauses.iterator();
boolean first = true;
- while (it.hasNext())
+ for (int i=0; i<clauses.length; i++)
{
- BooleanClause clause = (BooleanClause)it.next();
+ BooleanClause clause = clauses[i];
if (!first)
{
result.append(", ");
}
- if (!clause.isProhibited())
+ if (!clause.prohibited)
{
- result.append(((JCRQuery)super.convert(clause.getQuery())).getJcrQuery());
+ result.append(((JCRQuery)convert(clause.query)).getJcrQuery());
first = false;
}
}
Added:
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/lucene/LuceneFederatedIndexer.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/lucene/LuceneFederatedIndexer.java
(rev 0)
+++
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/lucene/LuceneFederatedIndexer.java 2007-08-10
13:07:59 UTC (rev 7894)
@@ -0,0 +1,134 @@
+/******************************************************************************
+ * 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.impl.lucene;
+
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.lucene.analysis.standard.StandardAnalyzer;
+import org.apache.lucene.document.Document;
+import org.apache.lucene.document.Field;
+import org.apache.lucene.index.IndexWriter;
+import org.jboss.portal.search.IndexingException;
+import org.jboss.portal.search.federation.Info;
+import org.jboss.portal.search.impl.AbstractFederatedIndexer;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public abstract class LuceneFederatedIndexer extends AbstractFederatedIndexer
+{
+ private IndexWriter index;
+
+ private String indexPath;
+
+ public LuceneFederatedIndexer(String id, String indexPath)
+ {
+ this.id = id;
+ this.indexPath = indexPath;
+ }
+
+ public void createIndex() throws IndexingException
+ {
+
+ try
+ {
+ index = new IndexWriter(indexPath, new StandardAnalyzer(), true);
+ }
+ catch (IOException e)
+ {
+ e.printStackTrace();
+ }
+ info.setStatus(Info.Status.INDEXING);
+ try
+ {
+ List documents = getLuceneDocuments();
+ Iterator it = documents.iterator();
+ while (it.hasNext())
+ {
+ Document document = (Document)it.next();
+ index.addDocument(document);
+ }
+ index.optimize();
+ index.close();
+ }
+ catch (IOException e)
+ {
+ throw new IndexingException("Cannot index document", e);
+ }
+ info.setStatus(Info.Status.STARTED);
+ }
+
+ public List getLuceneDocuments()
+ {
+ List documents = getDocuments();
+ Iterator it = documents.iterator();
+ while (it.hasNext())
+ {
+ GenericDocument genericDoc = (GenericDocument) it.next();
+ Document doc = new Document();
+ if (genericDoc.getTitle() != null)
+ doc.add(Field.Text("title", genericDoc.getTitle()));
+ if (genericDoc.getDate() != 0)
+ doc.add(Field.Text("date", genericDoc.getDate()+""));
+ if (genericDoc.getFields() != null)
+ {
+ Map map = genericDoc.getFields();
+ Iterator itKeys = map.keySet().iterator();
+ while (itKeys.hasNext())
+ {
+ String key = (String)itKeys.next();
+ doc.add(Field.Text(key, (String)map.get(key)));
+ }
+ }
+ documents.add(doc);
+ }
+ return documents;
+ }
+
+ /**
+ * List of GenericDocument
+ * @return
+ */
+ public abstract List getDocuments();
+
+ public void destroyIndex()
+ {
+ info.setStatus(Info.Status.STOPPED);
+ }
+
+ public String getId()
+ {
+ return id;
+ }
+
+ public Info getInfo()
+ {
+ return info;
+ }
+
+}
+
Copied:
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/lucene/LuceneFederatedSearcher.java
(from rev 7884,
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/lucene/LuceneSearchFederated.java)
===================================================================
---
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/lucene/LuceneFederatedSearcher.java
(rev 0)
+++
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/lucene/LuceneFederatedSearcher.java 2007-08-10
13:07:59 UTC (rev 7894)
@@ -0,0 +1,71 @@
+/******************************************************************************
+ * 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.impl.lucene;
+
+import org.apache.lucene.search.Hits;
+import org.apache.lucene.search.IndexSearcher;
+import org.apache.lucene.search.Searcher;
+import org.jboss.portal.search.Query;
+import org.jboss.portal.search.impl.AbstractFederatedSearcher;
+import org.jboss.portal.search.result.ResultSet;
+import org.jboss.portal.search.result.impl.SimpleResult;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public abstract class LuceneFederatedSearcher extends AbstractFederatedSearcher
+{
+
+ private String id;
+
+ private String indexPath;
+
+ public LuceneFederatedSearcher(String id, String indexPath)
+ {
+ this.id = id;
+ this.indexPath = indexPath;
+ }
+
+
+ public ResultSet search(Query query)
+ {
+ ResultSet result = new ResultSet(this);
+ try
+ {
+ Searcher searcher = new IndexSearcher(indexPath);
+ Hits hits = searcher.search(((LuceneQuery)query).getLuceneQuery());
+ for (int i=0; i<hits.length(); i++)
+ {
+ result.add(new SimpleResult(id, hits.doc(i)));
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+
+ return result;
+ }
+
+}
Modified:
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/lucene/LuceneQuery.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/lucene/LuceneQuery.java 2007-08-10
07:32:05 UTC (rev 7893)
+++
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/lucene/LuceneQuery.java 2007-08-10
13:07:59 UTC (rev 7894)
@@ -22,41 +22,23 @@
******************************************************************************/
package org.jboss.portal.search.impl.lucene;
-import org.apache.lucene.analysis.standard.StandardAnalyzer;
-import org.apache.lucene.queryParser.ParseException;
-import org.apache.lucene.queryParser.QueryParser;
-import org.jboss.logging.Logger;
-import org.jboss.portal.search.Query;
+import org.apache.lucene.search.Query;
/**
* @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
* @version $Revision$
*/
-public class LuceneQuery implements Query
+public class LuceneQuery implements org.jboss.portal.search.Query
{
- private org.apache.lucene.search.Query query;
+ private Query luceneQuery;
- private Logger logger = Logger.getLogger(LuceneQuery.class);
-
- public LuceneQuery(String queryString)
+ public LuceneQuery(Query luceneQuery)
{
- try
- {
- query = QueryParser.parse(queryString, "all" , new
StandardAnalyzer());
- }
- catch (ParseException e)
- {
- logger.debug("Cannot parse query: " + queryString);
- }
+ this.luceneQuery = luceneQuery;
}
- public LuceneQuery(org.apache.lucene.search.Query query)
+ public Query getLuceneQuery()
{
- this.query = query;
+ return luceneQuery;
}
-
- public org.apache.lucene.search.Query getLuceneQuery()
- {
- return query;
- }
}
Added:
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/lucene/LuceneQueryConverter.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/lucene/LuceneQueryConverter.java
(rev 0)
+++
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/lucene/LuceneQueryConverter.java 2007-08-10
13:07:59 UTC (rev 7894)
@@ -0,0 +1,44 @@
+/******************************************************************************
+ * 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.impl.lucene;
+
+import org.jboss.portal.search.FederatedQuery;
+import org.jboss.portal.search.Query;
+import org.jboss.portal.search.QueryConversionException;
+import org.jboss.portal.search.QueryConverter;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class LuceneQueryConverter implements QueryConverter
+{
+
+ public Query convert(FederatedQuery query) throws QueryConversionException
+ {
+ return new LuceneQuery(query.getLuceneQuery());
+ }
+
+
+}
+
Deleted:
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/lucene/LuceneSearchFederated.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/lucene/LuceneSearchFederated.java 2007-08-10
07:32:05 UTC (rev 7893)
+++
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/lucene/LuceneSearchFederated.java 2007-08-10
13:07:59 UTC (rev 7894)
@@ -1,185 +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.impl.lucene;
-
-import java.io.IOException;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.lucene.analysis.standard.StandardAnalyzer;
-import org.apache.lucene.document.Document;
-import org.apache.lucene.document.Field;
-import org.apache.lucene.index.IndexWriter;
-import org.apache.lucene.queryParser.QueryParser;
-import org.apache.lucene.search.Hits;
-import org.apache.lucene.search.IndexSearcher;
-import org.apache.lucene.search.Searcher;
-import org.jboss.portal.search.IndexingException;
-import org.jboss.portal.search.Query;
-import org.jboss.portal.search.FederatedSearcher;
-import org.jboss.portal.search.federation.Info;
-import org.jboss.portal.search.impl.QueryImpl;
-import org.jboss.portal.search.result.ResultSet;
-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>
- * @version $Revision$
- */
-public abstract class LuceneSearchFederated implements FederatedSearcher
-{
-
- private IndexWriter index;
-
- private String id;
-
- private Info info;
-
- private String indexPath;
-
- private String defaultField;
-
- public LuceneSearchFederated(String id, String indexPath, String defaultField)
- {
- this.id = id;
- this.indexPath = indexPath;
- this.defaultField = defaultField;
- info = new Info();
- }
-
- public void create() throws IndexingException
- {
-
- try
- {
- index = new IndexWriter(indexPath, new StandardAnalyzer(), true);
- }
- catch (IOException e)
- {
- e.printStackTrace();
- }
- info.setStatus(Info.Status.INDEXING);
- try
- {
- List documents = getLuceneDocuments();
- Iterator it = documents.iterator();
- while (it.hasNext())
- {
- Document document = (Document)it.next();
- index.addDocument(document);
- }
- index.optimize();
- index.close();
- }
- catch (IOException e)
- {
- throw new IndexingException("Cannot index document", e);
- }
- info.setStatus(Info.Status.STARTED);
- }
-
- public List getLuceneDocuments()
- {
- List documents = getDocuments();
- Iterator it = documents.iterator();
- while (it.hasNext())
- {
- GenericDocument genericDoc = (GenericDocument) it.next();
- Document doc = new Document();
- if (genericDoc.getTitle() != null)
- doc.add(Field.Text("title", genericDoc.getTitle()));
- if (genericDoc.getDate() != 0)
- doc.add(Field.Text("date", genericDoc.getDate()+""));
- if (genericDoc.getFields() != null)
- {
- Map map = genericDoc.getFields();
- Iterator itKeys = map.keySet().iterator();
- while (itKeys.hasNext())
- {
- String key = (String)itKeys.next();
- doc.add(Field.Text(key, (String)map.get(key)));
- }
- }
- documents.add(doc);
- }
- return documents;
- }
-
- /**
- * List of GenericDocument
- * @return
- */
- public abstract List getDocuments();
-
- public void destroy()
- {
- info.setStatus(Info.Status.STOPPED);
- }
-
- public String getId()
- {
- return id;
- }
-
- public Info getInfo()
- {
- return info;
- }
-
- public ResultSet search(Query query)
- {
- ResultSet result = new ResultSet(this);
- try
- {
- Searcher searcher = new IndexSearcher(indexPath);
- Hits hits = searcher.search(((LuceneQuery)query).getLuceneQuery());
- for (int i=0; i<hits.length(); i++)
- {
- result.add(new SimpleResult(id, hits.doc(i)));
- }
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
-
- return result;
- }
-
- public String getMarkup(ResultSet results, int markupLevel)
- {
- StringBuffer buffer = new StringBuffer();
- Iterator it = results.iterator();
- while (it.hasNext())
- {
- AbstractResult result = (AbstractResult) it.next();
- Document document = (Document)((SimpleResult)result).getValue();
- buffer.append("Id:" +
document.getField("id").stringValue());
- buffer.append(" ");
- }
- return buffer.toString();
- }
-
-}
Modified:
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/query/BooleanClause.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/query/BooleanClause.java 2007-08-10
07:32:05 UTC (rev 7893)
+++
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/query/BooleanClause.java 2007-08-10
13:07:59 UTC (rev 7894)
@@ -22,7 +22,9 @@
******************************************************************************/
package org.jboss.portal.search.query;
+import org.jboss.portal.search.FederatedQuery;
import org.jboss.portal.search.Query;
+import org.jboss.portal.search.SimpleQuery;
/**
* @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
@@ -30,20 +32,20 @@
*/
public class BooleanClause
{
- private Query query;
+ private SimpleQuery query;
private boolean isRequired;
private boolean isProhibited;
- public BooleanClause(Query query, boolean isRequired, boolean isProhibited)
+ public BooleanClause(SimpleQuery query, boolean isRequired, boolean isProhibited)
{
this.query = query;
this.isRequired = isRequired;
this.isProhibited = isProhibited;
}
- public Query getQuery()
+ public SimpleQuery getQuery()
{
return query;
}
Modified:
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/query/BooleanQuery.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/query/BooleanQuery.java 2007-08-10
07:32:05 UTC (rev 7893)
+++
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/query/BooleanQuery.java 2007-08-10
13:07:59 UTC (rev 7894)
@@ -24,13 +24,13 @@
import java.util.List;
-import org.jboss.portal.search.Query;
+import org.jboss.portal.search.SimpleQuery;
/**
* @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
* @version $Revision$
*/
-public class BooleanQuery implements Query
+public class BooleanQuery extends SimpleQuery
{
private List clauses;
Modified:
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/query/TermQuery.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/query/TermQuery.java 2007-08-10
07:32:05 UTC (rev 7893)
+++
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/query/TermQuery.java 2007-08-10
13:07:59 UTC (rev 7894)
@@ -22,13 +22,13 @@
******************************************************************************/
package org.jboss.portal.search.query;
-import org.jboss.portal.search.Query;
+import org.jboss.portal.search.SimpleQuery;
/**
* @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
* @version $Revision$
*/
-public class TermQuery implements Query
+public class TermQuery extends SimpleQuery
{
private Term term;
Modified:
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/test/ConverterTest.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/test/ConverterTest.java 2007-08-10
07:32:05 UTC (rev 7893)
+++
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/test/ConverterTest.java 2007-08-10
13:07:59 UTC (rev 7894)
@@ -24,17 +24,16 @@
import junit.framework.TestCase;
-import org.apache.lucene.index.Term;
-import org.apache.lucene.queryParser.ParseException;
-import org.apache.lucene.search.TermQuery;
+import org.jboss.portal.search.FederatedQuery;
import org.jboss.portal.search.Query;
import org.jboss.portal.search.QueryConversionException;
import org.jboss.portal.search.QueryConverter;
-import org.jboss.portal.search.impl.QueryImpl;
+import org.jboss.portal.search.SimpleQuery;
import org.jboss.portal.search.impl.StandardQueryConverter;
import org.jboss.portal.search.impl.jcr.JCRQuery;
import org.jboss.portal.search.impl.jcr.JCRQueryConverter;
-import org.jboss.portal.search.impl.lucene.LuceneQuery;
+import org.jboss.portal.search.query.Term;
+import org.jboss.portal.search.query.TermQuery;
/**
* @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
@@ -53,25 +52,14 @@
public void testJCRConverter()
{
- org.apache.lucene.search.Query luceneQuery = new TermQuery(new Term("id",
"1"));
- Query query = new LuceneQuery(luceneQuery);
+
+ FederatedQuery fQuery = new FederatedQuery("bar");
- StandardQueryConverter standardConverter = new StandardQueryConverter();
- try
- {
- query = standardConverter.convert(query);
- }
- catch (QueryConversionException e)
- {
- // FIXME
- e.printStackTrace();
- }
-
QueryConverter converter = new JCRQueryConverter();
try
{
- JCRQuery xpath = (JCRQuery)converter.convert(query);
- assertEquals("//*[jcr:contains(., '1')]", xpath.toString());
+ JCRQuery xpath = (JCRQuery)converter.convert(fQuery);
+ assertEquals("//*[jcr:contains(., 'bar')]",
xpath.toString());
}
catch (QueryConversionException e)
{
@@ -81,19 +69,8 @@
public void testJCRConverterMultipleTerms()
{
- Query query = new QueryImpl("foo bar");
+ FederatedQuery query = new FederatedQuery("foo bar");
- StandardQueryConverter standardConverter = new StandardQueryConverter();
- try
- {
- query = standardConverter.convert(query);
- }
- catch (QueryConversionException e)
- {
- // FIXME
- e.printStackTrace();
- }
-
QueryConverter converter = new JCRQueryConverter();
try
{
@@ -105,5 +82,4 @@
e.printStackTrace();
}
}
-
}
Modified:
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/test/DummyFederatedSearch.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/test/DummyFederatedSearch.java 2007-08-10
07:32:05 UTC (rev 7893)
+++
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/test/DummyFederatedSearch.java 2007-08-10
13:07:59 UTC (rev 7894)
@@ -22,14 +22,14 @@
******************************************************************************/
package org.jboss.portal.search.test;
-import java.util.Locale;
-
import org.jboss.portal.common.i18n.LocalizedString;
import org.jboss.portal.search.FederatedIndexer;
+import org.jboss.portal.search.FederatedSearcher;
import org.jboss.portal.search.IndexingException;
import org.jboss.portal.search.Query;
-import org.jboss.portal.search.FederatedSearcher;
+import org.jboss.portal.search.QueryConverter;
import org.jboss.portal.search.federation.Info;
+import org.jboss.portal.search.impl.lucene.LuceneQueryConverter;
import org.jboss.portal.search.result.ResultSet;
import org.jboss.portal.search.result.impl.SimpleResult;
@@ -87,5 +87,10 @@
{
return null;
}
+
+ public QueryConverter getQueryConverter()
+ {
+ return new LuceneQueryConverter();
+ }
}
Modified:
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/test/FederationTest.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/test/FederationTest.java 2007-08-10
07:32:05 UTC (rev 7893)
+++
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/test/FederationTest.java 2007-08-10
13:07:59 UTC (rev 7894)
@@ -26,6 +26,7 @@
import org.apache.lucene.index.Term;
import org.apache.lucene.search.TermQuery;
+import org.jboss.portal.search.FederatedQuery;
import org.jboss.portal.search.Query;
import org.jboss.portal.search.SearchingException;
import org.jboss.portal.search.federation.IndexFederation;
@@ -54,8 +55,10 @@
indexfederation.register(federatedSearch);
indexfederation.reindexAll();
+
+
org.apache.lucene.search.Query luceneQuery = new TermQuery(new Term("id",
"1"));
- Query query = new LuceneQuery(luceneQuery);
+ FederatedQuery query = new FederatedQuery(luceneQuery);
List list = searchfederation.search(query);
ResultSet results = (ResultSet)list.get(0);
Deleted:
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/test/LuceneQueryTest.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/test/LuceneQueryTest.java 2007-08-10
07:32:05 UTC (rev 7893)
+++
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/test/LuceneQueryTest.java 2007-08-10
13:07:59 UTC (rev 7894)
@@ -1,64 +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.test;
-
-import junit.framework.TestCase;
-
-/**
- * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
- * @version $Revision$
- */
-public class LuceneQueryTest extends TestCase
-{
-
- /*
- public void test01()
- {
- Query query = new Query();
- query.addMandatoryTerm(new FieldQueryTerm("Title", "My
Title"));
- query.addMandatoryTerm(new FieldQueryTerm("id", "1"));
- assertEquals(" +Title:\"My Title\" +id:\"1\"",
LuceneQueryConverter.convert(query));
- }
-
- public void test02()
- {
- Query query = new Query();
- query.addMandatoryTerm(new FieldQueryTerm("Title", "My
Title"));
- query.addMandatoryTerm(new FieldQueryTerm("id", "1"));
- query.addNotTerm(new BetweenDatesTerm("date", 10000, 20000));
- assertEquals(" +Title:\"My Title\" +id:\"1\"
-date:[10000,20000]", LuceneQueryConverter.convert(query));
- }
-
- public void test03() throws IndexingException
- {
- LuceneSearchFederated fed = new TestLuceneSearchFederated("TestSearch",
"test", "id");
- fed.create();
-
- Query query = new Query();
- query.addMandatoryTerm(new FieldQueryTerm("id", "1"));
- ResultSet results = fed.search(query);
- System.out.println(fed.getMarkup(results, 0));
- assertEquals("Id:1 Id:1 cat ", fed.getMarkup(results, 0));
- }
- */
-}
Deleted:
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/test/TestLuceneSearchFederated.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/test/TestLuceneSearchFederated.java 2007-08-10
07:32:05 UTC (rev 7893)
+++
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/test/TestLuceneSearchFederated.java 2007-08-10
13:07:59 UTC (rev 7894)
@@ -1,72 +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.test;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Locale;
-
-import org.apache.lucene.document.Document;
-import org.apache.lucene.document.Field;
-import org.jboss.portal.common.i18n.LocalizedString;
-import org.jboss.portal.search.impl.lucene.LuceneSearchFederated;
-
-/**
- * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
- * @version $Revision$
- */
-public class TestLuceneSearchFederated extends LuceneSearchFederated
-{
-
- public TestLuceneSearchFederated(String id, String indexPath, String defaultField)
- {
- super(id, indexPath, defaultField);
- }
-
- public List getLuceneDocuments()
- {
- List result = new ArrayList();
-
- Document doc1 = new Document();
- doc1.add(Field.Text("id", "1"));
- result.add(doc1);
-
- Document doc2 = new Document();
- doc2.add(Field.Text("id", "1 cat"));
- result.add(doc2);
-
- return result;
- }
-
- public List getDocuments()
- {
- return null;
- }
-
- public LocalizedString getDisplayName()
- {
- // TODO Auto-generated method stub
- return null;
- }
-
-}