First pass at fixes/extensions/tidy ups to the search API - part of wiring FTS up as a query language MOB-568

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@14361 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Andrew Hind
2009-05-19 14:06:15 +00:00
parent 418035df05
commit d195ff8542
37 changed files with 2085 additions and 1261 deletions

View File

@@ -31,11 +31,15 @@ import java.util.Map;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.Path;
import org.alfresco.service.cmr.search.ResultSet;
import org.alfresco.service.cmr.search.ResultSetRow;
import org.alfresco.service.namespace.QName;
/**
* Common support for a row in a result set
*
* @author andyh
*/
public abstract class AbstractResultSetRow implements ResultSetRow
{
@@ -50,12 +54,17 @@ public abstract class AbstractResultSetRow implements ResultSetRow
private int index;
/**
* The direct properties of the current node
* Used by those implementations that can cache the whole set.
* The direct properties of the current node Used by those implementations that can cache the whole set.
*/
private Map<Path, Serializable> properties;
protected Map<String, Serializable> properties;
/**
* The row needs the result set and the index for lookup.
*
* @param resultSet
* @param index
*/
public AbstractResultSetRow(ResultSet resultSet, int index)
{
super();
@@ -82,55 +91,49 @@ public abstract class AbstractResultSetRow implements ResultSetRow
{
return getResultSet().getChildAssocRef(getIndex()).getQName();
}
public ChildAssociationRef getChildAssocRef()
{
return getResultSet().getChildAssocRef(getIndex());
}
public float getScore()
{
return getResultSet().getScore(getIndex());
}
public Map<Path, Serializable> getValues()
public Map<String, Serializable> getValues()
{
if (properties == null)
{
properties = new HashMap<Path, Serializable>();
properties = new HashMap<String, Serializable>();
setProperties(getDirectProperties());
}
return Collections.unmodifiableMap(properties);
}
public Serializable getValue(Path path)
public Serializable getValue(String columnName)
{
return properties.get(path);
return properties.get(columnName);
}
protected Map<QName, Serializable> getDirectProperties()
{
return Collections.<QName, Serializable>emptyMap();
return Collections.<QName, Serializable> emptyMap();
}
protected void setProperties(Map<QName, Serializable> byQname)
{
for (QName qname : byQname.keySet())
{
Serializable value = byQname.get(qname);
Path path = new Path();
path.append(new Path.SelfElement());
path.append(new Path.AttributeElement(qname));
properties.put(path, value);
properties.put(qname.toString(), value);
}
}
public Serializable getValue(QName qname)
{
Path path = new Path();
path.append(new Path.SelfElement());
path.append(new Path.AttributeElement(qname));
return getValues().get(path);
return getValues().get(qname.toString());
}
}