/**
   * Month conversion from jaxb model to entity object.
   *
   * @param model jaxb model of month
   * @return month entity object
   */
  public static org.kaleta.scheduler.backend.entity.Month transformMonthToData(Month model) {
    org.kaleta.scheduler.backend.entity.Month data =
        new org.kaleta.scheduler.backend.entity.Month();

    data.setId(Integer.valueOf(model.getId()));
    data.setName(model.getSpecification().getName());
    data.setDaysNumber(Integer.valueOf(model.getSpecification().getDays()));
    data.setDayStartsWith(Integer.valueOf(model.getSpecification().getFirstDay()));
    for (Month.Specification.FreeDay freeDay : model.getSpecification().getFreeDayList()) {
      data.getPublicFreeDays().add(Integer.valueOf(freeDay.getDay()));
    }

    for (Month.Schedule.Task modelTask : model.getSchedule().getTaskList()) {
      Task task = new Task();
      task.setId(Integer.valueOf(modelTask.getId()));
      task.setType(modelTask.getType());
      task.setDescription(modelTask.getDescription());
      task.setDay(Integer.valueOf(modelTask.getDay()));
      Time starts = new Time();
      starts.setFromString(modelTask.getStarts());
      task.setStarts(starts);
      Time duration = new Time();
      duration.setFromString(modelTask.getDuration());
      task.setDuration(duration);
      task.setPriority(Boolean.valueOf(modelTask.getPriority()));
      task.setSuccessful(Boolean.valueOf(modelTask.getSuccessful()));
      data.getTasks().add(task);
    }

    for (Month.Accounting.Item modelItem : model.getAccounting().getItemList()) {
      Item item = new Item();
      item.setId(Integer.valueOf(modelItem.getId()));
      item.setType(modelItem.getType());
      item.setDescription(modelItem.getDescription());
      item.setDay(Integer.valueOf(modelItem.getDay()));
      item.setIncome(Boolean.valueOf(modelItem.getIncome()));
      item.setAmount(new BigDecimal(modelItem.getAmount()));
      data.getItems().add(item);
    }

    return data;
  }
  /**
   * Global conversion from jaxb model to entity object.
   *
   * @param model jaxb model of Global
   * @return Global entity object
   */
  public static org.kaleta.scheduler.backend.entity.Global transformGlobalToData(Global model) {
    org.kaleta.scheduler.backend.entity.Global data =
        new org.kaleta.scheduler.backend.entity.Global();

    for (Global.Months.Month month : model.getMonths().getMonthList()) {
      data.getMonths().put(Integer.valueOf(month.getId()), Integer.valueOf(month.getOrder()));
    }

    for (Global.Tasks.Task task : model.getTasks().getTaskList()) {
      GlobalTask globalTask = new GlobalTask();
      globalTask.setId(Integer.valueOf(task.getId()));
      globalTask.setType(task.getType());
      globalTask.setDescription(task.getDescription());
      globalTask.setPriority(Boolean.valueOf(task.getPriority()));
      globalTask.setFinished(Boolean.valueOf(task.getFinished()));
      data.getTasks().add(globalTask);
    }

    return data;
  }
  /**
   * Settings conversion from jaxb model to entity object.
   *
   * @param model jaxb model of Settings
   * @return Settings entity object
   */
  public static org.kaleta.scheduler.backend.entity.Settings transformSettingsToData(
      Settings model) {
    org.kaleta.scheduler.backend.entity.Settings data =
        new org.kaleta.scheduler.backend.entity.Settings();

    data.setFirstUse(Boolean.valueOf(model.getAppSettings().getFirstUse().getValue()));
    data.setUserName(model.getUserSettings().getUserName().getValue());
    data.setLastMonthSelectedId(
        Integer.valueOf(model.getUserSettings().getLastSelected().getMonth_id()));
    data.setLastDaySelected(Integer.valueOf(model.getUserSettings().getLastSelected().getDay()));
    data.setUiSchemeSelected(model.getUserSettings().getUiScheme().getValue());
    data.setLanguage(model.getUserSettings().getLanguage().getValue());
    data.setCurrency(model.getUserSettings().getCurrency().getValue());
    for (Settings.TypesSettings.Type type :
        model.getTypesSettings().getItemTypes().getItemTypes()) {
      UserType itemType = new UserType();
      itemType.setName(type.getName());
      itemType.setColor(new Color(Integer.valueOf(type.getColor())));
      itemType.setSign(type.getSign().equals("+")); // diff -/+
      for (Settings.TypesSettings.Description description : type.getDescriptions()) {
        itemType.getPreparedDescriptions().add(description.getValue());
      }
      data.getItemTypes().add(itemType);
    }
    for (Settings.TypesSettings.Type type :
        model.getTypesSettings().getTaskTypes().getTaskTypes()) {
      UserType taskType = new UserType();
      taskType.setName(type.getName());
      taskType.setColor(new Color(Integer.valueOf(type.getColor())));
      taskType.setSign(false); // not supported
      for (Settings.TypesSettings.Description description : type.getDescriptions()) {
        taskType.getPreparedDescriptions().add(description.getValue());
      }
      data.getTaskTypes().add(taskType);
    }
    for (Settings.TypesSettings.Type type :
        model.getTypesSettings().getGlobalTaskTypes().getGlobalTaskTypes()) {
      UserType globalTaskType = new UserType();
      globalTaskType.setName(type.getName());
      globalTaskType.setColor(new Color(Integer.valueOf(type.getColor())));
      globalTaskType.setSign(false); // not supported
      for (Settings.TypesSettings.Description description : type.getDescriptions()) {
        globalTaskType.getPreparedDescriptions().add(description.getValue());
      }
      data.getGlobalTaskTypes().add(globalTaskType);
    }

    return data;
  }