r7142 - in dumbhippo/trunk/server/src/com/dumbhippo/server: blocks dm



Author: otaylor
Date: 2008-01-07 15:59:36 -0600 (Mon, 07 Jan 2008)
New Revision: 7142

Modified:
   dumbhippo/trunk/server/src/com/dumbhippo/server/blocks/MusicPersonBlockHandlerBean.java
   dumbhippo/trunk/server/src/com/dumbhippo/server/dm/TrackDMO.java
Log:
TrackDMO: Add 'downloads' property
MusicPersonBlockHandlerBean: Notify on changes to MusicPersonBlockDMO.tracks


Modified: dumbhippo/trunk/server/src/com/dumbhippo/server/blocks/MusicPersonBlockHandlerBean.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/server/blocks/MusicPersonBlockHandlerBean.java	2008-01-07 21:47:15 UTC (rev 7141)
+++ dumbhippo/trunk/server/src/com/dumbhippo/server/blocks/MusicPersonBlockHandlerBean.java	2008-01-07 21:59:36 UTC (rev 7142)
@@ -24,6 +24,9 @@
 import com.dumbhippo.server.Enabled;
 import com.dumbhippo.server.MusicSystem;
 import com.dumbhippo.server.NotFoundException;
+import com.dumbhippo.server.dm.BlockDMO;
+import com.dumbhippo.server.dm.BlockDMOKey;
+import com.dumbhippo.server.dm.DataService;
 import com.dumbhippo.server.views.AnonymousViewpoint;
 import com.dumbhippo.server.views.ChatMessageView;
 import com.dumbhippo.server.views.PersonView;
@@ -138,6 +141,8 @@
 	
 	public void onTrackPlayed(User user, Track track, Date when) {
 		Block block = stacker.stack(getKey(user), when.getTime(), user, false, StackReason.BLOCK_UPDATE);
+		
+		DataService.currentSessionRW().feedChanged(BlockDMO.class, new BlockDMOKey(block), "tracks", when.getTime());
 
 		// if we weren't public we might be now. Playing a track won't 
 		// ever un-public us though.

Modified: dumbhippo/trunk/server/src/com/dumbhippo/server/dm/TrackDMO.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/server/dm/TrackDMO.java	2008-01-07 21:47:15 UTC (rev 7141)
+++ dumbhippo/trunk/server/src/com/dumbhippo/server/dm/TrackDMO.java	2008-01-07 21:59:36 UTC (rev 7142)
@@ -1,5 +1,9 @@
 package com.dumbhippo.server.dm;
 
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
 import javax.ejb.EJB;
 import javax.persistence.EntityManager;
 
@@ -9,6 +13,7 @@
 import com.dumbhippo.dm.annotations.DMProperty;
 import com.dumbhippo.dm.annotations.Inject;
 import com.dumbhippo.dm.annotations.PropertyType;
+import com.dumbhippo.persistence.SongDownloadSource;
 import com.dumbhippo.persistence.Track;
 import com.dumbhippo.server.MusicSystem;
 import com.dumbhippo.server.NotFoundException;
@@ -93,4 +98,17 @@
 	public long getDuration() {
 		return trackView.getDurationSeconds() * 1000;
 	}
+	
+	@DMProperty(defaultInclude=true, group=TRACK_VIEW_GROUP)
+	public List<String> getDownloads() {
+		List<String> result = new ArrayList<String>();
+		
+		Map<SongDownloadSource, String> downloads = trackView.getDownloads();
+		for (SongDownloadSource source: trackView.getDownloads().keySet()) {
+			String url = downloads.get(source);
+			result.add(source.name() + ":" + url);
+		}
+		
+		return result;
+	}
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]