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

@@ -32,13 +32,11 @@ import java.util.Map;
import java.util.Set;
import org.alfresco.cmis.dictionary.CMISDictionaryService;
import org.alfresco.cmis.property.CMISPropertyService;
import org.alfresco.repo.search.impl.querymodel.Query;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.search.LimitBy;
import org.alfresco.service.cmr.search.ResultSet;
import org.springframework.web.servlet.tags.form.OptionTag;
/**
* @author andyh
@@ -57,17 +55,14 @@ public class CMISResultSetImpl implements CMISResultSet, Serializable
CMISDictionaryService cmisDictionaryService;
CMISPropertyService cmisPropertyService;
public CMISResultSetImpl(Map<String, ResultSet> wrapped, CMISQueryOptions options, NodeService nodeService, Query query, CMISDictionaryService cmisDictionaryService,
CMISPropertyService cmisPropertyService)
public CMISResultSetImpl(Map<String, ResultSet> wrapped, CMISQueryOptions options, NodeService nodeService, Query query, CMISDictionaryService cmisDictionaryService)
{
this.wrapped = wrapped;
this.options = options;
this.nodeService = nodeService;
this.query = query;
this.cmisDictionaryService = cmisDictionaryService;
this.cmisPropertyService = cmisPropertyService;
}
/*
@@ -106,7 +101,7 @@ public class CMISResultSetImpl implements CMISResultSet, Serializable
*/
public CMISResultSetRow getRow(int i)
{
return new CMISResultSetRowImpl(this, i, getScores(i), nodeService, getNodeRefs(i), query, cmisPropertyService, cmisDictionaryService);
return new CMISResultSetRowImpl(this, i, getScores(i), nodeService, getNodeRefs(i), query, cmisDictionaryService);
}
/*

View File

@@ -29,7 +29,6 @@ import java.util.LinkedHashMap;
import java.util.Map;
import org.alfresco.cmis.dictionary.CMISDictionaryService;
import org.alfresco.cmis.property.CMISPropertyService;
import org.alfresco.repo.search.impl.querymodel.Column;
import org.alfresco.repo.search.impl.querymodel.Query;
import org.alfresco.service.cmr.repository.NodeRef;
@@ -58,11 +57,9 @@ public class CMISResultSetRowImpl implements CMISResultSetRow
private Query query;
private CMISPropertyService cmisPropertyService;
private CMISDictionaryService cmisDictionaryService;
public CMISResultSetRowImpl(CMISResultSet resultSet, int index, Map<String, Float> scores, NodeService nodeService, Map<String, NodeRef> nodeRefs, Query query, CMISPropertyService cmisPropertyService, CMISDictionaryService cmisDictionaryService )
public CMISResultSetRowImpl(CMISResultSet resultSet, int index, Map<String, Float> scores, NodeService nodeService, Map<String, NodeRef> nodeRefs, Query query, CMISDictionaryService cmisDictionaryService)
{
this.resultSet = resultSet;
this.index = index;
@@ -70,7 +67,6 @@ public class CMISResultSetRowImpl implements CMISResultSetRow
this.nodeService = nodeService;
this.nodeRefs = nodeRefs;
this.query = query;
this.cmisPropertyService = cmisPropertyService;
this.cmisDictionaryService = cmisDictionaryService;
}
@@ -163,7 +159,6 @@ public class CMISResultSetRowImpl implements CMISResultSetRow
{
CmisFunctionEvaluationContext context = new CmisFunctionEvaluationContext();
context.setCmisDictionaryService(cmisDictionaryService);
context.setCmisPropertyService(cmisPropertyService);
context.setNodeRefs(nodeRefs);
context.setNodeService(nodeService);
context.setScores(scores);

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();
}
}

View File

@@ -305,7 +305,7 @@ public class QueryTest extends BaseCMISTest
returnValue = (T) DefaultTypeConverter.INSTANCE.convert(returnType.getClass(), sValue);
if (dump)
{
System.out.println(cmisPropertyService.getProperties(row.getNodeRef(rs.getMetaData().getSelectorNames()[0])));
System.out.println(cmisService.getProperties(row.getNodeRef(rs.getMetaData().getSelectorNames()[0])));
}
}
if (dump)
@@ -1346,7 +1346,7 @@ public class QueryTest extends BaseCMISTest
{
String companyHomeId = testQuery("SELECT ObjectId FROM Folder WHERE Name = '\"Folder 0\"'", 1, false, "ObjectId", new String(), false);
Serializable ser = cmisPropertyService.getProperty(f0, CMISDictionaryModel.PROP_OBJECT_ID);
Serializable ser = cmisService.getProperty(f0, CMISDictionaryModel.PROP_OBJECT_ID);
String id = DefaultTypeConverter.INSTANCE.convert(String.class, ser);
assertEquals(companyHomeId, id);
@@ -1490,7 +1490,7 @@ public class QueryTest extends BaseCMISTest
public void testFolderEquals()
{
Serializable ser = cmisPropertyService.getProperty(f0, CMISDictionaryModel.PROP_NAME);
Serializable ser = cmisService.getProperty(f0, CMISDictionaryModel.PROP_NAME);
String Name = DefaultTypeConverter.INSTANCE.convert(String.class, ser);
testQuery("SELECT * FROM Folder WHERE Name = '" + Name + "'", 1, false, "ObjectId", new String(), false);
@@ -1501,7 +1501,7 @@ public class QueryTest extends BaseCMISTest
public void test_IN_TREE()
{
Serializable ser = cmisPropertyService.getProperty(f0, CMISDictionaryModel.PROP_OBJECT_ID);
Serializable ser = cmisService.getProperty(f0, CMISDictionaryModel.PROP_OBJECT_ID);
String id = DefaultTypeConverter.INSTANCE.convert(String.class, ser);
testQuery("SELECT * FROM Folder WHERE IN_TREE('" + id + "')", 6, false, "ObjectId", new String(), false);
@@ -1509,7 +1509,7 @@ public class QueryTest extends BaseCMISTest
public void test_IN_FOLDER()
{
Serializable ser = cmisPropertyService.getProperty(f0, CMISDictionaryModel.PROP_OBJECT_ID);
Serializable ser = cmisService.getProperty(f0, CMISDictionaryModel.PROP_OBJECT_ID);
String id = DefaultTypeConverter.INSTANCE.convert(String.class, ser);
testQuery("SELECT * FROM Folder WHERE IN_FOLDER('" + id + "')", 2, false, "ObjectId", new String(), false);

View File

@@ -33,8 +33,6 @@ import org.alfresco.cmis.CMISJoinEnum;
import org.alfresco.cmis.CMISQueryEnum;
import org.alfresco.cmis.CMISService;
import org.alfresco.cmis.dictionary.CMISDictionaryService;
import org.alfresco.cmis.dictionary.CMISMapping;
import org.alfresco.cmis.property.CMISPropertyService;
import org.alfresco.cmis.search.CMISQueryOptions;
import org.alfresco.cmis.search.CMISQueryService;
import org.alfresco.cmis.search.CMISResultSet;
@@ -55,8 +53,6 @@ public class CMISQueryServiceImpl implements CMISQueryService
private CMISDictionaryService cmisDictionaryService;
private CMISPropertyService cmisPropertyService;
private QueryEngine queryEngine;
private NodeService nodeService;
@@ -65,7 +61,7 @@ public class CMISQueryServiceImpl implements CMISQueryService
* @param service
* the service to set
*/
public void setCmisService(CMISService cmisService)
public void setCMISService(CMISService cmisService)
{
this.cmisService = cmisService;
}
@@ -74,7 +70,7 @@ public class CMISQueryServiceImpl implements CMISQueryService
* @param cmisDictionaryService
* the cmisDictionaryService to set
*/
public void setCmisDictionaryService(CMISDictionaryService cmisDictionaryService)
public void setCMISDictionaryService(CMISDictionaryService cmisDictionaryService)
{
this.cmisDictionaryService = cmisDictionaryService;
}
@@ -97,15 +93,6 @@ public class CMISQueryServiceImpl implements CMISQueryService
this.nodeService = nodeService;
}
/**
* @param cmisPropertyService
* the cmisPropertyService to set
*/
public void setCmisPropertyService(CMISPropertyService cmisPropertyService)
{
this.cmisPropertyService = cmisPropertyService;
}
/*
* (non-Javadoc)
*
@@ -123,7 +110,6 @@ public class CMISQueryServiceImpl implements CMISQueryService
CmisFunctionEvaluationContext functionContext = new CmisFunctionEvaluationContext();
functionContext.setCmisDictionaryService(cmisDictionaryService);
functionContext.setCmisPropertyService(cmisPropertyService);
functionContext.setNodeService(nodeService);
QueryEngineResults results = queryEngine.executeQuery(query, options, functionContext);
@@ -137,7 +123,7 @@ public class CMISQueryServiceImpl implements CMISQueryService
wrapped.put(selector, current);
}
}
CMISResultSet cmis = new CMISResultSetImpl(wrapped, options, nodeService, query, cmisDictionaryService, cmisPropertyService);
CMISResultSet cmis = new CMISResultSetImpl(wrapped, options, nodeService, query, cmisDictionaryService);
return cmis;
}