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

Copy metadata of documents enregistred yet to new document

Post by cherifmad » Sun May 20, 2018 10:42 pm

Hello,
I would like to know if there a way or possible to copy the metadata enregistred yet at a old document to a new document ?

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

Re: Copy metadata of documents enregistred yet to new document

Post by lnovoa » Mon May 21, 2018 8:58 am

You could do it by scripting.

It is assumed that these metadata are detailed in the xml.
You would have to locate the uuid of the file, create a map with the values of the fields and the metadata group from the old file.
Attached a link with examples.

https://docs.openkm.com/kcenter/view/ok ... mples.html

jllort
Moderator
Moderator
Posts: 10552
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 » Mon May 21, 2018 1:40 pm

Should be something like:

Code: Select all

String uuid_origin = "some uuid";
String uuid_destination = "some uuid";
Map properties = OKMPropertyGroup.getInstance().getPropertiesSimple(null, uuid_origin, "okg:group_name");
OKMPropertyGroup.getInstance().addGroup(null, uuid_destination, "okg:group_name"); // Adding empty group to destination
OKMPropertyGroup.getInstance().setPropertiesSimple(null, uuid_destination,  "okg:group_name", properties ); // Setting metadata to destination node

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 » Mon May 21, 2018 1:55 pm

jllort wrote:
Mon May 21, 2018 1:40 pm
Should be something like:

Code: Select all

String uuid_origin = "some uuid";
String uuid_destination = "some uuid";
Map properties = OKMPropertyGroup.getInstance().getPropertiesSimple(null, uuid_origin, "okg:group_name");
OKMPropertyGroup.getInstance().addGroup(null, uuid_destination, "okg:group_name"); // Adding empty group to destination
OKMPropertyGroup.getInstance().setPropertiesSimple(null, uuid_destination,  "okg:group_name", properties ); // Setting metadata to destination node
please this script is a Beanshell script or a JBDC queries?
Where Can I run It ?

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

Re: Copy metadata of documents enregistred yet to new document

Post by lnovoa » Mon May 21, 2018 2:21 pm

Yes, as Josep explains, it could work for you.
Modify it and launch it as Beanshell script.

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 » Mon May 21, 2018 2:34 pm

lnovoa wrote:
Mon May 21, 2018 2:21 pm
Yes, as Josep explains, it could work for you.
Modify it and launch it as Beanshell script.
Thanks a lot for all
I make you a return when I do it

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 » Mon May 21, 2018 3:10 pm

I have make some modification But, I didn't get the result. here is my modified code.

Code: Select all

String uuid_origin = "some uuid";
String uuid_destination = "some uuid";
Map properties = OKMPropertyGroup.getInstance().getPropertiesSimple(null, uuid_origin, "okg:abc.abc");
OKMPropertyGroup.getInstance().addGroup(null, uuid_destination, "okg:abc.abc"); // Adding empty group to destination
OKMPropertyGroup.getInstance().setPropertiesSimple(null, uuid_destination,  "okg:abc.abc", properties ); // Setting metadata to destination node
can I make modification in String uuid_origin and String uuid_destination code? If yes What should I write?
thanks for your unnderstanding

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

Re: Copy metadata of documents enregistred yet to new document

Post by lnovoa » Tue May 22, 2018 8:05 am

Hi!,
You must replace it with the uuid of the source and destination document.
If you want to know the value of the uuid, you select the document and in the properties tab you will find the value.
For example:

String uuid_origin = "d39e38e3-e561-4c46-8415-aca6dab0773c";
String uuid_destination = "829881b0-c859-4704-ba85-6e763d9e086f"
.......

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 » Tue May 22, 2018 11:56 am

lnovoa wrote:
Tue May 22, 2018 8:05 am
Hi!,
You must replace it with the uuid of the source and destination document.
If you want to know the value of the uuid, you select the document and in the properties tab you will find the value.
For example:

String uuid_origin = "d39e38e3-e561-4c46-8415-aca6dab0773c";
String uuid_destination = "829881b0-c859-4704-ba85-6e763d9e086f"
.......
@Inovoa
I have make this modification but nothing appears in the new document's Metadata

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

Re: Copy metadata of documents enregistred yet to new document

Post by lnovoa » Tue May 22, 2018 1:27 pm

Has it given you any kind of error?

This is the script that I launched and it works correctly.

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");
OKMPropertyGroup.getInstance().addGroup(null, uuid_destination, "okg:cdapodoc");
OKMPropertyGroup.getInstance().setPropertiesSimple(null, uuid_destination,  "okg:cdapodoc", properties );

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 » Tue May 22, 2018 1:45 pm

lnovoa wrote:
Tue May 22, 2018 1:27 pm
Has it given you any kind of error?

This is the script that I launched and it works correctly.

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");
OKMPropertyGroup.getInstance().addGroup(null, uuid_destination, "okg:cdapodoc");
OKMPropertyGroup.getInstance().setPropertiesSimple(null, uuid_destination,  "okg:cdapodoc", properties );
please this script is a beanshell script also?

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

Re: Copy metadata of documents enregistred yet to new document

Post by lnovoa » Tue May 22, 2018 4:04 pm

Steps:
1. Go to Administration > Utilities > Scripting
2. Paste your code
3. Click into Evaualte

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 » Tue May 22, 2018 4:38 pm

please @Inovoa,
There are not box or tool scripting in Utilities
Attachments
test11.JPG

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

Re: Copy metadata of documents enregistred yet to new document

Post by lnovoa » Wed May 23, 2018 10:34 am

Hi!,

In the community version is the icon that is between statistics and metadata, it is a violet rhombus

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 » Wed May 23, 2018 3:35 pm

lnovoa wrote:
Wed May 23, 2018 10:34 am
Hi!,

In the community version is the icon that is between statistics and metadata, it is a violet rhombus
thanks @Inovoa
I run it ( with my modification :" see my screenshot"); But an error appear.
thanks for you supporting
Attachments
test11.JPG

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest