Page 1 of 1

Write automaticly ID in to ODT file at upload

PostPosted:Sat Aug 15, 2015 3:40 pm
by stefbort
Hi everybody.
I wold like OpenKM to write an unique ID in the ODT file when I upload it, but I don't understund how do that.

I traied the guide "Incremental autonumeric" to generate an easy numeric unique ID for each document. Aftrer I tested the template system + form to insert, by hand, the data in to document and it works fine.
Now I wold like complete the test updating the script to ID generate from the script it goes in the LibreOffice file at the upload time.
My LibreOffice files have an tag/field name (okp_tpl_uuid), I have alredy insert the property group name (okp:tpl.uuid), the script "incremental autonumeric" are running and I am used the the community OpenKM 6.3.0 bundle pack.

Thanks in advance.

Re: Write automaticly ID in to ODT file at upload

PostPosted:Sat Aug 15, 2015 6:22 pm
by jllort
Really your case is not exactly the "create from template" problem but it's similar. You should take a look at ou source code for replacing the tag, but you can not use directly the create from template methods.
Do you have JAVA skills ? You should take a look at com.openkm.servlet.frontend.DocumentServlet.java, take a look at the private method ( into the method you have what you need to update the odt file ) :
Code: Select all
private File tmpFromTemplate(Document docTpl, List<GWTFormElement> formProperties, Map<String, List<Map<String, String>>> tableProperties)

Re: Write automaticly ID in to ODT file at upload

PostPosted:Mon Aug 17, 2015 8:49 am
by stefbort
Thanks jllort.
I will see your suggestion.
About "create from template" was an idea, for me, to understand how work OpenKM.
My java skill is near "0" :( but I now a bit about programming (bash, php, .net)

But about my case is it possible to do the replacement by script at upload?
I am thinking a script in the OpenKM -> Administration -> Automation.

TANKS again.

Re: Write automaticly ID in to ODT file at upload

PostPosted:Tue Aug 18, 2015 10:06 am
by jllort
Yes could be done in a script, basically getting almost code in the classes I shared to you and doing a checkout and check-in of the document.

The idea will be:
1- upload document
2- automation executed
2.0 - verify document is version 1.0 otherwise do nothing.
2.1 - document chekcout ( on edition )
2.2 - download the document -> getContent() -> InputStream to tmp file
2.3 - with some code in the classes I shared to you, modify the tmp file ( odt ) replacing the tag with the number
2.4 - checkin new version of document ( 1.1 ) from tmp file

Re: Write automaticly ID in to ODT file at upload

PostPosted:Tue Aug 18, 2015 8:38 pm
by stefbort
OK.
I will going busy night(s) ;)
Thank yuo. At next post.

Re: Write automaticly ID in to ODT file at upload

PostPosted:Thu Aug 20, 2015 4:22 pm
by jllort
Here's the doxygen documentation http://doxygen.openkm.com/openkm_6.3.0/ you should have interest in com.openkm.api.* classes http://doxygen.openkm.com/openkm_6.3.0/ ... _1api.html ( actually are still not described in our documentation, but is something also we will do ).

Re: Write automaticly ID in to ODT file at upload

PostPosted:Wed Aug 26, 2015 6:30 pm
by stefbort
Thanks jllort.
I am studing doxygen documentation, but I procede slow: too busy and I am not a java programer.

Thanks again.