use of org.kuali.kfs.kew.api.WorkflowRuntimeException in project cu-kfs by CU-CommunityApps.
the class DocumentRouteHeaderDAOOjbImpl method findPendingByResponsibilityIds.
public Collection<String> findPendingByResponsibilityIds(Set<String> responsibilityIds) {
Collection<String> documentIds = new ArrayList<>();
if (responsibilityIds.isEmpty()) {
return documentIds;
}
PersistenceBroker broker = null;
Connection conn = null;
Statement statement = null;
ResultSet rs = null;
try {
broker = getPersistenceBroker(false);
conn = broker.serviceConnectionManager().getConnection();
String respIds = "('";
int index = 0;
for (String responsibilityId : responsibilityIds) {
respIds += responsibilityId + (index == responsibilityIds.size() - 1 ? "" : "','");
index++;
}
respIds += "')";
String query = "SELECT DISTINCT(doc_hdr_id) FROM KREW_ACTN_RQST_T " + "WHERE (STAT_CD='" + ActionRequestStatus.INITIALIZED.getCode() + "' OR STAT_CD='" + ActionRequestStatus.ACTIVATED.getCode() + "') AND RSP_ID IN " + respIds;
LOG.debug("Query to find pending documents for requeue: " + query);
statement = conn.createStatement();
rs = statement.executeQuery(query);
while (rs.next()) {
documentIds.add(rs.getString(1));
}
} catch (SQLException sqle) {
LOG.error("SQLException: " + sqle.getMessage(), sqle);
throw new WorkflowRuntimeException(sqle);
} catch (LookupException le) {
LOG.error("LookupException: " + le.getMessage(), le);
throw new WorkflowRuntimeException(le);
} finally {
if (rs != null) {
try {
rs.close();
} catch (SQLException e) {
LOG.warn("Could not close result set.");
}
}
if (statement != null) {
try {
statement.close();
} catch (SQLException e) {
LOG.warn("Could not close statement.");
}
}
try {
if (broker != null) {
OjbFactoryUtils.releasePersistenceBroker(broker, this.getPersistenceBrokerTemplate().getPbKey());
}
} catch (Exception e) {
LOG.error("Failed closing connection: " + e.getMessage(), e);
}
}
return documentIds;
}
use of org.kuali.kfs.kew.api.WorkflowRuntimeException in project cu-kfs by CU-CommunityApps.
the class DocumentRouteHeaderDAOOjbImpl method findByDocTypeAndAppId.
public Collection findByDocTypeAndAppId(String documentTypeName, String appId) {
Collection documentIds = new ArrayList<>();
PersistenceBroker broker = null;
Connection conn = null;
ResultSet rs = null;
try {
broker = getPersistenceBroker(false);
conn = broker.serviceConnectionManager().getConnection();
String query = "SELECT DISTINCT " + " (docHdr.doc_hdr_id) " + "FROM " + " KREW_DOC_HDR_T docHdr, " + " KREW_DOC_TYP_T docTyp " + "WHERE " + " docHdr.APP_DOC_ID = ? " + " AND docHdr.DOC_TYP_ID = docTyp.DOC_TYP_ID " + " AND docTyp.DOC_TYP_NM = ?";
LOG.debug("Query to find documents by app id: " + query);
PreparedStatement stmt = conn.prepareStatement(query);
stmt.setString(1, appId);
stmt.setString(2, documentTypeName);
rs = stmt.executeQuery();
while (rs.next()) {
documentIds.add(new String(rs.getString(1)));
}
rs.close();
} catch (SQLException sqle) {
LOG.error("SQLException: " + sqle.getMessage(), sqle);
throw new WorkflowRuntimeException(sqle);
} catch (LookupException le) {
LOG.error("LookupException: " + le.getMessage(), le);
throw new WorkflowRuntimeException(le);
} finally {
try {
if (broker != null) {
OjbFactoryUtils.releasePersistenceBroker(broker, this.getPersistenceBrokerTemplate().getPbKey());
}
} catch (Exception e) {
LOG.error("Failed closing connection: " + e.getMessage(), e);
}
}
return documentIds;
}
Aggregations