/** * 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; }
/** * 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; }
/** * Gets repository name. * * @return name */ public String getName() { return _harvestRepository.getName(); }