mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
RM-2501: New RM API, mirroring existing slingshot search API but adds in full node details to results.
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@110562 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
<webscript>
|
||||
<shortname>RM Faceted Search</shortname>
|
||||
<description>RM Faceted Search Component Data Webscript</description>
|
||||
<url>/slingshot/rmsearch/faceted/rmsearch?term={term?}&tag={tag?}&site={site?}&container={container?}&sort={sort?}&query={query?}&repo={repo?}</url>
|
||||
<format default="json">argument</format>
|
||||
<authentication>user</authentication>
|
||||
<transaction allow="readonly">required</transaction>
|
||||
<lifecycle>internal</lifecycle>
|
||||
</webscript>
|
@@ -0,0 +1,25 @@
|
||||
<import resource="classpath:/alfresco/templates/webscripts/org/alfresco/slingshot/search/search.lib.js">
|
||||
<import resource="classpath:/alfresco/templates/webscripts/org/alfresco/slingshot/rmsearch/faceted/rmsearch.lib.js">
|
||||
function main() {
|
||||
var params =
|
||||
{
|
||||
siteId: args.site,
|
||||
containerId: args.container,
|
||||
repo: (args.repo !== null) ? (args.repo == "true") : false,
|
||||
term: args.term,
|
||||
tag: args.tag,
|
||||
query: args.query,
|
||||
rootNode: args.rootNode,
|
||||
sort: args.sort,
|
||||
maxResults: (args.maxResults !== null) ? parseInt(args.maxResults, 10) : DEFAULT_MAX_RESULTS,
|
||||
pageSize: (args.pageSize !== null) ? parseInt(args.pageSize, 10) : DEFAULT_PAGE_SIZE,
|
||||
startIndex: (args.startIndex !== null) ? parseInt(args.startIndex, 10) : 0,
|
||||
facetFields: args.facetFields,
|
||||
filters: args.filters,
|
||||
spell: (args.spellcheck !== null) ? (args.spellcheck == "true") : false
|
||||
};
|
||||
|
||||
model.data = getSearchResults(params);
|
||||
};
|
||||
|
||||
main();
|
@@ -0,0 +1,88 @@
|
||||
<#--Copied from Share's search.get.json.ftl with RM specific additions noted below:-->
|
||||
<#escape x as jsonUtils.encodeJSONString(x)>
|
||||
{
|
||||
"totalRecords": ${data.paging.totalRecords?c},
|
||||
"totalRecordsUpper": ${data.paging.totalRecordsUpper?c},
|
||||
"startIndex": ${data.paging.startIndex?c},
|
||||
"numberFound": ${(data.paging.numberFound!-1)?c},
|
||||
"facets":
|
||||
{
|
||||
<#if data.facets??><#list data.facets?keys as field>
|
||||
"${field}":
|
||||
[
|
||||
<#assign facets=data.facets[field]><#list facets as f>
|
||||
{
|
||||
"label": "${f.facetLabel}",
|
||||
"value": "${f.facetValue}",
|
||||
"hits": ${f.hits?c},
|
||||
"index": ${f.facetLabelIndex?c}
|
||||
}<#if f_has_next>,</#if>
|
||||
</#list>
|
||||
]<#if field_has_next>,</#if>
|
||||
</#list></#if>
|
||||
},
|
||||
"items":
|
||||
[
|
||||
<#list data.items as item>
|
||||
{
|
||||
"nodeRef": "${item.nodeRef}",
|
||||
"type": "${item.type}",
|
||||
"name": "${item.name!''}",
|
||||
"displayName": "${item.displayName!''}",
|
||||
<#if item.title??>
|
||||
"title": "${item.title}",
|
||||
</#if>
|
||||
"description": "${item.description!''}",
|
||||
"modifiedOn": "${xmldate(item.modifiedOn)}",
|
||||
"modifiedByUser": "${item.modifiedByUser}",
|
||||
"modifiedBy": "${item.modifiedBy}",
|
||||
"fromDate": "${xmldate(item.fromDate)}",
|
||||
"size": ${item.size?c},
|
||||
"mimetype": "${item.mimetype!''}",
|
||||
<#if item.site??>
|
||||
"site":
|
||||
{
|
||||
"shortName": "${item.site.shortName}",
|
||||
"title": "${item.site.title}"
|
||||
},
|
||||
"container": "${item.container}",
|
||||
</#if>
|
||||
<#if item.path??>
|
||||
"path": "${item.path}",
|
||||
</#if>
|
||||
"lastThumbnailModification":
|
||||
[
|
||||
<#if item.lastThumbnailModification??>
|
||||
<#list item.lastThumbnailModification as lastThumbnailMod>
|
||||
"${lastThumbnailMod}"
|
||||
<#if lastThumbnailMod_has_next>,</#if>
|
||||
</#list>
|
||||
</#if>
|
||||
],
|
||||
"tags": [<#list item.tags as tag>"${tag}"<#if tag_has_next>,</#if></#list>],
|
||||
<#--Add in full node details-->
|
||||
"node": <#noescape>${item.nodeJSON}</#noescape>
|
||||
|
||||
}<#if item_has_next>,</#if>
|
||||
</#list>
|
||||
],
|
||||
"spellcheck":
|
||||
{
|
||||
<#if data.spellcheck?? && data.spellcheck.spellCheckExist>
|
||||
"searchRequest": "${data.spellcheck.originalSearchTerm}",
|
||||
<#if data.spellcheck.searchedFor>
|
||||
<#list data.spellcheck.results as collationQueryStr>
|
||||
"searchedFor": "${collationQueryStr?string}"
|
||||
<#break>
|
||||
</#list>
|
||||
<#else>
|
||||
"searchSuggestions": [
|
||||
<#list data.spellcheck.results as suggestion>
|
||||
"${suggestion?string}"<#if suggestion_has_next>,</#if>
|
||||
</#list>
|
||||
]
|
||||
</#if>
|
||||
</#if>
|
||||
}
|
||||
}
|
||||
</#escape>
|
@@ -0,0 +1,13 @@
|
||||
// RM Search Lib.
|
||||
|
||||
// Wrap the original document item method with our own one that appends RM specific properties.
|
||||
// Additional properties will also need rendering in rmsearch.get.json.ftl.
|
||||
var getOriginalDocumentItem = getDocumentItem;
|
||||
getDocumentItem = function(siteId, containerId, pathParts, node, populate){
|
||||
// Get original Document item.
|
||||
var item = getOriginalDocumentItem(siteId, containerId, pathParts, node, populate);
|
||||
|
||||
item.nodeJSON = appUtils.toJSON(node, true);
|
||||
|
||||
return item;
|
||||
};
|
Reference in New Issue
Block a user