Author: thomas.heute(a)jboss.com
Date: 2007-08-09 08:50:21 -0400 (Thu, 09 Aug 2007)
New Revision: 7882
Added:
branches/JBoss_Portal_Branch_2_6/search/.settings/
branches/JBoss_Portal_Branch_2_6/search/.settings/org.eclipse.jdt.core.prefs
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/Query.java
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/QueryConversionException.java
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/SearchingException.java
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/federation/IndexFederation.java
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/federation/impl/IndexFederationService.java
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/identity/
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/QueryImpl.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/hibernate/
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/hibernate/HibernateSearchFederated.java
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/jcr/
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/lucene/
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/lucene/GenericDocument.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/result/impl/JSFPortletResultURL.java
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/result/impl/PortletResultURL.java
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/test/DummyFederatedSearch.java
Removed:
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/SearchFederated.java
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/federated/jcr/
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/federated/lucene/
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/hibernate/GenericDocument.java
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/hibernate/LuceneQueryConverter.java
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/hibernate/LuceneSearchFederated.java
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/lucene/GenericDocument.java
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/lucene/
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/test/DummySearchFederated.java
Modified:
branches/JBoss_Portal_Branch_2_6/search/.classpath
branches/JBoss_Portal_Branch_2_6/search/build.xml
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/IndexingException.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/impl/GenericSearchFederated.java
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/result/Result.java
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/result/ResultSet.java
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/result/impl/AbstractResult.java
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/result/impl/SimpleResult.java
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/result/impl/SimpleResultURL.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/FederationTest.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
Log:
- Refactored search service
- Started JSF Search portlet
(Increasing my ohloh ranking ;) )
Modified: branches/JBoss_Portal_Branch_2_6/search/.classpath
===================================================================
--- branches/JBoss_Portal_Branch_2_6/search/.classpath 2007-08-09 12:45:50 UTC (rev 7881)
+++ branches/JBoss_Portal_Branch_2_6/search/.classpath 2007-08-09 12:50:21 UTC (rev 7882)
@@ -3,12 +3,13 @@
<classpathentry kind="src" path="src/main"/>
<classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con"
path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3.8.1"/>
- <classpathentry combineaccessrules="false" kind="src"
path="/jems"/>
<classpathentry kind="lib"
path="/thirdparty/jbossas/core-libs/lib/jboss-system.jar"/>
<classpathentry kind="lib"
path="/thirdparty/jbossas/core-libs/lib/jboss-jmx.jar"/>
<classpathentry kind="lib"
path="/thirdparty/jbossas/core-libs/lib/jboss-common.jar"/>
<classpathentry kind="lib"
path="/thirdparty/apache-lucene/lib/lucene.jar"/>
<classpathentry kind="lib"
path="/thirdparty/jcr/lib/jcr-1.0.jar"/>
+ <classpathentry combineaccessrules="false" kind="src"
path="/common"/>
+ <classpathentry combineaccessrules="false" kind="src"
path="/jems"/>
<classpathentry combineaccessrules="false" kind="src"
path="/identity"/>
<classpathentry kind="output" path="bin"/>
</classpath>
Added: branches/JBoss_Portal_Branch_2_6/search/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- branches/JBoss_Portal_Branch_2_6/search/.settings/org.eclipse.jdt.core.prefs
(rev 0)
+++
branches/JBoss_Portal_Branch_2_6/search/.settings/org.eclipse.jdt.core.prefs 2007-08-09
12:50:21 UTC (rev 7882)
@@ -0,0 +1,12 @@
+#Tue Jul 31 15:51:48 CEST 2007
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.4
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning
+org.eclipse.jdt.core.compiler.source=1.3
Modified: branches/JBoss_Portal_Branch_2_6/search/build.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_6/search/build.xml 2007-08-09 12:45:50 UTC (rev 7881)
+++ branches/JBoss_Portal_Branch_2_6/search/build.xml 2007-08-09 12:50:21 UTC (rev 7882)
@@ -74,7 +74,10 @@
<!-- Configure modules -->
<call target="configure-modules"/>
<path id="dependentmodule.classpath">
+ <path refid="jboss.portal-common.classpath"/>
<path refid="jboss.portal-jems.classpath"/>
+ <path refid="jboss.portal-identity.classpath"/>
+ <path refid="jboss.portlet-api.classpath"/>
</path>
<!--+=======================================+-->
Added:
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
(rev 0)
+++
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/FederatedIndexer.java 2007-08-09
12:50:21 UTC (rev 7882)
@@ -0,0 +1,70 @@
+/******************************************************************************
+ * 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.Locale;
+
+import org.jboss.portal.common.i18n.LocalizedString;
+import org.jboss.portal.search.federation.Info;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public interface FederatedIndexer
+{
+ /**
+ * Get the ID for this federated search
+ * @return String representing this particular federated search
+ */
+ public String getId();
+
+ /**
+ * Get a localized name for this federated search
+ * @return String
+ */
+ public LocalizedString getDisplayName();
+
+ /**
+ * Method called when this federated search is not used anymore.
+ * This could be the place to destroy any index
+ * @throws IndexingException
+ */
+ public void destroyIndex() throws IndexingException;
+
+ /**
+ * The create method should index the required components
+ * @throws IndexingException
+ */
+ public void createIndex() throws IndexingException;
+
+ /**
+ * Info should return information on the current status
+ * if the federated search
+ * @return
+ */
+ public Info getInfo();
+
+
+}
+
Added:
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
(rev 0)
+++
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/FederatedSearcher.java 2007-08-09
12:50:21 UTC (rev 7882)
@@ -0,0 +1,76 @@
+/******************************************************************************
+ * 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.Locale;
+
+import org.jboss.portal.common.i18n.LocalizedString;
+import org.jboss.portal.identity.config.metadata.profile.LocalizedStringMetaData;
+import org.jboss.portal.search.result.ResultSet;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public interface FederatedSearcher
+{
+
+ /**
+ * Get the ID for this federated search
+ * @return String representing this particular federated search
+ */
+ public String getId();
+
+ /**
+ * Get a localized name for this federated search
+ * @return String
+ */
+ public LocalizedString getDisplayName();
+
+ /**
+ * From the query object this method is responsible to return the
+ * results of the query
+ * @param query
+ * @return
+ * @throws SearchingException
+ */
+ public ResultSet search(Query query) throws SearchingException;
+
+ /**
+ * TODO: Subject to change...
+ * get the markup fragment for this federated search. A markup level is used
+ * to define different amount of information to provide.
+ * @param results
+ * @param markupLevel
+ * @return
+ */
+ /*
+ public String getMarkup(ResultSet results, int markupLevel);
+
+ public interface MarkupLevel
+ {
+ public static final int FULL = 0;
+ public static final int REDUCED = 1;
+ }
+ */
+}
Modified:
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/IndexingException.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/IndexingException.java 2007-08-09
12:45:50 UTC (rev 7881)
+++
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/IndexingException.java 2007-08-09
12:50:21 UTC (rev 7882)
@@ -28,9 +28,7 @@
*/
public class IndexingException extends Exception
{
- /**
- *
- */
+ /** . */
private static final long serialVersionUID = -4153594211827182795L;
public IndexingException(Throwable e)
Copied:
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/Query.java (from
rev 7815,
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/query/Query.java)
===================================================================
--- branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/Query.java
(rev 0)
+++
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/Query.java 2007-08-09
12:50:21 UTC (rev 7882)
@@ -0,0 +1,35 @@
+/******************************************************************************
+ * 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;
+
+
+
+/**
+ * The Query object is used to express a query.
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public interface Query
+{
+
+}
Added:
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/QueryConversionException.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/QueryConversionException.java
(rev 0)
+++
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/QueryConversionException.java 2007-08-09
12:50:21 UTC (rev 7882)
@@ -0,0 +1,48 @@
+/******************************************************************************
+ * 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 QueryConversionException extends Exception
+{
+ /** . */
+ private static final long serialVersionUID = -4153594211827182795L;
+
+ public QueryConversionException(Throwable e)
+ {
+ super(e);
+ }
+
+ public QueryConversionException(String msg, Throwable e)
+ {
+ super(msg, e);
+ }
+
+ public QueryConversionException(String msg)
+ {
+ super(msg);
+ }
+}
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-09
12:45:50 UTC (rev 7881)
+++
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/QueryConverter.java 2007-08-09
12:50:21 UTC (rev 7882)
@@ -22,27 +22,15 @@
******************************************************************************/
package org.jboss.portal.search;
-import org.jboss.portal.search.query.Query;
-import org.jboss.portal.search.query.impl.KeywordQueryTerm;
/**
* @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
* @version $Revision$
*/
-public class QueryConverter
+public interface QueryConverter
{
- // TODO: implemement this with something more sofisticated using JavaCC
- // and a simple grammar probably
- /**
- * Convert a string into a Query object
- * @return Query object for the text string
- */
- public static Query convert(String textQuery)
- {
- Query query = new Query();
- query.addOptionalTerm(new KeywordQueryTerm(textQuery));
-
- return query;
- }
+ public Query convert(Query query) throws QueryConversionException;
+
}
+
Deleted:
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/SearchFederated.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/SearchFederated.java 2007-08-09
12:45:50 UTC (rev 7881)
+++
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/SearchFederated.java 2007-08-09
12:50:21 UTC (rev 7882)
@@ -1,93 +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.Locale;
-
-import org.jboss.portal.search.federation.Info;
-import org.jboss.portal.search.query.Query;
-import org.jboss.portal.search.result.ResultSet;
-
-/**
- * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
- * @version $Revision$
- */
-public interface SearchFederated
-{
-
- /**
- * Get the ID for this federated search
- * @return String representing this particular federated search
- */
- public String getId();
-
- /**
- * Get a localized name for this federated search
- * @return String
- */
- public String getName(Locale locale);
-
- /**
- * Method called when this federated search is not used anymore.
- * This could be the place to destry any index
- * @throws IndexingException
- */
- public void destroy() throws IndexingException;
-
- /**
- * The create method should index the required components
- * @throws IndexingException
- */
- public void create() throws IndexingException;
-
- /**
- * Info should return information on the current status
- * if the federated search
- * @return
- */
- public Info getInfo();
-
- /**
- * From the query object this method is responsible to return the
- * results of the query
- * @param query
- * @return
- */
- public ResultSet search(Query query);
-
- /**
- * TODO: Subject to change...
- * get the markup fragment for this federated search. A markup level is used
- * to define different amount of information to provide.
- * @param results
- * @param markupLevel
- * @return
- */
- public String getMarkup(ResultSet results, int markupLevel);
-
- public interface MarkupLevel
- {
- public static final int FULL = 0;
- public static final int REDUCED = 1;
- }
-}
Added:
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/SearchingException.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/SearchingException.java
(rev 0)
+++
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/SearchingException.java 2007-08-09
12:50:21 UTC (rev 7882)
@@ -0,0 +1,46 @@
+/******************************************************************************
+ * 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 SearchingException extends Exception
+{
+ public SearchingException(Throwable e)
+ {
+ super(e);
+ }
+
+ public SearchingException(String msg, Throwable e)
+ {
+ super(msg, e);
+ }
+
+ public SearchingException(String msg)
+ {
+ super(msg);
+ }
+}
+
Added:
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/federation/IndexFederation.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/federation/IndexFederation.java
(rev 0)
+++
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/federation/IndexFederation.java 2007-08-09
12:50:21 UTC (rev 7882)
@@ -0,0 +1,45 @@
+/******************************************************************************
+ * 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.federation;
+
+import java.util.List;
+
+import org.jboss.portal.search.FederatedIndexer;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public interface IndexFederation
+{
+ public void register(FederatedIndexer federatedIndexer);
+
+ public void unregister(String id);
+
+ public void reindexAll();
+
+ public List getFederatedIndexerList();
+
+ public FederatedIndexer getFederatedIndexer(String id);
+
+}
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-09
12:45:50 UTC (rev 7881)
+++
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/federation/SearchFederation.java 2007-08-09
12:50:21 UTC (rev 7882)
@@ -24,8 +24,9 @@
import java.util.List;
-import org.jboss.portal.search.SearchFederated;
-import org.jboss.portal.search.query.Query;
+import org.jboss.portal.search.Query;
+import org.jboss.portal.search.FederatedSearcher;
+import org.jboss.portal.search.SearchingException;
/**
* @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
@@ -33,16 +34,16 @@
*/
public interface SearchFederation
{
- public void register(SearchFederated searchFederated);
+ public void register(FederatedSearcher FederatedSearcher);
public void unregister(String id);
- public void reindexAll();
-
- public List getSearchFederatedList();
+ public List getFederatedSearcherList();
- public SearchFederated getSearchFederated(String id);
+ public FederatedSearcher getFederatedSearcher(String id);
- public List search(Query query);
+ public List search(Query query) throws SearchingException;
+ public List search(Query query, List searchers) throws SearchingException;
+
}
Copied:
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/federation/impl/IndexFederationService.java
(from rev 7815,
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/IndexFederationService.java
(rev 0)
+++
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/federation/impl/IndexFederationService.java 2007-08-09
12:50:21 UTC (rev 7882)
@@ -0,0 +1,152 @@
+/******************************************************************************
+ * 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.federation.impl;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.jboss.portal.jems.as.system.AbstractJBossService;
+import org.jboss.portal.search.FederatedIndexer;
+import org.jboss.portal.search.IndexingException;
+import org.jboss.portal.search.federation.IndexFederation;
+import org.jboss.portal.search.federation.Info;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class IndexFederationService extends AbstractJBossService implements
IndexFederation
+{
+
+ private Map registry;
+
+ public IndexFederationService()
+ {
+ registry = new HashMap();
+ }
+
+ public synchronized void register(FederatedIndexer federatedIndexer)
+ {
+ if (federatedIndexer == null)
+ {
+ throw new IllegalArgumentException("No null indexer");
+ }
+ String id = federatedIndexer.getId();
+ if (registry.containsKey(id))
+ {
+ throw new IllegalArgumentException("Attempting dual registration of "
+ id);
+ }
+ Map copy = new HashMap(registry);
+ copy.put(id, federatedIndexer);
+ registry = copy;
+ }
+
+ public synchronized void unregister(String id)
+ {
+ if (id == null)
+ {
+ throw new IllegalArgumentException("No null id accepted");
+ }
+ if (!registry.containsKey(id))
+ {
+ throw new IllegalArgumentException("Attempting to unregister unknown
federated search service " + id);
+ }
+ Map copy = new HashMap(registry);
+ copy.remove(id);
+ registry = copy;
+ }
+
+ public void reindexAll()
+ {
+ if (registry != null)
+ {
+ Iterator it = registry.values().iterator();
+ while (it.hasNext())
+ {
+ FederatedIndexer federated = (FederatedIndexer) it.next();
+ int status = federated.getInfo().getStatus();
+ if (status != Info.Status.INDEXING)
+ {
+ Thread thread = new ReindexFederatedIndexThread(federated);
+ thread.run();
+ }
+ }
+ }
+ }
+
+ private class ReindexFederatedIndexThread extends Thread
+ {
+ private FederatedIndexer federated;
+
+ public ReindexFederatedIndexThread(FederatedIndexer federated)
+ {
+ this.federated = federated;
+ }
+
+ public void run()
+ {
+ federated.getInfo().setStatus(Info.Status.INDEXING);
+ try
+ {
+ federated.destroyIndex();
+ federated.createIndex();
+ federated.getInfo().setStatus(Info.Status.AVAILABLE);
+ }
+ catch (IndexingException e)
+ {
+ federated.getInfo().setStatus(Info.Status.CORRUPTED);
+ e.printStackTrace();
+ }
+ }
+ }
+
+ public List getFederatedIndexerList()
+ {
+ return Collections.unmodifiableList(new ArrayList(registry.values()));
+ }
+
+ public FederatedIndexer getFederatedIndexer(String id)
+ {
+ return (FederatedIndexer)registry.get(id);
+ }
+/*
+ public List search(Query query)
+ {
+ List results = new ArrayList();
+ Iterator it = registry.values().iterator();
+ while (it.hasNext())
+ {
+ FederatedIndexer federated = (FederatedIndexer)it.next();
+ if (federated.getInfo().getStatus() == Info.Status.AVAILABLE)
+ {
+ results.add(federated.search(query));
+ }
+ }
+ return results;
+ }
+ */
+}
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-09
12:45:50 UTC (rev 7881)
+++
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/federation/impl/SearchFederationService.java 2007-08-09
12:50:21 UTC (rev 7882)
@@ -30,12 +30,10 @@
import java.util.Map;
import org.jboss.portal.jems.as.system.AbstractJBossService;
-import org.jboss.portal.search.IndexingException;
-import org.jboss.portal.search.SearchFederated;
-import org.jboss.portal.search.federation.Info;
+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.query.Query;
-import org.jboss.portal.search.result.ResultSet;
/**
* @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
@@ -51,19 +49,19 @@
registry = new HashMap();
}
- public synchronized void register(SearchFederated searchFederated)
+ public synchronized void register(FederatedSearcher federatedSearcher)
{
- if (searchFederated == null)
+ if (federatedSearcher == null)
{
throw new IllegalArgumentException("No null invoker");
}
- String id = searchFederated.getId();
+ String id = federatedSearcher.getId();
if (registry.containsKey(id))
{
throw new IllegalArgumentException("Attempting dual registration of "
+ id);
}
Map copy = new HashMap(registry);
- copy.put(id, searchFederated);
+ copy.put(id, federatedSearcher);
registry = copy;
}
@@ -82,71 +80,41 @@
registry = copy;
}
- public void reindexAll()
+ public List getFederatedSearcherList()
{
- if (registry != null)
- {
- Iterator it = registry.values().iterator();
- while (it.hasNext())
- {
- SearchFederated federated = (SearchFederated) it.next();
- int status = federated.getInfo().getStatus();
- if (status != Info.Status.INDEXING)
- {
- Thread thread = new ReindexFederatedThread(federated);
- thread.run();
- }
- }
- }
+ return Collections.unmodifiableList(new ArrayList(registry.values()));
}
-
- private class ReindexFederatedThread extends Thread
- {
- private SearchFederated federated;
-
- public ReindexFederatedThread(SearchFederated federated)
- {
- this.federated = federated;
- }
-
- public void run()
- {
- federated.getInfo().setStatus(Info.Status.INDEXING);
- try
- {
- federated.destroy();
- federated.create();
- federated.getInfo().setStatus(Info.Status.AVAILABLE);
- }
- catch (IndexingException e)
- {
- federated.getInfo().setStatus(Info.Status.CORRUPTED);
- e.printStackTrace();
- }
- }
- }
- public List getSearchFederatedList()
+ public FederatedSearcher getFederatedSearcher(String id)
{
- return Collections.unmodifiableList(new ArrayList(registry.values()));
+ return (FederatedSearcher)registry.get(id);
}
- public SearchFederated getSearchFederated(String id)
+ public List search(Query query) throws SearchingException
{
- return (SearchFederated)registry.get(id);
+ List results = new ArrayList();
+ Iterator it = registry.values().iterator();
+ while (it.hasNext())
+ {
+ FederatedSearcher federated = (FederatedSearcher)it.next();
+ results.add(federated.search(query));
+ }
+ return results;
}
- public List search(Query query)
+ public List search(Query query, List searchers) throws SearchingException
{
List results = new ArrayList();
- Iterator it = registry.values().iterator();
+ Iterator it = searchers.iterator();
while (it.hasNext())
{
- SearchFederated federated = (SearchFederated)it.next();
- if (federated.getInfo().getStatus() == Info.Status.AVAILABLE)
+ String federatedId = (String)it.next();
+ FederatedSearcher federated = getFederatedSearcher(federatedId);
+ if (federated == null)
{
- results.add(federated.search(query));
+ throw new SearchingException("Cannot find searcher: " +
federatedId);
}
+ results.add(federated.search(query));
}
return results;
}
Added:
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
(rev 0)
+++
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/identity/UserSearcher.java 2007-08-09
12:50:21 UTC (rev 7882)
@@ -0,0 +1,150 @@
+/******************************************************************************
+ * 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.identity;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Locale;
+import java.util.Map;
+
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import org.jboss.portal.common.i18n.LocalizedString;
+import org.jboss.portal.identity.IdentityException;
+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.SearchingException;
+import org.jboss.portal.search.impl.AbstractFederatedSearcher;
+import org.jboss.portal.search.impl.StandardQueryConverter;
+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;
+import org.jboss.portal.search.result.ResultSet;
+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>
+ * @version $Revision$
+ */
+public class UserSearcher extends AbstractFederatedSearcher
+{
+
+ private UserModule userModule;
+
+ public UserSearcher()
+ {
+ setId("user_searcher");
+ setDisplayName(new LocalizedString("User Searcher"));
+ try
+ {
+ userModule = (UserModule) new
InitialContext().lookup("java:/portal/UserModule");
+ }
+ catch (NamingException e)
+ {
+ // FIXME
+ e.printStackTrace();
+ }
+ }
+
+
+ public ResultSet search(Query query) throws SearchingException
+ {
+ ResultSet resultSet = new ResultSet(this);
+ StandardQueryConverter queryConverter = new StandardQueryConverter();
+
+ try
+ {
+ search(queryConverter.convert(query), resultSet);
+ }
+ catch (QueryConversionException e)
+ {
+ throw new SearchingException("An error occured while searching", e);
+ }
+ return resultSet;
+ }
+
+ private void search(Query query, ResultSet resultSet)
+ {
+ if (query instanceof TermQuery)
+ {
+ searchTerm(((TermQuery)query).getTerm(), resultSet);
+ }
+ else if (query instanceof BooleanQuery)
+ {
+ BooleanQuery booleanQuery = (BooleanQuery)query;
+ Iterator it = booleanQuery.getClauses().iterator();
+ while (it.hasNext())
+ {
+ BooleanClause clause = (BooleanClause)it.next();
+ if (!clause.isProhibited())
+ {
+ search(booleanQuery, resultSet);
+ }
+ }
+ }
+ }
+
+ private void searchTerm(Term term, ResultSet resultSet)
+ {
+ try
+ {
+ User user = userModule.findUserByUserName(term.getText());
+ SimpleResult result = new SimpleResult(getId(), user);
+ result.setTitle(new LocalizedString(user.getUserName()));
+ result.setType(new LocalizedString("User"));
+ Map renderParameters = new HashMap();
+ renderParameters.put("userid", user.getId().toString());
+ renderParameters.put("op", "viewProfile");
+ ResultURL url = new
PortletResultURL("default.default.UserPortletWindow", renderParameters);
+ result.setURL(url);
+ resultSet.add(result);
+ }
+ catch (IllegalArgumentException e)
+ {
+ // FIXME
+ e.printStackTrace();
+ }
+ catch (NoSuchUserException e)
+ {
+ // Ignore
+ }
+ catch (IdentityException e)
+ {
+ // FIXME
+ e.printStackTrace();
+ }
+ }
+
+
+}
+
Added:
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
(rev 0)
+++
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/AbstractFederatedIndexer.java 2007-08-09
12:50:21 UTC (rev 7882)
@@ -0,0 +1,75 @@
+/******************************************************************************
+ * 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.common.i18n.LocalizedString;
+import org.jboss.portal.jems.as.system.AbstractJBossService;
+import org.jboss.portal.search.FederatedIndexer;
+import org.jboss.portal.search.federation.Info;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public abstract class AbstractFederatedIndexer extends AbstractJBossService implements
FederatedIndexer
+{
+
+ private String id;
+
+ private LocalizedString displayName;
+
+ private Info info;
+
+ public LocalizedString getDisplayName()
+ {
+ return displayName;
+ }
+
+ public void setDisplayName(LocalizedString displayName)
+ {
+ this.displayName = displayName;
+ }
+
+ public Info getInfo()
+ {
+ return info;
+ }
+
+ public void setInfo(Info info)
+ {
+ this.info = info;
+ }
+
+ public String getId()
+ {
+ return id;
+ }
+
+ public void setId(String id)
+ {
+ this.id = id;
+ }
+
+
+}
+
Added:
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
(rev 0)
+++
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/AbstractFederatedSearcher.java 2007-08-09
12:50:21 UTC (rev 7882)
@@ -0,0 +1,64 @@
+/******************************************************************************
+ * 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.common.i18n.LocalizedString;
+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.SearchingException;
+import org.jboss.portal.search.result.ResultSet;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public abstract class AbstractFederatedSearcher extends AbstractJBossService implements
FederatedSearcher
+{
+
+ private String id;
+
+ private LocalizedString displayName;
+
+ public String getId()
+ {
+ return id;
+ }
+
+ public void setId(String id)
+ {
+ this.id = id;
+ }
+
+ public LocalizedString getDisplayName()
+ {
+ return displayName;
+ }
+
+ public void setDisplayName(LocalizedString displayName)
+ {
+ this.displayName = displayName;
+ }
+
+}
+
Added:
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
(rev 0)
+++
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/AbstractQueryConverter.java 2007-08-09
12:50:21 UTC (rev 7882)
@@ -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.impl;
+
+import org.jboss.logging.Logger;
+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>
+ * @version $Revision$
+ */
+public abstract class AbstractQueryConverter implements QueryConverter
+{
+
+ public Query convert(Query query) throws QueryConversionException
+ {
+ if (query instanceof TermQuery)
+ {
+ return convertTermQuery((TermQuery)query);
+ }
+ else if (query instanceof BooleanQuery)
+ {
+ return convertBooleanQuery((BooleanQuery)query);
+ }
+ else if (query instanceof QueryImpl)
+ {
+ StandardQueryConverter converter = new StandardQueryConverter();
+ return convert(converter.convert(query));
+ }
+ else
+ {
+ throw new QueryConversionException("Unknown query type: " + query);
+ }
+ }
+
+ public abstract Query convertTermQuery(TermQuery query);
+
+ public abstract Query convertBooleanQuery(BooleanQuery query) throws
QueryConversionException;
+}
+
Modified:
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/GenericSearchFederated.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/GenericSearchFederated.java 2007-08-09
12:45:50 UTC (rev 7881)
+++
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/GenericSearchFederated.java 2007-08-09
12:50:21 UTC (rev 7882)
@@ -24,16 +24,17 @@
import java.util.Locale;
-import org.jboss.portal.search.SearchFederated;
+import org.jboss.portal.common.i18n.LocalizedString;
+import org.jboss.portal.search.FederatedSearcher;
/**
* @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
* @version $Revision$
*/
-public abstract class GenericSearchFederated implements SearchFederated
+public abstract class GenericSearchFederated implements FederatedSearcher
{
- public String getName(Locale locale)
+ public LocalizedString getDisplayName(Locale locale)
{
- return getId();
+ return new LocalizedString(getId());
}
}
Added:
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
(rev 0)
+++
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/QueryImpl.java 2007-08-09
12:50:21 UTC (rev 7882)
@@ -0,0 +1,39 @@
+/******************************************************************************
+ * 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/StandardQueryConverter.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/StandardQueryConverter.java
(rev 0)
+++
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/StandardQueryConverter.java 2007-08-09
12:50:21 UTC (rev 7882)
@@ -0,0 +1,96 @@
+/******************************************************************************
+ * 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.QueryConverter;
+import org.jboss.portal.search.impl.lucene.LuceneQuery;
+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 StandardQueryConverter implements QueryConverter
+{
+
+ public Query convert(Query query) throws QueryConversionException
+ {
+ org.apache.lucene.search.Query luceneQuery = ((LuceneQuery)
query).getLuceneQuery();
+ return convertFromLucene(luceneQuery);
+ }
+
+ public Query convertFromLucene(org.apache.lucene.search.Query luceneQuery) throws
QueryConversionException
+ {
+ if (luceneQuery == null)
+ {
+ return null;
+ }
+ else if (luceneQuery instanceof org.apache.lucene.search.TermQuery)
+ {
+ return convertTermQuery((org.apache.lucene.search.TermQuery)luceneQuery);
+ }
+ else if (luceneQuery instanceof org.apache.lucene.search.BooleanQuery)
+ {
+ return convertBooleanQuery((org.apache.lucene.search.BooleanQuery)luceneQuery);
+ }
+ else
+ {
+ throw new QueryConversionException("Unknown query type: " +
luceneQuery.getClass());
+ }
+ }
+
+ 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(convertFromLucene(luceneClause.query),
luceneClause.required, luceneClause.prohibited));
+ }
+ catch (QueryConversionException e)
+ {
+ e.printStackTrace();
+ }
+ }
+ return new BooleanQuery(clauses);
+ }
+}
+
Copied:
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/hibernate
(from rev 7815,
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/lucene)
Deleted:
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/hibernate/GenericDocument.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/lucene/GenericDocument.java 2007-07-18
07:33:25 UTC (rev 7815)
+++
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/hibernate/GenericDocument.java 2007-08-09
12:50:21 UTC (rev 7882)
@@ -1,73 +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.lucene;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
- * @version $Revision$
- */
-public class GenericDocument
-{
- private String title;
-
- private long date;
-
- private Map fields;
-
- public Map getFields()
- {
- return fields;
- }
-
- public long getDate()
- {
- return date;
- }
-
- public void setDate(long date)
- {
- this.date = date;
- }
-
- public String getTitle()
- {
- return title;
- }
-
- public void setTitle(String title)
- {
- this.title = title;
- }
-
- public void addField(String name, String value)
- {
- if (fields == null)
- {
- fields = new HashMap();
- }
- fields.put(name, value);
- }
-}
Added:
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/hibernate/HibernateSearchFederated.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/hibernate/HibernateSearchFederated.java
(rev 0)
+++
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/hibernate/HibernateSearchFederated.java 2007-08-09
12:50:21 UTC (rev 7882)
@@ -0,0 +1,14 @@
+package org.jboss.portal.search.impl.hibernate;
+
+import org.jboss.portal.search.Query;
+import org.jboss.portal.search.impl.AbstractFederatedSearcher;
+import org.jboss.portal.search.result.ResultSet;
+
+public class HibernateSearchFederated extends AbstractFederatedSearcher {
+
+ public ResultSet search(Query query) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
Deleted:
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/hibernate/LuceneQueryConverter.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/lucene/LuceneQueryConverter.java 2007-07-18
07:33:25 UTC (rev 7815)
+++
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/hibernate/LuceneQueryConverter.java 2007-08-09
12:50:21 UTC (rev 7882)
@@ -1,106 +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.lucene;
-
-import java.util.Iterator;
-import java.util.List;
-
-import org.jboss.portal.search.query.Query;
-import org.jboss.portal.search.query.QueryTerm;
-import org.jboss.portal.search.query.impl.BetweenDatesTerm;
-import org.jboss.portal.search.query.impl.DateTerm;
-import org.jboss.portal.search.query.impl.FieldQueryTerm;
-import org.jboss.portal.search.query.impl.KeywordQueryTerm;
-
-/**
- * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
- * @version $Revision$
- */
-public class LuceneQueryConverter
-{
-
- public static String convert(Query query)
- {
- StringBuffer result = new StringBuffer();
- Iterator it;
-
- List terms = query.getMandatoryTerms();
- if (terms != null)
- {
- it = terms.iterator();
- while (it.hasNext())
- {
- QueryTerm term = (QueryTerm) it.next();
- convert(result, term, "+");
- }
- }
-
- terms = query.getNotTerms();
- if (terms != null)
- {
- it = terms.iterator();
- while (it.hasNext())
- {
- QueryTerm term = (QueryTerm) it.next();
- convert(result, term, "-");
- }
- }
-
- terms = query.getOptionalTerms();
- if (terms != null)
- {
- it = terms.iterator();
- while (it.hasNext())
- {
- QueryTerm term = (QueryTerm) it.next();
- convert(result, term, "");
- }
- }
- return result.toString();
- }
-
- private static void convert(StringBuffer result, QueryTerm term, String prefix)
- {
- if (term instanceof FieldQueryTerm)
- {
- FieldQueryTerm convertedTerm = (FieldQueryTerm) term;
- result.append(" " + prefix + convertedTerm.getName() +
":\"" + convertedTerm.getValue()+"\"");
- }
- else if (term instanceof KeywordQueryTerm)
- {
- KeywordQueryTerm convertedTerm = (KeywordQueryTerm) term;
- result.append(" " + prefix + convertedTerm.getKeyWord());
- }
- else if (term instanceof BetweenDatesTerm)
- {
- BetweenDatesTerm convertedTerm = (BetweenDatesTerm) term;
- result.append(" " + prefix + convertedTerm.getField() + ":["
+ convertedTerm.getFromTime() + "," + convertedTerm.getToTime() +
"]");
- }
- else if (term instanceof DateTerm)
- {
- DateTerm convertedTerm = (DateTerm) term;
- result.append(" " + prefix + convertedTerm.getField() + ":["
+ convertedTerm.getTime() + "," + (convertedTerm.getTime() + 24*60*60*1000) +
"}");
- }
- }
-
-}
Deleted:
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/hibernate/LuceneSearchFederated.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/lucene/LuceneSearchFederated.java 2007-07-18
07:33:25 UTC (rev 7815)
+++
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/hibernate/LuceneSearchFederated.java 2007-08-09
12:50:21 UTC (rev 7882)
@@ -1,183 +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.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.SearchFederated;
-import org.jboss.portal.search.federation.Info;
-import org.jboss.portal.search.query.Query;
-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 SearchFederated
-{
-
- 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;
- }
-
- 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);
- String luceneQueryString = LuceneQueryConverter.convert(query);
- QueryParser parser = new QueryParser(defaultField, new StandardAnalyzer());
- try
- {
- org.apache.lucene.search.Query luceneQuery = parser.parse(luceneQueryString);
- Searcher searcher = new IndexSearcher(indexPath);
- Hits hits = searcher.search(luceneQuery);
- 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();
- }
-
-}
Copied:
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/lucene (from
rev 7815,
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/lucene)
Deleted:
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/lucene/GenericDocument.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/lucene/GenericDocument.java 2007-07-18
07:33:25 UTC (rev 7815)
+++
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/lucene/GenericDocument.java 2007-08-09
12:50:21 UTC (rev 7882)
@@ -1,73 +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.lucene;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
- * @version $Revision$
- */
-public class GenericDocument
-{
- private String title;
-
- private long date;
-
- private Map fields;
-
- public Map getFields()
- {
- return fields;
- }
-
- public long getDate()
- {
- return date;
- }
-
- public void setDate(long date)
- {
- this.date = date;
- }
-
- public String getTitle()
- {
- return title;
- }
-
- public void setTitle(String title)
- {
- this.title = title;
- }
-
- public void addField(String name, String value)
- {
- if (fields == null)
- {
- fields = new HashMap();
- }
- fields.put(name, value);
- }
-}
Copied:
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/lucene/GenericDocument.java
(from rev 7815,
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/federated/lucene/GenericDocument.java)
===================================================================
---
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/lucene/GenericDocument.java
(rev 0)
+++
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/lucene/GenericDocument.java 2007-08-09
12:50:21 UTC (rev 7882)
@@ -0,0 +1,73 @@
+/******************************************************************************
+ * 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.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class GenericDocument
+{
+ private String title;
+
+ private long date;
+
+ private Map fields;
+
+ public Map getFields()
+ {
+ return fields;
+ }
+
+ public long getDate()
+ {
+ return date;
+ }
+
+ public void setDate(long date)
+ {
+ this.date = date;
+ }
+
+ public String getTitle()
+ {
+ return title;
+ }
+
+ public void setTitle(String title)
+ {
+ this.title = title;
+ }
+
+ public void addField(String name, String value)
+ {
+ if (fields == null)
+ {
+ fields = new HashMap();
+ }
+ fields.put(name, value);
+ }
+}
Added:
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
(rev 0)
+++
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/lucene/LuceneQuery.java 2007-08-09
12:50:21 UTC (rev 7882)
@@ -0,0 +1,62 @@
+/******************************************************************************
+ * 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.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;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class LuceneQuery implements Query
+{
+ private org.apache.lucene.search.Query query;
+
+ private Logger logger = Logger.getLogger(LuceneQuery.class);
+
+ public LuceneQuery(String queryString)
+ {
+ try
+ {
+ query = QueryParser.parse(queryString, "all" , new
StandardAnalyzer());
+ }
+ catch (ParseException e)
+ {
+ logger.debug("Cannot parse query: " + queryString);
+ }
+ }
+
+ public LuceneQuery(org.apache.lucene.search.Query query)
+ {
+ this.query = query;
+ }
+
+ public org.apache.lucene.search.Query getLuceneQuery()
+ {
+ return query;
+ }
+}
Deleted:
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/lucene/LuceneQueryConverter.java 2007-07-18
07:33:25 UTC (rev 7815)
+++
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/lucene/LuceneQueryConverter.java 2007-08-09
12:50:21 UTC (rev 7882)
@@ -1,106 +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.lucene;
-
-import java.util.Iterator;
-import java.util.List;
-
-import org.jboss.portal.search.query.Query;
-import org.jboss.portal.search.query.QueryTerm;
-import org.jboss.portal.search.query.impl.BetweenDatesTerm;
-import org.jboss.portal.search.query.impl.DateTerm;
-import org.jboss.portal.search.query.impl.FieldQueryTerm;
-import org.jboss.portal.search.query.impl.KeywordQueryTerm;
-
-/**
- * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
- * @version $Revision$
- */
-public class LuceneQueryConverter
-{
-
- public static String convert(Query query)
- {
- StringBuffer result = new StringBuffer();
- Iterator it;
-
- List terms = query.getMandatoryTerms();
- if (terms != null)
- {
- it = terms.iterator();
- while (it.hasNext())
- {
- QueryTerm term = (QueryTerm) it.next();
- convert(result, term, "+");
- }
- }
-
- terms = query.getNotTerms();
- if (terms != null)
- {
- it = terms.iterator();
- while (it.hasNext())
- {
- QueryTerm term = (QueryTerm) it.next();
- convert(result, term, "-");
- }
- }
-
- terms = query.getOptionalTerms();
- if (terms != null)
- {
- it = terms.iterator();
- while (it.hasNext())
- {
- QueryTerm term = (QueryTerm) it.next();
- convert(result, term, "");
- }
- }
- return result.toString();
- }
-
- private static void convert(StringBuffer result, QueryTerm term, String prefix)
- {
- if (term instanceof FieldQueryTerm)
- {
- FieldQueryTerm convertedTerm = (FieldQueryTerm) term;
- result.append(" " + prefix + convertedTerm.getName() +
":\"" + convertedTerm.getValue()+"\"");
- }
- else if (term instanceof KeywordQueryTerm)
- {
- KeywordQueryTerm convertedTerm = (KeywordQueryTerm) term;
- result.append(" " + prefix + convertedTerm.getKeyWord());
- }
- else if (term instanceof BetweenDatesTerm)
- {
- BetweenDatesTerm convertedTerm = (BetweenDatesTerm) term;
- result.append(" " + prefix + convertedTerm.getField() + ":["
+ convertedTerm.getFromTime() + "," + convertedTerm.getToTime() +
"]");
- }
- else if (term instanceof DateTerm)
- {
- DateTerm convertedTerm = (DateTerm) term;
- result.append(" " + prefix + convertedTerm.getField() + ":["
+ convertedTerm.getTime() + "," + (convertedTerm.getTime() + 24*60*60*1000) +
"}");
- }
- }
-
-}
Modified:
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/lucene/LuceneSearchFederated.java 2007-07-18
07:33:25 UTC (rev 7815)
+++
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/lucene/LuceneSearchFederated.java 2007-08-09
12:50:21 UTC (rev 7882)
@@ -20,7 +20,7 @@
* 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.lucene;
+package org.jboss.portal.search.impl.lucene;
import java.io.IOException;
import java.util.Iterator;
@@ -36,9 +36,10 @@
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.Searcher;
import org.jboss.portal.search.IndexingException;
-import org.jboss.portal.search.SearchFederated;
+import org.jboss.portal.search.Query;
+import org.jboss.portal.search.FederatedSearcher;
import org.jboss.portal.search.federation.Info;
-import org.jboss.portal.search.query.Query;
+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;
@@ -47,7 +48,7 @@
* @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
* @version $Revision$
*/
-public abstract class LuceneSearchFederated implements SearchFederated
+public abstract class LuceneSearchFederated implements FederatedSearcher
{
private IndexWriter index;
@@ -126,6 +127,10 @@
return documents;
}
+ /**
+ * List of GenericDocument
+ * @return
+ */
public abstract List getDocuments();
public void destroy()
@@ -146,13 +151,10 @@
public ResultSet search(Query query)
{
ResultSet result = new ResultSet(this);
- String luceneQueryString = LuceneQueryConverter.convert(query);
- QueryParser parser = new QueryParser(defaultField, new StandardAnalyzer());
try
{
- org.apache.lucene.search.Query luceneQuery = parser.parse(luceneQueryString);
Searcher searcher = new IndexSearcher(indexPath);
- Hits hits = searcher.search(luceneQuery);
+ Hits hits = searcher.search(((LuceneQuery)query).getLuceneQuery());
for (int i=0; i<hits.length(); i++)
{
result.add(new SimpleResult(id, hits.doc(i)));
Modified:
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/result/Result.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/result/Result.java 2007-08-09
12:45:50 UTC (rev 7881)
+++
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/result/Result.java 2007-08-09
12:50:21 UTC (rev 7882)
@@ -22,6 +22,8 @@
******************************************************************************/
package org.jboss.portal.search.result;
+import org.jboss.portal.common.i18n.LocalizedString;
+
/**
* @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
* @version $Revision$
@@ -32,5 +34,7 @@
public ResultURL getURL();
- public String getTitle();
+ public LocalizedString getTitle();
+
+ public LocalizedString getType();
}
Modified:
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/result/ResultSet.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/result/ResultSet.java 2007-08-09
12:45:50 UTC (rev 7881)
+++
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/result/ResultSet.java 2007-08-09
12:50:21 UTC (rev 7882)
@@ -24,7 +24,7 @@
import java.util.ArrayList;
-import org.jboss.portal.search.SearchFederated;
+import org.jboss.portal.search.FederatedSearcher;
/**
* @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
@@ -34,14 +34,14 @@
{
private static final long serialVersionUID = -334471675564695554L;
- private SearchFederated searchFederated;
+ private FederatedSearcher searchFederated;
- public ResultSet(SearchFederated searchFederated)
+ public ResultSet(FederatedSearcher searchFederated)
{
this.searchFederated = searchFederated;
}
- public SearchFederated getSearchFederated()
+ public FederatedSearcher getSearchFederated()
{
return searchFederated;
}
Modified:
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/result/impl/AbstractResult.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/result/impl/AbstractResult.java 2007-08-09
12:45:50 UTC (rev 7881)
+++
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/result/impl/AbstractResult.java 2007-08-09
12:50:21 UTC (rev 7882)
@@ -22,6 +22,7 @@
******************************************************************************/
package org.jboss.portal.search.result.impl;
+import org.jboss.portal.common.i18n.LocalizedString;
import org.jboss.portal.search.result.Result;
import org.jboss.portal.search.result.ResultURL;
@@ -29,12 +30,14 @@
* @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
* @version $Revision$
*/
-public abstract class AbstractResult implements Result
+public abstract class AbstractResult implements Result, Comparable
{
private String federatedId;
- private String title;
+ private LocalizedString title;
+ private LocalizedString type;
+
private float score;
private ResultURL url;
@@ -69,14 +72,44 @@
this.score = score;
}
- public String getTitle()
+ public LocalizedString getTitle()
{
return title;
}
- public void setTitle(String title)
+ public void setTitle(LocalizedString title)
{
this.title = title;
}
+ public LocalizedString getType()
+ {
+ return type;
+ }
+
+ public void setType(LocalizedString type)
+ {
+ this.type = type;
+ }
+
+ public int compareTo(Object anotherResult) throws ClassCastException {
+ if (!(anotherResult instanceof Result))
+ {
+ throw new ClassCastException("Cannot mix Result with other stuff");
+ }
+ Result other = (Result)anotherResult;
+ float diff = other.getScore() - this.getScore();
+ if (diff == 0)
+ {
+ return 0;
+ }
+ else if (diff < 0)
+ {
+ return -1;
+ }
+ else
+ {
+ return 1;
+ }
+ }
}
Added:
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/result/impl/JSFPortletResultURL.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/result/impl/JSFPortletResultURL.java
(rev 0)
+++
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/result/impl/JSFPortletResultURL.java 2007-08-09
12:50:21 UTC (rev 7882)
@@ -0,0 +1,54 @@
+/******************************************************************************
+ * 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 java.util.Map;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class JSFPortletResultURL extends PortletResultURL
+{
+
+ private String viewId;
+
+ public JSFPortletResultURL(String windowRef, String viewId, Map renderParameters)
+ {
+ super(windowRef, renderParameters);
+ this.viewId = viewId;
+ }
+
+ public String getViewId()
+ {
+ return viewId;
+ }
+
+ public void setViewId(String viewId)
+ {
+ this.viewId = viewId;
+ }
+
+
+}
+
Added:
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/result/impl/PortletResultURL.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/result/impl/PortletResultURL.java
(rev 0)
+++
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/result/impl/PortletResultURL.java 2007-08-09
12:50:21 UTC (rev 7882)
@@ -0,0 +1,89 @@
+/******************************************************************************
+ * 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 java.util.HashMap;
+import java.util.Map;
+
+//import org.jboss.portal.core.controller.ControllerContext;
+import org.jboss.portal.search.result.ResultURL;
+//import org.jboss.portal.server.request.URLContext;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class PortletResultURL implements ResultURL
+{
+
+ private String windowRef;
+
+ private Map renderParameters;
+
+// private PortalObjectContainer portalObjectContainer;
+
+// private PortalNode portalNode;
+
+ public PortletResultURL(String windowRef, Map renderParameters)
+ {
+// this.portalObjectContainer = portalObjectContainer;
+// this.portalNode = portalNode;
+ this.windowRef = windowRef;
+ this.renderParameters = renderParameters;
+ if (renderParameters == null)
+ {
+ renderParameters = new HashMap();
+ }
+ }
+
+ public void addRenderParameter(String name, String value )
+ {
+ renderParameters.put(name, value);
+ }
+
+ public String getWindowRef()
+ {
+ return windowRef;
+ }
+
+ public Map getRenderParameters()
+ {
+ return renderParameters;
+ }
+
+ /*
+ public String getStringURL()
+ {
+ PortalObject targetPortalNode =
portalObjectContainer.getObject(PortalObjectId.parse(windowRef,
PortalObjectPath.CANONICAL_FORMAT));
+
+ return url.toString();
+ }
+ */
+ /*
+ public String getStringURL()
+ {
+
+ }
+ */
+}
+
Modified:
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/result/impl/SimpleResult.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/result/impl/SimpleResult.java 2007-08-09
12:45:50 UTC (rev 7881)
+++
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/result/impl/SimpleResult.java 2007-08-09
12:50:21 UTC (rev 7882)
@@ -30,7 +30,7 @@
{
private Object value;
-
+
public SimpleResult(String federatedId, Object value)
{
super(federatedId);
Modified:
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/result/impl/SimpleResultURL.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/result/impl/SimpleResultURL.java 2007-08-09
12:45:50 UTC (rev 7881)
+++
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/result/impl/SimpleResultURL.java 2007-08-09
12:50:21 UTC (rev 7882)
@@ -37,7 +37,7 @@
this.url = url;
}
- public String getURL()
+ public String getStringURL()
{
return url;
}
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-09
12:45:50 UTC (rev 7881)
+++
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/test/ConverterTest.java 2007-08-09
12:50:21 UTC (rev 7882)
@@ -22,25 +22,88 @@
******************************************************************************/
package org.jboss.portal.search.test;
+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.Query;
+import org.jboss.portal.search.QueryConversionException;
import org.jboss.portal.search.QueryConverter;
-import org.jboss.portal.search.query.Query;
-import org.jboss.portal.search.query.impl.KeywordQueryTerm;
+import org.jboss.portal.search.impl.QueryImpl;
+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 junit.framework.TestCase;
-
/**
* @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
* @version $Revision$
*/
public class ConverterTest extends TestCase
{
-
+/*
public void testOptionalKeyword()
{
Query query = QueryConverter.convert("test");
KeywordQueryTerm term = (KeywordQueryTerm)query.getOptionalTerms().get(0);
assertEquals("test", term.getKeyWord());
}
+*/
-
+ public void testJCRConverter()
+ {
+ org.apache.lucene.search.Query luceneQuery = new TermQuery(new Term("id",
"1"));
+ Query query = new LuceneQuery(luceneQuery);
+
+ 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());
+ }
+ catch (QueryConversionException e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ public void testJCRConverterMultipleTerms()
+ {
+ Query query = new QueryImpl("foo 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(., 'foo'), jcr:contains(.,
'bar')]", xpath.toString());
+ }
+ catch (QueryConversionException e)
+ {
+ e.printStackTrace();
+ }
+ }
+
}
Copied:
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/test/DummyFederatedSearch.java
(from rev 7815,
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/test/DummySearchFederated.java)
===================================================================
---
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/test/DummyFederatedSearch.java
(rev 0)
+++
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/test/DummyFederatedSearch.java 2007-08-09
12:50:21 UTC (rev 7882)
@@ -0,0 +1,91 @@
+/******************************************************************************
+ * 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.Locale;
+
+import org.jboss.portal.common.i18n.LocalizedString;
+import org.jboss.portal.search.FederatedIndexer;
+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.result.ResultSet;
+import org.jboss.portal.search.result.impl.SimpleResult;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class DummyFederatedSearch implements FederatedSearcher, FederatedIndexer
+{
+
+ private Info info;
+
+ public DummyFederatedSearch()
+ {
+ info = new Info();
+ }
+
+ public void createIndex() throws IndexingException
+ {
+ info.setStatus(Info.Status.STARTED);
+ // Do stuff in a thread
+ info.setStatus(Info.Status.AVAILABLE);
+ }
+
+ public void destroyIndex() throws IndexingException
+ {
+ info.setStatus(Info.Status.STOPPED);
+ }
+
+ public String getId()
+ {
+ return "DummySearchFederated";
+ }
+
+ public Info getInfo()
+ {
+ return info;
+ }
+
+ public String getMarkup(ResultSet results, int markupLevel)
+ {
+ return null;
+ }
+
+ public ResultSet search(Query query)
+ {
+ ResultSet results = new ResultSet(this);
+ results.add(new SimpleResult(getId(), "Result 1"));
+ results.add(new SimpleResult(getId(), "Result 2"));
+ results.add(new SimpleResult(getId(), "Result 3"));
+ return results;
+ }
+
+ public LocalizedString getDisplayName()
+ {
+ return null;
+ }
+
+}
Deleted:
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/test/DummySearchFederated.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/test/DummySearchFederated.java 2007-08-09
12:45:50 UTC (rev 7881)
+++
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/test/DummySearchFederated.java 2007-08-09
12:50:21 UTC (rev 7882)
@@ -1,89 +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.Locale;
-
-import org.jboss.portal.search.IndexingException;
-import org.jboss.portal.search.SearchFederated;
-import org.jboss.portal.search.federation.Info;
-import org.jboss.portal.search.query.Query;
-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 class DummySearchFederated implements SearchFederated
-{
-
- private Info info;
-
- public DummySearchFederated()
- {
- info = new Info();
- }
-
- public void create() throws IndexingException
- {
- info.setStatus(Info.Status.STARTED);
- info.setStatus(Info.Status.AVAILABLE);
- }
-
- public void destroy() throws IndexingException
- {
- info.setStatus(Info.Status.STOPPED);
- }
-
- public String getId()
- {
- return "DummySearchFederated";
- }
-
- public Info getInfo()
- {
- return info;
- }
-
- public String getMarkup(ResultSet results, int markupLevel)
- {
- return null;
- }
-
- public ResultSet search(Query query)
- {
- ResultSet results = new ResultSet(this);
- results.add(new SimpleResult(getId(), "Result 1"));
- results.add(new SimpleResult(getId(), "Result 2"));
- results.add(new SimpleResult(getId(), "Result 3"));
- return results;
- }
-
- public String getName(Locale locale)
- {
- // TODO Auto-generated method stub
- return null;
- }
-
-}
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-09
12:45:50 UTC (rev 7881)
+++
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/test/FederationTest.java 2007-08-09
12:50:21 UTC (rev 7882)
@@ -24,10 +24,15 @@
import java.util.List;
+import org.apache.lucene.index.Term;
+import org.apache.lucene.search.TermQuery;
+import org.jboss.portal.search.Query;
+import org.jboss.portal.search.SearchingException;
+import org.jboss.portal.search.federation.IndexFederation;
import org.jboss.portal.search.federation.SearchFederation;
+import org.jboss.portal.search.federation.impl.IndexFederationService;
import org.jboss.portal.search.federation.impl.SearchFederationService;
-import org.jboss.portal.search.query.Query;
-import org.jboss.portal.search.query.impl.FieldQueryTerm;
+import org.jboss.portal.search.impl.lucene.LuceneQuery;
import org.jboss.portal.search.result.ResultSet;
import org.jboss.portal.search.result.impl.SimpleResult;
@@ -39,17 +44,20 @@
*/
public class FederationTest extends TestCase
{
- public void test01()
+ public void test01() throws SearchingException
{
- SearchFederation federation = new SearchFederationService();
- DummySearchFederated federated = new DummySearchFederated();
- federation.register(federated);
- federation.reindexAll();
+ SearchFederation searchfederation = new SearchFederationService();
+ DummyFederatedSearch federatedSearch = new DummyFederatedSearch();
+ searchfederation.register(federatedSearch);
- Query query = new Query();
- query.addMandatoryTerm(new FieldQueryTerm("id", "1"));
+ IndexFederation indexfederation = new IndexFederationService();
+ indexfederation.register(federatedSearch);
+ indexfederation.reindexAll();
- List list = federation.search(query);
+ org.apache.lucene.search.Query luceneQuery = new TermQuery(new Term("id",
"1"));
+ Query query = new LuceneQuery(luceneQuery);
+
+ List list = searchfederation.search(query);
ResultSet results = (ResultSet)list.get(0);
assertEquals("Result 1",
(((SimpleResult)results.getResult(0)).getValue()));
assertEquals("Result 2",
(((SimpleResult)results.getResult(1)).getValue()));
Modified:
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-09
12:45:50 UTC (rev 7881)
+++
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/test/LuceneQueryTest.java 2007-08-09
12:50:21 UTC (rev 7882)
@@ -22,14 +22,6 @@
******************************************************************************/
package org.jboss.portal.search.test;
-import org.jboss.portal.search.IndexingException;
-import org.jboss.portal.search.federated.lucene.LuceneQueryConverter;
-import org.jboss.portal.search.federated.lucene.LuceneSearchFederated;
-import org.jboss.portal.search.query.Query;
-import org.jboss.portal.search.query.impl.BetweenDatesTerm;
-import org.jboss.portal.search.query.impl.FieldQueryTerm;
-import org.jboss.portal.search.result.ResultSet;
-
import junit.framework.TestCase;
/**
@@ -39,6 +31,7 @@
public class LuceneQueryTest extends TestCase
{
+ /*
public void test01()
{
Query query = new Query();
@@ -67,5 +60,5 @@
System.out.println(fed.getMarkup(results, 0));
assertEquals("Id:1 Id:1 cat ", fed.getMarkup(results, 0));
}
-
+ */
}
Modified:
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-09
12:45:50 UTC (rev 7881)
+++
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/test/TestLuceneSearchFederated.java 2007-08-09
12:50:21 UTC (rev 7882)
@@ -28,7 +28,8 @@
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
-import org.jboss.portal.search.federated.lucene.LuceneSearchFederated;
+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>
@@ -62,7 +63,7 @@
return null;
}
- public String getName(Locale locale)
+ public LocalizedString getDisplayName()
{
// TODO Auto-generated method stub
return null;