/** {@inheritDoc} */ @Override public void removeOldJobs(final @NotNull Integer days) { final Calendar cal = CalendarUtils.getCalendarWithoutTime(); cal.add(Calendar.DAY_OF_YEAR, days.intValue() * -1); final List<Job> jobs = jobDao.getJobsByUpdateDate(cal); LOGGER.info("Found " + jobs.size() + " jobs that are eligible for removal."); if (!jobs.isEmpty()) { final long jobsCount = jobDao.getJobsCount(); for (final Job job : jobs) { jobDao.remove(job.getId()); } JobCountPerDay jobCountPerDay = jobCountPerDayDao.getByDate(new Date()); if (jobCountPerDay == null) { jobCountPerDay = new JobCountPerDay(); jobCountPerDay.setJobDate(new Date()); } jobCountPerDay.setNumberOfJobsDeleted(Long.valueOf(jobs.size())); jobCountPerDay.setNumberOfJobsPosted(Long.valueOf(0)); jobCountPerDay.setTotalNumberOfJobs(jobsCount - jobs.size()); jobCountPerDay.setAutomaticallyCleaned(Boolean.TRUE); jobCountPerDayDao.save(jobCountPerDay); } }
/** {@inheritDoc} */ @Override public void deleteJobForId(final Long jobId) { jobDao.remove(jobId); JobCountPerDay jobCountPerDay = jobCountPerDayDao.getByDate(new Date()); if (jobCountPerDay == null) { jobCountPerDay = new JobCountPerDay(); jobCountPerDay.setJobDate(new Date()); } jobCountPerDay.setNumberOfJobsDeleted(Long.valueOf(1)); jobCountPerDay.setNumberOfJobsPosted(Long.valueOf(0)); jobCountPerDay.setTotalNumberOfJobs(jobDao.getJobsCount()); jobCountPerDayDao.save(jobCountPerDay); }
/** {@inheritDoc} */ @Override @Transactional(readOnly = true, propagation = Propagation.SUPPORTS) public List<Job> getUsersJobsForStatistics(final String username) { final User user = userDao.getUser(username); if (user == null) { throw new IllegalArgumentException("No user found for username " + username); } if (AcegiUtil.hasRole(Roles.ADMIN.name())) { return jobDao.getAll(); } return jobDao.getAllUserJobsForStatistics(user.getId()); }
/** {@inheritDoc} */ @Override @Transactional(readOnly = true, propagation = Propagation.SUPPORTS) public List<Job> getJobs( Integer pageSize, Integer pageNumber, Map<String, String> sortOrders, Map<String, String> jobFilters) { return jobDao.getJobs(pageSize, pageNumber, sortOrders, jobFilters); }
/** {@inheritDoc} */ public void saveJobStatistics(Job job) { if (job.getId() == null) { JobCountPerDay jobCountPerDay = jobCountPerDayDao.getByDate(job.getRegistrationDate()); if (jobCountPerDay == null) { jobCountPerDay = new JobCountPerDay(); jobCountPerDay.setJobDate(job.getRegistrationDate()); jobCountPerDay.setNumberOfJobsDeleted(Long.valueOf(0)); jobCountPerDay.setNumberOfJobsPosted(Long.valueOf(1)); jobCountPerDay.setTotalNumberOfJobs(jobDao.getJobsCount()); jobCountPerDayDao.save(jobCountPerDay); } else { jobCountPerDay.setNumberOfJobsPosted(jobCountPerDay.getNumberOfJobsPosted() + 1); jobCountPerDay.setTotalNumberOfJobs(jobDao.getJobsCount() + 1); jobCountPerDayDao.save(jobCountPerDay); } } }
/** {@inheritDoc} */ @Override @Transactional(readOnly = true, propagation = Propagation.SUPPORTS) public List<Job> getUsersJobs(final String username) { List<Job> jobs = null; User user = userDao.getUser(username); boolean administrator = false; if (AcegiUtil.containsRole(user.getAuthorities(), Roles.ADMIN.name())) { administrator = true; } if (administrator) { jobs = jobDao.getAllJobs(); } else { jobs = jobDao.getAllUserJobs(username); } return jobs; }
/** {@inheritDoc} */ @Override public Job addJob(final Job job) { if (job.getStatistic() == null) { Statistic statistic = new Statistic(job.getId(), Long.valueOf(0), null, Long.valueOf(0)); statistic.setJob(job); job.setStatistic(statistic); } final Job savedJob = jobDao.save(job); saveJobStatistics(job); return savedJob; }
/** {@inheritDoc} */ @Override @Transactional(readOnly = true, propagation = Propagation.SUPPORTS) public List<Job> getUsersJobsForStatistics(String username, Integer maxResult) { final User user = userDao.getUser(username); if (user == null) { throw new IllegalArgumentException("No user found for username " + username); } boolean administrator = false; if (AcegiUtil.hasRole(Roles.ADMIN.name())) { administrator = true; } return jobDao.getUsersJobsForStatistics(user.getId(), maxResult, administrator); }
/** {@inheritDoc} */ @Override public void updateJob(final Job job) { if (job.getStatistic() == null) { Statistic statistic = new Statistic(job.getId(), Long.valueOf(0), null, Long.valueOf(0)); statistic.setJob(job); job.setStatistic(statistic); } final Job savedJob = jobDao.save(job); saveJobStatistics(savedJob); String tweetMessage = "Job Update: " + job.getJobTitle() + " @ " + job.getBusinessName(); final URI uri = createShortenedJobDetailUrl(job); tweetMessage = tweetMessage + ": " + uri.toString(); // notificationService.sendTweetToTwitter(tweetMessage); }
/** {@inheritDoc} */ @Override @Transactional(readOnly = true, propagation = Propagation.SUPPORTS) public List<Job> getJobs() { return jobDao.getAllJobs(); }
/** {@inheritDoc} */ @Override public void reindexSearch() { jobDao.reindexSearch(); }
/** {@inheritDoc} */ @Override @Transactional(readOnly = true, propagation = Propagation.SUPPORTS) public List<Job> searchByKeyword(final String keyword) { return jobDao.searchByKeyword(keyword); }
/* (non-Javadoc) * @see org.jrecruiter.service.JobService#getJobForUniversalId(java.lang.Long) */ @Override public Job getJobForUniversalId(final String universalId) { return jobDao.getForUniversalId(universalId); }
/** {@inheritDoc} */ @Override @Transactional(readOnly = true, propagation = Propagation.SUPPORTS) public Job getJobForId(final Long jobId) { return jobDao.get(jobId); }
/** {@inheritDoc} */ @Override @Transactional(readOnly = true, propagation = Propagation.SUPPORTS) public Long getJobsCount() { return jobDao.getJobsCount(); }