Refactor CMIS property accessors (value / lucene mappers).

- remove notion of generic property accessor; consolidated on named property accessor
- build property accessors at time of CMIS Dictionary creation (cached, removes continuous creation of small objects); hooked into CMIS Property Definition
- remove property service
- lookup of property accessor quicker and constrained to properties in CMIS Dictionary
- fixup fallout in CMIS AtomPub, Web Services and Query

CMIS AtomPub, Web Services and Query tests pass.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@13806 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
David Caruana
2009-04-02 12:06:26 +00:00
parent 2b111d1b6f
commit af2b4f43c4
49 changed files with 1409 additions and 2649 deletions

View File

@@ -30,8 +30,6 @@ import java.util.Map;
import org.alfresco.cmis.dictionary.CMISDictionaryService;
import org.alfresco.cmis.dictionary.CMISPropertyDefinition;
import org.alfresco.cmis.property.CMISPropertyService;
import org.alfresco.cmis.property.CMISPropertyServiceImpl;
import org.alfresco.repo.search.impl.lucene.LuceneQueryParser;
import org.alfresco.repo.search.impl.querymodel.FunctionEvaluationContext;
import org.alfresco.repo.search.impl.querymodel.PredicateMode;
@@ -52,8 +50,6 @@ public class CmisFunctionEvaluationContext implements FunctionEvaluationContext
private NodeService nodeService;
private CMISPropertyService cmisPropertyService;
private CMISDictionaryService cmisDictionaryService;
private Float score;
@@ -85,15 +81,6 @@ public class CmisFunctionEvaluationContext implements FunctionEvaluationContext
this.nodeService = nodeService;
}
/**
* @param cmisPropertyService
* the cmisPropertyService to set
*/
public void setCmisPropertyService(CMISPropertyService cmisPropertyService)
{
this.cmisPropertyService = cmisPropertyService;
}
/**
* @param cmisDictionaryService
* the cmisDictionaryService to set
@@ -132,7 +119,7 @@ public class CmisFunctionEvaluationContext implements FunctionEvaluationContext
public Serializable getProperty(NodeRef nodeRef, QName propertyQName)
{
CMISPropertyDefinition propertyDef = cmisDictionaryService.findProperty(propertyQName, null);
return cmisPropertyService.getProperty(nodeRef, propertyDef.getPropertyId().getName());
return propertyDef.getPropertyAccessor().getValue(nodeRef);
}
/*
@@ -164,16 +151,8 @@ public class CmisFunctionEvaluationContext implements FunctionEvaluationContext
public Query buildLuceneEquality(LuceneQueryParser lqp, QName propertyQName, Serializable value, PredicateMode mode) throws ParseException
{
if (cmisPropertyService instanceof CMISPropertyServiceImpl)
{
CMISPropertyDefinition propertyDef = cmisDictionaryService.findProperty(propertyQName, null);
CMISPropertyServiceImpl impl = (CMISPropertyServiceImpl) cmisPropertyService;
return impl.buildLuceneEquality(lqp, propertyDef.getPropertyId().getName(), value, mode);
}
else
{
return null;
}
CMISPropertyDefinition propertyDef = cmisDictionaryService.findProperty(propertyQName, null);
return propertyDef.getPropertyLuceneBuilder().buildLuceneEquality(lqp, value, mode);
}
/*
@@ -184,16 +163,8 @@ public class CmisFunctionEvaluationContext implements FunctionEvaluationContext
*/
public Query buildLuceneExists(LuceneQueryParser lqp, QName propertyQName, Boolean not) throws ParseException
{
if (cmisPropertyService instanceof CMISPropertyServiceImpl)
{
CMISPropertyDefinition propertyDef = cmisDictionaryService.findProperty(propertyQName, null);
CMISPropertyServiceImpl impl = (CMISPropertyServiceImpl) cmisPropertyService;
return impl.buildLuceneExists(lqp, propertyDef.getPropertyId().getName(), not);
}
else
{
return null;
}
CMISPropertyDefinition propertyDef = cmisDictionaryService.findProperty(propertyQName, null);
return propertyDef.getPropertyLuceneBuilder().buildLuceneExists(lqp, not);
}
/*
@@ -205,16 +176,8 @@ public class CmisFunctionEvaluationContext implements FunctionEvaluationContext
*/
public Query buildLuceneGreaterThan(LuceneQueryParser lqp, QName propertyQName, Serializable value, PredicateMode mode) throws ParseException
{
if (cmisPropertyService instanceof CMISPropertyServiceImpl)
{
CMISPropertyDefinition propertyDef = cmisDictionaryService.findProperty(propertyQName, null);
CMISPropertyServiceImpl impl = (CMISPropertyServiceImpl) cmisPropertyService;
return impl.buildLuceneGreaterThan(lqp, propertyDef.getPropertyId().getName(), value, mode);
}
else
{
return null;
}
CMISPropertyDefinition propertyDef = cmisDictionaryService.findProperty(propertyQName, null);
return propertyDef.getPropertyLuceneBuilder().buildLuceneGreaterThan(lqp, value, mode);
}
/*
@@ -226,16 +189,8 @@ public class CmisFunctionEvaluationContext implements FunctionEvaluationContext
*/
public Query buildLuceneGreaterThanOrEquals(LuceneQueryParser lqp, QName propertyQName, Serializable value, PredicateMode mode) throws ParseException
{
if (cmisPropertyService instanceof CMISPropertyServiceImpl)
{
CMISPropertyDefinition propertyDef = cmisDictionaryService.findProperty(propertyQName, null);
CMISPropertyServiceImpl impl = (CMISPropertyServiceImpl) cmisPropertyService;
return impl.buildLuceneGreaterThanOrEquals(lqp, propertyDef.getPropertyId().getName(), value, mode);
}
else
{
return null;
}
CMISPropertyDefinition propertyDef = cmisDictionaryService.findProperty(propertyQName, null);
return propertyDef.getPropertyLuceneBuilder().buildLuceneGreaterThanOrEquals(lqp, value, mode);
}
/*
@@ -247,16 +202,8 @@ public class CmisFunctionEvaluationContext implements FunctionEvaluationContext
*/
public Query buildLuceneIn(LuceneQueryParser lqp, QName propertyQName, Collection<Serializable> values, Boolean not, PredicateMode mode) throws ParseException
{
if (cmisPropertyService instanceof CMISPropertyServiceImpl)
{
CMISPropertyDefinition propertyDef = cmisDictionaryService.findProperty(propertyQName, null);
CMISPropertyServiceImpl impl = (CMISPropertyServiceImpl) cmisPropertyService;
return impl.buildLuceneIn(lqp, propertyDef.getPropertyId().getName(), values, not, mode);
}
else
{
return null;
}
CMISPropertyDefinition propertyDef = cmisDictionaryService.findProperty(propertyQName, null);
return propertyDef.getPropertyLuceneBuilder().buildLuceneIn(lqp, values, not, mode);
}
/*
@@ -268,16 +215,8 @@ public class CmisFunctionEvaluationContext implements FunctionEvaluationContext
*/
public Query buildLuceneInequality(LuceneQueryParser lqp, QName propertyQName, Serializable value, PredicateMode mode) throws ParseException
{
if (cmisPropertyService instanceof CMISPropertyServiceImpl)
{
CMISPropertyDefinition propertyDef = cmisDictionaryService.findProperty(propertyQName, null);
CMISPropertyServiceImpl impl = (CMISPropertyServiceImpl) cmisPropertyService;
return impl.buildLuceneInequality(lqp, propertyDef.getPropertyId().getName(), value, mode);
}
else
{
return null;
}
CMISPropertyDefinition propertyDef = cmisDictionaryService.findProperty(propertyQName, null);
return propertyDef.getPropertyLuceneBuilder().buildLuceneInequality(lqp, value, mode);
}
/*
@@ -289,16 +228,8 @@ public class CmisFunctionEvaluationContext implements FunctionEvaluationContext
*/
public Query buildLuceneLessThan(LuceneQueryParser lqp, QName propertyQName, Serializable value, PredicateMode mode) throws ParseException
{
if (cmisPropertyService instanceof CMISPropertyServiceImpl)
{
CMISPropertyDefinition propertyDef = cmisDictionaryService.findProperty(propertyQName, null);
CMISPropertyServiceImpl impl = (CMISPropertyServiceImpl) cmisPropertyService;
return impl.buildLuceneLessThan(lqp, propertyDef.getPropertyId().getName(), value, mode);
}
else
{
return null;
}
CMISPropertyDefinition propertyDef = cmisDictionaryService.findProperty(propertyQName, null);
return propertyDef.getPropertyLuceneBuilder().buildLuceneLessThan(lqp, value, mode);
}
/*
@@ -310,16 +241,8 @@ public class CmisFunctionEvaluationContext implements FunctionEvaluationContext
*/
public Query buildLuceneLessThanOrEquals(LuceneQueryParser lqp, QName propertyQName, Serializable value, PredicateMode mode) throws ParseException
{
if (cmisPropertyService instanceof CMISPropertyServiceImpl)
{
CMISPropertyDefinition propertyDef = cmisDictionaryService.findProperty(propertyQName, null);
CMISPropertyServiceImpl impl = (CMISPropertyServiceImpl) cmisPropertyService;
return impl.buildLuceneLessThanOrEquals(lqp, propertyDef.getPropertyId().getName(), value, mode);
}
else
{
return null;
}
CMISPropertyDefinition propertyDef = cmisDictionaryService.findProperty(propertyQName, null);
return propertyDef.getPropertyLuceneBuilder().buildLuceneLessThanOrEquals(lqp, value, mode);
}
/*
@@ -330,16 +253,8 @@ public class CmisFunctionEvaluationContext implements FunctionEvaluationContext
*/
public Query buildLuceneLike(LuceneQueryParser lqp, QName propertyQName, Serializable value, Boolean not) throws ParseException
{
if (cmisPropertyService instanceof CMISPropertyServiceImpl)
{
CMISPropertyDefinition propertyDef = cmisDictionaryService.findProperty(propertyQName, null);
CMISPropertyServiceImpl impl = (CMISPropertyServiceImpl) cmisPropertyService;
return impl.buildLuceneLike(lqp, propertyDef.getPropertyId().getName(), value, not);
}
else
{
return null;
}
CMISPropertyDefinition propertyDef = cmisDictionaryService.findProperty(propertyQName, null);
return propertyDef.getPropertyLuceneBuilder().buildLuceneLike(lqp, value, not);
}
/* (non-Javadoc)
@@ -347,16 +262,8 @@ public class CmisFunctionEvaluationContext implements FunctionEvaluationContext
*/
public String getLuceneSortField(QName propertyQName)
{
if (cmisPropertyService instanceof CMISPropertyServiceImpl)
{
CMISPropertyDefinition propertyDef = cmisDictionaryService.findProperty(propertyQName, null);
CMISPropertyServiceImpl impl = (CMISPropertyServiceImpl) cmisPropertyService;
return impl.getLuceneSortField(propertyDef.getPropertyId().getName());
}
else
{
return null;
}
CMISPropertyDefinition propertyDef = cmisDictionaryService.findProperty(propertyQName, null);
return propertyDef.getPropertyLuceneBuilder().getLuceneSortField();
}
}