Search in sources :

Example 1 with FileReference

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);
}
Also used : NinjaException(com.evolveum.midpoint.ninja.impl.NinjaException) ObjectTypes(com.evolveum.midpoint.schema.constants.ObjectTypes) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) FileReference(com.evolveum.midpoint.ninja.util.FileReference) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) RepositoryService(com.evolveum.midpoint.repo.api.RepositoryService)

Aggregations

NinjaException (com.evolveum.midpoint.ninja.impl.NinjaException)1 FileReference (com.evolveum.midpoint.ninja.util.FileReference)1 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)1 RepositoryService (com.evolveum.midpoint.repo.api.RepositoryService)1 ObjectTypes (com.evolveum.midpoint.schema.constants.ObjectTypes)1 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)1