001 /**
002 *
003 * $Revision: 15001 $ $Date: 2009-03-24 17:39:36 +0100 (Tue, 24 Mar 2009) $
004 *
005 * This file is part of ** M y C o R e **
006 * Visit our homepage at http://www.mycore.de/ for details.
007 *
008 * This program is free software; you can use it, redistribute it
009 * and / or modify it under the terms of the GNU General Public License
010 * (GPL) as published by the Free Software Foundation; either version 2
011 * of the License or (at your option) any later version.
012 *
013 * This program is distributed in the hope that it will be useful, but
014 * WITHOUT ANY WARRANTY; without even the implied warranty of
015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
016 * GNU General Public License for more details.
017 *
018 * You should have received a copy of the GNU General Public License
019 * along with this program, normally in the file license.txt.
020 * If not, write to the Free Software Foundation Inc.,
021 * 59 Temple Place - Suite 330, Boston, MA 02111-1307 USA
022 *
023 **/
024 package org.mycore.datamodel.classifications2;
025
026 import java.util.Collection;
027 import java.util.Map;
028
029 /**
030 *
031 * @author Thomas Scheffler (yagee)
032 * @version $Revision: 15001 $ $Date: 2009-03-24 17:39:36 +0100 (Tue, 24 Mar 2009) $
033 * @since 2.0
034 */
035 public interface MCRCategLinkService {
036
037 /**
038 * Checks if a categories id refered by objects.
039 *
040 * @param category
041 * a subtree rooted at a MCRCategory for which links should be counted
042 * @return true if the classification is used
043 */
044 public abstract Map<MCRCategoryID, Boolean> hasLinks(MCRCategory category);
045
046 /**
047 * Counts links to a collection of categories.
048 *
049 * @param category
050 * a subtree rooted at a MCRCategory for which links should be counted
051 * @param childrenOnly
052 * if only direct children of category should be queried (query may be more optimized)
053 * @return a Map with MCRCategoryID as key and the number of links as value
054 */
055 public abstract Map<MCRCategoryID, Number> countLinks(MCRCategory category, boolean childrenOnly);
056
057 /**
058 * Counts links to a collection of categories.
059 *
060 * @param categIDs
061 * a subtree rooted at a MCRCategory for which links should be counted
062 * @param type
063 * restrict links that refer to object of this type
064 * @param childrenOnly
065 * if only direct children of category should be queried (query may be more optimized)
066 * @return a Map with MCRCategoryID as key and the number of links as value
067 */
068 public abstract Map<MCRCategoryID, Number> countLinksForType(MCRCategory category, String type, boolean childrenOnly);
069
070 /**
071 * Delete all links that refer to the given Object ID.
072 *
073 * @param id
074 * an Object ID
075 * @see #deleteLinks(Collection)
076 */
077 public abstract void deleteLink(String id);
078
079 /**
080 * Delete all links that refer to the given collection of Object IDs.
081 *
082 * @param ids
083 * a collection of Object IDs
084 * @see #deleteLink(String)
085 */
086 public abstract void deleteLinks(Collection<String> ids);
087
088 /**
089 * Returns a list of linked Object IDs.
090 *
091 * @param id
092 * ID of the category
093 * @return Collection of Object IDs
094 */
095 public abstract Collection<String> getLinksFromCategory(MCRCategoryID id);
096
097 /**
098 * Returns a list of linked Object IDs restricted by the specified type.
099 *
100 * @param id
101 * ID of the category
102 * @param type
103 * restrict links that refer to object of this type
104 * @return Collection of Object IDs
105 */
106 public abstract Collection<String> getLinksFromCategoryForType(MCRCategoryID id, String type);
107
108 /**
109 * Returns a list of linked categories.
110 *
111 * @param id
112 * Object ID of a linked Object
113 * @return list of MCRCategoryID of linked categories
114 */
115 public abstract Collection<MCRCategoryID> getLinksFromObject(String id);
116
117 /**
118 * Add links between categories and Objects.
119 *
120 * Implementors must assure that ancestor (parent) axis categories are
121 * implicit linked by this method.
122 *
123 * @param objectReference
124 * reference to a Object
125 * @param categories
126 * a collection of categoryIDs to be linked to
127 * @see #countLinks(Collection)
128 * @see #countLinksForType(Collection, String)
129 */
130 public abstract void setLinks(MCRObjectReference objectReference, Collection<MCRCategoryID> categories);
131
132 }