Author: glandais Date: 2008-02-25 09:30:34 +0000 (Mon, 25 Feb 2008) New Revision: 1227 Added: trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/SearchColumn.java Modified: trunk/simexplorer-is/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/MockStorageServiceImpl.java trunk/simexplorer-is/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/StorageService.java trunk/simexplorer-is/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/StorageServiceCommon.java trunk/simexplorer-is/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/storage/engine/StorageEngineSecuImpl.java trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/SortColumn.java trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/database/Database.java trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/database/lucene/LuceneDatabase.java trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/engine/StorageEngine.java trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/engine/StorageEngineImpl.java trunk/simexplorer-is/simexplorer-is-storage/src/test/fr/cemagref/simexplorer/is/storage/database/lucene/LuceneDatabaseLoadMassTestCase.java trunk/simexplorer-is/simexplorer-is-storage/src/test/fr/cemagref/simexplorer/is/storage/database/lucene/LuceneDatabaseTestCase.java trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/StorageServiceHelper.java trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/grid/ElementDataSource.java Log: Search by column Modified: trunk/simexplorer-is/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/MockStorageServiceImpl.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/MockStorageServiceImpl.java 2008-02-25 09:07:57 UTC (rev 1226) +++ trunk/simexplorer-is/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/MockStorageServiceImpl.java 2008-02-25 09:30:34 UTC (rev 1227) @@ -109,12 +109,12 @@ return null; } - public int findFullTextCount(String token, String query, boolean onlyLatest) throws SimExplorerException { + public int findFullTextCount(String token, String query,String queryColumn, boolean onlyLatest) throws SimExplorerException { // TODO Changer return findApplicationsCount(token, onlyLatest); } - public MetaData[] findFullText(String token, String query, boolean onlyLatest, int indexStart, int count, + public MetaData[] findFullText(String token, String query, String queryColumn, boolean onlyLatest, int indexStart, int count, String column, boolean ascending) throws SimExplorerException { // TODO Changer Modified: trunk/simexplorer-is/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/StorageService.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/StorageService.java 2008-02-25 09:07:57 UTC (rev 1226) +++ trunk/simexplorer-is/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/StorageService.java 2008-02-25 09:30:34 UTC (rev 1227) @@ -212,12 +212,14 @@ * @param token the token * @param query the query * @param onlyLatest the only latest + * @param queryColumn the query column * * @return the int * * @throws SimExplorerException the sim explorer service exception */ - int findFullTextCount(String token, String query, boolean onlyLatest) throws SimExplorerException; + int findFullTextCount(String token, String query, String queryColumn, boolean onlyLatest) + throws SimExplorerException; /** * Find elements matching query. @@ -227,15 +229,16 @@ * @param onlyLatest the only latest * @param indexStart the index start * @param count the count - * @param column the column * @param ascending the ascending + * @param queryColumn the query column + * @param sortColumn the sort column * * @return the meta data[] * * @throws SimExplorerException the sim explorer service exception */ - MetaData[] findFullText(String token, String query, boolean onlyLatest, int indexStart, int count, String column, boolean ascending) - throws SimExplorerException; + MetaData[] findFullText(String token, String query, String queryColumn, boolean onlyLatest, int indexStart, + int count, String sortColumn, boolean ascending) throws SimExplorerException; /** * Retrieve number of applications. Modified: trunk/simexplorer-is/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/StorageServiceCommon.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/StorageServiceCommon.java 2008-02-25 09:07:57 UTC (rev 1226) +++ trunk/simexplorer-is/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/StorageServiceCommon.java 2008-02-25 09:30:34 UTC (rev 1227) @@ -52,6 +52,7 @@ import fr.cemagref.simexplorer.is.exceptions.SimExplorerException; import fr.cemagref.simexplorer.is.exceptions.SimExplorerTechnicalException; import fr.cemagref.simexplorer.is.factories.LoggableElementFactory; +import fr.cemagref.simexplorer.is.storage.SearchColumn; import fr.cemagref.simexplorer.is.storage.SortColumn; import fr.cemagref.simexplorer.is.storage.SortOrder; import fr.cemagref.simexplorer.is.storage.engine.StorageEngine; @@ -147,10 +148,10 @@ * * @return the column */ - private SortColumn getColumn(String column) { + private SortColumn getSortColumn(String column) { SortColumn sortColumn; try { - sortColumn = SortColumn.valueOf(column); + sortColumn = SortColumn.valueOf(column); } catch (Exception e) { sortColumn = SortColumn.None; } @@ -158,6 +159,23 @@ } /** + * Gets the query column. + * + * @param column the column + * + * @return the query column + */ + private SearchColumn getQueryColumn(String column) { + SearchColumn searchColumn; + try { + searchColumn = SearchColumn.valueOf(column); + } catch (Exception e) { + searchColumn = SearchColumn.AllFields; + } + return searchColumn; + } + + /** * Gets the order. * * @param ascending the ascending @@ -174,17 +192,18 @@ /* (non-Javadoc) * @see fr.cemagref.simexplorer.is.service.StorageService#findFullText(java.lang.String, java.lang.String, boolean, int, int, int) */ - public MetaData[] findFullText(String token, String query, boolean onlyLatest, int indexStart, int count, - String column, boolean ascending) throws SimExplorerException { - return getStorageEngine().findFullText(token, query, onlyLatest, indexStart, count, getColumn(column), - getOrder(ascending)); + public MetaData[] findFullText(String token, String query, String queryColumn, boolean onlyLatest, int indexStart, + int count, String column, boolean ascending) throws SimExplorerException { + return getStorageEngine().findFullText(token, query, getQueryColumn(queryColumn), onlyLatest, indexStart, + count, getSortColumn(column), getOrder(ascending)); } /* (non-Javadoc) * @see fr.cemagref.simexplorer.is.service.StorageService#findFullTextCount(java.lang.String, java.lang.String, boolean) */ - public int findFullTextCount(String token, String query, boolean onlyLatest) throws SimExplorerException { - return getStorageEngine().findFullTextCount(token, query, onlyLatest); + public int findFullTextCount(String token, String query, String queryColumn, boolean onlyLatest) + throws SimExplorerException { + return getStorageEngine().findFullTextCount(token, query, getQueryColumn(queryColumn), onlyLatest); } /* (non-Javadoc) @@ -201,7 +220,7 @@ public MetaData[] findApplications(String token, boolean onlyLatest, int start, int count, String column, boolean ascending) throws SimExplorerException { return getStorageEngine().findElementsByType(token, ExplorationApplication.class.getCanonicalName(), - onlyLatest, start, count, getColumn(column), getOrder(ascending)); + onlyLatest, start, count, getSortColumn(column), getOrder(ascending)); } /* (non-Javadoc) @@ -386,7 +405,8 @@ List<LoggableElement> children = loggableElement.getChildren(); // TODO a valider : (fixbug: ajouter les attachments du le aussi) for (Attachment attachment : loggableElement.getAttachments()) { - files.put(FILE_DATA_PREFIX + FOLDER_SEPARATOR + attachment.getUniqueId(), getStorageEngine().retrieveData(token, loggableElement.getMetaData(), attachment)); + files.put(FILE_DATA_PREFIX + FOLDER_SEPARATOR + attachment.getUniqueId(), getStorageEngine().retrieveData( + token, loggableElement.getMetaData(), attachment)); } for (LoggableElement child : children) { List<Attachment> attachments = child.getAttachments(); Modified: trunk/simexplorer-is/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/storage/engine/StorageEngineSecuImpl.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/storage/engine/StorageEngineSecuImpl.java 2008-02-25 09:07:57 UTC (rev 1226) +++ trunk/simexplorer-is/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/storage/engine/StorageEngineSecuImpl.java 2008-02-25 09:30:34 UTC (rev 1227) @@ -34,6 +34,7 @@ import fr.cemagref.simexplorer.is.exceptions.SimExplorerTechnicalException; import fr.cemagref.simexplorer.is.security.credentials.CredentialManager; import fr.cemagref.simexplorer.is.security.entities.Permission; +import fr.cemagref.simexplorer.is.storage.SearchColumn; import fr.cemagref.simexplorer.is.storage.SortColumn; import fr.cemagref.simexplorer.is.storage.SortOrder; @@ -101,11 +102,11 @@ * @see fr.cemagref.simexplorer.is.storage.engine.StorageEngineImpl#findFullText(java.lang.String, java.lang.String, boolean, int, int, int) */ @Override - public MetaData[] findFullText(String token, String query, boolean onlyLatest, int indexStart, int count, - SortColumn column, SortOrder sortOrder) throws SimExplorerException { + public MetaData[] findFullText(String token, String query, SearchColumn searchColumn, boolean onlyLatest, + int indexStart, int count, SortColumn column, SortOrder sortOrder) throws SimExplorerException { String userFilter = getUserFilter(token); - List<MetaData> elements = database.findElementsByContentSearch(query, onlyLatest, indexStart, count, column, - sortOrder, userFilter); + List<MetaData> elements = database.findElementsByContentSearch(query, searchColumn, onlyLatest, indexStart, + count, column, sortOrder, userFilter); return convertList(elements); } @@ -113,9 +114,10 @@ * @see fr.cemagref.simexplorer.is.storage.engine.StorageEngineImpl#findFullTextCount(java.lang.String, java.lang.String, boolean) */ @Override - public int findFullTextCount(String token, String query, boolean onlyLatest) throws SimExplorerException { + public int findFullTextCount(String token, String query, SearchColumn searchColumn, boolean onlyLatest) + throws SimExplorerException { String userFilter = getUserFilter(token); - return database.findElementsByContentSearchCount(query, onlyLatest, userFilter); + return database.findElementsByContentSearchCount(query, searchColumn, onlyLatest, userFilter); } /** Added: trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/SearchColumn.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/SearchColumn.java (rev 0) +++ trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/SearchColumn.java 2008-02-25 09:30:34 UTC (rev 1227) @@ -0,0 +1,59 @@ +/* +* ##% Copyright (C) 2008 Code Lutin, Gabriel Landais +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program 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 General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +* ##% */ +package fr.cemagref.simexplorer.is.storage; + +import fr.cemagref.simexplorer.is.storage.database.DatabaseConstants; + +/** + * The Enum SearchColumn. + */ +public enum SearchColumn { + + /** The All fields. */ + AllFields(DatabaseConstants.KEY_SEARCHABLE_CONTENT), + + /** The Name. */ + Name(DatabaseConstants.KEY_SEARCHABLE_CONTENT), + + /** The Description. */ + Description(DatabaseConstants.KEY_SEARCHABLE_CONTENT), + + /** The Descriptors. */ + Descriptors(DatabaseConstants.KEY_SEARCHABLE_CONTENT); + + /** The column. */ + private String column; + + /** + * Gets the column. + * + * @return the column + */ + public String getColumn() { + return column; + } + + /** + * Instantiates a new searchable column. + * + * @param column the column + */ + private SearchColumn(String column) { + this.column = column; + } +} Modified: trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/SortColumn.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/SortColumn.java 2008-02-25 09:07:57 UTC (rev 1226) +++ trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/SortColumn.java 2008-02-25 09:30:34 UTC (rev 1227) @@ -10,17 +10,17 @@ public enum SortColumn { /** None. */ None("", 0), - /** The Date. */ + /** The Id. */ uuid(DatabaseConstants.KEY_UUID, SortField.STRING), - /** The Date. */ + /** The Version. */ version(DatabaseConstants.KEY_VERSION, SortField.STRING), - /** The Date. */ + /** The Name. */ name(DatabaseConstants.KEY_NAME, SortField.STRING), - /** The Date. */ + /** The Description. */ description(DatabaseConstants.KEY_DESCRIPTION, SortField.STRING), /** The Date. */ creationDate(DatabaseConstants.KEY_CREATIONDATE, SortField.LONG), - /** The Date. */ + /** The Class name. */ elementClass(DatabaseConstants.KEY_CLASSNAME, SortField.STRING); /** The column. */ Modified: trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/database/Database.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/database/Database.java 2008-02-25 09:07:57 UTC (rev 1226) +++ trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/database/Database.java 2008-02-25 09:30:34 UTC (rev 1227) @@ -27,6 +27,7 @@ import fr.cemagref.simexplorer.is.entities.metadata.Version; import fr.cemagref.simexplorer.is.exceptions.SimExplorerException; import fr.cemagref.simexplorer.is.exceptions.SimExplorerTechnicalException; +import fr.cemagref.simexplorer.is.storage.SearchColumn; import fr.cemagref.simexplorer.is.storage.SortColumn; import fr.cemagref.simexplorer.is.storage.SortOrder; @@ -170,19 +171,21 @@ * @param start Index of first element returned * @param count Number of elements to return * @param sortOrder the order - * @param column the column + * @param sortColumn the sort column + * @param userFilter the user filter * * @return Element list * * @throws SimExplorerException the sim explorer storage exception */ public abstract List<MetaData> findElementsByProperties(Map<String, String> properties, int start, int count, - SortColumn column, SortOrder sortOrder, String userFilter) throws SimExplorerException; + SortColumn sortColumn, SortOrder sortOrder, String userFilter) throws SimExplorerException; /** * Retrieve element count specific properties. * * @param properties Matching properties needed + * @param userFilter the user filter * * @return Number of elements fund * @@ -215,16 +218,16 @@ * @param onlyLatest Only latest elements * @param start Start index * @param count Number of documents - * @param column the column * @param sortOrder the sort order + * @param sortColumn the sort column * * @return Element list * * @throws SimExplorerException the sim explorer storage exception */ - public List<MetaData> findElementsByType(String type, boolean onlyLatest, int start, int count, SortColumn column, + public List<MetaData> findElementsByType(String type, boolean onlyLatest, int start, int count, SortColumn sortColumn, SortOrder sortOrder) throws SimExplorerException { - return findElementsByType(type, onlyLatest, start, count, column, sortOrder, null); + return findElementsByType(type, onlyLatest, start, count, sortColumn, sortOrder, null); } /** @@ -234,17 +237,17 @@ * @param onlyLatest the only latest * @param start the start * @param count the count - * @param column the column * @param sortOrder the sort order - * @param elementsVisible the elements visible + * @param sortColumn the sort column + * @param user the user * * @return the list< meta data> * * @throws SimExplorerException the sim explorer exception */ - public List<MetaData> findElementsByType(String type, boolean onlyLatest, int start, int count, SortColumn column, + public List<MetaData> findElementsByType(String type, boolean onlyLatest, int start, int count, SortColumn sortColumn, SortOrder sortOrder, String user) throws SimExplorerException { - return findElementsByProperties(getPropertiesByType(type, onlyLatest), start, count, column, sortOrder, user); + return findElementsByProperties(getPropertiesByType(type, onlyLatest), start, count, sortColumn, sortOrder, user); } /** @@ -284,15 +287,17 @@ * @param onlyLatest the only latest * @param start Index of first element returned * @param count Number of elements to return - * @param column the column * @param sortOrder the sort order + * @param searchColumn the search column + * @param sortColumn the sort column + * @param userFilter the user filter * * @return Element list * * @throws SimExplorerException the sim explorer storage exception */ - public abstract List<MetaData> findElementsByContentSearch(String queryText, boolean onlyLatest, int start, - int count, SortColumn column, SortOrder sortOrder, String userFilter) throws SimExplorerException; + public abstract List<MetaData> findElementsByContentSearch(String queryText, SearchColumn searchColumn, boolean onlyLatest, int start, + int count, SortColumn sortColumn, SortOrder sortOrder, String userFilter) throws SimExplorerException; /** * Find elements by content search. @@ -301,16 +306,17 @@ * @param onlyLatest the only latest * @param start the start * @param count the count - * @param column the column * @param sortOrder the sort order + * @param searchColumn the search column + * @param sortColumn the sort column * * @return the list< meta data> * * @throws SimExplorerException the sim explorer exception */ - public List<MetaData> findElementsByContentSearch(String queryText, boolean onlyLatest, int start, int count, - SortColumn column, SortOrder sortOrder) throws SimExplorerException { - return findElementsByContentSearch(queryText, onlyLatest, start, count, column, sortOrder, null); + public List<MetaData> findElementsByContentSearch(String queryText, SearchColumn searchColumn, boolean onlyLatest, int start, int count, + SortColumn sortColumn, SortOrder sortOrder) throws SimExplorerException { + return findElementsByContentSearch(queryText, searchColumn, onlyLatest, start, count, sortColumn, sortOrder, null); } /** @@ -318,12 +324,14 @@ * * @param queryText Searched text * @param onlyLatest the only latest + * @param userFilter the user filter + * @param searchColumn the search column * * @return Number of elements fund * * @throws SimExplorerException the sim explorer storage exception */ - public abstract int findElementsByContentSearchCount(String queryText, boolean onlyLatest, String userFilter) + public abstract int findElementsByContentSearchCount(String queryText, SearchColumn searchColumn, boolean onlyLatest, String userFilter) throws SimExplorerException; /** @@ -331,13 +339,14 @@ * * @param queryText the query text * @param onlyLatest the only latest + * @param searchColumn the search column * * @return the int * * @throws SimExplorerException the sim explorer exception */ - public int findElementsByContentSearchCount(String queryText, boolean onlyLatest) throws SimExplorerException { - return findElementsByContentSearchCount(queryText, onlyLatest, null); + public int findElementsByContentSearchCount(String queryText, SearchColumn searchColumn, boolean onlyLatest) throws SimExplorerException { + return findElementsByContentSearchCount(queryText, searchColumn, onlyLatest, null); } /** @@ -345,7 +354,8 @@ * * @param userFilter the user filter * @param visibleItems the visible items - * @throws SimExplorerTechnicalException + * + * @throws SimExplorerTechnicalException the sim explorer technical exception */ public abstract void updateFilter(String userFilter, Collection<String> visibleItems) throws SimExplorerTechnicalException; Modified: trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/database/lucene/LuceneDatabase.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/database/lucene/LuceneDatabase.java 2008-02-25 09:07:57 UTC (rev 1226) +++ trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/database/lucene/LuceneDatabase.java 2008-02-25 09:30:34 UTC (rev 1227) @@ -44,7 +44,6 @@ import org.apache.lucene.search.BooleanClause; import org.apache.lucene.search.BooleanQuery; import org.apache.lucene.search.Filter; -import org.apache.lucene.search.HitCollector; import org.apache.lucene.search.Hits; import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.Query; @@ -61,6 +60,7 @@ import fr.cemagref.simexplorer.is.entities.metadata.Version; import fr.cemagref.simexplorer.is.exceptions.SimExplorerException; import fr.cemagref.simexplorer.is.exceptions.SimExplorerTechnicalException; +import fr.cemagref.simexplorer.is.storage.SearchColumn; import fr.cemagref.simexplorer.is.storage.SortColumn; import fr.cemagref.simexplorer.is.storage.SortOrder; import fr.cemagref.simexplorer.is.storage.database.Database; @@ -622,11 +622,11 @@ * @see fr.cemagref.simexplorer.is.storage.database.Database#findElementsByContentSearchCount(java.lang.String, boolean) */ @Override - public int findElementsByContentSearchCount(String queryText, boolean onlyLatest, String userFilter) + public int findElementsByContentSearchCount(String queryText, SearchColumn column, boolean onlyLatest, String userFilter) throws SimExplorerException { Query query; try { - query = getQueryByContentSearch(queryText, onlyLatest); + query = getQueryByContentSearch(queryText, column, onlyLatest); } catch (ParseException e) { throw new SimExplorerTechnicalException(e); } @@ -656,11 +656,11 @@ * @see fr.cemagref.simexplorer.is.storage.database.Database#findElementsByContentSearch(java.lang.String, boolean, int, int, int) */ @Override - public List<MetaData> findElementsByContentSearch(String queryText, boolean onlyLatest, int start, int count, - SortColumn column, SortOrder sortOrder, String userFilter) throws SimExplorerException { + public List<MetaData> findElementsByContentSearch(String queryText, SearchColumn searchColumn, boolean onlyLatest, int start, int count, + SortColumn sortColumn, SortOrder sortOrder, String userFilter) throws SimExplorerException { Query query; try { - query = getQueryByContentSearch(queryText, onlyLatest); + query = getQueryByContentSearch(queryText, searchColumn, onlyLatest); } catch (ParseException e) { throw new SimExplorerTechnicalException(e); } @@ -672,7 +672,7 @@ // Get current searcher instance Searcher searcher = getSearcher(); try { - hits = filterSearch(searcher, query, userFilter, getSortDate(column, sortOrder)); + hits = filterSearch(searcher, query, userFilter, getSortDate(sortColumn, sortOrder)); // Convert hits to elements result = convertHitsToElements(hits, start, count); } finally { @@ -725,12 +725,12 @@ * * @throws ParseException the parse exception */ - private Query getQueryByContentSearch(String queryText, boolean onlyLatest) throws ParseException { + private Query getQueryByContentSearch(String queryText, SearchColumn column, boolean onlyLatest) throws ParseException { Query query; // Create an analyzer for query parsing Analyzer analyzer = new SimpleAnalyzer(); // Create an parser to handle query - QueryParser parser = new QueryParser(KEY_SEARCHABLE_CONTENT, analyzer); + QueryParser parser = new QueryParser(column.getColumn(), analyzer); // Parse query Query searchQuery = parser.parse(queryText); Modified: trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/engine/StorageEngine.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/engine/StorageEngine.java 2008-02-25 09:07:57 UTC (rev 1226) +++ trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/engine/StorageEngine.java 2008-02-25 09:30:34 UTC (rev 1227) @@ -27,6 +27,7 @@ import fr.cemagref.simexplorer.is.entities.metadata.MetaData; import fr.cemagref.simexplorer.is.entities.metadata.Version; import fr.cemagref.simexplorer.is.exceptions.SimExplorerException; +import fr.cemagref.simexplorer.is.storage.SearchColumn; import fr.cemagref.simexplorer.is.storage.SortColumn; import fr.cemagref.simexplorer.is.storage.SortOrder; @@ -227,12 +228,13 @@ * @param query the query * @param onlyLatest the only latest * @param token the token + * @param searchColumn the search column * * @return the int * * @throws SimExplorerException the sim explorer storage exception */ - public abstract int findFullTextCount(String token, String query, boolean onlyLatest) throws SimExplorerException; + public abstract int findFullTextCount(String token, String query, SearchColumn searchColumn, boolean onlyLatest) throws SimExplorerException; /** * Retrieve list of items corresponding to query. @@ -242,15 +244,16 @@ * @param indexStart the index start * @param count the count * @param token the token - * @param column the column * @param sortOrder the sort order + * @param searchColumn the search column + * @param sortColumn the sort column * * @return the meta data[] * * @throws SimExplorerException the sim explorer storage exception */ - public abstract MetaData[] findFullText(String token, String query, boolean onlyLatest, int indexStart, int count, - SortColumn column, SortOrder sortOrder) throws SimExplorerException; + public abstract MetaData[] findFullText(String token, String query, SearchColumn searchColumn, boolean onlyLatest, int indexStart, int count, + SortColumn sortColumn, SortOrder sortOrder) throws SimExplorerException; /** * Retrieve list of items of type wanted. Modified: trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/engine/StorageEngineImpl.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/engine/StorageEngineImpl.java 2008-02-25 09:07:57 UTC (rev 1226) +++ trunk/simexplorer-is/simexplorer-is-storage/src/java/fr/cemagref/simexplorer/is/storage/engine/StorageEngineImpl.java 2008-02-25 09:30:34 UTC (rev 1227) @@ -33,6 +33,7 @@ import fr.cemagref.simexplorer.is.entities.metadata.Version; import fr.cemagref.simexplorer.is.exceptions.SimExplorerException; import fr.cemagref.simexplorer.is.exceptions.SimExplorerTechnicalException; +import fr.cemagref.simexplorer.is.storage.SearchColumn; import fr.cemagref.simexplorer.is.storage.SortColumn; import fr.cemagref.simexplorer.is.storage.SortOrder; import fr.cemagref.simexplorer.is.storage.attachment.AttachmentHandler; @@ -278,16 +279,16 @@ /* (non-Javadoc) * @see fr.cemagref.simexplorer.is.storage.engine.StorageEngine#findFullTextCount(java.lang.String, boolean) */ - public int findFullTextCount(String token, String query, boolean onlyLatest) throws SimExplorerException { - return database.findElementsByContentSearchCount(query, onlyLatest); + public int findFullTextCount(String token, String query, SearchColumn searchColumn, boolean onlyLatest) throws SimExplorerException { + return database.findElementsByContentSearchCount(query, searchColumn, onlyLatest); } /* (non-Javadoc) * @see fr.cemagref.simexplorer.is.storage.engine.StorageEngine#findFullText(java.lang.String, boolean, int, int, int) */ - public MetaData[] findFullText(String token, String query, boolean onlyLatest, int indexStart, int count, + public MetaData[] findFullText(String token, String query, SearchColumn searchColumn, boolean onlyLatest, int indexStart, int count, SortColumn column, SortOrder sortOrder) throws SimExplorerException { - List<MetaData> elements = database.findElementsByContentSearch(query, onlyLatest, indexStart, count, column, + List<MetaData> elements = database.findElementsByContentSearch(query, searchColumn, onlyLatest, indexStart, count, column, sortOrder); return convertList(elements); } Modified: trunk/simexplorer-is/simexplorer-is-storage/src/test/fr/cemagref/simexplorer/is/storage/database/lucene/LuceneDatabaseLoadMassTestCase.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-storage/src/test/fr/cemagref/simexplorer/is/storage/database/lucene/LuceneDatabaseLoadMassTestCase.java 2008-02-25 09:07:57 UTC (rev 1226) +++ trunk/simexplorer-is/simexplorer-is-storage/src/test/fr/cemagref/simexplorer/is/storage/database/lucene/LuceneDatabaseLoadMassTestCase.java 2008-02-25 09:30:34 UTC (rev 1227) @@ -27,6 +27,7 @@ import junit.framework.TestCase; import fr.cemagref.simexplorer.is.entities.metadata.MetaData; import fr.cemagref.simexplorer.is.storage.MetaDataGenerator; +import fr.cemagref.simexplorer.is.storage.SearchColumn; import fr.cemagref.simexplorer.is.storage.SortColumn; import fr.cemagref.simexplorer.is.storage.SortOrder; import fr.cemagref.simexplorer.is.storage.database.Database; @@ -61,8 +62,7 @@ /** * Generate string. * - * @param length - * the length + * @param length the length * * @return the string */ @@ -101,8 +101,7 @@ /** * Instantiates a new lucene database load mass test case. * - * @param name - * the name + * @param name the name */ public LuceneDatabaseLoadMassTestCase(String name) { super(name); @@ -132,8 +131,7 @@ /** * Test mass insert. * - * @throws Exception - * the exception + * @throws Exception the exception */ public void testMassInsert() throws Exception { database.open(true); @@ -171,12 +169,9 @@ Date end = new Date(); long time = end.getTime() - begin.getTime(); - System.out.println("Insert " + i + " : Time taken : " + time - + "ms"); + System.out.println("Insert " + i + " : Time taken : " + time + "ms"); double timePerElement = time / (4 * i); - System.out.println("Insert " + i - + " : Time taken per element : " + timePerElement - + "ms"); + System.out.println("Insert " + i + " : Time taken per element : " + timePerElement + "ms"); System.out.println("Content size : " + contentSize); } @@ -188,16 +183,14 @@ long time = end.getTime() - begin.getTime(); System.out.println("Insert : Time taken : " + time + "ms"); double timePerElement = time / (4 * c); - System.out.println("Insert : Time taken per element : " - + timePerElement + "ms"); + System.out.println("Insert : Time taken per element : " + timePerElement + "ms"); System.out.println("Content size : " + contentSize); } /** * Test mass search paginated. * - * @throws Exception - * the exception + * @throws Exception the exception */ public void testMassSearchPaginated() throws Exception { database.open(); @@ -209,25 +202,23 @@ for (int i = 0; i < csearch; i++) { String key = randomstrings[r.nextInt(randomstrings.length)] + "*"; - int count = database.findElementsByContentSearchCount(key, false); + int count = database.findElementsByContentSearchCount(key, SearchColumn.AllFields, false); System.out.println(key + " : " + count); int start = count / 2; int length = Math.min(200, Math.min(count, Math.max(1, count / 4))); - List<MetaData> metaDatas = database.findElementsByContentSearch(key, - false, start, length, SortColumn.None, SortOrder.Ascending); + List<MetaData> metaDatas = database.findElementsByContentSearch(key, SearchColumn.AllFields, false, start, + length, SortColumn.None, SortOrder.Ascending); - System.out.println(key + " (" + start + " " + length + ") : " - + metaDatas.size()); + System.out.println(key + " (" + start + " " + length + ") : " + metaDatas.size()); } Date end = new Date(); long time = end.getTime() - begin.getTime(); System.out.println("Search : Time taken : " + time + "ms"); double timePerElement = time / csearch; - System.out.println("Search : Time taken per element : " - + timePerElement + "ms"); + System.out.println("Search : Time taken per element : " + timePerElement + "ms"); } } Modified: trunk/simexplorer-is/simexplorer-is-storage/src/test/fr/cemagref/simexplorer/is/storage/database/lucene/LuceneDatabaseTestCase.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-storage/src/test/fr/cemagref/simexplorer/is/storage/database/lucene/LuceneDatabaseTestCase.java 2008-02-25 09:07:57 UTC (rev 1226) +++ trunk/simexplorer-is/simexplorer-is-storage/src/test/fr/cemagref/simexplorer/is/storage/database/lucene/LuceneDatabaseTestCase.java 2008-02-25 09:30:34 UTC (rev 1227) @@ -32,6 +32,7 @@ import fr.cemagref.simexplorer.is.entities.metadata.MetaData; import fr.cemagref.simexplorer.is.entities.metadata.Version; import fr.cemagref.simexplorer.is.storage.MetaDataGenerator; +import fr.cemagref.simexplorer.is.storage.SearchColumn; import fr.cemagref.simexplorer.is.storage.database.Database; import fr.cemagref.simexplorer.is.storage.util.Config; @@ -41,8 +42,7 @@ public class LuceneDatabaseTestCase extends TestCase { /** The Constant log. */ - private static final Log log = LogFactory - .getLog(LuceneDatabaseTestCase.class); + private static final Log log = LogFactory.getLog(LuceneDatabaseTestCase.class); /** The database. */ private Database database; @@ -77,8 +77,7 @@ /** * Test insert element get element. * - * @throws Exception - * the exception + * @throws Exception the exception */ public void testInsertElementGetElement() throws Exception { MetaData me = mdg.generateMetaDataEntity(); @@ -93,16 +92,14 @@ /** * Test index add find elements by content search. * - * @throws Exception - * the exception + * @throws Exception the exception */ public void testIndexAddFindElementsByContentSearch() throws Exception { MetaData me = mdg.generateMetaDataEntity(); String keyphrase = Long.toHexString(r.nextLong()); - StringReader reader = new StringReader("ogijeriog ergijergioj " - + keyphrase + " egiojergij ergijerogij"); + StringReader reader = new StringReader("ogijeriog ergijergioj " + keyphrase + " egiojergij ergijerogij"); List<Reader> readers = new ArrayList<Reader>(); readers.add(reader); @@ -110,8 +107,7 @@ database.insertElement(me, readers); database.commit(); - int mesCount = database.findElementsByContentSearchCount(keyphrase, - true); + int mesCount = database.findElementsByContentSearchCount(keyphrase, SearchColumn.AllFields, true); assertEquals(1, mesCount); } @@ -119,8 +115,7 @@ /** * Test get versions. * - * @throws Exception - * the exception + * @throws Exception the exception */ public void testGetVersions() throws Exception { MetaData[] mes = mdg.generateVersionnedMetaDataEntity(); @@ -141,8 +136,7 @@ /** * Test find elements by id. * - * @throws Exception - * the exception + * @throws Exception the exception */ public void testFindElementsById() throws Exception { MetaData[] mes = mdg.generateVersionnedMetaDataEntity(); @@ -151,16 +145,14 @@ } database.commit(); - List<MetaData> elements = database.findElementsById(mes[0].getUuid(), - false); + List<MetaData> elements = database.findElementsById(mes[0].getUuid(), false); assertEquals(elements.size(), mes.length); } /** * Test find elements by properties. * - * @throws Exception - * the exception + * @throws Exception the exception */ public void testFindElementsByProperties() throws Exception { MetaData me = mdg.generateMetaDataEntity(); Modified: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/StorageServiceHelper.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/StorageServiceHelper.java 2008-02-25 09:07:57 UTC (rev 1226) +++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/StorageServiceHelper.java 2008-02-25 09:30:34 UTC (rev 1227) @@ -83,7 +83,7 @@ if (query == null || query.isEmpty()) { size = service.findApplicationsCount(token, onlyLatest); } else { - size = service.findFullTextCount(token, query, onlyLatest); + size = service.findFullTextCount(token, query, "", onlyLatest); } return size; } catch (SimExplorerException e) { @@ -110,7 +110,7 @@ if (query == null || query.isEmpty()) { data = service.findApplications(token, onlyLatest, (int) newFirstIndex, width, column, ascending); } else { - data = service.findFullText(token, query, onlyLatest, (int) newFirstIndex, width, column, ascending); + data = service.findFullText(token, query, "", onlyLatest, (int) newFirstIndex, width, column, ascending); } return data; } catch (SimExplorerException e) { Modified: trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/grid/ElementDataSource.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/grid/ElementDataSource.java 2008-02-25 09:07:57 UTC (rev 1226) +++ trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/grid/ElementDataSource.java 2008-02-25 09:30:34 UTC (rev 1227) @@ -64,7 +64,7 @@ if (query == null) { result = RemoteStorageService.getStorageService().findApplicationsCount(token, true); } else { - result = RemoteStorageService.getStorageService().findFullTextCount(token, query, false); + result = RemoteStorageService.getStorageService().findFullTextCount(token, query, "", false); } } catch (SimExplorerException e) { throw new RuntimeException(e); @@ -102,7 +102,7 @@ entities = RemoteStorageService.getStorageService().findApplications(token, true, startIndex, 1 + endIndex - startIndex, sortColumn, ascending); } else { - entities = RemoteStorageService.getStorageService().findFullText(token, query, false, startIndex, + entities = RemoteStorageService.getStorageService().findFullText(token, query, "", false, startIndex, 1 + endIndex - startIndex, sortColumn, ascending); } } catch (SimExplorerException e) {