Select cmis:document with tags or category

583 views Asked by At

Any idea how to select all cmis:document with specified tags or category? I'm using Apache Chemistry. I'm guessing I should use JOINs but can't figure out how to do so, I'm still having trouble drawing relationships between types.

I found this piece of code:

testDoc = session.getObjectByPath("/test/testfolder1/test1.txt")
catIds = testDoc.getPropertyValue("cm:categories")
for (catId in catIds) {
    cat = session.getObject(catId)
    println(cat.name)
}

But so far I plan to use prepared statement, because i'm interested in the use of IN_FOLDER, just like this:

QueryStatement qs = session.createQueryStatement("SELECT ?, ? FROM ? WHERE ? > TIMESTAMP ? AND IN_FOLDER(?) OR ? IN (?)");

The goal of my request is to get all documents with certain category and contained in a folder (soon I'll have too add criteria on tag)

Thanks for your help

1

There are 1 answers

0
Rapster On

That's how I did for tags:

SELECT * FROM cmis:folder AS F JOIN cm:taggable AS T ON T.cmis:objectId = F.cmis:objectId WHERE T.cmis:name = 'Agency Files'

But it won't work if I decide to add the IN_FOLDER condition