Hi,
I am using 6.3.4 community version of OpenKM
I have query regarding update of the metadata for documents after they are uploaded to OpenKM.
My scenario:
There is a metadata group added with some properties in OpenKM and some documents were uploaded to OpenKM by setting the required metadata for the documents.
Now I have added 1 more property to the metadata group, so for the new documents getting uploaded I will set this property also and metadata is updated.
I want this metadata property updated for the old documents as well, how do i go about it?
Two approaches
1. Written a stored procedure which updates ‘USER’ metadata property with the ‘author’ of the old documents. This was tested and the corresponding updated metadata can be seen for the documents in the OpenKM application UI.
Stored procedure as below
2. There is also an API given by OpenKM to update the metadata property for a document. I have done a POC of this API and it successfully updated the property for the given document in the DB table, but this updated metadata is not visible in OpenKM application UI.
Why with the 2nd approach I am not able to see the updated metadata? This does not show the updated metadata after restarting the server also.
Sample code:
I am using 6.3.4 community version of OpenKM
I have query regarding update of the metadata for documents after they are uploaded to OpenKM.
My scenario:
There is a metadata group added with some properties in OpenKM and some documents were uploaded to OpenKM by setting the required metadata for the documents.
Now I have added 1 more property to the metadata group, so for the new documents getting uploaded I will set this property also and metadata is updated.
I want this metadata property updated for the old documents as well, how do i go about it?
Two approaches
1. Written a stored procedure which updates ‘USER’ metadata property with the ‘author’ of the old documents. This was tested and the corresponding updated metadata can be seen for the documents in the OpenKM application UI.
Stored procedure as below
Code: Select all
Is this the correct way of doing it? Do i need to update any other tables?CREATE DEFINER=`root`@`localhost` PROCEDURE `new_procedure`()
BEGIN
DECLARE finished INTEGER default 0;
DECLARE docId varchar(100) default "";
DECLARE maxId INTEGER;
DECLARE curs CURSOR FOR select NDV_PARENT from okmdb.okm_node_document_version as T2 where not exists ( select * from okmdb.okm_node_property as T1 where T1.NPG_NODE = T2.NDV_PARENT and T1.NPG_NAME='okp:OPENKM.USER');
DECLARE CONTINUE HANDLER FOR NOT FOUND SET finished = 1;
OPEN curs;
select max(NPG_ID) + 1 into maxId from okmdb.okm_node_property;
insertRecords:LOOP
FETCH curs into docId;
if finished = 1 then
leave insertRecords;
end if;
insert into okmdb.okm_node_property (NPG_ID, NPG_GROUP, NPG_NAME, NPG_VALUE, NPG_NODE)
values (maxId, 'okg:OPENKM','okp:OPENKM.USER', (select NDV_AUTHOR from okmdb.okm_node_document_version where NDV_PARENT = docId), docId);
set maxId = maxId + 1;
END LOOP insertRecords;
CLOSE curs;
END
2. There is also an API given by OpenKM to update the metadata property for a document. I have done a POC of this API and it successfully updated the property for the given document in the DB table, but this updated metadata is not visible in OpenKM application UI.
Why with the 2nd approach I am not able to see the updated metadata? This does not show the updated metadata after restarting the server also.
Sample code:
Code: Select all
public class OpenKMTest {
public static void main(String[] args) {
String host = "http://localhost:8180/OpenKM";
String username = "okmAdmin";
String password = "admin";
OKMWebservices ws = OKMWebservicesFactory.newInstance(host, username, password);
try {
List<FormElement> fElements = new ArrayList<>();
Input user = new Input();
user.setName("okg:OPENKM.USER");
user.setValue("MyUser");
fElements.add(user);
ws.setPropertyGroupProperties("4ac33d91-9bd2-413f-a4c3-1fb1079f4e5b","okg:OPENKM", fElements);
System.out.println("Done");
} catch (Exception e) {
e.printStackTrace();
}
}
}