001: /*
002: * Created on 03 mai 2004 by the Message Center Team
003: *
004: */
005: package mc.formgenerator.servlets.bonita;
006:
007: import java.rmi.RemoteException;
008: import java.util.ArrayList;
009: import java.util.Collection;
010:
011: import javax.ejb.CreateException;
012: import javax.naming.NamingException;
013:
014: import hero.interfaces.UserSessionHome;
015: import hero.interfaces.UserSession;
016: import hero.util.HeroException;
017:
018: /**
019: * Model for servlet ServletActivityToDoList to give ToDo List to display.
020: *
021: */
022: public class ModelActivityToDoList {
023:
024: //The project name
025: private String projectName = null;
026:
027: //The todo list as a collection
028: private Collection toDoList = null;
029:
030: /**
031: * Default constructor
032: * Creates an instance of ModelActivityToDoList
033: */
034: public ModelActivityToDoList() {
035: };
036:
037: /**
038: * Gets the ToDoList
039: * @return the ToDoList as collection
040: */
041: public Collection getToDoList() {
042: //Return the todo list
043: return this .toDoList;
044: }
045:
046: /**
047: * Sets the ToDoList
048: * @param collection : The collection to set
049: */
050: public void setToDoList(Collection collection) {
051: //Set the todo list
052: this .toDoList = collection;
053: }
054:
055: /**
056: * Gets the project name
057: * @return the project name as stringection
058: */
059: public String getProjectName() {
060: //Return the name of the project
061: return this .projectName;
062: }
063:
064: /**
065: * Sets the project name
066: * @param theProjectName : The name of the project
067: */
068: public void setProjectName(String theProjectName) {
069: //Set the todo list
070: this .projectName = theProjectName;
071: }
072:
073: /**
074: * Gets the to do list for the authentified user
075: * @param projectName : The name of the project
076: * @return The todo list for this project
077: * @throws HeroException
078: * @throws RemoteException
079: * @throws CreateException
080: * @throws NamingException
081: * @throws LoginException
082: */
083: private Collection getBonitaToDoList(String projectName)
084: throws HeroException, RemoteException, CreateException,
085: NamingException {
086:
087: //Connection to Bonita via API
088: UserSessionHome userh = (UserSessionHome) hero.interfaces.UserSessionUtil
089: .getHome();
090: UserSession usersession = userh.create();
091:
092: //Collection as ToDo list
093: Collection collectionToDoList = new ArrayList();
094: try {
095: collectionToDoList = usersession.getToDoList(projectName);
096: } catch (HeroException e) {
097: }
098:
099: return collectionToDoList;
100: }
101:
102: /**
103: * For the MVC corresponds to the work the object has to do
104: * @param projectName : The project on which the object opers
105: * @throws RemoteException
106: * @throws LoginException
107: * @throws HeroException
108: * @throws CreateException
109: * @throws NamingException
110: */
111: public void process(String theProjectName) throws RemoteException,
112: HeroException, CreateException, NamingException {
113:
114: //Setting attributes
115: this.setProjectName(theProjectName);
116: this.setToDoList(this.getBonitaToDoList(theProjectName));
117: }
118: }
|