How can User Defined Collection Topology data be deleted?
Run the groovy script below in the system to clear stale objects that are X days old.
Set the staleAge variable to the number of days after the value to purge data for
Set the typeName to the rule scope. Knowledgebase article 4289884 describes how to determine the rule scope for a User Defined Collection.
def typeName = "DBSS_Cust_UDCName";
def staleAge = 1;
def force = "force";
def dataSvc = server.get("DataService");
def topSvc = server.get("TopologyService");
def objects = server.get("QueryService").queryTopologyObjects(typeName);
println(objects);
def staleTime = System.currentTimeMillis() - (staleAge * 60 * 60 * 1000L);
def staleObjects = [];
objects.each({ if (it.lastUpdated.time < staleTime) staleObjects << it });
println(staleObjects);
def output = new StringBuilder();
output.append("Stale objects:\n");
for (obj in staleObjects) {
output.append(obj.longName).append('\t');
output.append(obj.lastUpdated).append('\t')
output.append('\n');
}
// Delete the objects if force is given
if (force=='force') {
def batchSize = 100;
def idx = 0;
while (idx < staleObjects.size()) {
def endPos = Math.min(idx + batchSize, staleObjects.size());
def batch = staleObjects.subList(idx, endPos);
topSvc.deleteObjects(new HashSet(batch));
idx = endPos;
}
output.append("\n*** Successfully deleted " + staleObjects.size() + " stale objects. ***");
} else {
output.append("\n*** No objects deleted (use force argument to actually delete objects) ***");
}
println(output);
return objects.size();
© ALL RIGHTS RESERVED. Feedback Conditions d’utilisation Confidentialité Cookie Preference Center