com.atlassian.core.ofbiz.association
Class DefaultAssociationManager

java.lang.Object
  extended by com.atlassian.core.ofbiz.association.DefaultAssociationManager
All Implemented Interfaces:
AssociationManager

public class DefaultAssociationManager
extends Object
implements AssociationManager

This was taken from atlassian-ofbiz and placed into its now rightful home of JIRA.

Since:
4.3

Constructor Summary
DefaultAssociationManager(org.ofbiz.core.entity.DelegatorInterface delegator)
           
 
Method Summary
 org.ofbiz.core.entity.GenericValue createAssociation(org.ofbiz.core.entity.GenericValue source, org.ofbiz.core.entity.GenericValue sink, String associationType)
          Create an association between two entities, given a particular association type.
 org.ofbiz.core.entity.GenericValue createAssociation(Long sourceNodeId, String sourceNodeEntity, Long sinkNodeId, String sinkNodeEntity, String associationType)
          Create an association between two entities, given a particular association type.
 org.ofbiz.core.entity.GenericValue createAssociation(String userName, Long sinkNodeId, String sinkNodeEntity, String associationType)
           
 org.ofbiz.core.entity.GenericValue createAssociation(com.atlassian.crowd.embedded.api.User user, org.ofbiz.core.entity.GenericValue sink, String associationType)
           
 org.ofbiz.core.entity.GenericValue getAssociation(org.ofbiz.core.entity.GenericValue source, org.ofbiz.core.entity.GenericValue sink, String associationType)
           
 org.ofbiz.core.entity.GenericValue getAssociation(com.atlassian.crowd.embedded.api.User user, org.ofbiz.core.entity.GenericValue sink, String associationType)
           
 List<org.ofbiz.core.entity.GenericValue> getSinkFromSource(org.ofbiz.core.entity.GenericValue source, String sinkName, String associationType, boolean useCache)
          Operates on NodeAssociations - gets MANY sinks from ONE source
 List<org.ofbiz.core.entity.GenericValue> getSinkFromSource(org.ofbiz.core.entity.GenericValue source, String sinkName, String associationType, boolean useCache, boolean useSequence)
           
 List<org.ofbiz.core.entity.GenericValue> getSinkFromUser(com.atlassian.crowd.embedded.api.User source, String sinkName, String associationType, boolean useCache)
          Operates on UserAssociations - gets MANY sinks from ONE user
 List<org.ofbiz.core.entity.GenericValue> getSinkFromUser(com.atlassian.crowd.embedded.api.User source, String sinkName, String associationType, boolean useCache, boolean useSequence)
          Operates on UserAssociations - gets MANY sinks from ONE user
 List<Long> getSinkIdsFromSource(org.ofbiz.core.entity.GenericValue source, String sinkEntity, String associationType)
           
 List<Long> getSinkIdsFromUser(com.atlassian.crowd.embedded.api.User source, String sinkName, String associationType, boolean useCache)
          Operates on UserAssociations - gets MANY sinks Ids from ONE user
 List<org.ofbiz.core.entity.GenericValue> getSourceFromSink(org.ofbiz.core.entity.GenericValue sink, String sourceName, String associationType, boolean useCache)
          Operates on NodeAssociations - gets MANY sources from ONE sink
 List<org.ofbiz.core.entity.GenericValue> getSourceFromSink(org.ofbiz.core.entity.GenericValue sink, String sourceName, String associationType, boolean useCache, boolean useSequence)
          Operates on NodeAssociations - gets MANY sources from ONE sink
 List<Long> getSourceIdsFromSink(org.ofbiz.core.entity.GenericValue sink, String sourceEntity, String associationType)
           
 List<com.atlassian.crowd.embedded.api.User> getUserFromSink(org.ofbiz.core.entity.GenericValue sink, String associationType, boolean useCache)
          Operates on UserAssociations - gets MANY users from ONE sink
 List<com.atlassian.crowd.embedded.api.User> getUserFromSink(org.ofbiz.core.entity.GenericValue sink, String associationType, boolean useCache, boolean useSequence)
          Operates on UserAssociations - gets MANY users from ONE sink
 List<String> getUsernamesFromSink(org.ofbiz.core.entity.GenericValue sink, String associationType, boolean useCache, boolean useSequence)
          Finds and returns a list of associated usernames, never null.
 void removeAssociation(org.ofbiz.core.entity.GenericValue source, org.ofbiz.core.entity.GenericValue sink, String associationType)
          Removes association between two entities, given a particular association type.
 void removeAssociation(String username, org.ofbiz.core.entity.GenericValue sink, String associationType)
          Removes association between the user with given username and the generic value
 void removeAssociation(com.atlassian.crowd.embedded.api.User user, org.ofbiz.core.entity.GenericValue sink, String associationType)
          Removes association between the user with given username and the generic value.
 void removeAssociationsFromSink(org.ofbiz.core.entity.GenericValue sink)
          Remove all entity<->entity associations, given the sink.
 void removeAssociationsFromSource(org.ofbiz.core.entity.GenericValue source)
          Remove all entity<->entity associations, given the source
 void removeUserAssociationsFromSink(org.ofbiz.core.entity.GenericValue sink)
          Remove all user<->entity associations, given the entity
 void removeUserAssociationsFromSink(org.ofbiz.core.entity.GenericValue sink, String associationType)
          Remove all user<->entity associations, given the entity and association type
 void removeUserAssociationsFromUser(com.atlassian.crowd.embedded.api.User user)
          Remove all user<->entity associations, given the user
 void removeUserAssociationsFromUser(com.atlassian.crowd.embedded.api.User user, String associationType)
          Remove all user<->entity associations, given the user and association type
 void removeUserAssociationsFromUser(com.atlassian.crowd.embedded.api.User user, String associationType, String entityName)
          Remove all user<->entity associations, given the user and association type
 void swapAssociation(List<org.ofbiz.core.entity.GenericValue> entities, String associationType, org.ofbiz.core.entity.GenericValue fromSink, org.ofbiz.core.entity.GenericValue toSink)
          Swaps all associations for a given list of entities (say move a list of unresolved issue entities to a new fix for version)
 void swapAssociation(String sourceEntityName, String associationType, org.ofbiz.core.entity.GenericValue fromSink, org.ofbiz.core.entity.GenericValue toSink)
          Swap all assocaitions of a particular type from one sink to another.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultAssociationManager

public DefaultAssociationManager(org.ofbiz.core.entity.DelegatorInterface delegator)
Method Detail

createAssociation

public org.ofbiz.core.entity.GenericValue createAssociation(org.ofbiz.core.entity.GenericValue source,
                                                            org.ofbiz.core.entity.GenericValue sink,
                                                            String associationType)
                                                     throws org.ofbiz.core.entity.GenericEntityException
Create an association between two entities, given a particular association type.

If the association already exists - it will not be created.

Specified by:
createAssociation in interface AssociationManager
Parameters:
source - the source
sink - the sink
associationType - the Association Type
Returns:
The new association, or the existing association if it already existed.
Throws:
org.ofbiz.core.entity.GenericEntityException - If there is a DB Exception.

createAssociation

public org.ofbiz.core.entity.GenericValue createAssociation(Long sourceNodeId,
                                                            String sourceNodeEntity,
                                                            Long sinkNodeId,
                                                            String sinkNodeEntity,
                                                            String associationType)
                                                     throws org.ofbiz.core.entity.GenericEntityException
Description copied from interface: AssociationManager
Create an association between two entities, given a particular association type.

If the association already exists - it will not be created.

NOTE: this is a convenience method that should only be used when you are certain of the related entity id's. This method does not verify the integrity of the links it creates.

Specified by:
createAssociation in interface AssociationManager
Returns:
The new association, or the existing association if it already existed.
Throws:
org.ofbiz.core.entity.GenericEntityException - If there is a DB Exception.

createAssociation

public org.ofbiz.core.entity.GenericValue createAssociation(String userName,
                                                            Long sinkNodeId,
                                                            String sinkNodeEntity,
                                                            String associationType)
                                                     throws org.ofbiz.core.entity.GenericEntityException
Throws:
org.ofbiz.core.entity.GenericEntityException

createAssociation

public org.ofbiz.core.entity.GenericValue createAssociation(com.atlassian.crowd.embedded.api.User user,
                                                            org.ofbiz.core.entity.GenericValue sink,
                                                            String associationType)
                                                     throws org.ofbiz.core.entity.GenericEntityException
Throws:
org.ofbiz.core.entity.GenericEntityException

removeAssociation

public void removeAssociation(com.atlassian.crowd.embedded.api.User user,
                              org.ofbiz.core.entity.GenericValue sink,
                              String associationType)
                       throws org.ofbiz.core.entity.GenericEntityException
Description copied from interface: AssociationManager
Removes association between the user with given username and the generic value.

Specified by:
removeAssociation in interface AssociationManager
Parameters:
user - the user
sink - generic value, e.g. issue
associationType - association type
Throws:
org.ofbiz.core.entity.GenericEntityException

removeAssociation

public void removeAssociation(String username,
                              org.ofbiz.core.entity.GenericValue sink,
                              String associationType)
                       throws org.ofbiz.core.entity.GenericEntityException
Description copied from interface: AssociationManager
Removes association between the user with given username and the generic value

Specified by:
removeAssociation in interface AssociationManager
Parameters:
username - username
sink - generic value, e.g. issue
associationType - association type
Throws:
org.ofbiz.core.entity.GenericEntityException - If there is a DB Exception.

removeAssociation

public void removeAssociation(org.ofbiz.core.entity.GenericValue source,
                              org.ofbiz.core.entity.GenericValue sink,
                              String associationType)
                       throws org.ofbiz.core.entity.GenericEntityException
Description copied from interface: AssociationManager
Removes association between two entities, given a particular association type.

Specified by:
removeAssociation in interface AssociationManager
Parameters:
source - the source entity
sink - generic value, e.g. issue
associationType - association type
Throws:
org.ofbiz.core.entity.GenericEntityException

removeAssociationsFromSource

public void removeAssociationsFromSource(org.ofbiz.core.entity.GenericValue source)
                                  throws org.ofbiz.core.entity.GenericEntityException
Remove all entity<->entity associations, given the source

Specified by:
removeAssociationsFromSource in interface AssociationManager
Parameters:
source - the Source
Throws:
org.ofbiz.core.entity.GenericEntityException - If there is a DB Exception.

removeAssociationsFromSink

public void removeAssociationsFromSink(org.ofbiz.core.entity.GenericValue sink)
                                throws org.ofbiz.core.entity.GenericEntityException
Description copied from interface: AssociationManager
Remove all entity<->entity associations, given the sink.

Specified by:
removeAssociationsFromSink in interface AssociationManager
Parameters:
sink - the sink
Throws:
org.ofbiz.core.entity.GenericEntityException - If there is a DB Exception.

removeUserAssociationsFromSink

public void removeUserAssociationsFromSink(org.ofbiz.core.entity.GenericValue sink)
                                    throws org.ofbiz.core.entity.GenericEntityException
Remove all user<->entity associations, given the entity

Specified by:
removeUserAssociationsFromSink in interface AssociationManager
Parameters:
sink - the sink
Throws:
org.ofbiz.core.entity.GenericEntityException - If there is a DB Exception.

removeUserAssociationsFromSink

public void removeUserAssociationsFromSink(org.ofbiz.core.entity.GenericValue sink,
                                           String associationType)
                                    throws org.ofbiz.core.entity.GenericEntityException
Remove all user<->entity associations, given the entity and association type

Specified by:
removeUserAssociationsFromSink in interface AssociationManager
Parameters:
sink - The entity disassociate with all users
associationType - the association type to remove
Throws:
org.ofbiz.core.entity.GenericEntityException - throws if problem with ofbiz

removeUserAssociationsFromUser

public void removeUserAssociationsFromUser(com.atlassian.crowd.embedded.api.User user)
                                    throws org.ofbiz.core.entity.GenericEntityException
Remove all user<->entity associations, given the user

Specified by:
removeUserAssociationsFromUser in interface AssociationManager
Parameters:
user - the User
Throws:
org.ofbiz.core.entity.GenericEntityException - If there is a DB Exception.

removeUserAssociationsFromUser

public void removeUserAssociationsFromUser(com.atlassian.crowd.embedded.api.User user,
                                           String associationType)
                                    throws org.ofbiz.core.entity.GenericEntityException
Description copied from interface: AssociationManager
Remove all user<->entity associations, given the user and association type

Specified by:
removeUserAssociationsFromUser in interface AssociationManager
Parameters:
user - The user to remove all associations with
associationType - the type of associations to remove
Throws:
org.ofbiz.core.entity.GenericEntityException - if database exception occurs

removeUserAssociationsFromUser

public void removeUserAssociationsFromUser(com.atlassian.crowd.embedded.api.User user,
                                           String associationType,
                                           String entityName)
                                    throws org.ofbiz.core.entity.GenericEntityException
Description copied from interface: AssociationManager
Remove all user<->entity associations, given the user and association type

Specified by:
removeUserAssociationsFromUser in interface AssociationManager
Parameters:
user - The user to remove all associations with
associationType - the type of associations to remove
entityName - The type of entity to remove
Throws:
org.ofbiz.core.entity.GenericEntityException - if database exception occurs

swapAssociation

public void swapAssociation(String sourceEntityName,
                            String associationType,
                            org.ofbiz.core.entity.GenericValue fromSink,
                            org.ofbiz.core.entity.GenericValue toSink)
                     throws org.ofbiz.core.entity.GenericEntityException
Swap all assocaitions of a particular type from one sink to another.

Used in ComponentDelete and VersionDelete.

Specified by:
swapAssociation in interface AssociationManager
Parameters:
sourceEntityName - the Source Entity Type
associationType - the Association Type
fromSink - the From sink
toSink - the To sink
Throws:
org.ofbiz.core.entity.GenericEntityException - If there is a DB Exception.

swapAssociation

public void swapAssociation(List<org.ofbiz.core.entity.GenericValue> entities,
                            String associationType,
                            org.ofbiz.core.entity.GenericValue fromSink,
                            org.ofbiz.core.entity.GenericValue toSink)
                     throws org.ofbiz.core.entity.GenericEntityException
Description copied from interface: AssociationManager
Swaps all associations for a given list of entities (say move a list of unresolved issue entities to a new fix for version)

Specified by:
swapAssociation in interface AssociationManager
Parameters:
entities - the entities
associationType - the Association Type
fromSink - the From sink
toSink - the To sink
Throws:
org.ofbiz.core.entity.GenericEntityException - If there is a DB Exception.

getAssociation

public org.ofbiz.core.entity.GenericValue getAssociation(org.ofbiz.core.entity.GenericValue source,
                                                         org.ofbiz.core.entity.GenericValue sink,
                                                         String associationType)
                                                  throws org.ofbiz.core.entity.GenericEntityException
Specified by:
getAssociation in interface AssociationManager
Throws:
org.ofbiz.core.entity.GenericEntityException

getAssociation

public org.ofbiz.core.entity.GenericValue getAssociation(com.atlassian.crowd.embedded.api.User user,
                                                         org.ofbiz.core.entity.GenericValue sink,
                                                         String associationType)
                                                  throws org.ofbiz.core.entity.GenericEntityException
Specified by:
getAssociation in interface AssociationManager
Throws:
org.ofbiz.core.entity.GenericEntityException

getSinkFromSource

public List<org.ofbiz.core.entity.GenericValue> getSinkFromSource(org.ofbiz.core.entity.GenericValue source,
                                                                  String sinkName,
                                                                  String associationType,
                                                                  boolean useCache)
                                                           throws org.ofbiz.core.entity.GenericEntityException
Operates on NodeAssociations - gets MANY sinks from ONE source

Specified by:
getSinkFromSource in interface AssociationManager
Throws:
org.ofbiz.core.entity.GenericEntityException - If there is a DB Exception.

getSinkFromSource

public List<org.ofbiz.core.entity.GenericValue> getSinkFromSource(org.ofbiz.core.entity.GenericValue source,
                                                                  String sinkName,
                                                                  String associationType,
                                                                  boolean useCache,
                                                                  boolean useSequence)
                                                           throws org.ofbiz.core.entity.GenericEntityException
Specified by:
getSinkFromSource in interface AssociationManager
Throws:
org.ofbiz.core.entity.GenericEntityException

getSourceFromSink

public List<org.ofbiz.core.entity.GenericValue> getSourceFromSink(org.ofbiz.core.entity.GenericValue sink,
                                                                  String sourceName,
                                                                  String associationType,
                                                                  boolean useCache)
                                                           throws org.ofbiz.core.entity.GenericEntityException
Operates on NodeAssociations - gets MANY sources from ONE sink

Specified by:
getSourceFromSink in interface AssociationManager
Throws:
org.ofbiz.core.entity.GenericEntityException - If there is a DB Exception.

getSourceFromSink

public List<org.ofbiz.core.entity.GenericValue> getSourceFromSink(org.ofbiz.core.entity.GenericValue sink,
                                                                  String sourceName,
                                                                  String associationType,
                                                                  boolean useCache,
                                                                  boolean useSequence)
                                                           throws org.ofbiz.core.entity.GenericEntityException
Operates on NodeAssociations - gets MANY sources from ONE sink

Specified by:
getSourceFromSink in interface AssociationManager
Throws:
org.ofbiz.core.entity.GenericEntityException - If there is a DB Exception.

getSinkFromUser

public List<org.ofbiz.core.entity.GenericValue> getSinkFromUser(com.atlassian.crowd.embedded.api.User source,
                                                                String sinkName,
                                                                String associationType,
                                                                boolean useCache)
                                                         throws org.ofbiz.core.entity.GenericEntityException
Operates on UserAssociations - gets MANY sinks from ONE user

Specified by:
getSinkFromUser in interface AssociationManager
Parameters:
source - The associated user
sinkName - The type of entity
associationType - The association type
useCache - Do we use the cache
Returns:
a List of sinks (GenericValue)
Throws:
org.ofbiz.core.entity.GenericEntityException - If there is a DB Exception.

getSinkIdsFromUser

public List<Long> getSinkIdsFromUser(com.atlassian.crowd.embedded.api.User source,
                                     String sinkName,
                                     String associationType,
                                     boolean useCache)
                              throws org.ofbiz.core.entity.GenericEntityException
Description copied from interface: AssociationManager
Operates on UserAssociations - gets MANY sinks Ids from ONE user

Specified by:
getSinkIdsFromUser in interface AssociationManager
Parameters:
source - The associated user
sinkName - The type of entity
associationType - The association type
useCache - Do we use the cache
Returns:
a List of ids (Long)
Throws:
org.ofbiz.core.entity.GenericEntityException - If there is a DB Exception.

getSinkFromUser

public List<org.ofbiz.core.entity.GenericValue> getSinkFromUser(com.atlassian.crowd.embedded.api.User source,
                                                                String sinkName,
                                                                String associationType,
                                                                boolean useCache,
                                                                boolean useSequence)
                                                         throws org.ofbiz.core.entity.GenericEntityException
Operates on UserAssociations - gets MANY sinks from ONE user

Specified by:
getSinkFromUser in interface AssociationManager
Parameters:
source - the source User
sinkName - The type of entity
associationType - the association type
useCache - use cache flag
useSequence - use sequence number flag
Returns:
a list of sinks
Throws:
org.ofbiz.core.entity.GenericEntityException - If there is a DB Exception.

getUserFromSink

public List<com.atlassian.crowd.embedded.api.User> getUserFromSink(org.ofbiz.core.entity.GenericValue sink,
                                                                   String associationType,
                                                                   boolean useCache)
                                                            throws org.ofbiz.core.entity.GenericEntityException
Operates on UserAssociations - gets MANY users from ONE sink

Specified by:
getUserFromSink in interface AssociationManager
Parameters:
sink - the Sink generic value
associationType - association type
useCache - use cache flag
Returns:
a list of associated users, never null
Throws:
org.ofbiz.core.entity.GenericEntityException - If there is a DB Exception.

getUserFromSink

public List<com.atlassian.crowd.embedded.api.User> getUserFromSink(org.ofbiz.core.entity.GenericValue sink,
                                                                   String associationType,
                                                                   boolean useCache,
                                                                   boolean useSequence)
                                                            throws org.ofbiz.core.entity.GenericEntityException
Operates on UserAssociations - gets MANY users from ONE sink

Specified by:
getUserFromSink in interface AssociationManager
Parameters:
sink - the Sink generic value
associationType - association type
useCache - use cache flag
useSequence - use sequence number flag
Returns:
a list of associated users, never null
Throws:
org.ofbiz.core.entity.GenericEntityException - If there is a DB Exception.

getUsernamesFromSink

public List<String> getUsernamesFromSink(org.ofbiz.core.entity.GenericValue sink,
                                         String associationType,
                                         boolean useCache,
                                         boolean useSequence)
                                  throws org.ofbiz.core.entity.GenericEntityException
Description copied from interface: AssociationManager
Finds and returns a list of associated usernames, never null.

Specified by:
getUsernamesFromSink in interface AssociationManager
Parameters:
sink - the Sink generic value
associationType - association type
useCache - use cache flag
useSequence - use sequence number flag
Returns:
a list of associated usernames, never null
Throws:
org.ofbiz.core.entity.GenericEntityException - If there is a DB Exception.

getSinkIdsFromSource

public List<Long> getSinkIdsFromSource(org.ofbiz.core.entity.GenericValue source,
                                       String sinkEntity,
                                       String associationType)
                                throws org.ofbiz.core.entity.GenericEntityException
Specified by:
getSinkIdsFromSource in interface AssociationManager
Throws:
org.ofbiz.core.entity.GenericEntityException

getSourceIdsFromSink

public List<Long> getSourceIdsFromSink(org.ofbiz.core.entity.GenericValue sink,
                                       String sourceEntity,
                                       String associationType)
                                throws org.ofbiz.core.entity.GenericEntityException
Specified by:
getSourceIdsFromSink in interface AssociationManager
Throws:
org.ofbiz.core.entity.GenericEntityException


Copyright © 2002-2012 Atlassian. All Rights Reserved.