001/*
002 *  Copyright 2010 Anyware Services
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 */
016package org.ametys.plugins.newsletter.category;
017
018import java.util.Collection;
019import java.util.List;
020
021import org.ametys.cms.repository.Content;
022import org.ametys.plugins.repository.AmetysObjectIterable;
023import org.ametys.runtime.i18n.I18nizableText;
024
025/**
026 * This interface represents a category provider. <br>
027 */
028public interface CategoryProvider
029{
030    /**
031     * Determines if the categories can be modified
032     * @return true if the categories can be modified
033     */
034    public boolean isWritable ();
035    /**
036     * Returns the provider's id.
037     * @return the provider's id.
038     */
039    public String getId();
040    
041    /**
042     * Returns the provider's label.
043     * @return the provider's label.
044     */
045    public I18nizableText getLabel();
046    
047    /**
048     * Returns the provider's description.
049     * @return the provider's description.
050     */
051    public I18nizableText getDescription ();
052    
053    /**
054     * Returns the provider's root categories.
055     * @param siteName The site name. Can be null for all sites
056     * @param lang The languages. Can be null for all languages
057     * @return the provider's root categories.
058     */
059    public List<Category> getCategories (String siteName, String lang);
060    
061    /**
062     * Returns all the provider's categories, recursively.
063     * @param siteName The site name.
064     * @param lang The languages.
065     * @return all the provider's categories.
066     */
067    public Collection<Category> getAllCategories(String siteName, String lang);
068    
069    /**
070     * Returns the provider's category.
071     * @param categoryID The category id
072     * @return the provider's category.
073     */
074    public Category getCategory(String categoryID);
075    
076    
077    /**
078     * Determines if the category exists.
079     * @param categoryID The category id
080     * @return true if the category exists.
081     */
082    public boolean hasCategory (String categoryID);
083    
084    /**
085     * Determines if the category has sub-categories
086     * @param categoryID The category id
087     * @return true if the category have sub-categories
088     */
089    public boolean hasChildren (String categoryID);
090    
091    /**
092     * Get the sub-categories of a category
093     * @param categoryID The category id
094     * @return the sub-categories
095     */
096    public List<Category> getCategories (String categoryID);
097    
098    /**
099     * Determines if a category has categories linked with
100     * @param categoryID The category id
101     * @param siteName The site name
102     * @param lang The language name
103     * @return if a category has categories linked with
104     */
105    public boolean hasNewsletters (String categoryID, String siteName, String lang);
106    
107    /**
108     * Get the newsletter contents linked to a category
109     * @param categoryID The category id
110     * @param siteName The site name
111     * @param lang The language name
112     * @return the newsletter contents
113     */
114    public AmetysObjectIterable<Content> getNewsletters (String categoryID, String siteName, String lang);
115    
116    /**
117     * Get the root id
118     * @param siteName The site name
119     * @param lang The language name
120     * @return the root id
121     */
122    public String getRootId (String siteName, String lang);
123    
124    /**
125     * Affect a template to category
126     * @param category The category  
127     * @param templateName The template name
128     */
129    public void setTemplate (Category category, String templateName);
130    
131    /**
132     * Get automatic property.
133     * @param categoryId The category id.
134     * @return the list of automatic newsletter IDs.
135     */
136    public Collection<String> getAutomaticIds(String categoryId);
137    
138    /**
139     * Set automatic property.
140     * @param categoryId The category id.
141     * @param automaticNewsletterIds The automatic newsletter IDs or empty to set non-automatic.
142     */
143    public void setAutomatic(String categoryId, Collection<String> automaticNewsletterIds);
144    
145}