Search in sources :

Example 1 with WorkflowRequestAssociation

use of org.wso2.carbon.identity.workflow.mgt.bean.WorkflowRequestAssociation in project carbon-identity-framework by wso2.

the class WorkflowRequestAssociationDAO method getWorkflowsOfRequest.

/**
 * Get array of Workflows of a request
 *
 * @param requestId
 * @return
 * @throws InternalWorkflowException
 */
public WorkflowRequestAssociation[] getWorkflowsOfRequest(String requestId) throws InternalWorkflowException {
    Connection connection = IdentityDatabaseUtil.getDBConnection(false);
    PreparedStatement prepStmt = null;
    String query = SQLConstants.GET_WORKFLOWS_OF_REQUEST;
    ResultSet resultSet = null;
    try {
        prepStmt = connection.prepareStatement(query);
        prepStmt.setString(1, requestId);
        resultSet = prepStmt.executeQuery();
        ArrayList<WorkflowRequestAssociation> workflowDTOs = new ArrayList<>();
        while (resultSet.next()) {
            WorkflowRequestAssociation workflowDTO = new WorkflowRequestAssociation();
            workflowDTO.setWorkflowId(resultSet.getString(SQLConstants.ID_COLUMN));
            workflowDTO.setWorkflowName(resultSet.getString(SQLConstants.WF_NAME_COLUMN));
            workflowDTO.setLastUpdatedTime(resultSet.getTimestamp(SQLConstants.REQUEST_UPDATED_AT_COLUMN).toString());
            workflowDTO.setStatus(resultSet.getString(SQLConstants.REQUEST_STATUS_COLUMN));
            workflowDTOs.add(workflowDTO);
        }
        WorkflowRequestAssociation[] requestArray = new WorkflowRequestAssociation[workflowDTOs.size()];
        for (int i = 0; i < workflowDTOs.size(); i++) {
            requestArray[i] = workflowDTOs.get(i);
        }
        return requestArray;
    } catch (SQLException e) {
        throw new InternalWorkflowException("Error when executing the sql query:" + query, e);
    } finally {
        IdentityDatabaseUtil.closeAllConnections(connection, resultSet, prepStmt);
    }
}
Also used : WorkflowRequestAssociation(org.wso2.carbon.identity.workflow.mgt.bean.WorkflowRequestAssociation) SQLException(java.sql.SQLException) InternalWorkflowException(org.wso2.carbon.identity.workflow.mgt.exception.InternalWorkflowException) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) ArrayList(java.util.ArrayList) PreparedStatement(java.sql.PreparedStatement)

Example 2 with WorkflowRequestAssociation

use of org.wso2.carbon.identity.workflow.mgt.bean.WorkflowRequestAssociation in project carbon-identity-framework by wso2.

the class WorkflowManagementServiceImpl method getWorkflowsOfRequest.

/**
 * Get list of workflows of a request
 *
 * @param requestId
 * @return
 * @throws WorkflowException
 */
@Override
public WorkflowRequestAssociation[] getWorkflowsOfRequest(String requestId) throws WorkflowException {
    List<WorkflowListener> workflowListenerList = WorkflowServiceDataHolder.getInstance().getWorkflowListenerList();
    for (WorkflowListener workflowListener : workflowListenerList) {
        if (workflowListener.isEnable()) {
            workflowListener.doPreGetWorkflowsOfRequest(requestId);
        }
    }
    WorkflowRequestAssociation[] requestAssociations = workflowRequestAssociationDAO.getWorkflowsOfRequest(requestId);
    for (WorkflowListener workflowListener : workflowListenerList) {
        if (workflowListener.isEnable()) {
            workflowListener.doPostGetWorkflowsOfRequest(requestId, requestAssociations);
        }
    }
    return requestAssociations;
}
Also used : WorkflowRequestAssociation(org.wso2.carbon.identity.workflow.mgt.bean.WorkflowRequestAssociation) WorkflowListener(org.wso2.carbon.identity.workflow.mgt.listener.WorkflowListener)

Aggregations

WorkflowRequestAssociation (org.wso2.carbon.identity.workflow.mgt.bean.WorkflowRequestAssociation)2 Connection (java.sql.Connection)1 PreparedStatement (java.sql.PreparedStatement)1 ResultSet (java.sql.ResultSet)1 SQLException (java.sql.SQLException)1 ArrayList (java.util.ArrayList)1 InternalWorkflowException (org.wso2.carbon.identity.workflow.mgt.exception.InternalWorkflowException)1 WorkflowListener (org.wso2.carbon.identity.workflow.mgt.listener.WorkflowListener)1