public static EntityRepository createEntity(Repository gitRepository, GenericDao dao, boolean primary) {
if (gitRepository == null) {
return null;
}
EntityRepository repo = getRepositoryByIdRepository(gitRepository.getId(), dao);
if (primary || repo == null) {
if (repo == null) {
repo = new EntityRepository();
}
repo.setParent(RepositoryServices.createEntity(gitRepository.getParent(), dao, false));
repo.setSource(RepositoryServices.createEntity(gitRepository.getSource(), dao, false));
repo.setMasterBranch(gitRepository.getMasterBranch());
}
repo.setMineredAt(new Date());
repo.setPrimaryMiner(primary);
repo.setFork(gitRepository.isFork());
repo.setHasDownloads(gitRepository.isHasDownloads());
repo.setHasIssues(gitRepository.isHasIssues());
repo.setHasWiki(gitRepository.isHasWiki());
repo.setIsPrivate(gitRepository.isPrivate());
repo.setCreatedAt(gitRepository.getCreatedAt());
repo.setPushedAt(gitRepository.getPushedAt());
repo.setUpdatedAt(gitRepository.getUpdatedAt());
repo.setIdRepository(gitRepository.getId());
repo.setSizeRepository(gitRepository.getSize());
repo.setCloneUrl(gitRepository.getCloneUrl());
repo.setDescription(gitRepository.getDescription());
repo.setHomepage(gitRepository.getHomepage());
repo.setGitUrl(gitRepository.getGitUrl());
repo.setHtmlUrl(gitRepository.getHtmlUrl());
repo.setLanguageRepository(gitRepository.getLanguage());
repo.setMirrorUrl(gitRepository.getMirrorUrl());
repo.setName(gitRepository.getName());
repo.setSshUrl(gitRepository.getSshUrl());
repo.setSvnUrl(gitRepository.getSvnUrl());
repo.setUrl(gitRepository.getUrl());
repo.setOwner(UserServices.createEntity(gitRepository.getOwner(), dao, false));
if (repo.getId() == null || repo.getId().equals(0l)) {
dao.insert(repo);
} else {
dao.edit(repo);
}