001/*
002 * (C) Copyright 2006-2007 Nuxeo SA (http://nuxeo.com/) and others.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 *
016 * Contributors:
017 *     Nuxeo - initial API and implementation
018 *
019 * $Id: JOOoConvertPluginImpl.java 18651 2007-05-13 20:28:53Z sfermigier $
020 */
021
022package org.nuxeo.ecm.platform.types;
023
024import java.util.Collection;
025import java.util.List;
026import java.util.Map;
027
028import org.nuxeo.ecm.core.api.DocumentModel;
029import org.nuxeo.runtime.service.TimestampedService;
030
031/**
032 * Service handling registered UI Types.
033 *
034 * @author <a href="mailto:troger@nuxeo.com">Thomas Roger</a>
035 */
036public interface TypeManager extends TimestampedService {
037
038    /**
039     * Gets the super type names for the given type.
040     *
041     * @return an array of supertypes or an empty array if no supertype exists. null is returned if no such type exists
042     */
043    String[] getSuperTypes(String typeName);
044
045    /**
046     * Returns all the registered {@code Type}s.
047     */
048    Collection<Type> getTypes();
049
050    /**
051     * Returns the {@code Type} instance for the given {@code typeName}.
052     */
053    Type getType(String typeName);
054
055    /**
056     * Returns {@code true} if {@code typeName} is a registered Type, {@code false} otherwise.
057     */
058    boolean hasType(String typeName);
059
060    Collection<Type> getAllowedSubTypes(String typeName);
061
062    /**
063     * Returns the allowed sub types of the given {@code typeName}, filtered by a local UI types configuration retrieved
064     * from the {@code currentDoc}, if any.
065     *
066     * @since 5.4.2
067     */
068    Collection<Type> getAllowedSubTypes(String typeName, DocumentModel currentDoc);
069
070    /**
071     * Returns recursively all the allowed sub types from the given {@code typeName}.
072     *
073     * @since 5.4.2
074     */
075    Collection<Type> findAllAllowedSubTypesFrom(String typeName);
076
077    /**
078     * Returns recursively all the allowed sub types from the given {@code typeName}, filtered by a local UI types
079     * configuration retrieved from the {@code currentDoc}, if any.
080     *
081     * @since 5.4.2
082     */
083    Collection<Type> findAllAllowedSubTypesFrom(String typeName, DocumentModel currentDoc);
084
085    /**
086     * Returns the sub type of the given {@code typeName}, filtered by a local UI types configuration retrieved from the
087     * {@code currentDoc}, if any, and organized by type categories.
088     *
089     * @since 5.4.2
090     */
091    Map<String, List<Type>> getTypeMapForDocumentType(String typeName, DocumentModel currentDoc);
092
093    /**
094     * Returns {@code true} if {@code typeName} is a sub type, allowed in creation mode, of {@code containerTypeName},
095     * {@code false} otherwise.
096     *
097     * @since 5.4.2
098     */
099    boolean canCreate(String typeName, String containerTypeName);
100
101    /**
102     * Returns {@code true} if {@code typeName} is a sub type, allowed in creation, of {@code containerTypeName},
103     * {@code false} otherwise.
104     * <p>
105     * It takes care of a local UI types configuration retrieved from the {@code currentDoc} to filter the sub types of
106     * {@code typeName} before checking the creation mode.
107     *
108     * @since 5.4.2
109     */
110    boolean canCreate(String typeName, String containerTypeName, DocumentModel currentDoc);
111
112    /**
113     * Returns {@code true} if {@code typeName} is an allowed sub type of {@code containerTypeName}, {@code false}
114     * otherwise.
115     *
116     * @since 5.4.2
117     */
118    boolean isAllowedSubType(String typeName, String containerTypeName);
119
120    /**
121     * Returns {@code true} if {@code typeName} is an allowed sub type of {@code containerTypeName}, filtered by a local
122     * UI types configuration retrieved from the {@code currentDoc}, if any, {@code false} otherwise.
123     *
124     * @since 5.4.2
125     */
126    boolean isAllowedSubType(String typeName, String containerTypeName, DocumentModel currentDoc);
127
128}