protected List<String> computeAllowedTypes(DocumentModel currentDoc) { List<String> types = new ArrayList<String>(); DocumentModel parent = documentManager.getRootDocument(); DocumentRef parentRef = currentDoc.getParentRef(); if (parentRef != null && documentManager.hasPermission(parentRef, SecurityConstants.READ)) { parent = documentManager.getDocument(parentRef); } for (Type type : typeManager.findAllAllowedSubTypesFrom(currentDoc.getType(), parent)) { types.add(type.getId()); } return types; }
/** * Returns a List of type not selected for the domain given as parameter * * @param document the domain to configure * @return a List of type of document, not currently selected for the domain * @since 5.5 */ public List<Type> getNotSelectedTypes(DocumentModel document) { if (!document.hasFacet(UI_TYPES_CONFIGURATION_FACET)) { return Collections.emptyList(); } List<String> allowedTypes = getAllowedTypes(document); List<Type> notSelectedTypes = new ArrayList<Type>(typeManager.findAllAllowedSubTypesFrom(document.getType())); for (Iterator<Type> it = notSelectedTypes.iterator(); it.hasNext(); ) { Type type = it.next(); if (allowedTypes.contains(type.getId())) { it.remove(); } } Collections.sort(notSelectedTypes, new TypeLabelAlphabeticalOrder(messages)); return notSelectedTypes; }
@Override public int compare(Type type1, Type type2) { String label1 = messages.get(type1.getLabel()); String label2 = messages.get(type2.getLabel()); return label1.compareTo(label2); }
@Override public int compare(Type type1, Type type2) { return type1.getId().compareTo(type2.getId()); }