Ejemplo n.º 1
0
 /**
  * Spans new, separate thread exclusively for the resource.
  *
  * @param context request context
  * @param resource resource to harvest
  * @param maxRecs maximum number of records to harvest (<code>null</code> for no maximum limit)
  * @param fromDate to harvest only from the specific date (<code>null</code> for no from date)
  * @return <code>true</code> if task has been sumbited
  */
 public boolean span(RequestContext context, HrRecord resource, Integer maxRecs, Date fromDate) {
   if (resource == null) throw new IllegalArgumentException("No resource to harvest provided.");
   // create instance of the task
   // add only if no similar task currently executing
   boolean submitted = false;
   if (resource.getApprovalStatus() == ApprovalStatus.approved && resource.getSynchronizable()) {
     CommonCriteria criteria = new CommonCriteria();
     criteria.setMaxRecords(maxRecs);
     criteria.setFromDate(fromDate);
     submitted =
         pool != null && taskQueue != null
             ? !pool.isExecuting(resource.getUuid())
                 && taskQueue.register(context, resource, criteria)
             : false;
     if (submitted) pool.span(resource, criteria);
     LOGGER.log(
         Level.FINER,
         "[SYNCHRONIZER] Submitted resource: {0} ({1})",
         new Object[] {resource.getUuid(), resource.getName()});
   }
   return submitted;
 }