/** * Retrieve List of associated Entity-types of the workflow requests. * * @param wfOperationType Operation Type of the Work-flow. * @param wfStatus Current Status of the Work-flow. * @param entityType Entity Type of the Work-flow. * @param tenantID Tenant ID of the currently Logged user. * @return * @throws InternalWorkflowException */ @Override public List<String> listEntityNames( String wfOperationType, String wfStatus, String entityType, int tenantID) throws InternalWorkflowException { return requestEntityRelationshipDAO.getEntityNamesOfRequest( wfOperationType, wfStatus, entityType, tenantID); }
/** * Add a new relationship between a workflow request and an entity. * * @param requestId * @param entities * @throws InternalWorkflowException */ @Override public void addRequestEntityRelationships(String requestId, Entity[] entities) throws InternalWorkflowException { for (int i = 0; i < entities.length; i++) { requestEntityRelationshipDAO.addRelationship(entities[i], requestId); } }
@Override public void deleteWorkflowRequest(String requestId) throws WorkflowException { String loggedUser = CarbonContext.getThreadLocalCarbonContext().getUsername(); String createdUser = workflowRequestDAO.retrieveCreatedUserOfRequest(requestId); if (!loggedUser.equals(createdUser)) { throw new WorkflowException("User not authorized to delete this request"); } List<WorkflowRequestDeleteListener> workflowRequestDeleteListenerList = WorkflowServiceDataHolder.getInstance().getWorkflowRequestDeleteListenerList(); WorkflowRequest workflowRequest = new WorkflowRequest(); workflowRequest.setRequestId(requestId); workflowRequest.setCreatedBy(createdUser); for (WorkflowRequestDeleteListener workflowRequestDeleteListener : workflowRequestDeleteListenerList) { try { workflowRequestDeleteListener.doPreDeleteWorkflowRequest(workflowRequest); } catch (WorkflowException e) { throw new WorkflowException( "Error occurred while calling doPreDeleteWorkflowRequest in WorkflowRequestDeleteListener ," + workflowRequestDeleteListener.getClass().getName(), e); } } workflowRequestDAO.updateStatusOfRequest(requestId, WorkflowRequestStatus.DELETED.toString()); workflowRequestAssociationDAO.updateStatusOfRelationshipsOfPendingRequest( requestId, WFConstant.HT_STATE_SKIPPED); requestEntityRelationshipDAO.deleteRelationshipsOfRequest(requestId); for (WorkflowRequestDeleteListener workflowRequestDeleteListener : workflowRequestDeleteListenerList) { try { workflowRequestDeleteListener.doPostDeleteWorkflowRequest(workflowRequest); } catch (WorkflowException e) { throw new WorkflowException( "Error occurred while calling doPostDeleteWorkflowRequest in WorkflowRequestDeleteListener ," + workflowRequestDeleteListener.getClass().getName(), e); } } }
/** * Check if there are any requests the associated with both entities. * * @param entity1 * @param entity2 * @return * @throws InternalWorkflowException */ @Override public boolean areTwoEntitiesRelated(Entity entity1, Entity entity2) throws InternalWorkflowException { return requestEntityRelationshipDAO.twoEntitiesAreRelated(entity1, entity2); }
/** * Check if a given entity as any pending workflows of a given type associated with it. * * @param entity * @param requestType * @return * @throws InternalWorkflowException */ @Override public boolean entityHasPendingWorkflowsOfType(Entity entity, String requestType) throws InternalWorkflowException { return requestEntityRelationshipDAO.entityHasPendingWorkflowsOfType(entity, requestType); }
/** * Check if a given entity has any pending workflow requests associated with it. * * @param entity * @return * @throws InternalWorkflowException */ @Override public boolean entityHasPendingWorkflows(Entity entity) throws InternalWorkflowException { return requestEntityRelationshipDAO.entityHasPendingWorkflows(entity); }