docs: public void deleteProcessDefinition(ProcessDefinition processDefinition, String processDefinitionId, boolean cascadeToHistory, boolean cascadeToInstances, boolean skipCustomListeners, boolean skipIoMappings) {
  
      if (cascadeToHistory) {
        cascadeDeleteHistoryForProcessDefinition(processDefinitionId);
        if (cascadeToInstances) {
          cascadeDeleteProcessInstancesForProcessDefinition(processDefinitionId, skipCustomListeners, skipIoMappings);
        }
      } else {
        ProcessInstanceQueryImpl procInstQuery = new ProcessInstanceQueryImpl().processDefinitionId(processDefinitionId);
        long processInstanceCount = getProcessInstanceManager().findProcessInstanceCountByQueryCriteria(procInstQuery);
        if (processInstanceCount != 0) {
          throw LOG.deleteProcessDefinitionWithProcessInstancesException(processDefinitionId, processInstanceCount);
        }
      }
  
      // remove related authorization parameters in IdentityLink table
      getIdentityLinkManager().deleteIdentityLinksByProcDef(processDefinitionId);
  
      // remove timer start events:
      deleteTimerStartEventsForProcessDefinition(processDefinition);
  
      //delete process definition from database
      getDbEntityManager().delete(ProcessDefinitionEntity.class, "deleteProcessDefinitionsById", processDefinitionId);
  
      // remove process definition from cache:
      Context
        .getProcessEngineConfiguration()
        .getDeploymentCache()
        .removeProcessDefinition(processDefinitionId);
  
      deleteSubscriptionsForProcessDefinition(processDefinitionId);
  
      // delete job definitions
      getJobDefinitionManager().deleteJobDefinitionsByProcessDefinitionId(processDefinition.getId());
  
    }