use of com.evolveum.midpoint.web.page.admin.configuration.dto.ResourceItemDto in project midpoint by Evolveum.
the class PageAccounts method initLayout.
private void initLayout() {
Form form = new Form(ID_MAIN_FORM);
form.setOutputMarkupId(true);
add(form);
Form accForm = new Form(ID_FORM_ACCOUNT);
accForm.setOutputMarkupId(true);
add(accForm);
Form searchForm = new Form(ID_SEARCH_FORM);
initSearchForm(searchForm);
searchForm.setOutputMarkupPlaceholderTag(true);
searchForm.setOutputMarkupId(true);
searchForm.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return resourceModel.getObject() != null;
}
});
add(searchForm);
DropDownChoice<ResourceItemDto> resources = new DropDownChoice<>(ID_RESOURCES, resourceModel, resourcesModel, new ChoiceableChoiceRenderer<ResourceItemDto>());
form.add(resources);
initLinks(form, accForm);
initTotals(form);
final AjaxDownloadBehaviorFromFile ajaxDownloadBehavior = new AjaxDownloadBehaviorFromFile(true) {
@Override
protected File initFile() {
return downloadFile;
}
};
ajaxDownloadBehavior.setRemoveFile(false);
form.add(ajaxDownloadBehavior);
WebMarkupContainer filesContainer = new WebMarkupContainer(ID_FILES_CONTAINER);
filesContainer.setOutputMarkupId(true);
accForm.add(filesContainer);
ModalWindow resultPopup = createModalWindow(ID_RESULT_DIALOG, createStringResource("PageAccounts.result.popoup"), 1100, 560);
resultPopup.setContent(new AceEditorDialog(resultPopup.getContentId()));
add(resultPopup);
filesModel = createFilesModel();
ListView<String> files = new ListView<String>(ID_FILES, filesModel) {
@Override
protected void populateItem(final ListItem<String> item) {
AjaxLink file = new AjaxLink(ID_FILE) {
@Override
public void onClick(AjaxRequestTarget target) {
downloadPerformed(target, item.getModelObject(), ajaxDownloadBehavior);
}
};
file.add(new Label(ID_FILE_NAME, item.getModelObject()));
item.add(file);
}
};
files.setRenderBodyOnly(true);
filesContainer.add(files);
WebMarkupContainer accountsContainer = new WebMarkupContainer(ID_ACCOUNTS_CONTAINER);
accountsContainer.setOutputMarkupId(true);
accForm.add(accountsContainer);
ObjectDataProvider provider = new ObjectDataProvider(this, ShadowType.class);
provider.setOptions(SelectorOptions.createCollection(GetOperationOptions.createRaw()));
provider.setQuery(ObjectQuery.createObjectQuery(createResourceQueryFilter()));
TablePanel accounts = new TablePanel(ID_ACCOUNTS, provider, createAccountsColumns(), UserProfileStorage.TableId.CONF_PAGE_ACCOUNTS, getItemsPerPage(UserProfileStorage.TableId.CONF_PAGE_ACCOUNTS));
accounts.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return resourceModel.getObject() != null;
}
});
accounts.setItemsPerPage(50);
accountsContainer.add(accounts);
}
use of com.evolveum.midpoint.web.page.admin.configuration.dto.ResourceItemDto in project midpoint by Evolveum.
the class PageAccounts method createIntentChoices.
private IModel<List<String>> createIntentChoices() {
return new AbstractReadOnlyModel<List<String>>() {
@Override
public List<String> getObject() {
List<String> intentList = new ArrayList<>();
ResourceItemDto dto = resourceModel.getObject();
PrismObject<ResourceType> resourcePrism;
if (dto == null) {
return intentList;
}
String oid = dto.getOid();
OperationResult result = new OperationResult(OPERATION_GET_INTENTS);
try {
resourcePrism = getModelService().getObject(ResourceType.class, oid, null, createSimpleTask(OPERATION_GET_INTENTS), result);
ResourceType resource = resourcePrism.asObjectable();
SchemaHandlingType schemaHandling = resource.getSchemaHandling();
for (ResourceObjectTypeDefinitionType r : schemaHandling.getObjectType()) {
intentList.add(r.getIntent());
}
} catch (Exception e) {
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load intents from resource.", e);
error("Couldn't load intents from resource.");
return null;
}
return intentList;
}
};
}
use of com.evolveum.midpoint.web.page.admin.configuration.dto.ResourceItemDto 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.ResourceItemDto in project midpoint by Evolveum.
the class ReconciliationPopupPanel method createModel.
private IModel<ResourceItemDto> createModel(final List<ResourceItemDto> resources) {
return new IModel<ResourceItemDto>() {
@Override
public ResourceItemDto getObject() {
ReconciliationReportDto dto = getModel().getObject();
if (dto.getResourceOid() == null) {
return null;
}
for (ResourceItemDto item : resources) {
if (StringUtils.equals(item.getOid(), dto.getResourceOid())) {
return item;
}
}
return null;
}
@Override
public void setObject(ResourceItemDto object) {
ReconciliationReportDto dto = getModel().getObject();
dto.setResourceOid(object != null ? object.getOid() : null);
dto.setResourceName(object != null ? object.getName() : null);
}
@Override
public void detach() {
}
};
}
use of com.evolveum.midpoint.web.page.admin.configuration.dto.ResourceItemDto in project midpoint by Evolveum.
the class PageAccounts method loadResources.
private List<ResourceItemDto> loadResources() {
List<ResourceItemDto> resources = new ArrayList<>();
OperationResult result = new OperationResult(OPERATION_LOAD_RESOURCES);
try {
List<PrismObject<ResourceType>> objects = getModelService().searchObjects(ResourceType.class, null, SelectorOptions.createCollection(GetOperationOptions.createNoFetch()), createSimpleTask(OPERATION_LOAD_RESOURCES), result);
if (objects != null) {
for (PrismObject<ResourceType> object : objects) {
StringBuilder nameBuilder = new StringBuilder(WebComponentUtil.getName(object));
PrismProperty<OperationResultType> fetchResult = object.findProperty(ResourceType.F_FETCH_RESULT);
if (fetchResult != null) {
nameBuilder.append(" (");
nameBuilder.append(fetchResult.getRealValue().getStatus());
nameBuilder.append(")");
}
resources.add(new ResourceItemDto(object.getOid(), nameBuilder.toString()));
}
}
result.recordSuccess();
} catch (Exception ex) {
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load resources", ex);
result.recordFatalError("Couldn't load resources, reason: " + ex.getMessage(), ex);
} finally {
if (result.isUnknown()) {
result.computeStatus();
}
}
Collections.sort(resources);
if (!WebComponentUtil.isSuccessOrHandledError(result)) {
showResult(result, false);
throw new RestartResponseException(PageDashboard.class);
}
return resources;
}
Aggregations