use of com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView in project midpoint by Evolveum.
the class ContainerableListPanel method getObjectCollectionView.
protected CompiledObjectCollectionView getObjectCollectionView() {
CompiledObjectCollectionView containerPanelCollectionView = getCompiledCollectionViewFromPanelConfiguration();
if (containerPanelCollectionView != null) {
return containerPanelCollectionView;
}
CompiledObjectCollectionView view = getWidgetCollectionView();
if (view != null) {
return view;
}
String collectionName = getCollectionNameParameterValue().toString();
return getPageBase().getCompiledGuiProfile().findObjectCollectionView(WebComponentUtil.containerClassToQName(getPageBase().getPrismContext(), getType()), collectionName);
}
use of com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView in project midpoint by Evolveum.
the class ContainerableListPanel method createSearchModel.
protected LoadableDetachableModel<Search<C>> createSearchModel() {
return new LoadableDetachableModel<>() {
private static final long serialVersionUID = 1L;
@Override
public Search<C> load() {
Search<C> newSearch = createSearch(getType());
Search<C> search = null;
PageStorage storage = getPageStorage();
String searchByName = getSearchByNameParameterValue();
if (storage != null && searchByName == null) {
// do NOT use storage when using name search (e.g. from dashboard)
search = storage.getSearch();
}
if (search == null || (!SearchBoxModeType.ADVANCED.equals(search.getSearchType()) && !search.getAllDefinitions().containsAll(newSearch.getAllDefinitions())) || search.isTypeChanged()) {
search = newSearch;
search.searchWasReload();
}
if (searchByName != null) {
if (SearchBoxModeType.FULLTEXT.equals(search.getSearchType())) {
search.setFullText(searchByName);
} else {
for (PropertySearchItem<String> item : search.getPropertyItems()) {
if (ItemPath.create(ObjectType.F_NAME).equivalent(item.getPath())) {
item.setValue(new SearchValue<>(searchByName));
}
}
}
}
if (isCollectionViewPanel()) {
CompiledObjectCollectionView view = getObjectCollectionView();
search.setCollectionSearchItem(new ObjectCollectionSearchItem(search, view));
search.setCollectionItemVisible(isCollectionViewPanelForWidget());
if (storage != null && view.getPaging() != null) {
ObjectPaging paging = ObjectQueryUtil.convertToObjectPaging(view.getPaging(), getPrismContext());
if (storage.getPaging() == null) {
storage.setPaging(paging);
}
if (getTableId() != null && paging.getMaxSize() != null && !getPageBase().getSessionStorage().getUserProfile().isExistPagingSize(getTableId())) {
getPageBase().getSessionStorage().getUserProfile().setPagingSize(getTableId(), paging.getMaxSize());
}
}
}
if (storage != null) {
storage.setSearch(search);
}
return search;
}
};
}
use of com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView in project midpoint by Evolveum.
the class ContainerableListPanel method createReportPerformed.
protected void createReportPerformed(AjaxRequestTarget target) {
PrismContext prismContext = getPageBase().getPrismContext();
PrismObjectDefinition<ReportType> def = prismContext.getSchemaRegistry().findObjectDefinitionByType(ReportType.COMPLEX_TYPE);
PrismObject<ReportType> obj;
try {
obj = def.instantiate();
} catch (SchemaException e) {
LOGGER.error("Couldn't instantiate new report", e);
getPageBase().error(getString("MainObjectListPanel.message.error.instantiateNewReport"));
target.add(getPageBase().getFeedbackPanel());
return;
}
ReportType report = obj.asObjectable();
ObjectCollectionReportEngineConfigurationType objectCollection = new ObjectCollectionReportEngineConfigurationType();
CompiledObjectCollectionView view = getObjectCollectionView();
CollectionRefSpecificationType collection = new CollectionRefSpecificationType();
objectCollection.setUseOnlyReportView(true);
if (view != null) {
objectCollection.setView(view.toGuiObjectListViewType());
if (view.getCollection() != null && view.getCollection().getCollectionRef() != null) {
if (!QNameUtil.match(view.getCollection().getCollectionRef().getType(), ArchetypeType.COMPLEX_TYPE)) {
collection.setBaseCollectionRef(view.getCollection());
} else {
OperationResult result = new OperationResult(MainObjectListPanel.class.getSimpleName() + "." + "evaluateExpressionsInFilter");
CollectionRefSpecificationType baseCollection = new CollectionRefSpecificationType();
try {
baseCollection.setFilter(getPageBase().getQueryConverter().createSearchFilterType(WebComponentUtil.evaluateExpressionsInFilter(view.getFilter(), result, getPageBase())));
collection.setBaseCollectionRef(baseCollection);
} catch (SchemaException e) {
LOGGER.error("Couldn't create filter for archetype");
getPageBase().error(getString("MainObjectListPanel.message.error.createArchetypeFilter"));
target.add(getPageBase().getFeedbackPanel());
}
}
}
} else {
objectCollection.setView(getDefaultView());
}
SearchFilterType searchFilter = null;
ObjectQuery query = getSearchModel().getObject().createObjectQuery(getPageBase());
if (query != null) {
ObjectFilter filter = query.getFilter();
try {
searchFilter = getPageBase().getPrismContext().getQueryConverter().createSearchFilterType(filter);
} catch (Exception e) {
LOGGER.error("Couldn't create filter from search panel", e);
getPageBase().error(getString("ExportingFilterTabPanel.message.error.serializeFilterFromSearch"));
}
}
if (searchFilter != null) {
collection.setFilter(searchFilter);
} else {
try {
SearchFilterType allFilter = prismContext.getQueryConverter().createSearchFilterType(prismContext.queryFactory().createAll());
collection.setFilter(allFilter);
} catch (SchemaException e) {
LOGGER.error("Couldn't create all filter", e);
getPageBase().error(getString("MainObjectListPanel.message.error.createAllFilter"));
target.add(getPageBase().getFeedbackPanel());
return;
}
}
objectCollection.setCollection(collection);
report.setObjectCollection(objectCollection);
report.getAssignment().add(ObjectTypeUtil.createAssignmentTo(SystemObjectsType.ARCHETYPE_COLLECTION_REPORT.value(), ObjectTypes.ARCHETYPE, prismContext));
report.getArchetypeRef().add(ObjectTypeUtil.createObjectRef(SystemObjectsType.ARCHETYPE_COLLECTION_REPORT.value(), ObjectTypes.ARCHETYPE));
PageReport pageReport = new PageReport(report.asPrismObject());
getPageBase().navigateToNext(pageReport);
}
use of com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView in project midpoint by Evolveum.
the class ContainerableListPanel method getAutoRefreshInterval.
protected int getAutoRefreshInterval() {
if (isCollectionViewPanel()) {
CompiledObjectCollectionView view = getObjectCollectionView();
if (view == null) {
return 0;
}
Integer autoRefreshInterval = view.getRefreshInterval();
return Objects.requireNonNullElse(autoRefreshInterval, 0);
}
return 0;
}
use of com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView in project midpoint by Evolveum.
the class ContainerableListPanel method getCompiledCollectionViewFromPanelConfiguration.
private CompiledObjectCollectionView getCompiledCollectionViewFromPanelConfiguration() {
if (compiledCollectionViewFromPanelConfiguration != null) {
return compiledCollectionViewFromPanelConfiguration;
}
if (config == null) {
return null;
}
GuiObjectListViewType listViewType = config.getListView();
if (listViewType == null) {
return null;
}
Task task = getPageBase().createSimpleTask("Compile collection");
OperationResult result = task.getResult();
try {
compiledCollectionViewFromPanelConfiguration = new CompiledObjectCollectionView();
getPageBase().getModelInteractionService().compileView(compiledCollectionViewFromPanelConfiguration, listViewType, task, result);
} catch (Throwable e) {
LOGGER.error("Cannot compile object collection view for panel configuration {}. Reason: {}", config, e.getMessage(), e);
result.recordFatalError("Cannot compile object collection view for panel configuration " + config + ". Reason: " + e.getMessage(), e);
getPageBase().showResult(result);
}
return compiledCollectionViewFromPanelConfiguration;
}
Aggregations