use of org.c4sg.entity.Project in project c4sg-services by Code4SocialGood.
the class ProjectMapper method getProjectEntityFromCreateProjectDto.
public Project getProjectEntityFromCreateProjectDto(CreateProjectDTO createProjectDTO) {
getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
Project project = map(createProjectDTO, Project.class);
project.setOrganization(organizationDAO.findOne(createProjectDTO.getOrganizationId()));
return project;
}
use of org.c4sg.entity.Project in project c4sg-services by Code4SocialGood.
the class BadgeServiceImpl method findProjectsForHero.
@Override
public List<ProjectDTO> findProjectsForHero(Integer userId) {
// To display it in Heroes page
System.out.println("findProjectsForHero called...");
List<Badge> badges = badgeDAO.findByUser_IdOrderByCreatedTimeAsc(userId);
List<ProjectDTO> projectDtos = new ArrayList<ProjectDTO>();
List<Project> projects = new ArrayList<Project>();
for (Badge badge : badges) {
projects.add(badge.getProject());
System.out.println("findProjectsForHero called..." + badge.getProject().getName());
}
projectDtos = projectMapper.getDtosFromEntities(projects);
return projectDtos;
}
use of org.c4sg.entity.Project in project c4sg-services by Code4SocialGood.
the class BookmarkServiceImpl method createBookmark.
@Override
public BookmarkDTO createBookmark(Integer userId, Integer projectId) {
User user = userDAO.findById(userId);
requireNonNull(user, "Invalid User Id");
Project project = projectDAO.findById(projectId);
requireNonNull(project, "Invalid Project Id");
isBookmarked(userId, projectId);
Bookmark bookmark = new Bookmark();
bookmark.setUser(user);
bookmark.setProject(project);
bookmarkDAO.save(bookmark);
return bookmarkMapper.getBookmarkDtoFromEntity(bookmark);
}
use of org.c4sg.entity.Project in project c4sg-services by Code4SocialGood.
the class ProjectServiceImpl method save.
public void save(ProjectDTO projectDTO) {
Project project = projectMapper.getProjectEntityFromDto(projectDTO);
projectDAO.save(project);
}
use of org.c4sg.entity.Project in project c4sg-services by Code4SocialGood.
the class ProjectServiceImpl method createProject.
public ProjectDTO createProject(CreateProjectDTO createProjectDTO) {
Project project = projectDAO.findByNameAndOrganizationId(createProjectDTO.getName(), createProjectDTO.getOrganizationId());
if (project != null) {
System.out.println("Project already exist.");
} else {
project = projectDAO.save(projectMapper.getProjectEntityFromCreateProjectDto(createProjectDTO));
// Updates projectUpdateTime for the organization
Organization localOrgan = project.getOrganization();
localOrgan.setProjectUpdatedTime(new Timestamp(Calendar.getInstance().getTime().getTime()));
organizationDAO.save(localOrgan);
}
return projectMapper.getProjectDtoFromEntity(project);
}
Aggregations