Skip to content

Instantly share code, notes, and snippets.

@rickx1
Created April 8, 2018 11:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rickx1/2872f170a9f93de4755cd64eb91fb919 to your computer and use it in GitHub Desktop.
Save rickx1/2872f170a9f93de4755cd64eb91fb919 to your computer and use it in GitHub Desktop.
Starts a background search
importClass(Packages.com.filenet.api.constants.RefreshMode);
importClass(Packages.com.filenet.api.constants.SweepMode);
importClass(Packages.com.filenet.api.core.Factory);
importClass(Packages.java.text.SimpleDateFormat);
importClass(Packages.java.util.Calendar);
importClass(Packages.java.util.TimeZone);
function getRequiredProperties(){
}
function onPolicySweep(sweepObject, SweepPolicy, SweepItems){
startBackgroundSearch("CmRptDocumentUsageByClass", sweepObject.getObjectStore() );
}
function onSweep(SweepObject, SweepItems){
}
function startBackgroundSearch(name, objectStore) {
var dateFormat = new SimpleDateFormat(" yyyy-MM-dd HH:mm:ss");
var backgroundSearch = Factory.CmBackgroundSearch.createInstance(objectStore, name);
var displayName = "Runnning" + name + dateFormat.format(new Date());
// backgroundSearch.getProperties().putValue("GFIUC_ClosureDate", getStartOfThisYear() )
backgroundSearch.set_DisplayName(displayName);
backgroundSearch.save(RefreshMode.NO_REFRESH);
}
function getStartOfThisYear() {
var calendar = Calendar.getInstance();
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
calendar.set(Calendar.DAY_OF_YEAR, 1);
calendar.setTimeZone(TimeZone.getTimeZone("UTC"));
return calendar.getTime();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment