Deepak Talape
Deepak Talape

Reputation: 997

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

I have Multiple Custom content types, and based on individual type i am able to query documents. But my requirement is i want to get all types of document.

I wrote query select * from hr:hrdoctype, Because my hr:hrdoctype is my parent type for all other types. But its not working.

But if i will write select * from hr:hrReimbursment, This is working fine.

So how can i get all All Custom types of documents with single parent type or with single condition. Please see the Below configuration.

in this case if i will use specific content type then its working fine. but i want to get all type of document using single query.

Please help me how can i write CMIS Query for this requirement.

Share-config-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>

Custom-content-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>                

Upvotes: 1

Views: 3587

Answers (1)

kinjelom
kinjelom

Reputation: 6460

I just tested simillar case on my repository.

There are four base CMIS types: cmis:document, cmis:folder, cmis:relationship, cmis:policy. Types cmis:document and cmis:folder must be supported by any repository.

I my case the myc:xyz type inherits from the cmis:folder type.

  1. CMIS query selecting all folders:

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

    returns folder:

    {
        "cmis:objectId": "5b97929c-553b-4494-91cc-2c18e50b2f1c",
        "cmis:objectTypeId": "F:myc:xyz",
        "cmis:baseTypeId": "cmis:folder",
        "cmis:name": "ABCD"
    }
    
  2. CMIS query selecting all myc:xyz folders:

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

    return the same folder with some myc:xyz type's additional properties:

    {
        "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"
    }
    

Hope this helps.

OpenCMIS Client API Developer's Guide

PS. You can test queries with Alfresco CMIS 1.1 "The Browser binding". For example, this is URL for the query select * from cmis:folder where cmis:name='ABCD' (Firefox automatically decoding encoded parameters in URL, it is very comfortable):

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'

Upvotes: 3

Related Questions