如何使用 CMIS 从 Alfresco 存储库中查询所有类型的文档

How to query All Types of document from Alfresco repository using CMIS

我有多个自定义内容类型,我可以根据各个类型查询文档。但我的要求是我想得到所有类型的文件。

我从 hr:hrdoctype 写了查询 select *,因为我的 hr:hrdoctype 是所有其他类型的父类型。但是它不起作用。

但是如果我从 hr:hrReimbursment 写 select *,这工作正常。

那么我如何才能获得具有单一父类型或单一条件的所有所有自定义类型的文档。 请看下面的配置。

在这种情况下,如果我将使用特定的内容类型,那么它工作正常。但我想使用单个查询获取所有类型的文档。

请帮助我如何为这个要求编写 CMIS 查询。

共享配置-custom.xml:-

                <type name="cm:content">
                   <subtype name="hr:hrdoctype" />
                </type>

                <type name="hr:hrdoctype">
                   <subtype name="hr:hrReimbursment" />
                   <subtype name="hr:hrMISCELLANEOUS" />
                   <subtype name="hr:hrWELFARE_POLICIES" />
                   <subtype name="hr:hrGENERAL_POLICIES" />
                   <subtype name="hr:hrPOLICIES_SIGNOFF_NOTES_FILE_NOTES" />
                   <subtype name="hr:hrPHOTOGRAPH" />
                   <subtype name="hr:hrPIF_PROFILE_OVERVIEW" />
                   <subtype name="hr:hrMPR_FORM" />
                   <subtype name="hr:hrPSYOMETRIC_REPORT" />
                   <subtype name="hr:hrTECHNICAL_TEST_ASSESSEMENT" />
                   <subtype name="hr:hrINTERVIEW_ASSESSEMENT_SHEET" />                                     

            </type>

自定义内容-model.xml:-

     <types>
         <type name="hr:hrdoctype">
            <title>HR Document</title>
            <parent>cm:content</parent>

            <properties>
                <property name="hr:employeeNumber">
                        <title>Employee Number</title>
                        <type>d:text</type>
                        </property>
                <property name="hr:employeeName">
                        <title>Employee Name</title>
                        <type>d:text</type>
                </property>                             
            </properties>

        </type>

        <type name="hr:hrReimbursment">
            <title>REIMBURSEMENT</title>
            <parent>hr:hrdoctype</parent>


            <properties>
                <property name="hr:DocumentDescription">
                        <title>Document Description</title>
                        <type>d:text</type>                         
                </property> 

                <property name="hr:ReimbursmentDate">
                        <title>Reimbursment Date</title>
                        <type>d:text</type>                         
                </property> 

            </properties>

        </type>

        <type name="hr:hrMISCELLANEOUS">
            <title>MISCELLANEOUS</title>
            <parent>hr:hrdoctype</parent>   

            <properties>
                <property name="hr:DocumentDescription1">
                        <title>Document Description</title>
                        <type>d:text</type>                         
                </property> 

            </properties>

        </type>
</types>                

我刚刚在我的存储库中测试了类似的案例。

有四种基本 CMIS 类型:cmis:documentcmis:foldercmis:relationshipcmis:policy。任何存储库都必须支持类型 cmis:documentcmis:folder

我的情况是 myc:xyz 类型继承自 cmis:folder 类型。

  1. 选择所有文件夹的 CMIS 查询:

    select * from cmis:folder where cmis:name='ABCD'
    

    returns 文件夹:

    {
        "cmis:objectId": "5b97929c-553b-4494-91cc-2c18e50b2f1c",
        "cmis:objectTypeId": "F:myc:xyz",
        "cmis:baseTypeId": "cmis:folder",
        "cmis:name": "ABCD"
    }
    
  2. 选择所有 myc:xyz 个文件夹的 CMIS 查询:

    select * from myc:xyz where cmis:name='ABCD'
    

    return 具有某些 myc:xyz 类型的附加属性的同一文件夹:

    {
        "cmis:objectId": "5b97929c-553b-4494-91cc-2c18e50b2f1c",
        "cmis:objectTypeId": "F:myc:xyz",
        "cmis:baseTypeId": "cmis:folder",
        "cmis:name": "ABCD",
    
        "myc:AdditionalProperty1": "1111",
        "myc:AdditionalProperty2": "2222"
    }
    

希望这对您有所帮助。

OpenCMIS Client API Developer's Guide

PS。您可以使用 Alfresco CMIS 1.1 "The Browser binding" 测试查询。 例如,这是URL查询select * from cmis:folder where cmis:name='ABCD'(Firefox自动解码URL中的编码参数,很舒服):

http://localhost:8080/alfresco/api/-default-/public/cmis/versions/1.1/browser/?cmisselector=query&succinct=true&q=select * from cmis:folder where cmis:name='ABCD'