use of org.olat.resource.references.ReferenceInfos in project openolat by klemens.
the class ConfirmDeletePermanentlyController method doCompleteDelete.
private void doCompleteDelete(UserRequest ureq) {
List<ErrorList> errorList = new ArrayList<>();
boolean allOk = deleteEntries(ureq, rows, errorList);
if (allOk && deleteReferencesEl.isVisible() && deleteReferencesEl.isEnabled() && deleteReferencesEl.isOneSelected() && deleteReferencesEl.isSelected(0)) {
Map<Long, ReferenceInfos> referencesMap = new HashMap<>();
for (ReferenceInfos reference : references) {
referencesMap.put(reference.getEntry().getKey(), reference);
}
Collection<String> selectedKeys = referencesEl.getSelectedKeys();
List<RepositoryEntry> referencesToDelete = new ArrayList<>(selectedKeys.size());
for (String selectedRefKey : selectedKeys) {
Long key = new Long(selectedRefKey);
ReferenceInfos refInfos = referencesMap.get(key);
if (refInfos != null && refInfos.isOrphan() && refInfos.isOwner() && !refInfos.isManaged()) {
referencesToDelete.add(referencesMap.get(key).getEntry());
}
}
allOk &= deleteEntries(ureq, referencesToDelete, errorList);
}
if (allOk) {
showInfo("info.entry.deleted");
} else {
List<String> msgs = new ArrayList<>();
for (ErrorList error : errorList) {
if (StringHelper.containsNonWhitespace(error.getFirstError())) {
msgs.add(error.getFirstError());
}
}
if (msgs.size() == 1) {
getWindowControl().setWarning(msgs.get(0));
} else if (msgs.size() > 1) {
StringBuilder sb = new StringBuilder();
sb.append("<ul>");
for (String msg : msgs) {
sb.append("<li>").append(msg).append("</li>");
}
sb.append("</ul>");
getWindowControl().setWarning(sb.toString());
} else {
showWarning("info.could.not.delete.entry");
}
}
}
Aggregations