View Javadoc

1   /*
2    *  $Id: SequenceWizard.java,v 1.5 2004/07/25 14:12:21 roku Exp $ 
3    *
4    *  Copyright 2004 University of Hannover
5    *
6    *  Licensed under the Apache License, Version 2.0 (the "License");
7    *  you may not use this file except in compliance with the License.
8    *  You may obtain a copy of the License at
9    *
10   *      http://www.apache.org/licenses/LICENSE-2.0
11   *
12   *  Unless required by applicable law or agreed to in writing, software
13   *  distributed under the License is distributed on an "AS IS" BASIS,
14   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   *  See the License for the specific language governing permissions and
16   *  limitations under the License.
17   */
18  
19  package olr.presentation;
20  
21  import java.util.Enumeration;
22  
23  import olr.SessionData;
24  import olr.rdf.Resource;
25  import olr.rdf.Tools;
26  
27  import org.w3c.dom.html.HTMLAnchorElement;
28  
29  import com.lutris.appserver.server.httpPresentation.HttpPresentationException;
30  import com.lutris.appserver.server.httpPresentation.HttpPresentationRequest;
31  
32  // Referenced classes of package olr3Servlet.presentation:
33  //            ExtendedHttpPresentation
34  
35  public class SequenceWizard extends ExtendedHttpPresentation
36  {
37  
38      public SequenceWizard()
39      {
40          aboutURI = null;
41      }
42  
43      public boolean loggedInUserRequired()
44      {
45          return true;
46      }
47  
48      private void showParams()
49      {
50          try
51          {
52              HttpPresentationRequest request = getComms().request;
53              String parameter;
54              String value;
55              for(Enumeration parameters = request.getParameterNames(); parameters.hasMoreElements(); System.out.println(String.valueOf(String.valueOf((new StringBuffer(">> ")).append(parameter).append("=").append(value)))))
56              {
57                  parameter = (String)parameters.nextElement();
58                  value = request.getParameter(parameter);
59              }
60  
61          }
62          catch(Exception e)
63          {
64              e.printStackTrace();
65          }
66      }
67  
68      public String handleDefault()
69          throws HttpPresentationException
70      {
71          setAboutURI();
72          return showPage();
73      }
74  
75      public String handleSort()
76          throws HttpPresentationException
77      {
78          setAboutURI();
79          HttpPresentationRequest request = getComms().request;
80          try
81          {
82              showParams();
83          }
84          catch(Exception e)
85          {
86              e.printStackTrace();
87          }
88          return showPage();
89      }
90  
91      public String handleRemove()
92          throws HttpPresentationException
93      {
94          setAboutURI();
95          HttpPresentationRequest request = getComms().request;
96          try
97          {
98              showParams();
99          }
100         catch(Exception e)
101         {
102             e.printStackTrace();
103         }
104         return showPage();
105     }
106 
107     public String handleUp()
108         throws HttpPresentationException
109     {
110         setAboutURI();
111         HttpPresentationRequest request = getComms().request;
112         try
113         {
114             showParams();
115         }
116         catch(Exception e)
117         {
118             e.printStackTrace();
119         }
120         return showPage();
121     }
122 
123     public String handleDown()
124         throws HttpPresentationException
125     {
126         setAboutURI();
127         HttpPresentationRequest request = getComms().request;
128         try
129         {
130             showParams();
131         }
132         catch(Exception e)
133         {
134             e.printStackTrace();
135         }
136         return showPage();
137     }
138 
139     public String handleCreateSequence()
140         throws HttpPresentationException
141     {
142         setAboutURI();
143         HttpPresentationRequest request = getComms().request;
144         try
145         {
146             SessionData sd = SessionData.getCurrentSession();
147             showParams();
148         }
149         catch(Exception e)
150         {
151             e.printStackTrace();
152         }
153         return showPage();
154     }
155 
156     public String showPage()
157     {
158         SequenceWizardHTML page = new SequenceWizardHTML();
159         HTMLAnchorElement aboutURIAnchor = page.getElementAboutURI();
160         page.getElementAboutURI1().setValue(Tools.URItoID(aboutURI));
161         page.getElementAboutURI2().setValue(Tools.URItoID(aboutURI));
162         page.getElementCreateSequence().setHref("SequenceWizard.po?event=createSequence&aboutURI=".concat(String.valueOf(String.valueOf(Tools.URItoID(aboutURI)))));
163         page.setTextAboutURI(aboutURI);
164         aboutURIAnchor.setHref("Content.po?aboutURI=".concat(String.valueOf(String.valueOf(Tools.URItoID(aboutURI)))));
165         page.setTextAboutTitle(getTitle());
166         page.setTextAboutType(getType());
167         return page.toDocument();
168     }
169 
170     private void setAboutURI()
171     {
172         if(aboutURI != null)
173             return;
174         try
175         {
176             aboutURI = getComms().request.getParameter("aboutURI");
177             if(aboutURI == null)
178                 aboutURI = getSessionData().getAboutURI();
179             if(aboutURI != null)
180                 aboutURI = Tools.IDtoURI(aboutURI);
181         }
182         catch(Exception e)
183         {
184             e.printStackTrace();
185         }
186     }
187 
188     public String getTitle()
189     {
190         Resource resource = SessionData.getCurrentSession().getStatementPool().getResource(aboutURI);
191         if(resource != null)
192             return resource.getTitle();
193         else
194             return "<untitled>";
195     }
196 
197     public String getType()
198     {
199         Resource resource = SessionData.getCurrentSession().getStatementPool().getResource(aboutURI);
200         if(resource != null)
201             return resource.getType();
202         else
203             return "";
204     }
205 
206     private String aboutURI;
207 }