KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > mc > formgenerator > servlets > bonita > ModeleAccueil


1 /*
2  * Created on 3 mai 2004
3  *
4  * To change the template for this generated file go to
5  * Window>Preferences>Java>Code Generation>Code and Comments
6  */

7 package mc.formgenerator.servlets.bonita;
8
9 import hero.client.importLdap.SimpleCallbackHandler;
10 import hero.interfaces.UserSessionHome;
11 import hero.interfaces.UserSessionUtil;
12 import hero.util.HeroException;
13 import hero.util.StrutsProjectValue;
14
15 import java.rmi.RemoteException JavaDoc;
16 import java.util.Collection JavaDoc;
17 import java.util.Iterator JavaDoc;
18 import java.util.Vector JavaDoc;
19
20 import javax.ejb.CreateException JavaDoc;
21 import javax.naming.NamingException JavaDoc;
22 import javax.security.auth.login.LoginContext JavaDoc;
23 import javax.security.auth.login.LoginException JavaDoc;
24
25 import hero.interfaces.*;
26
27 /**
28  * This class has to give the model projects list to display to the JSP page.
29  * @author delfourr
30  *
31  */

32 public class ModeleAccueil {
33
34     
35     /**
36      * Attribute which stocks the project names
37      */

38     private Collection JavaDoc modelProjectList;
39
40
41     /**
42      * Default class constructor
43      */

44     public ModeleAccueil() {
45     }
46
47
48
49
50     /**
51      * Returns the list of all the projects but without the instances.
52      * @return Colection model projects -> they aren't instances.
53      * @throws LoginException
54      * @throws NamingException
55      * @throws CreateException
56      * @throws RemoteException
57      * @throws HeroException
58      */

59     public Collection JavaDoc getAllModelProjects() throws LoginException JavaDoc, NamingException JavaDoc, CreateException JavaDoc, RemoteException JavaDoc, HeroException {
60         
61         boolean isAnInstance;
62         
63         Vector JavaDoc listeResultat = new Vector JavaDoc();
64         hero.interfaces.AllProjectsSessionLocalHome projecth = (AllProjectsSessionLocalHome)hero.interfaces.AllProjectsSessionUtil.getLocalHome();
65         hero.interfaces.AllProjectsSessionLocal allProject = projecth.create();
66                 
67         //Get all the projects : models & instances
68
Collection JavaDoc listeProjets = allProject.getProjects();
69         
70         //listeResultat only owns the model projects
71
Iterator JavaDoc it = listeProjets.iterator();
72         while (it.hasNext()) {
73                     //Getting the name of the current project
74
StrutsProjectValue struts = (StrutsProjectValue)it.next();
75                     String JavaDoc name = struts.getName();
76                     
77                     //is this project an instance
78
isAnInstance = name.matches(".*_instance.*");
79                     if (!isAnInstance) {
80                             listeResultat.addElement(name);
81                     }
82         }
83         
84         return listeResultat;
85     }
86
87
88
89
90     /**
91      * The main method which asks and returns the model projects list.
92      * @throws LoginException
93      * @throws RemoteException
94      * @throws NamingException
95      * @throws CreateException
96      * @throws HeroException
97      */

98     public void process() throws LoginException JavaDoc, RemoteException JavaDoc, NamingException JavaDoc, CreateException JavaDoc, HeroException {
99         
100         Collection JavaDoc list = this.getAllModelProjects();
101         
102         this.setModelProjectList(list);
103     }
104
105
106
107
108     /**
109      * Set the value of the attribute modelProjectList with the value 'col'.
110      * @param col Collection
111      */

112     public void setModelProjectList(Collection JavaDoc col) {
113         
114         this.modelProjectList = col;
115     }
116
117
118
119
120     /**
121      * Get the value of the attribute modelProjectList.
122      * @return Collection List of all model projects.
123      */

124     public Collection JavaDoc getModelProjectList() {
125         
126         return this.modelProjectList;
127     }
128
129
130 }
131
Popular Tags