View Javadoc

1   package com.atlassian.core.ofbiz.association;
2   
3   import com.opensymphony.user.EntityNotFoundException;
4   import com.opensymphony.user.User;
5   import org.ofbiz.core.entity.GenericEntityException;
6   import org.ofbiz.core.entity.GenericValue;
7   
8   import java.util.List;
9   
10  public interface AssociationManager
11  {
12      public GenericValue createAssociation(User user, GenericValue sink, String associationType)
13              throws GenericEntityException;
14  
15      /**
16       * Creates an association between a user and a sink node.
17       *
18       * @param userName the user name to associate with the sink node.
19       * @param sinkNodeId the id of the sink node entity
20       * @param sinkNodeEntity the entity name of the sink node
21       * @param associationType the association type
22       * @return the created association
23       */
24      public GenericValue createAssociation(String userName, Long sinkNodeId, String sinkNodeEntity, String associationType)
25              throws GenericEntityException;
26  
27      /**
28       * Create an association between two entities, given a particular association type.
29       * <p/>
30       * If the association already exists - it will not be created.
31       *
32       * @return The new association, or the existing association if it already existed.
33       */
34      public GenericValue createAssociation(GenericValue source, GenericValue sink, String associationType)
35              throws GenericEntityException;
36  
37      /**
38       * Create an association between two entities, given a particular assocation type.
39       * <p/>
40       * If the association already exists - it will not be created.
41       * <p/>
42       * NOTE: this is a convenience method that should only be used when you are certain of the related entity id's. This
43       * method does not verify the integrity of the links it creates.
44       *
45       * @return The new association, or the existing association if it already existed.
46       */
47      public GenericValue createAssociation(Long sourceNodeId, String sourceNodeEntity, Long sinkNodeId, String sinkNodeEntity, String associationType)
48              throws GenericEntityException;
49  
50      public void removeAssociation(GenericValue source, GenericValue sink, String associationType)
51              throws GenericEntityException;
52  
53      public void removeAssociation(User user, GenericValue sink, String associationType) throws GenericEntityException;
54  
55      /**
56       * Removes association between the user with given username and the generic value
57       *
58       * @param username username
59       * @param sink generic value, e.g. issue
60       * @param associationType association type
61       * @throws GenericEntityException if error occurs
62       */
63      public void removeAssociation(String username, GenericValue sink, String associationType)
64              throws GenericEntityException;
65  
66      /**
67       * Remove all entity<->entity associations, given the source
68       */
69      public void removeAssociationsFromSource(GenericValue source) throws GenericEntityException;
70  
71      public void removeAssociationsFromSink(GenericValue sink) throws GenericEntityException;
72  
73      /**
74       * Remove all user<->entity associations, given the entity
75       */
76      public void removeUserAssociationsFromSink(GenericValue sink) throws GenericEntityException;
77  
78      /**
79       * Remove all uer associations given an entity and association type
80       *
81       * @param sink The entity disassociate with all users
82       * @param associationType the association type to remove
83       * @throws GenericEntityException throws if problem with ofbiz
84       */
85      public void removeUserAssociationsFromSink(GenericValue sink, String associationType) throws GenericEntityException;
86  
87      /**
88       * Remove all user<->entity associations, given the user
89       */
90      public void removeUserAssociationsFromUser(User user) throws GenericEntityException;
91  
92      /**
93       * Remove all user<->entity associations, given the user and association type
94       *
95       * @param user The user to remove all associations with
96       * @param associationType the type of associations to remove
97       * @throws GenericEntityException if database exception occurs
98       */
99      public void removeUserAssociationsFromUser(User user, String associationType) throws GenericEntityException;
100 
101     /**
102      * Remove all user<->entity associations, given the user and association type
103      *
104      * @param user The user to remove all associations with
105      * @param entityName The type of entity to remove
106      * @param associationType the type of associations to remove
107      * @throws GenericEntityException if database exception occurs
108      */
109     public void removeUserAssociationsFromUser(User user, String associationType, String entityName)
110             throws GenericEntityException;
111 
112 
113     /**
114      * Swap all assocaitions of a particular type from one sink to another.
115      * <p/>
116      * Used in ComponentDelete and VersionDelete.
117      */
118     public void swapAssociation(String sourceEntityType, String associationType, GenericValue fromSink, GenericValue toSink)
119             throws GenericEntityException;
120 
121     public void swapAssociation(List entities, String associationType, GenericValue fromSink, GenericValue toSink)
122             throws GenericEntityException;
123 
124 
125     /**
126      * Operates on NodeAssociations - gets MANY sinks from ONE source
127      */
128     public List getSinkFromSource(GenericValue source, String sinkName, String associationType, boolean useCache)
129             throws GenericEntityException;
130 
131     public List getSinkFromSource(GenericValue source, String sinkName, String associationType, boolean useCache, boolean useSequence)
132             throws GenericEntityException;
133 
134     /**
135      * Operates on NodeAssociations - gets MANY sources from ONE sink
136      */
137     public List getSourceFromSink(GenericValue sink, String sourceName, String associationType, boolean useCache)
138             throws GenericEntityException;
139 
140     /**
141      * Operates on NodeAssociations - gets MANY sources from ONE sink
142      */
143     public List getSourceFromSink(GenericValue sink, String sourceName, String associationType, boolean useCache, boolean useSequence)
144             throws GenericEntityException;
145 
146     /**
147      * Operates on UserAssociations - gets MANY sinks from ONE user
148      */
149     public List getSinkFromUser(User source, String sinkName, String associationType, boolean useCache)
150             throws GenericEntityException;
151 
152     /**
153      * Operates on UserAssociations - gets MANY sinks Ids from ONE user
154      *
155      * @param source The associated user
156      * @param sinkName The type of entity
157      * @param associationType The association type
158      * @param useCache Do we use the cache
159      * @return a List of ids (Long)
160      */
161     public List /*<Long>*/ getSinkIdsFromUser(User source, String sinkName, String associationType, boolean useCache)
162             throws GenericEntityException;
163 
164     /**
165      * Operates on UserAssociations - gets MANY sinks from ONE user
166      */
167     public List getSinkFromUser(User source, String sinkName, String associationType, boolean useCache, boolean useSequence)
168             throws GenericEntityException;
169 
170     /**
171      * Operates on UserAssociations - gets MANY users from ONE sink
172      */
173     public List getUserFromSink(GenericValue sink, String associationType, boolean useCache)
174             throws GenericEntityException, EntityNotFoundException;
175 
176     /**
177      * Operates on UserAssociations - gets MANY users from ONE sink
178      */
179     public List getUserFromSink(GenericValue sink, String associationType, boolean useCache, boolean useSequence)
180             throws GenericEntityException, EntityNotFoundException;
181 
182     /**
183      * Finds and returns a list of associated usernames, never null.
184      *
185      * @param sink generic value
186      * @param associationType association type
187      * @param useCache use cache flag
188      * @param useSequence use sequence number flag
189      * @return a list of associated usernames, never null
190      * @throws GenericEntityException if an error occurs
191      */
192     public List/*<String>*/ getUsernamesFromSink(GenericValue sink, String associationType, boolean useCache, boolean useSequence)
193             throws GenericEntityException;
194 
195     public GenericValue getAssociation(GenericValue source, GenericValue sink, String associationType)
196             throws GenericEntityException;
197 
198     public GenericValue getAssociation(User user, GenericValue sink, String associationType)
199             throws GenericEntityException;
200 
201     public List getSinkIdsFromSource(GenericValue source, String sinkEntity, String associationType)
202             throws GenericEntityException;
203 
204     public List getSourceIdsFromSink(GenericValue sink, String sourceEntity, String associationType)
205             throws GenericEntityException;
206 
207 
208 }