mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
More SearchService refactor. Added CMIS SQL to the search service. Tidy ups. FTS supports default namespace and templates via search parameters API. (MOB-568, MOB-569)
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@14463 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -25,9 +25,11 @@
|
||||
package org.alfresco.cmis.search;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -37,10 +39,13 @@ import org.alfresco.cmis.CMISResultSet;
|
||||
import org.alfresco.cmis.CMISResultSetMetaData;
|
||||
import org.alfresco.cmis.CMISResultSetRow;
|
||||
import org.alfresco.repo.search.impl.querymodel.Query;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
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.alfresco.service.cmr.search.ResultSetRow;
|
||||
|
||||
/**
|
||||
* @author andyh
|
||||
@@ -58,15 +63,18 @@ public class CMISResultSetImpl implements CMISResultSet, Serializable
|
||||
Query query;
|
||||
|
||||
CMISDictionaryService cmisDictionaryService;
|
||||
|
||||
DictionaryService alfrescoDictionaryService;
|
||||
|
||||
|
||||
public CMISResultSetImpl(Map<String, ResultSet> wrapped, CMISQueryOptions options, NodeService nodeService, Query query, CMISDictionaryService cmisDictionaryService)
|
||||
public CMISResultSetImpl(Map<String, ResultSet> wrapped, CMISQueryOptions options, NodeService nodeService, Query query, CMISDictionaryService cmisDictionaryService, DictionaryService alfrescoDictionaryService)
|
||||
{
|
||||
this.wrapped = wrapped;
|
||||
this.options = options;
|
||||
this.nodeService = nodeService;
|
||||
this.query = query;
|
||||
this.cmisDictionaryService = cmisDictionaryService;
|
||||
this.alfrescoDictionaryService = alfrescoDictionaryService;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -95,7 +103,7 @@ public class CMISResultSetImpl implements CMISResultSet, Serializable
|
||||
*/
|
||||
public CMISResultSetMetaData getMetaData()
|
||||
{
|
||||
return new CMISResultSetMetaDataImpl(options, query, cmisDictionaryService);
|
||||
return new CMISResultSetMetaDataImpl(options, query, cmisDictionaryService, alfrescoDictionaryService);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -197,4 +205,68 @@ public class CMISResultSetImpl implements CMISResultSet, Serializable
|
||||
return scores;
|
||||
}
|
||||
|
||||
public ChildAssociationRef getChildAssocRef(int n)
|
||||
{
|
||||
NodeRef nodeRef = getNodeRef(n);
|
||||
return nodeService.getPrimaryParent(nodeRef);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public List<ChildAssociationRef> getChildAssocRefs()
|
||||
{
|
||||
ArrayList<ChildAssociationRef> cars = new ArrayList<ChildAssociationRef>(length());
|
||||
for (ResultSetRow row : this)
|
||||
{
|
||||
cars.add(row.getChildAssocRef());
|
||||
}
|
||||
return cars;
|
||||
}
|
||||
|
||||
public NodeRef getNodeRef(int n)
|
||||
{
|
||||
Map<String, NodeRef> refs = getNodeRefs(n);
|
||||
if(refs.size() == 1)
|
||||
{
|
||||
return refs.values().iterator().next();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalStateException("Ambiguous selector");
|
||||
}
|
||||
}
|
||||
|
||||
public List<NodeRef> getNodeRefs()
|
||||
{
|
||||
ArrayList<NodeRef> nodeRefs = new ArrayList<NodeRef>(length());
|
||||
for (ResultSetRow row : this)
|
||||
{
|
||||
nodeRefs.add(row.getNodeRef());
|
||||
}
|
||||
return nodeRefs;
|
||||
}
|
||||
|
||||
public CMISResultSetMetaData getResultSetMetaData()
|
||||
{
|
||||
return getMetaData();
|
||||
}
|
||||
|
||||
public float getScore(int n)
|
||||
{
|
||||
Map<String, Float> scores = getScores(n);
|
||||
if(scores.size() == 1)
|
||||
{
|
||||
return scores.values().iterator().next();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalStateException("Ambiguous selector");
|
||||
}
|
||||
}
|
||||
|
||||
public int length()
|
||||
{
|
||||
return getLength();
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user