Search in sources :

Example 1 with Project

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;
}
Also used : UserProject(org.c4sg.entity.UserProject) Project(org.c4sg.entity.Project)

Example 2 with 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;
}
Also used : ProjectDTO(org.c4sg.dto.ProjectDTO) Project(org.c4sg.entity.Project) ArrayList(java.util.ArrayList) Badge(org.c4sg.entity.Badge)

Example 3 with Project

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);
}
Also used : Project(org.c4sg.entity.Project) User(org.c4sg.entity.User) Bookmark(org.c4sg.entity.Bookmark)

Example 4 with Project

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);
}
Also used : UserProject(org.c4sg.entity.UserProject) Project(org.c4sg.entity.Project)

Example 5 with 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);
}
Also used : UserProject(org.c4sg.entity.UserProject) Project(org.c4sg.entity.Project) Organization(org.c4sg.entity.Organization) Timestamp(java.sql.Timestamp)

Aggregations

Project (org.c4sg.entity.Project)18 User (org.c4sg.entity.User)9 UserProject (org.c4sg.entity.UserProject)8 HashMap (java.util.HashMap)4 Timestamp (java.sql.Timestamp)3 ArrayList (java.util.ArrayList)3 Application (org.c4sg.entity.Application)3 Organization (org.c4sg.entity.Organization)3 MimeMessage (javax.mail.internet.MimeMessage)2 Badge (org.c4sg.entity.Badge)2 BadRequestException (org.c4sg.exception.BadRequestException)2 Test (org.junit.Test)2 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)2 Map (java.util.Map)1 ProjectDTO (org.c4sg.dto.ProjectDTO)1 Bookmark (org.c4sg.entity.Bookmark)1 ProjectSkill (org.c4sg.entity.ProjectSkill)1 Skill (org.c4sg.entity.Skill)1 UserOrganization (org.c4sg.entity.UserOrganization)1 UserSkill (org.c4sg.entity.UserSkill)1