查找具有特定子关联的节点

编程入门 行业动态 更新时间:2024-10-26 23:25:36
本文介绍了查找具有特定子关联的节点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在寻找一个查询(lucene,fts-alfresco或...)以返回所有具有特定子关联(不为null)的文档.

I am looking for a query (lucene, fts-alfresco or ...) to return all the document which have a specific child association (that is not null).

某些情况:类型为 abc:document 的文档具有子关联的 abc:linkedDocument .并非所有文档都链接了另一文档,有些文档没有链接.

Some context: Documents of type abc:document have a child-association abc:linkedDocument. Not all document have an other document linked to them, some have none some have one or multiple.

我需要一种快速简便的方法来概述所有确实链接有至少一个文档的文档.

I need a fast and easy way to get an overview of all the documents that do have at least one document linked to them.

目前,我有一个满足我需要的网页脚本,但宁愿不要拥有大量与业务无关的网页脚本.

Currently I have a webscript that does what I need, but prefer not to have tons of webscripts which are not business related.

代码:

SearchParameters sp = new SearchParameters(); String query = "TYPE:\"abc:document\""; StoreRef store = StoreRef.STORE_REF_WORKSPACE_SPACESSTORE; sp.addStore(store); sp.setLanguage(SearchService.LANGUAGE_FTS_ALFRESCO); sp.setQuery(query); ResultSet rs = services.getSearchService().query(sp); List<NodeRef> nodeRefs = rs.getNodeRefs(); for (NodeRef ref : nodeRefs) { List<ChildAssociationRef> refs = services.getNodeService().getChildAssocs(ref); for(ChildAssociationRef chref : refs){ if(chref.getQName().equals(AbcModel.ASSOC_LINKED_DOC)){ logger.debug("Document with linked doc: {}", ref); break; } } }

推荐答案

关联不是可查询的,因此您必须执行正在执行的操作,这实际上是检查结果集中的每个节点是否存在所需的关联.

Associations aren't query-able so you'll have to do what you are doing, which is essentially checking every node in a result set for the presence of a desired association.

我建议的唯一改进是,您可以请求特定类型的子关联,这将使您不必检查每个子关联的类型,请参见如何获取具有特定关联类型Alfresco(Java)的所有子关联

The only improvement I can suggest is that you can ask for the child associations of a specific type which would prevent you from having to check the type of every child association, see How to get all Child associations with a specific Association Type Alfresco (Java)

更多推荐

查找具有特定子关联的节点

本文发布于:2023-10-23 19:42:30,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1521823.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:定子   节点

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!