Exemplo n.º 1
0
 /**
  * Submits new harvesting task for partial harvest.
  *
  * @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 submitted
  */
 public boolean submit(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 (ApprovalStatus.isPubliclyVisible(resource.getApprovalStatus().name())
       && resource.getSynchronizable()) {
     CommonCriteria criteria = new CommonCriteria();
     criteria.setMaxRecords(maxRecs);
     if (fromDate != null) {
       Calendar cal = Calendar.getInstance();
       cal.setTime(fromDate);
       cal.set(Calendar.HOUR_OF_DAY, 0);
       cal.set(Calendar.MINUTE, 0);
       cal.set(Calendar.SECOND, 0);
       cal.set(Calendar.MILLISECOND, 0);
       fromDate = cal.getTime();
     }
     criteria.setFromDate(fromDate);
     submitted =
         !isExecutingLocally(resource.getUuid())
             && (taskQueue != null ? taskQueue.add(context, resource, criteria) : false);
     LOGGER.log(
         Level.FINER,
         "[SYNCHRONIZER] Submitted resource: {0} ({1})",
         new Object[] {resource.getUuid(), resource.getName()});
   }
   return submitted;
 }
 /**
  * Approval status.
  *
  * @param status approval status
  */
 public void setApprovalStatus(String status) {
   getRepository().setApprovalStatus(ApprovalStatus.checkValue(status));
 }