04-16-2010 05:01 AM
04-20-2010 02:09 AM
04-26-2010 06:05 AM
04-30-2010 03:47 AM
You should use the nodeService to retrieve the properties from the node using the references you get from the searchservice. The nodeService has no references to the FacesContext (at least, that i know of) …
05-02-2010 01:53 AM
05-03-2010 05:03 AM
05-03-2010 09:32 AM
package com.ia.search;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.dictionary.TypeDefinition;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.search.ResultSet;
import org.alfresco.service.cmr.search.ResultSetRow;
import org.alfresco.service.namespace.QName;
import org.alfresco.web.bean.repository.Node;
import org.alfresco.web.scripts.WebScriptRequest;
import com.ia.model.ContentModel;
import com.ia.utils.RepoSearchInitializer;
import com.ia.utils.RepoSearchUtils;
import com.ia.utils.RepositoryConstants;
import org.json.JSONArray;
public class SearchResourceAction {
private transient ServiceRegistry serviceRegistry;
public Map<String, Object> searchRepository()
{
Map<String, Object> model = null;
Map<String, Object> nodeProperties = null;
Map<String, NodeRef> nodeRefs = null;
ArrayList resultList = new ArrayList();
try
{
model = new HashMap<String, Object>();
String qry = "@\\{com.ia.repository\\}empName:amarendra";
SearchParameters sp = new SearchParameters();
sp.addStore(Repository.getStoreRef());
sp.setLanguage(SearchService.LANGUAGE_LUCENE);
sp.setQuery(qryString.toString());
ResultSet results = null;
Node alfNode = null;
try
{
results = serviceRegistry.getSearchService().query();
if(results!=null && results.length()>0)
{
for(ResultSetRow row : results)
{
NodeRef currentNodeRef = row.getNodeRef();
if (serviceRegistry.getNodeService().exists(currentNodeRef))
{
QName type = serviceRegistry.getNodeService().getType(currentNodeRef);
TypeDefinition typeDef = serviceRegistry.getDictionaryService().getType(type);
if (typeDef != null)
{
if (serviceRegistry.getDictionaryService().isSubClass(type, ContentModel.TYPE_RESOURCE))
{
alfNode = new Node(currentNodeRef);
resultList.add(alfNode);
}
}
}
}
model.put("node", resultList);
model.put("total", String.valueOf(resultList.size()));
}
else
{
}
}
catch(Exception e1)
{
e1.printStackTrace();
}
finally
{
if(results != null)
{
results.close();
//tx.commit();
}
}
}
catch (Exception e) {
e.printStackTrace();
}
return model;
}
public ServiceRegistry getServiceRegistry() {
return serviceRegistry;
}
public void setServiceRegistry(ServiceRegistry serviceRegistry) {
this.serviceRegistry = serviceRegistry;
}
}
<#if node?exists>
{
"total":"${total}",
"result":[
<#list node as n>
{"Id":"${n.properties["km:Id"]}",
"Title":"${n.properties["km:Title"]}",
"Type":"${n.properties["km:Type"]}"}
<#if n_has_next>,</#if>
</#list>
]
}
<#else>
{
"total":"0",
"result":""
}
</#if>
05-05-2010 05:32 AM
NodeRef currentNodeRef = row.getNodeRef();
resultList.add(currentNodeRef);
String resultJSON = searchUtils.buildResult(resultList);
resultJsonObj.put("resObj", resultJSON);
resourceJSONArr.put(resultJsonObj);
model.put("resultNodeRef", resourceJSONArr.toString());
<import resource="classpath:alfresco/templates/webscripts/com/xyz/json.js">
var nodeRefList = resultNodeRef;
function main()
{
//var nodeRefList = resultNodeRef;
//model.resultNodeRef = resultNodeRef;
var resultList = null;
var finalResultList = new Array();
if(resultNodeRef!="[]")
{
var resultJSONArr = json.parse(resultNodeRef);
for(var i=0;i<resultJSONArr.length;i++)
{
var resultsStr = resultJSONArr[i].resObj;
model.resJson = resultsStr;
resultList = resultsStr.split(",");
}
if(resultList!=null)
{
for(var i=0;i<resultList.length;i++)
{
var resultNode = search.findNode(resultList[i]);
finalResultList.push(resultNode);
}
}
model.results = finalResultList;
}
else
{
//model.results = resultList;
}
}
main(); Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.