use of com.evolveum.midpoint.prism.query.ObjectPaging in project midpoint by Evolveum.
the class AbstractLdapConnTest method test174SeachFirst222AccountsOffset20.
/**
* Blocksize is 100, so this gets more than two blocks.
* There is offset, so VLV should be used.
* No explicit sorting.
*/
@Test
public void test174SeachFirst222AccountsOffset20() throws Exception {
final String TEST_NAME = "test174SeachFirst222AccountsOffset20";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(getResourceOid(), getAccountObjectClass(), prismContext);
ObjectPaging paging = ObjectPaging.createPaging(20, 222);
query.setPaging(paging);
SearchResultList<PrismObject<ShadowType>> searchResultList = doSearch(TEST_NAME, query, 222, task, result);
assertConnectorOperationIncrement(1, 223);
assertConnectorSimulatedPagingSearchIncrement(0);
SearchResultMetadata metadata = searchResultList.getMetadata();
if (metadata != null) {
assertFalse(metadata.isPartialResults());
}
assertLdapConnectorInstances(1, 2);
}
use of com.evolveum.midpoint.prism.query.ObjectPaging in project midpoint by Evolveum.
the class ObjectDataProvider method internalIterator.
@Override
public Iterator<W> internalIterator(long first, long count) {
LOGGER.trace("begin::iterator() from {} count {}.", new Object[] { first, count });
for (W available : getAvailableData()) {
if (available instanceof SelectableBean) {
SelectableBean<T> selectableBean = (SelectableBean<T>) available;
if (selectableBean.isSelected() && selectableBean.getValue() != null) {
selected.add(selectableBean.getValue());
}
}
}
for (W available : getAvailableData()) {
if (available instanceof SelectableBean) {
SelectableBean<T> selectableBean = (SelectableBean<T>) available;
if (!selectableBean.isSelected()) {
if (selected.contains(selectableBean.getValue())) {
selected.remove(selectableBean.getValue());
}
}
}
}
getAvailableData().clear();
OperationResult result = new OperationResult(OPERATION_SEARCH_OBJECTS);
try {
ObjectPaging paging = createPaging(first, count);
Task task = getPage().createSimpleTask(OPERATION_SEARCH_OBJECTS);
ObjectQuery query = getQuery();
if (query == null) {
query = new ObjectQuery();
}
query.setPaging(paging);
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Query {} with {}", type.getSimpleName(), query.debugDump());
}
List<PrismObject<T>> list = getModel().searchObjects(type, query, options, task, result);
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Query {} resulted in {} objects", type.getSimpleName(), list.size());
}
for (PrismObject<T> object : list) {
getAvailableData().add(createDataObjectWrapper(object));
}
} catch (Exception ex) {
result.recordFatalError("Couldn't list objects.", ex);
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't list objects", ex);
} finally {
result.computeStatusIfUnknown();
}
if (!WebComponentUtil.isSuccessOrHandledError(result)) {
handleNotSuccessOrHandledErrorInIterator(result);
}
LOGGER.trace("end::iterator()");
return getAvailableData().iterator();
}
use of com.evolveum.midpoint.prism.query.ObjectPaging in project midpoint by Evolveum.
the class RepositoryObjectDataProvider method internalIterator.
@Override
public Iterator<DebugObjectItem> internalIterator(long first, long count) {
LOGGER.trace("begin::iterator() from {} count {}.", new Object[] { first, count });
getAvailableData().clear();
OperationResult result = new OperationResult(OPERATION_SEARCH_OBJECTS);
try {
ObjectPaging paging = createPaging(first, count);
ObjectQuery query = getQuery();
if (query == null) {
query = new ObjectQuery();
}
query.setPaging(paging);
//RAW and DEFAULT retrieve option selected
Collection<SelectorOptions<GetOperationOptions>> options = new ArrayList<SelectorOptions<GetOperationOptions>>();
GetOperationOptions opt = GetOperationOptions.createRaw();
opt.setRetrieve(RetrieveOption.DEFAULT);
options.add(SelectorOptions.create(ItemPath.EMPTY_PATH, opt));
List<PrismObject<? extends ObjectType>> list = getModel().searchObjects((Class) type, query, options, getPage().createSimpleTask(OPERATION_SEARCH_OBJECTS), result);
for (PrismObject<? extends ObjectType> object : list) {
getAvailableData().add(createItem(object, result));
}
} catch (Exception ex) {
result.recordFatalError("Couldn't list objects.", ex);
} finally {
result.computeStatusIfUnknown();
}
getPage().showResult(result, false);
LOGGER.trace("end::iterator()");
return getAvailableData().iterator();
}
use of com.evolveum.midpoint.prism.query.ObjectPaging in project midpoint by Evolveum.
the class ObjectListPanel method initProvider.
protected BaseSortableDataProvider<SelectableBean<O>> initProvider() {
Set<O> selectedObjectsSet = selectedObjects == null ? null : new HashSet<O>(selectedObjects);
SelectableBeanObjectDataProvider<O> provider = new SelectableBeanObjectDataProvider<O>(parentPage, type, selectedObjectsSet) {
private static final long serialVersionUID = 1L;
@Override
protected void saveProviderPaging(ObjectQuery query, ObjectPaging paging) {
String storageKey = getStorageKey();
if (StringUtils.isNotEmpty(storageKey)) {
PageStorage storage = getPageStorage(storageKey);
if (storage != null) {
storage.setPaging(paging);
}
}
}
@Override
public SelectableBean<O> createDataObjectWrapper(O obj) {
SelectableBean<O> bean = super.createDataObjectWrapper(obj);
List<InlineMenuItem> inlineMenu = createInlineMenu();
if (inlineMenu != null) {
bean.getMenuItems().addAll(inlineMenu);
}
return bean;
}
};
if (options == null) {
if (ResourceType.class.equals(type)) {
options = SelectorOptions.createCollection(GetOperationOptions.createNoFetch());
}
} else {
if (ResourceType.class.equals(type)) {
GetOperationOptions root = SelectorOptions.findRootOptions(options);
root.setNoFetch(Boolean.TRUE);
}
provider.setOptions(options);
}
provider.setQuery(getQuery());
return provider;
}
use of com.evolveum.midpoint.prism.query.ObjectPaging in project midpoint by Evolveum.
the class PageDebugList method initLayout.
private void initLayout() {
Form main = new Form(ID_MAIN_FORM);
add(main);
DebugSearchDto dto = searchModel.getObject();
Class type = dto.getType().getClassDefinition();
RepositoryObjectDataProvider provider = new RepositoryObjectDataProvider(this, type) {
@Override
protected void saveProviderPaging(ObjectQuery query, ObjectPaging paging) {
ConfigurationStorage storage = getSessionStorage().getConfiguration();
storage.setPaging(paging);
}
};
DebugSearchDto search = searchModel.getObject();
ObjectQuery query = search.getSearch().createObjectQuery(getPrismContext());
provider.setQuery(createQuery(query));
addOrReplaceTable(provider);
PageDebugDownloadBehaviour ajaxDownloadBehavior = new PageDebugDownloadBehaviour();
main.add(ajaxDownloadBehavior);
}
Aggregations