use of com.evolveum.midpoint.ninja.util.FileReference in project midpoint by Evolveum.
the class CountRepositoryAction method execute.
@Override
public void execute() throws Exception {
RepositoryService repository = context.getRepository();
FileReference fileReference = options.getFilter();
if (fileReference != null && options.getFilter() == null) {
throw new NinjaException("Type must be defined");
}
List<ObjectTypes> types = NinjaUtils.getTypes(options.getType());
int total = 0;
OperationResult result = new OperationResult(OPERATION_COUNT);
for (ObjectTypes type : types) {
ObjectQuery query = NinjaUtils.createObjectQuery(options.getFilter(), context, type.getClassDefinition());
int count = repository.countObjects(type.getClassDefinition(), query, new ArrayList<>(), result);
if (count == 0 && options.getType() == null) {
continue;
}
log.info("{}:\t{}", type.name(), count);
total += count;
}
log.info("===\nTotal:\t{}", total);
}
Aggregations