Script - Import reports from a folder
Import reports from $TOMCAT_HOME/reports and also enable them in the default profile.
import java.io.*;
import java.sql.*;
import org.hibernate.*;
import com.openkm.core.*;
import com.openkm.util.*;
import com.openkm.dao.*;
Session hbmSession = HibernateUtil.getSessionFactory().openSession();
Connection con = hbmSession.connection();
Statement st = con.createStatement();
File reports = new File(Config.HOME_DIR + "/reports");
try {
if (reports.isDirectory()) {
for (File rep : reports.listFiles()) {
int id = ReportDAO.createFromFile(rep, FileUtils.getFileName(rep.getName()), true);
String sql = "insert into OKM_PROFILE_MSC_REPORT (PRP_ID, PRP_REPORT) values (1, " + id + ")";
LegacyDAO.execute(con, sql);
}
}
} catch (Exception e) {
e.printStackTrace();
} finally {
LegacyDAO.close(con);
HibernateUtil.close(hbmSession);
}