View Javadoc

1   /*
2    *  Copyright 2004 University of Hannover
3    *
4    *  Licensed under the Apache License, Version 2.0 (the "License");
5    *  you may not use this file except in compliance with the License.
6    *  You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   *  Unless required by applicable law or agreed to in writing, software
11   *  distributed under the License is distributed on an "AS IS" BASIS,
12   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   *  See the License for the specific language governing permissions and
14   *  limitations under the License.
15   */
16  package olr.presentation;
17  
18  import java.util.List;
19  
20  import olr.rdf.Resource;
21  import olr.rdf.Tools;
22  import olr.viewer.CourseViewer;
23  import olr.viewer.ModelViewerRow;
24  
25  import org.w3c.dom.html.HTMLAnchorElement;
26  import org.w3c.dom.html.HTMLElement;
27  import org.w3c.dom.html.HTMLImageElement;
28  import org.w3c.dom.html.HTMLTableElement;
29  import org.w3c.dom.html.HTMLTableRowElement;
30  
31  import com.lutris.appserver.server.httpPresentation.HttpPresentationException;
32  
33  /***
34   * @version $Id: TBLStructure1.java,v 1.1 2004/08/03 08:33:53 roku Exp $
35   */
36  public class TBLStructure1 extends SecureHttpPresentation {
37  
38      public String handleDefault() throws HttpPresentationException {
39          return showPage();
40      }
41  
42      public String showPage() {
43          TBLStructureHTML page = new TBLStructureHTML();
44          HTMLTableElement table1 = page.getElementGenerate();
45          HTMLTableElement table = page.getElementTable();
46          HTMLAnchorElement basisRow = page.getElementBasisRow();
47          HTMLAnchorElement fragenRow = page.getElementFragenRow();
48          HTMLAnchorElement weiterRow = page.getElementWeiterRow();
49          HTMLAnchorElement uebungRow = page.getElementUebungRow();
50          HTMLImageElement basis = page.getElementBasis();
51          HTMLImageElement fragen = page.getElementFragen();
52          HTMLImageElement weiter = page.getElementWeiter();
53          HTMLImageElement uebung = page.getElementUebung();
54          HTMLTableRowElement courseRow = page.getElementCourseRow();
55          HTMLTableRowElement headLineRow = page.getElementHeadLineRow();
56  
57          HTMLElement headline = page.getElementHeadline();
58  
59          try {
60              CourseViewer courseViewer = getSessionData().getCourseViewers().getActiveViewer();
61              List rows = courseViewer.getModelRows();
62              String modifiedURI = getComms().request.getParameter("modifiedURI");
63              if (modifiedURI != null)
64                  getSessionData().getCourseViewers().getActiveViewer().updateResource(
65                          Tools.IDtoURI(modifiedURI));
66  
67              for (int rowNr = 0; rowNr < rows.size(); rowNr++) {
68  
69                  ModelViewerRow row = (ModelViewerRow) rows.get(rowNr);
70                  courseViewer.expandAllResource(rowNr);
71                  Resource resource = getSessionData().getStatementPool().getResource(
72                          row.getResource());
73                  if (row.getIndent() == 0 && !row.isPredicate()) {
74  
75                      String title = resource.getTitle();
76                      page.setTextCoursename(title);
77                      table1.appendChild(courseRow.cloneNode(true));
78                      continue;
79                  }
80  
81                  if (row.getIndent() == 4) {
82                      page.setTextHeadline(row.getTitle());
83                      String prop = "";
84                      Resource topic = getSessionData().getStatementPool().getResource(
85                              row.getResource());
86                      Resource property = getSessionData().getStatementPool().getResource(
87                              "tbl:hasBasis");
88                      if (property != null)
89                          prop = property.getName();
90                      System.out.println(prop);
91                      List objects = topic.getObjects(prop);
92                      if (objects.size() > 0) {
93                          String name = getSessionData().getStatementPool().getResource(
94                                  objects.get(0).toString()).getTitle();
95                          basisRow.setAttribute("href",
96                                  "Index.po?event=Create&resource=name&predicate=hasBasisElement");
97                      }
98  
99                      basis.setSrc("media/basisOff.gif");
100                     fragen.setSrc("media/fragenOff.gif");
101                     weiter.setSrc("media/weiterOff.gif");
102                     uebung.setSrc("media/aufgabenOff.gif");
103                     table.appendChild(headLineRow.cloneNode(true));
104 
105                 }
106             }
107 
108         } catch (Exception e) {
109             e.printStackTrace();
110         }
111         courseRow.getParentNode().removeChild(courseRow);
112         headLineRow.getParentNode().removeChild(headLineRow);
113 
114         return page.toDocument();
115     }
116 
117     private final String THIS_HTML = "Structure.po";
118 
119     private final String CONTENT_HTML = "Content.po";
120 
121 }
122