Skip to content
Other versions

Loading…

Script for automation - Execute OMR

The script process an image with OMR engine from Automation each time new document is uploaded. With minimal changes can be used in conjunction with crontab.  

import com.openkm.bean.Document;
import com.openkm.module.db.stuff.DbSessionManager;
import com.openkm.api.OKMDocument;
import com.openkm.api.OKMRepository;
import com.openkm.omr.OMRHelper;
long omId= 4;
String systemToken = DbSessionManager.getInstance().getSystemToken();
String docPath = OKMRepository.getInstance().getNodePath(systemToken, uuid);
Document doc = OKMDocument.getInstance().getProperties(systemToken, docPath);
if (OMRHelper.isValid(doc)) {
OMRHelper.processAndStoreMetadata(omId, uuid);
}

With some PathContains validation and ExecuteScripting action.

The script code:

Get the omId value of the template.

Each document uploaded into folder path ( or subfolders ), when is valid image file, is processed by OMR engine.