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

import java.util.ArrayList;
import java.util.List;

import javax.inject.Named;

import de.ivu.elect.business.system.entity.TimerStatus;
import de.ivu.elect.jee.presentation.dynamictable.AbstractColumnBuilder;
import de.ivu.elect.jee.presentation.dynamictable.ColumnEntry;
import de.ivu.elect.jee.presentation.dynamictable.ColumnType;
import de.ivu.elect.presentation.table.DefaultColumnEntry;

/**
 *  on 01.11.2016.
 */
@Named(TimerStatusColumnBuilder.COMPONENT_NAME)
public class TimerStatusColumnBuilder extends AbstractColumnBuilder<TimerStatus> {

  public static final String COMPONENT_NAME = "timerStatusColumnBuilder";

  private static final long serialVersionUID = 1L;

  private DefaultColumnEntry<TimerStatus> toStringColumn;

  private DefaultColumnEntry<TimerStatus> nextTimeoutColumn;

  private DefaultColumnEntry<TimerStatus> scheduleColumn;

  private DefaultColumnEntry<TimerStatus> infoColumn;

  public TimerStatusColumnBuilder() {
    super();
  }

  @Override
  protected void initColumns() {
    toStringColumn = new DefaultColumnEntry<>("TimerStatusColumnBuilder-timerToString", getMessages(), "timer.status.string", ColumnType.STRING, TimerStatus::getTimerToString);
    nextTimeoutColumn = new DefaultColumnEntry<>("TimerStatusColumnBuilder-nextTimeout", getMessages(), "timer.status.nextTimeout", ColumnType.TIMESTAMP, TimerStatus::getNextTimeout);
    scheduleColumn = new DefaultColumnEntry<>("TimerStatusColumnBuilder-schedule", getMessages(), "timer.status.schedule", ColumnType.STRING, TimerStatus::getSchedule);
    infoColumn = new DefaultColumnEntry<>("TimerStatusColumnBuilder-info", getMessages(), "timer.status.info", ColumnType.STRING, TimerStatus::getInfo);
  }

  @Override
  protected List<ColumnEntry< ? super TimerStatus>> getColumnEntriesSorted() {
    List<ColumnEntry< ? super TimerStatus>> result = new ArrayList<>();
    result.add(nextTimeoutColumn);
    result.add(scheduleColumn);
    result.add(infoColumn);
    result.add(toStringColumn);

    return result;
  }

  @Override
  public boolean isColumnsSortableByValue() {
    return false; // funktioniert nicht...
  }
}
