001/* 002 * (C) Copyright 2006-2007 Nuxeo SAS (http://nuxeo.com/) and contributors. 003 * 004 * All rights reserved. This program and the accompanying materials 005 * are made available under the terms of the GNU Lesser General Public License 006 * (LGPL) version 2.1 which accompanies this distribution, and is available at 007 * http://www.gnu.org/licenses/lgpl.html 008 * 009 * This library is distributed in the hope that it will be useful, 010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 012 * Lesser General Public License for more details. 013 * 014 * Contributors: 015 * Nuxeo - initial API and implementation 016 * 017 * $Id: JOOoConvertPluginImpl.java 18651 2007-05-13 20:28:53Z sfermigier $ 018 */ 019 020package org.nuxeo.ecm.platform.types; 021 022import java.util.Collection; 023import java.util.List; 024import java.util.Map; 025 026import org.nuxeo.ecm.core.api.DocumentModel; 027import org.nuxeo.runtime.service.TimestampedService; 028 029/** 030 * Service handling registered UI Types. 031 * 032 * @author <a href="mailto:troger@nuxeo.com">Thomas Roger</a> 033 */ 034public interface TypeManager extends TimestampedService { 035 036 /** 037 * Gets the super type names for the given type. 038 * 039 * @return an array of supertypes or an empty array if no supertype exists. null is returned if no such type exists 040 */ 041 String[] getSuperTypes(String typeName); 042 043 /** 044 * Returns all the registered {@code Type}s. 045 */ 046 Collection<Type> getTypes(); 047 048 /** 049 * Returns the {@code Type} instance for the given {@code typeName}. 050 */ 051 Type getType(String typeName); 052 053 /** 054 * Returns {@code true} if {@code typeName} is a registered Type, {@code false} otherwise. 055 */ 056 boolean hasType(String typeName); 057 058 Collection<Type> getAllowedSubTypes(String typeName); 059 060 /** 061 * Returns the allowed sub types of the given {@code typeName}, filtered by a local UI types configuration retrieved 062 * from the {@code currentDoc}, if any. 063 * 064 * @since 5.4.2 065 */ 066 Collection<Type> getAllowedSubTypes(String typeName, DocumentModel currentDoc); 067 068 /** 069 * Returns recursively all the allowed sub types from the given {@code typeName}. 070 * 071 * @since 5.4.2 072 */ 073 Collection<Type> findAllAllowedSubTypesFrom(String typeName); 074 075 /** 076 * Returns recursively all the allowed sub types from the given {@code typeName}, filtered by a local UI types 077 * configuration retrieved from the {@code currentDoc}, if any. 078 * 079 * @since 5.4.2 080 */ 081 Collection<Type> findAllAllowedSubTypesFrom(String typeName, DocumentModel currentDoc); 082 083 /** 084 * Returns the sub type of the given {@code typeName}, filtered by a local UI types configuration retrieved from the 085 * {@code currentDoc}, if any, and organized by type categories. 086 * 087 * @since 5.4.2 088 */ 089 Map<String, List<Type>> getTypeMapForDocumentType(String typeName, DocumentModel currentDoc); 090 091 /** 092 * Returns {@code true} if {@code typeName} is a sub type, allowed in creation mode, of {@code containerTypeName}, 093 * {@code false} otherwise. 094 * 095 * @since 5.4.2 096 */ 097 boolean canCreate(String typeName, String containerTypeName); 098 099 /** 100 * Returns {@code true} if {@code typeName} is a sub type, allowed in creation, of {@code containerTypeName}, 101 * {@code false} otherwise. 102 * <p> 103 * It takes care of a local UI types configuration retrieved from the {@code currentDoc} to filter the sub types of 104 * {@code typeName} before checking the creation mode. 105 * 106 * @since 5.4.2 107 */ 108 boolean canCreate(String typeName, String containerTypeName, DocumentModel currentDoc); 109 110 /** 111 * Returns {@code true} if {@code typeName} is an allowed sub type of {@code containerTypeName}, {@code false} 112 * otherwise. 113 * 114 * @since 5.4.2 115 */ 116 boolean isAllowedSubType(String typeName, String containerTypeName); 117 118 /** 119 * Returns {@code true} if {@code typeName} is an allowed sub type of {@code containerTypeName}, filtered by a local 120 * UI types configuration retrieved from the {@code currentDoc}, if any, {@code false} otherwise. 121 * 122 * @since 5.4.2 123 */ 124 boolean isAllowedSubType(String typeName, String containerTypeName, DocumentModel currentDoc); 125 126}