Module names and descriptions + some more styling

Sun, 08 Apr 2018 15:34:11 +0200

author
Mike Becker <universe@uap-core.de>
date
Sun, 08 Apr 2018 15:34:11 +0200
changeset 26
65d5a0ca49ae
parent 25
559da0ee9bb7
child 27
1f2a96efa69f

Module names and descriptions + some more styling

src/java/de/uapcore/lightpit/entities/Module.java file | annotate | diff | comparison | revisions
src/java/de/uapcore/lightpit/entities/ModuleDao.java file | annotate | diff | comparison | revisions
src/java/de/uapcore/lightpit/entities/User.java file | annotate | diff | comparison | revisions
src/java/de/uapcore/lightpit/entities/UserDao.java file | annotate | diff | comparison | revisions
src/java/de/uapcore/lightpit/resources/localization/home.properties file | annotate | diff | comparison | revisions
src/java/de/uapcore/lightpit/resources/localization/home_de.properties file | annotate | diff | comparison | revisions
src/java/de/uapcore/lightpit/resources/localization/language.properties file | annotate | diff | comparison | revisions
src/java/de/uapcore/lightpit/resources/localization/language_de.properties file | annotate | diff | comparison | revisions
src/java/de/uapcore/lightpit/resources/localization/modmgmt.properties file | annotate | diff | comparison | revisions
src/java/de/uapcore/lightpit/resources/localization/modmgmt_de.properties file | annotate | diff | comparison | revisions
src/java/de/uapcore/lightpit/resources/localization/versions.properties file | annotate | diff | comparison | revisions
src/java/de/uapcore/lightpit/resources/localization/versions_de.properties file | annotate | diff | comparison | revisions
web/WEB-INF/dynamic_fragments/modules.jsp file | annotate | diff | comparison | revisions
web/lightpit.css file | annotate | diff | comparison | revisions
--- a/src/java/de/uapcore/lightpit/entities/Module.java	Sun Apr 08 14:41:10 2018 +0200
+++ b/src/java/de/uapcore/lightpit/entities/Module.java	Sun Apr 08 15:34:11 2018 +0200
@@ -30,7 +30,7 @@
 
 import de.uapcore.lightpit.LightPITModule;
 
-public class Module {
+public final class Module {
     private int modID;
     private String classname;
     private boolean visible;
--- a/src/java/de/uapcore/lightpit/entities/ModuleDao.java	Sun Apr 08 14:41:10 2018 +0200
+++ b/src/java/de/uapcore/lightpit/entities/ModuleDao.java	Sun Apr 08 15:34:11 2018 +0200
@@ -43,6 +43,19 @@
 public abstract class ModuleDao {
     
     /**
+     * Maps database columns to POJO fields.
+     * @param result the database result set
+     * @param mod the POJO
+     * @throws SQLException 
+     */
+    protected void mapColumns(ResultSet result, Module mod) throws SQLException {
+        mod.setModID(result.getInt("modid"));
+        mod.setClassname(result.getString("classname"));
+        mod.setVisible(result.getBoolean("visible"));
+    }
+            
+    
+    /**
      * Must return a prepared statement for a single object query with the specified properties.
      * 
      * <ul>
@@ -136,9 +149,7 @@
                 ResultSet result = stmt.executeQuery("SELECT * FROM lpitcore_module")) {
             while (result.next()) {
                 final Module mod = new Module();
-                mod.setModID(result.getInt("modid"));
-                mod.setClassname(result.getString("classname"));
-                mod.setVisible(result.getBoolean("visible"));
+                mapColumns(result, mod);
                 list.add(mod);
             }
         }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java/de/uapcore/lightpit/entities/User.java	Sun Apr 08 15:34:11 2018 +0200
@@ -0,0 +1,92 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ * 
+ * Copyright 2018 Mike Becker. All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ *   1. Redistributions of source code must retain the above copyright
+ *      notice, this list of conditions and the following disclaimer.
+ *
+ *   2. Redistributions in binary form must reproduce the above copyright
+ *      notice, this list of conditions and the following disclaimer in the
+ *      documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ * 
+ */
+package de.uapcore.lightpit.entities;
+
+import java.util.Optional;
+
+public final class User {
+    
+    public static final int ANONYMOUS_USERID = -1;
+    
+    private int userID;
+    private String username;
+    private Optional<String> givenname;
+    private Optional<String> lastname;
+
+    public int getUserID() {
+        return userID;
+    }
+
+    public void setUserID(int userID) {
+        this.userID = userID;
+    }
+
+    public String getUsername() {
+        return username;
+    }
+
+    public void setUsername(String username) {
+        this.username = username;
+    }
+
+    public Optional<String> getGivenname() {
+        return givenname;
+    }
+
+    public void setGivenname(Optional<String> givenname) {
+        this.givenname = givenname;
+    }
+
+    public Optional<String> getLastname() {
+        return lastname;
+    }
+
+    public void setLastname(Optional<String> lastname) {
+        this.lastname = lastname;
+    }
+
+    @Override
+    public int hashCode() {
+        int hash = 3;
+        hash = 41 * hash + this.userID;
+        return hash;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj == null || getClass() != obj.getClass()) {
+            return false;
+        } else {
+            return this.userID == ((User) obj).userID;
+        }
+    }    
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java/de/uapcore/lightpit/entities/UserDao.java	Sun Apr 08 15:34:11 2018 +0200
@@ -0,0 +1,77 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ * 
+ * Copyright 2018 Mike Becker. All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ *   1. Redistributions of source code must retain the above copyright
+ *      notice, this list of conditions and the following disclaimer.
+ *
+ *   2. Redistributions in binary form must reproduce the above copyright
+ *      notice, this list of conditions and the following disclaimer in the
+ *      documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ * 
+ */
+package de.uapcore.lightpit.entities;
+
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Optional;
+
+public abstract class UserDao {
+    
+    /**
+     * Maps SQL columns to POJO fields.
+     * @param result the database result set
+     * @param user the POJO
+     * @throws SQLException 
+     */
+    protected void mapColumns(ResultSet result, User user) throws SQLException {
+        user.setUserID(result.getInt("userid"));
+        user.setUsername(result.getString("username"));
+        user.setGivenname(Optional.ofNullable(result.getString("givenname")));
+        user.setLastname(Optional.ofNullable(result.getString("lastname"))); 
+    }
+
+    /**
+     * Returns a list of all users ordered by their username.
+     * 
+     * Does not return reserved system users with negative user IDs.
+     * 
+     * @param conn the connection to use
+     * @return a list of all users
+     * @throws SQLException 
+     */
+    public List<User> listAll(Connection conn) throws SQLException {
+        List<User> list = new ArrayList<>();
+        try (
+                Statement stmt = conn.createStatement();
+                ResultSet result = stmt.executeQuery(
+                        "SELECT * FROM lpitcore_user WHERE userid >= 0 ORDER BY username")) {
+            while (result.next()) {
+                final User user = new User();
+                mapColumns(result, user);
+                list.add(user);
+            }
+        }
+        return list;
+    }
+}
--- a/src/java/de/uapcore/lightpit/resources/localization/home.properties	Sun Apr 08 14:41:10 2018 +0200
+++ b/src/java/de/uapcore/lightpit/resources/localization/home.properties	Sun Apr 08 15:34:11 2018 +0200
@@ -21,4 +21,6 @@
 # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
 
+name = Home Page
+description = The default page that is displayed when visiting the site.
 menuLabel = Home
--- a/src/java/de/uapcore/lightpit/resources/localization/home_de.properties	Sun Apr 08 14:41:10 2018 +0200
+++ b/src/java/de/uapcore/lightpit/resources/localization/home_de.properties	Sun Apr 08 15:34:11 2018 +0200
@@ -21,4 +21,6 @@
 # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
 
+name = Startseite
+description = Die Seite, die dem Benutzer standardm\u00e4\u00dfig beim Besuch angezeigt wird.
 menuLabel = Startseite
--- a/src/java/de/uapcore/lightpit/resources/localization/language.properties	Sun Apr 08 14:41:10 2018 +0200
+++ b/src/java/de/uapcore/lightpit/resources/localization/language.properties	Sun Apr 08 15:34:11 2018 +0200
@@ -21,7 +21,10 @@
 # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
 
+name = Language Selector
+description = Where the user can choose his / her language setting.
 menuLabel = Languages
+
 submit = Switch language
 browserLanguage = Browser language
 browserLanguageNotAvailable = Browser language not available.
--- a/src/java/de/uapcore/lightpit/resources/localization/language_de.properties	Sun Apr 08 14:41:10 2018 +0200
+++ b/src/java/de/uapcore/lightpit/resources/localization/language_de.properties	Sun Apr 08 15:34:11 2018 +0200
@@ -21,7 +21,11 @@
 # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
 
+name = Sprachauswahl
+description = Hier kann der Benutzer die Sprache f\u00fcr die Website ausw\u00e4hlen.
+
 menuLabel = Sprache
+
 submit = Sprache ausw\u00e4hlen
 browserLanguage = Browsersprache
 browserLanguageNotAvailable = Browsersprache nicht verf\u00fcgbar.
--- a/src/java/de/uapcore/lightpit/resources/localization/modmgmt.properties	Sun Apr 08 14:41:10 2018 +0200
+++ b/src/java/de/uapcore/lightpit/resources/localization/modmgmt.properties	Sun Apr 08 15:34:11 2018 +0200
@@ -21,4 +21,16 @@
 # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
 
+name = Module Management
+description = Configure the visible LightPIT modules and the required access powers.
 menuLabel = Modules
+
+section.modlist.title = List of Modules
+
+caption.module = Module
+caption.path = Path
+caption.desc = Description
+caption.active = Active
+caption.class = Class
+caption.bundle = Resource Bundle
+
--- a/src/java/de/uapcore/lightpit/resources/localization/modmgmt_de.properties	Sun Apr 08 14:41:10 2018 +0200
+++ b/src/java/de/uapcore/lightpit/resources/localization/modmgmt_de.properties	Sun Apr 08 15:34:11 2018 +0200
@@ -21,4 +21,15 @@
 # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
 
+name = Modulverwaltung
+description = Konfiguration der sichtbaren LightPIT Module und deren Zugriffsrechte.
 menuLabel = Module
+
+section.modlist.title = Liste der Module
+
+caption.module = Modul
+caption.path = Pfad
+caption.desc = Beschreibung
+caption.active = Aktiv
+caption.class = Klasse
+caption.bundle = Ressourcen-Datei
--- a/src/java/de/uapcore/lightpit/resources/localization/versions.properties	Sun Apr 08 14:41:10 2018 +0200
+++ b/src/java/de/uapcore/lightpit/resources/localization/versions.properties	Sun Apr 08 15:34:11 2018 +0200
@@ -21,4 +21,6 @@
 # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
 
+name = Version Management
+description = Allows the configuration of versions and milestones within your project.
 menuLabel = Versions
--- a/src/java/de/uapcore/lightpit/resources/localization/versions_de.properties	Sun Apr 08 14:41:10 2018 +0200
+++ b/src/java/de/uapcore/lightpit/resources/localization/versions_de.properties	Sun Apr 08 15:34:11 2018 +0200
@@ -21,4 +21,6 @@
 # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
 
+name = Versionsverwaltung
+description = Erlaubt die Konfiguration von Versionen und Meilensteinen im Projekt.
 menuLabel = Versionen
--- a/web/WEB-INF/dynamic_fragments/modules.jsp	Sun Apr 08 14:41:10 2018 +0200
+++ b/web/WEB-INF/dynamic_fragments/modules.jsp	Sun Apr 08 15:34:11 2018 +0200
@@ -29,24 +29,26 @@
 <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
 <%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
 
-<%-- TODO: a lot of work --%>
-<table>
+<h2><fmt:message key="section.modlist.title"/></h2>
+<table class="datatable">
     <tr>
-        <th>Module</th>
-        <th>Path</th>
-        <th>Description</th>
-        <th>Active</th>
-        <th>Class</th>
-        <th>Resource Bundle</th>
+        <th class="hcenter"><fmt:message key="caption.active" /></th>
+        <th><fmt:message key="caption.module" /></th>
+        <th><fmt:message key="caption.path" /></th>
+        <th><fmt:message key="caption.desc" /></th>
+        <th><fmt:message key="caption.class" /></th>
+        <th><fmt:message key="caption.bundle" /></th>
     </tr>
     <c:forEach items="${modules}" var="module">
         <tr>
-            <td>${module.annotatedInfos.nameKey}</td>
-            <td>${module.annotatedInfos.modulePath}</td>
-            <td>${module.annotatedInfos.descKey}</td>
-            <td align="center">${module.visible}</td>
-            <td>${module.classname}</td>
-            <td>${module.annotatedInfos.bundleBaseName}</td>
+            <td class="hcenter">${module.visible}</td>
+            <fmt:bundle basename="${module.annotatedInfos.bundleBaseName}">
+            <td class="nowrap"><fmt:message key="${module.annotatedInfos.nameKey}" /></td>
+            <td>/${module.annotatedInfos.modulePath}</td>
+            <td><fmt:message key="${module.annotatedInfos.descKey}" /></td>
+            <td class="smalltext">${module.classname}</td>
+            <td class="smalltext">${module.annotatedInfos.bundleBaseName}</td>
+            </fmt:bundle>
         </tr>
     </c:forEach>
 </table>
\ No newline at end of file
--- a/web/lightpit.css	Sun Apr 08 14:41:10 2018 +0200
+++ b/web/lightpit.css	Sun Apr 08 15:34:11 2018 +0200
@@ -33,7 +33,7 @@
 
 body {
     background: white;
-    font-family: sans-serif;
+    font-family: serif;
     
     border-color: #505050;
     border-style: solid;
@@ -42,6 +42,10 @@
     color: #1c202e;
 }
 
+h1, h2, h3, h4, #mainMenu, #subMenu {
+    font-family: sans-serif;
+}
+
 a {
     color: #3060f8;
     text-decoration: none;
@@ -52,7 +56,7 @@
     display: flex;
     flex-flow: row wrap;
     background: #f0f0f5;
-    font-size: large;
+    font-size: larger;
 }
 
 #subMenu {
@@ -82,26 +86,42 @@
     padding: 1em;
 }
 
-table {
+th {
+    text-align: left;
+}
+
+table.datatable {
+    width: 100%;
     border-style: solid;
     border-width: 1pt;
     border-color: black;
     border-collapse: collapse;
 }
 
-th {
-    text-align: left;
+table.datatable th {
     font-weight: bold;
     background: lightsteelblue;
 }
 
-th, td {
+table.datatable th, table.datatable td {
     border-style: solid;
     border-width: 1pt;
     border-color: black;
     padding: .4em;
 }
 
-tr:nth-child(2n) {
+table.datatable tr:nth-child(2n) {
     background: lightblue;
 }
+
+.hcenter {
+    text-align: center;
+}
+
+.smalltext {
+    font-size: smaller;
+}
+
+.nowrap {
+    white-space: nowrap;
+}
\ No newline at end of file

mercurial