ShowProfilAction.java
001 /*
002  * Created on 22.04.2004
003  */
004 package de.fub.tip.actions;
005 
006 import java.sql.SQLException;
007 import java.util.Collection;
008 
009 import javax.servlet.http.HttpServletRequest;
010 import javax.servlet.http.HttpServletResponse;
011 import javax.sql.DataSource;
012 
013 import org.apache.log4j.Logger;
014 import org.apache.struts.action.ActionForm;
015 import org.apache.struts.action.ActionForward;
016 import org.apache.struts.action.ActionMapping;
017 import org.apache.struts.actions.DispatchAction;
018 
019 import de.fub.tip.actionforms.ChangeProfilActionForm;
020 import de.fub.tip.datenanzeige.ormapper.UserdataVO;
021 import de.fub.tip.datenbank.factory.SightGruppenBearbeiterFactory;
022 import de.fub.tip.datenbank.factory.ThemenBearbeiterFactory;
023 import de.fub.tip.datenbank.logik.SightGruppenBearbeiter;
024 import de.fub.tip.datenbank.logik.ThemenBearbeiter;
025 import de.fub.tip.exceptions.NoDataFoundException;
026 import de.fub.tip.exceptions.NoUserLoggedInException;
027 
028 /**
029  * Sinn: beinhaltet den Arbeitsfluss zur Anzeige von Profilinformationen,
030  * um sie zu ändern. Dabei gibt es folgende Unteraktionen:<br>
031  <ol>
032  <li>Anzeige des Sehenswürdigkeitsgruppenprofils</li>
033  <li>Anzeige des Themengruppenprofils</li>
034  <li></li>
035  </ol>
036  
037  @author hirsch, 2004-04-22
038  @version 2004-04-30
039  * $Id: ShowProfilAction.java,v 1.3 2004/04/30 12:04:05 hirsch Exp $
040  */
041 public class ShowProfilAction extends DispatchAction {
042     /** Logger zur Fehlersuche */
043   private static Logger logger = 
044       Logger.getLogger(ShowProfilAction.class);
045 
046   /**
047    * zeigt das Themengruppenprofil eines Benutzers an
048    *
049    @param actionMapping ActionMapping
050    @param actionForm zugehörige ActionForm
051    @param request der aktuelle Request
052    @param response ServletResponse
053    *
054    @return ActionForward nächstes Ziel
055    */
056   public ActionForward showprofiltgroup(ActionMapping actionMapping,
057       ActionForm actionForm, HttpServletRequest request,
058       HttpServletResponse response ) { 
059 
060     logger.info("ChangeProfilAction.showprofiltgroup() called.");
061     
062     DataSource dataSource = null;
063     Collection ergebnis = null;
064 
065     try {
066             dataSource = this.getDataSource(request, "tip")
067             ThemenBearbeiter logik = (ThemenBearbeiter)
068               ThemenBearbeiterFactory.getInstance(dataSource).
069               getLogicObject();  
070 
071         // Formularelement greifbar machen für Manipulation 
072             // an HTML-Checkbox
073             ChangeProfilActionForm form = 
074             (ChangeProfilActionFormactionForm;
075             
076             if (form != nulllogger.debug("form = " + form);
077             else logger.debug("form ist null");
078 
079             // Attribute aus der Session holen
080             UserdataVO user = (UserdataVOrequest.getSession().
081               getAttribute("user");
082             
083           try {
084               ergebnis = logik.getBeanTopicGroupProfile(user);
085               
086             ifergebnis != null) {
087                 // Formularinhalt setzen
088                 form.setNames(ergebnis);
089                 form.setSelection();
090               request.setAttribute("tprofil", ergebnis);
091               logger.debug("ChangeProfilAction.showprofiltgroup." +
092                 "Container als Parameter tprofil gespeichert.");
093             // end if
094           catch(NoDataFoundException e) {
095             logger.debug("ChangeProfilAction.showprofiltgroup." +
096                 "Container leer");
097           // end of try
098 
099         catch (SQLException e) {
100         logger.debug("ChangeProfilAction.showprofiltgroup.SQLException "
101                 e + ", " + e.getLocalizedMessage());
102 
103         return actionMapping.findForward("dbproblem");
104 
105         catch (NoUserLoggedInException e) {
106         logger.debug("ChangeProfilAction.showprofiltgroup." +
107             "NoUserLoggedIn "+ e + ", " + e.getLocalizedMessage());
108 
109         return actionMapping.findForward("loginproblem");
110         // end of catch    
111         
112     return actionMapping.findForward("tgroupseite");
113   // end of showprofiltgroup
114   
115   /**
116    * zeigt das Sehenswürdigkeitsgruppenprofil eines Benutzers an.
117    * Dabei wird die Darstellung in HTML-Checkboxen aufbereitet.
118    *
119    @param actionMapping ActionMapping
120    @param actionForm zugehörige ActionForm
121    @param request der aktuelle Request
122    @param response ServletResponse
123    *
124    @return ActionForward nächstes Ziel
125    */
126   public ActionForward showprofilsgroup(ActionMapping actionMapping,
127       ActionForm actionForm, HttpServletRequest request,
128       HttpServletResponse response ) { 
129 
130     logger.info("ChangeProfilAction.showprofilsgroup() called.");
131     
132     DataSource dataSource = null;
133     Collection ergebnis = null;
134 
135     try {
136             dataSource = this.getDataSource(request, "tip")
137             SightGruppenBearbeiter logik = (SightGruppenBearbeiter)
138               SightGruppenBearbeiterFactory.getInstance(dataSource).
139               getLogicObject();  
140 
141         // Formularelement greifbar machen
142             // für Manipulation an HTML-Checkbox
143             ChangeProfilActionForm form = 
144             (ChangeProfilActionFormactionForm;
145             
146             if (form != nulllogger.debug("form = " + form);
147             else logger.debug("form ist null");
148 
149             // Attribute aus der Session holen
150             UserdataVO user = (UserdataVOrequest.getSession().
151               getAttribute("user");
152             
153           try {
154               ergebnis = logik.getBeanSightGroupProfile(user);
155               
156             ifergebnis != null) {
157                 // Formularinhalt setzen
158                 form.setNames(ergebnis);
159                 form.setSelection();
160               request.setAttribute("sprofil", ergebnis);
161               logger.debug("ChangeProfilAction.showprofilsgroup." +
162                 "Container als Parameter sprofil gespeichert.");
163             // end if
164           catch(NoDataFoundException e) {
165             logger.debug("ChangeProfilAction.showprofilsgroup." +
166                 "Container leer");
167           // end of try
168 
169         catch (SQLException e) {
170         logger.debug("ChangeProfilAction.showprofilsgroup.SQLException "
171                 e + ", " + e.getLocalizedMessage());
172 
173         return actionMapping.findForward("dbproblem");
174 
175         catch (NoUserLoggedInException e) {
176         logger.debug("ChangeProfilAction.showprofilsgroup." +
177             "NoUserLoggedIn "+ e + ", " + e.getLocalizedMessage());
178 
179         return actionMapping.findForward("loginproblem");
180         // end of catch    
181         
182     return actionMapping.findForward("sgroupseite");
183   // end of showprofilsgroup
184 // end of class