Exemplo n.º 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);
    }
  }
Exemplo n.º 2
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;
  }
Exemplo n.º 3
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);
      }
    }
  }
Exemplo n.º 4
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);

  }
Exemplo n.º 5
0
  private URI createShortenedJobDetailUrl(final Job job) {
    final String jobUrl =
        this.serverSettings.getServerAddress()
            + ServerActions.JOB_DETAIL.getPath()
            + "?jobId="
            + job.getId();

    final URI tweetUri;

    try {
      tweetUri = new URI(jobUrl);
    } catch (URISyntaxException e) {
      throw new IllegalStateException("Cannot creat URI for " + jobUrl);
    }

    final URI jobDetailUrl = notificationService.shortenUrl(tweetUri.toString());

    return jobDetailUrl;
  }
Exemplo n.º 6
0
  /** {@inheritDoc} */
  @Override
  public void addJobAndSendToMailingList(final Job job) {
    final Job savedJob = this.addJob(job);

    final Map<String, Object> context = CollectionUtils.getHashMap();
    context.put("jobId", savedJob.getId());
    context.put("jobTitle", savedJob.getJobTitle());
    context.put("businessLocation", savedJob.getRegionOther());
    context.put("businessName", savedJob.getBusinessName());
    context.put("description", savedJob.getDescription());
    context.put("jobRestrictions", savedJob.getJobRestrictions());
    context.put("updateDate", savedJob.getUpdateDate());
    context.put("businessEmail", savedJob.getBusinessEmail());
    context.put("serverAddress", serverSettings.getServerAddress());

    notificationService.sendEmail(
        ((Configuration) this.getJRecruiterSetting("mail.jobposting.email")).getMessageText(),
        savedJob.getJobTitle(),
        context,
        "add-job");
    final String tweetMessage =
        "New Job: " + savedJob.getJobTitle() + " @ " + savedJob.getBusinessName();

    final URI uri = createShortenedJobDetailUrl(savedJob);
    //  notificationService.sendTweetToTwitter(tweetMessage + ": " + uri.toString());

  }