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;
}
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;
}
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);
}
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);
}
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);
}
Aggregations