package de.ivu.elect.presentation.praesentation.table;

import java.util.function.Function;

import javax.annotation.Nullable;

import de.ivu.elect.business.praesentation.entity.PraesentationStatistikSearchResult;
import de.ivu.elect.jee.faces.Messages;
import de.ivu.elect.jee.presentation.dynamictable.ColumnType;
import de.ivu.elect.presentation.table.DefaultColumnEntry;

public class PraesentationStatistikUploadZeitstempelColumn extends DefaultColumnEntry<PraesentationStatistikSearchResult> {
  private static final long serialVersionUID = 1L;

  public PraesentationStatistikUploadZeitstempelColumn(String id, Messages messages, String headerKey, ColumnType type, Function<PraesentationStatistikSearchResult, Object> getter, Object... headerParams) {
    super(id, messages, headerKey, type, getter, headerParams);
  }

  @Override
  public boolean isIconPresent() {
    return true;
  }

  @Override
  public boolean isIconRendered(PraesentationStatistikSearchResult entity) {
    return super.isIconRendered(entity) || entity.getPraesentationUploadEntry().isError();
  }

  @Nullable
  @Override
  public String getIcon(PraesentationStatistikSearchResult entity) {
    if (entity.getPraesentationUploadEntry().isError()) {
      return "fa fa-exclamation-triangle";
    }
    return super.getIcon(entity);
  }

}
