Page 2 of 2

Re: Copy metadata of documents enregistred yet to new document

PostPosted:Thu May 24, 2018 5:33 pm
by cherifmad
Please can you help me to obtain good result ?

Re: Copy metadata of documents enregistred yet to new document

PostPosted:Fri May 25, 2018 9:03 am
by lnovoa
You have to add the import to the code.
Code: Select all
import com.openkm.api.OKMPropertyGroup;
import java.util.Map; 

String uuid_origin = "222bd16a-01f1-4b5b-89b7-be72183706bc";
String uuid_destination = "73a99248-6364-4443-b407-e3584c921fc1";
Map properties = OKMPropertyGroup.getInstance().getPropertiesSimple(null, uuid_origin, "okg:cdapodoc"); ......

How do you check that the code is correct before execute it in openkm?

Re: Copy metadata of documents enregistred yet to new document

PostPosted:Fri May 25, 2018 9:43 am
by cherifmad
lnovoa wrote: Fri May 25, 2018 9:03 am You have to add the import to the code.
Code: Select all
import com.openkm.api.OKMPropertyGroup;
import java.util.Map; 

String uuid_origin = "222bd16a-01f1-4b5b-89b7-be72183706bc";
String uuid_destination = "73a99248-6364-4443-b407-e3584c921fc1";
Map properties = OKMPropertyGroup.getInstance().getPropertiesSimple(null, uuid_origin, "okg:cdapodoc"); ......

How do you check that the code is correct before execute it in openkm?
Hi Inovoa,
I just used the script that you gave me by modifying the uuid (origins and destinations). also about the OKG of metadata in my house, it's abc:abc. ( NB: I'm not a developer and I'm still learning to be one).
Do you have a way to check for errors?
Or if you wnat, how did you manage to run the script in your openkm ( if it worked) step by step ( with your metadata properties)
Thanks you for your supporting

Re: Copy metadata of documents enregistred yet to new document

PostPosted:Fri May 25, 2018 10:04 am
by lnovoa
We have a development environment, which consists of a VM in Linux.
This environment has already installed and configured everything you need to modify your own version of openkm.
The Eclipse IDE also has it configured ready to compile and develop.
One way to test your code is to create a main class in the eclipse and develop your code there.
From there you can access classes and methods and check that your code has no errors.
Then you just have to run it in your current openkm.
I give you a link:
Community development environment
https://www.openkm.com/en/download.html


About your code, I think that with the mistakes you have made should work.

Re: Copy metadata of documents enregistred yet to new document

PostPosted:Fri May 25, 2018 10:19 am
by cherifmad
lnovoa wrote: Fri May 25, 2018 10:04 am We have a development environment, which consists of a VM in Linux.
This environment has already installed and configured everything you need to modify your own version of openkm.
The Eclipse IDE also has it configured ready to compile and develop.
One way to test your code is to create a main class in the eclipse and develop your code there.
From there you can access classes and methods and check that your code has no errors.
Then you just have to run it in your current openkm.
I give you a link:
Community development environment
https://www.openkm.com/en/download.html


About your code, I think that with the mistakes you have made should work.
Dear Inovoa, I have it, some error are there when we use his portable's Eclispe version.
later I will use Virtualbox.
I have a other question, When I finish to install the OpenKM version for developper in VirtualBox, Where Can I test My script?

Re: Copy metadata of documents enregistred yet to new document

PostPosted:Fri May 25, 2018 10:45 am
by lnovoa
You do not have to install anything, just
1. Open eclipse
2. Inside src / test / java you create a java class and make the check public static void main
3. Add your code and correct errors, add the necessary import, etc.
4. Execute the script in your openkm

Re: Copy metadata of documents enregistred yet to new document

PostPosted:Sat May 26, 2018 7:36 am
by jllort
You can check the script from Administration > Scripting or if you have created a jar ( consider looking crontab task https://docs.openkm.com/kcenter/view/ok ... b-job.html then -> register as a crontab ). I'm not 100% sure if in community version exists this option Administration > tools > execute jar

Re: Copy metadata of documents enregistred yet to new document

PostPosted:Sat May 26, 2018 4:30 pm
by cherifmad
@Jlort and @Inovoa.
I would like to know if you have created a script that can solve this problem (Copy the old metadata still saved in openkm to a new downloaded document).
If so, can you explain all the steps to do it?
Thank you for your understanding.

Re: Copy metadata of documents enregistred yet to new document

PostPosted:Sun May 27, 2018 7:00 am
by jllort
The code what shared before lnova contains almost what you need ( get the metadata of some document ). The only what you need now is set to the destination document ( where properties are the metadata values map from original document ).
Code: Select all
OKMPropertyGroup.getInstance().setPropertiesSimple(null, uuid_destination,"okg:cdapodoc", properties);    
You should consider devoting some time to control of the OpenKM API https://docs.openkm.com/kcenter/view/ok ... ption.html