if (nForceFrequency==1) {
LOG.info("{HARVEST POLICY] Attempting to enforce 'Full harvest' for the record: "+record.getUuid());
return true;
}
ConnectionBroker connectionBroker = new ConnectionBroker();
PreparedStatement st = null;
ResultSet rs = null;
try {
ManagedConnection managedConnection = connectionBroker.returnConnection("");
Connection connection = managedConnection.getJdbcConnection();
st = connection.prepareStatement("SELECT COUNT(*) JOB_TYPE FROM GPT_HARVESTING_JOBS_COMPLETED WHERE HARVEST_ID=?");
st.setString(1, record.getUuid());
rs = st.executeQuery();
if (rs.next()) {
int count = rs.getInt(1);
if (count % nForceFrequency != 0) {
return false;
}
}
LOG.info("{HARVEST POLICY] Attempting to enforce 'Full harvest' for the record: "+record.getUuid());
return true;
} catch (SQLException ex) {
LOG.log(Level.SEVERE, "[HARVEST POLICY] Error evaluating policy for the record: "+record.getUuid(), ex);
} finally {
if (rs!=null) {
try {
rs.close();
} catch (SQLException ex) {}
}
if (st!=null) {
try {
st.close();
} catch (SQLException ex) {}
}
connectionBroker.closeAll();
}
}
return false;
}