docs: @Override
    public void delete(DbSession dbSession, Collection<QProfileDto> profiles) {
      if (profiles.isEmpty()) {
        return;
      }
  
      Set<String> uuids = new HashSet<>();
      List<QProfileDto> customProfiles = new ArrayList<>();
      Set<String> rulesProfileUuidsOfCustomProfiles = new HashSet<>();
      profiles.forEach(p -> {
        uuids.add(p.getKee());
        if (!p.isBuiltIn()) {
          customProfiles.add(p);
          rulesProfileUuidsOfCustomProfiles.add(p.getRulesProfileUuid());
        }
      });
  
      // tables org_qprofiles, default_qprofiles and project_qprofiles
      // are deleted whatever custom or built-in
      db.qualityProfileDao().deleteProjectAssociationsByProfileUuids(dbSession, uuids);
      db.defaultQProfileDao().deleteByQProfileUuids(dbSession, uuids);
      db.qualityProfileDao().deleteOrgQProfilesByUuids(dbSession, uuids);
  
      // Permissions are only available on custom profiles
      db.qProfileEditUsersDao().deleteByQProfiles(dbSession, customProfiles);
      db.qProfileEditGroupsDao().deleteByQProfiles(dbSession, customProfiles);
  
      // tables related to rules_profiles and active_rules are deleted
      // only for custom profiles. Built-in profiles are never
      // deleted from table rules_profiles.
      if (!rulesProfileUuidsOfCustomProfiles.isEmpty()) {
        db.activeRuleDao().deleteParametersByRuleProfileUuids(dbSession, rulesProfileUuidsOfCustomProfiles);
        db.activeRuleDao().deleteByRuleProfileUuids(dbSession, rulesProfileUuidsOfCustomProfiles);
        db.qProfileChangeDao().deleteByRulesProfileUuids(dbSession, rulesProfileUuidsOfCustomProfiles);
        db.qualityProfileDao().deleteRulesProfilesByUuids(dbSession, rulesProfileUuidsOfCustomProfiles);
        activeRuleIndexer.commitDeletionOfProfiles(dbSession, customProfiles);
      } else {
        dbSession.commit();
      }
    }