Search in sources :

Example 1 with Application

use of org.c4sg.entity.Application in project c4sg-services by Code4SocialGood.

the class ApplicationMapper method getApplicationProjectDtosFromEntities.

public List<ApplicationProjectDTO> getApplicationProjectDtosFromEntities(List<Application> applications) {
    List<ApplicationProjectDTO> applicationList = new ArrayList<ApplicationProjectDTO>();
    ApplicationProjectDTO applicationProject;
    for (Application application : applications) {
        applicationProject = new ApplicationProjectDTO();
        applicationProject.setUserId(application.getUser().getId());
        applicationProject.setProjectId(application.getProject().getId());
        applicationProject.setProjectName(application.getProject().getName());
        applicationProject.setApplicationStatus(application.getStatus());
        applicationProject.setComment(application.getComment());
        applicationProject.setResumeFlag(stringToBooleanConverter.convert(application.getResumeFlag()));
        applicationProject.setAppliedTime(application.getAppliedTime());
        applicationProject.setAcceptedTime(application.getAcceptedTime());
        applicationProject.setDeclinedTime(application.getDeclinedTime());
        applicationList.add(applicationProject);
    }
    return applicationList;
}
Also used : ApplicationProjectDTO(org.c4sg.dto.ApplicationProjectDTO) ArrayList(java.util.ArrayList) Application(org.c4sg.entity.Application)

Example 2 with Application

use of org.c4sg.entity.Application in project c4sg-services by Code4SocialGood.

the class ApplicationMapper method getApplicationDtosFromEntities.

public List<ApplicationDTO> getApplicationDtosFromEntities(List<Application> applications) {
    List<ApplicationDTO> applicationList = new ArrayList<ApplicationDTO>();
    Iterator<Application> applicationIter = applications.iterator();
    while (applicationIter.hasNext()) {
        Application application = applicationIter.next();
        applicationList.add(getApplicationDtoFromEntity(application));
    }
    return applicationList;
}
Also used : ApplicationDTO(org.c4sg.dto.ApplicationDTO) ArrayList(java.util.ArrayList) Application(org.c4sg.entity.Application)

Example 3 with Application

use of org.c4sg.entity.Application in project c4sg-services by Code4SocialGood.

the class ApplicationServiceImpl method updateApplication.

@Override
public ApplicationDTO updateApplication(ApplicationDTO applicationDto) {
    validateApplication(applicationDto);
    Application application = applicationDAO.findByUser_IdAndProject_Id(applicationDto.getUserId(), applicationDto.getProjectId());
    isApplied(application, applicationDto.getStatus());
    application.setStatus(applicationDto.getStatus());
    application.setComment(applicationDto.getComment());
    application.setResumeFlag(booleanToStringConverter.convert(applicationDto.getResumeFlag()));
    if (applicationDto.getStatus().equals("C")) {
        application.setAcceptedTime(new Timestamp(Calendar.getInstance().getTime().getTime()));
    } else if (applicationDto.getStatus().equals("D")) {
        application.setDeclinedTime(new Timestamp(Calendar.getInstance().getTime().getTime()));
    }
    application.setUpdatedTime(new Timestamp(Calendar.getInstance().getTime().getTime()));
    applicationDAO.save(application);
    User user = userDAO.findById(applicationDto.getUserId());
    Project project = projectDAO.findById(applicationDto.getProjectId());
    sendEmail(user, project, application);
    return applicationMapper.getApplicationDtoFromEntity(application);
}
Also used : Project(org.c4sg.entity.Project) User(org.c4sg.entity.User) Application(org.c4sg.entity.Application) Timestamp(java.sql.Timestamp)

Example 4 with Application

use of org.c4sg.entity.Application in project c4sg-services by Code4SocialGood.

the class ApplicationServiceImpl method getApplicationsByOrgAndByApplicant.

@Override
public List<ApplicationProjectDTO> getApplicationsByOrgAndByApplicant(Integer userId, Integer nonProfitUserId, String status) {
    // get org id from nonProfitUserId;
    List<UserOrganization> userOrganizations = userOrganizationDAO.findByUserId(nonProfitUserId);
    // get projects for the org
    List<Project> projects = new ArrayList<Project>();
    for (UserOrganization userOrganization : userOrganizations) {
        // list gets overwritten here becasue there should be only one organization for one nonprofit user
        projects = projectDAO.getProjectsByOrganization(userOrganization.getOrganization().getId(), "A");
    }
    // get applications by project and userId
    List<Application> applications = new ArrayList<Application>();
    Application application;
    for (Project project : projects) {
        application = new Application();
        application = applicationDAO.findByUser_IdAndProject_IdAndStatus(userId, project.getId(), status);
        if (java.util.Objects.nonNull(application)) {
            applications.add(application);
        }
    }
    return applicationMapper.getApplicationProjectDtosFromEntities(applications);
}
Also used : Project(org.c4sg.entity.Project) UserOrganization(org.c4sg.entity.UserOrganization) ArrayList(java.util.ArrayList) Application(org.c4sg.entity.Application)

Example 5 with Application

use of org.c4sg.entity.Application in project c4sg-services by Code4SocialGood.

the class ApplicationServiceImpl method createApplication.

@Override
public ApplicationDTO createApplication(ApplicationDTO applicationDto) {
    validateApplication(applicationDto);
    User user = userDAO.findById(applicationDto.getUserId());
    Project project = projectDAO.findById(applicationDto.getProjectId());
    Application application = applicationDAO.findByUser_IdAndProject_Id(applicationDto.getUserId(), applicationDto.getProjectId());
    if (java.util.Objects.nonNull(application)) {
        isApplied(application, applicationDto.getStatus());
    }
    application = new Application();
    application.setUser(user);
    application.setProject(project);
    application.setStatus(applicationDto.getStatus());
    application.setComment(applicationDto.getComment());
    application.setResumeFlag(booleanToStringConverter.convert(applicationDto.getResumeFlag()));
    application.setAppliedTime(applicationDto.getAppliedTime());
    application.setCreatedTime(new Timestamp(Calendar.getInstance().getTime().getTime()));
    // application.setAppliedTime(new Timestamp(Calendar.getInstance().getTime().getTime()));
    applicationDAO.save(application);
    sendEmail(user, project, application);
    return applicationMapper.getApplicationDtoFromEntity(application);
}
Also used : Project(org.c4sg.entity.Project) User(org.c4sg.entity.User) Application(org.c4sg.entity.Application) Timestamp(java.sql.Timestamp)

Aggregations

Application (org.c4sg.entity.Application)7 ArrayList (java.util.ArrayList)5 Project (org.c4sg.entity.Project)3 Timestamp (java.sql.Timestamp)2 ApplicationProjectDTO (org.c4sg.dto.ApplicationProjectDTO)2 User (org.c4sg.entity.User)2 ApplicantDTO (org.c4sg.dto.ApplicantDTO)1 ApplicationDTO (org.c4sg.dto.ApplicationDTO)1 ProjectDTO (org.c4sg.dto.ProjectDTO)1 UserOrganization (org.c4sg.entity.UserOrganization)1