コード例 #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);
  }
コード例 #3
0
  /** {@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());
  }
コード例 #4
0
 /** {@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);
 }
コード例 #5
0
  /** {@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);
      }
    }
  }
コード例 #6
0
  /** {@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;
  }
コード例 #7
0
  /** {@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;
  }
コード例 #8
0
  /** {@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);
  }
コード例 #9
0
  /** {@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);

  }
コード例 #10
0
 /** {@inheritDoc} */
 @Override
 @Transactional(readOnly = true, propagation = Propagation.SUPPORTS)
 public List<Job> getJobs() {
   return jobDao.getAllJobs();
 }
コード例 #11
0
 /** {@inheritDoc} */
 @Override
 public void reindexSearch() {
   jobDao.reindexSearch();
 }
コード例 #12
0
 /** {@inheritDoc} */
 @Override
 @Transactional(readOnly = true, propagation = Propagation.SUPPORTS)
 public List<Job> searchByKeyword(final String keyword) {
   return jobDao.searchByKeyword(keyword);
 }
コード例 #13
0
 /* (non-Javadoc)
  * @see org.jrecruiter.service.JobService#getJobForUniversalId(java.lang.Long)
  */
 @Override
 public Job getJobForUniversalId(final String universalId) {
   return jobDao.getForUniversalId(universalId);
 }
コード例 #14
0
 /** {@inheritDoc} */
 @Override
 @Transactional(readOnly = true, propagation = Propagation.SUPPORTS)
 public Job getJobForId(final Long jobId) {
   return jobDao.get(jobId);
 }
コード例 #15
0
 /** {@inheritDoc} */
 @Override
 @Transactional(readOnly = true, propagation = Propagation.SUPPORTS)
 public Long getJobsCount() {
   return jobDao.getJobsCount();
 }