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.directory;
023
024import java.util.List;
025
026/**
027 * Base interface for references between directory fields.
028 * <p>
029 * References are used to leverage SQL joins or attributes that store a list of distinguished names in LDAP servers
030 * (e.g. uniqueMember).
031 * <p>
032 * In nuxeo directories, references are special entry fields that are string list of entry ids of a target directory.
033 *
034 * @author ogrisel
035 */
036public interface Reference {
037
038    String getFieldName();
039
040    Directory getSourceDirectory();
041
042    void setSourceDirectoryName(String sourceDirectoryName);
043
044    Directory getTargetDirectory();
045
046    /**
047     * @deprecated since 9.2 (unused)
048     */
049    @Deprecated
050    void setTargetDirectoryName(String targetDirectoryName);
051
052    void addLinks(String sourceId, List<String> targetIds);
053
054    void addLinks(List<String> sourceIds, String targetId);
055
056    void removeLinksForSource(String sourceId);
057
058    void removeLinksForTarget(String targetId);
059
060    List<String> getTargetIdsForSource(String sourceId);
061
062    List<String> getSourceIdsForTarget(String targetId);
063
064    void setTargetIdsForSource(String sourceId, List<String> targetIds);
065
066    void setSourceIdsForTarget(String targetId, List<String> sourceIds);
067
068    /**
069     * Adds the links between the source id and the target ids
070     *
071     * @param sourceId the source id
072     * @param targetIds the target ids
073     * @param session the session
074     * @since 9.2
075     */
076    void addLinks(String sourceId, List<String> targetIds, Session session);
077
078    /**
079     * Adds the links between the source ids and the target id
080     *
081     * @param sourceIds the source ids
082     * @param targetId the target id
083     * @param session the session
084     * @since 9.2
085     */
086    void addLinks(List<String> sourceIds, String targetId, Session session);
087
088    /**
089     * Sets all source ids to be associated to the given target id
090     *
091     * @param targetId the target id
092     * @param sourceIds the source ids
093     * @param session the session
094     * @since 9.2
095     */
096    void setSourceIdsForTarget(String targetId, List<String> sourceIds, Session session);
097
098    /**
099     * Sets all target ids to be associated to the given source id
100     *
101     * @param sourceId the source id
102     * @param targetIds the target ids
103     * @param session the session
104     * @since 9.2
105     */
106    void setTargetIdsForSource(String sourceId, List<String> targetIds, Session session);
107
108    /**
109     * Removes all the links for a given target id
110     *
111     * @param targetId the target id
112     * @param session the session
113     * @since 9.2
114     */
115    void removeLinksForTarget(String targetId, Session session);
116
117    /**
118     * Removes all the links for a given source id
119     *
120     * @param sourceId the source id
121     * @param session the session
122     * @since 9.2
123     */
124    void removeLinksForSource(String sourceId, Session session);
125
126}