use of com.evolveum.midpoint.web.component.util.TreeSelectableBean in project midpoint by Evolveum.
the class OrgTreeProvider method createObjectWrapper.
private TreeSelectableBean<OrgType> createObjectWrapper(TreeSelectableBean<OrgType> parent, PrismObject<OrgType> unit) {
if (unit == null) {
return null;
}
// todo relation [lazyman]
OrgType org = unit.asObjectable();
if (parent != null) {
org.getParentOrgRef().clear();
ObjectReferenceType parentOrgRef = new ObjectReferenceType();
parentOrgRef.asReferenceValue().setObject(parent.getValue().asPrismObject());
org.getParentOrgRef().add(parentOrgRef);
}
TreeSelectableBean<OrgType> orgDto = new TreeSelectableBean<>(org);
return orgDto;
}
use of com.evolveum.midpoint.web.component.util.TreeSelectableBean in project midpoint by Evolveum.
the class OrgTreeProvider method getChildren.
@Override
public Iterator<? extends TreeSelectableBean<OrgType>> getChildren(TreeSelectableBean<OrgType> node) {
LOGGER.debug("Getting children for {}", node.getValue());
String nodeOid = node.getValue().getOid();
List<TreeSelectableBean<OrgType>> children;
long currentTime = System.currentTimeMillis();
if (currentTime > lastFetchOperation + EXPIRATION_AFTER_LAST_FETCH_OPERATION) {
childrenCache.clear();
}
if (childrenCache.containsKey(nodeOid)) {
LOGGER.debug("Using cached children for {}", node.getValue());
children = childrenCache.get(nodeOid);
} else {
LOGGER.debug("Loading fresh children for {}", node.getValue());
OperationResult result = new OperationResult(LOAD_ORG_UNITS);
try {
ObjectQuery query = getPageBase().getPrismContext().queryFor(OrgType.class).isDirectChildOf(nodeOid).build();
ObjectFilter customFilter = getCustomFilter();
if (customFilter != null) {
query.addFilter(customFilter);
}
Task task = getPageBase().createSimpleTask(LOAD_ORG_UNITS);
ObjectPaging paging = createPaging(node);
query.setPaging(paging);
List<PrismObject<OrgType>> orgs = getModelService().searchObjects(OrgType.class, query, null, task, result);
LOGGER.debug("Found {} sub-orgs.", orgs.size());
children = new ArrayList<>();
for (PrismObject<OrgType> org : orgs) {
children.add(createObjectWrapper(node, org));
}
childrenCache.put(nodeOid, children);
} catch (CommonException | RuntimeException ex) {
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load children", ex);
result.recordFatalError(getPageBase().createStringResource("OrgTreeProvider.message.getChildren.fatalError").getString(), ex);
children = new ArrayList<>();
} finally {
result.computeStatus();
}
if (WebComponentUtil.showResultInPage(result)) {
getPageBase().showResult(result);
throw new RestartResponseException(PageOrgTree.class);
}
children.forEach(orgUnit -> {
getAvailableData().putIfAbsent(orgUnit.getValue().getOid(), orgUnit);
});
}
LOGGER.debug("Finished getting children.");
lastFetchOperation = System.currentTimeMillis();
return children.iterator();
}
use of com.evolveum.midpoint.web.component.util.TreeSelectableBean in project midpoint by Evolveum.
the class RoleCatalogTabPanel method initLeftSidePanel.
@Override
protected void initLeftSidePanel() {
if (StringUtils.isEmpty(getRoleCatalogStorage().getSelectedOid())) {
getRoleCatalogStorage().setSelectedOid(roleCatalogOid);
}
WebMarkupContainer treePanelContainer = new WebMarkupContainer(ID_TREE_PANEL_CONTAINER);
treePanelContainer.setOutputMarkupId(true);
add(treePanelContainer);
OrgTreePanel treePanel = new OrgTreePanel(ID_TREE_PANEL, Model.of(roleCatalogOid), false, getPageBase(), "AssignmentShoppingCartPanel.treeTitle") {
private static final long serialVersionUID = 1L;
@Override
protected void selectTreeItemPerformed(TreeSelectableBean<OrgType> selected, AjaxRequestTarget target) {
setSelected(selected);
refreshContentPannels();
RoleCatalogTabPanel.this.selectTreeItemPerformed(selected, target);
}
protected List<InlineMenuItem> createTreeMenu() {
return new ArrayList<>();
}
@Override
protected List<InlineMenuItem> createTreeChildrenMenu(TreeSelectableBean<OrgType> org) {
return new ArrayList<>();
}
@Override
public OrgTreeStateStorage getOrgTreeStateStorage() {
return getRoleCatalogStorage();
}
};
treePanel.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return isRootOrgExists();
}
});
treePanel.setOutputMarkupId(true);
treePanelContainer.add(treePanel);
}
Aggregations