Dekoh platform API

dekoh.portal.fwk.persistence
Class Share

java.lang.Object
  extended by dekoh.portal.fwk.persistence.Share

public class Share
extends Object

A Share stores the relationship between DigitalObjects shared with buddies by the owner.

Comments can be made on this share.

Since:
Oct 4, 2006

Nested Class Summary
static class Share.BuddyVisitEvent
          Describes a buddy's visit to a share.
 
Field Summary
static String FIND_ALL_NOT_EMPTY_SHARES_BY_OWNER_OF_TYPE
           
static String FIND_ALL_SHARES_BY_OWNER_OF_TYPE
           
static String FIND_SHARE_BY_ID_OWNER
           
static String QUERY_VISIT_COUNT
           
 
Constructor Summary
protected Share()
           
  Share(String name, String applicationId)
           
 
Method Summary
 void addBuddyToShare(Buddy buddy)
           
 void addDigitalObjectToShare(DigitalObject digitalObject)
          Adds a DigitalObject to this share.
static int deleteShareByIdAndOwner(DIOEntityManager em, int id, LocalUser owner)
          Delete specified share, if it was created by the given owner.
 void disableShare()
           
 void enableShare()
           
static Share findShareByIdAndOwner(DIOEntityManager em, int id, LocalUser owner)
           
static Share findShareByIdAndOwner(DIOEntityManager em, int id, String ownerName)
           
static List getAllNonEmptySharesOfTypeByOwner(LocalUser owner, String applicationId, DIOEntityManager dioEntityManager)
          Gets all shared created by the user owner whose buddies and shared dios are not empty.
static List getAllSharesOfTypeByOwner(LocalUser owner, String applicationId, DIOEntityManager dioEntityManager)
          Gets all the Shares that are created by the user using a dekoh application with id applicationId.
 String getApplicationId()
           
 Set getBuddies()
          Gets the current list of buddies that have been given access to this Share.
 List getComments()
           
 List getComments(int dioId)
          Gets comments (Comment threads) made on the given digital object in this share.
 Timestamp getCreationTime()
           
 int getId()
           
 String getName()
           
 int getNumberOfViews(DIOEntityManager em)
           
 LocalUser getOwner()
           
static List getRecentBuddyShareVisits(DIOEntityManager em, String applicationId, String owner)
           
static List getShareByNameOfType(LocalUser owner, String applicationId, String shareName, DIOEntityManager dioEntityManager)
          Gets a Shares that this user has created with given name.
 Set getSharedDigitalObjects()
           
static List getSharesForDigitalObject(DigitalObject dio, DIOEntityManager em, String owner)
          Gets all the shares the given digitalObject belongs to.
 boolean isDisabled()
           
 boolean isPublic()
           
 Comment postComment(Buddy buddy, String comment, int dioId, DIOEntityManager em, String accessPath)
          Starts a new Comment Thread with this as the first comment.
 Comment postComment(String comment, int dioId, DIOEntityManager em, String accessPath)
          Starts a new Comment Thread with this as the first comment.
 void recordBuddyVisit(Buddy buddy, DIOEntityManager em)
           
 void setBuddies(Set buddies)
           
 void setComments(List allCommentThreads)
           
 void setCreationTime(Timestamp creationTime)
           
 void setDisabled(boolean disabled)
           
 void setName(String name)
           
 void setOwner(LocalUser owner)
           
 void setPublic(boolean aPublic)
           
 void setSharedDigitalObjects(Set sharedDigitalObjects)
           
 void shareDigitalObject(DigitalObject digitalObject, Buddy[] buddies)
          Adds given digital object to share and adds buddies to this Share.
 void shareDigitalObject(DigitalObject digitalObject, Set buddies)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FIND_ALL_SHARES_BY_OWNER_OF_TYPE

public static final String FIND_ALL_SHARES_BY_OWNER_OF_TYPE
See Also:
Constant Field Values

FIND_ALL_NOT_EMPTY_SHARES_BY_OWNER_OF_TYPE

public static final String FIND_ALL_NOT_EMPTY_SHARES_BY_OWNER_OF_TYPE
See Also:
Constant Field Values

FIND_SHARE_BY_ID_OWNER

public static final String FIND_SHARE_BY_ID_OWNER
See Also:
Constant Field Values

QUERY_VISIT_COUNT

public static final String QUERY_VISIT_COUNT
See Also:
Constant Field Values
Constructor Detail

Share

protected Share()

Share

public Share(String name,
             String applicationId)
Method Detail

findShareByIdAndOwner

public static Share findShareByIdAndOwner(DIOEntityManager em,
                                          int id,
                                          String ownerName)

findShareByIdAndOwner

public static Share findShareByIdAndOwner(DIOEntityManager em,
                                          int id,
                                          LocalUser owner)
Throws:
NoSuchEntityException - if there is no Share entity by given id created by the passed user

deleteShareByIdAndOwner

public static int deleteShareByIdAndOwner(DIOEntityManager em,
                                          int id,
                                          LocalUser owner)
Delete specified share, if it was created by the given owner. Comments made on the deleted Share will not be deleted.

Parameters:
em -
id - Share Id
owner - creator of the share
Returns:
number >0 if share is deleted, 0 otherwise.

isPublic

public boolean isPublic()

setPublic

public void setPublic(boolean aPublic)

getOwner

public LocalUser getOwner()

setOwner

public void setOwner(LocalUser owner)

getCreationTime

public Timestamp getCreationTime()

setCreationTime

public void setCreationTime(Timestamp creationTime)

isDisabled

public boolean isDisabled()

setDisabled

public void setDisabled(boolean disabled)

addBuddyToShare

public void addBuddyToShare(Buddy buddy)

addDigitalObjectToShare

public void addDigitalObjectToShare(DigitalObject digitalObject)
Adds a DigitalObject to this share. All the buddies in this share can now access this DigitalObject.

Parameters:
digitalObject -

shareDigitalObject

public void shareDigitalObject(DigitalObject digitalObject,
                               Buddy[] buddies)
Adds given digital object to share and adds buddies to this Share. All DigitalObjects that are part of this share will be accessible to the buddies passed to this method.

Calling this method is equivalent to :

 
 share.getBuddies().add(Buddy.getOrCreateBuddyByName("buddy",em));
 share.shareDigitalObject(dio);
 

Parameters:
digitalObject - to be shared
buddies - people who will have access to this share. cannot be null
Throws:
NullPointerException - if buddies or digitalObject is NULL
See Also:
DioCollection, Buddy#getOrCreateBuddyByContactKey(String,dekoh.persistence.DIOEntityManager)

shareDigitalObject

public void shareDigitalObject(DigitalObject digitalObject,
                               Set buddies)

getComments

public List getComments(int dioId)
Gets comments (Comment threads) made on the given digital object in this share.

Parameters:
dioId - id of the digital object that belongs to this share.
Returns:
empty list if there were no comment on this digital objects.

postComment

public Comment postComment(Buddy buddy,
                           String comment,
                           int dioId,
                           DIOEntityManager em,
                           String accessPath)
Starts a new Comment Thread with this as the first comment. Replies can be posted to a Comment by calling Comment.replyToThisComment(Buddy,String)

Parameters:
comment -
dioId -
accessPath -
Returns:
comment object representing this comment

postComment

public Comment postComment(String comment,
                           int dioId,
                           DIOEntityManager em,
                           String accessPath)
Starts a new Comment Thread with this as the first comment. Replies can be posted to a Comment by calling Comment.replyToThisComment(Buddy,String)

Parameters:
comment -
dioId -
accessPath -
Returns:
comment object representing this comment

getComments

public List getComments()

setComments

public void setComments(List allCommentThreads)

getId

public int getId()

getName

public String getName()

setName

public void setName(String name)

getApplicationId

public String getApplicationId()

getBuddies

public Set getBuddies()
Gets the current list of buddies that have been given access to this Share. Use method Share.addBuddyToShare(Buddy) to add a new accessor to this share.

Returns:
current list of buddies that have access to this share.

setBuddies

public void setBuddies(Set buddies)

getSharedDigitalObjects

public Set getSharedDigitalObjects()

setSharedDigitalObjects

public void setSharedDigitalObjects(Set sharedDigitalObjects)

getSharesForDigitalObject

public static List getSharesForDigitalObject(DigitalObject dio,
                                             DIOEntityManager em,
                                             String owner)
Gets all the shares the given digitalObject belongs to.

Parameters:
dio - digitalObject
em - EntityManger
owner - owner
Returns:
list all matching shares

getAllSharesOfTypeByOwner

public static List getAllSharesOfTypeByOwner(LocalUser owner,
                                             String applicationId,
                                             DIOEntityManager dioEntityManager)
Gets all the Shares that are created by the user using a dekoh application with id applicationId.

Parameters:
owner -
applicationId - is the contextPath for web applications on Dekoh
dioEntityManager -
Returns:
list of shares that are created by application with id applicationId and by user LocalUser

getAllNonEmptySharesOfTypeByOwner

public static List getAllNonEmptySharesOfTypeByOwner(LocalUser owner,
                                                     String applicationId,
                                                     DIOEntityManager dioEntityManager)
Gets all shared created by the user owner whose buddies and shared dios are not empty.

Parameters:
owner -
applicationId -
dioEntityManager -
Returns:
list of shares if found or empty list

getShareByNameOfType

public static List getShareByNameOfType(LocalUser owner,
                                        String applicationId,
                                        String shareName,
                                        DIOEntityManager dioEntityManager)
Gets a Shares that this user has created with given name.

Parameters:
owner -
applicationId -
shareName -
dioEntityManager -
Returns:
empty list if there was a NoResultException in excuting the query.

getRecentBuddyShareVisits

public static List getRecentBuddyShareVisits(DIOEntityManager em,
                                             String applicationId,
                                             String owner)

getNumberOfViews

public int getNumberOfViews(DIOEntityManager em)

recordBuddyVisit

public void recordBuddyVisit(Buddy buddy,
                             DIOEntityManager em)

enableShare

public void enableShare()

disableShare

public void disableShare()

Dekoh platform API

© 2009 Pramati Technologies - Dekoh - Portal for Developers