class WidgetResourceProvider 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<WidgetEntity> entitiesToBeRemoved = new ArrayList<>();
    for (Map<String, Object> propertyMap : propertyMaps) {
      final Long id;
      try {
        id = Long.parseLong(propertyMap.get(WIDGET_ID_PROPERTY_ID).toString());
      } catch (Exception ex) {
        throw new SystemException("Widget should have numerical id");
      }
      final WidgetEntity entity = widgetDAO.findById(id);
      if (entity == null) {
        throw new NoSuchResourceException("There is no widget with id " + id);
      }
      entitiesToBeRemoved.add(entity);
    }

    for (WidgetEntity entity: entitiesToBeRemoved) {
      if (entity.getListWidgetLayoutUserWidgetEntity() != null) {
        for (WidgetLayoutUserWidgetEntity layoutUserWidgetEntity : entity.getListWidgetLayoutUserWidgetEntity()) {
          if (layoutUserWidgetEntity.getWidgetLayout().getListWidgetLayoutUserWidgetEntity() != null) {
            layoutUserWidgetEntity.getWidgetLayout().getListWidgetLayoutUserWidgetEntity().remove(layoutUserWidgetEntity);
          }
        }
      }
      widgetDAO.remove(entity);
    }

    return getRequestStatus(null);
  }

  public  WidgetResourceProvider(AmbariManagementController managementController);

}