简体   繁体   English

如何在Alfresco中获取具有自定义属性定义值的文档列表

[英]How to get list of documents with defined value of custom property in Alfresco

We use Alfresco Enterprise 4.2.2.5 platform for our projects. 我们将Alfresco Enterprise 4.2.2.5平台用于我们的项目。

Our users create contracts in Alfresco folder "../contracts_def" and then start process of approvement. 我们的用户在Alfresco文件夹“ ../contracts_def”中创建合同,然后开始批准过程。 For a example, folder "contracts_def" has the following structure: 例如,文件夹“ contracts_def”具有以下结构:

Contracts_def (Folder)
   |  
   |---- contract_name1 (Folder)  
   |            |--- contract_name1.docx (main document)  
   |            |--- ext_file1.docx      (document)
   |
   |---- contract_name2 (Folder)
                |--- contract_name2.docx (main document)
                |--- ext_file2.docx      (document)           

Each main document has set of properties, including status of approvement. 每个主文档都有一组属性,包括批准状态。 In Alfresco Node browser property's full name is {httр://www.mytest.ru/model/test/contract/1.0}status . 在Alfresco节点中,浏览器属性的全名是{httр://www.mytest.ru/model/test/contract/1.0} status
I'd like to fetch list of documents with status "on-sign" within folder "contracts_def". 我想在文件夹“ contracts_def”中获取状态为“ on-sign”的文档列表。

I've wrote simple script for running in Java Script Console: 我编写了用于在Java脚本控制台中运行的简单脚本:

    var rs = search.query
      ({ query:
        "SELECT * FROM cmis:document WHERE CONTAINS('PATH:\"/app:company_home/st:sites/cm:contracts/cm:documentLibrary/cm:contracts/cm:contracts_def//*\"')",
         language:"cmis-alfresco" });
      for (var r in rs)
      { logger.log(rs[r].parent.name + "/" + rs[r].name + "\t" +  rs[r].properties.status); }

There are 3 questions: 有3个问题:

1) Script works, but Instead of document's status I get "NULL". 1)脚本有效,但是我得到“ NULL”而不是文档的状态。 How I understand, script doesn't return custom property of documents - {httр://www.mytest.ru/model/test/contract/1.0}status , but I can get only none-custom properties, for example {httр://www.alfresco.org/model/content/1.0}creator . 据我了解,脚本不会返回文档的自定义属性- {httр://www.mytest.ru/model/test/contract/1.0} status ,但是我只能获得非自定义属性,例如{httр: //www.alfresco.org/model/content/1.0}creator

2) I'd like to fetch list of documents which have only status "on-sign", but script will return all specified properties without filtering. 2)我想获取仅具有“ on-sign”状态的文档列表,但是脚本将返回所有指定的属性而不进行过滤。

How can I change code for my requirements? 如何更改代码以符合要求?

3) Can I get this information using built-in web-scripts of Alfresco? 3)我可以使用Alfresco的内置网络脚本获得此信息吗?

Thanks in advance. 提前致谢。

It is not clear why you want to use CMIS for this if you are running the code in the server-side JavaScript console which has full access to the JavaScript API and native search. 如果您在服务器端JavaScript控制台中运行代码,而该控制台具有对JavaScript API和本机搜索的完全访问权限,则不清楚为什么要为此使用CMIS。

Rather than using JavaScript and CMIS, you might find it easier to first just get a query working by using the Node Browser available in the admin console. 与使用JavaScript和CMIS相比,您可能会发现首先使用管理控制台中可用的节点浏览器使查询正常工作会更容易。

Go to the admin console, then the node browser, and put this in the search box: 转到管理控制台,然后转到节点浏览器,并将其放在搜索框中:

PATH:"/app:company_home/st:sites/cm:contracts/cm:documentLibrary/cm:contracts/cm:contracts_def//*" =test:status:"on-sign"

Make sure "fts-alfresco" is selected. 确保选择“ fts-alfresco”。

Now that you have a working query, you can go back to the JS console and use it in your search.query call. 现在您有了一个有效的查询,您可以返回JS控制台并在search.query调用中使用它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM