예제 #1
0
  /** {@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);
    }
  }
예제 #2
0
  /** {@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);
  }