mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Merged V2.1 to HEAD
6975: Fix for WCM-883 - ZIP files with non-ascii characters, now gives the user an option for the encoding of the ZIP filenames 6978: Fixed test for 2.1 bean names. 6981: Fixes test failure. 6982: Integrity exception message carries full failure details. 6983: Added upgrade script for SQL Server. 6988: Replaced UserTransaction with RetryingTransactionHelper. 6989: Added org.hibernate.ObjectNotFoundException RetryingTransactionHelper. 6996: Added updated support for datetime tokens in the lucene index 7001: FIx for AR-1806 7015: Added missing post-create index script for QName columns on alf_child_assoc. 7022: Merged V2.0 to V2.1: 7013: Fixed primary child node status query git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@7371 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -36,6 +36,7 @@
|
||||
<property name="postCreateScriptUrls">
|
||||
<list>
|
||||
<value>classpath:alfresco/dbscripts/create/2.1/${db.script.dialect}/AlfrescoPostCreate-2.1-FKIndexes.sql</value>
|
||||
<value>classpath:alfresco/dbscripts/create/1.4/${db.script.dialect}/post-create-indexes-02.sql</value>
|
||||
</list>
|
||||
</property>
|
||||
<property name="validateUpdateScriptPatches">
|
||||
|
@@ -0,0 +1,22 @@
|
||||
--
|
||||
-- Title: Jbpm 3.2 Process Instance Key
|
||||
-- Database: SQL Server
|
||||
-- Since: V2.1 Schema 63
|
||||
-- Author: David Caruana
|
||||
--
|
||||
-- Please contact support@alfresco.com if you need assistance with the upgrade.
|
||||
--
|
||||
|
||||
UPDATE JBPM_PROCESSINSTANCE SET KEY_ = STR(ID_) WHERE KEY_ IS NULL;
|
||||
|
||||
--
|
||||
-- Record script finish
|
||||
--
|
||||
DELETE FROM alf_applied_patch WHERE id = 'patch.db-V2.1-JBPMProcessKey';
|
||||
INSERT INTO alf_applied_patch
|
||||
(id, description, fixes_from_schema, fixes_to_schema, applied_to_schema, target_schema, applied_on_date, applied_to_server, was_executed, succeeded, report)
|
||||
VALUES
|
||||
(
|
||||
'patch.db-V2.1-JBPMProcessKey', 'Manually executed script upgrade V2.1: JBPM 3.2 Process Instance Key',
|
||||
0, 62, -1, 63, null, 'UNKOWN', 1, 1, 'Script completed'
|
||||
);
|
4
config/alfresco/model/dataTypeAnalyzers_fi.properties
Normal file
4
config/alfresco/model/dataTypeAnalyzers_fi.properties
Normal file
@@ -0,0 +1,4 @@
|
||||
# Data Type Index Analyzers
|
||||
|
||||
d_dictionary.datatype.d_text.analyzer=org.alfresco.repo.search.impl.lucene.analysis.FinnishSnowballAnalyser
|
||||
d_dictionary.datatype.d_content.analyzer=org.alfresco.repo.search.impl.lucene.analysis.FinnishSnowballAnalyser
|
@@ -254,20 +254,13 @@
|
||||
select
|
||||
status
|
||||
from
|
||||
org.alfresco.repo.domain.hibernate.NodeStatusImpl as status
|
||||
join status.node as node
|
||||
org.alfresco.repo.domain.hibernate.NodeStatusImpl as status,
|
||||
org.alfresco.repo.domain.hibernate.ChildAssocImpl as assoc
|
||||
join assoc.child as child
|
||||
where
|
||||
node.id in
|
||||
(
|
||||
select
|
||||
child.id
|
||||
from
|
||||
org.alfresco.repo.domain.hibernate.ChildAssocImpl as assoc
|
||||
join assoc.child as child
|
||||
where
|
||||
assoc.parent.id = :parentId and
|
||||
assoc.isPrimary = true
|
||||
)
|
||||
assoc.parent.id = :parentId and
|
||||
assoc.isPrimary = true and
|
||||
status.node.id = child.id
|
||||
</query>
|
||||
|
||||
<query name="node.GetChildAssocsByAll">
|
||||
|
@@ -66,7 +66,7 @@ public class IndexTransactionTrackerTest extends TestCase
|
||||
searchService = serviceRegistry.getSearchService();
|
||||
nodeService = serviceRegistry.getNodeService();
|
||||
fileFolderService = serviceRegistry.getFileFolderService();
|
||||
authenticationComponent = (AuthenticationComponent) ctx.getBean("authenticationComponentImpl");
|
||||
authenticationComponent = (AuthenticationComponent) ctx.getBean("authenticationComponent");
|
||||
contentStore = (ContentStore) ctx.getBean("fileContentStore");
|
||||
ftsIndexer = (FullTextSearchIndexer) ctx.getBean("LuceneFullTextSearchIndexer");
|
||||
|
||||
@@ -108,7 +108,7 @@ public class IndexTransactionTrackerTest extends TestCase
|
||||
return childAssocRef;
|
||||
}
|
||||
};
|
||||
ChildAssociationRef childAssocRef = transactionService.getRetryingTransactionHelper().doInTransaction(createNodeWork, true);
|
||||
ChildAssociationRef childAssocRef = transactionService.getRetryingTransactionHelper().doInTransaction(createNodeWork, false);
|
||||
}
|
||||
|
||||
public void testSetup() throws Exception
|
||||
|
@@ -623,7 +623,7 @@ public class IntegrityChecker
|
||||
if (failOnViolation && !warnOnly)
|
||||
{
|
||||
logger.error(sb.toString());
|
||||
throw new IntegrityException(failures);
|
||||
throw new IntegrityException(sb.toString(), failures);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@@ -45,6 +45,12 @@ public class IntegrityException extends AlfrescoRuntimeException
|
||||
this.records = records;
|
||||
}
|
||||
|
||||
public IntegrityException(String msg, List<IntegrityRecord> records)
|
||||
{
|
||||
super(msg);
|
||||
this.records = records;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns a list of all the integrity violations
|
||||
*/
|
||||
|
@@ -31,8 +31,11 @@ import java.io.Reader;
|
||||
import java.io.Serializable;
|
||||
import java.io.StringReader;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
@@ -46,6 +49,7 @@ import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.content.MimetypeMap;
|
||||
import org.alfresco.repo.content.transform.ContentTransformer;
|
||||
import org.alfresco.repo.search.IndexerException;
|
||||
import org.alfresco.repo.search.impl.lucene.analysis.DateTimeAnalyser;
|
||||
import org.alfresco.repo.search.impl.lucene.fts.FTSIndexerAware;
|
||||
import org.alfresco.repo.search.impl.lucene.fts.FullTextSearchIndexer;
|
||||
import org.alfresco.repo.tenant.TenantService;
|
||||
@@ -69,10 +73,12 @@ import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter;
|
||||
import org.alfresco.service.cmr.repository.datatype.TypeConversionException;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.CachingDateFormat;
|
||||
import org.alfresco.util.EqualsHelper;
|
||||
import org.alfresco.util.ISO9075;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.lucene.analysis.Token;
|
||||
import org.apache.lucene.document.Document;
|
||||
import org.apache.lucene.document.Field;
|
||||
import org.apache.lucene.index.IndexReader;
|
||||
@@ -93,7 +99,7 @@ import org.apache.lucene.search.BooleanClause.Occur;
|
||||
*/
|
||||
public class ADMLuceneIndexerImpl extends AbstractLuceneIndexerImpl<NodeRef> implements ADMLuceneIndexer
|
||||
{
|
||||
static Log s_logger = LogFactory.getLog(ADMLuceneIndexerImpl.class);
|
||||
static Log s_logger = LogFactory.getLog(ADMLuceneIndexerImpl.class);
|
||||
|
||||
/**
|
||||
* The node service we use to get information about nodes
|
||||
@@ -133,16 +139,6 @@ public class ADMLuceneIndexerImpl extends AbstractLuceneIndexerImpl<NodeRef> imp
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* IOC setting of the dictionary service
|
||||
*
|
||||
* @param dictionaryService
|
||||
*/
|
||||
public void setDictionaryService(DictionaryService dictionaryService)
|
||||
{
|
||||
super.setDictionaryService(dictionaryService);
|
||||
}
|
||||
|
||||
/**
|
||||
* IOC setting of the node service
|
||||
*
|
||||
@@ -722,6 +718,7 @@ public class ADMLuceneIndexerImpl extends AbstractLuceneIndexerImpl<NodeRef> imp
|
||||
boolean isContent = false;
|
||||
boolean isMultiLingual = false;
|
||||
boolean isText = false;
|
||||
boolean isDateTime = false;
|
||||
|
||||
PropertyDefinition propertyDef = getDictionaryService().getProperty(propertyName);
|
||||
if (propertyDef != null)
|
||||
@@ -733,6 +730,12 @@ public class ADMLuceneIndexerImpl extends AbstractLuceneIndexerImpl<NodeRef> imp
|
||||
isContent = propertyDef.getDataType().getName().equals(DataTypeDefinition.CONTENT);
|
||||
isMultiLingual = propertyDef.getDataType().getName().equals(DataTypeDefinition.MLTEXT);
|
||||
isText = propertyDef.getDataType().getName().equals(DataTypeDefinition.TEXT);
|
||||
if (propertyDef.getDataType().getName().equals(DataTypeDefinition.DATETIME))
|
||||
{
|
||||
DataTypeDefinition dataType = propertyDef.getDataType();
|
||||
String analyserClassName = dataType.getAnalyserClassName();
|
||||
isDateTime = analyserClassName.equals(DateTimeAnalyser.class.getCanonicalName());
|
||||
}
|
||||
}
|
||||
if (value == null)
|
||||
{
|
||||
@@ -843,10 +846,8 @@ public class ADMLuceneIndexerImpl extends AbstractLuceneIndexerImpl<NodeRef> imp
|
||||
// Check that the reader is a view onto something concrete
|
||||
if (!reader.exists())
|
||||
{
|
||||
throw new ContentIOException(
|
||||
"The transformation did not write any content, yet: \n" +
|
||||
" transformer: " + transformer + "\n" +
|
||||
" temp writer: " + writer);
|
||||
throw new ContentIOException("The transformation did not write any content, yet: \n"
|
||||
+ " transformer: " + transformer + "\n" + " temp writer: " + writer);
|
||||
}
|
||||
}
|
||||
catch (ContentIOException e)
|
||||
@@ -977,6 +978,24 @@ public class ADMLuceneIndexerImpl extends AbstractLuceneIndexerImpl<NodeRef> imp
|
||||
doc.add(new Field(attributeName, strValue, fieldStore, fieldIndex, Field.TermVector.NO));
|
||||
}
|
||||
}
|
||||
else if (isDateTime)
|
||||
{
|
||||
doc.add(new Field(attributeName, strValue, fieldStore, fieldIndex, Field.TermVector.NO));
|
||||
|
||||
SimpleDateFormat df = CachingDateFormat.getDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS", true);
|
||||
|
||||
Date date;
|
||||
try
|
||||
{
|
||||
date = df.parse(strValue);
|
||||
doc.add(new Field(attributeName + ".sort", df.format(date), Field.Store.NO, Field.Index.NO_NORMS, Field.TermVector.NO));
|
||||
}
|
||||
catch (ParseException e)
|
||||
{
|
||||
// ignore for ordering
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
doc.add(new Field(attributeName, strValue, fieldStore, fieldIndex, Field.TermVector.NO));
|
||||
|
@@ -41,7 +41,10 @@ import org.alfresco.repo.search.SearcherException;
|
||||
import org.alfresco.repo.search.impl.NodeSearcher;
|
||||
import org.alfresco.repo.search.impl.lucene.QueryParser.Operator;
|
||||
import org.alfresco.repo.tenant.TenantService;
|
||||
import org.alfresco.repo.search.impl.lucene.analysis.DateTimeAnalyser;
|
||||
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
|
||||
import org.alfresco.service.cmr.repository.InvalidNodeRefException;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
@@ -80,7 +83,7 @@ import com.werken.saxpath.XPathReader;
|
||||
*/
|
||||
public class ADMLuceneSearcherImpl extends AbstractLuceneBase implements LuceneSearcher
|
||||
{
|
||||
static Log s_logger = LogFactory.getLog(ADMLuceneSearcherImpl.class);
|
||||
static Log s_logger = LogFactory.getLog(ADMLuceneSearcherImpl.class);
|
||||
|
||||
/**
|
||||
* Default field name
|
||||
@@ -93,8 +96,6 @@ public class ADMLuceneSearcherImpl extends AbstractLuceneBase implements LuceneS
|
||||
|
||||
private TenantService tenantService;
|
||||
|
||||
private DictionaryService dictionaryService;
|
||||
|
||||
private QueryRegisterComponent queryRegister;
|
||||
|
||||
private LuceneIndexer indexer;
|
||||
@@ -161,10 +162,6 @@ public class ADMLuceneSearcherImpl extends AbstractLuceneBase implements LuceneS
|
||||
this.tenantService = tenantService;
|
||||
}
|
||||
|
||||
public void setDictionaryService(DictionaryService dictionaryService)
|
||||
{
|
||||
this.dictionaryService = dictionaryService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the query register
|
||||
@@ -249,10 +246,10 @@ public class ADMLuceneSearcherImpl extends AbstractLuceneBase implements LuceneS
|
||||
Query query = LuceneQueryParser.parse(
|
||||
parameterisedQueryString, DEFAULT_FIELD,
|
||||
new LuceneAnalyser(
|
||||
dictionaryService,
|
||||
getDictionaryService(),
|
||||
searchParameters.getMlAnalaysisMode() == null ? getLuceneConfig().getDefaultMLSearchAnalysisMode() : searchParameters.getMlAnalaysisMode()),
|
||||
namespacePrefixResolver,
|
||||
dictionaryService,
|
||||
getDictionaryService(),
|
||||
tenantService,
|
||||
defaultOperator,
|
||||
searchParameters,
|
||||
@@ -279,9 +276,26 @@ public class ADMLuceneSearcherImpl extends AbstractLuceneBase implements LuceneS
|
||||
switch (sd.getSortType())
|
||||
{
|
||||
case FIELD:
|
||||
if (fieldHasTerm(searcher.getReader(), sd.getField()))
|
||||
String field = sd.getField();
|
||||
if(field.startsWith("@"))
|
||||
{
|
||||
fields[index++] = new SortField(sd.getField(), !sd.isAscending());
|
||||
field = expandAttributeFieldName(field);
|
||||
PropertyDefinition propertyDef = getDictionaryService().getProperty(QName.createQName(field.substring(1)));
|
||||
|
||||
if (propertyDef.getDataType().getName().equals(DataTypeDefinition.DATETIME))
|
||||
{
|
||||
DataTypeDefinition dataType = propertyDef.getDataType();
|
||||
String analyserClassName = dataType.getAnalyserClassName();
|
||||
if(analyserClassName.equals(DateTimeAnalyser.class.getCanonicalName()))
|
||||
{
|
||||
field = field + ".sort";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if (fieldHasTerm(searcher.getReader(), field))
|
||||
{
|
||||
fields[index++] = new SortField(field, !sd.isAscending());
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -329,7 +343,7 @@ public class ADMLuceneSearcherImpl extends AbstractLuceneBase implements LuceneS
|
||||
XPathReader reader = new XPathReader();
|
||||
LuceneXPathHandler handler = new LuceneXPathHandler();
|
||||
handler.setNamespacePrefixResolver(namespacePrefixResolver);
|
||||
handler.setDictionaryService(dictionaryService);
|
||||
handler.setDictionaryService(getDictionaryService());
|
||||
// TODO: Handler should have the query parameters to use in
|
||||
// building its lucene query
|
||||
// At the moment xpath style parameters in the PATH
|
||||
@@ -569,7 +583,7 @@ public class ADMLuceneSearcherImpl extends AbstractLuceneBase implements LuceneS
|
||||
public List<NodeRef> selectNodes(NodeRef contextNodeRef, String xpath, QueryParameterDefinition[] parameters, NamespacePrefixResolver namespacePrefixResolver,
|
||||
boolean followAllParentLinks, String language) throws InvalidNodeRefException, XPathException
|
||||
{
|
||||
NodeSearcher nodeSearcher = new NodeSearcher(nodeService, dictionaryService, this);
|
||||
NodeSearcher nodeSearcher = new NodeSearcher(nodeService, getDictionaryService(), this);
|
||||
|
||||
contextNodeRef = tenantService.getName(contextNodeRef);
|
||||
|
||||
@@ -582,7 +596,7 @@ public class ADMLuceneSearcherImpl extends AbstractLuceneBase implements LuceneS
|
||||
public List<Serializable> selectProperties(NodeRef contextNodeRef, String xpath, QueryParameterDefinition[] parameters, NamespacePrefixResolver namespacePrefixResolver,
|
||||
boolean followAllParentLinks, String language) throws InvalidNodeRefException, XPathException
|
||||
{
|
||||
NodeSearcher nodeSearcher = new NodeSearcher(nodeService, dictionaryService, this);
|
||||
NodeSearcher nodeSearcher = new NodeSearcher(nodeService, getDictionaryService(), this);
|
||||
return nodeSearcher.selectProperties(contextNodeRef, xpath, parameters, namespacePrefixResolver, followAllParentLinks, language);
|
||||
}
|
||||
|
||||
@@ -715,4 +729,25 @@ public class ADMLuceneSearcherImpl extends AbstractLuceneBase implements LuceneS
|
||||
{
|
||||
return selectProperties(contextNodeRef, xpath, parameters, namespacePrefixResolver, followAllParentLinks, SearchService.LANGUAGE_XPATH);
|
||||
}
|
||||
|
||||
private String expandAttributeFieldName(String field)
|
||||
{
|
||||
String fieldName = field;
|
||||
// Check for any prefixes and expand to the full uri
|
||||
if (field.charAt(1) != '{')
|
||||
{
|
||||
int colonPosition = field.indexOf(':');
|
||||
if (colonPosition == -1)
|
||||
{
|
||||
// use the default namespace
|
||||
fieldName = "@{" + namespacePrefixResolver.getNamespaceURI("") + "}" + field.substring(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
// find the prefix
|
||||
fieldName = "@{" + namespacePrefixResolver.getNamespaceURI(field.substring(1, colonPosition)) + "}" + field.substring(colonPosition + 1);
|
||||
}
|
||||
}
|
||||
return fieldName;
|
||||
}
|
||||
}
|
||||
|
@@ -31,6 +31,7 @@ import java.io.InputStream;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.Serializable;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
@@ -67,6 +68,7 @@ import org.alfresco.repo.security.authentication.AuthenticationComponent;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.tenant.TenantService;
|
||||
import org.alfresco.repo.transaction.RetryingTransactionHelper;
|
||||
import org.alfresco.repo.transaction.TransactionResourceInterceptor;
|
||||
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
||||
@@ -398,7 +400,7 @@ public class ADMLuceneTest extends TestCase
|
||||
writer.putContent("The quick brown fox jumped over the lazy dog and ate the Alfresco Tutorial, in pdf format, along with the following stop words; a an and are"
|
||||
+ " as at be but by for if in into is it no not of on or such that the their then there these they this to was will with: "
|
||||
+ " and random charcters \u00E0\u00EA\u00EE\u00F0\u00F1\u00F6\u00FB\u00FF");
|
||||
//System.out.println("Size is " + writer.getSize());
|
||||
// System.out.println("Size is " + writer.getSize());
|
||||
|
||||
nodeService.addChild(rootNodeRef, n8, ContentModel.ASSOC_CHILDREN, QName.createQName("{namespace}eight-0"));
|
||||
nodeService.addChild(n1, n8, ASSOC_TYPE_QNAME, QName.createQName("{namespace}eight-1"));
|
||||
@@ -1191,6 +1193,7 @@ public class ADMLuceneTest extends TestCase
|
||||
{
|
||||
public Object execute() throws Throwable
|
||||
{
|
||||
SessionSizeResourceManager.setDisableInTransaction();
|
||||
for (int i = 0; i < 20; i++)
|
||||
{
|
||||
HashSet<ChildAssociationRef> refs = new HashSet<ChildAssociationRef>();
|
||||
@@ -1576,6 +1579,47 @@ public class ADMLuceneTest extends TestCase
|
||||
}
|
||||
results.close();
|
||||
|
||||
SearchParameters sp_7 = new SearchParameters();
|
||||
sp_7.addStore(rootNodeRef.getStoreRef());
|
||||
sp_7.setLanguage(SearchService.LANGUAGE_LUCENE);
|
||||
sp_7.setQuery("PATH:\"//.\"");
|
||||
sp_7.addSort("@" + ContentModel.PROP_MODIFIED, true);
|
||||
results = searcher.query(sp_7);
|
||||
|
||||
date = null;
|
||||
for (ResultSetRow row : results)
|
||||
{
|
||||
Date currentBun = DefaultTypeConverter.INSTANCE.convert(Date.class, nodeService.getProperty(row.getNodeRef(), ContentModel.PROP_MODIFIED));
|
||||
// System.out.println(currentBun);
|
||||
if (date != null)
|
||||
{
|
||||
assertTrue(date.compareTo(currentBun) <= 0);
|
||||
}
|
||||
date = currentBun;
|
||||
}
|
||||
results.close();
|
||||
|
||||
SearchParameters sp_8 = new SearchParameters();
|
||||
sp_8.addStore(rootNodeRef.getStoreRef());
|
||||
sp_8.setLanguage(SearchService.LANGUAGE_LUCENE);
|
||||
sp_8.setQuery("PATH:\"//.\"");
|
||||
sp_8.addSort("@" + ContentModel.PROP_MODIFIED, false);
|
||||
results = searcher.query(sp_8);
|
||||
|
||||
date = null;
|
||||
for (ResultSetRow row : results)
|
||||
{
|
||||
Date currentBun = DefaultTypeConverter.INSTANCE.convert(Date.class, nodeService.getProperty(row.getNodeRef(), ContentModel.PROP_MODIFIED));
|
||||
// System.out.println(currentBun);
|
||||
if ((date != null) && (currentBun != null))
|
||||
{
|
||||
assertTrue(date.compareTo(currentBun) >= 0);
|
||||
}
|
||||
date = currentBun;
|
||||
}
|
||||
results.close();
|
||||
|
||||
|
||||
// sort by double
|
||||
|
||||
SearchParameters sp9 = new SearchParameters();
|
||||
@@ -2488,16 +2532,18 @@ public class ADMLuceneTest extends TestCase
|
||||
boolean usesDateTimeAnalyser = analyserClassName.equals(DateTimeAnalyser.class.getCanonicalName());
|
||||
|
||||
Date date = new Date();
|
||||
String sDate = CachingDateFormat.getDateFormat().format(date);
|
||||
SimpleDateFormat df = CachingDateFormat.getDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS", true);
|
||||
String sDate = df.format(date);
|
||||
results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(QName.createQName(TEST_NAMESPACE, "date-ista")) + ":\"" + sDate + "\"", null, null);
|
||||
assertEquals(1, results.length());
|
||||
results.close();
|
||||
|
||||
results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(QName.createQName(TEST_NAMESPACE, "datetime-ista")) + ":\"" + sDate + "\"", null, null);
|
||||
assertEquals(usesDateTimeAnalyser ? 0 : 1 , results.length());
|
||||
assertEquals(usesDateTimeAnalyser ? 0 : 1, results.length());
|
||||
results.close();
|
||||
|
||||
sDate = CachingDateFormat.getDateFormat().format(testDate);
|
||||
sDate = df.format(testDate);
|
||||
|
||||
results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(QName.createQName(TEST_NAMESPACE, "date-ista")) + ":\"" + sDate + "\"", null, null);
|
||||
assertEquals(1, results.length());
|
||||
results.close();
|
||||
@@ -2506,6 +2552,62 @@ public class ADMLuceneTest extends TestCase
|
||||
assertEquals(1, results.length());
|
||||
results.close();
|
||||
|
||||
// Date ranges
|
||||
// Test date collapses but date time does not
|
||||
|
||||
sDate = df.format(date);
|
||||
results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(QName.createQName(TEST_NAMESPACE, "date-ista")) + ":[" + sDate + " TO " + sDate + "]",
|
||||
null, null);
|
||||
assertEquals(1, results.length());
|
||||
results.close();
|
||||
|
||||
sDate = CachingDateFormat.getDateFormat().format(date);
|
||||
results = searcher.query(rootNodeRef.getStoreRef(), "lucene",
|
||||
"\\@" + escapeQName(QName.createQName(TEST_NAMESPACE, "datetime-ista")) + ":[" + sDate + " TO " + sDate + "]", null, null);
|
||||
assertEquals(usesDateTimeAnalyser ? 0 : 1, results.length(), results.length());
|
||||
results.close();
|
||||
|
||||
if (usesDateTimeAnalyser)
|
||||
{
|
||||
sDate = df.format(testDate);
|
||||
// System.out.println("SD = " + sDate);
|
||||
|
||||
for (long i : new long[] { 333, 20000, 20 * 60 * 1000, 8 * 60 * 60 * 1000, 10 * 24 * 60 * 60 * 1000, 4 * 30 * 24 * 60 * 60 * 1000, 10 * 12 * 30 * 24 * 60 * 60 * 1000 })
|
||||
{
|
||||
String startDate = df.format(new Date(testDate.getTime() - i));
|
||||
// System.out.println("\tStart = " + startDate);
|
||||
|
||||
|
||||
String endDate = df.format(new Date(testDate.getTime() + i));
|
||||
// System.out.println("\tEnd = " + endDate);
|
||||
|
||||
results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@"
|
||||
+ escapeQName(QName.createQName(TEST_NAMESPACE, "datetime-ista")) + ":[" + startDate + " TO " + endDate + "]", null, null);
|
||||
assertEquals(1, results.length());
|
||||
results.close();
|
||||
|
||||
results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@"
|
||||
+ escapeQName(QName.createQName(TEST_NAMESPACE, "datetime-ista")) + ":[" + sDate + " TO " + endDate + "]", null, null);
|
||||
assertEquals(1, results.length());
|
||||
results.close();
|
||||
|
||||
results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@"
|
||||
+ escapeQName(QName.createQName(TEST_NAMESPACE, "datetime-ista")) + ":[" + startDate + " TO " + sDate + "]", null, null);
|
||||
assertEquals(1, results.length());
|
||||
results.close();
|
||||
|
||||
results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@"
|
||||
+ escapeQName(QName.createQName(TEST_NAMESPACE, "datetime-ista")) + ":{" + sDate + " TO " + endDate + "}", null, null);
|
||||
assertEquals(0, results.length());
|
||||
results.close();
|
||||
|
||||
results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@"
|
||||
+ escapeQName(QName.createQName(TEST_NAMESPACE, "datetime-ista")) + ":{" + startDate + " TO " + sDate + "}", null, null);
|
||||
assertEquals(0, results.length());
|
||||
results.close();
|
||||
}
|
||||
}
|
||||
|
||||
results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(QName.createQName(TEST_NAMESPACE, "boolean-ista")) + ":\"true\"", null, null);
|
||||
assertEquals(1, results.length());
|
||||
results.close();
|
||||
@@ -2566,28 +2668,39 @@ public class ADMLuceneTest extends TestCase
|
||||
assertEquals(1, results.length());
|
||||
results.close();
|
||||
|
||||
results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "@" + LuceneQueryParser.escape(ContentModel.PROP_DESCRIPTION.toString()) + ":\"Alfresco Tutorial\"", null,
|
||||
null);
|
||||
|
||||
results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "@" + LuceneQueryParser.escape(ContentModel.PROP_DESCRIPTION.toString())+":\"Alfresco Tutorial\"", null, null);
|
||||
assertEquals(1, results.length());
|
||||
results.close();
|
||||
|
||||
results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "@" + LuceneQueryParser.escape(ContentModel.PROP_DESCRIPTION.toString())+":\"Tutorial Alfresco\"", null, null);
|
||||
results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "@" + LuceneQueryParser.escape(ContentModel.PROP_DESCRIPTION.toString()) + ":\"Tutorial Alfresco\"", null,
|
||||
null);
|
||||
|
||||
assertEquals(0, results.length());
|
||||
results.close();
|
||||
|
||||
results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "@" + LuceneQueryParser.escape(ContentModel.PROP_DESCRIPTION.toString())+":\"Tutorial Alfresco\"~0", null, null);
|
||||
results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "@" + LuceneQueryParser.escape(ContentModel.PROP_DESCRIPTION.toString()) + ":\"Tutorial Alfresco\"~0", null,
|
||||
null);
|
||||
|
||||
assertEquals(0, results.length());
|
||||
results.close();
|
||||
|
||||
results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "@" + LuceneQueryParser.escape(ContentModel.PROP_DESCRIPTION.toString())+":\"Tutorial Alfresco\"~1", null, null);
|
||||
results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "@" + LuceneQueryParser.escape(ContentModel.PROP_DESCRIPTION.toString()) + ":\"Tutorial Alfresco\"~1", null,
|
||||
null);
|
||||
|
||||
assertEquals(0, results.length());
|
||||
results.close();
|
||||
|
||||
results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "@" + LuceneQueryParser.escape(ContentModel.PROP_DESCRIPTION.toString())+":\"Tutorial Alfresco\"~2", null, null);
|
||||
results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "@" + LuceneQueryParser.escape(ContentModel.PROP_DESCRIPTION.toString()) + ":\"Tutorial Alfresco\"~2", null,
|
||||
null);
|
||||
|
||||
assertEquals(1, results.length());
|
||||
results.close();
|
||||
|
||||
results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "@" + LuceneQueryParser.escape(ContentModel.PROP_DESCRIPTION.toString())+":\"Tutorial Alfresco\"~3", null, null);
|
||||
results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "@" + LuceneQueryParser.escape(ContentModel.PROP_DESCRIPTION.toString()) + ":\"Tutorial Alfresco\"~3", null,
|
||||
null);
|
||||
|
||||
assertEquals(1, results.length());
|
||||
results.close();
|
||||
|
||||
@@ -3221,7 +3334,7 @@ public class ADMLuceneTest extends TestCase
|
||||
sp = new SearchParameters();
|
||||
sp.addStore(rootNodeRef.getStoreRef());
|
||||
sp.setLanguage("lucene");
|
||||
sp.setQuery("@" + LuceneQueryParser.escape(ContentModel.PROP_DESCRIPTION.toString()) +":\"alfres??\"");
|
||||
sp.setQuery("@" + LuceneQueryParser.escape(ContentModel.PROP_DESCRIPTION.toString()) + ":\"alfres??\"");
|
||||
results = searcher.query(sp);
|
||||
assertEquals(1, results.length());
|
||||
results.close();
|
||||
|
@@ -31,6 +31,8 @@ import java.io.Reader;
|
||||
import java.io.Serializable;
|
||||
import java.io.StringReader;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
@@ -52,6 +54,7 @@ import org.alfresco.repo.content.transform.ContentTransformer;
|
||||
import org.alfresco.repo.domain.PropertyValue;
|
||||
import org.alfresco.repo.search.IndexMode;
|
||||
import org.alfresco.repo.search.Indexer;
|
||||
import org.alfresco.repo.search.impl.lucene.analysis.DateTimeAnalyser;
|
||||
import org.alfresco.repo.search.impl.lucene.fts.FTSIndexerAware;
|
||||
import org.alfresco.repo.search.impl.lucene.fts.FullTextSearchIndexer;
|
||||
import org.alfresco.repo.transaction.AlfrescoTransactionSupport;
|
||||
@@ -74,6 +77,7 @@ import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter;
|
||||
import org.alfresco.service.cmr.repository.datatype.TypeConversionException;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.CachingDateFormat;
|
||||
import org.alfresco.util.EqualsHelper;
|
||||
import org.alfresco.util.GUID;
|
||||
import org.alfresco.util.ISO9075;
|
||||
@@ -104,7 +108,7 @@ public class AVMLuceneIndexerImpl extends AbstractLuceneIndexerImpl<String> impl
|
||||
|
||||
private static String SNAP_SHOT_ID = "SnapShot";
|
||||
|
||||
static Log s_logger = LogFactory.getLog(AVMLuceneIndexerImpl.class);
|
||||
static Log s_logger = LogFactory.getLog(AVMLuceneIndexerImpl.class);
|
||||
|
||||
private AVMService avmService;
|
||||
|
||||
@@ -649,6 +653,7 @@ public class AVMLuceneIndexerImpl extends AbstractLuceneIndexerImpl<String> impl
|
||||
boolean isContent = false;
|
||||
boolean isMultiLingual = false;
|
||||
boolean isText = false;
|
||||
boolean isDateTime = false;
|
||||
|
||||
PropertyDefinition propertyDef = getDictionaryService().getProperty(propertyName);
|
||||
if (propertyDef != null)
|
||||
@@ -660,6 +665,12 @@ public class AVMLuceneIndexerImpl extends AbstractLuceneIndexerImpl<String> impl
|
||||
isContent = propertyDef.getDataType().getName().equals(DataTypeDefinition.CONTENT);
|
||||
isMultiLingual = propertyDef.getDataType().getName().equals(DataTypeDefinition.MLTEXT);
|
||||
isText = propertyDef.getDataType().getName().equals(DataTypeDefinition.TEXT);
|
||||
if (propertyDef.getDataType().getName().equals(DataTypeDefinition.DATETIME))
|
||||
{
|
||||
DataTypeDefinition dataType = propertyDef.getDataType();
|
||||
String analyserClassName = dataType.getAnalyserClassName();
|
||||
isDateTime = analyserClassName.equals(DateTimeAnalyser.class.getCanonicalName());
|
||||
}
|
||||
}
|
||||
if (value == null)
|
||||
{
|
||||
@@ -896,6 +907,24 @@ public class AVMLuceneIndexerImpl extends AbstractLuceneIndexerImpl<String> impl
|
||||
doc.add(new Field(attributeName, strValue, fieldStore, fieldIndex, Field.TermVector.NO));
|
||||
}
|
||||
}
|
||||
else if (isDateTime)
|
||||
{
|
||||
|
||||
doc.add(new Field(attributeName, strValue, fieldStore, fieldIndex, Field.TermVector.NO));
|
||||
|
||||
SimpleDateFormat df = CachingDateFormat.getDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS", true);
|
||||
|
||||
Date date;
|
||||
try
|
||||
{
|
||||
date = df.parse(strValue);
|
||||
doc.add(new Field(attributeName + ".sort", df.format(date), Field.Store.NO, Field.Index.NO_NORMS, Field.TermVector.NO));
|
||||
}
|
||||
catch (ParseException e)
|
||||
{
|
||||
// ignore for ordering
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
doc.add(new Field(attributeName, strValue, fieldStore, fieldIndex, Field.TermVector.NO));
|
||||
@@ -1546,7 +1575,6 @@ public class AVMLuceneIndexerImpl extends AbstractLuceneIndexerImpl<String> impl
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public boolean hasIndexBeenCreated(String store)
|
||||
{
|
||||
return hasIndexBeenCreatedimpl(store, IndexChannel.MAIN) || hasIndexBeenCreatedimpl(store, IndexChannel.DELTA);
|
||||
|
@@ -26,10 +26,13 @@ package org.alfresco.repo.search.impl.lucene;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.StringReader;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
@@ -40,6 +43,7 @@ import java.util.Vector;
|
||||
import org.alfresco.i18n.I18NUtil;
|
||||
import org.alfresco.repo.search.MLAnalysisMode;
|
||||
import org.alfresco.repo.search.SearcherException;
|
||||
import org.alfresco.repo.search.impl.lucene.analysis.DateTimeAnalyser;
|
||||
import org.alfresco.repo.search.impl.lucene.analysis.MLTokenDuplicator;
|
||||
import org.alfresco.repo.search.impl.lucene.analysis.VerbatimAnalyser;
|
||||
import org.alfresco.repo.search.impl.lucene.query.PathQuery;
|
||||
@@ -54,6 +58,7 @@ import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.service.cmr.search.SearchParameters;
|
||||
import org.alfresco.service.namespace.NamespacePrefixResolver;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.CachingDateFormat;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.lucene.analysis.Analyzer;
|
||||
@@ -77,7 +82,7 @@ import com.werken.saxpath.XPathReader;
|
||||
|
||||
public class LuceneQueryParser extends QueryParser
|
||||
{
|
||||
private static Log s_logger = LogFactory.getLog(LuceneQueryParser.class);
|
||||
private static Log s_logger = LogFactory.getLog(LuceneQueryParser.class);
|
||||
|
||||
private NamespacePrefixResolver namespacePrefixResolver;
|
||||
|
||||
@@ -1120,6 +1125,52 @@ public class LuceneQueryParser extends QueryParser
|
||||
if (field.startsWith("@"))
|
||||
{
|
||||
String fieldName = expandAttributeFieldName(field);
|
||||
|
||||
QName propertyQName = QName.createQName(fieldName.substring(1));
|
||||
PropertyDefinition propertyDef = dictionaryService.getProperty(propertyQName);
|
||||
if (propertyDef != null)
|
||||
{
|
||||
if (propertyDef.getDataType().getName().equals(DataTypeDefinition.DATETIME))
|
||||
{
|
||||
DataTypeDefinition dataType = propertyDef.getDataType();
|
||||
String analyserClassName = dataType.getAnalyserClassName();
|
||||
boolean usesDateTimeAnalyser = analyserClassName.equals(DateTimeAnalyser.class.getCanonicalName());
|
||||
// Expand query for internal date time format
|
||||
|
||||
if (usesDateTimeAnalyser)
|
||||
{
|
||||
Calendar start = Calendar.getInstance();
|
||||
Calendar end = Calendar.getInstance();
|
||||
SimpleDateFormat df = CachingDateFormat.getDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS", true);
|
||||
try
|
||||
{
|
||||
Date date = df.parse(part1);
|
||||
start.setTime(date);
|
||||
}
|
||||
catch (java.text.ParseException e)
|
||||
{
|
||||
return new TermQuery(new Term("NO_TOKENS", "__"));
|
||||
}
|
||||
try
|
||||
{
|
||||
Date date = df.parse(part2);
|
||||
end.setTime(date);
|
||||
}
|
||||
catch (java.text.ParseException e)
|
||||
{
|
||||
return new TermQuery(new Term("NO_TOKENS", "__"));
|
||||
}
|
||||
|
||||
// Build a composite query for all the bits
|
||||
return buildDateTimeRange(field, start, end, inclusive);
|
||||
}
|
||||
else
|
||||
{
|
||||
return new RangeQuery(new Term(fieldName, getToken(fieldName, part1)), new Term(fieldName, getToken(fieldName, part2)), inclusive);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new RangeQuery(new Term(fieldName, getToken(fieldName, part1)), new Term(fieldName, getToken(fieldName, part2)), inclusive);
|
||||
|
||||
}
|
||||
@@ -1127,7 +1178,601 @@ public class LuceneQueryParser extends QueryParser
|
||||
{
|
||||
return super.getRangeQuery(field, part1, part2, inclusive);
|
||||
}
|
||||
}
|
||||
|
||||
private Query buildDateTimeRange(String field, Calendar start, Calendar end, boolean inclusive) throws ParseException
|
||||
{
|
||||
BooleanQuery query = new BooleanQuery();
|
||||
Query part;
|
||||
if (start.get(Calendar.YEAR) == end.get(Calendar.YEAR))
|
||||
{
|
||||
part = new TermQuery(new Term(field, "YE" + start.get(Calendar.YEAR)));
|
||||
query.add(part, Occur.MUST);
|
||||
if (start.get(Calendar.MONTH) == end.get(Calendar.MONTH))
|
||||
{
|
||||
part = new TermQuery(new Term(field, build2SF("MO", start.get(Calendar.MONTH))));
|
||||
query.add(part, Occur.MUST);
|
||||
if (start.get(Calendar.DAY_OF_MONTH) == end.get(Calendar.DAY_OF_MONTH))
|
||||
{
|
||||
part = new TermQuery(new Term(field, build2SF("DA", start.get(Calendar.DAY_OF_MONTH))));
|
||||
query.add(part, Occur.MUST);
|
||||
if (start.get(Calendar.HOUR_OF_DAY) == end.get(Calendar.HOUR_OF_DAY))
|
||||
{
|
||||
part = new TermQuery(new Term(field, build2SF("HO", start.get(Calendar.HOUR_OF_DAY))));
|
||||
query.add(part, Occur.MUST);
|
||||
if (start.get(Calendar.MINUTE) == end.get(Calendar.MINUTE))
|
||||
{
|
||||
part = new TermQuery(new Term(field, build2SF("MI", start.get(Calendar.MINUTE))));
|
||||
query.add(part, Occur.MUST);
|
||||
if (start.get(Calendar.SECOND) == end.get(Calendar.SECOND))
|
||||
{
|
||||
part = new TermQuery(new Term(field, build2SF("SE", start.get(Calendar.SECOND))));
|
||||
query.add(part, Occur.MUST);
|
||||
if (start.get(Calendar.MILLISECOND) == end.get(Calendar.MILLISECOND))
|
||||
{
|
||||
if (inclusive)
|
||||
{
|
||||
part = new TermQuery(new Term(field, build3SF("MS", start.get(Calendar.MILLISECOND))));
|
||||
query.add(part, Occur.MUST);
|
||||
}
|
||||
else
|
||||
{
|
||||
return new TermQuery(new Term("NO_TOKENS", "__"));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// only ms
|
||||
part = new RangeQuery(new Term(field, build3SF("MS", start.get(Calendar.MILLISECOND))), new Term(field, build3SF("MS", end
|
||||
.get(Calendar.MILLISECOND))), inclusive);
|
||||
query.add(part, Occur.MUST);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// s + ms
|
||||
|
||||
BooleanQuery subQuery = new BooleanQuery();
|
||||
Query subPart;
|
||||
|
||||
subPart = buildStart(field, start, inclusive, Calendar.SECOND, Calendar.MILLISECOND);
|
||||
if (subPart != null)
|
||||
{
|
||||
subQuery.add(subPart, Occur.SHOULD);
|
||||
}
|
||||
|
||||
if ((end.get(Calendar.SECOND) - start.get(Calendar.SECOND)) > 1)
|
||||
{
|
||||
subPart = new RangeQuery(new Term(field, build2SF("SE", start.get(Calendar.SECOND))),
|
||||
new Term(field, build2SF("SE", end.get(Calendar.SECOND))), false);
|
||||
subQuery.add(subPart, Occur.SHOULD);
|
||||
}
|
||||
|
||||
subPart = buildEnd(field, end, inclusive, Calendar.SECOND, Calendar.MILLISECOND);
|
||||
if (subPart != null)
|
||||
{
|
||||
subQuery.add(subPart, Occur.SHOULD);
|
||||
}
|
||||
|
||||
if (subQuery.clauses().size() > 0)
|
||||
{
|
||||
query.add(subQuery, Occur.MUST);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// min + s + ms
|
||||
|
||||
BooleanQuery subQuery = new BooleanQuery();
|
||||
Query subPart;
|
||||
|
||||
for (int i : new int[] { Calendar.MILLISECOND, Calendar.SECOND })
|
||||
{
|
||||
subPart = buildStart(field, start, inclusive, Calendar.MINUTE, i);
|
||||
if (subPart != null)
|
||||
{
|
||||
subQuery.add(subPart, Occur.SHOULD);
|
||||
}
|
||||
}
|
||||
|
||||
if ((end.get(Calendar.MINUTE) - start.get(Calendar.MINUTE)) > 1)
|
||||
{
|
||||
subPart = new RangeQuery(new Term(field, build2SF("MI", start.get(Calendar.MINUTE))), new Term(field, build2SF("MI", end.get(Calendar.MINUTE))),
|
||||
false);
|
||||
subQuery.add(subPart, Occur.SHOULD);
|
||||
}
|
||||
|
||||
for (int i : new int[] { Calendar.SECOND, Calendar.MILLISECOND })
|
||||
{
|
||||
subPart = buildEnd(field, end, inclusive, Calendar.MINUTE, i);
|
||||
if (subPart != null)
|
||||
{
|
||||
subQuery.add(subPart, Occur.SHOULD);
|
||||
}
|
||||
}
|
||||
|
||||
if (subQuery.clauses().size() > 0)
|
||||
{
|
||||
query.add(subQuery, Occur.MUST);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// hr + min + s + ms
|
||||
|
||||
BooleanQuery subQuery = new BooleanQuery();
|
||||
Query subPart;
|
||||
|
||||
for (int i : new int[] { Calendar.MILLISECOND, Calendar.SECOND, Calendar.MINUTE })
|
||||
{
|
||||
subPart = buildStart(field, start, inclusive, Calendar.HOUR_OF_DAY, i);
|
||||
if (subPart != null)
|
||||
{
|
||||
subQuery.add(subPart, Occur.SHOULD);
|
||||
}
|
||||
}
|
||||
|
||||
if ((end.get(Calendar.HOUR_OF_DAY) - start.get(Calendar.HOUR_OF_DAY)) > 1)
|
||||
{
|
||||
subPart = new RangeQuery(new Term(field, build2SF("HO", start.get(Calendar.HOUR_OF_DAY))), new Term(field,
|
||||
build2SF("HO", end.get(Calendar.HOUR_OF_DAY))), false);
|
||||
subQuery.add(subPart, Occur.SHOULD);
|
||||
}
|
||||
|
||||
for (int i : new int[] { Calendar.MINUTE, Calendar.SECOND, Calendar.MILLISECOND })
|
||||
{
|
||||
subPart = buildEnd(field, end, inclusive, Calendar.HOUR_OF_DAY, i);
|
||||
if (subPart != null)
|
||||
{
|
||||
subQuery.add(subPart, Occur.SHOULD);
|
||||
}
|
||||
}
|
||||
|
||||
if (subQuery.clauses().size() > 0)
|
||||
{
|
||||
query.add(subQuery, Occur.MUST);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// day + hr + min + s + ms
|
||||
|
||||
BooleanQuery subQuery = new BooleanQuery();
|
||||
Query subPart;
|
||||
|
||||
for (int i : new int[] { Calendar.MILLISECOND, Calendar.SECOND, Calendar.MINUTE, Calendar.HOUR_OF_DAY })
|
||||
{
|
||||
subPart = buildStart(field, start, inclusive, Calendar.DAY_OF_MONTH, i);
|
||||
if (subPart != null)
|
||||
{
|
||||
subQuery.add(subPart, Occur.SHOULD);
|
||||
}
|
||||
}
|
||||
|
||||
if ((end.get(Calendar.DAY_OF_MONTH) - start.get(Calendar.DAY_OF_MONTH)) > 1)
|
||||
{
|
||||
subPart = new RangeQuery(new Term(field, build2SF("DA", start.get(Calendar.DAY_OF_MONTH))),
|
||||
new Term(field, build2SF("DA", end.get(Calendar.DAY_OF_MONTH))), false);
|
||||
subQuery.add(subPart, Occur.SHOULD);
|
||||
}
|
||||
|
||||
for (int i : new int[] { Calendar.HOUR_OF_DAY, Calendar.MINUTE, Calendar.SECOND, Calendar.MILLISECOND })
|
||||
{
|
||||
subPart = buildEnd(field, end, inclusive, Calendar.DAY_OF_MONTH, i);
|
||||
if (subPart != null)
|
||||
{
|
||||
subQuery.add(subPart, Occur.SHOULD);
|
||||
}
|
||||
}
|
||||
|
||||
if (subQuery.clauses().size() > 0)
|
||||
{
|
||||
query.add(subQuery, Occur.MUST);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// month + day + hr + min + s + ms
|
||||
|
||||
BooleanQuery subQuery = new BooleanQuery();
|
||||
Query subPart;
|
||||
|
||||
for (int i : new int[] { Calendar.MILLISECOND, Calendar.SECOND, Calendar.MINUTE, Calendar.HOUR_OF_DAY, Calendar.DAY_OF_MONTH })
|
||||
{
|
||||
subPart = buildStart(field, start, inclusive, Calendar.MONTH, i);
|
||||
if (subPart != null)
|
||||
{
|
||||
subQuery.add(subPart, Occur.SHOULD);
|
||||
}
|
||||
}
|
||||
|
||||
if ((end.get(Calendar.MONTH) - start.get(Calendar.MONTH)) > 1)
|
||||
{
|
||||
subPart = new RangeQuery(new Term(field, build2SF("MO", start.get(Calendar.MONTH))), new Term(field, build2SF("MO", end.get(Calendar.MONTH))), false);
|
||||
subQuery.add(subPart, Occur.SHOULD);
|
||||
}
|
||||
|
||||
for (int i : new int[] { Calendar.DAY_OF_MONTH, Calendar.HOUR_OF_DAY, Calendar.MINUTE, Calendar.SECOND, Calendar.MILLISECOND })
|
||||
{
|
||||
subPart = buildEnd(field, end, inclusive, Calendar.MONTH, i);
|
||||
if (subPart != null)
|
||||
{
|
||||
subQuery.add(subPart, Occur.SHOULD);
|
||||
}
|
||||
}
|
||||
|
||||
if (subQuery.clauses().size() > 0)
|
||||
{
|
||||
query.add(subQuery, Occur.MUST);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// year + month + day + hr + min + s + ms
|
||||
|
||||
BooleanQuery subQuery = new BooleanQuery();
|
||||
Query subPart;
|
||||
|
||||
for (int i : new int[] { Calendar.MILLISECOND, Calendar.SECOND, Calendar.MINUTE, Calendar.HOUR_OF_DAY, Calendar.DAY_OF_MONTH, Calendar.MONTH })
|
||||
{
|
||||
subPart = buildStart(field, start, inclusive, Calendar.YEAR, i);
|
||||
if (subPart != null)
|
||||
{
|
||||
subQuery.add(subPart, Occur.SHOULD);
|
||||
}
|
||||
}
|
||||
|
||||
if ((end.get(Calendar.YEAR) - start.get(Calendar.YEAR)) > 1)
|
||||
{
|
||||
subPart = new RangeQuery(new Term(field, "YE" + start.get(Calendar.YEAR)), new Term(field, "YE" + end.get(Calendar.YEAR)), false);
|
||||
subQuery.add(subPart, Occur.SHOULD);
|
||||
}
|
||||
|
||||
for (int i : new int[] { Calendar.MONTH, Calendar.DAY_OF_MONTH, Calendar.HOUR_OF_DAY, Calendar.MINUTE, Calendar.SECOND, Calendar.MILLISECOND })
|
||||
{
|
||||
subPart = buildEnd(field, end, inclusive, Calendar.YEAR, i);
|
||||
if (subPart != null)
|
||||
{
|
||||
subQuery.add(subPart, Occur.SHOULD);
|
||||
}
|
||||
}
|
||||
|
||||
if (subQuery.clauses().size() > 0)
|
||||
{
|
||||
query.add(subQuery, Occur.MUST);
|
||||
}
|
||||
}
|
||||
return query;
|
||||
}
|
||||
|
||||
private Query buildStart(String field, Calendar cal, boolean inclusive, int startField, int padField)
|
||||
{
|
||||
BooleanQuery range = new BooleanQuery();
|
||||
// only ms difference
|
||||
Query part;
|
||||
|
||||
int ms = cal.get(Calendar.MILLISECOND) + (inclusive ? 0 : 1);
|
||||
|
||||
switch (startField)
|
||||
{
|
||||
case Calendar.YEAR:
|
||||
part = new TermQuery(new Term(field, "YE" + cal.get(Calendar.YEAR)));
|
||||
range.add(part, Occur.MUST);
|
||||
case Calendar.MONTH:
|
||||
if ((cal.get(Calendar.MONTH) == 0)
|
||||
&& (cal.get(Calendar.DAY_OF_MONTH) == 1) && (cal.get(Calendar.HOUR_OF_DAY) == 0) && (cal.get(Calendar.MINUTE) == 0) && (cal.get(Calendar.SECOND) == 0)
|
||||
&& (ms == 0))
|
||||
{
|
||||
if (padField == Calendar.DAY_OF_MONTH)
|
||||
{
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (padField == Calendar.MONTH)
|
||||
{
|
||||
part = new RangeQuery(new Term(field, build2SF("MO", (cal.get(Calendar.MONTH) + 1))), new Term(field, "MO11"), true);
|
||||
range.add(part, Occur.MUST);
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
part = new TermQuery(new Term(field, build2SF("MO", cal.get(Calendar.MONTH))));
|
||||
range.add(part, Occur.MUST);
|
||||
}
|
||||
case Calendar.DAY_OF_MONTH:
|
||||
if ((cal.get(Calendar.DAY_OF_MONTH) == 1) && (cal.get(Calendar.HOUR_OF_DAY) == 0) && (cal.get(Calendar.MINUTE) == 0) && (cal.get(Calendar.SECOND) == 0) && (ms == 0))
|
||||
{
|
||||
if (padField == Calendar.HOUR_OF_DAY)
|
||||
{
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (padField == Calendar.DAY_OF_MONTH)
|
||||
{
|
||||
part = new RangeQuery(new Term(field, build2SF("DA", (cal.get(Calendar.DAY_OF_MONTH) + 1))), new Term(field, "DA31"), true);
|
||||
range.add(part, Occur.MUST);
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
part = new TermQuery(new Term(field, build2SF("DA", cal.get(Calendar.DAY_OF_MONTH))));
|
||||
range.add(part, Occur.MUST);
|
||||
}
|
||||
case Calendar.HOUR_OF_DAY:
|
||||
if ((cal.get(Calendar.HOUR_OF_DAY) == 0) && (cal.get(Calendar.MINUTE) == 0) && (cal.get(Calendar.SECOND) == 0) && (ms == 0))
|
||||
{
|
||||
if (padField == Calendar.MINUTE)
|
||||
{
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (padField == Calendar.HOUR_OF_DAY)
|
||||
{
|
||||
part = new RangeQuery(new Term(field, build2SF("HO", (cal.get(Calendar.HOUR_OF_DAY) + 1))), new Term(field, "HO23"), true);
|
||||
range.add(part, Occur.MUST);
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
part = new TermQuery(new Term(field, build2SF("HO", cal.get(Calendar.HOUR_OF_DAY))));
|
||||
range.add(part, Occur.MUST);
|
||||
}
|
||||
case Calendar.MINUTE:
|
||||
if ((cal.get(Calendar.MINUTE) == 0) && (cal.get(Calendar.SECOND) == 0) && (ms == 0))
|
||||
{
|
||||
if (padField == Calendar.SECOND)
|
||||
{
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (padField == Calendar.MINUTE)
|
||||
{
|
||||
part = new RangeQuery(new Term(field, build2SF("MI", (cal.get(Calendar.MINUTE) + 1))), new Term(field, "MI59"), true);
|
||||
range.add(part, Occur.MUST);
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
part = new TermQuery(new Term(field, build2SF("MI", cal.get(Calendar.MINUTE))));
|
||||
range.add(part, Occur.MUST);
|
||||
}
|
||||
case Calendar.SECOND:
|
||||
if ((cal.get(Calendar.SECOND) == 0) && (ms == 0))
|
||||
{
|
||||
if (padField == Calendar.MILLISECOND)
|
||||
{
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (padField == Calendar.SECOND)
|
||||
{
|
||||
part = new RangeQuery(new Term(field, build2SF("SE", (cal.get(Calendar.SECOND) + 1))), new Term(field, "SE59"), true);
|
||||
range.add(part, Occur.MUST);
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
part = new TermQuery(new Term(field, build2SF("SE", cal.get(Calendar.SECOND))));
|
||||
range.add(part, Occur.MUST);
|
||||
}
|
||||
default:
|
||||
if ((ms > 0) && (ms < 999))
|
||||
{
|
||||
part = new RangeQuery(new Term(field, build3SF("MS", ms)), new Term(field, "MS999"), true);
|
||||
range.add(part, Occur.MUST);
|
||||
}
|
||||
else if (ms == 1000)
|
||||
{
|
||||
// exclude
|
||||
range.add(new TermQuery(new Term("NO_TOKENS", "__")), Occur.MUST);
|
||||
}
|
||||
}
|
||||
|
||||
if (range.clauses().size() > 0)
|
||||
{
|
||||
return range;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private Query buildEnd(String field, Calendar cal, boolean inclusive, int startField, int padField)
|
||||
{
|
||||
BooleanQuery range = new BooleanQuery();
|
||||
// only ms difference
|
||||
Query part;
|
||||
|
||||
int ms = cal.get(Calendar.MILLISECOND) - (inclusive ? 0 : 1);
|
||||
|
||||
switch (startField)
|
||||
{
|
||||
case Calendar.YEAR:
|
||||
part = new TermQuery(new Term(field, "YE" + cal.get(Calendar.YEAR)));
|
||||
range.add(part, Occur.MUST);
|
||||
case Calendar.MONTH:
|
||||
if ((cal.get(Calendar.MONTH) == 0)
|
||||
&& (cal.get(Calendar.DAY_OF_MONTH) == 1) && (cal.get(Calendar.HOUR_OF_DAY) == 0) && (cal.get(Calendar.MINUTE) == 0) && (cal.get(Calendar.SECOND) == 0)
|
||||
&& (ms == 0))
|
||||
{
|
||||
if (padField == Calendar.MONTH)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
if (padField == Calendar.MONTH)
|
||||
{
|
||||
part = new RangeQuery(new Term(field, "MO00"), new Term(field, build2SF("MO", (cal.get(Calendar.MONTH) - 1))), true);
|
||||
range.add(part, Occur.MUST);
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
part = new TermQuery(new Term(field, build2SF("MO", cal.get(Calendar.MONTH))));
|
||||
range.add(part, Occur.MUST);
|
||||
}
|
||||
case Calendar.DAY_OF_MONTH:
|
||||
if ((cal.get(Calendar.DAY_OF_MONTH) == 1) && (cal.get(Calendar.HOUR_OF_DAY) == 0) && (cal.get(Calendar.MINUTE) == 0) && (cal.get(Calendar.SECOND) == 0)
|
||||
&& (ms == 0))
|
||||
{
|
||||
if (padField == Calendar.DAY_OF_MONTH)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
if (padField == Calendar.DAY_OF_MONTH)
|
||||
{
|
||||
part = new RangeQuery(new Term(field, "DA00"), new Term(field, build2SF("DA", (cal.get(Calendar.DAY_OF_MONTH) - 1))), true);
|
||||
range.add(part, Occur.MUST);
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
part = new TermQuery(new Term(field, build2SF("DA", cal.get(Calendar.DAY_OF_MONTH))));
|
||||
range.add(part, Occur.MUST);
|
||||
}
|
||||
case Calendar.HOUR_OF_DAY:
|
||||
if ((cal.get(Calendar.HOUR_OF_DAY) == 0) && (cal.get(Calendar.MINUTE) == 0) && (cal.get(Calendar.SECOND) == 0)
|
||||
&& (ms == 0))
|
||||
{
|
||||
if (padField == Calendar.HOUR_OF_DAY)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
if (padField == Calendar.HOUR_OF_DAY)
|
||||
{
|
||||
part = new RangeQuery(new Term(field, "HO00"), new Term(field, build2SF("HO", (cal.get(Calendar.HOUR_OF_DAY) - 1))), true);
|
||||
range.add(part, Occur.MUST);
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
part = new TermQuery(new Term(field, build2SF("HO", cal.get(Calendar.HOUR_OF_DAY))));
|
||||
range.add(part, Occur.MUST);
|
||||
}
|
||||
case Calendar.MINUTE:
|
||||
if ((cal.get(Calendar.MINUTE) == 0) && (cal.get(Calendar.SECOND) == 0)
|
||||
&& (ms == 0))
|
||||
{
|
||||
if (padField == Calendar.MINUTE)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
if (padField == Calendar.MINUTE)
|
||||
{
|
||||
part = new RangeQuery(new Term(field, "MI00"), new Term(field, build2SF("MI", (cal.get(Calendar.MINUTE) - 1))), true);
|
||||
range.add(part, Occur.MUST);
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
part = new TermQuery(new Term(field, build2SF("MI", cal.get(Calendar.MINUTE))));
|
||||
range.add(part, Occur.MUST);
|
||||
}
|
||||
case Calendar.SECOND:
|
||||
if ((cal.get(Calendar.SECOND) == 0)
|
||||
&& (ms == 0))
|
||||
{
|
||||
if (padField == Calendar.SECOND)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
if (padField == Calendar.SECOND)
|
||||
{
|
||||
part = new RangeQuery(new Term(field, "SE00"), new Term(field, build2SF("SE", (cal.get(Calendar.SECOND) - 1))), true);
|
||||
range.add(part, Occur.MUST);
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
part = new TermQuery(new Term(field, build2SF("SE", cal.get(Calendar.SECOND))));
|
||||
range.add(part, Occur.MUST);
|
||||
}
|
||||
default:
|
||||
if ((ms >= 0) && (ms < 999))
|
||||
{
|
||||
part = new RangeQuery(new Term(field, "MS000"), new Term(field, build3SF("MS", ms)), true);
|
||||
range.add(part, Occur.MUST);
|
||||
}
|
||||
else if (ms == -1)
|
||||
{
|
||||
// exclude
|
||||
range.add(new TermQuery(new Term("NO_TOKENS", "__")), Occur.MUST);
|
||||
}
|
||||
}
|
||||
|
||||
if (range.clauses().size() > 0)
|
||||
{
|
||||
return range;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private String build2SF(String prefix, int value)
|
||||
{
|
||||
if (value < 10)
|
||||
{
|
||||
return prefix + "0" + value;
|
||||
}
|
||||
else
|
||||
{
|
||||
return prefix + value;
|
||||
}
|
||||
}
|
||||
|
||||
private String build3SF(String prefix, int value)
|
||||
{
|
||||
if (value < 10)
|
||||
{
|
||||
return prefix + "00" + value;
|
||||
}
|
||||
else if (value < 100)
|
||||
{
|
||||
return prefix + "0" + value;
|
||||
}
|
||||
else
|
||||
{
|
||||
return prefix + value;
|
||||
}
|
||||
}
|
||||
|
||||
private String expandAttributeFieldName(String field)
|
||||
@@ -1558,4 +2203,33 @@ public class LuceneQueryParser extends QueryParser
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws ParseException
|
||||
{
|
||||
Query query;
|
||||
|
||||
Calendar start = Calendar.getInstance();
|
||||
Calendar end = Calendar.getInstance();
|
||||
SimpleDateFormat df = CachingDateFormat.getDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS", false);
|
||||
try
|
||||
{
|
||||
Date date = df.parse("2007-10-15T11:21:03.312");
|
||||
start.setTime(date);
|
||||
}
|
||||
catch (java.text.ParseException e)
|
||||
{
|
||||
query = new TermQuery(new Term("NO_TOKENS", "__"));
|
||||
}
|
||||
try
|
||||
{
|
||||
Date date = df.parse("2007-10-15T11:21:03.645");
|
||||
end.setTime(date);
|
||||
}
|
||||
catch (java.text.ParseException e)
|
||||
{
|
||||
query = new TermQuery(new Term("NO_TOKENS", "__"));
|
||||
}
|
||||
LuceneQueryParser lqp = new LuceneQueryParser(null, null);
|
||||
query = lqp.buildDateTimeRange("TEST", start, end, true);
|
||||
System.out.println("Query is " + query);
|
||||
}
|
||||
}
|
||||
|
@@ -1,3 +1,27 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
package org.alfresco.repo.search.impl.lucene.analysis;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
|
@@ -1,3 +1,27 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
package org.alfresco.repo.search.impl.lucene.analysis;
|
||||
|
||||
import org.apache.lucene.analysis.snowball.SnowballAnalyzer;
|
||||
|
@@ -28,7 +28,10 @@ import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.alfresco.util.CachingDateFormat;
|
||||
import org.apache.lucene.analysis.Token;
|
||||
@@ -42,6 +45,8 @@ public class DateTimeTokenFilter extends Tokenizer
|
||||
{
|
||||
Tokenizer baseTokeniser;
|
||||
|
||||
Iterator<Token> tokenIterator = null;
|
||||
|
||||
public DateTimeTokenFilter(Reader in)
|
||||
{
|
||||
super(in);
|
||||
@@ -50,10 +55,26 @@ public class DateTimeTokenFilter extends Tokenizer
|
||||
|
||||
public Token next() throws IOException
|
||||
{
|
||||
SimpleDateFormat df = CachingDateFormat.getDateFormat();
|
||||
SimpleDateFormat dof = CachingDateFormat.getDateFormat();
|
||||
if (tokenIterator == null)
|
||||
{
|
||||
buildIterator();
|
||||
}
|
||||
if (tokenIterator.hasNext())
|
||||
{
|
||||
return tokenIterator.next();
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public void buildIterator() throws IOException
|
||||
{
|
||||
SimpleDateFormat df = CachingDateFormat.getDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS", true);
|
||||
Token candidate;
|
||||
while((candidate = baseTokeniser.next()) != null)
|
||||
ArrayList<Token> tokens = new ArrayList<Token>();
|
||||
while ((candidate = baseTokeniser.next()) != null)
|
||||
{
|
||||
Date date;
|
||||
try
|
||||
@@ -62,13 +83,99 @@ public class DateTimeTokenFilter extends Tokenizer
|
||||
}
|
||||
catch (ParseException e)
|
||||
{
|
||||
continue;
|
||||
continue;
|
||||
}
|
||||
String valueString = dof.format(date);
|
||||
Token integerToken = new Token(valueString, candidate.startOffset(), candidate.startOffset(),
|
||||
candidate.type());
|
||||
return integerToken;
|
||||
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTime(date);
|
||||
|
||||
Token token;
|
||||
|
||||
// four digits
|
||||
token = new Token("YE" + cal.get(Calendar.YEAR), candidate.startOffset(), candidate.startOffset(), candidate.type());
|
||||
tokens.add(token);
|
||||
|
||||
// 2 digits
|
||||
int month = cal.get(Calendar.MONTH);
|
||||
if (month < 10)
|
||||
{
|
||||
token = new Token("MO0" + month, candidate.startOffset(), candidate.startOffset(), candidate.type());
|
||||
tokens.add(token);
|
||||
}
|
||||
else
|
||||
{
|
||||
token = new Token("MO" + month, candidate.startOffset(), candidate.startOffset(), candidate.type());
|
||||
tokens.add(token);
|
||||
}
|
||||
|
||||
int day = cal.get(Calendar.DAY_OF_MONTH);
|
||||
if (day < 10)
|
||||
{
|
||||
token = new Token("DA0" + day, candidate.startOffset(), candidate.startOffset(), candidate.type());
|
||||
tokens.add(token);
|
||||
}
|
||||
else
|
||||
{
|
||||
token = new Token("DA" + day, candidate.startOffset(), candidate.startOffset(), candidate.type());
|
||||
tokens.add(token);
|
||||
}
|
||||
|
||||
int hour = cal.get(Calendar.HOUR_OF_DAY);
|
||||
if (hour < 10)
|
||||
{
|
||||
token = new Token("HO0" + hour, candidate.startOffset(), candidate.startOffset(), candidate.type());
|
||||
tokens.add(token);
|
||||
}
|
||||
else
|
||||
{
|
||||
token = new Token("HO" + hour, candidate.startOffset(), candidate.startOffset(), candidate.type());
|
||||
tokens.add(token);
|
||||
}
|
||||
|
||||
int minute = cal.get(Calendar.MINUTE);
|
||||
if (minute < 10)
|
||||
{
|
||||
token = new Token("MI0" + minute, candidate.startOffset(), candidate.startOffset(), candidate.type());
|
||||
tokens.add(token);
|
||||
}
|
||||
else
|
||||
{
|
||||
token = new Token("MI" + minute, candidate.startOffset(), candidate.startOffset(), candidate.type());
|
||||
tokens.add(token);
|
||||
}
|
||||
|
||||
int second = cal.get(Calendar.SECOND);
|
||||
if (second < 10)
|
||||
{
|
||||
token = new Token("SE0" + second, candidate.startOffset(), candidate.startOffset(), candidate.type());
|
||||
tokens.add(token);
|
||||
}
|
||||
else
|
||||
{
|
||||
token = new Token("SE" + second, candidate.startOffset(), candidate.startOffset(), candidate.type());
|
||||
tokens.add(token);
|
||||
}
|
||||
|
||||
int millis = cal.get(Calendar.MILLISECOND);
|
||||
if (millis < 10)
|
||||
{
|
||||
token = new Token("MS00" + millis, candidate.startOffset(), candidate.startOffset(), candidate.type());
|
||||
tokens.add(token);
|
||||
}
|
||||
else if (millis < 100)
|
||||
{
|
||||
token = new Token("MS0" + millis, candidate.startOffset(), candidate.startOffset(), candidate.type());
|
||||
tokens.add(token);
|
||||
}
|
||||
else
|
||||
{
|
||||
token = new Token("MS" + millis, candidate.startOffset(), candidate.startOffset(), candidate.type());
|
||||
tokens.add(token);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
return null;
|
||||
|
||||
tokenIterator = tokens.iterator();
|
||||
}
|
||||
}
|
@@ -1,3 +1,27 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
package org.alfresco.repo.search.impl.lucene.analysis;
|
||||
|
||||
import org.apache.lucene.analysis.snowball.SnowballAnalyzer;
|
||||
@@ -7,6 +31,6 @@ public class DutchSnowballAnalyser extends SnowballAnalyzer
|
||||
|
||||
public DutchSnowballAnalyser()
|
||||
{
|
||||
super("Danish");
|
||||
super("Dutch");
|
||||
}
|
||||
}
|
||||
|
@@ -1,3 +1,27 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
package org.alfresco.repo.search.impl.lucene.analysis;
|
||||
|
||||
import org.apache.lucene.analysis.snowball.SnowballAnalyzer;
|
||||
@@ -7,6 +31,6 @@ public class EnglishSnowballAnalyser extends SnowballAnalyzer
|
||||
|
||||
public EnglishSnowballAnalyser()
|
||||
{
|
||||
super("Danish");
|
||||
super("English");
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
package org.alfresco.repo.search.impl.lucene.analysis;
|
||||
|
||||
import org.apache.lucene.analysis.snowball.SnowballAnalyzer;
|
||||
|
||||
public class FinnishSnowballAnalyser extends SnowballAnalyzer
|
||||
{
|
||||
|
||||
public FinnishSnowballAnalyser()
|
||||
{
|
||||
super("Finnish");
|
||||
}
|
||||
}
|
@@ -1,3 +1,27 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
package org.alfresco.repo.search.impl.lucene.analysis;
|
||||
|
||||
import org.apache.lucene.analysis.snowball.SnowballAnalyzer;
|
||||
@@ -7,6 +31,6 @@ public class FrenchSnowballAnalyser extends SnowballAnalyzer
|
||||
|
||||
public FrenchSnowballAnalyser()
|
||||
{
|
||||
super("Danish");
|
||||
super("French");
|
||||
}
|
||||
}
|
||||
|
@@ -1,3 +1,27 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
package org.alfresco.repo.search.impl.lucene.analysis;
|
||||
|
||||
import org.apache.lucene.analysis.snowball.SnowballAnalyzer;
|
||||
@@ -7,6 +31,6 @@ public class German2SnowballAnalyser extends SnowballAnalyzer
|
||||
|
||||
public German2SnowballAnalyser()
|
||||
{
|
||||
super("Danish");
|
||||
super("German2");
|
||||
}
|
||||
}
|
||||
|
@@ -1,3 +1,27 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
package org.alfresco.repo.search.impl.lucene.analysis;
|
||||
|
||||
import org.apache.lucene.analysis.snowball.SnowballAnalyzer;
|
||||
@@ -7,6 +31,6 @@ public class GermanSnowballAnalyser extends SnowballAnalyzer
|
||||
|
||||
public GermanSnowballAnalyser()
|
||||
{
|
||||
super("Danish");
|
||||
super("German");
|
||||
}
|
||||
}
|
||||
|
@@ -1,3 +1,27 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
package org.alfresco.repo.search.impl.lucene.analysis;
|
||||
|
||||
import org.apache.lucene.analysis.snowball.SnowballAnalyzer;
|
||||
@@ -7,6 +31,6 @@ public class ItalianSnowballAnalyser extends SnowballAnalyzer
|
||||
|
||||
public ItalianSnowballAnalyser()
|
||||
{
|
||||
super("Danish");
|
||||
super("Italian");
|
||||
}
|
||||
}
|
||||
|
@@ -1,3 +1,27 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
package org.alfresco.repo.search.impl.lucene.analysis;
|
||||
|
||||
import org.apache.lucene.analysis.snowball.SnowballAnalyzer;
|
||||
@@ -7,6 +31,6 @@ public class KPSnowballAnalyser extends SnowballAnalyzer
|
||||
|
||||
public KPSnowballAnalyser()
|
||||
{
|
||||
super("Danish");
|
||||
super("Kp");
|
||||
}
|
||||
}
|
||||
|
@@ -1,3 +1,27 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
package org.alfresco.repo.search.impl.lucene.analysis;
|
||||
|
||||
import org.apache.lucene.analysis.snowball.SnowballAnalyzer;
|
||||
@@ -7,6 +31,6 @@ public class LovinsSnowballAnalyser extends SnowballAnalyzer
|
||||
|
||||
public LovinsSnowballAnalyser()
|
||||
{
|
||||
super("Danish");
|
||||
super("Lovins");
|
||||
}
|
||||
}
|
||||
|
@@ -1,3 +1,27 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
package org.alfresco.repo.search.impl.lucene.analysis;
|
||||
|
||||
public class LowerCaseVerbatimAnalyser extends VerbatimAnalyser
|
||||
|
@@ -1,3 +1,27 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
package org.alfresco.repo.search.impl.lucene.analysis;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
|
@@ -1,3 +1,27 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
package org.alfresco.repo.search.impl.lucene.analysis;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@@ -1,3 +1,27 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
package org.alfresco.repo.search.impl.lucene.analysis;
|
||||
|
||||
import org.apache.lucene.analysis.snowball.SnowballAnalyzer;
|
||||
@@ -7,6 +31,6 @@ public class NorwegianSnowballAnalyser extends SnowballAnalyzer
|
||||
|
||||
public NorwegianSnowballAnalyser()
|
||||
{
|
||||
super("Danish");
|
||||
super("Norwegian");
|
||||
}
|
||||
}
|
||||
|
@@ -1,3 +1,27 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
package org.alfresco.repo.search.impl.lucene.analysis;
|
||||
|
||||
import org.apache.lucene.analysis.snowball.SnowballAnalyzer;
|
||||
@@ -7,6 +31,6 @@ public class PorterSnowballAnalyser extends SnowballAnalyzer
|
||||
|
||||
public PorterSnowballAnalyser()
|
||||
{
|
||||
super("Danish");
|
||||
super("Porter");
|
||||
}
|
||||
}
|
||||
|
@@ -1,3 +1,27 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
package org.alfresco.repo.search.impl.lucene.analysis;
|
||||
|
||||
import org.apache.lucene.analysis.snowball.SnowballAnalyzer;
|
||||
@@ -7,6 +31,6 @@ public class PortugueseSnowballAnalyser extends SnowballAnalyzer
|
||||
|
||||
public PortugueseSnowballAnalyser()
|
||||
{
|
||||
super("Danish");
|
||||
super("Portuguese");
|
||||
}
|
||||
}
|
||||
|
@@ -1,3 +1,27 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
package org.alfresco.repo.search.impl.lucene.analysis;
|
||||
|
||||
import org.apache.lucene.analysis.snowball.SnowballAnalyzer;
|
||||
@@ -7,6 +31,6 @@ public class RussianSnowballAnalyser extends SnowballAnalyzer
|
||||
|
||||
public RussianSnowballAnalyser()
|
||||
{
|
||||
super("Danish");
|
||||
super("Russian");
|
||||
}
|
||||
}
|
||||
|
@@ -1,3 +1,27 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
package org.alfresco.repo.search.impl.lucene.analysis;
|
||||
|
||||
import org.apache.lucene.analysis.snowball.SnowballAnalyzer;
|
||||
@@ -7,6 +31,6 @@ public class SpanishSnowballAnalyser extends SnowballAnalyzer
|
||||
|
||||
public SpanishSnowballAnalyser()
|
||||
{
|
||||
super("Danish");
|
||||
super("Spanish");
|
||||
}
|
||||
}
|
||||
|
@@ -1,3 +1,27 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
package org.alfresco.repo.search.impl.lucene.analysis;
|
||||
|
||||
import org.apache.lucene.analysis.snowball.SnowballAnalyzer;
|
||||
@@ -7,6 +31,6 @@ public class SwedishSnowballAnalyser extends SnowballAnalyzer
|
||||
|
||||
public SwedishSnowballAnalyser()
|
||||
{
|
||||
super("Danish");
|
||||
super("Swedish");
|
||||
}
|
||||
}
|
||||
|
@@ -1,3 +1,27 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
package org.alfresco.repo.search.impl.lucene.analysis;
|
||||
|
||||
import java.io.Reader;
|
||||
|
@@ -1,3 +1,27 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
package org.alfresco.repo.search.impl.lucene.analysis;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@@ -38,6 +38,7 @@ import org.alfresco.repo.security.permissions.AccessDeniedException;
|
||||
import org.alfresco.service.transaction.TransactionService;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.hibernate.ObjectNotFoundException;
|
||||
import org.hibernate.StaleObjectStateException;
|
||||
import org.hibernate.StaleStateException;
|
||||
import org.hibernate.exception.ConstraintViolationException;
|
||||
@@ -73,7 +74,8 @@ public class RetryingTransactionHelper
|
||||
BatchUpdateException.class,
|
||||
ConstraintViolationException.class,
|
||||
DataIntegrityViolationException.class,
|
||||
StaleStateException.class
|
||||
StaleStateException.class,
|
||||
ObjectNotFoundException.class
|
||||
};
|
||||
}
|
||||
|
||||
@@ -398,6 +400,15 @@ public class RetryingTransactionHelper
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (retryCause instanceof ObjectNotFoundException)
|
||||
{
|
||||
// This is (I'm almost certain) an optimistic locking failure in disguise.
|
||||
if (retryCause.getMessage().contains("No row"))
|
||||
{
|
||||
return retryCause;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
return retryCause;
|
||||
|
Reference in New Issue
Block a user