public void dropStream(String streamName) {

    Map<String, QueryDTO> attachedQueries = streamStatusDao.get(streamName).getAddedQueries();
    for (String queryId : attachedQueries.keySet()) {
      siddhiManager.removeQuery(queryId);
    }
    siddhiManager.removeStream(streamName);
    streamStatusDao.remove(streamName);
  }
 public void removeQuery(String queryId, String streamName) {
   siddhiManager.removeQuery(queryId);
   streamStatusDao.removeQuery(streamName, queryId);
   for (Map.Entry<String, StreamStatusDTO> streamStatus : streamStatusDao.getAll().entrySet()) {
     String temporalStreamName = streamStatus.getKey();
     if (siddhiManager.getStreamDefinition(temporalStreamName) == null) {
       this.dropStream(temporalStreamName);
     }
   }
 }
  public void disableAction(String streamName, StreamAction action) {
    streamStatusDao.disableAction(streamName, action);

    if (streamStatusDao.getEnabledActions(streamName).size() == 0) {
      String actionQueryId = streamStatusDao.getActionQuery(streamName);
      if (actionQueryId != null) {
        siddhiManager.removeQuery(actionQueryId);
      }
      callbackService.remove(streamName);
    }
  }
  public void disableEngineAction(String streamName, EngineActionType engineActionType) {

    if (streamStatusDao.isEngineActionEnabled(streamName, engineActionType)) {

      String engineActionQueryId =
          streamStatusDao.getEngineActionQueryId(streamName, engineActionType);

      if (engineActionQueryId != null) {

        siddhiManager.removeQuery(engineActionQueryId);
      }

      streamStatusDao.disableEngineAction(streamName, engineActionType);
      callbackService.removeEngineAction(streamName, engineActionType);
    }
  }