@SuppressWarnings("unchecked")
  private void createAlertGroups(Set<Map<String, Object>> requestMaps)
      throws AmbariException, AuthorizationException {

    List<AlertGroupEntity> entities = new ArrayList<>();
    for (Map<String, Object> requestMap : requestMaps) {
      AlertGroupEntity entity = new AlertGroupEntity();

      String name = (String) requestMap.get(ALERT_GROUP_NAME);
      String clusterName = (String) requestMap.get(ALERT_GROUP_CLUSTER_NAME);

      if (StringUtils.isEmpty(name)) {
        throw new IllegalArgumentException(
            "The name of the alert group is required.");
      }

      if (StringUtils.isEmpty(clusterName)) {
        throw new IllegalArgumentException(
            "The name of the cluster is required when creating an alert group.");
      }

      Cluster cluster = getManagementController().getClusters().getCluster(
          clusterName);

      entity.setClusterId(cluster.getClusterId());
      entity.setGroupName(name);

      // groups created through the provider are not default service groups
      entity.setDefault(false);

      // targets are not required on creation
      if (requestMap.containsKey(ALERT_GROUP_TARGETS)) {
        List<Long> targetIds = (List<Long>) requestMap.get(ALERT_GROUP_TARGETS);
        Set<AlertTargetEntity> targets = new HashSet<>();
        targets.addAll(s_dao.findTargetsById(targetIds));
        entity.setAlertTargets(targets);
      }

      // definitions are not required on creation
      if (requestMap.containsKey(ALERT_GROUP_DEFINITIONS)) {
        List<Long> definitionIds = (List<Long>) requestMap.get(ALERT_GROUP_DEFINITIONS);
        Set<AlertDefinitionEntity> definitions = new HashSet<>();
        definitions.addAll(s_definitionDao.findByIds(definitionIds));
        entity.setAlertDefinitions(definitions);
      }

      AlertResourceProviderUtils.verifyManageAuthorization(entity, cluster.getResourceId());

      entities.add(entity);
    }

    s_dao.createGroups(entities);
  }
Create and persist {@link AlertTargetEntity} from the map of properties.

@param requestMaps
@throws AmbariException
ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AlertGroupResourceProvider.java