
package de.ivu.elect.jee.presentation;

import java.io.Serializable;

import javax.enterprise.context.RequestScoped;
import javax.inject.Named;

/**
 * Beim Überschreiben der Icons beachten: Um bspw. ein Icon auszublenden, muss der entsprechende Getter mit Icons#getIconTransparent überschrieben werden ...
 */
@RequestScoped
@Named(Icons.COMPONENT_NAME)
public class Icons implements Serializable {

  private static final long serialVersionUID = 1L;

  public static final String COMPONENT_NAME = "icons";

  private static final String FA_ICON_PREFIX = "fa fa-";

  protected static final String UI_ICON_PREFIX = "ui-icon-";

  private static final String UI_ICONBADGE_STATUS_PREFIX = "ui-icon-badge-";

  private static final String UI_CUSTOM_ICON_CLASS = "ui-icon ui-icon-custom";

  public Icons() {
    super();
  }

  public String getIconTransparent() {
    // Spezielle, selbst definierte Style-Klasse! siehe outputIcon.css
    return UI_ICON_PREFIX + "transparent";
  }

  public String getIconHidden() {
    // Spezielle, selbst definierte Style-Klasse! siehe outputIcon.css
    return UI_ICON_PREFIX + "hidden";
  }

  public String getIconOrganisation() {
    // Spezielle, selbst definierte Style-Klasse! siehe outputIcon.css
    return UI_ICON_PREFIX + "organisation";
  }

  protected String createFaIcon(String iconName) {
    return FA_ICON_PREFIX + iconName;
  }

  @Deprecated
  protected String createUiIcon(String iconName) {
    return UI_ICON_PREFIX + iconName;
  }

  protected String createUiIconCustom(String iconName) {
    return UI_ICON_PREFIX + iconName + " " + UI_CUSTOM_ICON_CLASS;
  }

  /*
   * Cf. https://fontawesome.com/v4.7.0/icons/
   */

  public String getIconBooleanFalse() {
    return createFaIcon("minus");
  }

  public String getIconBooleanTrue() {
    return createFaIcon("check");
  }

  public String getIconBooleanNull() {
    return getIconTransparent();
  }

  public String getIconSearch() {
    return createFaIcon("search");
  }

  public String getIconCreate() {
    return createFaIcon("plus");
  }

  public String getIconView() {
    return createFaIcon("file-o");
  }

  public String getIconEdit() {
    return createFaIcon("pencil");
  }

  public String getIconNew() {
    return createFaIcon("plus");
  }

  public String getIconDelete() {
    return createFaIcon("trash");
  }

  public String getIconRecover() {
    return createFaIcon("undo");
  }

  public String getIconImport() {
    return createFaIcon("download");
  }

  public String getIconRegister() {
    return createFaIcon("folder-open");
  }

  public String getIconExport() {
    return createFaIcon("upload");
  }

  public String getIconDownload() {
    return createFaIcon("download");
  }

  public String getIconOk() {
    return getIconBooleanTrue();
  }

  public String getIconCancel() {
    return createFaIcon("ban");
  }

  public String getIconBack() {
    return createFaIcon("arrow-left");
  }

  public String getIconClose() {
    return createFaIcon("times");
  }

  public String getIconCloseCircle() {
    return createFaIcon("times-circle");
  }

  public String getIconAdd() {
    return createFaIcon("plus");
  }

  public String getIconSort() {
    return createFaIcon("random");
  }

  public String getIconRemove() {
    return createFaIcon("minus");
  }

  public String getIconZuweisen() {
    return createFaIcon("exchange");
  }

  public String getIconComment() {
    return createFaIcon("comment-o");
  }

  public String getIconComments() {
    return createFaIcon("comments");
  }

  public String getIconCommit() {
    return createFaIcon("refresh");
  }

  public String getIconRefresh() {
    return createFaIcon("refresh");
  }

  public String getIconSettings() {
    return createFaIcon("wrench");
  }

  public String getIconKey() {
    return createFaIcon("key");
  }

  public String getIconGear() {
    return createFaIcon("cog");
  }

  public String getIconCalculate() {
    return createFaIcon("calculator");
  }

  public String getIconStatus() {
    return createFaIcon("battery-2");
  }

  public String getIconCheck() {
    return createFaIcon("check");
  }

  public String getIconPerson() {
    return createFaIcon("user");
  }

  public String getIconNotice() {
    return createFaIcon("exclamation");
  }

  public String getIconHelp() {
    return createFaIcon("question");
  }

  public String getIconStar() {
    return createFaIcon("star");
  }

  public String getIconFolderOpen() {
    return createFaIcon("folder-open");
  }

  public String getIconSelectWahlFuerErfasser() {
    return createFaIcon("check-circle-o");
  }

  public String getIconUnselectWahlFuerErfasser() {
    return createFaIcon("times-circle-o");
  }

  public String getIconCircleLeer() {
    return createFaIcon("circle-thin");
  }

  public String getIconCircleVoll() {
    return createFaIcon("circle");
  }

  public String getIconPin() {
    return createFaIcon("thumb-tack");
  }

  public String getIconLock() {
    return createFaIcon("lock");
  }

  public String getIconUnlock() {
    return createFaIcon("unlock");
  }

  public String getIconSelect() {
    return createFaIcon("check");
  }

  public String getIconContact() {
    return createFaIcon("address-card-o");
  }

  public String getIconAddressCard() {
    return createFaIcon("address-card");
  }

  public String getIconList() {
    return createFaIcon("list");
  }

  public String getIconMicrochip() {
    return createFaIcon("microchip");
  }

  public String getIconFlag() {
    return createFaIcon("flag");
  }

  public String getIconSuitcase() {
    return createFaIcon("suitcase");
  }

  public String getIconInfo() {
    return createFaIcon("info-circle");
  }

  public String getIconAnwesenheit() {
    return createFaIcon("clock-o");
  }

  public String getIconOverview() {
    return createFaIcon("inbox");
  }

  public String getIconReport() {
    return createFaIcon("file-text");
  }

  public String getIconDesktop() {
    return createFaIcon("desktop");
  }

  public String getIconZoomIn() {
    return createFaIcon("search-plus");
  }

  public String getIconCircleCheck() {
    return createFaIcon("check-circle");
  }

  public String getIconAssignLeft() {
    return getIconLeft();
  }

  public String getIconProblem() {
    return createFaIcon("exclamation-triangle");
  }

  public String getIconNext() {
    return createFaIcon("forward");
  }

  public String getIconPrevious() {
    return createFaIcon("backward");
  }

  public String getIconUp() {
    return createFaIcon("long-arrow-up");
  }

  public String getIconDown() {
    return createFaIcon("long-arrow-down");
  }

  public String getIconLeft() {
    return createFaIcon("arrow-left");
  }

  public String getIconLueckeEinfuegen() {
    return createFaIcon("arrows-v");
  }

  public String getIconEinkaufswagen() {
    return createFaIcon("shopping-cart");
  }

  public String getIconDocument() {
    return createFaIcon("file");
  }

  public String getIconTypVoid() {
    return getIconLock();
  }

  public String getIconTypString() {
    return createFaIcon("file-text-o");
  }

  public String getIconTypTimestamp() {
    return getIconClock();
  }

  public String getIconTypCron() {
    return createFaIcon("bell-o");
  }

  public String getIconTypBoolean() {
    return createFaIcon("toggle-on");
  }

  public String getIconTypLong() {
    return createFaIcon("calculator");
  }

  public String getIconTypInteger() {
    return createFaIcon("calculator");
  }

  public String getIconTypVerzeichnis() {
    return createFaIcon("folder-o");
  }

  public String getIconTypVerzeichnisBeschreibbar() {
    return createFaIcon("folder-open-o");
  }

  public String getIconTypEnum() {
    return createFaIcon("list-ul");
  }

  public String getIconTypSelect() {
    return createFaIcon("list-alt");
  }

  public String getIconEntschuldigt() {
    return createFaIcon("circle");
  }

  public String getIconUnentschuldigt() {
    return createFaIcon("times");
  }

  public String getIconAnwesend() {
    return createFaIcon("check");
  }

  public String getIconBezahlt() {
    return getIconGeld();
  }

  public String getIconBenachrichtigt() {
    return createFaIcon("envelope-o");
  }

  public String getIconEingeteilt() {
    return createFaIcon("step-forward");
  }

  public String getIconPrint() {
    return createFaIcon("print");
  }

  public String getIconDublettenAufloesen() {
    return createFaIcon("exchange");
  }

  public String getIconAlert() {
    return createFaIcon("exclamation-triangle");
  }

  public String getIconWarning() {
    return createFaIcon("warning");
  }

  public String getIconQuestion() {
    return createFaIcon("question");
  }

  public String getIconTreeNodeExpand() {
    return createFaIcon("caret-right");
  }

  public String getIconTreeNodeCollapse() {
    return createFaIcon("caret-down");
  }

  public String getIconCopy() {
    return createFaIcon("copy");
  }

  public String getIconClock() {
    return createFaIcon("clock-o");
  }

  public String getIconCircleSmallPlus() {
    return createFaIcon("plus-square-o");
  }

  public String getIconZugelassen() {
    return getIconBooleanTrue();
  }

  public String getIconNichtZugelassen() {
    return getIconBooleanFalse();
  }

  public String getIconUngeprueft() {
    return getIconHelp();
  }

  public String getIconUnzutreffend() {
    return getIconCancel();
  }

  public String getIconHome() {
    return createFaIcon("home");
  }

  public String getIconSchnittstellen() {
    return createFaIcon("exchange");
  }

  public String getIconExternalLink() {
    return createFaIcon("external-link");
  }

  public String getIconOrt() {
    return createFaIcon("map-marker");
  }

  public String getIconBook() {
    return createFaIcon("book");
  }

  public String getIconPublish() {
    return createFaIcon("feed");
  }

  public String getIconImage() {
    return createFaIcon("picture-o");
  }

  public String getIconReplikation() {
    return createFaIcon("feed");
  }

  public String getIconAufruecken() {
    return createFaIcon("arrow-up");
  }

  public String getIconFiletypeImage() {
    return createFaIcon("file-image-o");
  }

  public String getIconFiletypeVideo() {
    return createFaIcon("file-video-o");
  }

  public String getIconExpand() {
    return createFaIcon("caret-down");
  }

  public String getIconDraggable() {
    return createFaIcon("arrows");
  }

  public String getIconCustomize() {
    return createFaIcon("cog");
  }

  public String getIconSave() {
    return createFaIcon("floppy-o");
  }

  public String getIconExportCSV() {
    return getIconSave();
  }

  public String getIconExportExcel() {
    return createFaIcon("file-excel-o");
  }

  public String getIconExportWord() {
    return createFaIcon("file-word-o");
  }

  public String getIconExportPDF() {
    return createFaIcon("file-pdf-o");
  }

  public String getIconExportText() {
    return createFaIcon("file-text-o");
  }

  public String getIconExportXML() {
    return createFaIcon("file-code-o");
  }

  public String getIconRepeat() {
    return createFaIcon("repeat");
  }

  public String getIconCollapseLeft() {
    return createFaIcon("chevron-left");
  }

  public String getIconStatusmessageError() {
    return createFaIcon("times");
  }

  public String getIconStatusmessageWarning() {
    return getIconWarning();
  }

  public String getIconStatusmessageNichtVorhanden() {
    return createFaIcon("question-circle-o");
  }

  public String getIconStatusmessageInfo() {
    return createFaIcon("info");
  }

  public String getIconStatusmessageOkay() {
    return getIconCheck();
  }

  public String getIconHelpCircle() {
    return createFaIcon("question-circle");
  }

  public String getIconGeld() {
    return createFaIcon("money");
  }

  public String getIconKalender() {
    return createFaIcon("calendar");
  }

  public String getIconPowerOff() {
    return createFaIcon("power-off");
  }

  public String getIconEmailLayout() {
    return createFaIcon("font");
  }

  public String getIconEmailVorlage() {
    return createFaIcon("envelope");
  }

  public String getIconEmailVorgang() {
    return getIconEmailVorlage();
  }

  public String getIconEmailAnhang() {
    return createFaIcon("paperclip");
  }

  public String getIconSend() {
    //    return "paper-plane"; // erst ab Font Awesome v4.1 verfügbar
    return getIconEmailVorgang();
  }

  /**
   * enthalten in ui-icons-custom.png
   */
  public String getIconEqual() {
    return createUiIconCustom("equal");
  }

  /**
   * enthalten in ui-icons-custom.png
   */
  public String getIconUnequal() {
    return createUiIconCustom("unequal");
  }

  /**
   * custom icon - deprecated
   *
   * @deprecated
   */
  @Deprecated
  public String getIconListe() {
    return createUiIconCustom("gebiet-liste");
  }

  /**
   * enthalten in ui-icons-custom.png
   */
  public String getIconWahlgebiet() {
    return createUiIconCustom("gebiet-wahlgebiet");
  }

  /**
   * enthalten in ui-icons-custom.png
   */
  public String getIconGebietsbaumRoot() {
    return createUiIconCustom("gebietsbaum-root");
  }

  /**
   * enthalten in ui-icons-custom.png
   */
  public String getIconGebietsbaumNode1() {
    return createUiIconCustom("gebietsbaum-node1");
  }

  /**
   * enthalten in ui-icons-custom.png
   */
  public String getIconGebietsbaumNode2() {
    return createUiIconCustom("gebietsbaum-node2");
  }

  /**
   * enthalten in ui-icons-custom.png
   */
  public String getIconGebietsbaumNode2Teilgebiet() {
    return createUiIconCustom("gebietsbaum-node2-teilgebiet");
  }

  /**
   * enthalten in ui-icons-custom.png
   */
  public String getIconGebietsbaumKreis() {
    return createUiIconCustom("gebiet-kreis");
  }

  /**
   * enthalten in ui-icons-custom.png
   */
  public String getIconGebietsbaumBriefwahlbezirk() {
    return createUiIconCustom("gebiet-briefwahlbezirk");
  }

  /**
   * enthalten in ui-icons-custom.png
   */
  public String getIconGebietsbaumWahllokal() {
    return createUiIconCustom("gebiet-wahllokal");
  }

  /**
   * enthalten in ui-icons-custom.png
   */
  public String getIconGebietsbaumReservepool() {
    return createUiIconCustom("gebiet-reservepool");
  }

  /**
   * enthalten in ui-icons-custom.png
   */
  public String getIconStatusError() {
    return createUiIconCustom("status-error");
  }

  /**
   * enthalten in ui-icons-custom.png
   */
  public String getIconStatusProzent0() {
    return createUiIconCustom("status-0");
  }

  /**
   * enthalten in ui-icons-custom.png
   */
  public String getIconStatusProzent125() {
    return createUiIconCustom("status-12-5");
  }

  /**
   * enthalten in ui-icons-custom.png
   */
  public String getIconStatusProzent25() {
    return createUiIconCustom("status-25");
  }

  /**
   * enthalten in ui-icons-custom.png
   */
  public String getIconStatusProzent375() {
    return createUiIconCustom("status-37-5");
  }

  /**
   * enthalten in ui-icons-custom.png
   */
  public String getIconStatusProzent50() {
    return createUiIconCustom("status-50");
  }

  /**
   * enthalten in ui-icons-custom.png
   */
  public String getIconStatusProzent625() {
    return createUiIconCustom("status-62-5");
  }

  /**
   * enthalten in ui-icons-custom.png
   */
  public String getIconStatusProzent75() {
    return createUiIconCustom("status-75");
  }

  /**
   * enthalten in ui-icons-custom.png
   */
  public String getIconStatusProzent875() {
    return createUiIconCustom("status-87-5");
  }

  /**
   * enthalten in ui-icons-custom.png
   */
  public String getIconStatusProzent100() {
    return createUiIconCustom("status-100");
  }

  public String getIconStatus(Double status) {
    if (status == null) {
      return getIconStatusError();
    }
    if (status <= 0d) {
      return getIconStatusProzent0();
    }
    if (status < .25d) {
      return getIconStatusProzent125();
    }
    if (status < .375d) {
      return getIconStatusProzent25();
    }
    if (status < .5d) {
      return getIconStatusProzent375();
    }
    if (status < .625d) {
      return getIconStatusProzent50();
    }
    if (status < .75d) {
      return getIconStatusProzent625();
    }
    if (status < .875d) {
      return getIconStatusProzent75();
    }
    if (status < 1d) {
      return getIconStatusProzent875();
    }
    return getIconStatusProzent100();
  }

  /**
   * enthalten in ui-iconbadges-status.png
   */
  private String createUiIconbadgeStatus(String iconName) {
    return UI_ICONBADGE_STATUS_PREFIX + iconName;
  }

  public String getIconbadgeStatusError() {
    return createUiIconbadgeStatus("error");
  }

  /**
   * enthalten in ui-iconbadges-status.png
   */
  public String getIconbadgeStatusProzent0() {
    return createUiIconbadgeStatus("0");
  }

  /**
   * enthalten in ui-iconbadges-status.png
   */
  public String getIconbadgeStatusProzent125() {
    return createUiIconbadgeStatus("12-5");
  }

  /**
   * enthalten in ui-iconbadges-status.png
   */
  public String getIconbadgeStatusProzent25() {
    return createUiIconbadgeStatus("25");
  }

  /**
   * enthalten in ui-iconbadges-status.png
   */
  public String getIconbadgeStatusProzent375() {
    return createUiIconbadgeStatus("37-5");
  }

  /**
   * enthalten in ui-iconbadges-status.png
   */
  public String getIconbadgeStatusProzent50() {
    return createUiIconbadgeStatus("50");
  }

  /**
   * enthalten in ui-iconbadges-status.png
   */
  public String getIconbadgeStatusProzent625() {
    return createUiIconbadgeStatus("62-5");
  }

  /**
   * enthalten in ui-iconbadges-status.png
   */
  public String getIconbadgeStatusProzent75() {
    return createUiIconbadgeStatus("75");
  }

  /**
   * enthalten in ui-iconbadges-status.png
   */
  public String getIconbadgeStatusProzent875() {
    return createUiIconbadgeStatus("87-5");
  }

  /**
   * enthalten in ui-iconbadges-status.png
   */
  public String getIconbadgeStatusProzent100() {
    return createUiIconbadgeStatus("100");
  }

  public String getIconbadgeStatus(Double status) {
    if (status == null) {
      return getIconbadgeStatusError();
    }

    if (status <= 0) {
      return getIconbadgeStatusProzent0();
    }
    if (status < .25d) {
      return getIconbadgeStatusProzent125();
    }
    if (status < .375d) {
      return getIconbadgeStatusProzent25();
    }
    if (status < .5d) {
      return getIconbadgeStatusProzent375();
    }
    if (status < .625d) {
      return getIconbadgeStatusProzent50();
    }
    if (status < .75d) {
      return getIconbadgeStatusProzent625();
    }
    if (status < .875d) {
      return getIconbadgeStatusProzent75();
    }
    if (status < 1d) {
      return getIconbadgeStatusProzent875();
    }
    return getIconbadgeStatusProzent100();
  }

  public String getIconMitStatus(String icon, Double status) {
    return icon + " " + getIconbadgeStatus(status);
  }

  public static Double getProzent(AnzahlSollIst anzahlSollIst) {
    return getProzent(anzahlSollIst.getSoll(), anzahlSollIst.getIst());
  }

  public static Double getProzent(Long soll, Long ist) {
    if (soll != null && ist != null) {
      if (Long.valueOf(0).equals(soll)) {
        return null;
      }
      return 1.0d * ist / (1.0d * soll);
    }
    return null;
  }

  public String getIconStatus(AnzahlSollIst anzahlSollIst) {
    return getIconStatus(anzahlSollIst.getSoll(), anzahlSollIst.getIst());
  }

  public String getIconStatus(Long anzahlSoll, Long anzahlIst) {
    return getIconStatus(getProzent(anzahlSoll, anzahlIst));
  }
}
