Created
April 8, 2018 11:06
-
-
Save rickx1/2872f170a9f93de4755cd64eb91fb919 to your computer and use it in GitHub Desktop.
Starts a background search
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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