class WidgetLayoutResourceProvider extends AbstractControllerResourceProvider {

  @Override
  public RequestStatus deleteResources(Request request, Predicate predicate)
      throws SystemException, UnsupportedPropertyException, NoSuchResourceException, NoSuchParentResourceException {
    final Set<Map<String, Object>> propertyMaps = getPropertyMaps(predicate);

    final List<WidgetLayoutEntity> entitiesToBeRemoved = new ArrayList<>();
    for (Map<String, Object> propertyMap : propertyMaps) {
      final Long id;
      try {
        id = Long.parseLong(propertyMap.get(WIDGETLAYOUT_ID_PROPERTY_ID).toString());
      } catch (Exception ex) {
        throw new SystemException("WidgetLayout should have numerical id");
      }

      final WidgetLayoutEntity entity = widgetLayoutDAO.findById(id);
      if (entity == null) {
        throw new NoSuchResourceException("There is no widget layout with id " + id);
      }

      entitiesToBeRemoved.add(entity);
    }

    for (WidgetLayoutEntity entity: entitiesToBeRemoved) {
      if (entity.getListWidgetLayoutUserWidgetEntity() != null) {
        for (WidgetLayoutUserWidgetEntity layoutUserWidgetEntity : entity.getListWidgetLayoutUserWidgetEntity()) {
          if (layoutUserWidgetEntity.getWidget().getListWidgetLayoutUserWidgetEntity() != null) {
            layoutUserWidgetEntity.getWidget().getListWidgetLayoutUserWidgetEntity().remove(layoutUserWidgetEntity);
          }
        }
      }
      widgetLayoutDAO.remove(entity);
    }

    return getRequestStatus(null);
  }

  public  WidgetLayoutResourceProvider(AmbariManagementController managementController);

}