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

    model.setId(String.valueOf(data.getId()));

    Month.Specification specification = new Month.Specification();
    specification.setName(data.getName());
    specification.setDays(String.valueOf(data.getDaysNumber()));
    specification.setFirstDay(String.valueOf(data.getDayStartsWith()));
    for (Integer day : data.getPublicFreeDays()) {
      Month.Specification.FreeDay freeDay = new Month.Specification.FreeDay();
      freeDay.setDay(String.valueOf(day));
      specification.getFreeDayList().add(freeDay);
    }
    model.setSpecification(specification);

    Month.Schedule schedule = new Month.Schedule();
    for (Task task : data.getTasks()) {
      Month.Schedule.Task taskModel = new Month.Schedule.Task();
      taskModel.setId(String.valueOf(task.getId()));
      taskModel.setType(task.getType());
      taskModel.setDescription(task.getDescription());
      taskModel.setDay(String.valueOf(task.getDay()));
      taskModel.setStarts(task.getStarts().toString());
      taskModel.setDuration(task.getDuration().toString());
      taskModel.setPriority(String.valueOf(task.getPriority()));
      taskModel.setSuccessful(String.valueOf(task.getSuccessful()));
      schedule.getTaskList().add(taskModel);
    }
    model.setSchedule(schedule);

    Month.Accounting accounting = new Month.Accounting();
    for (Item item : data.getItems()) {
      Month.Accounting.Item itemModel = new Month.Accounting.Item();
      itemModel.setId(String.valueOf(item.getId()));
      itemModel.setType(item.getType());
      itemModel.setDescription(item.getDescription());
      itemModel.setDay(String.valueOf(item.getDay()));
      itemModel.setIncome(String.valueOf(item.getIncome()));
      itemModel.setAmount(String.valueOf(item.getAmount()));
      accounting.getItemList().add(itemModel);
    }
    model.setAccounting(accounting);

    return model;
  }
  /**
   * 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;
  }