use of com.evolveum.midpoint.web.page.admin.configuration.dto.AccountDetailsSearchDto in project midpoint by Evolveum.
the class PageAccounts method createObjectClassValidator.
private IValidator<String> createObjectClassValidator() {
return new IValidator<String>() {
@Override
public void validate(IValidatable<String> validatable) {
String value = validatable.getValue();
AccountDetailsSearchDto dto = searchModel.getObject();
List<QName> accountObjectClassList = dto.getObjectClassList();
List<String> accountObjectClassListString = new ArrayList<>();
for (QName objectClass : accountObjectClassList) {
accountObjectClassListString.add(objectClass.getLocalPart());
}
if (!accountObjectClassListString.contains(value)) {
error(createStringResource("PageAccounts.message.validationError", value).getString());
}
}
};
}
use of com.evolveum.midpoint.web.page.admin.configuration.dto.AccountDetailsSearchDto in project midpoint by Evolveum.
the class PageAccounts method loadResourceObjectClass.
private void loadResourceObjectClass() {
AccountDetailsSearchDto dto = searchModel.getObject();
PrismObject<ResourceType> resourcePrism;
OperationResult result = new OperationResult(OPERATION_GET_OBJECT_CLASS);
List<QName> accountObjectClassList = new ArrayList<>();
ResourceItemDto resourceDto = resourceModel.getObject();
String oid = resourceDto.getOid();
try {
resourcePrism = getModelService().getObject(ResourceType.class, oid, null, createSimpleTask(OPERATION_GET_INTENTS), result);
ResourceSchema schema = RefinedResourceSchemaImpl.getResourceSchema(resourcePrism, getPrismContext());
schema.getObjectClassDefinitions();
for (Definition def : schema.getDefinitions()) {
accountObjectClassList.add(def.getTypeName());
}
dto.setObjectClassList(accountObjectClassList);
} catch (Exception e) {
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load object class list from resource.", e);
result.recordFatalError("Couldn't load object class list from resource.: " + e.getMessage(), e);
showResult(result, false);
resourceModel.setObject(null);
new RestartResponseException(PageAccounts.this);
}
}
use of com.evolveum.midpoint.web.page.admin.configuration.dto.AccountDetailsSearchDto in project midpoint by Evolveum.
the class PageAccounts method clearSearchPerformed.
private void clearSearchPerformed(AjaxRequestTarget target) {
refreshSyncTotalsModels();
searchModel.setObject(new AccountDetailsSearchDto());
TablePanel panel = getAccountsTable();
DataTable table = panel.getDataTable();
ObjectDataProvider provider = (ObjectDataProvider) table.getDataProvider();
provider.setQuery(ObjectQuery.createObjectQuery(createResourceQueryFilter()));
ConfigurationStorage storage = getSessionStorage().getConfiguration();
storage.setAccountSearchDto(searchModel.getObject());
storage.setAccountDetailsPaging(null);
panel.setCurrentPage(storage.getAccountDetailsPaging());
target.add(getTotalsPanel());
target.add(getSearchPanel());
target.add(getAccountsContainer());
}
use of com.evolveum.midpoint.web.page.admin.configuration.dto.AccountDetailsSearchDto in project midpoint by Evolveum.
the class PageAccounts method initSearchForm.
private void initSearchForm(Form searchForm) {
BasicSearchPanel<AccountDetailsSearchDto> basicSearch = new BasicSearchPanel<AccountDetailsSearchDto>(ID_SEARCH_BASIC) {
@Override
protected IModel<String> createSearchTextModel() {
return new PropertyModel<>(searchModel, AccountDetailsSearchDto.F_SEARCH_TEXT);
}
@Override
protected void searchPerformed(AjaxRequestTarget target) {
PageAccounts.this.searchPerformed(target);
}
@Override
protected void clearSearchPerformed(AjaxRequestTarget target) {
PageAccounts.this.clearSearchPerformed(target);
}
};
basicSearch.setOutputMarkupId(true);
searchForm.add(basicSearch);
DropDownChoice failedOperationType = new DropDownChoice<>(ID_SEARCH_FAILED_OPERATION_TYPE, new PropertyModel<FailedOperationTypeType>(searchModel, AccountDetailsSearchDto.F_FAILED_OPERATION_TYPE), WebComponentUtil.createReadonlyModelFromEnum(FailedOperationTypeType.class), new EnumChoiceRenderer<FailedOperationTypeType>(this));
failedOperationType.add(new OnChangeAjaxBehavior() {
@Override
protected void onUpdate(AjaxRequestTarget target) {
searchPerformed(target);
}
});
failedOperationType.setOutputMarkupId(true);
failedOperationType.setNullValid(true);
searchForm.add(failedOperationType);
DropDownChoice kind = new DropDownChoice<>(ID_SEARCH_KIND, new PropertyModel<ShadowKindType>(searchModel, AccountDetailsSearchDto.F_KIND), WebComponentUtil.createReadonlyModelFromEnum(ShadowKindType.class), new EnumChoiceRenderer<ShadowKindType>(this));
kind.add(new OnChangeAjaxBehavior() {
@Override
protected void onUpdate(AjaxRequestTarget target) {
searchPerformed(target);
}
});
kind.setOutputMarkupId(true);
kind.setNullValid(true);
searchForm.add(kind);
DropDownChoice intent = new DropDownChoice<>(ID_SEARCH_INTENT, new PropertyModel<String>(searchModel, AccountDetailsSearchDto.F_INTENT), createIntentChoices(), new StringChoiceRenderer(null));
intent.setNullValid(true);
intent.add(new OnChangeAjaxBehavior() {
@Override
protected void onUpdate(AjaxRequestTarget target) {
searchPerformed(target);
}
});
intent.setOutputMarkupId(true);
searchForm.add(intent);
AutoCompleteTextField<String> objectClass = new AutoCompleteTextField<String>(ID_SEARCH_OBJECT_CLASS, new PropertyModel<String>(searchModel, AccountDetailsSearchDto.F_OBJECT_CLASS)) {
@Override
protected Iterator<String> getChoices(String input) {
if (Strings.isEmpty(input)) {
List<String> emptyList = Collections.emptyList();
return emptyList.iterator();
}
AccountDetailsSearchDto dto = searchModel.getObject();
List<QName> accountObjectClassList = dto.getObjectClassList();
List<String> choices = new ArrayList<>(AUTO_COMPLETE_LIST_SIZE);
for (QName s : accountObjectClassList) {
if (s.getLocalPart().toLowerCase().startsWith(input.toLowerCase())) {
choices.add(s.getLocalPart());
if (choices.size() == AUTO_COMPLETE_LIST_SIZE) {
break;
}
}
}
return choices.iterator();
}
};
objectClass.add(AttributeModifier.replace("placeholder", createStringResource("PageAccounts.accounts.objectClass")));
objectClass.setOutputMarkupId(true);
objectClass.add(createObjectClassValidator());
objectClass.add(new SearchFormEnterBehavior(basicSearch.getSearchButton()));
searchForm.add(objectClass);
}
use of com.evolveum.midpoint.web.page.admin.configuration.dto.AccountDetailsSearchDto in project midpoint by Evolveum.
the class PageAccounts method createObjectQuery.
private ObjectQuery createObjectQuery() {
AccountDetailsSearchDto dto = searchModel.getObject();
String searchText = dto.getText();
ShadowKindType kind = dto.getKind();
String intent = dto.getIntent();
String objectClass = dto.getObjectClass();
FailedOperationTypeType failedOperatonType = dto.getFailedOperationType();
S_AtomicFilterEntry q = QueryBuilder.queryFor(ShadowType.class, getPrismContext());
if (StringUtils.isNotEmpty(searchText)) {
PolyStringNormalizer normalizer = getPrismContext().getDefaultPolyStringNormalizer();
String normalized = normalizer.normalize(searchText);
q = q.item(ShadowType.F_NAME).contains(normalized).matchingNorm().and();
}
if (kind != null) {
q = q.item(ShadowType.F_KIND).eq(kind).and();
}
if (StringUtils.isNotEmpty(intent)) {
q = q.item(ShadowType.F_INTENT).eq(intent).and();
}
if (failedOperatonType != null) {
q = q.item(ShadowType.F_FAILED_OPERATION_TYPE).eq(failedOperatonType).and();
}
if (StringUtils.isNotEmpty(objectClass)) {
QName objClass = new QName(objectClass);
for (QName qn : dto.getObjectClassList()) {
if (objectClass.equals(qn.getLocalPart())) {
objClass = qn;
}
}
q = q.item(ShadowType.F_OBJECT_CLASS).eq(objClass).and();
}
return appendResourceQueryFilter(q);
}
Aggregations