01: package org.emforge.jbpm.rss;
02:
03: import java.util.ArrayList;
04: import java.util.List;
05: import java.util.Map;
06:
07: import javax.servlet.http.HttpServletRequest;
08: import javax.servlet.http.HttpServletResponse;
09:
10: import org.emforge.jbpm.web.bean.MainController;
11: import org.emforge.jbpm.web.bean.TaskController;
12: import org.emforge.xfer.StepTO;
13: import org.emforge.xfer.TaskTO;
14:
15: import ru.emdev.EmForge.rss.AbstractRSSView;
16: import ru.emdev.EmForge.util.Helper;
17:
18: import com.sun.syndication.feed.synd.SyndContent;
19: import com.sun.syndication.feed.synd.SyndContentImpl;
20: import com.sun.syndication.feed.synd.SyndEntry;
21: import com.sun.syndication.feed.synd.SyndEntryImpl;
22: import com.sun.syndication.feed.synd.SyndFeed;
23:
24: public class TaskListRSSView extends AbstractRSSView {
25:
26: public static final String DESCRIPTION_KEY = "description";
27: public static final String TITLE_KEY = "title";
28: public static final String LIST_KEY = "tasks";
29:
30: /**
31: * Build RSS View.
32: *
33: * @todo [AKA] SindContent - use html instead of plain text
34: */
35: @SuppressWarnings("unchecked")
36: @Override
37: protected void buildRSSFeed(Map i_model, SyndFeed i_feed,
38: HttpServletRequest i_request, HttpServletResponse o_response)
39: throws Exception {
40:
41: StepTO[] stepList = (StepTO[]) i_model.get(LIST_KEY);
42:
43: m_description = (String) i_model.get(DESCRIPTION_KEY);
44: m_title = (String) i_model.get(TITLE_KEY);
45:
46: m_link = Helper.concatUrl(m_appContext.getApplicationPath(),
47: MainController.TASKSMAINPAGE_NAME);
48: m_imagePath = Helper.concatUrl(m_appContext
49: .getApplicationPath(), "/chrome/emforge.ico");
50:
51: List<SyndEntry> entries = new ArrayList<SyndEntry>();
52:
53: for (StepTO step : stepList) {
54: SyndEntry entry = new SyndEntryImpl();
55:
56: entry.setLink(m_appContext.getApplicationPath() + "/"
57: + TaskController.TASK_PAGE_NAME + "/"
58: + step.getTaskId());
59: entry.setTitle(step.getName() + ":" + step.getTitle());
60: entry.setPublishedDate(step.getActualStartTime());
61: entry.setAuthor(step.getActor());
62:
63: SyndContent description = new SyndContentImpl();
64: description.setType("text/html");
65:
66: TaskTO task = (TaskTO) i_model.get(step.getTaskId()
67: .toString());
68: description.setValue(task.getDescription());
69: entry.setDescription(description);
70:
71: entries.add(entry);
72: }
73:
74: i_feed.setEntries(entries);
75: }
76: }
|