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.  

The value of the variable omId is the template id.

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);	
}

Images

Register automation rule

With PathContains and ExecuteScripting action.

The script code:

Templates defintion

Get the omId value of the template.

Result

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