public static EntityMilestone createEntity(Milestone gitMilestone, EntityRepository repository, GenericDao dao) {
if (gitMilestone == null) {
return null;
}
EntityMilestone milestone = getMilestoneByURL(gitMilestone.getUrl(), dao);
if (milestone == null) {
milestone = new EntityMilestone();
milestone.setCreator(UserServices.createEntity(gitMilestone.getCreator(), dao, false));
milestone.setUrl(gitMilestone.getUrl());
milestone.setNumber(gitMilestone.getNumber());
milestone.setCreatedAt(gitMilestone.getCreatedAt());
if (repository != null) {
milestone.setRepository(repository);
}
}
milestone.setDueOn(gitMilestone.getDueOn());
milestone.setClosedIssues(gitMilestone.getClosedIssues());
milestone.setOpenIssues(gitMilestone.getOpenIssues());
milestone.setDescription(gitMilestone.getDescription());
milestone.setStateMilestone(gitMilestone.getState());
milestone.setTitle(gitMilestone.getTitle());
if (milestone.getId() == null || milestone.getId().equals(0l)) {
dao.insert(milestone);
} else {
dao.edit(milestone);
}