Skip to content
Snippets Groups Projects
Commit 18407941 authored by Julian Dehne's avatar Julian Dehne
Browse files

Finished Munschkin Example

parent ec9fbd63
No related branches found
No related tags found
No related merge requests found
Showing
with 537 additions and 105 deletions
......@@ -33,3 +33,7 @@
/.idea/workspace.xml
/.idea/workspace.xml
/.idea/workspace.xml
/gemeinsamforschen/.idea/*
/.idea/workspace.xml
/gemeinsamforschen/out/*
/gemeinsamforschen/target/*
......@@ -88,17 +88,17 @@
</file>
<file leaf-file-name="fltrail.users" pinned="false" current-in-tab="false">
<entry file="dbDummy://dbtable:/fc3764cf/14340c2c-ac4b-492f-ac4f-18c0853598a8/fltrail.users">
<provider selected="true" editor-type-id="com.intellij.database.editor.DatabaseTableFileEditorProvider">
<state>
<filtering enabled="true" />
</state>
</provider>
<provider editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0">
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding />
</state>
</provider>
<provider selected="true" editor-type-id="com.intellij.database.editor.DatabaseTableFileEditorProvider">
<state>
<filtering enabled="true" />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="config.js" pinned="false" current-in-tab="false">
......@@ -137,10 +137,10 @@
</provider>
</entry>
</file>
<file leaf-file-name="showProjects.js" pinned="false" current-in-tab="false">
<file leaf-file-name="showProjects.js" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/studentview/assets/js/showProjects.js">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0">
<state vertical-scroll-proportion="0.54735154">
<caret line="31" column="38" selection-start-line="31" selection-start-column="38" selection-end-line="31" selection-end-column="38" />
<folding />
</state>
......@@ -151,9 +151,9 @@
<entry file="file://$PROJECT_DIR$/studentview/pages/preferences.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0">
<caret line="111" column="0" selection-start-line="111" selection-start-column="0" selection-end-line="111" selection-end-column="0" />
<caret line="112" column="0" selection-start-line="112" selection-start-column="0" selection-end-line="112" selection-end-column="0" />
<folding>
<marker date="1523351341227" expanded="true" signature="182:256" placeholder="SELECT (`id`... projects" />
<marker date="1524568548412" expanded="true" signature="182:256" placeholder="SELECT (`id`... projects" />
</folding>
</state>
</provider>
......@@ -163,25 +163,15 @@
<entry file="file://$PROJECT_DIR$/studentview/assets/js/overview.js">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0">
<caret line="68" column="38" selection-start-line="68" selection-start-column="38" selection-end-line="68" selection-end-column="38" />
<caret line="66" column="38" selection-start-line="66" selection-start-column="38" selection-end-line="66" selection-end-column="38" />
<folding>
<marker date="1523359889383" expanded="true" signature="872:1018" placeholder="..." />
<marker date="1524568548402" expanded="true" signature="872:1018" placeholder="..." />
</folding>
</state>
</provider>
</entry>
</file>
<file leaf-file-name="projects.php" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/studentview/pages/projects.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0">
<caret line="125" column="34" selection-start-line="125" selection-start-column="34" selection-end-line="125" selection-end-column="34" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="console.sql" pinned="false" current-in-tab="true">
<file leaf-file-name="console.sql" pinned="false" current-in-tab="false">
<entry file="file://$APPLICATION_CONFIG_DIR$/consoles/db/85944065-0254-4a61-b256-d3493cdb0a4f/console.sql">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0">
......@@ -266,10 +256,10 @@
<component name="PhpWebServerValidation" path_to_validation_script="C:\dev\amp\htdocs\" selected_validation_type="LOCAL" web_path_to_validation_script="http://127.0.0.1/" />
<component name="PhpWorkspaceProjectConfiguration" backward_compatibility_performed="true" interpreter_name="PHP" />
<component name="ProjectFrameBounds">
<option name="x" value="1" />
<option name="y" value="1" />
<option name="width" value="2135" />
<option name="height" value="1078" />
<option name="x" value="-9" />
<option name="y" value="-9" />
<option name="width" value="2578" />
<option name="height" value="1410" />
</component>
<component name="ProjectLevelVcsManager" settingsEditedManually="false">
<OptionsSetting value="true" id="Add" />
......@@ -296,7 +286,6 @@
<foldersAlwaysOnTop value="true" />
</navigator>
<panes>
<pane id="Scratches" />
<pane id="ProjectPane">
<subPane>
<PATH>
......@@ -305,8 +294,33 @@
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
</PATH_ELEMENT>
</PATH>
<PATH>
<PATH_ELEMENT>
<option name="myItemId" value="fltrail" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="fltrail" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
</PATH>
<PATH>
<PATH_ELEMENT>
<option name="myItemId" value="fltrail" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="fltrail" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="gemeinsamforschen" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
</PATH>
</subPane>
</pane>
<pane id="Scratches" />
<pane id="Scope" />
<pane id="PackagesPane" />
</panes>
......@@ -829,15 +843,16 @@
<updated>1522142632208</updated>
<workItem from="1522142635858" duration="32910000" />
<workItem from="1522918322507" duration="37691000" />
<workItem from="1524484938943" duration="2746000" />
<workItem from="1524484938943" duration="3356000" />
<workItem from="1524585513713" duration="57000" />
</task>
<servers />
</component>
<component name="TimeTrackingManager">
<option name="totallyTimeSpent" value="73347000" />
<option name="totallyTimeSpent" value="74014000" />
</component>
<component name="ToolWindowManager">
<frame x="1" y="1" width="2135" height="1078" extended-state="1" />
<frame x="-9" y="-9" width="2578" height="1410" extended-state="6" />
<editor active="false" />
<layout>
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
......@@ -850,8 +865,8 @@
<window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="9" side_tool="false" content_ui="tabs" />
<window_info id="Remote Host" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="8" side_tool="false" content_ui="tabs" />
<window_info id="Designer" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
<window_info id="Project" active="true" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.29428437" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
<window_info id="Database" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.19036372" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
<window_info id="Project" active="true" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.24335937" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
<window_info id="Database" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.15742187" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.331509" sideWeight="0.52265626" order="3" side_tool="false" content_ui="tabs" />
......@@ -900,6 +915,14 @@
<option name="FILTER_TARGETS" value="false" />
</component>
<component name="editorHistoryManager">
<entry file="file://$APPLICATION_CONFIG_DIR$/consoles/db/85944065-0254-4a61-b256-d3493cdb0a4f/console.sql">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0">
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/../../phpMyAdmin/server_databases.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.15742397">
......@@ -989,16 +1012,16 @@
</provider>
</entry>
<entry file="dbDummy://dbtable:/fc3764cf/14340c2c-ac4b-492f-ac4f-18c0853598a8/fltrail.tags">
<provider selected="true" editor-type-id="com.intellij.database.editor.DatabaseTableFileEditorProvider">
<state>
<filtering enabled="true" />
</state>
</provider>
<provider editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0">
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
</state>
</provider>
<provider selected="true" editor-type-id="com.intellij.database.editor.DatabaseTableFileEditorProvider">
<state>
<filtering enabled="true" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/studentview/assets/js/register.js">
<provider selected="true" editor-type-id="text-editor">
......@@ -1070,14 +1093,6 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/studentview/assets/egal.html">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0">
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/studentview/database/createUser.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-4.967742">
......@@ -1149,16 +1164,16 @@
</provider>
</entry>
<entry file="dbDummy://dbtable:/fc3764cf/14340c2c-ac4b-492f-ac4f-18c0853598a8/fltrail.projects">
<provider selected="true" editor-type-id="com.intellij.database.editor.DatabaseTableFileEditorProvider">
<state>
<filtering enabled="true" />
</state>
</provider>
<provider editor-type-id="text-editor">
<state vertical-scroll-proportion="-0.0">
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
</state>
</provider>
<provider selected="true" editor-type-id="com.intellij.database.editor.DatabaseTableFileEditorProvider">
<state>
<filtering enabled="true" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/studentview/assets/js/createPreferences.js">
<provider selected="true" editor-type-id="text-editor">
......@@ -1178,6 +1193,7 @@
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-9.741936">
<caret line="19" column="50" selection-start-line="19" selection-start-column="50" selection-end-line="19" selection-end-column="50" />
<folding />
</state>
</provider>
</entry>
......@@ -1222,16 +1238,6 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/studentview/pages/preferences.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0">
<caret line="111" column="0" selection-start-line="111" selection-start-column="0" selection-end-line="111" selection-end-column="0" />
<folding>
<marker date="1523351341227" expanded="true" signature="182:256" placeholder="SELECT (`id`... projects" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/studentview/assets/js/config.js">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0">
......@@ -1242,59 +1248,68 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/studentview/assets/js/showProjects.js">
<provider selected="true" editor-type-id="text-editor">
<entry file="dbDummy://dbtable:/fc3764cf/14340c2c-ac4b-492f-ac4f-18c0853598a8/fltrail.users">
<provider editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0">
<caret line="31" column="38" selection-start-line="31" selection-start-column="38" selection-end-line="31" selection-end-column="38" />
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding />
</state>
</provider>
<provider selected="true" editor-type-id="com.intellij.database.editor.DatabaseTableFileEditorProvider">
<state>
<filtering enabled="true" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/studentview/pages/projects.php">
<entry file="file://$PROJECT_DIR$/studentview/database/config.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0">
<caret line="125" column="34" selection-start-line="125" selection-start-column="34" selection-end-line="125" selection-end-column="34" />
<folding />
<caret line="8" column="0" selection-start-line="8" selection-start-column="0" selection-end-line="8" selection-end-column="0" />
<folding>
<element signature="e#6#92#0#PHP" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="dbDummy://dbtable:/fc3764cf/14340c2c-ac4b-492f-ac4f-18c0853598a8/fltrail.users">
<provider selected="true" editor-type-id="com.intellij.database.editor.DatabaseTableFileEditorProvider">
<state>
<filtering enabled="true" />
</state>
</provider>
<provider editor-type-id="text-editor">
<entry file="file://$APPLICATION_CONFIG_DIR$/consoles/db/85944065-0254-4a61-b256-d3493cdb0a4f/console.sql">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0">
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/studentview/database/config.php">
<entry file="file://$PROJECT_DIR$/studentview/pages/projects.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.56131685">
<caret line="125" column="34" selection-start-line="125" selection-start-column="34" selection-end-line="125" selection-end-column="34" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/studentview/assets/js/overview.js">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0">
<caret line="8" column="0" selection-start-line="8" selection-start-column="0" selection-end-line="8" selection-end-column="0" />
<caret line="66" column="38" selection-start-line="66" selection-start-column="38" selection-end-line="66" selection-end-column="38" />
<folding>
<element signature="e#6#92#0#PHP" expanded="true" />
<marker date="1524568548402" expanded="true" signature="872:1018" placeholder="..." />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/studentview/assets/js/overview.js">
<entry file="file://$PROJECT_DIR$/studentview/pages/preferences.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0">
<caret line="68" column="38" selection-start-line="68" selection-start-column="38" selection-end-line="68" selection-end-column="38" />
<caret line="112" column="0" selection-start-line="112" selection-start-column="0" selection-end-line="112" selection-end-column="0" />
<folding>
<marker date="1523359889383" expanded="true" signature="872:1018" placeholder="..." />
<marker date="1524568548412" expanded="true" signature="182:256" placeholder="SELECT (`id`... projects" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$APPLICATION_CONFIG_DIR$/consoles/db/85944065-0254-4a61-b256-d3493cdb0a4f/console.sql">
<entry file="file://$PROJECT_DIR$/studentview/assets/js/showProjects.js">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0">
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<state vertical-scroll-proportion="0.54735154">
<caret line="31" column="38" selection-start-line="31" selection-start-column="38" selection-end-line="31" selection-end-column="38" />
<folding />
</state>
</provider>
......
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
</web-app>
\ No newline at end of file
......@@ -6,7 +6,77 @@
<groupId>groupId</groupId>
<artifactId>gemeinsamforschen</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<properties>
<org.springframework.version>3.2.4.RELEASE</org.springframework.version>
<jersey.version>2.6</jersey.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.16</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.6</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<scope>test</scope>
</dependency>
<!-- Hier kommen ganz viele Jersey Sachen -->
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet</artifactId>
<version>${jersey.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-grizzly2-servlet</artifactId>
<version>${jersey.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.glassfish.jersey.media/jersey-media-multipart -->
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-multipart</artifactId>
<version>2.26</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.4.5</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.4.5</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.4.5</version>
</dependency>
</dependencies>
</project>
\ No newline at end of file
package unipotsdam.gf.config;
import org.apache.log4j.Logger;
import org.glassfish.jersey.server.ResourceConfig;
import javax.ws.rs.ApplicationPath;
@ApplicationPath("/")
public class MyRESTAPIApp extends ResourceConfig {
private Logger logger = org.apache.log4j.LogManager
.getLogger(MyRESTAPIApp.class);
public MyRESTAPIApp() {
packages("unipotsdam.gf.service");
register(org.glassfish.jersey.filter.LoggingFilter.class);
property(
"jersey.config.beanValidation.enableOutputValidationErrorEntity.server",
"true");
logger.info("Initiated Logger");
logger.info("Initiated Server");
}
}
\ No newline at end of file
package unipotsdam.gf.controller;
import unipotsdam.gf.model.Munschkin;
import java.sql.*;
/**
* Created by dehne on 24.04.2018.
*/
public class MunschkinLoader {
static final String JDBC_DRIVER = "com.mysql.jdbc.Driver";
static final String DB_URL = "jdbc:mysql://localhost";
// Database credentials
static final String USER = "root2";
static final String PASS = "voyager2";
// Es gibt natürlich auch libraries, die den Datenbankzugriff einfacher gestalten. Ziel soll sein, dass alle
// die Basics können.
public Munschkin loadMunschkin(int id) {
Munschkin munschkin = new Munschkin();
// JDBC driver name and database URL
Connection conn = null;
Statement stmt = null;
try {
//STEP 2: Register JDBC driver
Class.forName("com.mysql.jdbc.Driver");
//STEP 3: Open a connection
System.out.println("Connecting to database...");
conn = DriverManager.getConnection(DB_URL, USER, PASS);
//STEP 4: Execute a query
System.out.println("Creating statement...");
stmt = conn.createStatement();
String sql;
sql = "Use munschkins;";
System.out.println(sql);
ResultSet rs = stmt.executeQuery(sql);
sql = "SELECT MunschkinId, LastName, FirstName, BadThings, Strength FROM Munschkins WHERE " +
"MunschkinId="+id+";";
rs = stmt.executeQuery(sql);
//STEP 5: Extract data from result set
while (rs.next()) {
//Retrieve by column name
munschkin.setMunschkinId(rs.getInt("MunschkinId"));
munschkin.setBadThings(rs.getString("BadThings"));
munschkin.setLastName(rs.getString("LastName"));
munschkin.setFirstName(rs.getString("FirstName"));
munschkin.setStrength(rs.getInt("Strength"));
}
//STEP 6: Clean-up environment
rs.close();
stmt.close();
conn.close();
} catch (SQLException se) {
//Handle errors for JDBC
se.printStackTrace();
} catch (Exception e) {
//Handle errors for Class.forName
e.printStackTrace();
} finally {
//finally block used to close resources
try {
if (stmt != null)
stmt.close();
} catch (SQLException se2) {
}// nothing we can do
try {
if (conn != null)
conn.close();
} catch (SQLException se) {
se.printStackTrace();
}//end finally try
}//end try
return munschkin;
}
}
package unipotsdam.gf.model;
/**
* Created by dehne on 24.04.2018.
*/
public class Munschkin {
private int munschkinId;
private String lastName;
private String firstName;
private String BadThings;
private int strength;
public Munschkin(int munschkinId, String lastName, String firstName, String badThings, int strength) {
this.munschkinId = munschkinId;
this.lastName = lastName;
this.firstName = firstName;
BadThings = badThings;
this.strength = strength;
}
public Munschkin() {
}
public int getMunschkinId() {
return munschkinId;
}
public void setMunschkinId(int munschkinId) {
this.munschkinId = munschkinId;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getBadThings() {
return BadThings;
}
public void setBadThings(String badThings) {
BadThings = badThings;
}
public int getStrength() {
return strength;
}
public void setStrength(int strength) {
this.strength = strength;
}
@Override
public String toString() {
final StringBuilder sb = new StringBuilder("Munschkin{");
sb.append("munschkinId=").append(munschkinId);
sb.append(", lastName='").append(lastName).append('\'');
sb.append(", firstName='").append(firstName).append('\'');
sb.append(", BadThings='").append(BadThings).append('\'');
sb.append(", strength=").append(strength);
sb.append(", badThings='").append(getBadThings()).append('\'');
sb.append('}');
return sb.toString();
}
}
package unipotsdam.gf.service;
/**
* Created by dehne on 24.04.2018.
*/
import unipotsdam.gf.controller.MunschkinLoader;
import unipotsdam.gf.model.Munschkin;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
@Path("/hello")
public class RestyMunschkin {
// This method is called if HTML is request
@GET
@Produces(MediaType.TEXT_HTML)
@Path("/{id}")
public String sayHtmlHello(@PathParam("id") String id) {
MunschkinLoader munschkinLoader = new MunschkinLoader();
Munschkin munschkin = munschkinLoader.loadMunschkin(Integer.parseInt(id));
return "<html> " + "<title>" + "Hello Munschkin" + "</title>" + "<body><h1>" + munschkin
.toString() + "</body></h1>" + "</html> ";
}
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j" debug="true">
<!--
<appender name="fileAppender" class="org.apache.log4j.RollingFileAppender">
<param name="Threshold" value="DEBUG"/>
<param name="File"
value="/opt/up/logs/competence.log"></param>
&lt;!&ndash; <param name="File" value="C:/Users/dehne/Desktop/logs/competecd nce.log" /> &ndash;&gt;
<param name="maxFileSize" value="1MB"/>
<param name="maxBackupIndex" value="5"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d %-5p [%c{1}] %m %n"/>
</layout>
</appender>
-->
<!-- <appender name="rootFileAppender" class="org.apache.log4j.RollingFileAppender">
<param name="Threshold" value="INFO"/>
<param name="File" value="/opt/up/logs/root.log"/>
&lt;!&ndash;<param name="File" value="C:/Users/dehne/Desktop/logs/root.log" />&ndash;&gt;
<param name="maxFileSize" value="1MB"/>
<param name="maxBackupIndex" value="5"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d %-5p [%c{1}] %m %n"/>
</layout>
</appender>-->
<appender name="console" class="org.apache.log4j.ConsoleAppender">
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="[%t]%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n"/>
</layout>
</appender>
<logger name="unipotsdam.gf">
<!--<appender-ref ref="fileAppender"/>-->
<appender-ref ref="console"/>
</logger>
<root>
<appender-ref ref="console"/>
<!--<appender-ref ref="rootFileAppender"/>-->
</root>
</log4j:configuration>
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="WebApp_ID" version="3.0">
<display-name>Gemeinsam Forschen</display-name>
<servlet>
<!--suppress ServletWithoutMappingInspection -->
<servlet-name>rest-server</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>com.sun.jersey.config.property.packages</param-name>
<param-value>unipotsdam.gf</param-value>
</init-param>
<init-param>
<param-name>jersey.config.server.provider.packages</param-name>
<param-value>
unipotsdam.gf
</param-value>
</init-param>
<init-param>
<param-name>com.sun.jersey.api.json.POJOMappingFeature</param-name>
<param-value>true</param-value>
</init-param>
<!-- <init-param>
<param-name>com.sun.jersey.config.feature.DisableWADL</param-name>
<param-value>true</param-value>
</init-param>-->
<load-on-startup>1</load-on-startup>
</servlet>
<filter>
<filter-name>CorsFilter</filter-name>
<filter-class>org.apache.catalina.filters.CorsFilter</filter-class>
<init-param>
<param-name>cors.allowed.origins</param-name>
<param-value>*</param-value>
</init-param>
<init-param>
<param-name>cors.allowed.methods</param-name>
<param-value>GET,DELETE,POST,HEAD,OPTIONS,PUT</param-value>
</init-param>
<init-param>
<param-name>cors.allowed.headers</param-name>
<param-value>
Content-Type,X-Requested-With,accept,Origin,Access-Control-Request-Method,Access-Control-Request-Headers
</param-value>
</init-param>
<init-param>
<param-name>cors.exposed.headers</param-name>
<param-value>Access-Control-Allow-Origin,Access-Control-Allow-Credentials</param-value>
</init-param>
<init-param>
<param-name>cors.support.credentials</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>cors.preflight.maxage</param-name>
<param-value>10</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>CorsFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
</web-app>
use munschkins;
CREATE TABLE IF NOT EXISTS Munschkins (
MunschkinId int,
LastName varchar(255),
......@@ -7,4 +10,5 @@ CREATE TABLE IF NOT EXISTS Munschkins (
);
INSERT INTO `Munschkins` (MunschkinId, LastName, FirstName, BadThings, Strength) values(1, "Thor", "Theodor", "he
will eat your feet", 5);
\ No newline at end of file
will eat your feet", 5);
import unipotsdam.gf.controller.MunschkinLoader;
import unipotsdam.gf.model.Munschkin;
import org.junit.Test;
/**
* Created by dehne on 24.04.2018.
*/
public class MunschkinLoaderTest {
@Test
public void testMunschKinLoader() {
MunschkinLoader m = new MunschkinLoader();
Munschkin loadedM = m.loadMunschkin(1);
assert loadedM != null;
System.out.print(loadedM.toString());
}
}
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
</web-app>
\ No newline at end of file
<html>
<head>
<title>Gemeinsam Forschen</title>
</head>
<body>
Krasse Website
</body>
</html>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment