Copy metadata of documents enregistred yet to new document

OpenKM a de nombreuses fonctionnalités interessantes, mais demande un minimum de configuration pour être pleinement exploité.

Moderator: dedisoft

Forum rules
Avant de poser une question, merci de regarder la documentation du wiki ou d'utiliser la fonction recherche du forum. Et rappelez vous que nous n'avons ni boule de cristal ni possibilité de lire dans les pensées, aussi pensez à spécifier quelle version d'OpenKM vous utilisez ainsi que la version du navigateur web et du système d'exploitation. Pour de plus amples informations lisez Comment reporter un bug efficacement (anglais).
cherifmad
Junior Boarder
Junior Boarder
Posts: 37
Joined: Tue Apr 03, 2018 6:22 pm

Re: Copy metadata of documents enregistred yet to new document

Post by cherifmad » Thu May 24, 2018 5:33 pm

Please can you help me to obtain good result ?

lnovoa
Expert Boarder
Expert Boarder
Posts: 95
Joined: Tue Mar 27, 2018 8:00 am

Re: Copy metadata of documents enregistred yet to new document

Post by lnovoa » 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?

cherifmad
Junior Boarder
Junior Boarder
Posts: 37
Joined: Tue Apr 03, 2018 6:22 pm

Re: Copy metadata of documents enregistred yet to new document

Post by cherifmad » Fri May 25, 2018 9:43 am

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

lnovoa
Expert Boarder
Expert Boarder
Posts: 95
Joined: Tue Mar 27, 2018 8:00 am

Re: Copy metadata of documents enregistred yet to new document

Post by lnovoa » 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.

cherifmad
Junior Boarder
Junior Boarder
Posts: 37
Joined: Tue Apr 03, 2018 6:22 pm

Re: Copy metadata of documents enregistred yet to new document

Post by cherifmad » Fri May 25, 2018 10:19 am

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?

lnovoa
Expert Boarder
Expert Boarder
Posts: 95
Joined: Tue Mar 27, 2018 8:00 am

Re: Copy metadata of documents enregistred yet to new document

Post by lnovoa » Fri May 25, 2018 10:45 am

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

jllort
Moderator
Moderator
Posts: 10244
Joined: Fri Dec 21, 2007 11:23 am
Location: Sineu - ( Illes Balears ) - Spain
Contact:

Re: Copy metadata of documents enregistred yet to new document

Post by jllort » Sat May 26, 2018 7:36 am

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

cherifmad
Junior Boarder
Junior Boarder
Posts: 37
Joined: Tue Apr 03, 2018 6:22 pm

Re: Copy metadata of documents enregistred yet to new document

Post by cherifmad » Sat May 26, 2018 4:30 pm

@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.

jllort
Moderator
Moderator
Posts: 10244
Joined: Fri Dec 21, 2007 11:23 am
Location: Sineu - ( Illes Balears ) - Spain
Contact:

Re: Copy metadata of documents enregistred yet to new document

Post by jllort » Sun May 27, 2018 7:00 am

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

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest