001    /*
002     * 
003     * $Revision: 14986 $ $Date: 2009-03-20 21:41:45 +0100 (Fri, 20 Mar 2009) $
004     *
005     * This file is part of ***  M y C o R e  ***
006     * See 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, in a file called gpl.txt or 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.common;
025    
026    import java.util.Collection;
027    import java.util.Map;
028    
029    /**
030     * This interface is designed to choose the persistence for the link tables.
031     * 
032     * @author Jens Kupferschmidt
033     * @version $Revision: 14986 $ $Date: 2009-03-20 21:41:45 +0100 (Fri, 20 Mar 2009) $
034     */
035    public interface MCRLinkTableInterface {
036        
037        /**
038         * The method create a new item in the datastore.
039         * 
040         * @param from
041         *            a string with the link ID MCRFROM
042         * @param to
043         *            a string with the link ID MCRTO
044         * @param type
045         *            a string with the link ID MCRTYPE
046         * @param attr
047         *            a string with the link ID MCRATTR
048         */
049        public void create(String from, String to, String type, String attr);
050    
051        /**
052         * The method remove a item for the from ID from the datastore.
053         * 
054         * @param from
055         *            a string with the link ID MCRFROM
056         * @param to
057         *            an array of strings with the link ID MCRTO
058         * @param type
059         *            an array of strings with the link ID MCRTYPE
060         */
061        public void delete(String from, String to, String type);
062    
063        /**
064         * The method count the number of references with '%from%' and 'to' and
065         * optional 'type' and optional 'restriction%' values of the table.
066         * 
067         * @param fromtype
068         *            a substing in the from ID as String, it can be null
069         * @param to
070         *            the object ID as String, which is referenced
071         * @param type
072         *            the refernce type, it can be null
073         * @param restriction
074         *            a first part of the to ID as String, it can be null
075         * @return the number of references
076         */
077        public int countTo(String fromtype, String to, String type, String restriction);
078    
079        /**
080         * The method returns a Map of all counted distinct references
081         * 
082         * @param mcrtoPrefix
083         * @return
084         * 
085         * the result-map of (key,value)-pairs can be visualized as <br />
086         * select count(mcrfrom) as value, mcrto as key from
087         * mcrlinkclass|mcrlinkhref where mcrto like mcrtoPrefix + '%' group by
088         * mcrto;
089         * 
090         */
091        public Map<String, Number> getCountedMapOfMCRTO(String mcrtoPrefix);
092    
093        /**
094         * Returns a List of all link sources of <code>to</code> and a special
095         * <code>type</code>
096         * 
097         * @param to
098         *            Destination-ID
099         * @param type
100         *            Link reference type, this can be null. Current types are
101         *            classid, child, parent, reference and derivate.
102         * @return List of Strings (Source-IDs)
103         */
104        public Collection<String> getSourcesOf(String to, String type);
105    
106        /**
107         * Returns a List of all link destination of <code>from</code> and a
108         * special <code>type</code>
109         * 
110         * @param from
111         *            Source-ID
112         * @param type
113         *            Link reference type, this can be null. Current types are
114         *            classid, child, parent, reference and derivate.
115         * @return List of Strings (Destination-IDs)
116         */
117        public Collection<String> getDestinationsOf(String from, String type);
118    
119    }