PageRenderTime 40ms CodeModel.GetById 31ms app.highlight 6ms RepoModel.GetById 2ms app.codeStats 0ms

/connect-task/src/main/java/org/osforce/connect/task/gallery/AlbumActivityStreamTask.java

http://focus-sns.googlecode.com/
Java | 55 lines | 39 code | 9 blank | 7 comment | 0 complexity | 28186527030ba08b8845df17d69d577b MD5 | raw file
 1package org.osforce.connect.task.gallery;
 2
 3import java.util.Map;
 4
 5import org.osforce.connect.entity.gallery.Album;
 6import org.osforce.connect.entity.stream.Activity;
 7import org.osforce.connect.service.gallery.AlbumService;
 8import org.osforce.connect.service.stream.ActivityService;
 9import org.osforce.spring4me.task.AbstractTask;
10import org.osforce.spring4me.task.annotation.Task;
11import org.springframework.beans.factory.annotation.Autowired;
12
13/**
14 *
15 * @author gavin
16 * @since 1.0.0
17 * @create Apr 27, 2011 - 2:22:47 PM
18 *  <a href="http://www.opensourceforce.org">开源力量</a>
19 */
20@Task
21public class AlbumActivityStreamTask extends AbstractTask {
22
23	private AlbumService albumService;
24	private ActivityService activityService;
25
26	public AlbumActivityStreamTask() {
27	}
28
29	@Autowired
30	public void setAlbumService(AlbumService albumService) {
31		this.albumService = albumService;
32	}
33
34	@Autowired
35	public void setActivityService(ActivityService activityService) {
36		this.activityService = activityService;
37	}
38
39	@Override
40	protected void doTask(Map<Object, Object> context) throws Exception {
41		Long albumId = (Long) context.get("albumId");
42		Album album = albumService.getAlbum(albumId);
43		String template = (String) context.get("template");
44		Activity activity = new Activity();
45		activity.setLinkedId(albumId);
46		activity.setEntity(Album.NAME);
47		activity.setType(Album.NAME);
48		activity.setDescription(template);
49		activity.setFormat(Activity.FORMAT_FTL);
50		activity.setProjectId(album.getProjectId());
51		activity.setEnteredId(album.getModifiedId());
52		activityService.createActivity(activity);
53	}
54
55}