use of com.evolveum.midpoint.schema.GetOperationOptionsBuilder in project midpoint by Evolveum.
the class SelectableBeanContainerDataProvider method internalIterator.
@Override
public Iterator<SelectableBean<C>> internalIterator(long offset, long pageSize) {
LOGGER.trace("begin::iterator() offset {} pageSize {}.", offset, pageSize);
preprocessSelectedData();
OperationResult result = new OperationResult(OPERATION_SEARCH_OBJECTS);
try {
ObjectPaging paging = createPaging(offset, pageSize);
Task task = getPageBase().createSimpleTask(OPERATION_SEARCH_OBJECTS);
ObjectQuery query = getQuery();
if (query == null) {
if (emptyListOnNullQuery) {
return Collections.emptyIterator();
}
query = getPrismContext().queryFactory().createQuery();
}
query.setPaging(paging);
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Query {} with {}", getType().getSimpleName(), query.debugDump());
}
Collection<SelectorOptions<GetOperationOptions>> options = getOptions();
if (ResourceType.class.equals(getType()) && (options == null || options.isEmpty())) {
options = SelectorOptions.createCollection(GetOperationOptions.createNoFetch());
}
GetOperationOptionsBuilder optionsBuilder = getOperationOptionsBuilder(options);
if (export) {
// TODO also for other classes
if (ShadowType.class.equals(getType())) {
optionsBuilder = optionsBuilder.definitionProcessing(ONLY_IF_EXISTS).item(ShadowType.F_FETCH_RESULT).definitionProcessing(FULL).item(ShadowType.F_AUXILIARY_OBJECT_CLASS).definitionProcessing(FULL);
}
}
optionsBuilder.mergeFrom(getDistinctRelatedOptions());
getAvailableData().addAll(createDataObjectWrappers(getType(), query, optionsBuilder.build(), task, result));
} catch (Exception ex) {
result.recordFatalError(getPageBase().createStringResource("ObjectDataProvider.message.listObjects.fatalError").getString(), ex);
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't list objects", ex);
return handleNotSuccessOrHandledErrorInIterator(result);
} finally {
result.computeStatusIfUnknown();
}
LOGGER.trace("end::iterator() {}", result);
return getAvailableData().iterator();
}
use of com.evolveum.midpoint.schema.GetOperationOptionsBuilder in project midpoint by Evolveum.
the class SearchProducerWorker method run.
@Override
public void run() {
Log log = context.getLog();
try {
GetOperationOptionsBuilder optionsBuilder = context.getSchemaService().getOperationOptionsBuilder();
if (options.isRaw()) {
optionsBuilder = optionsBuilder.raw();
}
optionsBuilder = NinjaUtils.addIncludeOptionsForExport(optionsBuilder, type.getClassDefinition());
ResultHandler<?> handler = (object, parentResult) -> {
try {
queue.put(object.asObjectable());
} catch (InterruptedException ex) {
log.error("Couldn't queue object {}, reason: {}", ex, object, ex.getMessage());
}
return true;
};
RepositoryService repository = context.getRepository();
repository.searchObjectsIterative(type.getClassDefinition(), query, handler, optionsBuilder.build(), true, operation.getResult());
} catch (SchemaException ex) {
log.error("Unexpected exception, reason: {}", ex, ex.getMessage());
} catch (NinjaException ex) {
log.error(ex.getMessage(), ex);
} finally {
markDone();
if (isWorkersDone()) {
if (!operation.isFinished()) {
operation.producerFinish();
}
}
}
}
use of com.evolveum.midpoint.schema.GetOperationOptionsBuilder in project midpoint by Evolveum.
the class ExportAuditProducerWorker method run.
@Override
public void run() {
Log log = context.getLog();
try {
GetOperationOptionsBuilder optionsBuilder = context.getSchemaService().getOperationOptionsBuilder();
optionsBuilder = NinjaUtils.addIncludeOptionsForExport(optionsBuilder, AuditEventRecordType.class);
AuditResultHandler handler = (object, parentResult) -> {
try {
queue.put(object);
} catch (InterruptedException ex) {
log.error("Couldn't queue object {}, reason: {}", ex, object, ex.getMessage());
}
return true;
};
AuditService auditService = context.getAuditService();
auditService.searchObjectsIterative(query, handler, optionsBuilder.build(), operation.getResult());
} catch (SchemaException ex) {
log.error("Unexpected exception, reason: {}", ex, ex.getMessage());
} catch (NinjaException ex) {
log.error(ex.getMessage(), ex);
} finally {
markDone();
if (isWorkersDone()) {
if (!operation.isFinished()) {
operation.producerFinish();
}
}
}
}
use of com.evolveum.midpoint.schema.GetOperationOptionsBuilder in project midpoint by Evolveum.
the class SqaleRepoLookupTableTest method test125LookupLanguagesGetByKeyContainingReturningNothing.
@Test
public void test125LookupLanguagesGetByKeyContainingReturningNothing() throws Exception {
given();
OperationResult result = createOperationResult();
when();
GetOperationOptionsBuilder optionsBuilder = SchemaService.get().getOperationOptionsBuilder().item(LookupTableType.F_ROW).retrieveQuery().item(LookupTableRowType.F_KEY).contains("xyz").end();
PrismObject<LookupTableType> lookup = repositoryService.getObject(LookupTableType.class, LOOKUP_LANGUAGES_OID, optionsBuilder.build(), result);
then();
result.computeStatus();
TestUtil.assertSuccess(result);
assertEquals("Wrong lang lookup name", LOOKUP_LANGUAGES_NAME, lookup.asObjectable().getName().getOrig());
PrismContainer<LookupTableRowType> tableContainer = lookup.findContainer(LookupTableType.F_ROW);
assertTrue("Unexpected content in tableContainer", tableContainer == null || tableContainer.size() == 0);
}
use of com.evolveum.midpoint.schema.GetOperationOptionsBuilder in project midpoint by Evolveum.
the class SqaleRepoLookupTableTest method test133LookupLanguagesGetByValueContainingWithPaging.
@Test
public void test133LookupLanguagesGetByValueContainingWithPaging() throws Exception {
given();
OperationResult result = createOperationResult();
when();
GetOperationOptionsBuilder optionsBuilder = SchemaService.get().getOperationOptionsBuilder().item(LookupTableType.F_ROW).retrieveQuery().item(LookupTableRowType.F_VALUE).contains("n").offset(0).maxSize(1).desc(// using sorting key other than the one used in search
LookupTableRowType.F_LABEL).end();
PrismObject<LookupTableType> lookup = repositoryService.getObject(LookupTableType.class, LOOKUP_LANGUAGES_OID, optionsBuilder.build(), result);
then();
result.computeStatus();
TestUtil.assertSuccess(result);
checkLookupResult(lookup, new String[] { "en_US", "en", "English (US)" });
}
Aggregations