public static EntityPullRequest createEntity(PullRequest gitPullRequest, GenericDao dao) {
if (gitPullRequest == null) {
return null;
}
EntityPullRequest pull = getPullRequestByIdPull(gitPullRequest.getId(), dao);
if (pull == null) {
pull = new EntityPullRequest();
}
pull.setMineredAt(new Date());
pull.setMergeable(gitPullRequest.isMergeable());
pull.setMerged(gitPullRequest.isMerged());
pull.setClosedAt(gitPullRequest.getClosedAt());
pull.setMergedAt(gitPullRequest.getMergedAt());
pull.setUpdatedAt(gitPullRequest.getUpdatedAt());
pull.setCreatedAt(gitPullRequest.getCreatedAt());
pull.setIdPullRequest(gitPullRequest.getId());
pull.setAdditions(gitPullRequest.getAdditions());
pull.setChangedFiles(gitPullRequest.getChangedFiles());
pull.setCommentsCount(gitPullRequest.getComments());
pull.setCommitsCount(gitPullRequest.getCommits());
pull.setDeletions(gitPullRequest.getDeletions());
pull.setNumber(gitPullRequest.getNumber());
if (pull.getBase() == null) {
pull.setBase(PullRequestMakerServices.createEntity(gitPullRequest.getBase(), dao));
}
if (pull.getHead() == null) {
pull.setHead(PullRequestMakerServices.createEntity(gitPullRequest.getHead(), dao));
}
pull.setBody(gitPullRequest.getBody());
pull.setBodyHtml(gitPullRequest.getBodyHtml());
pull.setBodyText(gitPullRequest.getBodyText());
pull.setDiffUrl(gitPullRequest.getDiffUrl());
pull.setHtmlUrl(gitPullRequest.getHtmlUrl());
pull.setIssueUrl(gitPullRequest.getIssueUrl());
pull.setPatchUrl(gitPullRequest.getPatchUrl());
pull.setStatePullRequest(gitPullRequest.getState());
pull.setTitle(gitPullRequest.getTitle());
pull.setUrl(gitPullRequest.getUrl());
pull.setMergedBy(UserServices.createEntity(gitPullRequest.getMergedBy(), dao, false));
pull.setUser(UserServices.createEntity(gitPullRequest.getUser(), dao, false));
if (pull.getId() == null || pull.getId().equals(0l)) {
dao.insert(pull);
} else {
dao.edit(pull);
}