/** * Global conversion from entity object to jaxb model. * * @param data Global entity object * @return jaxb model of Global */ public static Global transformGlobalToModel(org.kaleta.scheduler.backend.entity.Global data) { Global model = new Global(); Global.Months months = new Global.Months(); for (Integer monthId : data.getMonths().keySet()) { Global.Months.Month month = new Global.Months.Month(); month.setId(String.valueOf(monthId)); month.setOrder(String.valueOf(data.getMonths().get(monthId))); months.getMonthList().add(month); } model.setMonths(months); Global.Tasks tasks = new Global.Tasks(); for (GlobalTask globalTask : data.getTasks()) { Global.Tasks.Task task = new Global.Tasks.Task(); task.setId(String.valueOf(globalTask.getId())); task.setType(globalTask.getType()); task.setDescription(globalTask.getDescription()); task.setPriority(String.valueOf(globalTask.getPriority())); task.setFinished(String.valueOf(globalTask.getFinished())); tasks.getTaskList().add(task); } model.setTasks(tasks); return model; }
/** * 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; }