cancel
Showing results for 
Search instead for 
Did you mean: 

How do I get/set document tags through the automation client?

jostout_Stout
Champ on-the-rise
Champ on-the-rise

I'm having a heck of a time finding documentation on getting/setting document tags through the automation client. I found the TagServiceImpl but it wants a CoreSession not a ConcreteJavaProxy. Can someone point me in the right direction?

1 ACCEPTED ANSWER

Florent_Guillau
World-Class Innovator
World-Class Innovator

Today there's no operation to tag a document. You could easily write one though, that would call the underlying TagService.

Operations available in Nuxeo 5.4.2 are listed at http://explorer.nuxeo.org/nuxeo/site/distribution/Nuxeo%20DM-5.4.2/listOperations

View answer in original post

9 REPLIES 9

jostout_Stout
Champ on-the-rise
Champ on-the-rise

Woops, that ConcreteJavaProxy should be org.nuxeo.ecm.automation.client.jaxrs.spi.DefaultSession. The ConcreteJavaProxy is the jruby wrapper class.

Florent_Guillau
World-Class Innovator
World-Class Innovator

Today there's no operation to tag a document. You could easily write one though, that would call the underlying TagService.

Operations available in Nuxeo 5.4.2 are listed at http://explorer.nuxeo.org/nuxeo/site/distribution/Nuxeo%20DM-5.4.2/listOperations

Based on http

If you code through Automation Client then you don't have access to all the Nuxeo APIs, only the Automation ones. If you want to code using all the Nuxeo APIs then you have to code server-side, by writing a new service or a new Operation.

maumig_
Confirmed Champ
Confirmed Champ

in the meantime has been implemented tagging through automation client? Thanks!

Arnault_
Confirmed Champ
Confirmed Champ

Hi,

In the last comment, maumig mention an implementation of tagging through automation client... can you give me hints on how this is done?

Thanks

Christian

Arnault_
Confirmed Champ
Confirmed Champ

Hi,

OK I did it in a new operation

@Operation(id=SetDocumentTag.ID, category=Constants.CAT_DOCUMENT, label="SetDocumentTag", description="") public class SetDocumentTag { public static final String ID = "SetDocumentTag"; private static final Log log = LogFactory.getLog(SetDocumentTag.class);

@Context
protected CoreSession session;

@Param(name = "label", required = true)
protected String label;

@Param(name = "username", required = true)
protected String username;

@OperationMethod
public void run(DocumentModel input) throws Exception {
    TagService service = Framework.getLocalService(TagService.class);
    String docId = input.getId();
    log.error("SetDocumentTag> docId=" + docId + " tag=" + label + " username=" + username);
    service.tag(session, docId, label, username);
    session.save();
}

}

Christian

pibou_Bouvret
Elite Collaborator
Elite Collaborator

This one s a bit late :

list / search tags : select * from tags (where tag:label like '%odontolo%')

you can then retrieve the UUID of the Tag

list tagged documents : select * from Tagging where relation:target = '*UUID_OF_THE_TAG*'

Create a Tagging document (inherits from Relation) with

**relation:source** being the UUID of your document,

**relation:target** the UUID of the Tag and

**ecm:path** the label of the tag

Note that both are HiddenInNavigation, the ecm:path is also used for storing the tag label and it causes some problems when querying through the UI (advanced search queries can lead to "Illegal relative path with null node")

much better since 7.1