Script - Put documents from folder and descendants into pending text extraction queue

 

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.openkm.api.*;
import com.openkm.bean.*;
import com.openkm.dao.*;
 
Logger log = LoggerFactory.getLogger("com.openkm.scripting");
int MAX_DEPTH = Integer.MAX_VALUE;
 
void nodeTask(String uuid, int depth) throws Exception {
    String sql = "UPDATE OKM_NODE_DOCUMENT SET NDC_TEXT_EXTRACTED='F' WHERE NBS_UUID IN (SELECT NBS_UUID FROM OKM_NODE_BASE WHERE NBS_PARENT='"+uuid+"')";    
    LegacyDAO.executeSQL(sql);
 
    for (Folder fld : OKMFolder.getInstance().getChildren(null, uuid)) {
        log.info("Folder: {}", fld.getPath());        
 
        if (depth < MAX_DEPTH) {
           nodeTask(fld.getUuid(), depth + 1);
        }
    }
}
 
log.info("***** Process BEGIN *****");
String fldPath = "/okm:root/KnowledgeBase";
String fldUuid = OKMRepository.getInstance().getNodeUuid(null,fldPath);
nodeTask(fldUuid , 0);
log.info("***** Process END *****");