Page 1 of 2

Copy metadata of documents enregistred yet to new document

PostPosted:Sun May 20, 2018 10:42 pm
by cherifmad
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 ?

Re: Copy metadata of documents enregistred yet to new document

PostPosted:Mon May 21, 2018 8:58 am
by lnovoa
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

Re: Copy metadata of documents enregistred yet to new document

PostPosted:Mon May 21, 2018 1:40 pm
by jllort
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

Re: Copy metadata of documents enregistred yet to new document

PostPosted:Mon May 21, 2018 1:55 pm
by cherifmad
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 ?

Re: Copy metadata of documents enregistred yet to new document

PostPosted:Mon May 21, 2018 2:21 pm
by lnovoa
Yes, as Josep explains, it could work for you.
Modify it and launch it as Beanshell script.

Re: Copy metadata of documents enregistred yet to new document

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

Re: Copy metadata of documents enregistred yet to new document

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

Re: Copy metadata of documents enregistred yet to new document

PostPosted:Tue May 22, 2018 8:05 am
by lnovoa
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"
.......

Re: Copy metadata of documents enregistred yet to new document

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

Re: Copy metadata of documents enregistred yet to new document

PostPosted:Tue May 22, 2018 1:27 pm
by lnovoa
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 );

Re: Copy metadata of documents enregistred yet to new document

PostPosted:Tue May 22, 2018 1:45 pm
by cherifmad
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?

Re: Copy metadata of documents enregistred yet to new document

PostPosted:Tue May 22, 2018 4:04 pm
by lnovoa
Steps:
1. Go to Administration > Utilities > Scripting
2. Paste your code
3. Click into Evaualte

Re: Copy metadata of documents enregistred yet to new document

PostPosted:Tue May 22, 2018 4:38 pm
by cherifmad
please @Inovoa,
There are not box or tool scripting in Utilities

Re: Copy metadata of documents enregistred yet to new document

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

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

Re: Copy metadata of documents enregistred yet to new document

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